diff options
Diffstat (limited to 'chart2/source/controller')
284 files changed, 10617 insertions, 9617 deletions
diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx index e5ca33bff4be..9add032de702 100644 --- a/chart2/source/controller/accessibility/AccessibleBase.cxx +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -21,30 +21,26 @@ #include "AccessibleChartShape.hxx" #include <ObjectHierarchy.hxx> #include <ObjectIdentifier.hxx> -#include <chartview/ExplicitValueProvider.hxx> +#include <ChartView.hxx> +#include <ChartController.hxx> #include <com/sun/star/accessibility/AccessibleEventId.hpp> -#include <com/sun/star/accessibility/AccessibleEventObject.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/FillStyle.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <sal/log.hxx> +#include <utility> #include <vcl/svapp.hxx> -#include <comphelper/servicehelper.hxx> #include <cppuhelper/supportsservice.hxx> #include <i18nlangtag/languagetag.hxx> -#include <vcl/unohelp.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/window.hxx> #include <vcl/settings.hxx> #include <o3tl/functional.hxx> #include <o3tl/safeint.hxx> -#include <tools/diagnose_ex.h> -#include <unotools/accessiblestatesethelper.hxx> +#include <comphelper/diagnose_ex.hxx> #include <algorithm> #include <iterator> @@ -66,42 +62,27 @@ namespace chart /** @param bMayHaveChildren is false per default */ AccessibleBase::AccessibleBase( - const AccessibleElementInfo & rAccInfo, + AccessibleElementInfo aAccInfo, bool bMayHaveChildren, bool bAlwaysTransparent /* default: false */ ) : - impl::AccessibleBase_Base( m_aMutex ), - m_bIsDisposed( false ), m_bMayHaveChildren( bMayHaveChildren ), m_bChildrenInitialized( false ), - m_nEventNotifierId(0), - m_xStateSetHelper( new ::utl::AccessibleStateSetHelper() ), - m_aAccInfo( rAccInfo ), + m_nStateSet( 0 ), + m_aAccInfo(std::move( aAccInfo )), m_bAlwaysTransparent( bAlwaysTransparent ), m_bStateSetInitialized( false ) { // initialize some states - OSL_ASSERT( m_xStateSetHelper.is() ); - m_xStateSetHelper->AddState( AccessibleStateType::ENABLED ); - m_xStateSetHelper->AddState( AccessibleStateType::SHOWING ); - m_xStateSetHelper->AddState( AccessibleStateType::VISIBLE ); - m_xStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); - m_xStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); + m_nStateSet |= AccessibleStateType::ENABLED; + m_nStateSet |= AccessibleStateType::SHOWING; + m_nStateSet |= AccessibleStateType::VISIBLE; + m_nStateSet |= AccessibleStateType::SELECTABLE; + m_nStateSet |= AccessibleStateType::FOCUSABLE; } AccessibleBase::~AccessibleBase() { - OSL_ASSERT( m_bIsDisposed ); -} - -bool AccessibleBase::CheckDisposeState( bool bThrowException /* default: true */ ) const -{ - if( bThrowException && - m_bIsDisposed ) - { - throw lang::DisposedException("component has state DEFUNC", - static_cast< uno::XWeak * >( const_cast< AccessibleBase * >( this ))); - } - return m_bIsDisposed; + OSL_ASSERT(!isAlive()); } bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId & rId ) @@ -118,11 +99,11 @@ bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId case EventType::GOT_SELECTION: { AddState( AccessibleStateType::SELECTED ); - BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aEmpty, aSelected); AddState( AccessibleStateType::FOCUSED ); aSelected <<= AccessibleStateType::FOCUSED; - BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty, true ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aEmpty, aSelected); SAL_INFO("chart2.accessibility", "Selection acquired by: " << getAccessibleName()); } @@ -131,11 +112,11 @@ bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId case EventType::LOST_SELECTION: { RemoveState( AccessibleStateType::SELECTED ); - BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aSelected, aEmpty); AddState( AccessibleStateType::FOCUSED ); aSelected <<= AccessibleStateType::FOCUSED; - BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected, true ); + NotifyAccessibleEvent(AccessibleEventId::STATE_CHANGED, aSelected, aEmpty); SAL_INFO("chart2.accessibility", "Selection lost by: " << getAccessibleName()); } break; @@ -148,15 +129,12 @@ bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId ClearableMutexGuard aGuard( m_aMutex ); // make local copy for notification - ChildListVectorType aLocalChildList( m_aChildList ); + std::vector<rtl::Reference<AccessibleBase>> aLocalChildList(m_aChildList); aGuard.clear(); for (auto const& localChild : aLocalChildList) { - // Note: at this place we must be sure to have an AccessibleBase - // object in the UNO reference to XAccessible ! - bStop = (*static_cast< AccessibleBase * > - ( localChild.get() )).NotifyEvent( eEventType, rId ); + bStop = localChild->NotifyEvent(eEventType, rId); if (bStop) break; } @@ -166,18 +144,16 @@ bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId return false; } -void AccessibleBase::AddState( sal_Int16 aState ) +void AccessibleBase::AddState( sal_Int64 aState ) { - CheckDisposeState(); - OSL_ASSERT( m_xStateSetHelper.is() ); - m_xStateSetHelper->AddState( aState ); + ensureAlive(); + m_nStateSet |= aState; } -void AccessibleBase::RemoveState( sal_Int16 aState ) +void AccessibleBase::RemoveState( sal_Int64 aState ) { - CheckDisposeState(); - OSL_ASSERT( m_xStateSetHelper.is() ); - m_xStateSetHelper->RemoveState( aState ); + ensureAlive(); + m_nStateSet &= ~aState; } bool AccessibleBase::UpdateChildren() @@ -185,8 +161,7 @@ bool AccessibleBase::UpdateChildren() bool bMustUpdateChildren = false; { MutexGuard aGuard( m_aMutex ); - if( ! m_bMayHaveChildren || - m_bIsDisposed ) + if (!m_bMayHaveChildren || !isAlive()) return false; bMustUpdateChildren = ( m_bMayHaveChildren && @@ -258,7 +233,7 @@ void AccessibleBase::AddChild( AccessibleBase * pChild ) ClearableMutexGuard aGuard( m_aMutex ); - Reference< XAccessible > xChild( pChild ); + rtl::Reference<AccessibleBase> xChild(pChild); m_aChildList.push_back( xChild ); m_aChildOIDMap[ pChild->GetId() ] = xChild; @@ -267,16 +242,13 @@ void AccessibleBase::AddChild( AccessibleBase * pChild ) if( m_bChildrenInitialized ) { Any aEmpty, aNew; - aNew <<= xChild; + aNew <<= uno::Reference<XAccessible>(xChild); aGuard.clear(); - BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); + NotifyAccessibleEvent(AccessibleEventId::CHILD, aEmpty, aNew); } } -/** in this method we imply that the Reference< XAccessible > elements in the - vector are AccessibleBase objects ! - */ void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) { ClearableMutexGuard aGuard( m_aMutex ); @@ -285,14 +257,13 @@ void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) if( aIt == m_aChildOIDMap.end()) return; - Reference< XAccessible > xChild( aIt->second ); + rtl::Reference<AccessibleBase> xChild(aIt->second); // remove from map m_aChildOIDMap.erase( aIt ); // search child in vector - ChildListVectorType::iterator aVecIter = - std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); + auto aVecIter = std::find(m_aChildList.begin(), m_aChildList.end(), xChild); OSL_ENSURE( aVecIter != m_aChildList.end(), "Inconsistent ChildMap" ); @@ -308,15 +279,14 @@ void AccessibleBase::RemoveChildByOId( const ObjectIdentifier& rOId ) if( bInitialized ) { Any aEmpty, aOld; - aOld <<= xChild; + aOld <<= uno::Reference<XAccessible>(xChild); - BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); + NotifyAccessibleEvent(AccessibleEventId::CHILD, aOld, aEmpty); } // dispose the child - Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); - if( xComp.is()) - xComp->dispose(); + if (xChild.is()) + xChild->dispose(); } awt::Point AccessibleBase::GetUpperLeftOnScreen() const @@ -339,43 +309,12 @@ awt::Point AccessibleBase::GetUpperLeftOnScreen() const return aResult; } -void AccessibleBase::BroadcastAccEvent( - sal_Int16 nId, - const Any & rNew, - const Any & rOld, - bool bSendGlobally ) const -{ - ClearableMutexGuard aGuard( m_aMutex ); - - if ( !m_nEventNotifierId && !bSendGlobally ) - return; - // if we don't have a client id for the notifier, then we don't have listeners, then - // we don't need to notify anything - //except SendGlobally for focus handling? - - // the const cast is needed, because UNO parameters are never const - const AccessibleEventObject aEvent( - const_cast< uno::XWeak * >( static_cast< const uno::XWeak * >( this )), - nId, rNew, rOld ); - - if ( m_nEventNotifierId ) // let the notifier handle this event - ::comphelper::AccessibleEventNotifier::addEvent( m_nEventNotifierId, aEvent ); - - aGuard.clear(); - - // send event to global message queue - if( bSendGlobally ) - { - vcl::unohelper::NotifyAccessibleStateEventGlobally( aEvent ); - } -} - void AccessibleBase::KillAllChildren() { ClearableMutexGuard aGuard( m_aMutex ); // make local copy for notification, and remove all children - ChildListVectorType aLocalChildList; + std::vector<rtl::Reference<AccessibleBase>> aLocalChildList; aLocalChildList.swap( m_aChildList ); m_aChildOIDMap.clear(); @@ -383,16 +322,14 @@ void AccessibleBase::KillAllChildren() // call dispose for all children // and notify listeners - Reference< lang::XComponent > xComp; Any aEmpty, aOld; for (auto const& localChild : aLocalChildList) { - aOld <<= localChild; - BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); + aOld <<= uno::Reference<XAccessible>(localChild); + NotifyAccessibleEvent(AccessibleEventId::CHILD, aOld, aEmpty); - xComp.set(localChild, UNO_QUERY); - if( xComp.is()) - xComp->dispose(); + if (localChild.is()) + localChild->dispose(); } m_bChildrenInitialized = false; } @@ -404,8 +341,7 @@ void AccessibleBase::SetInfo( const AccessibleElementInfo & rNewInfo ) { KillAllChildren(); } - BroadcastAccEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN, uno::Any(), uno::Any(), - true /* global notification */ ); + NotifyAccessibleEvent(AccessibleEventId::INVALIDATE_ALL_CHILDREN, uno::Any(), uno::Any()); } // ________ (XComponent::dispose) ________ @@ -413,26 +349,15 @@ void SAL_CALL AccessibleBase::disposing() { { MutexGuard aGuard(m_aMutex); - OSL_ENSURE(!m_bIsDisposed, "dispose() called twice"); + OSL_ENSURE(isAlive(), "dispose() called twice"); - // notify disposing to all AccessibleEvent listeners asynchronous - if (m_nEventNotifierId) - { - ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing(m_nEventNotifierId, - *this); - m_nEventNotifierId = 0; - } + OAccessible::disposing(); // reset pointers + m_aAccInfo.m_pWindow.reset(); m_aAccInfo.m_pParent = nullptr; - // attach new empty state set helper to member reference - rtl::Reference<::utl::AccessibleStateSetHelper> pHelper = new ::utl::AccessibleStateSetHelper(); - pHelper->AddState(AccessibleStateType::DEFUNC); - // release old helper and attach new one - m_xStateSetHelper = pHelper; - - m_bIsDisposed = true; + m_nStateSet = AccessibleStateType::DEFUNC; } // call listeners unguarded @@ -445,18 +370,11 @@ void SAL_CALL AccessibleBase::disposing() OSL_ENSURE( m_aChildList.empty(), "Child list should be empty" ); } -// ________ XAccessible ________ -Reference< XAccessibleContext > SAL_CALL AccessibleBase::getAccessibleContext() -{ - return this; -} - // ________ AccessibleBase::XAccessibleContext ________ -sal_Int32 SAL_CALL AccessibleBase::getAccessibleChildCount() +sal_Int64 SAL_CALL AccessibleBase::getAccessibleChildCount() { ClearableMutexGuard aGuard( m_aMutex ); - if( ! m_bMayHaveChildren || - m_bIsDisposed ) + if (!m_bMayHaveChildren || !isAlive()) return 0; bool bMustUpdateChildren = ( m_bMayHaveChildren && @@ -471,14 +389,14 @@ sal_Int32 SAL_CALL AccessibleBase::getAccessibleChildCount() return ImplGetAccessibleChildCount(); } -sal_Int32 AccessibleBase::ImplGetAccessibleChildCount() const +sal_Int64 AccessibleBase::ImplGetAccessibleChildCount() const { return m_aChildList.size(); } -Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int32 i ) +Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int64 i ) { - CheckDisposeState(); + ensureAlive(); Reference< XAccessible > xResult; ClearableMutexGuard aGuard( m_aMutex ); @@ -495,9 +413,9 @@ Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int32 return xResult; } -Reference< XAccessible > AccessibleBase::ImplGetAccessibleChildById( sal_Int32 i ) const +Reference< XAccessible > AccessibleBase::ImplGetAccessibleChildById( sal_Int64 i ) const { - Reference< XAccessible > xResult; + rtl::Reference<AccessibleBase> xResult; MutexGuard aGuard( m_aMutex); if( ! m_bMayHaveChildren || @@ -513,14 +431,14 @@ Reference< XAccessible > AccessibleBase::ImplGetAccessibleChildById( sal_Int32 i throw aEx; } else - xResult.set( m_aChildList[ i ] ); + xResult = m_aChildList[i]; return xResult; } Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleParent() { - CheckDisposeState(); + ensureAlive(); Reference< XAccessible > aResult; if( m_aAccInfo.m_pParent ) aResult.set( m_aAccInfo.m_pParent ); @@ -528,9 +446,9 @@ Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleParent() return aResult; } -sal_Int32 SAL_CALL AccessibleBase::getAccessibleIndexInParent() +sal_Int64 SAL_CALL AccessibleBase::getAccessibleIndexInParent() { - CheckDisposeState(); + ensureAlive(); if( m_aAccInfo.m_spObjectHierarchy ) return m_aAccInfo.m_spObjectHierarchy->getIndexInParent( GetId() ); @@ -548,11 +466,11 @@ Reference< XAccessibleRelationSet > SAL_CALL AccessibleBase::getAccessibleRelati return aResult; } -Reference< XAccessibleStateSet > SAL_CALL AccessibleBase::getAccessibleStateSet() +sal_Int64 SAL_CALL AccessibleBase::getAccessibleStateSet() { if( ! m_bStateSetInitialized ) { - Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); + rtl::Reference< ::chart::ChartController > xSelSupp( GetInfo().m_xChartController ); if ( xSelSupp.is() ) { ObjectIdentifier aOID( xSelSupp->getSelection() ); @@ -565,36 +483,23 @@ Reference< XAccessibleStateSet > SAL_CALL AccessibleBase::getAccessibleStateSet( m_bStateSetInitialized = true; } - return m_xStateSetHelper; + return m_nStateSet; } lang::Locale SAL_CALL AccessibleBase::getLocale() { - CheckDisposeState(); + ensureAlive(); return Application::GetSettings().GetLanguageTag().getLocale(); } // ________ AccessibleBase::XAccessibleComponent ________ -sal_Bool SAL_CALL AccessibleBase::containsPoint( const awt::Point& aPoint ) -{ - awt::Rectangle aRect( getBounds() ); - - // contains() works with relative coordinates - aRect.X = 0; - aRect.Y = 0; - - return ( aPoint.X >= aRect.X && - aPoint.Y >= aRect.Y && - aPoint.X < (aRect.X + aRect.Width) && - aPoint.Y < (aRect.Y + aRect.Height) ); -} Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleAtPoint( const awt::Point& aPoint ) { - CheckDisposeState(); - Reference< XAccessible > aResult; - awt::Rectangle aRect( getBounds()); + ensureAlive(); + rtl::Reference< AccessibleBase > aResult; + awt::Rectangle aRect( implGetBounds()); // children are positioned relative to this object, so translate bound rect aRect.X = 0; @@ -605,20 +510,18 @@ Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleAtPoint( const aw ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) { ClearableMutexGuard aGuard( m_aMutex ); - ChildListVectorType aLocalChildList( m_aChildList ); + std::vector<rtl::Reference<AccessibleBase>> aLocalChildList(m_aChildList); aGuard.clear(); - Reference< XAccessibleComponent > aComp; - for (auto const& localChild : aLocalChildList) + for (const rtl::Reference<AccessibleBase>& xLocalChild : aLocalChildList) { - aComp.set(localChild, UNO_QUERY); - if( aComp.is()) + if (xLocalChild.is()) { - aRect = aComp->getBounds(); + aRect = xLocalChild->implGetBounds(); if( ( aRect.X <= aPoint.X && aPoint.X <= (aRect.X + aRect.Width) ) && ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) { - aResult = localChild; + aResult = xLocalChild; break; } } @@ -628,14 +531,13 @@ Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleAtPoint( const aw return aResult; } -awt::Rectangle SAL_CALL AccessibleBase::getBounds() +css::awt::Rectangle AccessibleBase::implGetBounds() { - ExplicitValueProvider *pExplicitValueProvider( - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_aAccInfo.m_xView )); - if( pExplicitValueProvider ) + rtl::Reference<ChartView> pChartView = m_aAccInfo.m_xView.get(); + if( pChartView ) { - VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( m_aAccInfo.m_xWindow )); - awt::Rectangle aLogicRect( pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aOID.getObjectCID() )); + VclPtr<vcl::Window> pWindow = m_aAccInfo.m_pWindow; + awt::Rectangle aLogicRect( pChartView->getRectangleOfObject( m_aAccInfo.m_aOID.getObjectCID() )); if( pWindow ) { tools::Rectangle aRect( aLogicRect.X, aLogicRect.Y, @@ -655,49 +557,19 @@ awt::Rectangle SAL_CALL AccessibleBase::getBounds() awt::Point aOffset( aParentLocOnScreen.X - aULOnScreen.X, aParentLocOnScreen.Y - aULOnScreen.Y ); - return awt::Rectangle( aRect.getX() - aOffset.X, aRect.getY() - aOffset.Y, - aRect.getWidth(), aRect.getHeight()); + return awt::Rectangle( aRect.Left() - aOffset.X, aRect.Top() - aOffset.Y, + aRect.getOpenWidth(), aRect.getOpenHeight()); } } return awt::Rectangle(); } -awt::Point SAL_CALL AccessibleBase::getLocation() -{ - CheckDisposeState(); - awt::Rectangle aBBox( getBounds() ); - return awt::Point( aBBox.X, aBBox.Y ); -} - -awt::Point SAL_CALL AccessibleBase::getLocationOnScreen() -{ - CheckDisposeState(); - - if (AccessibleBase* pParent = m_aAccInfo.m_pParent) - { - awt::Point aLocThisRel( getLocation()); - awt::Point aUpperLeft(pParent->getLocationOnScreen()); - - return awt::Point( aUpperLeft.X + aLocThisRel.X, - aUpperLeft.Y + aLocThisRel.Y ); - } - else - return getLocation(); -} - -awt::Size SAL_CALL AccessibleBase::getSize() -{ - CheckDisposeState(); - awt::Rectangle aBBox( getBounds() ); - return awt::Size( aBBox.Width, aBBox.Height ); -} - void SAL_CALL AccessibleBase::grabFocus() { - CheckDisposeState(); + ensureAlive(); - Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); + rtl::Reference< ::chart::ChartController > xSelSupp( GetInfo().m_xChartController ); if ( xSelSupp.is() ) { xSelSupp->select( GetId().getAny() ); @@ -727,13 +599,13 @@ Color AccessibleBase::getColor( eColorType eColType ) if( eType == OBJECTTYPE_LEGEND_ENTRY ) { // for colors get the data series/point properties - OUString aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID )); + std::u16string_view aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID )); aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); } xObjProp = ObjectIdentifier::getObjectPropertySet( - aObjectCID, Reference< chart2::XChartDocument >( m_aAccInfo.m_xChartDocument )); + aObjectCID, m_aAccInfo.m_xChartDocument ); if( xObjProp.is()) { try @@ -778,13 +650,13 @@ Color AccessibleBase::getColor( eColorType eColType ) { if( eColType == ACC_BASE_FOREGROUND ) { - drawing::LineStyle aLStyle; + drawing::LineStyle aLStyle = drawing::LineStyle_SOLID; if( xObjProp->getPropertyValue( aStylePropName ) >>= aLStyle ) bTransparent = (aLStyle == drawing::LineStyle_NONE); } else { - drawing::FillStyle aFStyle; + drawing::FillStyle aFStyle = drawing::FillStyle_SOLID; if( xObjProp->getPropertyValue( aStylePropName ) >>= aFStyle ) bTransparent = (aFStyle == drawing::FillStyle_NONE); } @@ -806,60 +678,6 @@ Color AccessibleBase::getColor( eColorType eColType ) return nResult; } -// ________ AccessibleBase::XServiceInfo ________ -OUString SAL_CALL AccessibleBase::getImplementationName() -{ - return "AccessibleBase"; -} - -sal_Bool SAL_CALL AccessibleBase::supportsService( const OUString& ServiceName ) -{ - return cppu::supportsService( this, ServiceName ); -} - -uno::Sequence< OUString > SAL_CALL AccessibleBase::getSupportedServiceNames() -{ - return { - "com.sun.star.accessibility.Accessible", - "com.sun.star.accessibility.AccessibleContext" - }; -} - -// ________ AccessibleBase::XEventListener ________ -void SAL_CALL AccessibleBase::disposing( const lang::EventObject& /*Source*/ ) -{ -} - -// ________ XAccessibleEventBroadcasters ________ -void SAL_CALL AccessibleBase::addAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - MutexGuard aGuard( m_aMutex ); - - if ( xListener.is() ) - { - if ( !m_nEventNotifierId ) - m_nEventNotifierId = ::comphelper::AccessibleEventNotifier::registerClient(); - - ::comphelper::AccessibleEventNotifier::addEventListener( m_nEventNotifierId, xListener ); - } -} - -void SAL_CALL AccessibleBase::removeAccessibleEventListener( const Reference< XAccessibleEventListener >& xListener ) -{ - MutexGuard aGuard( m_aMutex ); - - if ( xListener.is() && m_nEventNotifierId) - { - sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( m_nEventNotifierId, xListener ); - if ( !nListenerCount ) - { - // no listeners anymore - ::comphelper::AccessibleEventNotifier::revokeClient( m_nEventNotifierId ); - m_nEventNotifierId = 0; - } - } -} - } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx index cbee2ddbb01a..b935193abdb1 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -18,28 +18,23 @@ */ #include "AccessibleChartElement.hxx" +#include <AccessibleTextHelper.hxx> #include <CharacterProperties.hxx> +#include <ChartModel.hxx> +#include <ChartController.hxx> #include <ObjectIdentifier.hxx> #include <ObjectNameProvider.hxx> -#include <servicenames.hxx> #include <com/sun/star/awt/XDevice.hpp> #include <com/sun/star/chart2/XTitle.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/beans/XMultiPropertySet.hpp> #include <com/sun/star/accessibility/AccessibleStateType.hpp> -#include <com/sun/star/lang/XInitialization.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> - -#include <tools/diagnose_ex.h> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::com::sun::star::uno::UNO_QUERY; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace chart { @@ -47,7 +42,7 @@ namespace chart AccessibleChartElement::AccessibleChartElement( const AccessibleElementInfo & rAccInfo, bool bMayHaveChildren ) : - impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, false/*bAlwaysTransparent*/ ), + AccessibleBase(rAccInfo, bMayHaveChildren, false/*bAlwaysTransparent*/), m_bHasText( false ) { AddState( AccessibleStateType::TRANSIENT ); @@ -55,7 +50,7 @@ AccessibleChartElement::AccessibleChartElement( AccessibleChartElement::~AccessibleChartElement() { - OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) ); + OSL_ASSERT(!isAlive()); } // ________ protected ________ @@ -65,7 +60,7 @@ bool AccessibleChartElement::ImplUpdateChildren() bool bResult = false; Reference< chart2::XTitle > xTitle( ObjectIdentifier::getObjectPropertySet( - GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), + GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ), uno::UNO_QUERY ); m_bHasText = xTitle.is(); @@ -85,38 +80,21 @@ void AccessibleChartElement::InitTextEdit() if( ! m_xTextHelper.is()) { // get hard reference - Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); - // get factory from selection supplier (controller) - Reference< lang::XMultiServiceFactory > xFact( xSelSupp, uno::UNO_QUERY ); - if( xFact.is()) - { - m_xTextHelper.set( - xFact->createInstance( CHART_ACCESSIBLE_TEXT_SERVICE_NAME ), uno::UNO_QUERY ); - } + rtl::Reference< ::chart::ChartController > xChartController( GetInfo().m_xChartController ); + if( xChartController.is()) + m_xTextHelper = xChartController->createAccessibleTextContext(); } if( !m_xTextHelper.is()) return; - try - { - Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); - Sequence< uno::Any > aArgs( 3 ); - aArgs[0] <<= GetInfo().m_aOID.getObjectCID(); - aArgs[1] <<= Reference< XAccessible >( this ); - aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); - xInit->initialize( aArgs ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + m_xTextHelper->initialize(GetInfo().m_aOID.getObjectCID(), this, GetInfo().m_pWindow); } // Interfaces // ________ AccessibleBase::XAccessibleContext ________ -Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const +Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int64 i ) const { Reference< XAccessible > xResult; @@ -128,7 +106,7 @@ Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal return xResult; } -sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const +sal_Int64 AccessibleChartElement::ImplGetAccessibleChildCount() const { if( m_bHasText ) { @@ -140,12 +118,6 @@ sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const return AccessibleBase::ImplGetAccessibleChildCount(); } -// ________ XServiceInfo ________ -OUString SAL_CALL AccessibleChartElement::getImplementationName() -{ - return "AccessibleChartElement"; -} - // ________ AccessibleChartElement::XAccessibleContext (override) ________ OUString SAL_CALL AccessibleChartElement::getAccessibleName() { @@ -160,83 +132,13 @@ OUString SAL_CALL AccessibleChartElement::getAccessibleDescription() } // ________ AccessibleChartElement::XAccessibleExtendedComponent ________ -Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont() -{ - CheckDisposeState(); - - Reference< awt::XFont > xFont; - Reference< awt::XDevice > xDevice( Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY ); - - if( xDevice.is()) - { - Reference< beans::XMultiPropertySet > xObjProp( - ObjectIdentifier::getObjectPropertySet( - GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), uno::UNO_QUERY ); - awt::FontDescriptor aDescr( - CharacterProperties::createFontDescriptorFromPropertySet( xObjProp )); - xFont = xDevice->getFont( aDescr ); - } - - return xFont; -} - -OUString SAL_CALL AccessibleChartElement::getTitledBorderText() -{ - return OUString(); -} OUString SAL_CALL AccessibleChartElement::getToolTipText() { - CheckDisposeState(); + ensureAlive(); return ObjectNameProvider::getHelpText( - GetInfo().m_aOID.getObjectCID(), Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )); -} - -// ________ XAccessibleComponent ________ -sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint ) -{ - return AccessibleBase::containsPoint( aPoint ); -} - -Reference< XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint ) -{ - return AccessibleBase::getAccessibleAtPoint( aPoint ); -} - -awt::Rectangle SAL_CALL AccessibleChartElement::getBounds() -{ - return AccessibleBase::getBounds(); -} - -awt::Point SAL_CALL AccessibleChartElement::getLocation() -{ - return AccessibleBase::getLocation(); -} - -awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen() -{ - return AccessibleBase::getLocationOnScreen(); -} - -awt::Size SAL_CALL AccessibleChartElement::getSize() -{ - return AccessibleBase::getSize(); -} - -void SAL_CALL AccessibleChartElement::grabFocus() -{ - return AccessibleBase::grabFocus(); -} - -sal_Int32 SAL_CALL AccessibleChartElement::getForeground() -{ - return AccessibleBase::getForeground(); -} - -sal_Int32 SAL_CALL AccessibleChartElement::getBackground() -{ - return AccessibleBase::getBackground(); + GetInfo().m_aOID.getObjectCID(), GetInfo().m_xChartDocument ); } } // namespace chart diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.hxx b/chart2/source/controller/accessibility/AccessibleChartElement.hxx index 12982db8faa1..4594a240bcb3 100644 --- a/chart2/source/controller/accessibility/AccessibleChartElement.hxx +++ b/chart2/source/controller/accessibility/AccessibleChartElement.hxx @@ -19,14 +19,12 @@ #pragma once #include <AccessibleBase.hxx> -#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> namespace com::sun::star::accessibility { class XAccessible; } -namespace com::sun::star::accessibility { class XAccessibleContext; } -namespace com::sun::star::awt { class XFont; } namespace chart { +class AccessibleTextHelper; /** Base class for all Chart Accessibility objects except the root node (see AccessibleChartView) @@ -42,16 +40,7 @@ namespace chart </ul> */ -namespace impl -{ -typedef ::cppu::ImplInheritanceHelper< - AccessibleBase, - css::accessibility::XAccessibleExtendedComponent - > AccessibleChartElement_Base; -} - -class AccessibleChartElement : - public impl::AccessibleChartElement_Base +class AccessibleChartElement : public AccessibleBase { public: AccessibleChartElement( const AccessibleElementInfo & rAccInfo, @@ -61,39 +50,19 @@ public: // ________ AccessibleBase ________ virtual bool ImplUpdateChildren() override; virtual css::uno::Reference< css::accessibility::XAccessible > - ImplGetAccessibleChildById( sal_Int32 i ) const override; - virtual sal_Int32 ImplGetAccessibleChildCount() const override; + ImplGetAccessibleChildById( sal_Int64 i ) const override; + virtual sal_Int64 ImplGetAccessibleChildCount() const override; // ________ XAccessibleContext ________ virtual OUString SAL_CALL getAccessibleName() override; virtual OUString SAL_CALL getAccessibleDescription() override; // ________ XAccessibleExtendedComponent ________ - virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont() override; - virtual OUString SAL_CALL getTitledBorderText() override; virtual OUString SAL_CALL getToolTipText() override; - // the following interface is implemented in AccessibleBase, however it is - // also a (non-virtual) base class of XAccessibleExtendedComponent Thus - // these methods have to be overridden and forward to AccessibleBase - - // ________ XAccessibleComponent ________ - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; - virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; - virtual css::awt::Rectangle SAL_CALL getBounds() override; - virtual css::awt::Point SAL_CALL getLocation() override; - virtual css::awt::Point SAL_CALL getLocationOnScreen() override; - virtual css::awt::Size SAL_CALL getSize() override; - virtual void SAL_CALL grabFocus() override; - virtual sal_Int32 SAL_CALL getForeground() override; - virtual sal_Int32 SAL_CALL getBackground() override; - - // ________ XServiceInfo ________ - virtual OUString SAL_CALL getImplementationName() override; - private: bool m_bHasText; - css::uno::Reference< css::accessibility::XAccessibleContext > + rtl::Reference< ::chart::AccessibleTextHelper > m_xTextHelper; void InitTextEdit(); diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.cxx b/chart2/source/controller/accessibility/AccessibleChartShape.cxx index 2d4fd3010e4b..7deb39b447e5 100644 --- a/chart2/source/controller/accessibility/AccessibleChartShape.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartShape.cxx @@ -24,7 +24,6 @@ #include <svx/ShapeTypeHandler.hxx> #include <svx/AccessibleShape.hxx> #include <svx/AccessibleShapeInfo.hxx> -#include <vcl/window.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; @@ -36,7 +35,7 @@ namespace chart AccessibleChartShape::AccessibleChartShape( const AccessibleElementInfo& rAccInfo ) - :impl::AccessibleChartShape_Base( rAccInfo, true/*bMayHaveChildren*/, false/*bAlwaysTransparent*/ ) + :AccessibleBase(rAccInfo, true/*bMayHaveChildren*/, false/*bAlwaysTransparent*/) { if ( !rAccInfo.m_aOID.isAdditionalShape() ) return; @@ -51,7 +50,7 @@ AccessibleChartShape::AccessibleChartShape( m_aShapeTreeInfo.SetSdrView( rAccInfo.m_pSdrView ); m_aShapeTreeInfo.SetController( nullptr ); - m_aShapeTreeInfo.SetWindow( VCLUnoHelper::GetWindow( rAccInfo.m_xWindow ) ); + m_aShapeTreeInfo.SetWindow(rAccInfo.m_pWindow); m_aShapeTreeInfo.SetViewForwarder( rAccInfo.m_pViewForwarder ); ::accessibility::ShapeTypeHandler& rShapeHandler = ::accessibility::ShapeTypeHandler::Instance(); @@ -64,7 +63,7 @@ AccessibleChartShape::AccessibleChartShape( AccessibleChartShape::~AccessibleChartShape() { - OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) ); + OSL_ASSERT(!isAlive()); if ( m_pAccShape.is() ) { @@ -72,16 +71,10 @@ AccessibleChartShape::~AccessibleChartShape() } } -// ________ XServiceInfo ________ -OUString AccessibleChartShape::getImplementationName() -{ - return "AccessibleChartShape"; -} - // ________ XAccessibleContext ________ -sal_Int32 AccessibleChartShape::getAccessibleChildCount() +sal_Int64 AccessibleChartShape::getAccessibleChildCount() { - sal_Int32 nCount(0); + sal_Int64 nCount(0); if ( m_pAccShape.is() ) { nCount = m_pAccShape->getAccessibleChildCount(); @@ -89,7 +82,7 @@ sal_Int32 AccessibleChartShape::getAccessibleChildCount() return nCount; } -Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int32 i ) +Reference< XAccessible > AccessibleChartShape::getAccessibleChild( sal_Int64 i ) { Reference< XAccessible > xChild; if ( m_pAccShape.is() ) @@ -130,15 +123,6 @@ OUString AccessibleChartShape::getAccessibleName() } // ________ XAccessibleComponent ________ -sal_Bool AccessibleChartShape::containsPoint( const awt::Point& aPoint ) -{ - bool bReturn = false; - if ( m_pAccShape.is() ) - { - bReturn = m_pAccShape->containsPoint( aPoint ); - } - return bReturn; -} Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt::Point& aPoint ) { @@ -150,7 +134,7 @@ Reference< XAccessible > AccessibleChartShape::getAccessibleAtPoint( const awt:: return xResult; } -awt::Rectangle AccessibleChartShape::getBounds() +awt::Rectangle AccessibleChartShape::implGetBounds() { awt::Rectangle aBounds; if ( m_pAccShape.is() ) @@ -160,41 +144,6 @@ awt::Rectangle AccessibleChartShape::getBounds() return aBounds; } -awt::Point AccessibleChartShape::getLocation() -{ - awt::Point aLocation; - if ( m_pAccShape.is() ) - { - aLocation = m_pAccShape->getLocation(); - } - return aLocation; -} - -awt::Point AccessibleChartShape::getLocationOnScreen() -{ - awt::Point aLocation; - if ( m_pAccShape.is() ) - { - aLocation = m_pAccShape->getLocationOnScreen(); - } - return aLocation; -} - -awt::Size AccessibleChartShape::getSize() -{ - awt::Size aSize; - if ( m_pAccShape.is() ) - { - aSize = m_pAccShape->getSize(); - } - return aSize; -} - -void AccessibleChartShape::grabFocus() -{ - return AccessibleBase::grabFocus(); -} - sal_Int32 AccessibleChartShape::getForeground() { sal_Int32 nColor(0); @@ -216,15 +165,6 @@ sal_Int32 AccessibleChartShape::getBackground() } // ________ XAccessibleExtendedComponent ________ -Reference< awt::XFont > AccessibleChartShape::getFont() -{ - Reference< awt::XFont > xFont; - if ( m_pAccShape.is() ) - { - xFont.set( m_pAccShape->getFont() ); - } - return xFont; -} OUString AccessibleChartShape::getTitledBorderText() { diff --git a/chart2/source/controller/accessibility/AccessibleChartShape.hxx b/chart2/source/controller/accessibility/AccessibleChartShape.hxx index 4377929fa41d..db169bd3b5c1 100644 --- a/chart2/source/controller/accessibility/AccessibleChartShape.hxx +++ b/chart2/source/controller/accessibility/AccessibleChartShape.hxx @@ -20,7 +20,6 @@ #include <AccessibleBase.hxx> -#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> #include <cppuhelper/implbase.hxx> #include <svx/AccessibleShapeTreeInfo.hxx> @@ -32,44 +31,29 @@ class AccessibleShape; namespace chart { -namespace impl -{ -typedef ::cppu::ImplInheritanceHelper< - AccessibleBase, - css::accessibility::XAccessibleExtendedComponent > AccessibleChartShape_Base; -} - -class AccessibleChartShape : - public impl::AccessibleChartShape_Base +class AccessibleChartShape : public AccessibleBase { public: explicit AccessibleChartShape( const AccessibleElementInfo& rAccInfo ); virtual ~AccessibleChartShape() override; - // ________ XServiceInfo ________ - virtual OUString SAL_CALL getImplementationName() override; - // ________ XAccessibleContext ________ - virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleChild( sal_Int32 i ) override; + getAccessibleChild( sal_Int64 i ) override; virtual sal_Int16 SAL_CALL getAccessibleRole() override; virtual OUString SAL_CALL getAccessibleDescription() override; virtual OUString SAL_CALL getAccessibleName() override; + // OAccessible + virtual css::awt::Rectangle implGetBounds() override; + // ________ XAccessibleComponent ________ - virtual sal_Bool SAL_CALL containsPoint( const css::awt::Point& aPoint ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; - virtual css::awt::Rectangle SAL_CALL getBounds() override; - virtual css::awt::Point SAL_CALL getLocation() override; - virtual css::awt::Point SAL_CALL getLocationOnScreen() override; - virtual css::awt::Size SAL_CALL getSize() override; - virtual void SAL_CALL grabFocus() override; virtual sal_Int32 SAL_CALL getForeground() override; virtual sal_Int32 SAL_CALL getBackground() override; // ________ XAccessibleExtendedComponent ________ - virtual css::uno::Reference< css::awt::XFont > SAL_CALL getFont() override; virtual OUString SAL_CALL getTitledBorderText() override; virtual OUString SAL_CALL getToolTipText() override; diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx index 0738f52abc36..7216c6bbc665 100644 --- a/chart2/source/controller/accessibility/AccessibleChartView.cxx +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -18,19 +18,18 @@ */ #include <AccessibleChartView.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <ObjectHierarchy.hxx> #include <ObjectIdentifier.hxx> #include <ResId.hxx> #include <strings.hrc> #include "AccessibleViewForwarder.hxx" +#include <ChartModel.hxx> +#include <ChartView.hxx> +#include <ChartController.hxx> #include <com/sun/star/accessibility/AccessibleStateType.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> - -#include <comphelper/servicehelper.hxx> #include <rtl/ustring.hxx> #include <vcl/window.hxx> @@ -41,22 +40,19 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; -using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::WeakReference; -using ::com::sun::star::uno::Any; using osl::MutexGuard; namespace chart { -AccessibleChartView::AccessibleChartView(SdrView* pView ) : - impl::AccessibleChartView_Base( - AccessibleElementInfo(), // empty for now - true, // has children - true // always transparent - ), - m_pSdrView( pView ) +AccessibleChartView::AccessibleChartView(SdrView* pView) + : ImplInheritanceHelper(AccessibleElementInfo(), // empty for now + true, // has children + true // always transparent + ) + , m_pSdrView(pView) { AddState( AccessibleStateType::OPAQUE ); } @@ -67,20 +63,19 @@ AccessibleChartView::~AccessibleChartView() awt::Rectangle AccessibleChartView::GetWindowPosSize() const { - Reference< awt::XWindow > xWindow( GetInfo().m_xWindow ); - if( ! xWindow.is()) - return awt::Rectangle(); + SolarMutexGuard aSolarGuard; - awt::Rectangle aBBox( xWindow->getPosSize() ); + VclPtr<vcl::Window> pWindow = GetInfo().m_pWindow; + if (!pWindow) + return awt::Rectangle(); - VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow )); - if( pWindow ) - { - SolarMutexGuard aSolarGuard; - Point aVCLPoint( pWindow->OutputToAbsoluteScreenPixel( Point( 0, 0 ) )); - aBBox.X = aVCLPoint.getX(); - aBBox.Y = aVCLPoint.getY(); - } + awt::Rectangle aBBox; + Point aVCLPoint( pWindow->OutputToAbsoluteScreenPixel( Point( 0, 0 ) )); + const Size aSize = pWindow->GetSizePixel(); + aBBox.X = aVCLPoint.getX(); + aBBox.Y = aVCLPoint.getY(); + aBBox.Width = aSize.Width(); + aBBox.Height = aSize.Height(); return aBBox; } @@ -112,7 +107,7 @@ Reference< XAccessible > SAL_CALL AccessibleChartView::getAccessibleParent() return Reference< XAccessible >( m_xParent ); } -sal_Int32 SAL_CALL AccessibleChartView::getAccessibleIndexInParent() +sal_Int64 SAL_CALL AccessibleChartView::getAccessibleIndexInParent() { // the document is always the only child of the window return 0; @@ -123,8 +118,7 @@ sal_Int16 SAL_CALL AccessibleChartView::getAccessibleRole() return AccessibleRole::DOCUMENT; } -// ________ XAccessibleComponent ________ -awt::Rectangle SAL_CALL AccessibleChartView::getBounds() +awt::Rectangle AccessibleChartView::implGetBounds() { awt::Rectangle aResult( GetWindowPosSize()); Reference< XAccessible > xParent( m_xParent ); @@ -141,25 +135,19 @@ awt::Rectangle SAL_CALL AccessibleChartView::getBounds() return aResult; } -awt::Point SAL_CALL AccessibleChartView::getLocationOnScreen() + +void SAL_CALL AccessibleChartView::disposing() { - awt::Rectangle aBounds( getBounds()); - awt::Point aResult; - Reference< XAccessible > xParent( m_xParent ); - if( xParent.is()) - { - Reference< XAccessibleComponent > xAccComp( - xParent->getAccessibleContext(), uno::UNO_QUERY ); - aResult = xAccComp->getLocationOnScreen(); - aResult.X += aBounds.X; - aResult.Y += aBounds.Y; - } - return aResult; -} + m_pChartWindow.reset(); -// lang::XInitialization + AccessibleBase::disposing(); +} -void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments ) +void AccessibleChartView::initialize( ChartController& rNewChartController, + const rtl::Reference<::chart::ChartModel>& xNewChartModel, + const rtl::Reference<::chart::ChartView>& xNewChartView, + const uno::Reference< XAccessible >& xNewParent, + ChartWindow* pNewChartWindow) { //0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself //1: frame::XModel representing the chart model - offers access to object data @@ -170,123 +158,170 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments bool bOldInvalid = false; bool bNewInvalid = false; - Reference< view::XSelectionSupplier > xSelectionSupplier; - Reference< frame::XModel > xChartModel; - Reference< uno::XInterface > xChartView; + rtl::Reference< ::chart::ChartController > xChartController; + rtl::Reference<::chart::ChartModel> xChartModel; + rtl::Reference<::chart::ChartView> xChartView; Reference< XAccessible > xParent; - Reference< awt::XWindow > xWindow; + VclPtr<ChartWindow> pChartWindow; { MutexGuard aGuard( m_aMutex); - xSelectionSupplier.set( m_xSelectionSupplier ); - xChartModel.set( m_xChartModel ); - xChartView.set( m_xChartView ); + xChartController = m_xChartController; + xChartModel = m_xChartModel; + xChartView = m_xChartView; xParent.set( m_xParent ); - xWindow.set( m_xWindow ); + pChartWindow = m_pChartWindow; } - if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) { bOldInvalid = true; } - if( rArguments.getLength() > 1 ) + if( xNewChartModel.get() != xChartModel.get() ) { - Reference< frame::XModel > xNewChartModel; - rArguments[1] >>= xNewChartModel; - if( xNewChartModel != xChartModel ) - { - xChartModel = xNewChartModel; - bChanged = true; - } + xChartModel = xNewChartModel; + bChanged = true; } - else if( xChartModel.is() ) + + if( xNewChartView != xChartView ) { + xChartView = xNewChartView; bChanged = true; - xChartModel = nullptr; } - if( rArguments.getLength() > 2 ) + if( xNewParent != xParent ) { - Reference< uno::XInterface > xNewChartView; - rArguments[2] >>= xNewChartView; - if( xNewChartView != xChartView ) - { - xChartView = xNewChartView; - bChanged = true; - } + xParent = xNewParent; + bChanged = true; } - else if( xChartView.is() ) + + if (pNewChartWindow != pChartWindow) { + pChartWindow = pNewChartWindow; bChanged = true; - xChartView = nullptr; } - if( rArguments.getLength() > 3 ) + if(xChartController != &rNewChartController) { - Reference< XAccessible > xNewParent; - rArguments[3] >>= xNewParent; - if( xNewParent != xParent ) - { - xParent = xNewParent; - bChanged = true; - } + if (xChartController) + xChartController->removeSelectionChangeListener(this); + rNewChartController.addSelectionChangeListener(this); + xChartController = &rNewChartController; + bChanged = true; } - if( rArguments.getLength() > 4 ) + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) { - Reference< awt::XWindow > xNewWindow; - rArguments[4] >>= xNewWindow; - if( xNewWindow != xWindow ) + if(xChartController.is()) { - xWindow.set( xNewWindow ); - bChanged = true; + xChartController->removeSelectionChangeListener(this); + xChartController.clear(); } + xChartModel.clear(); + xChartView.clear(); + xParent.clear(); + pChartWindow.reset(); + + bNewInvalid = true; } - if( rArguments.hasElements() && xChartModel.is() && xChartView.is() ) { - Reference< view::XSelectionSupplier > xNewSelectionSupplier; - rArguments[0] >>= xNewSelectionSupplier; - if(xSelectionSupplier!=xNewSelectionSupplier) - { - bChanged = true; - if(xSelectionSupplier.is()) - xSelectionSupplier->removeSelectionChangeListener(this); - if(xNewSelectionSupplier.is()) - xNewSelectionSupplier->addSelectionChangeListener(this); - xSelectionSupplier = xNewSelectionSupplier; - } + MutexGuard aGuard( m_aMutex); + m_xChartController = xChartController.get(); + m_xChartModel = xChartModel.get(); + m_xChartView = xChartView.get(); + m_xParent = xParent; + m_pChartWindow = std::move(pChartWindow); + } + + if( bOldInvalid && bNewInvalid ) + bChanged = false; + + if( !bChanged ) + return; + + { + //before notification we prepare for creation of new context + //the old context will be deleted after notification than + MutexGuard aGuard( m_aMutex); + if( xChartModel.is()) + m_spObjectHierarchy = + std::make_shared<ObjectHierarchy>( xChartModel, m_xChartView.get().get() ); + else + m_spObjectHierarchy.reset(); } - else if( xSelectionSupplier.is() ) + + { + AccessibleElementInfo aAccInfo; + aAccInfo.m_aOID = ObjectIdentifier(u"ROOT"_ustr); + aAccInfo.m_xChartDocument = m_xChartModel; + aAccInfo.m_xChartController = m_xChartController; + aAccInfo.m_xView = m_xChartView; + aAccInfo.m_pWindow = m_pChartWindow; + aAccInfo.m_pParent = nullptr; + aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; + aAccInfo.m_pSdrView = m_pSdrView; + m_pViewForwarder.reset(new AccessibleViewForwarder(this, m_pChartWindow)); + aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); + // broadcasts an INVALIDATE_ALL_CHILDREN event globally + SetInfo( aAccInfo ); + } +} + +void AccessibleChartView::initialize() +{ + //0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself + //1: frame::XModel representing the chart model - offers access to object data + //2: lang::XInterface representing the normal chart view - offers access to some extra object data + + //all arguments are only valid until next initialization + bool bChanged = false; + bool bOldInvalid = false; + + rtl::Reference< ::chart::ChartController > xChartController; + rtl::Reference<::chart::ChartModel> xChartModel; + rtl::Reference<::chart::ChartView> xChartView; + { + MutexGuard aGuard( m_aMutex); + xChartController = m_xChartController; + xChartModel = m_xChartModel; + xChartView = m_xChartView; + } + + if( !xChartController.is() || !xChartModel.is() || !xChartView.is() ) + { + bOldInvalid = true; + } + + if( xChartModel.is() ) { bChanged = true; - xSelectionSupplier->removeSelectionChangeListener(this); - xSelectionSupplier = nullptr; + xChartModel = nullptr; } - if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + if( xChartView.is() ) { - if(xSelectionSupplier.is()) - xSelectionSupplier->removeSelectionChangeListener(this); - xSelectionSupplier = nullptr; - xChartModel.clear(); - xChartView.clear(); - xParent.clear(); - xWindow.clear(); + bChanged = true; + xChartView = nullptr; + } - bNewInvalid = true; + if( xChartController.is() ) + { + bChanged = true; + xChartController->removeSelectionChangeListener(this); + xChartController = nullptr; } { MutexGuard aGuard( m_aMutex); - m_xSelectionSupplier = WeakReference< view::XSelectionSupplier >(xSelectionSupplier); - m_xChartModel = WeakReference< frame::XModel >(xChartModel); - m_xChartView = WeakReference< uno::XInterface >(xChartView); - m_xParent = WeakReference< XAccessible >(xParent); - m_xWindow = WeakReference< awt::XWindow >(xWindow); + m_xChartController = xChartController.get(); + m_xChartModel = xChartModel.get(); + m_xChartView = xChartView.get(); + m_xParent.clear(); + m_pChartWindow.reset(); } - if( bOldInvalid && bNewInvalid ) + if( bOldInvalid ) bChanged = false; if( !bChanged ) @@ -296,27 +331,24 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments //before notification we prepare for creation of new context //the old context will be deleted after notification than MutexGuard aGuard( m_aMutex); - Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); - if( xChartDoc.is()) + if( xChartModel.is()) m_spObjectHierarchy = - std::make_shared<ObjectHierarchy>( xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView) ); + std::make_shared<ObjectHierarchy>( xChartModel, m_xChartView.get().get() ); else m_spObjectHierarchy.reset(); } { AccessibleElementInfo aAccInfo; - aAccInfo.m_aOID = ObjectIdentifier("ROOT"); - aAccInfo.m_xChartDocument = uno::WeakReference< chart2::XChartDocument >( - uno::Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY )); - aAccInfo.m_xSelectionSupplier = m_xSelectionSupplier; + aAccInfo.m_aOID = ObjectIdentifier(u"ROOT"_ustr); + aAccInfo.m_xChartDocument = m_xChartModel; + aAccInfo.m_xChartController = m_xChartController; aAccInfo.m_xView = m_xChartView; - aAccInfo.m_xWindow = m_xWindow; + aAccInfo.m_pWindow.reset(); aAccInfo.m_pParent = nullptr; aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; aAccInfo.m_pSdrView = m_pSdrView; - VclPtr<vcl::Window> pWindow = VCLUnoHelper::GetWindow( m_xWindow ); - m_pViewForwarder.reset( new AccessibleViewForwarder( this, pWindow ) ); + m_pViewForwarder.reset(new AccessibleViewForwarder(this, nullptr)); aAccInfo.m_pViewForwarder = m_pViewForwarder.get(); // broadcasts an INVALIDATE_ALL_CHILDREN event globally SetInfo( aAccInfo ); @@ -327,16 +359,16 @@ void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /*rEvent*/ ) { - Reference< view::XSelectionSupplier > xSelectionSupplier; + rtl::Reference< ::chart::ChartController > xChartController; { MutexGuard aGuard( m_aMutex); - xSelectionSupplier.set(m_xSelectionSupplier); + xChartController = m_xChartController.get(); } - if( !xSelectionSupplier.is() ) + if( !xChartController.is() ) return; - ObjectIdentifier aSelectedOID( xSelectionSupplier->getSelection() ); + ObjectIdentifier aSelectedOID( xChartController->getSelection() ); if ( m_aCurrentSelectionOID.isValid() ) { NotifyEvent( EventType::LOST_SELECTION, m_aCurrentSelectionOID ); @@ -345,7 +377,7 @@ void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /* { NotifyEvent( EventType::GOT_SELECTION, aSelectedOID ); } - m_aCurrentSelectionOID = aSelectedOID; + m_aCurrentSelectionOID = std::move(aSelectedOID); } // XEventListener diff --git a/chart2/source/controller/accessibility/AccessibleTextHelper.cxx b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx index d2b56b2b7364..b58cb1c62294 100644 --- a/chart2/source/controller/accessibility/AccessibleTextHelper.cxx +++ b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx @@ -33,18 +33,18 @@ #include <com/sun/star/awt/XWindow.hpp> #include <com/sun/star/accessibility/AccessibleRole.hpp> +#include <osl/diagnose.h> + using namespace ::com::sun::star; using namespace ::com::sun::star::accessibility; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace chart { AccessibleTextHelper::AccessibleTextHelper( DrawViewWrapper * pDrawViewWrapper ) : - impl::AccessibleTextHelper_Base( m_aMutex ), m_pDrawViewWrapper( pDrawViewWrapper ) {} @@ -52,64 +52,52 @@ AccessibleTextHelper::~AccessibleTextHelper() { } -// ____ XInitialization ____ -void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments ) +void AccessibleTextHelper::initialize(const OUString& aCID, + const rtl::Reference<comphelper::OAccessible>& rEventSource, + vcl::Window* pWindow) { - OUString aCID; - Reference< XAccessible > xEventSource; - Reference< awt::XWindow > xWindow; - - if( aArguments.getLength() >= 3 ) - { - aArguments[0] >>= aCID; - aArguments[1] >>= xEventSource; - aArguments[2] >>= xWindow; - } OSL_ENSURE( !aCID.isEmpty(), "Empty CID" ); - OSL_ENSURE( xEventSource.is(), "Empty Event Source" ); - OSL_ENSURE( xWindow.is(), "Empty Window" ); - if( !xEventSource.is() || aCID.isEmpty() ) + assert(rEventSource.is() && "Empty Event Source"); + if (aCID.isEmpty()) return; SolarMutexGuard aSolarGuard; - m_pTextHelper.reset(); + m_oTextHelper.reset(); - VclPtr<vcl::Window> pWindow( VCLUnoHelper::GetWindow( xWindow )); if( pWindow ) { - SdrView * pView = m_pDrawViewWrapper; - if( pView ) + if (m_pDrawViewWrapper) { SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID ); if( pTextObj ) { - m_pTextHelper.reset( new ::accessibility::AccessibleTextHelper(std::make_unique<SvxTextEditSource>(*pTextObj, nullptr, *pView, *pWindow->GetOutDev())) ); - m_pTextHelper->SetEventSource( xEventSource ); + m_oTextHelper.emplace(std::make_unique<SvxTextEditSource>(*pTextObj, nullptr, *m_pDrawViewWrapper, *pWindow->GetOutDev())); + m_oTextHelper->SetEventSource(rEventSource); } } } - OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" ); + OSL_ENSURE( m_oTextHelper, "Couldn't create text helper" ); } // ____ XAccessibleContext ____ -::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount() +sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleChildCount() { - if( m_pTextHelper ) + if( m_oTextHelper ) { SolarMutexGuard aSolarGuard; - return m_pTextHelper->GetChildCount(); + return m_oTextHelper->GetChildCount(); } return 0; } -Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i ) +Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( sal_Int64 i ) { - if( m_pTextHelper ) + if( m_oTextHelper ) { SolarMutexGuard aSolarGuard; - return m_pTextHelper->GetChild( i ); + return m_oTextHelper->GetChild( i ); } return Reference< XAccessible >(); } @@ -120,7 +108,7 @@ Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent() return Reference< XAccessible >(); } -::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent() +sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent() { OSL_FAIL( "Not implemented in this helper" ); return -1; @@ -150,10 +138,10 @@ Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessible return Reference< XAccessibleRelationSet >(); } -Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet() +sal_Int64 SAL_CALL AccessibleTextHelper::getAccessibleStateSet() { OSL_FAIL( "Not implemented in this helper" ); - return Reference< XAccessibleStateSet >(); + return 0; } lang::Locale SAL_CALL AccessibleTextHelper::getLocale() diff --git a/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx index 31395f1181dc..dbd8ac0d51f2 100644 --- a/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx +++ b/chart2/source/controller/accessibility/AccessibleViewForwarder.cxx @@ -45,9 +45,9 @@ tools::Rectangle AccessibleViewForwarder::GetVisibleArea() const tools::Rectangle aVisibleArea; if ( m_pWindow ) { - aVisibleArea.SetPos( Point( 0, 0 ) ); - aVisibleArea.SetSize( m_pWindow->GetOutputSizePixel() ); - aVisibleArea = m_pWindow->PixelToLogic( aVisibleArea, m_aMapMode ); + aVisibleArea = m_pWindow->PixelToLogic( + tools::Rectangle( Point( 0, 0 ), m_pWindow->GetOutputSizePixel() ), + m_aMapMode ); } return aVisibleArea; } diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx index 8920b1eda076..11884859927a 100644 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx @@ -20,7 +20,6 @@ #include "AreaWrapper.hxx" #include "Chart2ModelContact.hxx" #include <WrappedDirectStateProperty.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> @@ -29,51 +28,18 @@ #include <UserDefinedProperties.hxx> #include <algorithm> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticAreaWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAreaWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAreaWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { -AreaWrapper::AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +AreaWrapper::AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -104,35 +70,37 @@ void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ ) // ____ XShapeDescriptor (base of XShape) ____ OUString SAL_CALL AreaWrapper::getShapeType() { - return "com.sun.star.chart.ChartArea"; + return u"com.sun.star.chart.ChartArea"_ustr; } // ____ XComponent ____ void SAL_CALL AreaWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL AreaWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL AreaWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xChartDoc.is() ) return xChartDoc->getPageBackground(); OSL_FAIL("AreaWrapper::getInnerPropertySet() is NULL"); @@ -141,21 +109,33 @@ Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() const Sequence< beans::Property >& AreaWrapper::getPropertySequence() { - return *StaticAreaWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > AreaWrapper::createWrappedProperties() { std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("LineStyle","LineStyle") ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"LineStyle"_ustr,u"LineStyle"_ustr) ); return aWrappedProperties; } OUString SAL_CALL AreaWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Area"; + return u"com.sun.star.comp.chart.Area"_ustr; } sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName ) @@ -166,10 +146,10 @@ sal_Bool SAL_CALL AreaWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL AreaWrapper::getSupportedServiceNames() { return { - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.beans.PropertySet", - "com.sun.star.drawing.FillProperties", - "com.sun.star.drawing.LineProperties" }; + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.beans.PropertySet"_ustr, + u"com.sun.star.drawing.FillProperties"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr }; } } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx index 4934ac5f1964..c150d5bbfcef 100644 --- a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -40,7 +40,7 @@ class AreaWrapper : public ::cppu::ImplInheritanceHelper< > { public: - explicit AreaWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit AreaWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~AreaWrapper() override; /// XServiceInfo declarations @@ -72,7 +72,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx index b15f33f1871a..3376282d6ffc 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -18,6 +18,7 @@ */ #include "AxisWrapper.hxx" +#include <Axis.hxx> #include <AxisHelper.hxx> #include <TitleHelper.hxx> #include "Chart2ModelContact.hxx" @@ -35,8 +36,6 @@ #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart/ChartAxisMarkPosition.hpp> #include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -49,7 +48,8 @@ #include "WrappedScaleTextProperties.hxx" #include <algorithm> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -335,33 +335,23 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticAxisWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticAxisWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticAxisWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticAxisWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -370,9 +360,8 @@ namespace chart::wrapper { AxisWrapper::AxisWrapper( - tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_eType( eType ) { } @@ -484,24 +473,24 @@ void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ ) // ____ XShapeDescriptor (base of XShape) ____ OUString SAL_CALL AxisWrapper::getShapeType() { - return "com.sun.star.chart.ChartAxis"; + return u"com.sun.star.chart.ChartAxis"_ustr; } // ____ XNumberFormatsSupplier ____ uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings() { - Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY ); - if( xNumSuppl.is() ) - return xNumSuppl->getNumberFormatSettings(); + rtl::Reference<ChartModel> xChartModel( m_spChart2ModelContact->getDocumentModel() ); + if( xChartModel ) + return xChartModel->getNumberFormatSettings(); return uno::Reference< beans::XPropertySet >(); } uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats() { - Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY ); - if( xNumSuppl.is() ) - return xNumSuppl->getNumberFormats(); + rtl::Reference<ChartModel> xChartModel( m_spChart2ModelContact->getDocumentModel() ); + if( xChartModel ) + return xChartModel->getNumberFormats(); return uno::Reference< util::XNumberFormats >(); } @@ -526,8 +515,9 @@ void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDim // ____ XComponent ____ void SAL_CALL AxisWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); DisposeHelper::DisposeAndClear( m_xAxisTitle ); DisposeHelper::DisposeAndClear( m_xMajorGrid ); @@ -539,13 +529,15 @@ void SAL_CALL AxisWrapper::dispose() void SAL_CALL AxisWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL AxisWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //ReferenceSizePropertyProvider @@ -554,8 +546,8 @@ void AxisWrapper::updateReferenceSize() Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY ); if( xProp.is() ) { - if( xProp->getPropertyValue("ReferencePageSize").hasValue() ) - xProp->setPropertyValue("ReferencePageSize", uno::Any( + if( xProp->getPropertyValue(u"ReferencePageSize"_ustr).hasValue() ) + xProp->setPropertyValue(u"ReferencePageSize"_ustr, uno::Any( m_spChart2ModelContact->GetPageSize() )); } } @@ -564,7 +556,7 @@ Any AxisWrapper::getReferenceSize() Any aRet; Reference< beans::XPropertySet > xProp( getAxis(), uno::UNO_QUERY ); if( xProp.is() ) - aRet = xProp->getPropertyValue("ReferencePageSize"); + aRet = xProp->getPropertyValue(u"ReferencePageSize"_ustr); return aRet; } awt::Size AxisWrapper::getCurrentSizeForReference() @@ -574,21 +566,20 @@ awt::Size AxisWrapper::getCurrentSizeForReference() Reference< chart2::XAxis > AxisWrapper::getAxis() { - Reference< chart2::XAxis > xAxis; + rtl::Reference< Axis > xAxis; try { sal_Int32 nDimensionIndex = 0; bool bMainAxis = true; AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); - Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ); if( !xAxis.is() ) { xAxis = AxisHelper::createAxis( nDimensionIndex, bMainAxis, xDiagram, m_spChart2ModelContact->m_xContext ); - Reference< beans::XPropertySet > xProp( xAxis, uno::UNO_QUERY ); - if( xProp.is() ) - xProp->setPropertyValue("Show", uno::Any( false ) ); + if( xAxis.is() ) + xAxis->setPropertyValue(u"Show"_ustr, uno::Any( false ) ); } } catch( const uno::Exception & ) @@ -606,7 +597,7 @@ Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() const Sequence< beans::Property >& AxisWrapper::getPropertySequence() { - return *StaticAxisWrapperPropertyArray::get(); + return StaticAxisWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProperties() @@ -614,19 +605,19 @@ std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProper std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; aWrappedProperties.emplace_back( new WrappedTextRotationProperty() ); - aWrappedProperties.emplace_back( new WrappedProperty("Marks","MajorTickmarks") ); - aWrappedProperties.emplace_back( new WrappedProperty("HelpMarks","MinorTickmarks") ); - aWrappedProperties.emplace_back( new WrappedProperty("TextCanOverlap","TextOverlap") ); - aWrappedProperties.emplace_back( new WrappedProperty("ArrangeOrder","ArrangeOrder") ); - aWrappedProperties.emplace_back( new WrappedProperty("Visible","Show") ); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("DisplayLabels","DisplayLabels") ); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("TryStaggeringFirst","TryStaggeringFirst") ); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("TextBreak","TextBreak") ); + aWrappedProperties.emplace_back( new WrappedProperty(u"Marks"_ustr,u"MajorTickmarks"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"HelpMarks"_ustr,u"MinorTickmarks"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"TextCanOverlap"_ustr,u"TextOverlap"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"ArrangeOrder"_ustr,u"ArrangeOrder"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"Visible"_ustr,u"Show"_ustr) ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"DisplayLabels"_ustr,u"DisplayLabels"_ustr) ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"TryStaggeringFirst"_ustr,u"TryStaggeringFirst"_ustr) ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"TextBreak"_ustr,u"TextBreak"_ustr) ); aWrappedProperties.emplace_back( new WrappedNumberFormatProperty(m_spChart2ModelContact) ); aWrappedProperties.emplace_back( new WrappedLinkNumberFormatProperty ); - aWrappedProperties.emplace_back( new WrappedProperty("StackedText","StackCharacters") ); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("CrossoverPosition","CrossoverPosition") ); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("MajorOrigin","MajorOrigin") ); + aWrappedProperties.emplace_back( new WrappedProperty(u"StackedText"_ustr,u"StackCharacters"_ustr) ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"CrossoverPosition"_ustr,u"CrossoverPosition"_ustr) ); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"MajorOrigin"_ustr,u"MajorOrigin"_ustr) ); { WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) ); WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) ); @@ -652,7 +643,7 @@ std::vector< std::unique_ptr<WrappedProperty> > AxisWrapper::createWrappedProper OUString SAL_CALL AxisWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Axis"; + return u"com.sun.star.comp.chart.Axis"_ustr; } sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName ) @@ -663,9 +654,9 @@ sal_Bool SAL_CALL AxisWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL AxisWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartAxis", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.style.CharacterProperties" + u"com.sun.star.chart.ChartAxis"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.style.CharacterProperties"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx index 7b55173f5d3d..3b63c45c100d 100644 --- a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx @@ -21,13 +21,13 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/chart/XAxis.hpp> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/util/XNumberFormatsSupplier.hpp> - +#include <rtl/ref.hxx> #include <memory> namespace com::sun::star::chart2 { class XAxis; } @@ -35,6 +35,8 @@ namespace com::sun::star::chart2 { class XAxis; } namespace chart::wrapper { class Chart2ModelContact; +class TitleWrapper; +class GridWrapper; class AxisWrapper : public ::cppu::ImplInheritanceHelper< WrappedPropertySet @@ -56,7 +58,7 @@ public: SECOND_Y_AXIS }; - AxisWrapper(tAxisType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + AxisWrapper(tAxisType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~AxisWrapper() override; static void getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, bool& rbMainAxis ); @@ -109,13 +111,13 @@ private: //methods private: //member std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; tAxisType m_eType; - css::uno::Reference< css::beans::XPropertySet > m_xAxisTitle; - css::uno::Reference< css::beans::XPropertySet > m_xMajorGrid; - css::uno::Reference< css::beans::XPropertySet > m_xMinorGrid; + rtl::Reference< TitleWrapper > m_xAxisTitle; + rtl::Reference< GridWrapper > m_xMajorGrid; + rtl::Reference< GridWrapper > m_xMinorGrid; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx index e0cd9e0311bb..f7ed5ca5165b 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -18,18 +18,23 @@ */ #include "Chart2ModelContact.hxx" -#include <ChartModelHelper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> #include <CommonConverters.hxx> #include <servicenames.hxx> #include <ObjectIdentifier.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <chartview/DrawModelWrapper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> +#include <ChartView.hxx> #include <DiagramHelper.hxx> +#include <BaseCoordinateSystem.hxx> #include <ChartModel.hxx> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <comphelper/diagnose_ex.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -41,8 +46,7 @@ namespace chart::wrapper Chart2ModelContact::Chart2ModelContact( const Reference< uno::XComponentContext > & xContext ) : m_xContext( xContext ), - m_xChartModel( nullptr ), - mpModel( nullptr ) + m_xChartModel( nullptr ) { } @@ -51,125 +55,102 @@ Chart2ModelContact::~Chart2ModelContact() clear(); } -void Chart2ModelContact::setModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) +void Chart2ModelContact::setDocumentModel( ChartModel* pChartModel ) { clear(); - m_xChartModel = xChartModel; - mpModel = dynamic_cast<ChartModel*>(xChartModel.get()); - uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY ); - if( !xTableFactory.is() ) + m_xChartModel = pChartModel; + if( !pChartModel ) return; - uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance("com.sun.star.drawing.DashTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance("com.sun.star.drawing.GradientTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance("com.sun.star.drawing.HatchTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance("com.sun.star.drawing.BitmapTable"), uno::UNO_QUERY ); - uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance("com.sun.star.drawing.TransparencyGradientTable"), uno::UNO_QUERY ); - m_aTableMap["LineDashName"] = xDashTable; - m_aTableMap["FillGradientName"] = xGradientTable; - m_aTableMap["FillHatchName"] = xHatchTable; - m_aTableMap["FillBitmapName"] = xBitmapTable; - m_aTableMap["FillTransparenceGradientName"] = xTransparencyGradientTable; + m_aTableMap[u"LineDashName"_ustr].set(pChartModel->createInstance(u"com.sun.star.drawing.DashTable"_ustr), uno::UNO_QUERY); + m_aTableMap[u"FillGradientName"_ustr].set(pChartModel->createInstance(u"com.sun.star.drawing.GradientTable"_ustr), uno::UNO_QUERY); + m_aTableMap[u"FillHatchName"_ustr].set(pChartModel->createInstance(u"com.sun.star.drawing.HatchTable"_ustr), uno::UNO_QUERY); + m_aTableMap[u"FillBitmapName"_ustr].set(pChartModel->createInstance(u"com.sun.star.drawing.BitmapTable"_ustr), uno::UNO_QUERY); + m_aTableMap[u"FillTransparenceGradientName"_ustr].set(pChartModel->createInstance(u"com.sun.star.drawing.TransparencyGradientTable"_ustr), uno::UNO_QUERY); } void Chart2ModelContact::clear() { m_xChartModel.clear(); m_xChartView.clear(); - mpModel = nullptr; } -Reference< frame::XModel > Chart2ModelContact::getChartModel() const +rtl::Reference< ChartModel > Chart2ModelContact::getDocumentModel() const { - return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY ); + return m_xChartModel; } -Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() const +rtl::Reference< ::chart::Diagram > Chart2ModelContact::getDiagram() const { - return Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY ); -} - -Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const -{ - return ChartModelHelper::findDiagram( getChartModel() ); + try + { + rtl::Reference<ChartModel> xChartModel = getDocumentModel(); + if( xChartModel) + return xChartModel->getFirstChartDiagram(); + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + return nullptr; } -uno::Reference< lang::XUnoTunnel > const & Chart2ModelContact::getChartView() const +rtl::Reference< ::chart::ChartView > const & Chart2ModelContact::getChartView() const { if(!m_xChartView.is()) { // get the chart view - Reference<frame::XModel> xModel(m_xChartModel); - uno::Reference< lang::XMultiServiceFactory > xFact( xModel, uno::UNO_QUERY ); - if( xFact.is() ) - m_xChartView.set( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + rtl::Reference<ChartModel> xChartModel( m_xChartModel ); + if( xChartModel ) + m_xChartView = xChartModel->createChartView(); } return m_xChartView; } -ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() const +rtl::Reference<SvxDrawPage> Chart2ModelContact::getDrawPage() const { - getChartView(); - if(!m_xChartView.is()) - return nullptr; - - //obtain the ExplicitValueProvider from the chart view - ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(m_xChartView->getSomething( - ExplicitValueProvider::getUnoTunnelId() )); - return pProvider; -} - -uno::Reference< drawing::XDrawPage > Chart2ModelContact::getDrawPage() const -{ - uno::Reference< drawing::XDrawPage > xResult; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) + rtl::Reference<SvxDrawPage> xResult; + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) { - xResult.set( pProvider->getDrawModelWrapper()->getMainDrawPage() ); + xResult = rxChartView->getDrawModelWrapper()->getMainDrawPage(); } return xResult; } void Chart2ModelContact::getExplicitValuesForAxis( - const Reference< XAxis > & xAxis, + const rtl::Reference< Axis > & xAxis, ExplicitScaleData & rOutExplicitScale, ExplicitIncrementData & rOutExplicitIncrement ) { - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) { - pProvider->getExplicitValuesForAxis( + rxChartView->getExplicitValuesForAxis( xAxis, rOutExplicitScale, rOutExplicitIncrement ); } } sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForAxis( - const Reference< chart2::XAxis >& xAxis ) + const rtl::Reference< ::chart::Axis >& xAxis ) { - Reference< chart2::XCoordinateSystem > xCooSys( + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) ); + xAxis, m_xChartModel.get()->getFirstChartDiagram() ) ); - return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys - , getChart2Document()); -} - -sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries( - const Reference< chart2::XDataSeries >& xSeries ) -{ - return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( - uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); + return ChartView::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys + , m_xChartModel.get() ); } awt::Size Chart2ModelContact::GetPageSize() const { - return ChartModelHelper::getPageSize(m_xChartModel); + return m_xChartModel.get()->getPageSize(); } awt::Rectangle Chart2ModelContact::SubstractAxisTitleSizes( const awt::Rectangle& rPositionRect ) { - awt::Rectangle aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes( - *mpModel, getChartView(), rPositionRect, true ); + awt::Rectangle aRect = ChartView::AddSubtractAxisTitleSizes( + *m_xChartModel.get(), getChartView().get(), rPositionRect, true ); return aRect; } @@ -178,8 +159,8 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const awt::Rectangle aRect( GetDiagramRectangleIncludingAxes() ); //add axis title sizes to the diagram size - aRect = ExplicitValueProvider::AddSubtractAxisTitleSizes( - *mpModel, getChartView(), aRect, false ); + aRect = ChartView::AddSubtractAxisTitleSizes( + *m_xChartModel.get(), getChartView().get(), aRect, false ); return aRect; } @@ -187,15 +168,15 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingTitle() const awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const { awt::Rectangle aRect(0,0,0,0); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); + rtl::Reference< Diagram > xDiagram = m_xChartModel.get()->getFirstChartDiagram(); - if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_INCLUDING ) - aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel); + if( xDiagram && xDiagram->getDiagramPositioningMode() == DiagramPositioningMode::Including ) + aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get()); else { - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) - aRect = pProvider->getRectangleOfObject("PlotAreaIncludingAxes"); + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) + aRect = rxChartView->getRectangleOfObject(u"PlotAreaIncludingAxes"_ustr); } return aRect; } @@ -203,15 +184,15 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleIncludingAxes() const awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const { awt::Rectangle aRect(0,0,0,0); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); + rtl::Reference< Diagram > xDiagram = m_xChartModel.get()->getFirstChartDiagram(); - if( DiagramHelper::getDiagramPositioningMode( xDiagram ) == DiagramPositioningMode_EXCLUDING ) - aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel); + if( xDiagram && xDiagram->getDiagramPositioningMode() == DiagramPositioningMode::Excluding ) + aRect = DiagramHelper::getDiagramRectangleFromModel(m_xChartModel.get()); else { - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) - aRect = pProvider->getDiagramRectangleExcludingAxes(); + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) + aRect = rxChartView->getDiagramRectangleExcludingAxes(); } return aRect; } @@ -219,12 +200,12 @@ awt::Rectangle Chart2ModelContact::GetDiagramRectangleExcludingAxes() const awt::Size Chart2ModelContact::GetLegendSize() const { awt::Size aSize; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) ); - aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + aSize = ToSize( rxChartView->getRectangleOfObject( aCID ) ); } return aSize; } @@ -232,12 +213,12 @@ awt::Size Chart2ModelContact::GetLegendSize() const awt::Point Chart2ModelContact::GetLegendPosition() const { awt::Point aPoint; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView ) { - uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *mpModel ) ); - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, *mpModel ) ); - aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_xChartModel.get() ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + aPoint = ToPoint( rxChartView->getRectangleOfObject( aCID ) ); } return aPoint; } @@ -245,11 +226,11 @@ awt::Point Chart2ModelContact::GetLegendPosition() const awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference< css::chart2::XTitle > & xTitle ) const { awt::Size aSize; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider && xTitle.is() ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView && xTitle.is() ) { OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) ); - aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + aSize = ToSize( rxChartView->getRectangleOfObject( aCID ) ); } return aSize; } @@ -257,11 +238,11 @@ awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference< css::chart2::X awt::Point Chart2ModelContact::GetTitlePosition( const uno::Reference< css::chart2::XTitle > & xTitle ) const { awt::Point aPoint; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider && xTitle.is() ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView && xTitle.is() ) { - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) ); - aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel.get() ) ); + aPoint = ToPoint( rxChartView->getRectangleOfObject( aCID ) ); } return aPoint; } @@ -269,11 +250,11 @@ awt::Point Chart2ModelContact::GetTitlePosition( const uno::Reference< css::char awt::Size Chart2ModelContact::GetAxisSize( const uno::Reference< css::chart2::XAxis > & xAxis ) const { awt::Size aSize; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider && xAxis.is() ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView && xAxis.is() ) { - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) ); - aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel.get() ) ); + aSize = ToSize( rxChartView->getRectangleOfObject( aCID ) ); } return aSize; } @@ -281,11 +262,11 @@ awt::Size Chart2ModelContact::GetAxisSize( const uno::Reference< css::chart2::XA awt::Point Chart2ModelContact::GetAxisPosition( const uno::Reference< css::chart2::XAxis > & xAxis ) const { awt::Point aPoint; - ExplicitValueProvider* pProvider( getExplicitValueProvider() ); - if( pProvider && xAxis.is() ) + rtl::Reference< ChartView > const & rxChartView = getChartView(); + if( rxChartView && xAxis.is() ) { - OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) ); - aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel.get() ) ); + aPoint = ToPoint( rxChartView->getRectangleOfObject( aCID ) ); } return aPoint; } diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx index 594bd0d87f31..40ef39fd105f 100644 --- a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -18,24 +18,22 @@ */ #pragma once -#include <cppuhelper/weakref.hxx> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Rectangle.hpp> - +#include <rtl/ref.hxx> +#include <svx/unopage.hxx> +#include <unotools/weakref.hxx> +#include <ChartModel.hxx> +#include <Diagram.hxx> #include <map> namespace chart { struct ExplicitIncrementData; } namespace chart { struct ExplicitScaleData; } namespace com::sun::star::chart2 { class XAxis; } -namespace com::sun::star::chart2 { class XChartDocument; } namespace com::sun::star::chart2 { class XDataSeries; } -namespace com::sun::star::chart2 { class XDiagram; } namespace com::sun::star::chart2 { class XTitle; } namespace com::sun::star::container { class XNameContainer; } -namespace com::sun::star::drawing { class XDrawPage; } -namespace com::sun::star::frame { class XModel; } -namespace com::sun::star::lang { class XUnoTunnel; } namespace com::sun::star::uno { class XComponentContext; } @@ -54,31 +52,25 @@ public: ~Chart2ModelContact(); public: - void setModel( const css::uno::Reference< css::frame::XModel >& xChartModel ); + void setDocumentModel( ChartModel* pChartModel ); void clear(); - css::uno::Reference< css::frame::XModel > getChartModel() const; - - ChartModel* getModel() const { return mpModel;} + rtl::Reference<ChartModel> getDocumentModel() const; - css::uno::Reference< css::chart2::XChartDocument > getChart2Document() const; - css::uno::Reference< css::chart2::XDiagram > getChart2Diagram() const; + rtl::Reference< ::chart::Diagram > getDiagram() const; - css::uno::Reference< css::drawing::XDrawPage > getDrawPage() const; + rtl::Reference<SvxDrawPage> getDrawPage() const; /** get the current values calculated for an axis in the current view in case properties are 'auto'. */ void getExplicitValuesForAxis( - const css::uno::Reference< css::chart2::XAxis > & xAxis, + const rtl::Reference< ::chart::Axis > & xAxis, ExplicitScaleData & rOutExplicitScale, ExplicitIncrementData & rOutExplicitIncrement ); sal_Int32 getExplicitNumberFormatKeyForAxis( - const css::uno::Reference< css::chart2::XAxis >& xAxis ); - - static sal_Int32 getExplicitNumberFormatKeyForSeries( - const css::uno::Reference< css::chart2::XDataSeries >& xSeries ); + const rtl::Reference< ::chart::Axis >& xAxis ); /** Returns the size of the page in logic coordinates. This value is used for setting an appropriate "ReferencePageSize" for FontHeights. @@ -129,18 +121,15 @@ public: css::awt::Point GetAxisPosition( const css::uno::Reference< css::chart2::XAxis > & xAxis ) const; private: //methods - ExplicitValueProvider* getExplicitValueProvider() const; - css::uno::Reference< css::lang::XUnoTunnel > const & getChartView() const; + rtl::Reference< ChartView > const & getChartView() const; public: //member css::uno::Reference< css::uno::XComponentContext > m_xContext; private: //member - css::uno::WeakReference< css::frame::XModel > m_xChartModel; - - ChartModel* mpModel; + unotools::WeakReference< ChartModel > m_xChartModel; - mutable css::uno::Reference< css::lang::XUnoTunnel > m_xChartView; + mutable rtl::Reference< ChartView > m_xChartView; std::map< OUString, css::uno::Reference< css::container::XNameContainer > > m_aTableMap; }; diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx index 9fc30c823a79..b2c38d31bde5 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -20,15 +20,16 @@ #include "ChartDataWrapper.hxx" #include <DiagramHelper.hxx> #include <DataSourceHelper.hxx> -#include <ChartModelHelper.hxx> +#include <InternalDataProvider.hxx> #include <ControllerLockGuard.hxx> #include "Chart2ModelContact.hxx" #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart/XChartDocument.hpp> #include <float.h> -#include <rtl/math.hxx> +#include <cmath> +#include <limits> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -48,16 +49,18 @@ uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Se uno::Sequence< uno::Sequence< double > > aRet; const sal_Int32 nOuterSize = rData.getLength(); aRet.realloc( nOuterSize ); + auto pRet = aRet.getArray(); for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) { sal_Int32 nInnerSize = rData[nOuter].getLength(); - aRet[nOuter].realloc( nInnerSize ); + pRet[nOuter].realloc( nInnerSize ); + auto pRet_nOuter = pRet[nOuter].getArray(); for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) { - aRet[nOuter][nInner] = rData[nOuter][nInner]; - double& rValue = aRet[nOuter][nInner]; + pRet_nOuter[nInner] = rData[nOuter][nInner]; + double& rValue = pRet_nOuter[nInner]; if( rValue == DBL_MIN ) - ::rtl::math::setNan( &rValue ); + rValue = std::numeric_limits<double>::quiet_NaN(); } } return aRet; @@ -68,14 +71,16 @@ uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN( const uno::Se uno::Sequence< uno::Sequence< double > > aRet; const sal_Int32 nOuterSize = rData.getLength(); aRet.realloc( nOuterSize ); + auto pRet = aRet.getArray(); for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) { sal_Int32 nInnerSize = rData[nOuter].getLength(); - aRet[nOuter].realloc( nInnerSize ); + pRet[nOuter].realloc( nInnerSize ); + auto pRet_nOuter = pRet[nOuter].getArray(); for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) { - aRet[nOuter][nInner] = rData[nOuter][nInner]; - double& rValue = aRet[nOuter][nInner]; + pRet_nOuter[nInner] = rData[nOuter][nInner]; + double& rValue = pRet_nOuter[nInner]; if( std::isnan( rValue ) ) rValue = DBL_MIN; } @@ -109,13 +114,17 @@ namespace { struct lcl_AllOperator : public lcl_Operator { explicit lcl_AllOperator( const Reference< XChartData >& xDataToApply ) - : lcl_Operator() - , m_xDataToApply( xDataToApply ) + : m_xDataToApply( xDataToApply ) { } virtual bool setsCategories( bool /*bDataInColumns*/ ) override { + // Do not force creation of categories, when original has no categories + if (auto pDataWrapper = dynamic_cast<const ChartDataWrapper*>(m_xDataToApply.get())) + if (auto xChartModel = pDataWrapper->getChartModel()) + if (auto xDiagram = xChartModel->getFirstChartDiagram()) + return xDiagram->getCategories().is(); return true; } @@ -156,8 +165,7 @@ struct lcl_AllOperator : public lcl_Operator struct lcl_DataOperator : public lcl_Operator { explicit lcl_DataOperator( const Sequence< Sequence< double > >& rData ) - : lcl_Operator() - , m_rData( rData ) + : m_rData( rData ) { } @@ -173,10 +181,9 @@ struct lcl_DataOperator : public lcl_Operator struct lcl_RowDescriptionsOperator : public lcl_Operator { lcl_RowDescriptionsOperator( const Sequence< OUString >& rRowDescriptions - , const Reference< chart2::XChartDocument >& xChartDoc ) - : lcl_Operator() - , m_rRowDescriptions( rRowDescriptions ) - , m_xChartDoc(xChartDoc) + , rtl::Reference<::chart::ChartModel> xChartDoc ) + : m_rRowDescriptions( rRowDescriptions ) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -198,17 +205,16 @@ struct lcl_RowDescriptionsOperator : public lcl_Operator } const Sequence< OUString >& m_rRowDescriptions; - Reference< chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; bool m_bDataInColumns; }; struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator { lcl_ComplexRowDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexRowDescriptions - , const Reference< chart2::XChartDocument >& xChartDoc ) - : lcl_Operator() - , m_rComplexRowDescriptions( rComplexRowDescriptions ) - , m_xChartDoc(xChartDoc) + , rtl::Reference<::chart::ChartModel> xChartDoc ) + : m_rComplexRowDescriptions( rComplexRowDescriptions ) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -230,15 +236,14 @@ struct lcl_ComplexRowDescriptionsOperator : public lcl_Operator } const Sequence< Sequence< OUString > >& m_rComplexRowDescriptions; - Reference< chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; bool m_bDataInColumns; }; struct lcl_AnyRowDescriptionsOperator : public lcl_Operator { explicit lcl_AnyRowDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyRowDescriptions ) - : lcl_Operator() - , m_rAnyRowDescriptions( rAnyRowDescriptions ) + : m_rAnyRowDescriptions( rAnyRowDescriptions ) { } @@ -259,10 +264,9 @@ struct lcl_AnyRowDescriptionsOperator : public lcl_Operator struct lcl_ColumnDescriptionsOperator : public lcl_Operator { lcl_ColumnDescriptionsOperator( const Sequence< OUString >& rColumnDescriptions - , const Reference< chart2::XChartDocument >& xChartDoc ) - : lcl_Operator() - , m_rColumnDescriptions( rColumnDescriptions ) - , m_xChartDoc(xChartDoc) + , rtl::Reference<::chart::ChartModel> xChartDoc ) + : m_rColumnDescriptions( rColumnDescriptions ) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -284,17 +288,16 @@ struct lcl_ColumnDescriptionsOperator : public lcl_Operator } const Sequence< OUString >& m_rColumnDescriptions; - Reference< chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; bool m_bDataInColumns; }; struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator { lcl_ComplexColumnDescriptionsOperator( const Sequence< Sequence< OUString > >& rComplexColumnDescriptions - , const Reference< chart2::XChartDocument >& xChartDoc ) - : lcl_Operator() - , m_rComplexColumnDescriptions( rComplexColumnDescriptions ) - , m_xChartDoc(xChartDoc) + , rtl::Reference<::chart::ChartModel> xChartDoc ) + : m_rComplexColumnDescriptions( rComplexColumnDescriptions ) + , m_xChartDoc(std::move(xChartDoc)) , m_bDataInColumns(true) { } @@ -316,15 +319,14 @@ struct lcl_ComplexColumnDescriptionsOperator : public lcl_Operator } const Sequence< Sequence< OUString > >& m_rComplexColumnDescriptions; - Reference< chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; bool m_bDataInColumns; }; struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator { explicit lcl_AnyColumnDescriptionsOperator( const Sequence< Sequence< uno::Any > >& rAnyColumnDescriptions ) - : lcl_Operator() - , m_rAnyColumnDescriptions( rAnyColumnDescriptions ) + : m_rAnyColumnDescriptions( rAnyColumnDescriptions ) { } @@ -345,8 +347,7 @@ struct lcl_AnyColumnDescriptionsOperator : public lcl_Operator struct lcl_DateCategoriesOperator : public lcl_Operator { explicit lcl_DateCategoriesOperator( const Sequence< double >& rDates ) - : lcl_Operator() - , m_rDates( rDates ) + : m_rDates( rDates ) { } @@ -367,19 +368,17 @@ struct lcl_DateCategoriesOperator : public lcl_Operator } -ChartDataWrapper::ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +ChartDataWrapper::ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { osl_atomic_increment( &m_refCount ); initDataAccess(); osl_atomic_decrement( &m_refCount ); } -ChartDataWrapper::ChartDataWrapper( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, +ChartDataWrapper::ChartDataWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact, const Reference< XChartData >& xNewData ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ) + m_spChart2ModelContact(std::move( spChart2ModelContact )) { osl_atomic_increment( &m_refCount ); lcl_AllOperator aOperator( xNewData ); @@ -469,24 +468,24 @@ void SAL_CALL ChartDataWrapper::setData( const Sequence< Sequence< double > >& r } void SAL_CALL ChartDataWrapper::setRowDescriptions( const Sequence< OUString >& rRowDescriptions ) { - lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); + lcl_RowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getDocumentModel() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setColumnDescriptions( const Sequence< OUString >& rColumnDescriptions ) { - lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); + lcl_ColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getDocumentModel() ); applyData( aOperator ); } // ____ XComplexDescriptionAccess (write) ____ void SAL_CALL ChartDataWrapper::setComplexRowDescriptions( const Sequence< Sequence< OUString > >& rRowDescriptions ) { - lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getChart2Document() ); + lcl_ComplexRowDescriptionsOperator aOperator( rRowDescriptions, m_spChart2ModelContact->getDocumentModel() ); applyData( aOperator ); } void SAL_CALL ChartDataWrapper::setComplexColumnDescriptions( const Sequence< Sequence< OUString > >& rColumnDescriptions ) { - lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getChart2Document() ); + lcl_ComplexColumnDescriptionsOperator aOperator( rColumnDescriptions, m_spChart2ModelContact->getDocumentModel() ); applyData( aOperator ); } @@ -505,7 +504,7 @@ void SAL_CALL ChartDataWrapper::setAnyColumnDescriptions( const Sequence< Sequen // ____ XDateCategories (write) ____ void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDates ) { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); ControllerLockGuardUNO aCtrlLockGuard( xChartDoc ); lcl_DateCategoriesOperator aOperator( rDates ); applyData( aOperator ); @@ -516,13 +515,15 @@ void SAL_CALL ChartDataWrapper::setDateCategories( const Sequence< double >& rDa void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener( const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) { - m_aEventListenerContainer.addInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, aListener ); } void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener( const uno::Reference< css::chart::XChartDataChangeEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } double SAL_CALL ChartDataWrapper::getNotANumber() @@ -540,20 +541,23 @@ sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber ) // ____ XComponent ____ void SAL_CALL ChartDataWrapper::dispose() { - m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); m_xDataAccess=nullptr; } void SAL_CALL ChartDataWrapper::addEventListener( const uno::Reference< lang::XEventListener > & xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL ChartDataWrapper::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // ____ XEventListener ____ @@ -563,21 +567,28 @@ void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ void ChartDataWrapper::fireChartDataChangeEvent( css::chart::ChartDataChangeEvent& aEvent ) { - if( ! m_aEventListenerContainer.getLength() ) + std::unique_lock g(m_aMutex); + if( ! m_aEventListenerContainer.getLength(g) ) return; uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this )); OSL_ASSERT( xSrc.is()); if( xSrc.is() ) - aEvent.Source = xSrc; + aEvent.Source = std::move(xSrc); - m_aEventListenerContainer.notifyEach( &css::chart::XChartDataChangeEventListener::chartDataChanged, aEvent ); + m_aEventListenerContainer.forEach( g, + [&aEvent](const uno::Reference<css::lang::XEventListener>& l) + { + uno::Reference<css::chart::XChartDataChangeEventListener> cl(l, uno::UNO_QUERY); + if (cl) + cl->chartDataChanged(aEvent); + }); } void ChartDataWrapper::switchToInternalDataProvider() { //create an internal data provider that is connected to the model - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xChartDoc.is() ) xChartDoc->createInternalDataProvider( true /*bCloneExistingData*/ ); initDataAccess(); @@ -585,7 +596,7 @@ void ChartDataWrapper::switchToInternalDataProvider() void ChartDataWrapper::initDataAccess() { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( !xChartDoc.is() ) return; if( xChartDoc->hasInternalDataProvider() ) @@ -593,15 +604,16 @@ void ChartDataWrapper::initDataAccess() else { //create a separate "internal data provider" that is not connected to the model - m_xDataAccess.set( ChartModelHelper::createInternalDataProvider( - xChartDoc, false /*bConnectToModel*/ ), uno::UNO_QUERY_THROW ); + rtl::Reference<InternalDataProvider> xInternal + = new InternalDataProvider( xChartDoc, /*bConnectToModel*/false, /*bDefaultDataInColumns*/ true ); + m_xDataAccess = xInternal; } } void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) { //bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( !xChartDoc.is() ) return; @@ -609,14 +621,14 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) bool bStacked = false; bool bPercent = false; bool bDeep = false; - uno::Reference< css::chart::XChartDocument > xOldDoc( xChartDoc, uno::UNO_QUERY ); + uno::Reference< css::chart::XChartDocument > xOldDoc( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); OSL_ASSERT( xOldDoc.is()); uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY ); if( xDiaProp.is()) { - xDiaProp->getPropertyValue("Stacked") >>= bStacked; - xDiaProp->getPropertyValue("Percent") >>= bPercent; - xDiaProp->getPropertyValue("Deep") >>= bDeep; + xDiaProp->getPropertyValue(u"Stacked"_ustr) >>= bStacked; + xDiaProp->getPropertyValue(u"Percent"_ustr) >>= bPercent; + xDiaProp->getPropertyValue(u"Deep"_ustr) >>= bDeep; } //detect arguments for the new data source @@ -649,7 +661,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) return; uno::Reference< chart2::data::XDataSource > xSource( xDataProvider->createDataSource( aArguments ) ); - uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram() ); + rtl::Reference< Diagram > xDia( xChartDoc->getFirstChartDiagram() ); if( xDia.is() ) xDia->setDiagramData( xSource, aArguments ); @@ -661,7 +673,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) eStackMode = StackMode::ZStacked; else if( bPercent ) eStackMode = StackMode::YStackedPercent; - DiagramHelper::setStackMode( xDia, eStackMode ); + xDia->setStackMode( eStackMode ); } // notify listeners @@ -674,7 +686,7 @@ void ChartDataWrapper::applyData( lcl_Operator& rDataOperator ) OUString SAL_CALL ChartDataWrapper::getImplementationName() { - return "com.sun.star.comp.chart.ChartData"; + return u"com.sun.star.comp.chart.ChartData"_ustr; } sal_Bool SAL_CALL ChartDataWrapper::supportsService( const OUString& rServiceName ) @@ -685,11 +697,16 @@ sal_Bool SAL_CALL ChartDataWrapper::supportsService( const OUString& rServiceNam css::uno::Sequence< OUString > SAL_CALL ChartDataWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartDataArray", - "com.sun.star.chart.ChartData" + u"com.sun.star.chart.ChartDataArray"_ustr, + u"com.sun.star.chart.ChartData"_ustr }; } +rtl::Reference<ChartModel> ChartDataWrapper::getChartModel() const +{ + return m_spChart2ModelContact->getDocumentModel(); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx index fd9dc2f7c50c..9a44e53b8b12 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -18,9 +18,10 @@ */ #pragma once -#include <MutexContainer.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> +#include <rtl/ref.hxx> + #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> #include <com/sun/star/chart/XDateCategories.hpp> #include <com/sun/star/lang/XComponent.hpp> @@ -29,13 +30,17 @@ #include <memory> -namespace chart::wrapper +namespace chart +{ +class ChartModel; + +namespace wrapper { class Chart2ModelContact; struct lcl_Operator; -class ChartDataWrapper final : public MutexContainer, public +class ChartDataWrapper final : public ::cppu::WeakImplHelper< css::chart2::XAnyDescriptionAccess, css::chart::XDateCategories, @@ -44,8 +49,8 @@ class ChartDataWrapper final : public MutexContainer, public css::lang::XComponent > { public: - explicit ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); - ChartDataWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact + explicit ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); + ChartDataWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact , const css::uno::Reference< css::chart::XChartData >& xNewData ); virtual ~ChartDataWrapper() override; @@ -54,6 +59,8 @@ public: virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; + rtl::Reference<ChartModel> getChartModel() const; + private: // ____ XDateCategories ____ virtual css::uno::Sequence< double > SAL_CALL getDateCategories() override; @@ -107,12 +114,13 @@ private: void initDataAccess(); void applyData( lcl_Operator& rDataOperator ); + std::mutex m_aMutex; css::uno::Reference< css::chart2::XAnyDescriptionAccess > m_xDataAccess; - std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper +} // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx index 449910274c7c..2bbff1f3c293 100644 --- a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -18,22 +18,25 @@ */ #include <ChartDocumentWrapper.hxx> +#include <ChartView.hxx> +#include <ChartViewHelper.hxx> +#include <ChartTypeManager.hxx> +#include <ChartTypeTemplate.hxx> #include <servicenames.hxx> #include <PropertyHelper.hxx> #include <TitleHelper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> #include <ControllerLockGuard.hxx> #include <DisposeHelper.hxx> #include "DataSeriesPointWrapper.hxx" -#include <chartview/ExplicitValueProvider.hxx> #include <chartview/DrawModelWrapper.hxx> #include "Chart2ModelContact.hxx" +#include <BaseCoordinateSystem.hxx> #include <ChartModel.hxx> -#include <DiagramHelper.hxx> #include <DataSourceHelper.hxx> -#include <ChartModelHelper.hxx> #include <AxisHelper.hxx> #include <ThreeDHelper.hxx> @@ -47,7 +50,7 @@ #include <cppuhelper/supportsservice.hxx> #include <comphelper/processfactory.hxx> #include <comphelper/sequence.hxx> -#include <comphelper/servicehelper.hxx> +#include <utility> #include <vcl/settings.hxx> #include <com/sun/star/drawing/ShapeCollection.hpp> @@ -55,9 +58,8 @@ #include <com/sun/star/lang/DisposedException.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/util/XRefreshable.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> -#include <vector> #include <algorithm> #include <map> @@ -216,30 +218,20 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticChartDocumentWrapperPropertyArray_Initializer +const Sequence< Property > & StaticChartDocumentWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); - return comphelper::containerToSequence( aProperties ); - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticChartDocumentWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticChartDocumentWrapperPropertyArray_Initializer > -{ -}; + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; +} } // anonymous namespace @@ -252,7 +244,7 @@ namespace { class WrappedDataSourceLabelsInFirstRowProperty : public WrappedProperty { public: - explicit WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -267,10 +259,9 @@ private: //member } -WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("DataSourceLabelsInFirstRow",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"DataSourceLabelsInFirstRow"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( nullptr ); } @@ -279,7 +270,7 @@ void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOu { bool bLabelsInFirstRow = true; if( ! (rOuterValue >>= bLabelsInFirstRow) ) - throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property DataSourceLabelsInFirstRow requires value of type boolean"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; bool bNewValue = bLabelsInFirstRow; @@ -291,19 +282,19 @@ void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOu uno::Sequence< sal_Int32 > aSequenceMapping; if( !DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) return; if( bUseColumns && bNewValue != bFirstCellAsLabel ) { DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories ); + m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories ); } else if( !bUseColumns && bNewValue != bHasCategories ) { DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue ); + m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue ); } } @@ -316,7 +307,7 @@ Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference uno::Sequence< sal_Int32 > aSequenceMapping; if( DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) { bool bLabelsInFirstRow = true; @@ -343,7 +334,7 @@ namespace { class WrappedDataSourceLabelsInFirstColumnProperty : public WrappedProperty { public: - explicit WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -358,10 +349,9 @@ private: //member } -WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("DataSourceLabelsInFirstColumn",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"DataSourceLabelsInFirstColumn"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( nullptr ); } @@ -370,7 +360,7 @@ void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& { bool bLabelsInFirstRow = true; if( ! (rOuterValue >>= bLabelsInFirstRow) ) - throw lang::IllegalArgumentException("Property DataSourceLabelsInFirstRow requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property DataSourceLabelsInFirstRow requires value of type boolean"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; bool bNewValue = bLabelsInFirstRow; @@ -382,19 +372,19 @@ void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& uno::Sequence< sal_Int32 > aSequenceMapping; if( !DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) return; if( bUseColumns && bNewValue != bHasCategories ) { DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue ); + m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue ); } else if( !bUseColumns && bNewValue != bFirstCellAsLabel ) { DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories ); + m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories ); } } @@ -407,7 +397,7 @@ Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Refere uno::Sequence< sal_Int32 > aSequenceMapping; if( DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) { bool bLabelsInFirstColumn = true; @@ -434,7 +424,7 @@ namespace { class WrappedHasLegendProperty : public WrappedProperty { public: - explicit WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasLegendProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -448,9 +438,9 @@ private: //member } -WrappedHasLegendProperty::WrappedHasLegendProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("HasLegend",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedHasLegendProperty::WrappedHasLegendProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"HasLegend"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -458,19 +448,18 @@ void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const R { bool bNewValue = true; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException("Property HasLegend requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property HasLegend requires value of type boolean"_ustr, nullptr, 0 ); try { - Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( *m_spChart2ModelContact->getModel(), m_spChart2ModelContact->m_xContext,bNewValue )); + rtl::Reference< Legend > xLegend = LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext,bNewValue ); if(xLegend.is()) { - Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW ); bool bOldValue = true; - Any aAOld = xLegendProp->getPropertyValue("Show"); + Any aAOld = xLegend->getPropertyValue(u"Show"_ustr); aAOld >>= bOldValue; if( bOldValue != bNewValue ) - xLegendProp->setPropertyValue("Show", uno::Any( bNewValue )); + xLegend->setPropertyValue(u"Show"_ustr, uno::Any( bNewValue )); } } catch (const uno::Exception&) @@ -484,10 +473,10 @@ Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropert Any aRet; try { - Reference< beans::XPropertySet > xLegendProp( - LegendHelper::getLegend( *m_spChart2ModelContact->getModel() ), uno::UNO_QUERY ); - if( xLegendProp.is()) - aRet = xLegendProp->getPropertyValue("Show"); + rtl::Reference< Legend > xLegend = + LegendHelper::getLegend( *m_spChart2ModelContact->getDocumentModel() ); + if( xLegend.is()) + aRet = xLegend->getPropertyValue(u"Show"_ustr); else aRet <<= false; } @@ -511,7 +500,7 @@ namespace { class WrappedHasMainTitleProperty : public WrappedProperty { public: - explicit WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasMainTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -525,9 +514,9 @@ private: //member } -WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("HasMainTitle",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedHasMainTitleProperty::WrappedHasMainTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"HasMainTitle"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -535,14 +524,14 @@ void WrappedHasMainTitleProperty::setPropertyValue( const Any& rOuterValue, cons { bool bNewValue = true; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException("Property HasMainTitle requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property HasMainTitle requires value of type boolean"_ustr, nullptr, 0 ); try { if( bNewValue ) - TitleHelper::createTitle( TitleHelper::MAIN_TITLE, "main-title", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + TitleHelper::createTitle( TitleHelper::MAIN_TITLE, u"main-title"_ustr, m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext ); else - TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ); + TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getDocumentModel() ); } catch (const uno::Exception&) { @@ -555,7 +544,7 @@ Any WrappedHasMainTitleProperty::getPropertyValue( const Reference< beans::XProp Any aRet; try { - aRet <<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ).is(); + aRet <<= TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getDocumentModel() ).is(); } catch (const uno::Exception&) { @@ -577,7 +566,7 @@ namespace { class WrappedHasSubTitleProperty : public WrappedProperty { public: - explicit WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedHasSubTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -591,9 +580,9 @@ private: //member } -WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("HasSubTitle",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedHasSubTitleProperty::WrappedHasSubTitleProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"HasSubTitle"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -601,14 +590,14 @@ void WrappedHasSubTitleProperty::setPropertyValue( const Any& rOuterValue, const { bool bNewValue = true; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException("Property HasSubTitle requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property HasSubTitle requires value of type boolean"_ustr, nullptr, 0 ); try { if( bNewValue ) - TitleHelper::createTitle( TitleHelper::SUB_TITLE, "", m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + TitleHelper::createTitle( TitleHelper::SUB_TITLE, u""_ustr, m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext ); else - TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ); + TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getDocumentModel() ); } catch (const uno::Exception&) { @@ -621,7 +610,7 @@ Any WrappedHasSubTitleProperty::getPropertyValue( const Reference< beans::XPrope Any aRet; try { - aRet <<= TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ).is(); + aRet <<= TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getDocumentModel() ).is(); } catch (const uno::Exception&) { @@ -651,6 +640,7 @@ ChartDocumentWrapper::~ChartDocumentWrapper() } // ____ XInterface (for new interfaces) ____ +// [-loplugin:unoaggregation] uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType ) { if( m_xDelegator.is()) @@ -665,7 +655,7 @@ Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle() { if( !m_xTitle.is() ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact ); } return m_xTitle; @@ -675,7 +665,7 @@ Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle() { if( !m_xSubTitle.is() ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact ); } return m_xSubTitle; @@ -718,24 +708,22 @@ Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram() return m_xDiagram; } -void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram ) +void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& _xDiagram ) { - uno::Reference< util::XRefreshable > xAddIn( xDiagram, uno::UNO_QUERY ); - if( xAddIn.is() ) - { - setAddIn( xAddIn ); - } - else if( xDiagram.is() && xDiagram != m_xDiagram ) + if (!_xDiagram.is()) + return; + auto xDiagram = dynamic_cast<DiagramWrapper*>(_xDiagram.get()); + assert(xDiagram); + if( xDiagram != m_xDiagram ) { // set new wrapped diagram at new chart. This requires the old // diagram given as parameter to implement the new interface. If // this is not possible throw an exception - Reference< chart2::XDiagramProvider > xNewDiaProvider( xDiagram, uno::UNO_QUERY_THROW ); - Reference< chart2::XDiagram > xNewDia( xNewDiaProvider->getDiagram()); + rtl::Reference< ::chart::Diagram > xNewDia( xDiagram->getUnderlyingDiagram()); try { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xChartDoc.is() ) { // set the new diagram @@ -766,7 +754,7 @@ void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& x if( !xNewData.is() ) return; - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact, xNewData ) ); } @@ -775,7 +763,7 @@ sal_Bool SAL_CALL ChartDocumentWrapper::attachResource( const OUString& URL, const Sequence< beans::PropertyValue >& Arguments ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->attachResource( URL, Arguments ); return false; @@ -783,7 +771,7 @@ sal_Bool SAL_CALL ChartDocumentWrapper::attachResource( OUString SAL_CALL ChartDocumentWrapper::getURL() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->getURL(); return OUString(); @@ -791,7 +779,7 @@ OUString SAL_CALL ChartDocumentWrapper::getURL() Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->getArgs(); return Sequence< beans::PropertyValue >(); @@ -799,7 +787,7 @@ Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs() void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::XController >& Controller ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->connectController( Controller ); } @@ -807,28 +795,28 @@ void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::X void SAL_CALL ChartDocumentWrapper::disconnectController( const Reference< frame::XController >& Controller ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->disconnectController( Controller ); } void SAL_CALL ChartDocumentWrapper::lockControllers() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->lockControllers(); } void SAL_CALL ChartDocumentWrapper::unlockControllers() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->unlockControllers(); } sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->hasControllersLocked(); return false; @@ -836,7 +824,7 @@ sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked() Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->getCurrentController(); return nullptr; @@ -845,14 +833,14 @@ Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentControl void SAL_CALL ChartDocumentWrapper::setCurrentController( const Reference< frame::XController >& Controller ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->setCurrentController( Controller ); } Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection() { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) return xModel->getCurrentSelection(); return nullptr; @@ -862,23 +850,26 @@ Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection( void SAL_CALL ChartDocumentWrapper::dispose() { if( m_bIsDisposed ) - throw lang::DisposedException("ChartDocumentWrapper is disposed", - static_cast< ::cppu::OWeakObject* >( this )); + return; m_bIsDisposed = true; try { Reference< lang::XComponent > xFormerDelegator( m_xDelegator, uno::UNO_QUERY ); - DisposeHelper::DisposeAndClear( m_xTitle ); + if (m_xTitle) + { + m_xTitle->dispose(); + m_xTitle.clear(); + } DisposeHelper::DisposeAndClear( m_xSubTitle ); DisposeHelper::DisposeAndClear( m_xLegend ); DisposeHelper::DisposeAndClear( m_xChartData ); DisposeHelper::DisposeAndClear( m_xDiagram ); DisposeHelper::DisposeAndClear( m_xArea ); - m_xChartView.set( nullptr ); - m_xShapeFactory.set( nullptr ); - m_xDelegator.set( nullptr ); + m_xChartView.clear(); + m_xShapeFactory.clear(); + m_xDelegator.clear(); clearWrappedPropertySet(); m_spChart2ModelContact->clear(); @@ -905,7 +896,7 @@ void SAL_CALL ChartDocumentWrapper::dispose() void ChartDocumentWrapper::impl_resetAddIn() { Reference< util::XRefreshable > xAddIn( m_xAddIn ); - m_xAddIn.set( nullptr ); + m_xAddIn.clear(); if( !xAddIn.is() ) return; @@ -941,7 +932,7 @@ void ChartDocumentWrapper::impl_resetAddIn() void ChartDocumentWrapper::setBaseDiagram( const OUString& rBaseDiagram ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); m_aBaseDiagram = rBaseDiagram; uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram ), uno::UNO_QUERY ); @@ -954,7 +945,7 @@ void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAdd if( m_xAddIn == xAddIn ) return; - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); impl_resetAddIn(); m_xAddIn = xAddIn; // initialize AddIn with this as chart document @@ -962,7 +953,7 @@ void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAdd if( xInit.is() ) { uno::Any aParam; - uno::Reference< XChartDocument > xDoc( static_cast<XChartDocument*>(this), uno::UNO_QUERY ); + uno::Reference< XChartDocument > xDoc(this); aParam <<= xDoc; uno::Sequence< uno::Any > aSeq( &aParam, 1 ); xInit->initialize( aSeq ); @@ -978,7 +969,7 @@ Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const { // get additional non-chart shapes for XML export uno::Reference< drawing::XShapes > xFoundShapes; - uno::Reference< drawing::XDrawPage > xDrawPage( impl_getDrawPage() ); + rtl::Reference<SvxDrawPage> xDrawPage( impl_getDrawPage() ); if( !xDrawPage.is() ) return xFoundShapes; @@ -1018,14 +1009,14 @@ Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->addEventListener( xListener ); } void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + rtl::Reference< ChartModel > xModel( m_spChart2ModelContact->getDocumentModel() ); if( xModel.is() ) xModel->removeEventListener( aListener ); } @@ -1036,18 +1027,17 @@ uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage( return impl_getDrawPage(); } -uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const +rtl::Reference<SvxDrawPage> ChartDocumentWrapper::impl_getDrawPage() const { return m_spChart2ModelContact->getDrawPage(); } namespace { -uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const uno::Reference<uno::XInterface>& xChartView) +uno::Reference< lang::XMultiServiceFactory > getShapeFactory(const rtl::Reference<ChartView>& xChartView) { - auto pProvider = comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(xChartView); - if( pProvider ) - return pProvider->getDrawModelWrapper()->getShapeFactory(); + if( xChartView ) + return xChartView->getDrawModelWrapper()->getShapeFactory(); return uno::Reference< lang::XMultiServiceFactory >(); } @@ -1060,7 +1050,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { uno::Reference< uno::XInterface > xResult; - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( !xChartDoc.is() ) return xResult; @@ -1071,102 +1061,92 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( if( aIt != rMap.end()) { bool bCreateDiagram = false; - uno::Reference< lang::XMultiServiceFactory > xManagerFact( - xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate; + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = + xChartDoc->getTypeManager(); + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate; switch( (*aIt).second ) { case SERVICE_NAME_AREA_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Area"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Area"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_BAR_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { // this is for bar and column (the latter is the default if // no "Vertical=false" property was set) - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Column"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Column"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_DONUT_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Donut"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Donut"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_LINE_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Line"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Line"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_NET_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Net"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Net"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_FILLED_NET_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.FilledNet"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.FilledNet"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_PIE_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Pie"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Pie"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_STOCK_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.StockLowHighClose"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.StockLowHighClose"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_XY_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.ScatterLineSymbol"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.ScatterLineSymbol"_ustr); bCreateDiagram = true; } break; case SERVICE_NAME_BUBBLE_DIAGRAM: - if( xManagerFact.is()) + if( xChartTypeManager.is()) { - xTemplate.set( - xManagerFact->createInstance("com.sun.star.chart2.template.Bubble"), - uno::UNO_QUERY ); + xTemplate = + xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Bubble"_ustr); bCreateDiagram = true; } break; @@ -1177,12 +1157,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( case SERVICE_NAME_BITMAP_TABLE: case SERVICE_NAME_TRANSP_GRADIENT_TABLE: case SERVICE_NAME_MARKER_TABLE: - { - uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartDoc, uno::UNO_QUERY ); - OSL_ENSURE( xTableFactory.get() != this, "new model is expected to implement service factory for gradient table etc" ); - if( xTableFactory.is() && xTableFactory.get() != this ) - xResult.set( xTableFactory->createInstance( aIt->first ), uno::UNO_QUERY ); - } + xResult.set( xChartDoc->createInstance( aIt->first ), uno::UNO_QUERY ); break; case SERVICE_NAME_NAMESPACE_MAP: @@ -1202,17 +1177,17 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { // locked controllers ControllerLockGuardUNO aCtrlLockGuard( xChartDoc ); - Reference< chart2::XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartDoc ); - ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); - Reference< lang::XMultiServiceFactory > xTemplateManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateWithService( - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); - if( aTemplateWithService.first.is()) - aTemplateWithService.first->resetStyles( xDiagram );//#i109371# + rtl::Reference< Diagram > xDiagram = xChartDoc->getFirstChartDiagram(); + ThreeDLookScheme e3DScheme = xDiagram->detectScheme(); + rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateWithService( + xDiagram->getTemplate( xTemplateManager )); + if( aTemplateWithService.xChartTypeTemplate.is()) + aTemplateWithService.xChartTypeTemplate->resetStyles2( xDiagram );//#i109371# xTemplate->changeDiagram( xDiagram ); if( AllSettings::GetMathLayoutRTL() ) AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); - ThreeDHelper::setScheme( xDiagram, e3DScheme ); + xDiagram->setScheme( e3DScheme ); } else { @@ -1244,28 +1219,23 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( { if( !m_xChartView.is() ) { - Reference< lang::XMultiServiceFactory > xFact( - m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); - Reference< lang::XInitialization > xViewInit( xFact->createInstance( - CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); - if(xViewInit.is()) + rtl::Reference<::chart::ChartModel> pChartModel = new ::chart::ChartModel(m_spChart2ModelContact->m_xContext); + rtl::Reference<ChartView> xChartView = new ::chart::ChartView(m_spChart2ModelContact->m_xContext, *pChartModel); + + try { - try - { - m_xChartView = xViewInit; + m_xChartView = xChartView; - Sequence< Any > aArguments(2); - aArguments[0] <<= Reference<frame::XModel>(this); - aArguments[1] <<= true; // bRefreshAddIn - xViewInit->initialize(aArguments); - } - catch (const uno::Exception&) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + Sequence< Any > aArguments{ Any(Reference<frame::XModel>(this)), + Any(true) }; // bRefreshAddIn + xChartView->initialize(aArguments); + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); } } - xResult.set( m_xChartView ); + xResult.set( static_cast<cppu::OWeakObject*>(m_xChartView.get()) ); bServiceFound = true; } else @@ -1279,7 +1249,7 @@ uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( } else { - ChartModel* pModel = m_spChart2ModelContact->getModel(); + rtl::Reference<ChartModel> pModel = m_spChart2ModelContact->getDocumentModel(); if(pModel) { m_xChartView = pModel->getChartView(); @@ -1343,7 +1313,7 @@ void SAL_CALL ChartDocumentWrapper::setDelegator( if( m_bIsDisposed ) { if( rDelegator.is() ) - throw lang::DisposedException("ChartDocumentWrapper is disposed", + throw lang::DisposedException(u"ChartDocumentWrapper is disposed"_ustr, static_cast< ::cppu::OWeakObject* >( this )); return; } @@ -1351,7 +1321,9 @@ void SAL_CALL ChartDocumentWrapper::setDelegator( if( rDelegator.is()) { m_xDelegator = rDelegator; - m_spChart2ModelContact->setModel( uno::Reference< frame::XModel >(m_xDelegator, uno::UNO_QUERY) ); + ChartModel* pChartModel = dynamic_cast<ChartModel*>(rDelegator.get()); + assert(pChartModel); + m_spChart2ModelContact->setDocumentModel( pChartModel ); } else { @@ -1375,22 +1347,36 @@ uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType // ____ ::utl::OEventListenerAdapter ____ void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource ) { - if( rSource.Source == m_xTitle ) - m_xTitle.set( nullptr ); - else if( rSource.Source == m_xSubTitle ) - m_xSubTitle.set( nullptr ); - else if( rSource.Source == m_xLegend ) - m_xLegend.set( nullptr ); + if( rSource.Source == cppu::getXWeak(m_xTitle.get()) ) + m_xTitle.clear(); + else if( rSource.Source == cppu::getXWeak(m_xSubTitle.get()) ) + m_xSubTitle.clear(); + else if( rSource.Source == cppu::getXWeak(m_xLegend.get()) ) + m_xLegend.clear(); else if( rSource.Source == m_xChartData ) - m_xChartData.set( nullptr ); - else if( rSource.Source == m_xDiagram ) - m_xDiagram.set( nullptr ); + m_xChartData.clear(); + else if( rSource.Source == cppu::getXWeak(m_xDiagram.get()) ) + m_xDiagram.clear(); else if( rSource.Source == m_xArea ) - m_xArea.set( nullptr ); + m_xArea.clear(); else if( rSource.Source == m_xAddIn ) - m_xAddIn.set( nullptr ); - else if( rSource.Source == m_xChartView ) - m_xChartView.set( nullptr ); + m_xAddIn.clear(); + else if( rSource.Source == static_cast<cppu::OWeakObject*>(m_xChartView.get()) ) + m_xChartView.clear(); +} + +// ____ XPropertySet ____ +void SAL_CALL ChartDocumentWrapper::setPropertyValue(const OUString& rPropertyName, const css::uno::Any& rValue) +{ + if (rPropertyName == u"ODFImport_UpdateView") + { + // A hack used at load time to notify the view that it needs an update + // See SchXMLImport::~SchXMLImport + if (auto xChartModel = rValue.query<css::chart2::XChartDocument>()) + ChartViewHelper::setViewToDirtyState_UNO(xChartModel); + return; + } + ChartDocumentWrapper_Base::setPropertyValue(rPropertyName, rValue); } // WrappedPropertySet @@ -1400,7 +1386,7 @@ Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet() } const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence() { - return *StaticChartDocumentWrapperPropertyArray::get(); + return StaticChartDocumentWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > ChartDocumentWrapper::createWrappedProperties() @@ -1415,16 +1401,16 @@ std::vector< std::unique_ptr<WrappedProperty> > ChartDocumentWrapper::createWrap aWrappedProperties.emplace_back( new WrappedBaseDiagramProperty( *this ) ); aWrappedProperties.emplace_back( new WrappedAdditionalShapesProperty( *this ) ); aWrappedProperties.emplace_back( new WrappedRefreshAddInAllowedProperty( *this ) ); - aWrappedProperties.emplace_back( new WrappedIgnoreProperty("NullDate",Any() ) ); // i99104 - aWrappedProperties.emplace_back( new WrappedIgnoreProperty("EnableComplexChartTypes", uno::Any(true) ) ); - aWrappedProperties.emplace_back( new WrappedIgnoreProperty("EnableDataTableDialog", uno::Any(true) ) ); + aWrappedProperties.emplace_back( new WrappedIgnoreProperty(u"NullDate"_ustr,Any() ) ); // i99104 + aWrappedProperties.emplace_back( new WrappedIgnoreProperty(u"EnableComplexChartTypes"_ustr, uno::Any(true) ) ); + aWrappedProperties.emplace_back( new WrappedIgnoreProperty(u"EnableDataTableDialog"_ustr, uno::Any(true) ) ); return aWrappedProperties; } OUString SAL_CALL ChartDocumentWrapper::getImplementationName() { - return CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME; + return u"com.sun.star.comp.chart2.ChartDocumentWrapper"_ustr; } sal_Bool SAL_CALL ChartDocumentWrapper::supportsService( const OUString& rServiceName ) @@ -1435,10 +1421,10 @@ sal_Bool SAL_CALL ChartDocumentWrapper::supportsService( const OUString& rServic css::uno::Sequence< OUString > SAL_CALL ChartDocumentWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartDocument", - CHART_CHARTAPIWRAPPER_SERVICE_NAME, - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.beans.PropertySet" + u"com.sun.star.chart.ChartDocument"_ustr, + u"com.sun.star.chart2.ChartDocumentWrapper"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.beans.PropertySet"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx index b2c819a87874..fe2552f7f5b4 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -19,8 +19,11 @@ #include "DataSeriesPointWrapper.hxx" #include "Chart2ModelContact.hxx" +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <DiagramHelper.hxx> +#include <DataSeries.hxx> +#include <DataSeriesProperties.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <CharacterProperties.hxx> @@ -37,6 +40,7 @@ #include "WrappedTextRotationProperty.hxx" #include <unonames.hxx> +#include <o3tl/safeint.hxx> #include <rtl/math.hxx> #include <algorithm> @@ -45,6 +49,7 @@ #include <com/sun/star/chart/ChartAxisAssign.hpp> #include <com/sun/star/chart/ChartErrorCategory.hpp> #include <com/sun/star/chart/ChartSymbolType.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> #include <com/sun/star/drawing/LineJoint.hpp> #include <com/sun/star/drawing/LineStyle.hpp> #include <com/sun/star/drawing/FillStyle.hpp> @@ -55,6 +60,7 @@ using namespace ::com::sun::star; using namespace ::chart::wrapper; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -243,30 +249,16 @@ uno::Sequence< Property > lcl_GetPropertySequence( DataSeriesPointWrapper::eType return comphelper::containerToSequence( aProperties ); } -struct StaticSeriesWrapperPropertyArray_Initializer +const Sequence< Property >& StaticSeriesWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); - return &aPropSeq; - } + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_SERIES ) ); + return aPropSeq; }; -struct StaticSeriesWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticSeriesWrapperPropertyArray_Initializer > -{ -}; - -struct StaticPointWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); - return &aPropSeq; - } -}; - -struct StaticPointWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticPointWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticPointWrapperPropertyArray() { + static Sequence< Property > aPropSeq( lcl_GetPropertySequence( DataSeriesPointWrapper::DATA_POINT ) ); + return aPropSeq; }; //PROP_SERIES_ATTACHED_AXIS @@ -287,7 +279,7 @@ protected: WrappedAttachedAxisProperty::WrappedAttachedAxisProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) - : WrappedProperty("Axis",OUString()) + : WrappedProperty(u"Axis"_ustr,OUString()) , m_spChart2ModelContact( spChart2ModelContact ) { } @@ -303,8 +295,8 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp { Any aRet; - uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); - bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); + bool bAttachedToMainAxis = xDataSeries->isAttachedToMainAxis(); if( bAttachedToMainAxis ) aRet <<= css::chart::ChartAxisAssign::PRIMARY_Y; else @@ -314,20 +306,20 @@ Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XProp void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xDataSeries( dynamic_cast<::chart::DataSeries*>(xInnerPropertySet.get()) ); sal_Int32 nChartAxisAssign = css::chart::ChartAxisAssign::PRIMARY_Y; if( ! (rOuterValue >>= nChartAxisAssign) ) - throw lang::IllegalArgumentException("Property Axis requires value of type sal_Int32", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property Axis requires value of type sal_Int32"_ustr, nullptr, 0 ); bool bNewAttachedToMainAxis = nChartAxisAssign == css::chart::ChartAxisAssign::PRIMARY_Y; - bool bOldAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + bool bOldAttachedToMainAxis = xDataSeries->isAttachedToMainAxis(); if( bNewAttachedToMainAxis != bOldAttachedToMainAxis) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) - ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext, false ); + xDiagram->attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, m_spChart2ModelContact->m_xContext, false ); } } @@ -342,7 +334,7 @@ protected: }; WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() : - WrappedProperty("SegmentOffset","Offset") + WrappedProperty(u"SegmentOffset"_ustr,u"Offset"_ustr) {} Any WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any& rInnerValue ) const @@ -387,7 +379,7 @@ protected: WrappedLineColorProperty::WrappedLineColorProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper ) - : WrappedSeriesAreaOrLineProperty("LineColor","BorderColor","Color", pDataSeriesPointWrapper ) + : WrappedSeriesAreaOrLineProperty(u"LineColor"_ustr,u"BorderColor"_ustr,u"Color"_ustr, pDataSeriesPointWrapper ) , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) , m_aDefaultValue(uno::Any(sal_Int32( 0x0099ccff ))) // blue 8 { @@ -428,7 +420,7 @@ protected: WrappedLineStyleProperty::WrappedLineStyleProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper ) - : WrappedSeriesAreaOrLineProperty("LineStyle","BorderStyle", "LineStyle", pDataSeriesPointWrapper ) + : WrappedSeriesAreaOrLineProperty(u"LineStyle"_ustr,u"BorderStyle"_ustr, u"LineStyle"_ustr, pDataSeriesPointWrapper ) , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) { } @@ -454,9 +446,8 @@ void WrappedLineStyleProperty::setPropertyToDefault( const Reference< beans::XPr namespace chart::wrapper { -DataSeriesPointWrapper::DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) +DataSeriesPointWrapper::DataSeriesPointWrapper( std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact( std::move(spChart2ModelContact) ) , m_eType( DATA_SERIES ) , m_nSeriesIndexInNewAPI( -1 ) , m_nPointIndex( -1 ) @@ -473,14 +464,18 @@ void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any m_nPointIndex = -1; if( aArguments.hasElements() ) { - aArguments[0] >>= m_xDataSeries; + uno::Reference<chart2::XDataSeries> xTmp; + aArguments[0] >>= xTmp; + auto p = dynamic_cast<DataSeries*>(xTmp.get()); + assert(p); + m_xDataSeries = p; if( aArguments.getLength() >= 2 ) aArguments[1] >>= m_nPointIndex; } if( !m_xDataSeries.is() ) throw uno::Exception( - "DataSeries index invalid", static_cast< ::cppu::OWeakObject * >( this )); + u"DataSeries index invalid"_ustr, static_cast< ::cppu::OWeakObject * >( this )); //todo: check upper border of point index @@ -493,9 +488,8 @@ void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any DataSeriesPointWrapper::DataSeriesPointWrapper(eType _eType, sal_Int32 nSeriesIndexInNewAPI , sal_Int32 nPointIndex, //ignored for series - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) + std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact( std::move(spChart2ModelContact) ) , m_eType( _eType ) , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI ) , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 ) @@ -510,8 +504,9 @@ DataSeriesPointWrapper::~DataSeriesPointWrapper() // ____ XComponent ____ void SAL_CALL DataSeriesPointWrapper::dispose() { + std::unique_lock g(m_aMutex); uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); m_xDataSeries.clear(); clearWrappedPropertySet(); @@ -520,13 +515,15 @@ void SAL_CALL DataSeriesPointWrapper::dispose() void SAL_CALL DataSeriesPointWrapper::addEventListener( const uno::Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL DataSeriesPointWrapper::removeEventListener( const uno::Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // ____ XEventListener ____ @@ -536,24 +533,25 @@ void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Sour bool DataSeriesPointWrapper::isSupportingAreaProperties() { - Reference< chart2::XDataSeries > xSeries( getDataSeries() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - - return ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ); + rtl::Reference< DataSeries > xSeries( getDataSeries() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); + if (!xChartType.is()) + return false; + sal_Int32 nDimensionCount = xDiagram->getDimension(); + return xChartType->isSupportingAreaProperties(nDimensionCount); } -Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries() +rtl::Reference< DataSeries > DataSeriesPointWrapper::getDataSeries() { - Reference< chart2::XDataSeries > xSeries( m_xDataSeries ); + rtl::Reference< DataSeries > xSeries = m_xDataSeries; if( !xSeries.is() ) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + std::vector< rtl::Reference< DataSeries > > aSeriesList = + xDiagram->getDataSeries(); - if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < static_cast<sal_Int32>(aSeriesList.size()) ) + if( m_nSeriesIndexInNewAPI >= 0 && o3tl::make_unsigned(m_nSeriesIndexInNewAPI) < aSeriesList.size() ) xSeries = aSeriesList[m_nSeriesIndexInNewAPI]; } @@ -564,7 +562,7 @@ Reference< beans::XPropertySet > DataSeriesPointWrapper::getDataPointProperties( { Reference< beans::XPropertySet > xPointProp; - Reference< chart2::XDataSeries > xSeries( getDataSeries() ); + rtl::Reference< DataSeries > xSeries( getDataSeries() ); // may throw an IllegalArgumentException if( xSeries.is() ) @@ -579,8 +577,8 @@ void DataSeriesPointWrapper::updateReferenceSize() Reference< beans::XPropertySet > xProp = getInnerPropertySet(); if( xProp.is() ) { - if( xProp->getPropertyValue("ReferencePageSize").hasValue() ) - xProp->setPropertyValue("ReferencePageSize", uno::Any( + if( xProp->getPropertyValue(u"ReferencePageSize"_ustr).hasValue() ) + xProp->setPropertyValue(u"ReferencePageSize"_ustr, uno::Any( m_spChart2ModelContact->GetPageSize() )); } } @@ -589,7 +587,7 @@ Any DataSeriesPointWrapper::getReferenceSize() Any aRet; Reference< beans::XPropertySet > xProp = getInnerPropertySet(); if( xProp.is() ) - aRet = xProp->getPropertyValue("ReferencePageSize"); + aRet = xProp->getPropertyValue(u"ReferencePageSize"_ustr); return aRet; } awt::Size DataSeriesPointWrapper::getCurrentSizeForReference() @@ -607,7 +605,7 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU { if (rPropertyName == "SymbolBitmap" || rPropertyName == "SymbolBitmapURL") { - uno::Any aAny = WrappedPropertySet::getPropertyValue("SymbolType"); + uno::Any aAny = WrappedPropertySet::getPropertyValue(u"SymbolType"_ustr); sal_Int32 nVal = css::chart::ChartSymbolType::NONE; if (aAny >>= nVal) { @@ -622,9 +620,10 @@ beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const OU { if( rPropertyName == "FillColor") { - Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = getDataSeries(); bool bVaryColorsByPoint = false; - if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) + // "VaryColorsByPoint" + if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint) && bVaryColorsByPoint ) return beans::PropertyState_DIRECT_VALUE; } @@ -683,7 +682,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rProper if( nHandle > 0 ) { //always take the series current value as default for points - Reference< beans::XPropertySet > xInnerPropertySet( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xInnerPropertySet = getDataSeries(); if( xInnerPropertySet.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -704,16 +703,16 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const OUString& rProper Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet() { if( m_eType == DATA_SERIES ) - return Reference< beans::XPropertySet >( getDataSeries(), uno::UNO_QUERY ); + return getDataSeries(); return getDataPointProperties(); } const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence() { if( m_eType == DATA_SERIES ) - return *StaticSeriesWrapperPropertyArray::get(); + return StaticSeriesWrapperPropertyArray(); else - return *StaticPointWrapperPropertyArray::get(); + return StaticPointWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWrappedProperties() @@ -737,38 +736,38 @@ std::vector< std::unique_ptr<WrappedProperty> > DataSeriesPointWrapper::createWr //add unnamed line properties (different inner names here) - aWrappedProperties.emplace_back( new WrappedProperty("FillColor","Color") ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillColor"_ustr,u"Color"_ustr) ); aWrappedProperties.emplace_back( new WrappedLineStyleProperty( this ) ); aWrappedProperties.emplace_back( new WrappedLineColorProperty( this ) ); - aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineDashName","BorderDashName","LineDashName", this ) ); - aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineTransparence","BorderTransparency","Transparency", this ) ); - aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineWidth","BorderWidth","LineWidth", this ) ); - aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty("LineCap","LineCap","LineCap", this ) ); - aWrappedProperties.emplace_back( new WrappedProperty("FillStyle","FillStyle" ) ); - aWrappedProperties.emplace_back( new WrappedProperty("FillTransparence","Transparency") ); - - aWrappedProperties.emplace_back( new WrappedIgnoreProperty("LineJoint", uno::Any( drawing::LineJoint_ROUND ) ) ); - aWrappedProperties.emplace_back( new WrappedProperty("FillTransparenceGradientName","TransparencyGradientName") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillGradientName","GradientName") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillGradientStepCount","GradientStepCount") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillHatchName","HatchName") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapName","FillBitmapName") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBackground","FillBackground") ); + aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty(u"LineDashName"_ustr,u"BorderDashName"_ustr,u"LineDashName"_ustr, this ) ); + aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty(u"LineTransparence"_ustr,u"BorderTransparency"_ustr,u"Transparency"_ustr, this ) ); + aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty(u"LineWidth"_ustr,u"BorderWidth"_ustr,u"LineWidth"_ustr, this ) ); + aWrappedProperties.emplace_back( new WrappedSeriesAreaOrLineProperty(u"LineCap"_ustr,u"LineCap"_ustr,u"LineCap"_ustr, this ) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillStyle"_ustr,u"FillStyle"_ustr ) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillTransparence"_ustr,u"Transparency"_ustr) ); + + aWrappedProperties.emplace_back( new WrappedIgnoreProperty(u"LineJoint"_ustr, uno::Any( drawing::LineJoint_ROUND ) ) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillTransparenceGradientName"_ustr,u"TransparencyGradientName"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillGradientName"_ustr,u"GradientName"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillGradientStepCount"_ustr,u"GradientStepCount"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillHatchName"_ustr,u"HatchName"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapName"_ustr,u"FillBitmapName"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBackground"_ustr,u"FillBackground"_ustr) ); //bitmap properties - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapMode","FillBitmapMode") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeX","FillBitmapSizeX") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapSizeY","FillBitmapSizeY") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapLogicalSize","FillBitmapLogicalSize") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetX","FillBitmapOffsetX") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapOffsetY","FillBitmapOffsetY") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapRectanglePoint","FillBitmapRectanglePoint") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetX","FillBitmapPositionOffsetX") ); - aWrappedProperties.emplace_back( new WrappedProperty("FillBitmapPositionOffsetY","FillBitmapPositionOffsetY") ); - - aWrappedProperties.emplace_back( new WrappedProperty("SolidType","Geometry3D") ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapMode"_ustr,u"FillBitmapMode"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapSizeX"_ustr,u"FillBitmapSizeX"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapSizeY"_ustr,u"FillBitmapSizeY"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapLogicalSize"_ustr,u"FillBitmapLogicalSize"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapOffsetX"_ustr,u"FillBitmapOffsetX"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapOffsetY"_ustr,u"FillBitmapOffsetY"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapRectanglePoint"_ustr,u"FillBitmapRectanglePoint"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapPositionOffsetX"_ustr,u"FillBitmapPositionOffsetX"_ustr) ); + aWrappedProperties.emplace_back( new WrappedProperty(u"FillBitmapPositionOffsetY"_ustr,u"FillBitmapPositionOffsetY"_ustr) ); + + aWrappedProperties.emplace_back( new WrappedProperty(u"SolidType"_ustr,u"Geometry3D"_ustr) ); aWrappedProperties.emplace_back( new WrappedSegmentOffsetProperty() ); - aWrappedProperties.emplace_back( new WrappedProperty("D3DPercentDiagonal","PercentDiagonal") ); + aWrappedProperties.emplace_back( new WrappedProperty(u"D3DPercentDiagonal"_ustr,u"PercentDiagonal"_ustr) ); aWrappedProperties.emplace_back( new WrappedTextRotationProperty() ); @@ -780,11 +779,11 @@ void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const OUString& rPropert if(rPropertyName == "Lines") { if( ! (rValue >>= m_bLinesAllowed) ) - throw lang::IllegalArgumentException("Property Lines requires value of type sal_Bool", nullptr, 0 ); + throw lang::IllegalArgumentException(u"Property Lines requires value of type sal_Bool"_ustr, nullptr, 0 ); } sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); - static const sal_Int32 nErrorCategoryHandle = getInfoHelper().getHandleByName("ErrorCategory"); + static const sal_Int32 nErrorCategoryHandle = getInfoHelper().getHandleByName(u"ErrorCategory"_ustr); if( nErrorCategoryHandle == nHandle ) { css::chart::ChartErrorCategory aNewValue = css::chart::ChartErrorCategory_NONE; @@ -794,16 +793,16 @@ void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const OUString& rPropert switch(aNewValue) { case css::chart::ChartErrorCategory_CONSTANT_VALUE: - aHigh = getPropertyValue("ConstantErrorHigh"); - aLow = getPropertyValue("ConstantErrorLow"); + aHigh = getPropertyValue(u"ConstantErrorHigh"_ustr); + aLow = getPropertyValue(u"ConstantErrorLow"_ustr); bSetHighAndLowValues = true; break; case css::chart::ChartErrorCategory_PERCENT: - aHigh = aLow = getPropertyValue("PercentageError"); + aHigh = aLow = getPropertyValue(u"PercentageError"_ustr); bSetHighAndLowValues = true; break; case css::chart::ChartErrorCategory_ERROR_MARGIN: - aHigh = aLow = getPropertyValue("ErrorMargin"); + aHigh = aLow = getPropertyValue(u"ErrorMargin"_ustr); bSetHighAndLowValues = true; break; default: @@ -817,14 +816,14 @@ void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const OUString& rPropert switch(aNewValue) { case css::chart::ChartErrorCategory_CONSTANT_VALUE: - setPropertyValue("ConstantErrorHigh",aHigh); - setPropertyValue("ConstantErrorLow",aLow); + setPropertyValue(u"ConstantErrorHigh"_ustr,aHigh); + setPropertyValue(u"ConstantErrorLow"_ustr,aLow); break; case css::chart::ChartErrorCategory_PERCENT: - setPropertyValue("PercentageError",aHigh); + setPropertyValue(u"PercentageError"_ustr,aHigh); break; case css::chart::ChartErrorCategory_ERROR_MARGIN: - setPropertyValue("ErrorMargin",aHigh); + setPropertyValue(u"ErrorMargin"_ustr,aHigh); break; default: break; @@ -841,15 +840,16 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rProperty { if( rPropertyName == "FillColor" ) { - Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = getDataSeries(); bool bVaryColorsByPoint = false; - if( xSeriesProp.is() && (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) + // "VaryColorsByPoint" + if( xSeries.is() && (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint) && bVaryColorsByPoint ) { uno::Reference< beans::XPropertyState > xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY ); - if( xPointState.is() && xPointState->getPropertyState("Color") == beans::PropertyState_DEFAULT_VALUE ) + if( xPointState.is() && xPointState->getPropertyState(u"Color"_ustr) == beans::PropertyState_DEFAULT_VALUE ) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() ); @@ -865,7 +865,7 @@ Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const OUString& rProperty OUString SAL_CALL DataSeriesPointWrapper::getImplementationName() { - return "com.sun.star.comp.chart.DataSeries"; + return u"com.sun.star.comp.chart.DataSeries"_ustr; } sal_Bool SAL_CALL DataSeriesPointWrapper::supportsService( const OUString& rServiceName ) @@ -876,13 +876,13 @@ sal_Bool SAL_CALL DataSeriesPointWrapper::supportsService( const OUString& rServ css::uno::Sequence< OUString > SAL_CALL DataSeriesPointWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartDataRowProperties", - "com.sun.star.chart.ChartDataPointProperties", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.beans.PropertySet", - "com.sun.star.drawing.FillProperties", - "com.sun.star.drawing.LineProperties", - "com.sun.star.style.CharacterProperties" + u"com.sun.star.chart.ChartDataRowProperties"_ustr, + u"com.sun.star.chart.ChartDataPointProperties"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.beans.PropertySet"_ustr, + u"com.sun.star.drawing.FillProperties"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr, + u"com.sun.star.style.CharacterProperties"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx index 5bf582586d9c..52322dfe46c9 100644 --- a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx @@ -21,15 +21,15 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XInitialization.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> - +#include <rtl/ref.hxx> #include <memory> -namespace com::sun::star::chart2 { class XDataSeries; } +namespace chart { class DataSeries; } namespace chart::wrapper { @@ -54,12 +54,12 @@ public: }; //this constructor needs an initialize call afterwards - explicit DataSeriesPointWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit DataSeriesPointWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); DataSeriesPointWrapper(eType eType , sal_Int32 nSeriesIndexInNewAPI , sal_Int32 nPointIndex //ignored for series - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~DataSeriesPointWrapper() override; @@ -100,11 +100,11 @@ private: virtual css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override; //own methods - css::uno::Reference< css::chart2::XDataSeries > getDataSeries(); + rtl::Reference< ::chart::DataSeries > getDataSeries(); css::uno::Reference< css::beans::XPropertySet > getDataPointProperties(); std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; eType m_eType; sal_Int32 m_nSeriesIndexInNewAPI; @@ -115,7 +115,7 @@ private: //this should only be used, if the DataSeriesPointWrapper is initialized via the XInitialize interface //because a big change in the chartmodel may lead to a dataseriespointer that is not connected to the model anymore //with the indices instead we can always get the new dataseries - css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; + rtl::Reference< ::chart::DataSeries > m_xDataSeries; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx index 8b068a9a57c7..217921db9f00 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -20,14 +20,17 @@ #include "DiagramWrapper.hxx" #include <servicenames_charttypes.hxx> #include "DataSeriesPointWrapper.hxx" +#include <DataSeriesProperties.hxx> #include "AxisWrapper.hxx" #include "Chart2ModelContact.hxx" #include "WallFloorWrapper.hxx" #include "MinMaxLineWrapper.hxx" #include "UpDownBarWrapper.hxx" +#include <Diagram.hxx> #include <DiagramHelper.hxx> #include <DataSourceHelper.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> +#include <DataSeries.hxx> #include <WrappedIgnoreProperty.hxx> #include "WrappedAxisAndGridExistenceProperties.hxx" #include "WrappedStatisticProperties.hxx" @@ -43,15 +46,16 @@ #include <unonames.hxx> #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> +#include <ChartTypeManager.hxx> +#include <ChartTypeTemplate.hxx> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart/ChartDataRowSource.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/PieChartSubType.hpp> #include <com/sun/star/chart/ChartSolidType.hpp> #include <com/sun/star/lang/IndexOutOfBoundsException.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> @@ -62,17 +66,19 @@ #include <map> #include <com/sun/star/lang/XServiceName.hpp> #include <com/sun/star/util/XRefreshable.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/string_view.hxx> +#include <utility> using namespace ::com::sun::star; using namespace ::chart::wrapper; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; using ::com::sun::star::chart::XAxis; -using ::osl::MutexGuard; namespace { @@ -96,6 +102,8 @@ enum PROP_DIAGRAM_SORT_BY_X_VALUES, PROP_DIAGRAM_STARTING_ANGLE, + PROP_DIAGRAM_OF_PIE_TYPE, + PROP_DIAGRAM_SPLIT_POS, PROP_DIAGRAM_RIGHT_ANGLED_AXES, PROP_DIAGRAM_PERSPECTIVE, @@ -132,9 +140,6 @@ enum PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, PROP_DIAGRAM_AUTOMATIC_SIZE, - PROP_DIAGRAM_DATATABLEHBORDER, - PROP_DIAGRAM_DATATABLEVBORDER, - PROP_DIAGRAM_DATATABLEOUTLINE, PROP_DIAGRAM_EXTERNALDATA }; @@ -225,6 +230,16 @@ void lcl_AddPropertiesToVector( cppu::UnoType<sal_Int32>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "SubPieType", + PROP_DIAGRAM_OF_PIE_TYPE, + cppu::UnoType<chart2::PieChartSubType>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "SplitPos", + PROP_DIAGRAM_SPLIT_POS, + cppu::UnoType<sal_Int32>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT ); //new for 3D charts rOutProperties.emplace_back( "RightAngledAxes", @@ -376,21 +391,7 @@ void lcl_AddPropertiesToVector( cppu::UnoType<bool>::get(), beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableHBorder", - PROP_DIAGRAM_DATATABLEHBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableVBorder", - PROP_DIAGRAM_DATATABLEVBORDER, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); - rOutProperties.emplace_back( "DataTableOutline", - PROP_DIAGRAM_DATATABLEOUTLINE, - cppu::UnoType<bool>::get(), - beans::PropertyAttribute::BOUND - | beans::PropertyAttribute::MAYBEDEFAULT ); + rOutProperties.emplace_back( "ExternalData", PROP_DIAGRAM_EXTERNALDATA, cppu::UnoType<OUString>::get(), @@ -398,45 +399,35 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEVOID ); } -struct StaticDiagramWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static uno::Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::SceneProperties::AddPropertiesToVector( aProperties ); - WrappedStatisticProperties::addProperties( aProperties ); - WrappedSymbolProperties::addProperties( aProperties ); - WrappedDataCaptionProperties::addProperties( aProperties ); - WrappedSplineProperties::addProperties( aProperties ); - WrappedStockProperties::addProperties( aProperties ); - WrappedAutomaticPositionProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticDiagramWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticDiagramWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticDiagramWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::SceneProperties::AddPropertiesToVector( aProperties ); + WrappedStatisticProperties::addProperties( aProperties ); + WrappedSymbolProperties::addProperties( aProperties ); + WrappedDataCaptionProperties::addProperties( aProperties ); + WrappedSplineProperties::addProperties( aProperties ); + WrappedStockProperties::addProperties( aProperties ); + WrappedAutomaticPositionProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram ) +bool lcl_isXYChart( const rtl::Reference< ::chart::Diagram >& xDiagram ) { bool bRet = false; - Reference< chart2::XChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( rDiagram, 0 ) ); + rtl::Reference< ::chart::ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); if( xChartType.is() ) { OUString aChartType( xChartType->getChartType() ); @@ -448,7 +439,7 @@ bool lcl_isXYChart( const Reference< chart2::XDiagram >& rDiagram ) sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( sal_Int32 nOldAPIIndex - , const Reference< chart2::XDiagram >& xDiagram ) + , const rtl::Reference< ::chart::Diagram >& xDiagram ) { sal_Int32 nNewAPIIndex = nOldAPIIndex; @@ -458,30 +449,39 @@ sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( nNewAPIIndex -= 1; } - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< ::chart::DataSeries > > aSeriesList = + xDiagram->getDataSeries(); if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) ) nNewAPIIndex = -1; return nNewAPIIndex; } -OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) +OUString lcl_getDiagramType( std::u16string_view rTemplateServiceName ) { - static const OUStringLiteral aPrefix(u"com.sun.star.chart2.template."); + static constexpr OUString aPrefix(u"com.sun.star.chart2.template."_ustr); - if( rTemplateServiceName.match( aPrefix )) + if( o3tl::starts_with(rTemplateServiceName, aPrefix) ) { - const OUString aName( rTemplateServiceName.copy( aPrefix.getLength())); + const std::u16string_view aName( rTemplateServiceName.substr( aPrefix.getLength())); // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" // "StackedThreeDArea" "PercentStackedThreeDArea" - if( aName.indexOf( "Area" ) != -1 ) - return "com.sun.star.chart.AreaDiagram"; + if( aName.find( u"Area" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.AreaDiagram"_ustr; + + // Handle bar-of-pie and pie-of-pie before simple pie + // "BarOfPie" + if( aName.find( u"BarOfPie" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.BarOfPieDiagram"_ustr; + + // "PieOfPie" + if( aName.find( u"PieOfPie" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.PieOfPieDiagram"_ustr; // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" - if( aName.indexOf( "Pie" ) != -1 ) - return "com.sun.star.chart.PieDiagram"; + if( aName.find( u"Pie" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.PieDiagram"_ustr; // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" // "ThreeDColumnFlat" "StackedThreeDColumnFlat" @@ -489,34 +489,34 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" // "StackedColumnWithLine" - if( aName.indexOf( "Column" ) != -1 || aName.indexOf( "Bar" ) != -1 ) - return "com.sun.star.chart.BarDiagram"; + if( aName.find( u"Column" ) != std::u16string_view::npos || aName.find( u"Bar" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.BarDiagram"_ustr; // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" - if( aName.indexOf( "Donut" ) != -1 ) - return "com.sun.star.chart.DonutDiagram"; + if( aName.find( u"Donut" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.DonutDiagram"_ustr; // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" - if( aName.indexOf( "Scatter" ) != -1 ) - return "com.sun.star.chart.XYDiagram"; + if( aName.find( u"Scatter" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.XYDiagram"_ustr; // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" - if( aName.indexOf( "FilledNet" ) != -1 ) - return "com.sun.star.chart.FilledNetDiagram"; + if( aName.find( u"FilledNet" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.FilledNetDiagram"_ustr; // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" // "PercentStackedNetLine" - if( aName.indexOf( "Net" ) != -1 ) - return "com.sun.star.chart.NetDiagram"; + if( aName.find( u"Net" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.NetDiagram"_ustr; // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" // "StockVolumeOpenLowHighClose" - if( aName.indexOf( "Stock" ) != -1 ) - return "com.sun.star.chart.StockDiagram"; + if( aName.find( u"Stock" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.StockDiagram"_ustr; - if( aName.indexOf( "Bubble" ) != -1 ) - return "com.sun.star.chart.BubbleDiagram"; + if( aName.find( u"Bubble" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.BubbleDiagram"_ustr; // Note: this must be checked after Bar, Net and Scatter @@ -524,8 +524,11 @@ OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) // "PercentStackedLine" "LineSymbol" "StackedLineSymbol" // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" // "PercentStackedThreeDLine" "ThreeDLineDeep" - if( aName.indexOf( "Line" ) != -1 || aName.indexOf( "Symbol" ) != -1 ) - return "com.sun.star.chart.LineDiagram"; + if( aName.find(u"Line") != std::u16string_view::npos || aName.find( u"Symbol" ) != std::u16string_view::npos ) + return u"com.sun.star.chart.LineDiagram"_ustr; + + if (aName.find(u"Histogram") != std::u16string_view::npos) + return u"com.sun.star.chart.HistogramDiagram"_ustr; OSL_FAIL( "unknown template" ); } @@ -541,6 +544,7 @@ const tMakeStringStringMap& lcl_getChartTypeNameMap() {"com.sun.star.chart2.LineChartType", "com.sun.star.chart.LineDiagram"}, {"com.sun.star.chart2.AreaChartType", "com.sun.star.chart.AreaDiagram"}, {"com.sun.star.chart2.ColumnChartType", "com.sun.star.chart.BarDiagram"}, + {"com.sun.star.chart2.HistogramChartType", "com.sun.star.chart.HistogramDiagram"}, {"com.sun.star.chart2.PieChartType", "com.sun.star.chart.PieDiagram"}, {"com.sun.star.chart2.DonutChartType", "com.sun.star.chart.DonutDiagram"}, {"com.sun.star.chart2.ScatterChartType", "com.sun.star.chart.XYDiagram"}, @@ -570,9 +574,8 @@ OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName ) namespace chart::wrapper { -DiagramWrapper::DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +DiagramWrapper::DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -584,15 +587,15 @@ OUString SAL_CALL DiagramWrapper::getDiagramType() { OUString aRet; - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xChartDoc.is() && xDiagram.is() ) { - Reference< beans::XPropertySet > xChartDocProp( xChartDoc, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xChartDocProp( static_cast<cppu::OWeakObject*>(xChartDoc.get()), uno::UNO_QUERY ); if( xChartDocProp.is() ) { uno::Reference< util::XRefreshable > xAddIn; - if( xChartDocProp->getPropertyValue( "AddIn" ) >>= xAddIn ) + if( xChartDocProp->getPropertyValue( u"AddIn"_ustr ) >>= xAddIn ) { uno::Reference< lang::XServiceName > xServiceName( xAddIn, uno::UNO_QUERY ); if( xServiceName.is()) @@ -600,27 +603,30 @@ OUString SAL_CALL DiagramWrapper::getDiagramType() } } - Reference< lang::XMultiServiceFactory > xChartTypeManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - aRet = lcl_getDiagramType( aTemplateAndService.second ); + aRet = lcl_getDiagramType( aTemplateAndService.sServiceName ); } - if( aRet.isEmpty()) + if( !aRet.isEmpty()) + return aRet; + + // none of the standard templates matched + // use first chart type + if (xDiagram) { - // none of the standard templates matched - // use first chart type - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); if( xChartType.is() ) { aRet = xChartType->getChartType(); if( !aRet.isEmpty() ) aRet = lcl_getOldChartTypeName( aRet ); } - if( aRet.isEmpty()) - aRet = "com.sun.star.chart.BarDiagram"; } + if( aRet.isEmpty()) + aRet = "com.sun.star.chart.BarDiagram"; return aRet; } @@ -629,12 +635,12 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow ) { if( nRow < 0 ) - throw lang::IndexOutOfBoundsException("DataSeries index invalid", + throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, static_cast< ::cppu::OWeakObject * >( this )); - sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); if( nNewAPIIndex < 0 ) - throw lang::IndexOutOfBoundsException("DataSeries index invalid", + throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, static_cast< ::cppu::OWeakObject * >( this )); Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( @@ -646,12 +652,12 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) { if( nCol < 0 || nRow < 0 ) - throw lang::IndexOutOfBoundsException("DataSeries index invalid", + throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, static_cast< ::cppu::OWeakObject * >( this )); - sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getDiagram() ); if( nNewAPIIndex < 0 ) - throw lang::IndexOutOfBoundsException("DataSeries index invalid", + throw lang::IndexOutOfBoundsException(u"DataSeries index invalid"_ustr, static_cast< ::cppu::OWeakObject * >( this )); //todo: check borders of point index @@ -671,7 +677,7 @@ awt::Point SAL_CALL DiagramWrapper::getPosition() void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); if( !xProp.is() ) return; @@ -686,11 +692,11 @@ void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) { OSL_FAIL("DiagramWrapper::setPosition called with a position out of range -> automatic values are taken instead" ); uno::Any aEmpty; - xProp->setPropertyValue( "RelativePosition", aEmpty ); + xProp->setPropertyValue( u"RelativePosition"_ustr, aEmpty ); return; } - xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); - xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); + xProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); + xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); } awt::Size SAL_CALL DiagramWrapper::getSize() @@ -701,7 +707,7 @@ awt::Size SAL_CALL DiagramWrapper::getSize() void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); Reference< beans::XPropertySet > xProp( getInnerPropertySet() ); if( !xProp.is() ) return; @@ -716,30 +722,30 @@ void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) { OSL_FAIL("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); uno::Any aEmpty; - xProp->setPropertyValue( "RelativeSize", aEmpty ); + xProp->setPropertyValue( u"RelativeSize"_ustr, aEmpty ); return; } - xProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) ); - xProp->setPropertyValue( "PosSizeExcludeAxes", uno::Any(false) ); + xProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any(aRelativeSize) ); + xProp->setPropertyValue( u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); } // ____ XShapeDescriptor (base of XShape) ____ OUString SAL_CALL DiagramWrapper::getShapeType() { - return "com.sun.star.chart.Diagram"; + return u"com.sun.star.chart.Diagram"_ustr; } // ____ XDiagramPositioning ____ void SAL_CALL DiagramWrapper::setAutomaticDiagramPositioning() { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) { - xDiaProps->setPropertyValue( "RelativeSize", Any() ); - xDiaProps->setPropertyValue( "RelativePosition", Any() ); + xDiaProps->setPropertyValue( u"RelativeSize"_ustr, Any() ); + xDiaProps->setPropertyValue( u"RelativePosition"_ustr, Any() ); } } sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) @@ -747,8 +753,8 @@ sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) { - Any aRelativeSize( xDiaProps->getPropertyValue( "RelativeSize" ) ); - Any aRelativePosition( xDiaProps->getPropertyValue( "RelativePosition" ) ); + Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); + Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) return false; } @@ -756,23 +762,23 @@ sal_Bool SAL_CALL DiagramWrapper::isAutomaticDiagramPositioning( ) } void SAL_CALL DiagramWrapper::setDiagramPositionExcludingAxes( const awt::Rectangle& rPositionRect ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); - DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); + DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) - xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(true) ); + xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(true) ); } sal_Bool SAL_CALL DiagramWrapper::isExcludingDiagramPositioning() { uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) { - Any aRelativeSize( xDiaProps->getPropertyValue( "RelativeSize" ) ); - Any aRelativePosition( xDiaProps->getPropertyValue( "RelativePosition" ) ); + Any aRelativeSize( xDiaProps->getPropertyValue( u"RelativeSize"_ustr ) ); + Any aRelativePosition( xDiaProps->getPropertyValue( u"RelativePosition"_ustr ) ); if( aRelativeSize.hasValue() && aRelativePosition.hasValue() ) { bool bPosSizeExcludeAxes = false; - xDiaProps->getPropertyValue( "PosSizeExcludeAxes" ) >>= bPosSizeExcludeAxes; + xDiaProps->getPropertyValue( u"PosSizeExcludeAxes"_ustr ) >>= bPosSizeExcludeAxes; return bPosSizeExcludeAxes; } } @@ -784,11 +790,11 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionExcludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxes( const awt::Rectangle& rPositionRect ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); - DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getChartModel(), rPositionRect ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); + DiagramHelper::setDiagramPositioning( m_spChart2ModelContact->getDocumentModel(), rPositionRect ); uno::Reference< beans::XPropertySet > xDiaProps( getDiagram(), uno::UNO_QUERY ); if( xDiaProps.is() ) - xDiaProps->setPropertyValue("PosSizeExcludeAxes", uno::Any(false) ); + xDiaProps->setPropertyValue(u"PosSizeExcludeAxes"_ustr, uno::Any(false) ); } awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( ) { @@ -796,7 +802,7 @@ awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAxes( } void SAL_CALL DiagramWrapper::setDiagramPositionIncludingAxesAndAxisTitles( const awt::Rectangle& rPositionRect ) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); awt::Rectangle aRect( m_spChart2ModelContact->SubstractAxisTitleSizes(rPositionRect) ); DiagramWrapper::setDiagramPositionIncludingAxes( aRect ); } @@ -808,7 +814,7 @@ css::awt::Rectangle SAL_CALL DiagramWrapper::calculateDiagramPositionIncludingAx // ____ XAxisSupplier ____ Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) { - Reference< XAxis > xAxis; + rtl::Reference< AxisWrapper > xAxis; if(!nDimensionIndex) { if( !m_xXAxis.is() ) @@ -832,7 +838,7 @@ Reference< XAxis > SAL_CALL DiagramWrapper::getAxis( sal_Int32 nDimensionIndex ) Reference< XAxis > SAL_CALL DiagramWrapper::getSecondaryAxis( sal_Int32 nDimensionIndex ) { - Reference< XAxis > xAxis; + rtl::Reference< AxisWrapper > xAxis; if(!nDimensionIndex) { if( !m_xSecondXAxis.is() ) @@ -880,7 +886,7 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() { if( ! m_xZAxis.is()) m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); - return Reference< beans::XPropertySet >( m_xZAxis, uno::UNO_QUERY ); + return m_xZAxis; } // ____ XTwoAxisXSupplier ____ @@ -888,7 +894,7 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() { if( ! m_xSecondXAxis.is()) m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); - return Reference< beans::XPropertySet >( m_xSecondXAxis, uno::UNO_QUERY ); + return m_xSecondXAxis; } // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ @@ -905,7 +911,7 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() { if( ! m_xXAxis.is()) m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); - return Reference< beans::XPropertySet >( m_xXAxis, uno::UNO_QUERY ); + return m_xXAxis; } Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() @@ -931,7 +937,7 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() { if( ! m_xSecondYAxis.is()) m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); - return Reference< beans::XPropertySet >( m_xSecondYAxis, uno::UNO_QUERY ); + return m_xSecondYAxis; } // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ @@ -948,7 +954,7 @@ Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() { if( ! m_xYAxis.is()) m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); - return Reference< beans::XPropertySet >( m_xYAxis, uno::UNO_QUERY ); + return m_xYAxis; } Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() @@ -1042,21 +1048,21 @@ Reference< // ____ X3DDefaultSetter ____ void SAL_CALL DiagramWrapper::set3DSettingsToDefault() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->set3DSettingsToDefault(); } void SAL_CALL DiagramWrapper::setDefaultRotation() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->setDefaultRotation(); } void SAL_CALL DiagramWrapper::setDefaultIllumination() { - Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > x3DDefaultSetter( m_spChart2ModelContact->getDiagram() ); if( x3DDefaultSetter.is() ) x3DDefaultSetter->setDefaultIllumination(); } @@ -1064,9 +1070,8 @@ void SAL_CALL DiagramWrapper::setDefaultIllumination() // ____ XComponent ____ void SAL_CALL DiagramWrapper::dispose() { - m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); - - MutexGuard aGuard( m_aMutex); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); DisposeHelper::DisposeAndClear( m_xXAxis ); DisposeHelper::DisposeAndClear( m_xYAxis ); @@ -1085,13 +1090,15 @@ void SAL_CALL DiagramWrapper::dispose() void SAL_CALL DiagramWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL DiagramWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } namespace { @@ -1100,7 +1107,7 @@ namespace { class WrappedDataRowSourceProperty : public WrappedProperty { public: - explicit WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1115,10 +1122,9 @@ private: //member } -WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("DataRowSource",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedDataRowSourceProperty::WrappedDataRowSourceProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"DataRowSource"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( nullptr ); } @@ -1130,7 +1136,7 @@ void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, con { sal_Int32 nNew = sal_Int32(css::chart::ChartDataRowSource_ROWS); if( !(rOuterValue >>= nNew) ) - throw lang::IllegalArgumentException( "Property DataRowSource requires css::chart::ChartDataRowSource value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property DataRowSource requires css::chart::ChartDataRowSource value"_ustr, nullptr, 0 ); eChartDataRowSource = css::chart::ChartDataRowSource(nNew); } @@ -1145,14 +1151,14 @@ void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, con uno::Sequence< sal_Int32 > aSequenceMapping; if( DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) { if( bUseColumns != bNewUseColumns ) { aSequenceMapping.realloc(0); DataSourceHelper::setRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aSequenceMapping, bNewUseColumns , bFirstCellAsLabel , bHasCategories); + m_spChart2ModelContact->getDocumentModel(), aSequenceMapping, bNewUseColumns , bFirstCellAsLabel , bHasCategories); } } } @@ -1166,7 +1172,7 @@ Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPro uno::Sequence< sal_Int32 > aSequenceMapping; if( DataSourceHelper::detectRangeSegmentation( - m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + m_spChart2ModelContact->getDocumentModel(), aRangeString, aSequenceMapping, bUseColumns , bFirstCellAsLabel, bHasCategories ) ) { css::chart::ChartDataRowSource eChartDataRowSource = css::chart::ChartDataRowSource_ROWS; @@ -1194,7 +1200,7 @@ namespace { class WrappedStackingProperty : public WrappedProperty { public: - WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1213,11 +1219,10 @@ std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; } -WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedStackingProperty::WrappedStackingProperty(StackMode eStackMode, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eStackMode( eStackMode ) - , m_aOuterValue() { switch( m_eStackMode ) { @@ -1240,8 +1245,8 @@ bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const { bool bHasDetectableInnerValue = false; bool bIsAmbiguous = false; - eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getChart2Diagram() - , bHasDetectableInnerValue, bIsAmbiguous ); + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + eStackMode = xDiagram ? xDiagram->getStackMode( bHasDetectableInnerValue, bIsAmbiguous ) : StackMode::NONE; return bHasDetectableInnerValue; } @@ -1249,7 +1254,7 @@ void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Re { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Stacking Properties require boolean values", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Stacking Properties require boolean values"_ustr, nullptr, 0 ); StackMode eInnerStackMode; bool bHasDetectableInnerValue = detectInnerValue( eInnerStackMode ); @@ -1265,11 +1270,11 @@ void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Re if( !bNewValue && eInnerStackMode != m_eStackMode ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode::NONE; - DiagramHelper::setStackMode( xDiagram, eNewStackMode ); + xDiagram->setStackMode( eNewStackMode ); } } @@ -1297,7 +1302,7 @@ namespace { class WrappedDim3DProperty : public WrappedProperty { public: - explicit WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1312,10 +1317,9 @@ private: //member } -WrappedDim3DProperty::WrappedDim3DProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("Dim3D",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedDim3DProperty::WrappedDim3DProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"Dim3D"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( nullptr ); } @@ -1324,25 +1328,25 @@ void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Refer { bool bNew3D = false; if( ! (rOuterValue >>= bNew3D) ) - throw lang::IllegalArgumentException( "Property Dim3D requires boolean value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property Dim3D requires boolean value"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; - bool bOld3D = DiagramHelper::getDimension( xDiagram ) == 3; + bool bOld3D = xDiagram->getDimension() == 3; if( bOld3D != bNew3D ) - DiagramHelper::setDimension( xDiagram, bNew3D ? 3 : 2 ); + xDiagram->setDimension( bNew3D ? 3 : 2 ); } Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { - bool b3D = DiagramHelper::getDimension( xDiagram ) == 3; + bool b3D = xDiagram->getDimension() == 3; m_aOuterValue <<= b3D; } return m_aOuterValue; @@ -1361,7 +1365,7 @@ namespace { class WrappedVerticalProperty : public WrappedProperty { public: - explicit WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1376,10 +1380,9 @@ private: //member } -WrappedVerticalProperty::WrappedVerticalProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("Vertical",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedVerticalProperty::WrappedVerticalProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"Vertical"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( nullptr ); } @@ -1388,29 +1391,29 @@ void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Re { bool bNewVertical = false; if( ! (rOuterValue >>= bNewVertical) ) - throw lang::IllegalArgumentException( "Property Vertical requires boolean value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property Vertical requires boolean value"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; bool bFound = false; bool bAmbiguous = false; - bool bOldVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + bool bOldVertical = xDiagram->getVertical( bFound, bAmbiguous ); if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) ) - DiagramHelper::setVertical( xDiagram, bNewVertical ); + xDiagram->setVertical( bNewVertical ); } Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bFound = false; bool bAmbiguous = false; - bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + bool bVertical = xDiagram->getVertical( bFound, bAmbiguous ); if( bFound ) m_aOuterValue <<= bVertical; } @@ -1430,7 +1433,7 @@ namespace { class WrappedNumberOfLinesProperty : public WrappedProperty { public: - explicit WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1448,9 +1451,9 @@ private: //member } -WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("NumberOfLines",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"NumberOfLines"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_aOuterValue( getPropertyDefault(nullptr) ) { } @@ -1459,22 +1462,22 @@ bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) con { sal_Int32 nNumberOfLines = 0; bool bHasDetectableInnerValue = false; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { - Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); - if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" ) + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); + if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) { try { - uno::Reference< beans::XPropertySet > xProp( aTemplateAndService.first, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(aTemplateAndService.xChartTypeTemplate.get()), uno::UNO_QUERY ); xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines; bHasDetectableInnerValue = true; } @@ -1494,30 +1497,32 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con { sal_Int32 nNewValue; if( ! (rOuterValue >>= nNewValue) ) - throw lang::IllegalArgumentException( "property NumberOfLines requires sal_Int32 value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"property NumberOfLines requires sal_Int32 value"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( !(xChartDoc.is() && xDiagram.is() && nDimension == 2) ) + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + if( !xChartDoc || !xDiagram ) + return; + sal_Int32 nDimension = xDiagram->getDimension(); + if( nDimension != 2 ) return; - Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate; - if( aTemplateAndService.second == "com.sun.star.chart2.template.ColumnWithLine" ) + rtl::Reference< ChartTypeTemplate > xTemplate; + if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.ColumnWithLine" ) { if( nNewValue != 0 ) { - xTemplate.set( aTemplateAndService.first ); + xTemplate = aTemplateAndService.xChartTypeTemplate; try { sal_Int32 nOldValue = 0; - uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; if( nOldValue == nNewValue ) return; @@ -1529,14 +1534,14 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con } else { - xTemplate.set( xFact->createInstance("com.sun.star.chart2.template.Column"), uno::UNO_QUERY ); + xTemplate = xChartTypeManager->createTemplate(u"com.sun.star.chart2.template.Column"_ustr); } } - else if( aTemplateAndService.second == "com.sun.star.chart2.template.Column" ) + else if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.Column" ) { if( nNewValue == 0 ) return; - xTemplate.set( xFact->createInstance( "com.sun.star.chart2.template.ColumnWithLine" ), uno::UNO_QUERY ); + xTemplate = xChartTypeManager->createTemplate( u"com.sun.star.chart2.template.ColumnWithLine"_ustr ); } if(!xTemplate.is()) @@ -1545,9 +1550,9 @@ void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, con try { // locked controllers - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); - uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); - xProp->setPropertyValue( "NumberOfLines", uno::Any(nNewValue) ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); + uno::Reference< beans::XPropertySet > xProp( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); + xProp->setPropertyValue( u"NumberOfLines"_ustr, uno::Any(nNewValue) ); xTemplate->changeDiagram( xDiagram ); } catch( const uno::Exception & ) @@ -1577,7 +1582,7 @@ namespace { class WrappedAttributedDataPointsProperty : public WrappedProperty { public: - explicit WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1592,10 +1597,9 @@ private: //member } -WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("AttributedDataPoints",OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"AttributedDataPoints"_ustr,OUString()) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( nullptr ); } @@ -1604,63 +1608,53 @@ void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterVal { uno::Sequence< uno::Sequence< sal_Int32 > > aNewValue; if( ! (rOuterValue >>= aNewValue) ) - throw lang::IllegalArgumentException( "Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - if( !(xDiagram.is() && xDiaProp.is())) + if( !xDiagram ) return; - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); sal_Int32 i = 0; for (auto const& series : aSeriesVector) { - Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); - if( xProp.is()) + uno::Any aVal; + if( i < aNewValue.getLength() ) + aVal <<= aNewValue[i]; + else { - uno::Any aVal; - if( i < aNewValue.getLength() ) - aVal <<= aNewValue[i]; - else - { - //set empty sequence - uno::Sequence< sal_Int32 > aSeq; - aVal <<= aSeq; - } - xProp->setPropertyValue( "AttributedDataPoints", aVal ); + //set empty sequence + uno::Sequence< sal_Int32 > aSeq; + aVal <<= aSeq; } + series->setFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS, aVal ); // "AttributedDataPoints" ++i; } } Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); - if( xDiagram.is() && xDiaProp.is()) + if( xDiagram ) { - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); - + auto aResultRange = asNonConstRange(aResult); sal_Int32 i = 0; for (auto const& series : aSeriesVector) { - Reference< beans::XPropertySet > xProp(series, uno::UNO_QUERY); - if( xProp.is()) - { - uno::Any aVal( - xProp->getPropertyValue("AttributedDataPoints")); - uno::Sequence< sal_Int32 > aSeq; - if( aVal >>= aSeq ) - aResult[ i ] = aSeq; - } + uno::Any aVal( + series->getFastPropertyValue(PROP_DATASERIES_ATTRIBUTED_DATA_POINTS)); // "AttributedDataPoints" + uno::Sequence< sal_Int32 > aSeq; + if( aVal >>= aSeq ) + aResultRange[ i ] = std::move(aSeq); ++i; } m_aOuterValue <<= aResult; @@ -1682,7 +1676,7 @@ namespace { class WrappedSolidTypeProperty : public WrappedProperty { public: - explicit WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -1697,10 +1691,9 @@ private: //member } -WrappedSolidTypeProperty::WrappedSolidTypeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty( "SolidType", OUString() ) - , m_spChart2ModelContact( spChart2ModelContact ) - , m_aOuterValue() +WrappedSolidTypeProperty::WrappedSolidTypeProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty( u"SolidType"_ustr, OUString() ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( nullptr ); } @@ -1709,29 +1702,29 @@ void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const R { sal_Int32 nNewSolidType = css::chart::ChartSolidType::RECTANGULAR_SOLID; if( ! (rOuterValue >>= nNewSolidType) ) - throw lang::IllegalArgumentException( "Property SolidType requires integer value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property SolidType requires integer value"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; bool bFound = false; bool bAmbiguous = false; - sal_Int32 nOldSolidType = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + sal_Int32 nOldSolidType = xDiagram->getGeometry3D( bFound, bAmbiguous ); if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) ) - DiagramHelper::setGeometry3D( xDiagram, nNewSolidType ); + xDiagram->setGeometry3D( nNewSolidType ); } Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bFound = false; bool bAmbiguous = false; - sal_Int32 nGeometry = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + sal_Int32 nGeometry = xDiagram->getGeometry3D( bFound, bAmbiguous ); if( bFound ) m_aOuterValue <<= nGeometry; } @@ -1760,7 +1753,7 @@ public: } WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty() - : WrappedProperty( "AutomaticSize", OUString() ) + : WrappedProperty( u"AutomaticSize"_ustr, OUString() ) { } @@ -1771,15 +1764,15 @@ void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, con bool bNewValue = true; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Property AutomaticSize requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property AutomaticSize requires value of type boolean"_ustr, nullptr, 0 ); try { if( bNewValue ) { - Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) ); + Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); if( aRelativeSize.hasValue() ) - xInnerPropertySet->setPropertyValue( "RelativeSize", Any() ); + xInnerPropertySet->setPropertyValue( u"RelativeSize"_ustr, Any() ); } } catch( const uno::Exception & ) @@ -1793,7 +1786,7 @@ Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPro Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); if( xInnerPropertySet.is() ) { - Any aRelativeSize( xInnerPropertySet->getPropertyValue( "RelativeSize" ) ); + Any aRelativeSize( xInnerPropertySet->getPropertyValue( u"RelativeSize"_ustr ) ); if( !aRelativeSize.hasValue() ) aRet <<= true; } @@ -1813,7 +1806,7 @@ namespace { class WrappedIncludeHiddenCellsProperty : public WrappedProperty { public: - explicit WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; virtual Any getPropertyValue(const Reference<beans::XPropertySet>& xInnerPropertySet) const override; @@ -1824,9 +1817,9 @@ private: //member } -WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedProperty("IncludeHiddenCells","IncludeHiddenCells") - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : WrappedProperty(u"IncludeHiddenCells"_ustr,u"IncludeHiddenCells"_ustr) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -1834,21 +1827,26 @@ void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Property IncludeHiddenCells requires boolean value", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property IncludeHiddenCells requires boolean value"_ustr, nullptr, 0 ); - ChartModelHelper::setIncludeHiddenCells( bNewValue, *m_spChart2ModelContact->getModel() ); + m_spChart2ModelContact->getDocumentModel()->setIncludeHiddenCells(bNewValue); } Any WrappedIncludeHiddenCellsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - bool bValue = ChartModelHelper::isIncludeHiddenCells( m_spChart2ModelContact->getChartModel() ); + bool bValue = m_spChart2ModelContact->getDocumentModel()->isIncludeHiddenCells(); return uno::Any(bValue); } // ____ XDiagramProvider ____ Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram() { - return m_spChart2ModelContact->getChart2Diagram(); + return m_spChart2ModelContact->getDiagram(); +} + +rtl::Reference< ::chart::Diagram > DiagramWrapper::getUnderlyingDiagram() +{ + return m_spChart2ModelContact->getDiagram(); } void SAL_CALL DiagramWrapper::setDiagram( @@ -1860,12 +1858,12 @@ void SAL_CALL DiagramWrapper::setDiagram( Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() { - return Reference< beans::XPropertySet >( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + return m_spChart2ModelContact->getDiagram(); } const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() { - return *StaticDiagramWrapperPropertyArray::get(); + return StaticDiagramWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedProperties() @@ -1893,7 +1891,7 @@ std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedPro aWrappedProperties.emplace_back( new WrappedVerticalProperty( m_spChart2ModelContact ) ); aWrappedProperties.emplace_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact ) ); aWrappedProperties.emplace_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact ) ); - aWrappedProperties.emplace_back( new WrappedProperty( "StackedBarsConnected", "ConnectBars" ) ); + aWrappedProperties.emplace_back( new WrappedProperty( u"StackedBarsConnected"_ustr, u"ConnectBars"_ustr ) ); aWrappedProperties.emplace_back( new WrappedSolidTypeProperty( m_spChart2ModelContact ) ); aWrappedProperties.emplace_back( new WrappedAutomaticSizeProperty() ); aWrappedProperties.emplace_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact ) ); @@ -1903,7 +1901,7 @@ std::vector< std::unique_ptr<WrappedProperty> > DiagramWrapper::createWrappedPro OUString SAL_CALL DiagramWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Diagram"; + return u"com.sun.star.comp.chart.Diagram"_ustr; } sal_Bool SAL_CALL DiagramWrapper::supportsService( const OUString& rServiceName ) @@ -1914,14 +1912,14 @@ sal_Bool SAL_CALL DiagramWrapper::supportsService( const OUString& rServiceName css::uno::Sequence< OUString > SAL_CALL DiagramWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.Diagram", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.chart.StackableDiagram", - "com.sun.star.chart.ChartAxisXSupplier", - "com.sun.star.chart.ChartAxisYSupplier", - "com.sun.star.chart.ChartAxisZSupplier", - "com.sun.star.chart.ChartTwoAxisXSupplier", - "com.sun.star.chart.ChartTwoAxisYSupplier" + u"com.sun.star.chart.Diagram"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.chart.StackableDiagram"_ustr, + u"com.sun.star.chart.ChartAxisXSupplier"_ustr, + u"com.sun.star.chart.ChartAxisYSupplier"_ustr, + u"com.sun.star.chart.ChartAxisZSupplier"_ustr, + u"com.sun.star.chart.ChartTwoAxisXSupplier"_ustr, + u"com.sun.star.chart.ChartTwoAxisYSupplier"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx index d8e35d3bfe17..99fdf7fa02d4 100644 --- a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/chart/XDiagramPositioning.hpp> #include <com/sun/star/chart2/XDiagramProvider.hpp> #include <com/sun/star/chart/XDiagram.hpp> @@ -33,16 +33,20 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> - #include <com/sun/star/chart/X3DDefaultSetter.hpp> +#include <rtl/ref.hxx> #include <memory> namespace com::sun::star::chart2 { class XDiagram; } namespace com::sun::star::lang { class XEventListener; } +namespace chart { class Diagram; } namespace chart::wrapper { - +class AxisWrapper; +class WallFloorWrapper; +class MinMaxLineWrapper; +class UpDownBarWrapper; class Chart2ModelContact; class DiagramWrapper : public cppu::ImplInheritanceHelper< @@ -63,7 +67,7 @@ class DiagramWrapper : public cppu::ImplInheritanceHelper< > { public: - explicit DiagramWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit DiagramWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~DiagramWrapper() override; /// XServiceInfo declarations @@ -178,6 +182,8 @@ public: virtual css::uno::Reference< css::chart2::XDiagram > SAL_CALL getDiagram() override; virtual void SAL_CALL setDiagram( const css::uno::Reference< css::chart2::XDiagram >& xDiagram ) override; + rtl::Reference< ::chart::Diagram > getUnderlyingDiagram(); + protected: // ____ WrappedPropertySet ____ virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override; @@ -186,30 +192,18 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; - - css::uno::Reference< - css::chart::XAxis > m_xXAxis; - css::uno::Reference< - css::chart::XAxis > m_xYAxis; - css::uno::Reference< - css::chart::XAxis > m_xZAxis; - css::uno::Reference< - css::chart::XAxis > m_xSecondXAxis; - css::uno::Reference< - css::chart::XAxis > m_xSecondYAxis; - - css::uno::Reference< - css::beans::XPropertySet > m_xWall; - css::uno::Reference< - css::beans::XPropertySet > m_xFloor; - - css::uno::Reference< - css::beans::XPropertySet > m_xMinMaxLineWrapper; - css::uno::Reference< - css::beans::XPropertySet > m_xUpBarWrapper; - css::uno::Reference< - css::beans::XPropertySet > m_xDownBarWrapper; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; + + rtl::Reference< AxisWrapper > m_xXAxis; + rtl::Reference< AxisWrapper > m_xYAxis; + rtl::Reference< AxisWrapper > m_xZAxis; + rtl::Reference< AxisWrapper > m_xSecondXAxis; + rtl::Reference< AxisWrapper > m_xSecondYAxis; + rtl::Reference< WallFloorWrapper > m_xWall; + rtl::Reference< WallFloorWrapper > m_xFloor; + rtl::Reference< MinMaxLineWrapper > m_xMinMaxLineWrapper; + rtl::Reference< UpDownBarWrapper > m_xUpBarWrapper; + rtl::Reference< UpDownBarWrapper > m_xDownBarWrapper; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx index 649086a1a458..4931b661cc53 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -21,6 +21,7 @@ #include <AxisHelper.hxx> #include "Chart2ModelContact.hxx" #include <AxisIndexDefines.hxx> +#include <BaseCoordinateSystem.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> @@ -29,51 +30,20 @@ #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> #include <algorithm> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticGridWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticGridWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticGridWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { -GridWrapper::GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +GridWrapper::GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_eType(eType) { } @@ -106,8 +76,9 @@ void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDime // ____ XComponent ____ void SAL_CALL GridWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); clearWrappedPropertySet(); } @@ -115,31 +86,33 @@ void SAL_CALL GridWrapper::dispose() void SAL_CALL GridWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL GridWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() { - Reference< beans::XPropertySet > xRet; + rtl::Reference< GridProperties > xRet; try { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 /*nCooSysIndex*/ ) ); sal_Int32 nDimensionIndex = 1; bool bSubGrid = false; getDimensionAndSubGridBool( m_eType, nDimensionIndex, bSubGrid ); sal_Int32 nSubGridIndex = bSubGrid ? 0 : -1; - xRet.set( AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ) ); + xRet = AxisHelper::getGridProperties( xCooSys , nDimensionIndex, MAIN_AXIS_INDEX, nSubGridIndex ); } catch( const uno::Exception & ) { @@ -150,21 +123,32 @@ Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() const Sequence< beans::Property >& GridWrapper::getPropertySequence() { - return *StaticGridWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > GridWrapper::createWrappedProperties() { std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; - aWrappedProperties.emplace_back( new WrappedDefaultProperty( "LineColor", "LineColor", uno::Any( sal_Int32( 0x000000) ) ) ); // black + aWrappedProperties.emplace_back( new WrappedDefaultProperty( u"LineColor"_ustr, u"LineColor"_ustr, uno::Any( sal_Int32( 0x000000) ) ) ); // black return aWrappedProperties; } OUString SAL_CALL GridWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Grid"; + return u"com.sun.star.comp.chart.Grid"_ustr; } sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName ) @@ -175,10 +159,10 @@ sal_Bool SAL_CALL GridWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL GridWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartGrid", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.drawing.LineProperties", - "com.sun.star.beans.PropertySet" + u"com.sun.star.chart.ChartGrid"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr, + u"com.sun.star.beans.PropertySet"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx index f9e918301a53..c978f3bb8d83 100644 --- a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -48,7 +48,7 @@ public: Z_MINOR_GRID }; - GridWrapper(tGridType eType, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + GridWrapper(tGridType eType, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~GridWrapper() override; static void getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid ); @@ -71,7 +71,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; tGridType m_eType; }; diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx index 01dc74e7b7be..5d17f3a609c0 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -26,7 +26,6 @@ #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -39,10 +38,10 @@ #include "WrappedScaleTextProperties.hxx" #include <algorithm> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -67,7 +66,7 @@ protected: } WrappedLegendAlignmentProperty::WrappedLegendAlignmentProperty() - : ::chart::WrappedProperty( "Alignment", "AnchorPosition" ) + : ::chart::WrappedProperty( u"Alignment"_ustr, u"AnchorPosition"_ustr ) { } @@ -77,7 +76,7 @@ Any WrappedLegendAlignmentProperty::getPropertyValue( const Reference< beans::XP if( xInnerPropertySet.is() ) { bool bShowLegend = true; - xInnerPropertySet->getPropertyValue( "Show" ) >>= bShowLegend; + xInnerPropertySet->getPropertyValue( u"Show"_ustr ) >>= bShowLegend; if(!bShowLegend) { aRet <<= css::chart::ChartLegendPosition_NONE; @@ -102,11 +101,11 @@ void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, c css::chart::ChartLegendPosition eOuterPos(css::chart::ChartLegendPosition_NONE); if( (rOuterValue >>= eOuterPos) && eOuterPos == css::chart::ChartLegendPosition_NONE ) bNewShowLegend = false; - xInnerPropertySet->getPropertyValue( "Show" ) >>= bOldShowLegend; + xInnerPropertySet->getPropertyValue( u"Show"_ustr ) >>= bOldShowLegend; } if(bNewShowLegend!=bOldShowLegend) { - xInnerPropertySet->setPropertyValue( "Show", uno::Any(bNewShowLegend) ); + xInnerPropertySet->setPropertyValue( u"Show"_ustr, uno::Any(bNewShowLegend) ); } if(!bNewShowLegend) return; @@ -127,17 +126,17 @@ void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, c css::chart::ChartLegendExpansion eOldExpansion( css::chart::ChartLegendExpansion_HIGH ); bool bExpansionWasSet( - xInnerPropertySet->getPropertyValue( "Expansion" ) >>= eOldExpansion ); + xInnerPropertySet->getPropertyValue( u"Expansion"_ustr ) >>= eOldExpansion ); if( !bExpansionWasSet || (eOldExpansion != eNewExpansion)) - xInnerPropertySet->setPropertyValue( "Expansion", uno::Any( eNewExpansion )); + xInnerPropertySet->setPropertyValue( u"Expansion"_ustr, uno::Any( eNewExpansion )); } //correct RelativePosition - Any aRelativePosition( xInnerPropertySet->getPropertyValue("RelativePosition") ); + Any aRelativePosition( xInnerPropertySet->getPropertyValue(u"RelativePosition"_ustr) ); if(aRelativePosition.hasValue()) { - xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); + xInnerPropertySet->setPropertyValue( u"RelativePosition"_ustr, Any() ); } } @@ -225,35 +224,25 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticLegendWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticLegendWrapperPropertyArray_Initializer > +const Sequence< Property >& StaticLegendWrapperPropertyArray() { + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; } // anonymous namespace @@ -261,9 +250,8 @@ struct StaticLegendWrapperPropertyArray : public rtl::StaticAggregate< Sequence< namespace chart::wrapper { -LegendWrapper::LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact(spChart2ModelContact) - , m_aEventListenerContainer(m_aMutex) +LegendWrapper::LegendWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -288,7 +276,7 @@ void SAL_CALL LegendWrapper::setPosition( const awt::Point& aPosition ) aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; aRelativePosition.Primary = aPageSize.Width == 0 ? 0 : double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = aPageSize.Height == 0 ? 0 : double(aPosition.Y)/double(aPageSize.Height); - xProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + xProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); } } @@ -316,29 +304,31 @@ void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize ) // ____ XShapeDescriptor (base of XShape) ____ OUString SAL_CALL LegendWrapper::getShapeType() { - return "com.sun.star.chart.ChartLegend"; + return u"com.sun.star.chart.ChartLegend"_ustr; } // ____ XComponent ____ void SAL_CALL LegendWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL LegendWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL LegendWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //ReferenceSizePropertyProvider @@ -347,8 +337,8 @@ void LegendWrapper::updateReferenceSize() Reference< beans::XPropertySet > xProp = getInnerPropertySet(); if( xProp.is() ) { - if( xProp->getPropertyValue( "ReferencePageSize" ).hasValue() ) - xProp->setPropertyValue( "ReferencePageSize", uno::Any( + if( xProp->getPropertyValue( u"ReferencePageSize"_ustr ).hasValue() ) + xProp->setPropertyValue( u"ReferencePageSize"_ustr, uno::Any( m_spChart2ModelContact->GetPageSize() )); } } @@ -357,7 +347,7 @@ Any LegendWrapper::getReferenceSize() Any aRet; Reference< beans::XPropertySet > xProp = getInnerPropertySet(); if( xProp.is() ) - aRet = xProp->getPropertyValue( "ReferencePageSize" ); + aRet = xProp->getPropertyValue( u"ReferencePageSize"_ustr ); return aRet; } @@ -370,7 +360,7 @@ awt::Size LegendWrapper::getCurrentSizeForReference() Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() { Reference< beans::XPropertySet > xRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) xRet.set( xDiagram->getLegend(), uno::UNO_QUERY ); OSL_ENSURE(xRet.is(),"LegendWrapper::getInnerPropertySet() is NULL"); @@ -379,7 +369,7 @@ Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() const Sequence< beans::Property >& LegendWrapper::getPropertySequence() { - return *StaticLegendWrapperPropertyArray::get(); + return StaticLegendWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProperties() @@ -387,11 +377,11 @@ std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProp std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; aWrappedProperties.emplace_back( new WrappedLegendAlignmentProperty() ); - aWrappedProperties.emplace_back( new WrappedProperty( "Expansion", "Expansion")); + aWrappedProperties.emplace_back( new WrappedProperty( u"Expansion"_ustr, u"Expansion"_ustr)); WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); //same problem as for wall: the defaults in the old chart are different for different charttypes, so we need to export explicitly - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("FillStyle", "FillStyle")); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty("FillColor", "FillColor")); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"FillStyle"_ustr, u"FillStyle"_ustr)); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty(u"FillColor"_ustr, u"FillColor"_ustr)); WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); @@ -400,7 +390,7 @@ std::vector< std::unique_ptr<WrappedProperty> > LegendWrapper::createWrappedProp OUString SAL_CALL LegendWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Legend"; + return u"com.sun.star.comp.chart.Legend"_ustr; } sal_Bool SAL_CALL LegendWrapper::supportsService( const OUString& rServiceName ) @@ -411,10 +401,10 @@ sal_Bool SAL_CALL LegendWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL LegendWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartLegend", - "com.sun.star.drawing.Shape", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.style.CharacterProperties" + u"com.sun.star.chart.ChartLegend"_ustr, + u"com.sun.star.drawing.Shape"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.style.CharacterProperties"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx index 5da2b1b1fb4a..5b4deac2a1f9 100644 --- a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx @@ -21,7 +21,7 @@ #include <WrappedPropertySet.hxx> #include "ReferenceSizePropertyProvider.hxx" #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -42,7 +42,7 @@ class LegendWrapper : public ::cppu::ImplInheritanceHelper< , public ReferenceSizePropertyProvider { public: - explicit LegendWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit LegendWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~LegendWrapper() override; /// XServiceInfo declarations @@ -79,7 +79,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx index a0f39774b5f1..fa34ef63a825 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -19,21 +19,19 @@ #include "MinMaxLineWrapper.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <servicenames_charttypes.hxx> #include <cppuhelper/propshlp.hxx> #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XChartType.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/drawing/LineJoint.hpp> #include <comphelper/sequence.hxx> - +#include <DataSeries.hxx> #include <LinePropertiesHelper.hxx> #include <UserDefinedProperties.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; @@ -43,72 +41,34 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticMinMaxLineWrapperDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - ::chart::LinePropertiesHelper::AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -}; - -struct StaticMinMaxLineWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticMinMaxLineWrapperDefaults_Initializer > -{ -}; - -struct StaticMinMaxLineWrapperPropertyArray_Initializer +Sequence< Property >& StaticMinMaxLineWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; -struct StaticMinMaxLineWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticMinMaxLineWrapperPropertyArray_Initializer > -{ -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticMinMaxLineWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticMinMaxLineWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticMinMaxLineWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticMinMaxLineWrapperInfoHelper_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticMinMaxLineWrapperInfo_Initializer +::cppu::OPropertyArrayHelper& StaticMinMaxLineWrapperInfoHelper() { - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticMinMaxLineWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } + static ::cppu::OPropertyArrayHelper aPropHelper( StaticMinMaxLineWrapperPropertyArray() ); + return aPropHelper; }; -struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticMinMaxLineWrapperInfo_Initializer > +uno::Reference< beans::XPropertySetInfo >& StaticMinMaxLineWrapperInfo() { + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo( StaticMinMaxLineWrapperInfoHelper() ) ); + return xPropertySetInfo; }; } // anonymous namespace @@ -116,10 +76,9 @@ struct StaticMinMaxLineWrapperInfo : public rtl::StaticAggregate< uno::Reference namespace chart::wrapper { -MinMaxLineWrapper::MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) - , m_aWrappedLineJointProperty( "LineJoint", uno::Any( drawing::LineJoint_NONE )) +MinMaxLineWrapper::MinMaxLineWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move( spChart2ModelContact )) + , m_aWrappedLineJointProperty( u"LineJoint"_ustr, uno::Any( drawing::LineJoint_NONE )) { } @@ -130,58 +89,53 @@ MinMaxLineWrapper::~MinMaxLineWrapper() // ____ XComponent ____ void SAL_CALL MinMaxLineWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); } void SAL_CALL MinMaxLineWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL MinMaxLineWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo() { - return *StaticMinMaxLineWrapperInfo::get(); + return StaticMinMaxLineWrapperInfo(); } void SAL_CALL MinMaxLineWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) { - Reference< beans::XPropertySet > xPropSet; - - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + const std::vector< rtl::Reference< ChartType > > aTypes = xDiagram->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + const std::vector< rtl::Reference< DataSeries > > & aSeriesSeq( xType->getDataSeries2() ); + if(!aSeriesSeq.empty()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) + if(aSeriesSeq[0].is()) { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - if(xPropSet.is()) - { - if( rPropertyName == "LineColor" ) - xPropSet->setPropertyValue( "Color", rValue ); - else if( rPropertyName == "LineTransparence" ) - xPropSet->setPropertyValue( "Transparency", rValue ); - else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) - m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet ); - else - xPropSet->setPropertyValue( rPropertyName, rValue ); - return; - } + if( rPropertyName == "LineColor" ) + aSeriesSeq[0]->setPropertyValue( u"Color"_ustr, rValue ); + else if( rPropertyName == "LineTransparence" ) + aSeriesSeq[0]->setPropertyValue( u"Transparency"_ustr, rValue ); + else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) + m_aWrappedLineJointProperty.setPropertyValue( rValue, aSeriesSeq[0] ); + else + aSeriesSeq[0]->setPropertyValue( rPropertyName, rValue ); + return; } } } @@ -191,33 +145,28 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const OUString& rProperty { Any aRet; - Reference< beans::XPropertySet > xPropSet; + rtl::Reference< DataSeries > xPropSet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + const std::vector< rtl::Reference< ChartType > > aTypes = xDiagram->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); - if( xSeriesContainer.is() ) + const std::vector< rtl::Reference< DataSeries > > & aSeriesSeq( xType->getDataSeries2() ); + if(!aSeriesSeq.empty()) { - Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); - if(aSeriesSeq.hasElements()) - { - xPropSet.set(aSeriesSeq[0],uno::UNO_QUERY); - break; - } + xPropSet = aSeriesSeq[0]; + break; } } } if(xPropSet.is()) { if( rPropertyName == "LineColor" ) - aRet = xPropSet->getPropertyValue( "Color" ); + aRet = xPropSet->getPropertyValue( u"Color"_ustr ); else if( rPropertyName == "LineTransparence" ) - aRet = xPropSet->getPropertyValue( "Transparency" ); + aRet = xPropSet->getPropertyValue( u"Transparency"_ustr ); else if( rPropertyName == m_aWrappedLineJointProperty.getOuterName() ) aRet = m_aWrappedLineJointProperty.getPropertyValue( xPropSet ); else @@ -251,7 +200,7 @@ void SAL_CALL MinMaxLineWrapper::setPropertyValues( const uno::Sequence< OUStrin sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() ); for(sal_Int32 nN=0; nN<nMinCount; nN++) { - OUString aPropertyName( rNameSeq[nN] ); + const OUString& aPropertyName( rNameSeq[nN] ); try { setPropertyValue( aPropertyName, rValueSeq[nN] ); @@ -269,10 +218,11 @@ uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyValues( const u if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyValue( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyValue( aPropertyName ); } } return aRetSeq; @@ -315,10 +265,11 @@ uno::Sequence< beans::PropertyState > SAL_CALL MinMaxLineWrapper::getPropertySta if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyState( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyState( aPropertyName ); } } return aRetSeq; @@ -330,9 +281,14 @@ void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const OUString& rProperty uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticMinMaxLineWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = [] + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticMinMaxLineWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -341,7 +297,7 @@ uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const OUString& rProper //getPropertyStates() already declared in XPropertyState void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticMinMaxLineWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticMinMaxLineWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); @@ -360,10 +316,11 @@ uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyDefault( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyDefault( aPropertyName ); } } return aRetSeq; @@ -371,7 +328,7 @@ uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const OUString SAL_CALL MinMaxLineWrapper::getImplementationName() { - return "com.sun.star.comp.chart.ChartLine"; + return u"com.sun.star.comp.chart.ChartLine"_ustr; } sal_Bool SAL_CALL MinMaxLineWrapper::supportsService( const OUString& rServiceName ) @@ -382,9 +339,9 @@ sal_Bool SAL_CALL MinMaxLineWrapper::supportsService( const OUString& rServiceNa css::uno::Sequence< OUString > SAL_CALL MinMaxLineWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartLine", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.drawing.LineProperties" + u"com.sun.star.chart.ChartLine"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx index 1ef4367c8f7d..337ca8bdebd7 100644 --- a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx @@ -18,9 +18,8 @@ */ #pragma once -#include <MutexContainer.hxx> #include <WrappedIgnoreProperty.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/beans/XMultiPropertySet.hpp> @@ -37,8 +36,7 @@ namespace chart::wrapper class Chart2ModelContact; -class MinMaxLineWrapper : public MutexContainer - , public ::cppu::WeakImplHelper +class MinMaxLineWrapper : public ::cppu::WeakImplHelper < css::lang::XComponent , css::lang::XServiceInfo , css::beans::XPropertySet @@ -48,7 +46,7 @@ class MinMaxLineWrapper : public MutexContainer > { public: - explicit MinMaxLineWrapper(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit MinMaxLineWrapper(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~MinMaxLineWrapper() override; /// XServiceInfo declarations @@ -93,8 +91,9 @@ public: virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; private: //member + std::mutex m_aMutex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; WrappedIgnoreProperty m_aWrappedLineJointProperty; }; diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx index 7de1b376b3ef..e4ca74c37f19 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -26,8 +26,6 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/XTitle.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <CharacterProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -41,10 +39,10 @@ #include <algorithm> #include <rtl/ustrbuf.hxx> #include <cppuhelper/propshlp.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Any; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; @@ -69,19 +67,19 @@ protected: } WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ) - : ::chart::WrappedProperty( "String", OUString() ) + : ::chart::WrappedProperty( u"String"_ustr, OUString() ) , m_xContext( xContext ) { } void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); - if(xTitle.is()) + Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); + if(pTitle) { OUString aString; rOuterValue >>= aString; - TitleHelper::setCompleteString( aString, xTitle, m_xContext ); + TitleHelper::setCompleteString( aString, pTitle, m_xContext ); } } Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -108,6 +106,51 @@ Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPro namespace { + class WrappedTitleFormStringsProperty : public WrappedProperty + { + public: + explicit WrappedTitleFormStringsProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; + virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const override; + }; + +} + +WrappedTitleFormStringsProperty::WrappedTitleFormStringsProperty() + : ::chart::WrappedProperty( u"FormattedStrings"_ustr, OUString() ) +{ +} + +void WrappedTitleFormStringsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const +{ + Title* pTitle = dynamic_cast<Title*>(xInnerPropertySet.get()); + if (pTitle) + { + Sequence< Reference< chart2::XFormattedString >> xFormattedStrings; + rOuterValue >>= xFormattedStrings; + TitleHelper::setFormattedString(pTitle, xFormattedStrings); + } +} +Any WrappedTitleFormStringsProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const +{ + Any aRet(getPropertyDefault(Reference< beans::XPropertyState >(xInnerPropertySet, uno::UNO_QUERY))); + Reference< chart2::XTitle > xTitle(xInnerPropertySet, uno::UNO_QUERY); + if (xTitle.is()) + { + const Sequence< Reference< chart2::XFormattedString > > aStrings(xTitle->getText()); + aRet <<= aStrings; + } + return aRet; +} +Any WrappedTitleFormStringsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const +{ + return uno::Any(Sequence< Reference< chart2::XFormattedString > >()); //default title is an empty Sequence of XFormattedStrings +} + +namespace { + class WrappedStackedTextProperty : public WrappedProperty { public: @@ -117,7 +160,7 @@ public: } WrappedStackedTextProperty::WrappedStackedTextProperty() - : ::chart::WrappedProperty( "StackedText", "StackCharacters" ) + : ::chart::WrappedProperty( u"StackedText"_ustr, u"StackCharacters"_ustr ) { } @@ -129,6 +172,8 @@ namespace enum { PROP_TITLE_STRING, + PROP_TITLE_FORMATTED_STRINGS, + PROP_TITLE_VISIBLE, PROP_TITLE_TEXT_ROTATION, PROP_TITLE_TEXT_STACKED }; @@ -142,6 +187,18 @@ void lcl_AddPropertiesToVector( beans::PropertyAttribute::BOUND | beans::PropertyAttribute::MAYBEVOID ); + rOutProperties.emplace_back( "FormattedStrings", + PROP_TITLE_FORMATTED_STRINGS, + cppu::UnoType< Sequence< Reference< chart2::XFormattedString >>>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID ); + + rOutProperties.emplace_back( "Visible", + PROP_TITLE_VISIBLE, + cppu::UnoType<OUString>::get(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID ); + rOutProperties.emplace_back( "TextRotation", PROP_TITLE_TEXT_ROTATION, cppu::UnoType<sal_Int32>::get(), @@ -154,36 +211,27 @@ void lcl_AddPropertiesToVector( | beans::PropertyAttribute::MAYBEDEFAULT ); } -struct StaticTitleWrapperPropertyArray_Initializer +const Sequence< Property > & StaticTitleWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< beans::Property > aProperties; - lcl_AddPropertiesToVector( aProperties ); - ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); - ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } + static Sequence< Property > aPropSeq = []() + { + std::vector< beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticTitleWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticTitleWrapperPropertyArray_Initializer > -{ -}; } // anonymous namespace @@ -191,14 +239,13 @@ namespace chart::wrapper { TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_eTitleType(eTitleType) { - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChart2Document() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); if( !getTitleObject().is() ) //#i83831# create an empty title at the model, thus references to properties can be mapped correctly - TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + TitleHelper::createTitle( m_eTitleType, OUString(), m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext ); } TitleWrapper::~TitleWrapper() @@ -222,7 +269,7 @@ void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition ) aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); - xPropertySet->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + xPropertySet->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); } } @@ -239,44 +286,31 @@ void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ ) // ____ XShapeDescriptor (base of XShape) ____ OUString SAL_CALL TitleWrapper::getShapeType() { - return "com.sun.star.chart.ChartTitle"; + return u"com.sun.star.chart.ChartTitle"_ustr; } // ____ XComponent ____ void SAL_CALL TitleWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL TitleWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL TitleWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); -} - -Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet() -{ - Reference< beans::XPropertySet > xProp; - - Reference< chart2::XTitle > xTitle( getTitleObject() ); - if( xTitle.is()) - { - Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); - if( aStrings.hasElements() ) - xProp.set( aStrings[0], uno::UNO_QUERY ); - } - - return xProp; + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue ) @@ -284,7 +318,7 @@ void TitleWrapper::getFastCharacterPropertyValue( sal_Int32 nHandle, Any& rValue OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); - Reference< beans::XPropertySet > xProp = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xProp = getInnerPropertySet(); Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); if(xProp.is()) { @@ -324,6 +358,16 @@ void TitleWrapper::setFastCharacterPropertyValue( else if( xFastPropertySet.is() ) xFastPropertySet->setFastPropertyValue( nHandle, rValue ); } + + Reference< beans::XPropertySet > xInnerProp = getInnerPropertySet(); + Reference< beans::XFastPropertySet > xFastInnerProp( xInnerProp, uno::UNO_QUERY ); + if (xInnerProp.is()) + { + if (pWrappedProperty) + pWrappedProperty->setPropertyValue(rValue, xInnerProp); + else if (xFastInnerProp.is()) + xFastInnerProp->setFastPropertyValue(nHandle, rValue); + } } // WrappedPropertySet @@ -357,7 +401,7 @@ beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rP sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY); if( xPropState.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -390,7 +434,7 @@ Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName ) sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + Reference< beans::XPropertyState > xPropState( getInnerPropertySet(), uno::UNO_QUERY ); if( xPropState.is() ) { const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); @@ -411,7 +455,7 @@ void SAL_CALL TitleWrapper::addPropertyChangeListener( const OUString& rProperty sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); if( xPropSet.is() ) xPropSet->addPropertyChangeListener( rPropertyName, xListener ); } @@ -423,7 +467,7 @@ void SAL_CALL TitleWrapper::removePropertyChangeListener( const OUString& rPrope sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) { - Reference< beans::XPropertySet > xPropSet = getFirstCharacterPropertySet(); + Reference< beans::XPropertySet > xPropSet = getInnerPropertySet(); if( xPropSet.is() ) xPropSet->removePropertyChangeListener( rPropertyName, xListener ); } @@ -437,8 +481,8 @@ void TitleWrapper::updateReferenceSize() Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY ); if( xProp.is() ) { - if( xProp->getPropertyValue( "ReferencePageSize" ).hasValue() ) - xProp->setPropertyValue( "ReferencePageSize", uno::Any( + if( xProp->getPropertyValue( u"ReferencePageSize"_ustr ).hasValue() ) + xProp->setPropertyValue( u"ReferencePageSize"_ustr, uno::Any( m_spChart2ModelContact->GetPageSize() )); } } @@ -447,7 +491,7 @@ Any TitleWrapper::getReferenceSize() Any aRet; Reference< beans::XPropertySet > xProp( getTitleObject(), uno::UNO_QUERY ); if( xProp.is() ) - aRet = xProp->getPropertyValue( "ReferencePageSize" ); + aRet = xProp->getPropertyValue( u"ReferencePageSize"_ustr ); return aRet; } @@ -458,7 +502,7 @@ awt::Size TitleWrapper::getCurrentSizeForReference() Reference< chart2::XTitle > TitleWrapper::getTitleObject() { - return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ); + return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ); } // WrappedPropertySet @@ -470,7 +514,7 @@ Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() const Sequence< beans::Property >& TitleWrapper::getPropertySequence() { - return *StaticTitleWrapperPropertyArray::get(); + return StaticTitleWrapperPropertyArray(); } std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedProperties() @@ -478,6 +522,7 @@ std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedPrope std::vector< std::unique_ptr<WrappedProperty> > aWrappedProperties; aWrappedProperties.emplace_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) ); + aWrappedProperties.emplace_back( new WrappedTitleFormStringsProperty() ); aWrappedProperties.emplace_back( new WrappedTextRotationProperty( true ) ); aWrappedProperties.emplace_back( new WrappedStackedTextProperty() ); WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); @@ -489,7 +534,7 @@ std::vector< std::unique_ptr<WrappedProperty> > TitleWrapper::createWrappedPrope OUString SAL_CALL TitleWrapper::getImplementationName() { - return "com.sun.star.comp.chart.Title"; + return u"com.sun.star.comp.chart.Title"_ustr; } sal_Bool SAL_CALL TitleWrapper::supportsService( const OUString& rServiceName ) @@ -500,10 +545,10 @@ sal_Bool SAL_CALL TitleWrapper::supportsService( const OUString& rServiceName ) css::uno::Sequence< OUString > SAL_CALL TitleWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartTitle", - "com.sun.star.drawing.Shape", - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.style.CharacterProperties" + u"com.sun.star.chart.ChartTitle"_ustr, + u"com.sun.star.drawing.Shape"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.style.CharacterProperties"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx index 71a0878d9e3a..03c551fcf52d 100644 --- a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx @@ -22,7 +22,7 @@ #include "ReferenceSizePropertyProvider.hxx" #include <TitleHelper.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/drawing/XShape.hpp> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -45,7 +45,7 @@ class TitleWrapper final : public ::cppu::ImplInheritanceHelper< { public: TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual ~TitleWrapper() override; /// XServiceInfo declarations @@ -58,7 +58,6 @@ public: virtual css::uno::Any getReferenceSize() override; virtual css::awt::Size getCurrentSizeForReference() override; -private: // ____ XShape ____ virtual css::awt::Point SAL_CALL getPosition() override; virtual void SAL_CALL setPosition( const css::awt::Point& aPosition ) override; @@ -95,12 +94,11 @@ private: virtual const css::uno::Sequence< css::beans::Property >& getPropertySequence() override; virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override; - css::uno::Reference< css::beans::XPropertySet > getFirstCharacterPropertySet(); - +private: css::uno::Reference< css::chart2::XTitle > getTitleObject(); std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; ::chart::TitleHelper::eTitleType m_eTitleType; }; diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx index ab7e5b333a2c..92128857b891 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -19,20 +19,19 @@ #include "UpDownBarWrapper.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <servicenames_charttypes.hxx> #include <cppuhelper/supportsservice.hxx> #include <cppuhelper/propshlp.hxx> -#include <com/sun/star/chart2/XChartType.hpp> #include <comphelper/sequence.hxx> #include <LinePropertiesHelper.hxx> #include <FillProperties.hxx> #include <UserDefinedProperties.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; using ::com::sun::star::uno::Reference; @@ -42,79 +41,28 @@ using ::com::sun::star::uno::Any; namespace { -struct StaticUpDownBarWrapperPropertyArray_Initializer +const Sequence< Property > & StaticUpDownBarWrapperPropertyArray() { - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticUpDownBarWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticUpDownBarWrapperPropertyArray_Initializer > -{ -}; - -struct StaticUpDownBarWrapperInfoHelper_Initializer -{ - ::cppu::OPropertyArrayHelper* operator()() - { - static ::cppu::OPropertyArrayHelper aPropHelper( *StaticUpDownBarWrapperPropertyArray::get() ); - return &aPropHelper; - } -}; + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; -struct StaticUpDownBarWrapperInfoHelper : public rtl::StaticAggregate< ::cppu::OPropertyArrayHelper, StaticUpDownBarWrapperInfoHelper_Initializer > -{ -}; + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); -struct StaticUpDownBarWrapperInfo_Initializer -{ - uno::Reference< beans::XPropertySetInfo >* operator()() - { - static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( - ::cppu::OPropertySetHelper::createPropertySetInfo(*StaticUpDownBarWrapperInfoHelper::get() ) ); - return &xPropertySetInfo; - } -}; + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); -struct StaticUpDownBarWrapperInfo : public rtl::StaticAggregate< uno::Reference< beans::XPropertySetInfo >, StaticUpDownBarWrapperInfo_Initializer > -{ + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; }; -struct StaticUpDownBarWrapperDefaults_Initializer -{ - ::chart::tPropertyValueMap* operator()() - { - static ::chart::tPropertyValueMap aStaticDefaults; - lcl_AddDefaultsToMap( aStaticDefaults ); - return &aStaticDefaults; - } -private: - static void lcl_AddDefaultsToMap( ::chart::tPropertyValueMap & rOutMap ) - { - ::chart::LinePropertiesHelper::AddDefaultsToMap( rOutMap ); - ::chart::FillProperties::AddDefaultsToMap( rOutMap ); - } -}; - -struct StaticUpDownBarWrapperDefaults : public rtl::StaticAggregate< ::chart::tPropertyValueMap, StaticUpDownBarWrapperDefaults_Initializer > +::cppu::OPropertyArrayHelper& StaticUpDownBarWrapperInfoHelper() { + static ::cppu::OPropertyArrayHelper aPropHelper( StaticUpDownBarWrapperPropertyArray() ); + return aPropHelper; }; } // anonymous namespace @@ -123,10 +71,9 @@ namespace chart::wrapper { UpDownBarWrapper::UpDownBarWrapper( - bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : m_spChart2ModelContact( spChart2ModelContact ) - , m_aEventListenerContainer( m_aMutex ) - , m_aPropertySetName( bUp ? OUString( "WhiteDay" ) : OUString( "BlackDay" )) + bool bUp, std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : m_spChart2ModelContact(std::move( spChart2ModelContact )) + , m_aPropertySetName( bUp ? u"WhiteDay"_ustr : u"BlackDay"_ustr) { } @@ -137,42 +84,44 @@ UpDownBarWrapper::~UpDownBarWrapper() // ____ XComponent ____ void SAL_CALL UpDownBarWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); } void SAL_CALL UpDownBarWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL UpDownBarWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } //XPropertySet uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo() { - return *StaticUpDownBarWrapperInfo::get(); + static uno::Reference< beans::XPropertySetInfo > xPropertySetInfo( + ::cppu::OPropertySetHelper::createPropertySetInfo(StaticUpDownBarWrapperInfoHelper() ) ); + return xPropertySetInfo; } + void SAL_CALL UpDownBarWrapper::setPropertyValue( const OUString& rPropertyName, const uno::Any& rValue ) { Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > aTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( rtl::Reference< ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) @@ -184,17 +133,13 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const OUString& rPropertyN Reference< beans::XPropertySet > xPropSet; - const Sequence< Reference< chart2::XChartType > > aTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( Reference< chart2::XChartType > const & xType : aTypes ) + const std::vector< rtl::Reference< ChartType > > aTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( rtl::Reference<ChartType > const & xType : aTypes ) { if( xType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) { - Reference< beans::XPropertySet > xTypeProps( xType, uno::UNO_QUERY ); - if(xTypeProps.is()) - { - xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; - } + xType->getPropertyValue( m_aPropertySetName ) >>= xPropSet; } } if(xPropSet.is()) @@ -226,7 +171,7 @@ void SAL_CALL UpDownBarWrapper::setPropertyValues( const uno::Sequence< OUString sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() ); for(sal_Int32 nN=0; nN<nMinCount; nN++) { - OUString aPropertyName( rNameSeq[nN] ); + const OUString& aPropertyName( rNameSeq[nN] ); try { setPropertyValue( aPropertyName, rValueSeq[nN] ); @@ -244,10 +189,11 @@ uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyValues( const un if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyValue( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyValue( aPropertyName ); } } return aRetSeq; @@ -282,10 +228,11 @@ uno::Sequence< beans::PropertyState > SAL_CALL UpDownBarWrapper::getPropertyStat if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyState( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyState( aPropertyName ); } } return aRetSeq; @@ -297,9 +244,15 @@ void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const OUString& rPropertyN uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropertyName ) { - const tPropertyValueMap& rStaticDefaults = *StaticUpDownBarWrapperDefaults::get(); - tPropertyValueMap::const_iterator aFound( rStaticDefaults.find( StaticUpDownBarWrapperInfoHelper::get()->getHandleByName( rPropertyName ) ) ); - if( aFound == rStaticDefaults.end() ) + static const ::chart::tPropertyValueMap aStaticDefaults = []() + { + ::chart::tPropertyValueMap aTmp; + ::chart::LinePropertiesHelper::AddDefaultsToMap( aTmp ); + ::chart::FillProperties::AddDefaultsToMap( aTmp ); + return aTmp; + }(); + tPropertyValueMap::const_iterator aFound( aStaticDefaults.find( StaticUpDownBarWrapperInfoHelper().getHandleByName( rPropertyName ) ) ); + if( aFound == aStaticDefaults.end() ) return uno::Any(); return (*aFound).second; } @@ -308,7 +261,7 @@ uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const OUString& rPropert //getPropertyStates() already declared in XPropertyState void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) { - const Sequence< beans::Property >& rPropSeq = *StaticUpDownBarWrapperPropertyArray::get(); + const Sequence< beans::Property >& rPropSeq = StaticUpDownBarWrapperPropertyArray(); for(beans::Property const & prop : rPropSeq) { setPropertyToDefault( prop.Name ); @@ -327,10 +280,11 @@ uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const if( rNameSeq.hasElements() ) { aRetSeq.realloc( rNameSeq.getLength() ); + auto pRetSeq = aRetSeq.getArray(); for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) { - OUString aPropertyName( rNameSeq[nN] ); - aRetSeq[nN] = getPropertyDefault( aPropertyName ); + const OUString& aPropertyName( rNameSeq[nN] ); + pRetSeq[nN] = getPropertyDefault( aPropertyName ); } } return aRetSeq; @@ -338,7 +292,7 @@ uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const OUString SAL_CALL UpDownBarWrapper::getImplementationName() { - return "com.sun.star.comp.chart.ChartArea"; + return u"com.sun.star.comp.chart.ChartArea"_ustr; } sal_Bool SAL_CALL UpDownBarWrapper::supportsService( const OUString& rServiceName ) @@ -349,10 +303,10 @@ sal_Bool SAL_CALL UpDownBarWrapper::supportsService( const OUString& rServiceNam css::uno::Sequence< OUString > SAL_CALL UpDownBarWrapper::getSupportedServiceNames() { return { - "com.sun.star.chart.ChartArea", - "com.sun.star.drawing.LineProperties", - "com.sun.star.drawing.FillProperties", - "com.sun.star.xml.UserDefinedAttributesSupplier" + u"com.sun.star.chart.ChartArea"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr, + u"com.sun.star.drawing.FillProperties"_ustr, + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx index 1211ff735d9b..517a2406fe2c 100644 --- a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx @@ -18,8 +18,7 @@ */ #pragma once -#include <MutexContainer.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/beans/XMultiPropertySet.hpp> @@ -36,8 +35,7 @@ namespace chart::wrapper class Chart2ModelContact; -class UpDownBarWrapper : public MutexContainer - , public ::cppu::WeakImplHelper +class UpDownBarWrapper : public ::cppu::WeakImplHelper < css::lang::XComponent , css::lang::XServiceInfo , css::beans::XPropertySet @@ -47,7 +45,7 @@ class UpDownBarWrapper : public MutexContainer > { public: - UpDownBarWrapper(bool bUp, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + UpDownBarWrapper(bool bUp, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~UpDownBarWrapper() override; /// XServiceInfo declarations @@ -94,8 +92,9 @@ public: virtual css::uno::Sequence< css::uno::Any > SAL_CALL getPropertyDefaults( const css::uno::Sequence< OUString >& aPropertyNames ) override; private: //member + std::mutex m_aMutex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; OUString m_aPropertySetName; }; diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx index daa0f1de4f20..23ef0780ccae 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -21,7 +21,6 @@ #include "Chart2ModelContact.hxx" #include <comphelper/sequence.hxx> #include <cppuhelper/supportsservice.hxx> -#include <com/sun/star/chart2/XDiagram.hpp> #include <FillProperties.hxx> #include <LinePropertiesHelper.hxx> @@ -29,54 +28,20 @@ #include <WrappedDirectStateProperty.hxx> #include <algorithm> +#include <utility> using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using ::com::sun::star::beans::Property; -using ::osl::MutexGuard; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -namespace -{ - -struct StaticWallFloorWrapperPropertyArray_Initializer -{ - Sequence< Property >* operator()() - { - static Sequence< Property > aPropSeq( lcl_GetPropertySequence() ); - return &aPropSeq; - } - -private: - static Sequence< Property > lcl_GetPropertySequence() - { - std::vector< css::beans::Property > aProperties; - ::chart::FillProperties::AddPropertiesToVector( aProperties ); - ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); - ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); - - std::sort( aProperties.begin(), aProperties.end(), - ::chart::PropertyNameLess() ); - - return comphelper::containerToSequence( aProperties ); - } -}; - -struct StaticWallFloorWrapperPropertyArray : public rtl::StaticAggregate< Sequence< Property >, StaticWallFloorWrapperPropertyArray_Initializer > -{ -}; - -} // anonymous namespace - namespace chart::wrapper { WallFloorWrapper::WallFloorWrapper( bool bWall, - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) : - m_spChart2ModelContact( spChart2ModelContact ), - m_aEventListenerContainer( m_aMutex ), + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : + m_spChart2ModelContact(std::move( spChart2ModelContact )), m_bWall( bWall ) { @@ -89,23 +54,25 @@ WallFloorWrapper::~WallFloorWrapper() // ____ XComponent ____ void SAL_CALL WallFloorWrapper::dispose() { + std::unique_lock g(m_aMutex); Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); - m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + m_aEventListenerContainer.disposeAndClear( g, lang::EventObject( xSource ) ); - MutexGuard aGuard( m_aMutex); clearWrappedPropertySet(); } void SAL_CALL WallFloorWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) { - m_aEventListenerContainer.addInterface( xListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.addInterface( g, xListener ); } void SAL_CALL WallFloorWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) { - m_aEventListenerContainer.removeInterface( aListener ); + std::unique_lock g(m_aMutex); + m_aEventListenerContainer.removeInterface( g, aListener ); } // WrappedPropertySet @@ -113,7 +80,7 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() { Reference< beans::XPropertySet > xRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { if( m_bWall ) @@ -127,7 +94,19 @@ Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() { - return *StaticWallFloorWrapperPropertyArray::get(); + static Sequence< Property > aPropSeq = []() + { + std::vector< css::beans::Property > aProperties; + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LinePropertiesHelper::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + return comphelper::containerToSequence( aProperties ); + }(); + return aPropSeq; } std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedProperties() @@ -138,15 +117,15 @@ std::vector< std::unique_ptr<WrappedProperty> > WallFloorWrapper::createWrappedP // exported. Because in the old chart the defaults is as follows: // Floor: SOLID (new and old model default), Wall: NONE, except for some chart types (line, scatter) if( m_bWall ) - aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillStyle", "FillStyle" )); - aWrappedProperties.emplace_back( new WrappedDirectStateProperty( "FillColor", "FillColor" )); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty( u"FillStyle"_ustr, u"FillStyle"_ustr )); + aWrappedProperties.emplace_back( new WrappedDirectStateProperty( u"FillColor"_ustr, u"FillColor"_ustr )); return aWrappedProperties; } OUString SAL_CALL WallFloorWrapper::getImplementationName() { - return "com.sun.star.comp.chart.WallOrFloor"; + return u"com.sun.star.comp.chart.WallOrFloor"_ustr; } sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceName ) @@ -157,10 +136,10 @@ sal_Bool SAL_CALL WallFloorWrapper::supportsService( const OUString& rServiceNam css::uno::Sequence< OUString > SAL_CALL WallFloorWrapper::getSupportedServiceNames() { return { - "com.sun.star.xml.UserDefinedAttributesSupplier", - "com.sun.star.drawing.FillProperties", - "com.sun.star.drawing.LineProperties", - "com.sun.star.beans.PropertySet" + u"com.sun.star.xml.UserDefinedAttributesSupplier"_ustr, + u"com.sun.star.drawing.FillProperties"_ustr, + u"com.sun.star.drawing.LineProperties"_ustr, + u"com.sun.star.beans.PropertySet"_ustr }; } diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx index b538d55f1d9d..4a85bd8d5b37 100644 --- a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx @@ -20,7 +20,7 @@ #include <WrappedPropertySet.hxx> #include <cppuhelper/implbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/lang/XComponent.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> @@ -38,7 +38,7 @@ class WallFloorWrapper : public ::cppu::ImplInheritanceHelper< > { public: - WallFloorWrapper(bool bWall, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WallFloorWrapper(bool bWall, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WallFloorWrapper() override; /// XServiceInfo declarations @@ -59,7 +59,7 @@ protected: private: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; - ::comphelper::OInterfaceContainerHelper2 m_aEventListenerContainer; + ::comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListenerContainer; bool m_bWall; }; diff --git a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx index 24a6dfb78a1c..261826eb0497 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx @@ -29,7 +29,7 @@ namespace chart::wrapper { WrappedAddInProperty::WrappedAddInProperty( ChartDocumentWrapper& rChartDocumentWrapper ) - : ::chart::WrappedProperty( "AddIn", OUString() ) + : ::chart::WrappedProperty( u"AddIn"_ustr, OUString() ) , m_rChartDocumentWrapper( rChartDocumentWrapper ) { } @@ -41,7 +41,7 @@ void WrappedAddInProperty::setPropertyValue( const Any& rOuterValue, const Refer { Reference< util::XRefreshable > xAddIn; if( ! (rOuterValue >>= xAddIn) ) - throw lang::IllegalArgumentException( "AddIn properties require type XRefreshable", nullptr, 0 ); + throw lang::IllegalArgumentException( u"AddIn properties require type XRefreshable"_ustr, nullptr, 0 ); m_rChartDocumentWrapper.setAddIn( xAddIn ); } @@ -52,7 +52,7 @@ Any WrappedAddInProperty::getPropertyValue( const Reference< beans::XPropertySet } WrappedBaseDiagramProperty::WrappedBaseDiagramProperty( ChartDocumentWrapper& rChartDocumentWrapper ) - : ::chart::WrappedProperty( "BaseDiagram" , OUString() ) + : ::chart::WrappedProperty( u"BaseDiagram"_ustr , OUString() ) , m_rChartDocumentWrapper( rChartDocumentWrapper ) { } @@ -64,7 +64,7 @@ void WrappedBaseDiagramProperty::setPropertyValue( const Any& rOuterValue, const { OUString aBaseDiagram; if( ! (rOuterValue >>= aBaseDiagram) ) - throw lang::IllegalArgumentException( "BaseDiagram properties require type OUString", nullptr, 0 ); + throw lang::IllegalArgumentException( u"BaseDiagram properties require type OUString"_ustr, nullptr, 0 ); m_rChartDocumentWrapper.setBaseDiagram( aBaseDiagram ); } @@ -75,7 +75,7 @@ Any WrappedBaseDiagramProperty::getPropertyValue( const Reference< beans::XPrope } WrappedAdditionalShapesProperty::WrappedAdditionalShapesProperty( ChartDocumentWrapper& rChartDocumentWrapper ) - : ::chart::WrappedProperty( "AdditionalShapes" , OUString() ) + : ::chart::WrappedProperty( u"AdditionalShapes"_ustr , OUString() ) , m_rChartDocumentWrapper( rChartDocumentWrapper ) { } @@ -85,7 +85,7 @@ WrappedAdditionalShapesProperty::~WrappedAdditionalShapesProperty() void WrappedAdditionalShapesProperty::setPropertyValue( const Any& /*rOuterValue*/, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - throw lang::IllegalArgumentException( "AdditionalShapes is a read only property", nullptr, 0 ); + throw lang::IllegalArgumentException( u"AdditionalShapes is a read only property"_ustr, nullptr, 0 ); } Any WrappedAdditionalShapesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const @@ -94,7 +94,7 @@ Any WrappedAdditionalShapesProperty::getPropertyValue( const Reference< beans::X } WrappedRefreshAddInAllowedProperty::WrappedRefreshAddInAllowedProperty( ChartDocumentWrapper& rChartDocumentWrapper ) - : ::chart::WrappedProperty( "RefreshAddInAllowed" , OUString() ) + : ::chart::WrappedProperty( u"RefreshAddInAllowed"_ustr , OUString() ) , m_rChartDocumentWrapper( rChartDocumentWrapper ) { } @@ -106,7 +106,7 @@ void WrappedRefreshAddInAllowedProperty::setPropertyValue( const Any& rOuterValu { bool bUpdateAddIn = true; if( ! (rOuterValue >>= bUpdateAddIn) ) - throw lang::IllegalArgumentException( "The property RefreshAddInAllowed requires type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException( u"The property RefreshAddInAllowed requires type boolean"_ustr, nullptr, 0 ); m_rChartDocumentWrapper.setUpdateAddIn( bUpdateAddIn ); } diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx index 2bfb5ed42211..0434e6dc041e 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx @@ -23,7 +23,7 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -48,7 +48,7 @@ public: } WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty() - : ::chart::WrappedProperty( "AutomaticPosition" , OUString() ) + : ::chart::WrappedProperty( u"AutomaticPosition"_ustr , OUString() ) { } @@ -59,15 +59,15 @@ void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, bool bNewValue = true; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Property AutomaticPosition requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property AutomaticPosition requires value of type boolean"_ustr, nullptr, 0 ); try { if( bNewValue ) { - Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) ); + Any aRelativePosition( xInnerPropertySet->getPropertyValue( u"RelativePosition"_ustr ) ); if( aRelativePosition.hasValue() ) - xInnerPropertySet->setPropertyValue( "RelativePosition", Any() ); + xInnerPropertySet->setPropertyValue( u"RelativePosition"_ustr, Any() ); } } catch( const uno::Exception & ) @@ -81,7 +81,7 @@ Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans:: Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); if( xInnerPropertySet.is() ) { - Any aRelativePosition( xInnerPropertySet->getPropertyValue( "RelativePosition" ) ); + Any aRelativePosition( xInnerPropertySet->getPropertyValue( u"RelativePosition"_ustr ) ); if( !aRelativePosition.hasValue() ) aRet <<= true; } diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx index 5ee50f4dbd73..1208ad539d3e 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -23,12 +23,12 @@ #include "WrappedAxisAndGridExistenceProperties.hxx" #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <WrappedProperty.hxx> #include "Chart2ModelContact.hxx" #include <TitleHelper.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -44,7 +44,7 @@ class WrappedAxisAndGridExistenceProperty : public WrappedProperty { public: WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -80,9 +80,9 @@ void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< s } WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_bAxis( bAxis ) , m_bMain( bMain ) , m_nDimensionIndex( nDimensionIndex ) @@ -149,7 +149,7 @@ void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterVal { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Has axis or grid properties require boolean values"_ustr, nullptr, 0 ); bool bOldValue = false; getPropertyValue( xInnerPropertySet ) >>= bOldValue; @@ -157,7 +157,7 @@ void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterVal if( bOldValue == bNewValue ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( bNewValue ) { if( m_bAxis ) @@ -177,7 +177,7 @@ void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterVal Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const { Any aRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if(m_bAxis) { bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram ); @@ -204,7 +204,7 @@ class WrappedAxisTitleExistenceProperty : public WrappedProperty { public: WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -230,9 +230,9 @@ void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< std } WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty(sal_Int32 nTitleIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eTitleType( TitleHelper::Y_AXIS_TITLE ) { switch( nTitleIndex ) @@ -264,7 +264,7 @@ void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Has axis or grid properties require boolean values"_ustr, nullptr, 0 ); bool bOldValue = false; getPropertyValue( xInnerPropertySet ) >>= bOldValue; @@ -275,11 +275,11 @@ void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue if( bNewValue ) { TitleHelper::createTitle( m_eTitleType, OUString() - , m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + , m_spChart2ModelContact->getDocumentModel(), m_spChart2ModelContact->m_xContext ); } else { - TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ); + TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ); } } @@ -287,7 +287,7 @@ Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans: { bool bHasTitle = false; - Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getDocumentModel() ) ); if( xTitle.is() && !TitleHelper::getCompleteString( xTitle ).isEmpty() ) bHasTitle = true; @@ -310,7 +310,7 @@ class WrappedAxisLabelExistenceProperty : public WrappedProperty { public: WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -337,9 +337,9 @@ void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< std } WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty(bool bMain, sal_Int32 nDimensionIndex - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_bMain( bMain ) , m_nDimensionIndex( nDimensionIndex ) { @@ -362,7 +362,7 @@ void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "Has axis or grid properties require boolean values", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Has axis or grid properties require boolean values"_ustr, nullptr, 0 ); bool bOldValue = false; getPropertyValue( xInnerPropertySet ) >>= bOldValue; @@ -370,26 +370,26 @@ void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue if( bOldValue == bNewValue ) return; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< Axis > xProp = AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ); if( !xProp.is() && bNewValue ) { //create axis if needed - xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY ); + xProp = AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ); if( xProp.is() ) - xProp->setPropertyValue( "Show", uno::Any( false ) ); + xProp->setPropertyValue( u"Show"_ustr, uno::Any( false ) ); } if( xProp.is() ) - xProp->setPropertyValue( "DisplayLabels", rOuterValue ); + xProp->setPropertyValue( u"DisplayLabels"_ustr, rOuterValue ); } Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { Any aRet; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< Axis > xProp = AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ); if( xProp.is() ) - aRet = xProp->getPropertyValue( "DisplayLabels" ); + aRet = xProp->getPropertyValue( u"DisplayLabels"_ustr ); else aRet <<= false; return aRet; diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx index 67ea51b0e913..6e09285dfd62 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx @@ -110,7 +110,7 @@ Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rO } WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) - : WrappedCharacterHeightProperty_Base( "CharHeight", pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( u"CharHeight"_ustr, pRefSizePropProvider ) { } WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty() @@ -118,7 +118,7 @@ WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty() } WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) - : WrappedCharacterHeightProperty_Base( "CharHeightAsian", pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( u"CharHeightAsian"_ustr, pRefSizePropProvider ) { } WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty() @@ -126,7 +126,7 @@ WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty() } WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) - : WrappedCharacterHeightProperty_Base( "CharHeightComplex", pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( u"CharHeightComplex"_ustr, pRefSizePropProvider ) { } WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty() diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx index 7eee90a2c209..be9457d0ffd7 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx @@ -45,7 +45,7 @@ protected: virtual css::uno::Any convertInnerToOuterValue( const css::uno::Any& rInnerValue ) const override; virtual css::uno::Any convertOuterToInnerValue( const css::uno::Any& rOuterValue ) const override; -protected: +private: ReferenceSizePropertyProvider* m_pRefSizePropProvider; }; diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx index d317210c3608..792bfdfadcb4 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx @@ -127,7 +127,7 @@ void WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( std::vector< WrappedDataCaptionProperty::WrappedDataCaptionProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact , tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty< sal_Int32 >( "DataCaption" + : WrappedSeriesOrDiagramProperty< sal_Int32 >( u"DataCaption"_ustr , uno::Any( sal_Int32(0) ), spChart2ModelContact, ePropertyType ) { } diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx index b49c5177dc2e..1da4fe9195cb 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -17,10 +17,15 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include "WrappedGapwidthProperty.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <tools/long.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -35,15 +40,15 @@ const sal_Int32 DEFAULT_OVERLAP = 0; WrappedBarPositionProperty_Base::WrappedBarPositionProperty_Base( const OUString& rOuterName - , const OUString& rInnerSequencePropertyName + , OUString aInnerSequencePropertyName , sal_Int32 nDefaultValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedDefaultProperty( rOuterName, OUString(), uno::Any( nDefaultValue ) ) , m_nDimensionIndex(0) , m_nAxisIndex(0) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_nDefaultValue( nDefaultValue ) - , m_InnerSequencePropertyName( rInnerSequencePropertyName ) + , m_InnerSequencePropertyName(std::move( aInnerSequencePropertyName )) { } @@ -61,41 +66,36 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, { sal_Int32 nNewValue = 0; if( ! (rOuterValue >>= nNewValue) ) - throw lang::IllegalArgumentException( "GapWidth and Overlap property require value of type sal_Int32", nullptr, 0 ); + throw lang::IllegalArgumentException( u"GapWidth and Overlap property require value of type sal_Int32"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( !xDiagram.is() ) return; if( m_nDimensionIndex!=1 ) return; - const Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( Reference< chart2::XChartType > const & chartType : aChartTypeList ) + const std::vector< rtl::Reference< ChartType > > aChartTypeList( xDiagram->getChartTypes() ); + for( rtl::Reference< ChartType > const & chartType : aChartTypeList ) { try { - Reference< beans::XPropertySet > xProp( chartType, uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + chartType->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + + tools::Long nOldLength = aBarPositionSequence.getLength(); + if( nOldLength <= m_nAxisIndex ) + aBarPositionSequence.realloc( m_nAxisIndex+1 ); + auto pBarPositionSequence = aBarPositionSequence.getArray(); + for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - - tools::Long nOldLength = aBarPositionSequence.getLength(); - if( nOldLength <= m_nAxisIndex ) - { - aBarPositionSequence.realloc( m_nAxisIndex+1 ); - for( sal_Int32 i=nOldLength; i<m_nAxisIndex; i++ ) - { - aBarPositionSequence[i] = m_nDefaultValue; - } - } - aBarPositionSequence[m_nAxisIndex] = nNewValue; - - xProp->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); + pBarPositionSequence[i] = m_nDefaultValue; } + pBarPositionSequence[m_nAxisIndex] = nNewValue; + + chartType->setPropertyValue( m_InnerSequencePropertyName, uno::Any( aBarPositionSequence ) ); } catch( uno::Exception& e ) { @@ -108,7 +108,7 @@ void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() ) { bool bInnerValueDetected = false; @@ -116,21 +116,17 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::X if( m_nDimensionIndex==1 ) { - Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); - for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ ) + std::vector< rtl::Reference< ChartType > > aChartTypeList = xDiagram->getChartTypes(); + for( std::size_t nN = 0; nN < aChartTypeList.size() && !bInnerValueDetected; nN++ ) { try { - Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); - if( xProp.is() ) + Sequence< sal_Int32 > aBarPositionSequence; + aChartTypeList[nN]->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + if( m_nAxisIndex < aBarPositionSequence.getLength() ) { - Sequence< sal_Int32 > aBarPositionSequence; - xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; - if( m_nAxisIndex < aBarPositionSequence.getLength() ) - { - nInnerValue = aBarPositionSequence[m_nAxisIndex]; - bInnerValueDetected = true; - } + nInnerValue = aBarPositionSequence[m_nAxisIndex]; + bInnerValueDetected = true; } } catch( uno::Exception& e ) @@ -151,7 +147,7 @@ Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::X WrappedGapwidthProperty::WrappedGapwidthProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedBarPositionProperty_Base( "GapWidth", "GapwidthSequence", DEFAULT_GAPWIDTH, spChart2ModelContact ) + : WrappedBarPositionProperty_Base( u"GapWidth"_ustr, u"GapwidthSequence"_ustr, DEFAULT_GAPWIDTH, spChart2ModelContact ) { } WrappedGapwidthProperty::~WrappedGapwidthProperty() @@ -160,7 +156,7 @@ WrappedGapwidthProperty::~WrappedGapwidthProperty() WrappedBarOverlapProperty::WrappedBarOverlapProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) - : WrappedBarPositionProperty_Base( "Overlap", "OverlapSequence", DEFAULT_OVERLAP, spChart2ModelContact ) + : WrappedBarPositionProperty_Base( u"Overlap"_ustr, u"OverlapSequence"_ustr, DEFAULT_OVERLAP, spChart2ModelContact ) { } WrappedBarOverlapProperty::~WrappedBarOverlapProperty() diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx index 550b0ce6ad9d..6ac43e9f7635 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx @@ -32,9 +32,9 @@ class WrappedBarPositionProperty_Base : public WrappedDefaultProperty public: WrappedBarPositionProperty_Base( const OUString& rOuterName - , const OUString& rInnerSequencePropertyName + , OUString aInnerSequencePropertyName , sal_Int32 nDefaultValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); virtual ~WrappedBarPositionProperty_Base() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; @@ -43,7 +43,7 @@ public: void setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); -protected: +private: sal_Int32 m_nDimensionIndex; sal_Int32 m_nAxisIndex; std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx index 1ce277c321ba..bc1f5aed14f6 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx @@ -19,9 +19,11 @@ #include "WrappedNumberFormatProperty.hxx" #include "Chart2ModelContact.hxx" -#include <com/sun/star/chart2/XAxis.hpp> +#include <Axis.hxx> +#include <DataSeries.hxx> #include <com/sun/star/chart2/XDataSeries.hpp> #include <unonames.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -31,9 +33,9 @@ using ::com::sun::star::uno::Any; namespace chart::wrapper { -WrappedNumberFormatProperty::WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) +WrappedNumberFormatProperty::WrappedNumberFormatProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedDirectStateProperty( CHART_UNONAME_NUMFMT, CHART_UNONAME_NUMFMT ) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) { } @@ -45,7 +47,7 @@ void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, cons { sal_Int32 nFormat = 0; if( ! (rOuterValue >>= nFormat) ) - throw lang::IllegalArgumentException( "Property 'NumberFormat' requires value of type sal_Int32", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property 'NumberFormat' requires value of type sal_Int32"_ustr, nullptr, 0 ); if(xInnerPropertySet.is()) xInnerPropertySet->setPropertyValue(getInnerName(), convertOuterToInnerValue(rOuterValue)); @@ -63,11 +65,12 @@ Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XProp { sal_Int32 nKey = 0; Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY ); - if( xSeries.is() ) - nKey = Chart2ModelContact::getExplicitNumberFormatKeyForSeries( xSeries ); + if( ::chart::DataSeries* pDataSeries = dynamic_cast<DataSeries*>(xSeries.get()) ) + nKey = pDataSeries->getExplicitNumberFormatKeyForDataLabel(); else { - Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get()); + assert(xAxis || !xInnerPropertySet); nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis ); } aRet <<= nKey; diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx index fa4042ceaedf..cf2f706c61c7 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx @@ -31,7 +31,7 @@ namespace chart::wrapper class WrappedNumberFormatProperty : public WrappedDirectStateProperty { public: - explicit WrappedNumberFormatProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedNumberFormatProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedNumberFormatProperty() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx index d9ad4a3e6bb4..35b8cd3040ea 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -20,11 +20,13 @@ #include "WrappedScaleProperty.hxx" #include "Chart2ModelContact.hxx" #include <CommonConverters.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <com/sun/star/chart/ChartAxisType.hpp> #include <chartview/ExplicitScaleValues.hxx> +#include <utility> #include <osl/diagnose.h> using namespace ::com::sun::star; @@ -38,9 +40,9 @@ namespace chart::wrapper { WrappedScaleProperty::WrappedScaleProperty(tScaleProperty eScaleProperty - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact) : WrappedProperty(OUString(),OUString()) - , m_spChart2ModelContact( spChart2ModelContact ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) , m_eScaleProperty( eScaleProperty ) { switch( m_eScaleProperty ) @@ -173,6 +175,7 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); double fStepHelp = 0; if( rOuterValue >>= fStepHelp ) @@ -181,14 +184,14 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons if( AxisHelper::isLogarithmic(aScaleData.Scaling) ) { sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp); - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; } else if( (fStepHelp != 0.0) && (aScaleData.IncrementData.Distance >>= fStepMain) ) { // approximate interval count sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp);//cppcheck-suppress zerodiv - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; } } bSetScaleData = true; @@ -199,11 +202,12 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); sal_Int32 nIntervalCount=0; if( rOuterValue>>=nIntervalCount ) - rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + pSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; else - rSubIncrements[ 0 ].IntervalCount = Any(); + pSubIncrements[ 0 ].IntervalCount = Any(); bSetScaleData = true; break; } @@ -239,11 +243,12 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); if( !rSubIncrements.hasElements() ) rSubIncrements.realloc( 1 ); + auto pSubIncrements = rSubIncrements.getArray(); if( (rOuterValue >>= bBool) && bBool ) - rSubIncrements[ 0 ].IntervalCount = Any(); + pSubIncrements[ 0 ].IntervalCount = Any(); else - rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); + pSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); bSetScaleData = true; break; } @@ -292,7 +297,7 @@ void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, cons { TimeIncrement aTimeIncrement; rOuterValue >>= aTimeIncrement; - aScaleData.TimeIncrement = aTimeIncrement; + aScaleData.TimeIncrement = std::move(aTimeIncrement); bSetScaleData = true; break; } @@ -345,7 +350,7 @@ Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const { Any aRet( m_aOuterValue ); - Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + rtl::Reference< Axis > xAxis = dynamic_cast<Axis*>(xInnerPropertySet.get()); OSL_ENSURE(xAxis.is(),"need an XAxis"); if(!xAxis.is()) return aRet; diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx index 64e8071b5345..eca52953552d 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -51,7 +51,7 @@ public: , SCALE_PROP_REVERSEDIRECTION }; - WrappedScaleProperty(tScaleProperty eScaleProperty, const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + WrappedScaleProperty(tScaleProperty eScaleProperty, std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedScaleProperty() override; static void addWrappedProperties( std::vector< std::unique_ptr<WrappedProperty> >& rList, const std::shared_ptr< Chart2ModelContact >& spChart2ModelContact ); diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx index 8551915d9c88..60a026c2fcaf 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx @@ -25,7 +25,8 @@ #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -40,7 +41,7 @@ namespace { class WrappedScaleTextProperty : public WrappedProperty { public: - explicit WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + explicit WrappedScaleTextProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const override; @@ -52,15 +53,15 @@ private: } -WrappedScaleTextProperty::WrappedScaleTextProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : ::chart::WrappedProperty( "ScaleText" , OUString() ) - , m_spChart2ModelContact( spChart2ModelContact ) +WrappedScaleTextProperty::WrappedScaleTextProperty(std::shared_ptr<Chart2ModelContact> spChart2ModelContact) + : ::chart::WrappedProperty( u"ScaleText"_ustr , OUString() ) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - static constexpr OUStringLiteral aRefSizeName = u"ReferencePageSize"; + static constexpr OUString aRefSizeName = u"ReferencePageSize"_ustr; if( !xInnerPropertySet.is() ) return; @@ -69,7 +70,7 @@ void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const R if( ! (rOuterValue >>= bNewValue) ) { if( rOuterValue.hasValue() ) - throw lang::IllegalArgumentException( "Property ScaleText requires value of type boolean", nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property ScaleText requires value of type boolean"_ustr, nullptr, 0 ); } try @@ -93,7 +94,7 @@ Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropert Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); if( xInnerPropertySet.is() ) { - if( xInnerPropertySet->getPropertyValue( "ReferencePageSize" ).hasValue() ) + if( xInnerPropertySet->getPropertyValue( u"ReferencePageSize"_ustr ).hasValue() ) aRet <<= true; else aRet <<= false; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx index d3a883429172..cf7a820115c3 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx @@ -19,8 +19,8 @@ #include "WrappedSceneProperty.hxx" #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> #include <BaseGFXHelper.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -36,9 +36,9 @@ void WrappedSceneProperty::addWrappedProperties( std::vector< std::unique_ptr<Wr } WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty( - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) - : WrappedProperty("D3DTransformMatrix","D3DTransformMatrix") - , m_spChart2ModelContact( spChart2ModelContact ) + std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) + : WrappedProperty(u"D3DTransformMatrix"_ustr,u"D3DTransformMatrix"_ustr) + , m_spChart2ModelContact(std::move( spChart2ModelContact )) { } @@ -48,7 +48,7 @@ WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty() void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() ) { drawing::HomogenMatrix aHM; if( rOuterValue >>= aHM ) @@ -73,7 +73,7 @@ void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const { - if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + if( m_spChart2ModelContact->getDiagram()->isPieOrDonutChart() ) { uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) ); drawing::HomogenMatrix aHM; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx index 7e6679016537..31ef35abc566 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx @@ -39,7 +39,7 @@ class WrappedD3DTransformMatrixProperty : public WrappedProperty { public: explicit WrappedD3DTransformMatrixProperty( - const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact); + std::shared_ptr<Chart2ModelContact> spChart2ModelContact); virtual ~WrappedD3DTransformMatrixProperty() override; virtual void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx index 88fa72696c03..5b073ca80152 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <utility> + #include "WrappedSeriesAreaOrLineProperty.hxx" #include "DataSeriesPointWrapper.hxx" @@ -25,13 +27,13 @@ namespace chart::wrapper WrappedSeriesAreaOrLineProperty::WrappedSeriesAreaOrLineProperty( const OUString& rOuterName - , const OUString& rInnerAreaTypeName - , const OUString& rInnerLineTypeName + , OUString aInnerAreaTypeName + , OUString aInnerLineTypeName , DataSeriesPointWrapper* pDataSeriesPointWrapper ) : WrappedProperty( rOuterName, OUString() ) , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) - , m_aInnerAreaTypeName( rInnerAreaTypeName ) - , m_aInnerLineTypeName( rInnerLineTypeName ) + , m_aInnerAreaTypeName(std::move( aInnerAreaTypeName )) + , m_aInnerLineTypeName(std::move( aInnerLineTypeName )) { } WrappedSeriesAreaOrLineProperty::~WrappedSeriesAreaOrLineProperty() diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx index ba77b6939f34..f3561e7361d4 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx @@ -28,7 +28,7 @@ class WrappedSeriesAreaOrLineProperty : public WrappedProperty { public: WrappedSeriesAreaOrLineProperty( const OUString& rOuterName - , const OUString& rInnerAreaTypeName, const OUString& rInnerLineTypeName + , OUString aInnerAreaTypeName, OUString aInnerLineTypeName , DataSeriesPointWrapper* pDataSeriesPointWrapper ); virtual ~WrappedSeriesAreaOrLineProperty() override; diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx index 7eb90e8b932b..61946ea5d75f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx @@ -20,13 +20,12 @@ #include <WrappedProperty.hxx> #include "Chart2ModelContact.hxx" -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> #include <memory> +#include <utility> #include <vector> -namespace com::sun::star::chart2 { class XDataSeries; } - namespace chart::wrapper { @@ -46,10 +45,10 @@ public: virtual void setValueToSeries( const css::uno::Reference< css::beans::XPropertySet >& xSeriesPropertySet, const PROPERTYTYPE & aNewValue ) const =0; explicit WrappedSeriesOrDiagramProperty( const OUString& rName, const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact , tSeriesOrDiagramPropertyType ePropertyType ) : WrappedProperty(rName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_aOuterValue(rDefaulValue) , m_aDefaultValue(rDefaulValue) , m_ePropertyType( ePropertyType ) @@ -58,30 +57,31 @@ public: bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const { - bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; - if( m_ePropertyType == DIAGRAM && - m_spChart2ModelContact ) + if( m_ePropertyType != DIAGRAM || !m_spChart2ModelContact ) + return false; + bool bHasDetectableInnerValue = false; + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + if (!xDiagram) + return false; + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); + for (auto const& series : aSeriesVector) { - std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for (auto const& series : aSeriesVector) + PROPERTYTYPE aCurValue = getValueFromSeries( series ); + if( !bHasDetectableInnerValue ) + rValue = aCurValue; + else { - PROPERTYTYPE aCurValue = getValueFromSeries( css::uno::Reference< css::beans::XPropertySet >::query(series) ); - if( !bHasDetectableInnerValue ) - rValue = aCurValue; - else + if( rValue != aCurValue ) { - if( rValue != aCurValue ) - { - rHasAmbiguousValue = true; - break; - } - else - rValue = aCurValue; + rHasAmbiguousValue = true; + break; } - bHasDetectableInnerValue = true; + else + rValue = aCurValue; } + bHasDetectableInnerValue = true; } return bHasDetectableInnerValue; } @@ -90,15 +90,11 @@ public: if( m_ePropertyType == DIAGRAM && m_spChart2ModelContact ) { - std::vector< css::uno::Reference< css::chart2::XDataSeries > > aSeriesVector( - ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + m_spChart2ModelContact->getDiagram()->getDataSeries(); for (auto const& series : aSeriesVector) { - css::uno::Reference< css::beans::XPropertySet > xSeriesPropertySet(series, css::uno::UNO_QUERY); - if( xSeriesPropertySet.is() ) - { - setValueToSeries( xSeriesPropertySet, aNewValue ); - } + setValueToSeries( series, aNewValue ); } } } @@ -106,7 +102,7 @@ public: { PROPERTYTYPE aNewValue = PROPERTYTYPE(); if( ! (rOuterValue >>= aNewValue) ) - throw css::lang::IllegalArgumentException( "statistic property requires different type", nullptr, 0 ); + throw css::lang::IllegalArgumentException( u"statistic property requires different type"_ustr, nullptr, 0 ); if( m_ePropertyType == DIAGRAM ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx index ad07a98bcd15..f40b9edd7fb2 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -20,7 +20,7 @@ #include "WrappedSplineProperties.hxx" #include "Chart2ModelContact.hxx" #include <FastPropertyIdRanges.hxx> -#include <DiagramHelper.hxx> +#include <ChartType.hxx> #include <WrappedProperty.hxx> #include <unonames.hxx> @@ -29,10 +29,10 @@ #include <com/sun/star/chart2/CurveStyle.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> #include <com/sun/star/beans/XPropertySet.hpp> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; -using ::com::sun::star::uno::Sequence; using ::com::sun::star::beans::Property; namespace chart::wrapper @@ -47,32 +47,30 @@ template< typename PROPERTYTYPE > class WrappedSplineProperty : public WrappedProperty { public: - explicit WrappedSplineProperty( const OUString& rOuterName, const OUString& rInnerName + explicit WrappedSplineProperty( const OUString& rOuterName, OUString aInnerName , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(rOuterName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) , m_aOuterValue(rDefaulValue) , m_aDefaultValue(rDefaulValue) - , m_aOwnInnerName(rInnerName) + , m_aOwnInnerName(std::move(aInnerName)) { } bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const { - bool bHasDetectableInnerValue = false; rHasAmbiguousValue = false; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + rtl::Reference<Diagram> xDiagram = m_spChart2ModelContact->getDiagram(); + if (!xDiagram) + return false; + bool bHasDetectableInnerValue = false; + std::vector< rtl::Reference< ChartType > > aChartTypes = xDiagram->getChartTypes(); + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - uno::Reference<beans::XPropertySet> xChartTypePropertySet(aChartTypes[nN], uno::UNO_QUERY); - if (!xChartTypePropertySet.is()) - continue; - - Any aSingleValue = convertInnerToOuterValue( xChartTypePropertySet->getPropertyValue(m_aOwnInnerName) ); + Any aSingleValue = convertInnerToOuterValue( aChartTypes[nN]->getPropertyValue(m_aOwnInnerName) ); PROPERTYTYPE aCurValue = PROPERTYTYPE(); aSingleValue >>= aCurValue; if( !bHasDetectableInnerValue ) @@ -102,7 +100,7 @@ public: { PROPERTYTYPE aNewValue; if( ! (rOuterValue >>= aNewValue) ) - throw css::lang::IllegalArgumentException( "spline property requires different type", nullptr, 0 ); + throw css::lang::IllegalArgumentException( u"spline property requires different type"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; @@ -114,17 +112,13 @@ public: if( !(bHasAmbiguousValue || aNewValue != aOldValue) ) return; - Sequence< css::uno::Reference< css::chart2::XChartType > > aChartTypes( - ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); - for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + std::vector< rtl::Reference< ChartType > > aChartTypes = + m_spChart2ModelContact->getDiagram()->getChartTypes(); + for( sal_Int32 nN = aChartTypes.size(); nN--; ) { try { - css::uno::Reference< css::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], css::uno::UNO_QUERY ); - if( xChartTypePropertySet.is() ) - { - xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); - } + aChartTypes[nN]->setPropertyValue(m_aOwnInnerName,convertOuterToInnerValue(uno::Any(aNewValue))); } catch( uno::Exception & ex ) { diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx index 6e12bea50e0a..c17f6c50c263 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -21,6 +21,7 @@ #include "WrappedSeriesOrDiagramProperty.hxx" #include <FastPropertyIdRanges.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <ErrorBar.hxx> #include <StatisticsHelper.hxx> #include <unonames.hxx> @@ -31,7 +32,6 @@ #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart/ChartErrorIndicatorType.hpp> #include <com/sun/star/chart/ChartRegressionCurveType.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <utility> @@ -116,7 +116,7 @@ sal_Int32 lcl_getErrorBarStyle( const uno::Reference< beans::XPropertySet >& xEr { sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; if(xErrorBarProperties.is()) - xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle; + xErrorBarProperties->getPropertyValue( u"ErrorBarStyle"_ustr ) >>= nStyle; return nStyle; } @@ -126,8 +126,8 @@ uno::Reference< chart2::data::XDataProvider > lcl_getDataProviderFromContact( uno::Reference< chart2::data::XDataProvider > xResult; if( spChart2ModelContact) { - uno::Reference< chart2::XChartDocument > xChartDoc( - spChart2ModelContact->getChart2Document()); + rtl::Reference< ChartModel > xChartDoc( + spChart2ModelContact->getDocumentModel()); if( xChartDoc.is()) xResult.set( xChartDoc->getDataProvider()); } @@ -144,8 +144,7 @@ void lcl_ConvertRangeFromXML( lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); if( xConverter.is()) { - OUString aResult = xConverter->convertRangeFromXML( rInOutRange ); - rInOutRange = aResult; + rInOutRange = xConverter->convertRangeFromXML( rInOutRange ); } } } @@ -160,8 +159,7 @@ void lcl_ConvertRangeToXML( lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); if( xConverter.is()) { - OUString aResult = xConverter->convertRangeToXML( rInOutRange ); - rInOutRange = aResult; + rInOutRange = xConverter->convertRangeToXML( rInOutRange ); } } } @@ -189,9 +187,9 @@ protected: { xErrorBarProperties = new ::chart::ErrorBar; //default in new and old api are different - xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(false) ); - xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(false) ); - xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(css::chart::ErrorBarStyle::NONE) ); + xErrorBarProperties->setPropertyValue( u"ShowPositiveError"_ustr , uno::Any(false) ); + xErrorBarProperties->setPropertyValue( u"ShowNegativeError"_ustr , uno::Any(false) ); + xErrorBarProperties->setPropertyValue( u"ErrorBarStyle"_ustr , uno::Any(css::chart::ErrorBarStyle::NONE) ); xSeriesPropertySet->setPropertyValue( CHART_UNONAME_ERRORBAR_Y , uno::Any( xErrorBarProperties ) ); } return xErrorBarProperties; @@ -218,7 +216,7 @@ private: WrappedConstantErrorLowProperty::WrappedConstantErrorLowProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< double >( "ConstantErrorLow" + : WrappedStatisticProperty< double >( u"ConstantErrorLow"_ustr , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -231,7 +229,7 @@ double WrappedConstantErrorLowProperty::getValueFromSeries( const Reference< bea if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE ) - xErrorBarProperties->getPropertyValue( "NegativeError" ) >>= aRet; + xErrorBarProperties->getPropertyValue( u"NegativeError"_ustr ) >>= aRet; else m_aOuterValue >>= aRet; } @@ -246,7 +244,7 @@ void WrappedConstantErrorLowProperty::setValueToSeries( const Reference< beans:: m_aOuterValue <<= aNewValue; if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE ) { - xErrorBarProperties->setPropertyValue( "NegativeError", m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"NegativeError"_ustr, m_aOuterValue ); } } } @@ -272,7 +270,7 @@ private: WrappedConstantErrorHighProperty::WrappedConstantErrorHighProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< double >( "ConstantErrorHigh" + : WrappedStatisticProperty< double >( u"ConstantErrorHigh"_ustr , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -285,7 +283,7 @@ double WrappedConstantErrorHighProperty::getValueFromSeries( const Reference< be if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE ) - xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet; + xErrorBarProperties->getPropertyValue( u"PositiveError"_ustr ) >>= aRet; else m_aOuterValue >>= aRet; } @@ -300,7 +298,7 @@ void WrappedConstantErrorHighProperty::setValueToSeries( const Reference< beans: m_aOuterValue <<= aNewValue; if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ABSOLUTE ) { - xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"PositiveError"_ustr , m_aOuterValue ); } } } @@ -323,7 +321,7 @@ public: WrappedMeanValueProperty::WrappedMeanValueProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< bool >( "MeanValue", uno::Any( false ), std::move(spChart2ModelContact), ePropertyType ) + : WrappedStatisticProperty< bool >( u"MeanValue"_ustr, uno::Any( false ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -367,7 +365,7 @@ public: WrappedErrorCategoryProperty::WrappedErrorCategoryProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< css::chart::ChartErrorCategory >( "ErrorCategory" + : WrappedStatisticProperty< css::chart::ChartErrorCategory >( u"ErrorCategory"_ustr , uno::Any( css::chart::ChartErrorCategory_NONE ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -380,7 +378,7 @@ css::chart::ChartErrorCategory WrappedErrorCategoryProperty::getValueFromSeries( if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; - xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nStyle; + xErrorBarProperties->getPropertyValue( u"ErrorBarStyle"_ustr ) >>= nStyle; switch(nStyle) { case css::chart::ErrorBarStyle::NONE: @@ -444,7 +442,7 @@ void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPr default: break; } - xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any(nNewStyle) ); + xErrorBarProperties->setPropertyValue( u"ErrorBarStyle"_ustr , uno::Any(nNewStyle) ); } namespace { @@ -468,7 +466,7 @@ private: WrappedPercentageErrorProperty::WrappedPercentageErrorProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< double >( "PercentageError" + : WrappedStatisticProperty< double >( u"PercentageError"_ustr , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -481,7 +479,7 @@ double WrappedPercentageErrorProperty::getValueFromSeries( const Reference< bean if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::RELATIVE ) - xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet; + xErrorBarProperties->getPropertyValue( u"PositiveError"_ustr ) >>= aRet; else m_aOuterValue >>= aRet; } @@ -495,8 +493,8 @@ void WrappedPercentageErrorProperty::setValueToSeries( const Reference< beans::X m_aOuterValue <<= aNewValue; if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::RELATIVE ) { - xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue ); - xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"PositiveError"_ustr , m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"NegativeError"_ustr , m_aOuterValue ); } } } @@ -522,7 +520,7 @@ private: WrappedErrorMarginProperty::WrappedErrorMarginProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< double >( "ErrorMargin" + : WrappedStatisticProperty< double >( u"ErrorMargin"_ustr , uno::Any( 0.0 ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -535,7 +533,7 @@ double WrappedErrorMarginProperty::getValueFromSeries( const Reference< beans::X if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ERROR_MARGIN ) - xErrorBarProperties->getPropertyValue( "PositiveError" ) >>= aRet; + xErrorBarProperties->getPropertyValue( u"PositiveError"_ustr ) >>= aRet; else m_aOuterValue >>= aRet; } @@ -549,8 +547,8 @@ void WrappedErrorMarginProperty::setValueToSeries( const Reference< beans::XProp m_aOuterValue <<= aNewValue; if( lcl_getErrorBarStyle( xErrorBarProperties ) == css::chart::ErrorBarStyle::ERROR_MARGIN ) { - xErrorBarProperties->setPropertyValue( "PositiveError" , m_aOuterValue ); - xErrorBarProperties->setPropertyValue( "NegativeError" , m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"PositiveError"_ustr , m_aOuterValue ); + xErrorBarProperties->setPropertyValue( u"NegativeError"_ustr , m_aOuterValue ); } } } @@ -573,7 +571,7 @@ public: WrappedErrorIndicatorProperty::WrappedErrorIndicatorProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< css::chart::ChartErrorIndicatorType >( "ErrorIndicator" + : WrappedStatisticProperty< css::chart::ChartErrorIndicatorType >( u"ErrorIndicator"_ustr , uno::Any( css::chart::ChartErrorIndicatorType_NONE ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -587,8 +585,8 @@ css::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromS { bool bPositive = false; bool bNegative = false; - xErrorBarProperties->getPropertyValue( "ShowPositiveError" ) >>= bPositive; - xErrorBarProperties->getPropertyValue( "ShowNegativeError" ) >>= bNegative; + xErrorBarProperties->getPropertyValue( u"ShowPositiveError"_ustr ) >>= bPositive; + xErrorBarProperties->getPropertyValue( u"ShowNegativeError"_ustr ) >>= bNegative; if( bPositive && bNegative ) aRet = css::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM; @@ -623,8 +621,8 @@ void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XP break; } - xErrorBarProperties->setPropertyValue( "ShowPositiveError" , uno::Any(bPositive) ); - xErrorBarProperties->setPropertyValue( "ShowNegativeError" , uno::Any(bNegative) ); + xErrorBarProperties->setPropertyValue( u"ShowPositiveError"_ustr , uno::Any(bPositive) ); + xErrorBarProperties->setPropertyValue( u"ShowNegativeError"_ustr , uno::Any(bNegative) ); } namespace { @@ -646,7 +644,7 @@ public: WrappedErrorBarStyleProperty::WrappedErrorBarStyleProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< sal_Int32 >( "ErrorBarStyle" + : WrappedStatisticProperty< sal_Int32 >( u"ErrorBarStyle"_ustr , uno::Any( css::chart::ErrorBarStyle::NONE ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -658,7 +656,7 @@ sal_Int32 WrappedErrorBarStyleProperty::getValueFromSeries( const Reference< bea uno::Reference< beans::XPropertySet > xErrorBarProperties; if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( CHART_UNONAME_ERRORBAR_Y ) >>= xErrorBarProperties ) && xErrorBarProperties.is()) { - xErrorBarProperties->getPropertyValue( "ErrorBarStyle" ) >>= nRet; + xErrorBarProperties->getPropertyValue( u"ErrorBarStyle"_ustr ) >>= nRet; } return nRet; } @@ -670,7 +668,7 @@ void WrappedErrorBarStyleProperty::setValueToSeries( const Reference< beans::XPr uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); if( xErrorBarProperties.is() ) { - xErrorBarProperties->setPropertyValue( "ErrorBarStyle" , uno::Any( nNewValue )); + xErrorBarProperties->setPropertyValue( u"ErrorBarStyle"_ustr , uno::Any( nNewValue )); } } @@ -692,7 +690,7 @@ public: WrappedErrorBarRangePositiveProperty::WrappedErrorBarRangePositiveProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< OUString >( "ErrorBarRangePositive" + : WrappedStatisticProperty< OUString >( u"ErrorBarRangePositive"_ustr , uno::Any( OUString() ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -730,7 +728,7 @@ void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< be if( xDataSource.is() && xDataProvider.is()) { OUString aTmp( aNewValue ); - OUString aXMLRange( aNewValue ); + const OUString& aXMLRange( aNewValue ); lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); StatisticsHelper::setErrorDataSequence( xDataSource, xDataProvider, aTmp, true /* positive */, true /* y-error */, &aXMLRange ); @@ -756,7 +754,7 @@ public: WrappedErrorBarRangeNegativeProperty::WrappedErrorBarRangeNegativeProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< OUString >( "ErrorBarRangeNegative" + : WrappedStatisticProperty< OUString >( u"ErrorBarRangeNegative"_ustr , uno::Any( OUString() ), std::move(spChart2ModelContact), ePropertyType ) { } @@ -794,7 +792,7 @@ void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< be if( xDataSource.is() && xDataProvider.is()) { OUString aTmp( aNewValue ); - OUString aXMLRange( aNewValue ); + const OUString& aXMLRange( aNewValue ); lcl_ConvertRangeFromXML( aTmp, m_spChart2ModelContact ); StatisticsHelper::setErrorDataSequence( xDataSource, xDataProvider, aTmp, false /* positive */, true /* y-error */, &aXMLRange ); @@ -820,7 +818,7 @@ public: WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty( std::shared_ptr< Chart2ModelContact > spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedStatisticProperty< css::chart::ChartRegressionCurveType >( "RegressionCurves" + : WrappedStatisticProperty< css::chart::ChartRegressionCurveType >( u"RegressionCurves"_ustr , lcl_getRegressionDefault(), std::move(spChart2ModelContact), ePropertyType ) { } @@ -840,9 +838,10 @@ css::chart::ChartRegressionCurveType WrappedRegressionCurvesProperty::getValueFr void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, const css::chart::ChartRegressionCurveType& aNewValue ) const { uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( xSeriesPropertySet, uno::UNO_QUERY ); - uno::Reference< chart2::XRegressionCurve > xRegressionCurve( xSeriesPropertySet, uno::UNO_QUERY ); - - if( xRegressionCurveContainer.is() && xRegressionCurve.is() ) + if (!xRegressionCurveContainer) + return; + rtl::Reference< ::chart::RegressionCurveModel> xRegressionCurve = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegressionCurveContainer ); + if( xRegressionCurve.is() ) { SvxChartRegress eNewRegressionType = lcl_getRegressionType( aNewValue ); @@ -888,10 +887,10 @@ WrappedStatisticPropertySetProperty::WrappedStatisticPropertySetProperty( , tSeriesOrDiagramPropertyType ePropertyType ) : WrappedStatisticProperty< Reference< beans::XPropertySet > >( (ePropertySetType == PROPERTY_SET_TYPE_REGRESSION) - ? OUString("DataRegressionProperties") + ? u"DataRegressionProperties"_ustr : (ePropertySetType == PROPERTY_SET_TYPE_ERROR_BAR) - ? OUString("DataErrorProperties") - : OUString("DataMeanValueProperties") + ? u"DataErrorProperties"_ustr + : u"DataMeanValueProperties"_ustr , uno::Any(), std::move(spChart2ModelContact), ePropertyType ) , m_eType( ePropertySetType ) { @@ -906,7 +905,7 @@ Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFr { case PROPERTY_SET_TYPE_REGRESSION: if( xRegCnt.is() ) - xResult.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + xResult = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ); break; case PROPERTY_SET_TYPE_ERROR_BAR: if( xSeriesPropertySet.is()) @@ -914,7 +913,7 @@ Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFr break; case PROPERTY_SET_TYPE_MEAN_VALUE: if( xRegCnt.is() ) - xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + xResult = RegressionCurveHelper::getMeanValueLine( xRegCnt ); break; } diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx index 5e7a2808f832..afd0d0d7e85a 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -20,13 +20,14 @@ #include "WrappedStockProperties.hxx" #include "Chart2ModelContact.hxx" #include <FastPropertyIdRanges.hxx> -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> #include <ControllerLockGuard.hxx> #include <WrappedProperty.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/beans/PropertyAttribute.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <ChartTypeManager.hxx> +#include <ChartTypeTemplate.hxx> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -41,14 +42,14 @@ class WrappedStockProperty : public WrappedProperty { public: explicit WrappedStockProperty( const OUString& rOuterName - , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ); + , css::uno::Any aDefaultValue + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ); void setPropertyValue( const css::uno::Any& rOuterValue, const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; css::uno::Any getPropertyDefault( const css::uno::Reference< css::beans::XPropertyState >& xInnerPropertyState ) const override; - virtual uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const = 0; + virtual rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const = 0; protected: std::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; @@ -59,12 +60,11 @@ protected: } WrappedStockProperty::WrappedStockProperty( const OUString& rOuterName - , const css::uno::Any& rDefaulValue - , const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact ) + , css::uno::Any aDefaultValue + , std::shared_ptr<Chart2ModelContact> spChart2ModelContact ) : WrappedProperty(rOuterName,OUString()) - , m_spChart2ModelContact(spChart2ModelContact) - , m_aOuterValue() - , m_aDefaultValue(rDefaulValue) + , m_spChart2ModelContact(std::move(spChart2ModelContact)) + , m_aDefaultValue(std::move(aDefaultValue)) { } @@ -72,22 +72,24 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c { bool bNewValue = false; if( ! (rOuterValue >>= bNewValue) ) - throw lang::IllegalArgumentException( "stock properties require type sal_Bool", nullptr, 0 ); + throw lang::IllegalArgumentException( u"stock properties require type sal_Bool"_ustr, nullptr, 0 ); m_aOuterValue = rOuterValue; - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - sal_Int32 nDimension = ::chart::DiagramHelper::getDimension( xDiagram ); - if( !(xChartDoc.is() && xDiagram.is() && nDimension==2) ) + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + if( !xChartDoc || !xDiagram ) + return; + sal_Int32 nDimension = xDiagram->getDimension(); + if( nDimension != 2 ) return; - Reference< lang::XMultiServiceFactory > xFactory( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFactory ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - uno::Reference< chart2::XChartTypeTemplate > xTemplate = - getNewTemplate( bNewValue, aTemplateAndService.second, xFactory ); + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate = + getNewTemplate( bNewValue, aTemplateAndService.sServiceName, xChartTypeManager ); if(!xTemplate.is()) return; @@ -95,7 +97,7 @@ void WrappedStockProperty::setPropertyValue( const css::uno::Any& rOuterValue, c try { // locked controllers - ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + ControllerLockGuardUNO aCtrlLockGuard( m_spChart2ModelContact->getDocumentModel() ); xTemplate->changeDiagram( xDiagram ); } catch( const uno::Exception & ) @@ -118,34 +120,34 @@ public: css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; - uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override; + rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const override; }; } WrappedVolumeProperty::WrappedVolumeProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedStockProperty( "Volume", uno::Any(false) , spChart2ModelContact ) + : WrappedStockProperty( u"Volume"_ustr, uno::Any(false) , spChart2ModelContact ) { } css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { - Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - if( aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeLowHighClose" - || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) + if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeLowHighClose" + || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) m_aOuterValue <<= true; - else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() ) + else if( !aTemplateAndService.sServiceName.isEmpty() || !m_aOuterValue.hasValue() ) m_aOuterValue <<= false; } else if(!m_aOuterValue.hasValue()) @@ -154,9 +156,9 @@ css::uno::Any WrappedVolumeProperty::getPropertyValue( const css::uno::Reference return m_aOuterValue; } -uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +rtl::Reference< ::chart::ChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ::chart::ChartTypeManager >& xFactory ) const { - uno::Reference< chart2::XChartTypeTemplate > xTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate; if(!xFactory.is()) return xTemplate; @@ -164,16 +166,16 @@ uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTempla if( bNewValue ) //add volume { if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockVolumeLowHighClose"_ustr ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockVolumeOpenLowHighClose"_ustr ); } else //remove volume { if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockLowHighClose"_ustr ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockOpenLowHighClose"_ustr ); } return xTemplate; } @@ -187,34 +189,34 @@ public: css::uno::Any getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& xInnerPropertySet ) const override; - uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const override; + rtl::Reference< ::chart::ChartTypeTemplate > getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ChartTypeManager >& xFactory ) const override; }; } WrappedUpDownProperty::WrappedUpDownProperty(const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact) - : WrappedStockProperty( "UpDown", uno::Any(false) , spChart2ModelContact ) + : WrappedStockProperty( u"UpDown"_ustr, uno::Any(false) , spChart2ModelContact ) { } css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference< css::beans::XPropertySet >& /*xInnerPropertySet*/ ) const { - Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + rtl::Reference< ChartModel > xChartDoc( m_spChart2ModelContact->getDocumentModel() ); + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); if( xDiagram.is() && xChartDoc.is() ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); if( !aSeriesVector.empty() ) { - Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = xChartDoc->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); - if( aTemplateAndService.second == "com.sun.star.chart2.template.StockOpenLowHighClose" - || aTemplateAndService.second == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) + if( aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockOpenLowHighClose" + || aTemplateAndService.sServiceName == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) m_aOuterValue <<= true; - else if( !aTemplateAndService.second.isEmpty() || !m_aOuterValue.hasValue() ) + else if( !aTemplateAndService.sServiceName.isEmpty() || !m_aOuterValue.hasValue() ) m_aOuterValue <<= false; } else if(!m_aOuterValue.hasValue()) @@ -222,22 +224,22 @@ css::uno::Any WrappedUpDownProperty::getPropertyValue( const css::uno::Reference } return m_aOuterValue; } -uno::Reference< chart2::XChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +rtl::Reference< ::chart::ChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( bool bNewValue, const OUString& rCurrentTemplate, const rtl::Reference< ChartTypeManager >& xFactory ) const { - uno::Reference< chart2::XChartTypeTemplate > xTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate; if( bNewValue ) //add open series { if( rCurrentTemplate == "com.sun.star.chart2.template.StockLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockOpenLowHighClose"_ustr ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockVolumeOpenLowHighClose"_ustr ); } else //remove open series { if( rCurrentTemplate == "com.sun.star.chart2.template.StockOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockLowHighClose"_ustr ); else if( rCurrentTemplate == "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) - xTemplate.set( xFactory->createInstance( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), uno::UNO_QUERY ); + xTemplate = xFactory->createTemplate( u"com.sun.star.chart2.template.StockVolumeLowHighClose"_ustr ); } return xTemplate; } diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx index 4dfabee4836f..19c05e5274bc 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -20,6 +20,7 @@ #include "WrappedSymbolProperties.hxx" #include "WrappedSeriesOrDiagramProperty.hxx" #include <FastPropertyIdRanges.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart2/SymbolStyle.hpp> @@ -31,8 +32,7 @@ #include <vcl/GraphicLoader.hxx> #include <vcl/graph.hxx> -#include <vcl/outdev.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using ::com::sun::star::uno::Any; @@ -118,14 +118,12 @@ sal_Int32 lcl_getSymbolType( const css::chart2::Symbol& rSymbol ) case chart2::SymbolStyle_NONE: break; case chart2::SymbolStyle_AUTO: + case chart2::SymbolStyle_POLYGON://new feature nSymbol = css::chart::ChartSymbolType::AUTO; break; case chart2::SymbolStyle_STANDARD: nSymbol = rSymbol.StandardSymbol%15; break; - case chart2::SymbolStyle_POLYGON://new feature - nSymbol = css::chart::ChartSymbolType::AUTO; - break; case chart2::SymbolStyle_GRAPHIC: nSymbol = css::chart::ChartSymbolType::BITMAPURL; break; @@ -216,7 +214,7 @@ void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< std:: WrappedSymbolTypeProperty::WrappedSymbolTypeProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty< sal_Int32 >( "SymbolType" + : WrappedSeriesOrDiagramProperty< sal_Int32 >( u"SymbolType"_ustr , uno::Any( css::chart::ChartSymbolType::NONE ) , spChart2ModelContact , ePropertyType ) @@ -228,7 +226,7 @@ sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans: sal_Int32 aRet = 0; m_aDefaultValue >>= aRet; chart2::Symbol aSymbol; - if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) ) + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) ) aRet = lcl_getSymbolType( aSymbol ); return aRet; } @@ -239,10 +237,10 @@ void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPrope return; chart2::Symbol aSymbol; - xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol; + xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol ); - xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) ); + xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); } Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const @@ -285,10 +283,10 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc if( m_ePropertyType == DATA_SERIES && //single series or point m_spChart2ModelContact) { - Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); - Reference< chart2::XDataSeries > xSeries( xInnerPropertyState, uno::UNO_QUERY ); - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - if( ChartTypeHelper::isSupportingSymbolProperties( xChartType, 2 ) ) + rtl::Reference< ::chart::Diagram > xDiagram( m_spChart2ModelContact->getDiagram() ); + rtl::Reference< ::chart::DataSeries > xSeries( dynamic_cast<DataSeries*>(xInnerPropertyState.get()) ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); + if (xChartType.is() && xChartType->isSupportingSymbolProperties(2)) return beans::PropertyState_DIRECT_VALUE; } return WrappedProperty::getPropertyState( xInnerPropertyState ); @@ -297,7 +295,7 @@ beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Referenc WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty<OUString>("SymbolBitmapURL", + : WrappedSeriesOrDiagramProperty<OUString>(u"SymbolBitmapURL"_ustr, uno::Any(OUString()), spChart2ModelContact, ePropertyType) { } @@ -315,13 +313,13 @@ void WrappedSymbolBitmapURLProperty::setValueToSeries( return; chart2::Symbol aSymbol; - if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol) + if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) { if (!xNewGraphicURL.isEmpty()) { Graphic aGraphic = vcl::graphic::loadFromURL(xNewGraphicURL); aSymbol.Graphic.set(aGraphic.GetXGraphic()); - xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol)); + xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); } } } @@ -329,7 +327,7 @@ void WrappedSymbolBitmapURLProperty::setValueToSeries( WrappedSymbolBitmapProperty::WrappedSymbolBitmapProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>("SymbolBitmap", + : WrappedSeriesOrDiagramProperty<uno::Reference<graphic::XGraphic>>(u"SymbolBitmap"_ustr, uno::Any(uno::Reference<graphic::XGraphic>()), spChart2ModelContact, ePropertyType) { } @@ -340,7 +338,7 @@ uno::Reference<graphic::XGraphic> WrappedSymbolBitmapProperty::getValueFromSerie m_aDefaultValue >>= xGraphic; chart2::Symbol aSymbol; - if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol) + if (xSeriesPropertySet.is() && (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) && aSymbol.Graphic.is()) { xGraphic = aSymbol.Graphic; @@ -356,12 +354,12 @@ void WrappedSymbolBitmapProperty::setValueToSeries( return; chart2::Symbol aSymbol; - if (xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol) + if (xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) { if (xNewGraphic.is()) { aSymbol.Graphic.set(xNewGraphic); - xSeriesPropertySet->setPropertyValue("Symbol", uno::Any(aSymbol)); + xSeriesPropertySet->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); } } } @@ -389,7 +387,7 @@ void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) bool bFoundSize = false; try { - if( xProp->getPropertyValue( "Size100thMM" ) >>= aSize ) + if( xProp->getPropertyValue( u"Size100thMM"_ustr ) >>= aSize ) { if( aSize.Width == 0 && aSize.Height == 0 ) aSize = aDefaultSize; @@ -405,10 +403,11 @@ void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) if(!bFoundSize) { awt::Size aAWTPixelSize(10,10); - if( xProp->getPropertyValue( "SizePixel" ) >>= aAWTPixelSize ) + if( xProp->getPropertyValue( u"SizePixel"_ustr ) >>= aAWTPixelSize ) { Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height); - Size aNewSize = OutputDevice::LogicToLogic(aPixelSize, MapMode(MapUnit::MapPixel), MapMode(MapUnit::Map100thMM)); + Size aNewSize = o3tl::convert(aPixelSize, o3tl::Length::pt, o3tl::Length::mm100); + aSize = awt::Size( aNewSize.Width(), aNewSize.Height() ); if( aSize.Width == 0 && aSize.Height == 0 ) @@ -429,7 +428,7 @@ void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) WrappedSymbolSizeProperty::WrappedSymbolSizeProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty< awt::Size >( "SymbolSize" + : WrappedSeriesOrDiagramProperty< awt::Size >( u"SymbolSize"_ustr , uno::Any( awt::Size(250,250) ), spChart2ModelContact, ePropertyType ) { } @@ -439,7 +438,7 @@ awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans: awt::Size aRet; m_aDefaultValue >>= aRet; chart2::Symbol aSymbol; - if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )) + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) aRet = aSymbol.Size; return aRet; } @@ -452,11 +451,11 @@ void WrappedSymbolSizeProperty::setValueToSeries( return; chart2::Symbol aSymbol; - if( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol ) + if( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol ) { aSymbol.Size = aNewSize; lcl_correctSymbolSizeForBitmaps(aSymbol); - xSeriesPropertySet->setPropertyValue( "Symbol", uno::Any( aSymbol ) ); + xSeriesPropertySet->setPropertyValue( u"Symbol"_ustr, uno::Any( aSymbol ) ); } } @@ -470,7 +469,7 @@ beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Referenc { chart2::Symbol aSymbol; Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY ); - if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue("Symbol") >>= aSymbol )) + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(u"Symbol"_ustr) >>= aSymbol )) { if( aSymbol.Style != chart2::SymbolStyle_NONE ) return beans::PropertyState_DIRECT_VALUE; @@ -486,7 +485,7 @@ beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Referenc WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty( const std::shared_ptr<Chart2ModelContact>& spChart2ModelContact, tSeriesOrDiagramPropertyType ePropertyType ) - : WrappedSeriesOrDiagramProperty< bool >( "Lines" + : WrappedSeriesOrDiagramProperty< bool >( u"Lines"_ustr , uno::Any( true ), spChart2ModelContact, ePropertyType ) { } @@ -505,17 +504,17 @@ void WrappedSymbolAndLinesProperty::setValueToSeries( return; drawing::LineStyle eOldLineStyle( drawing::LineStyle_SOLID ); - xSeriesPropertySet->getPropertyValue( "LineStyle" ) >>= eOldLineStyle; + xSeriesPropertySet->getPropertyValue( u"LineStyle"_ustr ) >>= eOldLineStyle; if( bDrawLines ) { //#i114298# don't overwrite dashed lines with solid lines here if( eOldLineStyle == drawing::LineStyle_NONE ) - xSeriesPropertySet->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_SOLID ) ); + xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_SOLID ) ); } else { if( eOldLineStyle != drawing::LineStyle_NONE ) - xSeriesPropertySet->setPropertyValue( "LineStyle", uno::Any( drawing::LineStyle_NONE ) ); + xSeriesPropertySet->setPropertyValue( u"LineStyle"_ustr, uno::Any( drawing::LineStyle_NONE ) ); } } diff --git a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx index c35a75e31a54..850e916eaf0f 100644 --- a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx +++ b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx @@ -28,7 +28,7 @@ namespace chart { WrappedTextRotationProperty::WrappedTextRotationProperty( bool bDirectState ) - : ::chart::WrappedProperty( "TextRotation" , "TextRotation" ) + : ::chart::WrappedProperty( u"TextRotation"_ustr , u"TextRotation"_ustr ) , m_bDirectState( bDirectState ) { } diff --git a/chart2/source/controller/chartcontroller.component b/chart2/source/controller/chartcontroller.component deleted file mode 100644 index 01201cbb2494..000000000000 --- a/chart2/source/controller/chartcontroller.component +++ /dev/null @@ -1,58 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - --> - -<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@" - xmlns="http://openoffice.org/2010/uno-components"> - <implementation name="com.sun.star.comp.chart.ElementSelectorToolbarController" - constructor="com_sun_star_comp_chart_ElementSelectorToolbarController_get_implementation"> - <service name="com.sun.star.frame.ToolbarController"/> - </implementation> - <implementation name="com.sun.star.comp.chart2.ChartController" - constructor="com_sun_star_comp_chart2_ChartController_get_implementation"> - <service name="com.sun.star.chart2.ChartController"/> - <service name="com.sun.star.frame.Controller"/> - </implementation> - <implementation name="com.sun.star.comp.chart2.ChartDocumentWrapper" - constructor="com_sun_star_comp_chart2_ChartDocumentWrapper_get_implementation"> - <service name="com.sun.star.beans.PropertySet"/> - <service name="com.sun.star.chart.ChartDocument"/> - <service name="com.sun.star.chart2.ChartDocumentWrapper"/> - <service name="com.sun.star.xml.UserDefinedAttributesSupplier"/> - </implementation> - <implementation name="com.sun.star.comp.chart2.ChartFrameLoader" - constructor="com_sun_star_comp_chart2_ChartFrameLoader_get_implementation"> - <service name="com.sun.star.frame.SynchronousFrameLoader"/> - </implementation> - <implementation name="com.sun.star.comp.chart2.ChartTypeDialog" - constructor="com_sun_star_comp_chart2_ChartTypeDialog_get_implementation"> - <service name="com.sun.star.chart2.ChartTypeDialog"/> - </implementation> - <implementation name="com.sun.star.comp.chart2.WizardDialog" - constructor="com_sun_star_comp_chart2_WizardDialog_get_implementation"> - <service name="com.sun.star.chart2.WizardDialog"/> - </implementation> - <implementation name="org.libreoffice.comp.chart2.sidebar.ChartPanelFactory" - constructor="org_libreoffice_comp_chart2_sidebar_ChartPanelFactory"> - <service name="com.sun.star.ui.UIElementFactory"/> - </implementation> - <implementation name="org.libreoffice.chart2.Chart2ToolboxController" - constructor="org_libreoffice_chart2_Chart2ToolboxController"> - <service name="com.sun.star.frame.ToolbarController"/> - </implementation> -</component> diff --git a/chart2/source/controller/dialogs/ChartResourceGroupDlgs.cxx b/chart2/source/controller/dialogs/ChartResourceGroupDlgs.cxx index 91307afaad3d..3e426c4e02c9 100644 --- a/chart2/source/controller/dialogs/ChartResourceGroupDlgs.cxx +++ b/chart2/source/controller/dialogs/ChartResourceGroupDlgs.cxx @@ -32,11 +32,12 @@ const sal_uInt16 CUBIC_SPLINE_POS = 0; const sal_uInt16 B_SPLINE_POS = 1; SplinePropertiesDialog::SplinePropertiesDialog(weld::Window* pParent) - : GenericDialogController(pParent, "modules/schart/ui/smoothlinesdlg.ui", "SmoothLinesDialog") - , m_xLB_Spline_Type(m_xBuilder->weld_combo_box("SplineTypeComboBox")) - , m_xMF_SplineResolution(m_xBuilder->weld_spin_button("ResolutionSpinbutton")) - , m_xFT_SplineOrder(m_xBuilder->weld_label("PolynomialsLabel")) - , m_xMF_SplineOrder(m_xBuilder->weld_spin_button("PolynomialsSpinButton")) + : GenericDialogController(pParent, u"modules/schart/ui/smoothlinesdlg.ui"_ustr, + u"SmoothLinesDialog"_ustr) + , m_xLB_Spline_Type(m_xBuilder->weld_combo_box(u"SplineTypeComboBox"_ustr)) + , m_xMF_SplineResolution(m_xBuilder->weld_spin_button(u"ResolutionSpinbutton"_ustr)) + , m_xFT_SplineOrder(m_xBuilder->weld_label(u"PolynomialsLabel"_ustr)) + , m_xMF_SplineOrder(m_xBuilder->weld_spin_button(u"PolynomialsSpinButton"_ustr)) { m_xDialog->set_title(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES)); @@ -85,11 +86,12 @@ IMPL_LINK_NOARG(SplinePropertiesDialog, SplineTypeListBoxHdl, weld::ComboBox&, v } SteppedPropertiesDialog::SteppedPropertiesDialog(weld::Window* pParent) - : GenericDialogController(pParent, "modules/schart/ui/steppedlinesdlg.ui", "SteppedLinesDialog") - , m_xRB_Start(m_xBuilder->weld_radio_button("step_start_rb")) - , m_xRB_End(m_xBuilder->weld_radio_button("step_end_rb")) - , m_xRB_CenterX(m_xBuilder->weld_radio_button("step_center_x_rb")) - , m_xRB_CenterY(m_xBuilder->weld_radio_button("step_center_y_rb")) + : GenericDialogController(pParent, u"modules/schart/ui/steppedlinesdlg.ui"_ustr, + u"SteppedLinesDialog"_ustr) + , m_xRB_Start(m_xBuilder->weld_radio_button(u"step_start_rb"_ustr)) + , m_xRB_End(m_xBuilder->weld_radio_button(u"step_end_rb"_ustr)) + , m_xRB_CenterX(m_xBuilder->weld_radio_button(u"step_center_x_rb"_ustr)) + , m_xRB_CenterY(m_xBuilder->weld_radio_button(u"step_center_y_rb"_ustr)) { m_xDialog->set_title(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES)); } diff --git a/chart2/source/controller/dialogs/ChartResourceGroups.cxx b/chart2/source/controller/dialogs/ChartResourceGroups.cxx index bc1ccc81e7c9..f773eefd7062 100644 --- a/chart2/source/controller/dialogs/ChartResourceGroups.cxx +++ b/chart2/source/controller/dialogs/ChartResourceGroups.cxx @@ -29,9 +29,8 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; Dim3DLookResourceGroup::Dim3DLookResourceGroup(weld::Builder* pBuilder) - : ChangingResource() - , m_xCB_3DLook(pBuilder->weld_check_button("3dlook")) - , m_xLB_Scheme(pBuilder->weld_combo_box("3dscheme")) + : m_xCB_3DLook(pBuilder->weld_check_button(u"3dlook"_ustr)) + , m_xLB_Scheme(pBuilder->weld_combo_box(u"3dscheme"_ustr)) { m_xCB_3DLook->connect_toggled(LINK(this, Dim3DLookResourceGroup, Dim3DLookCheckHdl)); m_xLB_Scheme->connect_changed(LINK(this, Dim3DLookResourceGroup, SelectSchemeHdl)); @@ -88,8 +87,7 @@ IMPL_LINK_NOARG(Dim3DLookResourceGroup, SelectSchemeHdl, weld::ComboBox&, void) } SortByXValuesResourceGroup::SortByXValuesResourceGroup(weld::Builder* pBuilder) - : ChangingResource() - , m_xCB_XValueSorting(pBuilder->weld_check_button("sort")) + : m_xCB_XValueSorting(pBuilder->weld_check_button(u"sort"_ustr)) { m_xCB_XValueSorting->connect_toggled( LINK(this, SortByXValuesResourceGroup, SortByXValuesCheckHdl)); @@ -117,11 +115,10 @@ IMPL_LINK_NOARG(SortByXValuesResourceGroup, SortByXValuesCheckHdl, weld::Togglea } StackingResourceGroup::StackingResourceGroup(weld::Builder* pBuilder) - : ChangingResource() - , m_xCB_Stacked(pBuilder->weld_check_button("stack")) - , m_xRB_Stack_Y(pBuilder->weld_radio_button("ontop")) - , m_xRB_Stack_Y_Percent(pBuilder->weld_radio_button("percent")) - , m_xRB_Stack_Z(pBuilder->weld_radio_button("deep")) + : m_xCB_Stacked(pBuilder->weld_check_button(u"stack"_ustr)) + , m_xRB_Stack_Y(pBuilder->weld_radio_button(u"ontop"_ustr)) + , m_xRB_Stack_Y_Percent(pBuilder->weld_radio_button(u"percent"_ustr)) + , m_xRB_Stack_Z(pBuilder->weld_radio_button(u"deep"_ustr)) { m_xCB_Stacked->connect_toggled(LINK(this, StackingResourceGroup, StackingEnableHdl)); m_xRB_Stack_Y->connect_toggled(LINK(this, StackingResourceGroup, StackingChangeHdl)); @@ -145,9 +142,6 @@ void StackingResourceGroup::fillControls(const ChartTypeParameter& rParameter) != GlobalStackMode_STACK_Z); //todo remove this condition if z stacking radio button is really used switch (rParameter.eStackMode) { - case GlobalStackMode_STACK_Y: - m_xRB_Stack_Y->set_active(true); - break; case GlobalStackMode_STACK_Y_PERCENT: m_xRB_Stack_Y_Percent->set_active(true); break; @@ -160,6 +154,7 @@ void StackingResourceGroup::fillControls(const ChartTypeParameter& rParameter) */ m_xRB_Stack_Y->set_active(true); break; + case GlobalStackMode_STACK_Y: default: m_xRB_Stack_Y->set_active(true); break; @@ -200,31 +195,30 @@ IMPL_LINK_NOARG(StackingResourceGroup, StackingEnableHdl, weld::Toggleable&, voi } SplineResourceGroup::SplineResourceGroup(weld::Builder* pBuilder, weld::Window* pParent) - : ChangingResource() - , m_pParent(pParent) - , m_xFT_LineType(pBuilder->weld_label("linetypeft")) - , m_xLB_LineType(pBuilder->weld_combo_box("linetype")) - , m_xPB_DetailsDialog(pBuilder->weld_button("properties")) + : m_pParent(pParent) + , m_xFT_LineType(pBuilder->weld_label(u"linetypeft"_ustr)) + , m_xLB_LineType(pBuilder->weld_combo_box(u"linetype"_ustr)) + , m_xPB_DetailsDialog(pBuilder->weld_button(u"properties"_ustr)) { m_xLB_LineType->connect_changed(LINK(this, SplineResourceGroup, LineTypeChangeHdl)); } -SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog() +const std::shared_ptr<SplinePropertiesDialog>& SplineResourceGroup::getSplinePropertiesDialog() { if (!m_xSplinePropertiesDialog) { m_xSplinePropertiesDialog.reset(new SplinePropertiesDialog(m_pParent)); } - return *m_xSplinePropertiesDialog; + return m_xSplinePropertiesDialog; } -SteppedPropertiesDialog& SplineResourceGroup::getSteppedPropertiesDialog() +const std::shared_ptr<SteppedPropertiesDialog>& SplineResourceGroup::getSteppedPropertiesDialog() { if (!m_xSteppedPropertiesDialog) { m_xSteppedPropertiesDialog.reset(new SteppedPropertiesDialog(m_pParent)); } - return *m_xSteppedPropertiesDialog; + return m_xSteppedPropertiesDialog; } void SplineResourceGroup::showControls(bool bShow) @@ -249,7 +243,7 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SplineDetailsDialogHdl)); m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES)); - getSplinePropertiesDialog().fillControls(rParameter); + getSplinePropertiesDialog()->fillControls(rParameter); break; case CurveStyle_STEP_START: case CurveStyle_STEP_END: @@ -260,7 +254,7 @@ void SplineResourceGroup::fillControls(const ChartTypeParameter& rParameter) m_xPB_DetailsDialog->connect_clicked( LINK(this, SplineResourceGroup, SteppedDetailsDialogHdl)); m_xPB_DetailsDialog->set_tooltip_text(SchResId(STR_DLG_STEPPED_LINE_PROPERTIES)); - getSteppedPropertiesDialog().fillControls(rParameter); + getSteppedPropertiesDialog()->fillControls(rParameter); break; default: m_xLB_LineType->set_active(-1); @@ -272,10 +266,10 @@ void SplineResourceGroup::fillParameter(ChartTypeParameter& rParameter) switch (m_xLB_LineType->get_active()) { case POS_LINETYPE_SMOOTH: - getSplinePropertiesDialog().fillParameter(rParameter, true); + getSplinePropertiesDialog()->fillParameter(rParameter, true); break; case POS_LINETYPE_STEPPED: - getSteppedPropertiesDialog().fillParameter(rParameter, true); + getSteppedPropertiesDialog()->fillParameter(rParameter, true); break; default: // includes POS_LINETYPE_STRAIGHT rParameter.eCurveStyle = CurveStyle_LINES; @@ -292,48 +286,69 @@ IMPL_LINK_NOARG(SplineResourceGroup, LineTypeChangeHdl, weld::ComboBox&, void) IMPL_LINK_NOARG(SplineResourceGroup, SplineDetailsDialogHdl, weld::Button&, void) { ChartTypeParameter aOldParameter; - getSplinePropertiesDialog().fillParameter(aOldParameter, - m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); + std::shared_ptr<SplinePropertiesDialog> xDlg = getSplinePropertiesDialog(); + xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); m_xLB_LineType->set_active(POS_LINETYPE_SMOOTH); - if (getSplinePropertiesDialog().run() == RET_OK) - { - if (m_pChangeListener) - m_pChangeListener->stateChanged(); - } - else - { - //restore old state: - m_xLB_LineType->set_active(iOldLineTypePos); - getSplinePropertiesDialog().fillControls(aOldParameter); - } + weld::GenericDialogController::runAsync(xDlg, [this, xDlg, aOldParameter, + iOldLineTypePos](sal_Int32 nResult) { + m_xSplinePropertiesDialog = nullptr; + auto xNewDlg = getSplinePropertiesDialog(); + + if (nResult == RET_OK) + { + ChartTypeParameter aNewParameter; + xDlg->fillParameter(aNewParameter, m_xLB_LineType->get_active() == POS_LINETYPE_SMOOTH); + xNewDlg->fillControls(aNewParameter); + + if (m_pChangeListener) + m_pChangeListener->stateChanged(); + } + else + { + //restore old state: + m_xLB_LineType->set_active(iOldLineTypePos); + xNewDlg->fillControls(aOldParameter); + } + }); } IMPL_LINK_NOARG(SplineResourceGroup, SteppedDetailsDialogHdl, weld::Button&, void) { ChartTypeParameter aOldParameter; - getSteppedPropertiesDialog().fillParameter(aOldParameter, m_xLB_LineType->get_active() - == POS_LINETYPE_STEPPED); + std::shared_ptr<SteppedPropertiesDialog> xDlg = getSteppedPropertiesDialog(); + xDlg->fillParameter(aOldParameter, m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); const sal_Int32 iOldLineTypePos = m_xLB_LineType->get_active(); m_xLB_LineType->set_active(POS_LINETYPE_STEPPED); - if (getSteppedPropertiesDialog().run() == RET_OK) - { - if (m_pChangeListener) - m_pChangeListener->stateChanged(); - } - else - { - //restore old state: - m_xLB_LineType->set_active(iOldLineTypePos); - getSteppedPropertiesDialog().fillControls(aOldParameter); - } + + weld::GenericDialogController::runAsync( + xDlg, [this, xDlg, aOldParameter, iOldLineTypePos](sal_Int32 nResult) { + m_xSteppedPropertiesDialog = nullptr; + auto xNewDlg = getSteppedPropertiesDialog(); + + if (nResult == RET_OK) + { + ChartTypeParameter aNewParameter; + xDlg->fillParameter(aNewParameter, + m_xLB_LineType->get_active() == POS_LINETYPE_STEPPED); + xNewDlg->fillControls(aNewParameter); + + if (m_pChangeListener) + m_pChangeListener->stateChanged(); + } + else + { + //restore old state: + m_xLB_LineType->set_active(iOldLineTypePos); + xDlg->fillControls(aOldParameter); + } + }); } GeometryResourceGroup::GeometryResourceGroup(weld::Builder* pBuilder) - : ChangingResource() - , m_aGeometryResources(pBuilder) + : m_aGeometryResources(pBuilder) { m_aGeometryResources.connect_changed(LINK(this, GeometryResourceGroup, GeometryChangeHdl)); } diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx index b0fda08c72f6..555600b86edf 100644 --- a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -18,24 +18,27 @@ */ #include <ChartTypeDialogController.hxx> +#include <ChartTypeManager.hxx> +#include <ChartTypeTemplate.hxx> #include <ResId.hxx> #include <strings.hrc> #include <bitmaps.hlst> -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> +#include <DataSeriesHelper.hxx> +#include <Diagram.hxx> #include <ControllerLockGuard.hxx> #include <AxisHelper.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> +#include <ChartModel.hxx> #include <com/sun/star/chart2/DataPointGeometry3D.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <svtools/valueset.hxx> #include <vcl/image.hxx> #include <vcl/settings.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -144,7 +147,7 @@ ChartTypeParameter ChartTypeDialogController::getChartTypeParameterForService( try { - xTemplateProps->getPropertyValue( "Geometry3D" ) >>= aRet.nGeometry3D; + xTemplateProps->getPropertyValue( u"Geometry3D"_ustr ) >>= aRet.nGeometry3D; } catch( uno::Exception& ex ) { @@ -250,19 +253,19 @@ OUString ChartTypeDialogController::getServiceNameForParameter( const ChartTypeP } return OUString(); } -uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate( +rtl::Reference< ChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate( const ChartTypeParameter& rParameter - , const uno::Reference< lang::XMultiServiceFactory >& xTemplateManager ) const + , const rtl::Reference< ChartTypeManager >& xTemplateManager ) const { - uno::Reference< XChartTypeTemplate > xTemplate; + rtl::Reference< ChartTypeTemplate > xTemplate; OUString aServiceName( getServiceNameForParameter( rParameter ) ); if(!aServiceName.isEmpty()) { - xTemplate.set( xTemplateManager->createInstance( aServiceName ), uno::UNO_QUERY ); + xTemplate = xTemplateManager->createTemplate( aServiceName ); if(xTemplate.is()) { - uno::Reference< beans::XPropertySet > xTemplateProps( xTemplate, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(xTemplate.get()), uno::UNO_QUERY ); if(xTemplateProps.is()) { try @@ -278,7 +281,7 @@ uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTempla } try { - xTemplateProps->setPropertyValue( "Geometry3D" , uno::Any(rParameter.nGeometry3D) ); + xTemplateProps->setPropertyValue( u"Geometry3D"_ustr , uno::Any(rParameter.nGeometry3D) ); } catch( uno::Exception & ex ) { @@ -301,30 +304,45 @@ uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTempla } void ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParameter - , const uno::Reference< XChartDocument >& xChartModel ) + , const rtl::Reference<::chart::ChartModel>& xChartModel + , const uno::Reference<beans::XPropertySet>& xTemplateProps) { - uno::Reference< lang::XMultiServiceFactory > xTemplateManager( xChartModel->getChartTypeManager(), uno::UNO_QUERY ); - uno::Reference< XChartTypeTemplate > xTemplate( getCurrentTemplate( rParameter, xTemplateManager ) ); + rtl::Reference< ::chart::ChartTypeManager > xTemplateManager = xChartModel->getTypeManager(); + rtl::Reference< ::chart::ChartTypeTemplate > xTemplate( getCurrentTemplate( rParameter, xTemplateManager ) ); if(!xTemplate.is()) return; // locked controllers ControllerLockGuardUNO aCtrlLockGuard( xChartModel ); - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); - DiagramHelper::tTemplateWithServiceName aTemplateWithService( - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); - if( aTemplateWithService.first.is()) - aTemplateWithService.first->resetStyles( xDiagram ); + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + Diagram::tTemplateWithServiceName aTemplateWithService; + if (xDiagram) + aTemplateWithService = xDiagram->getTemplate( xTemplateManager ); + if( aTemplateWithService.xChartTypeTemplate.is()) + aTemplateWithService.xChartTypeTemplate->resetStyles2( xDiagram ); xTemplate->changeDiagram( xDiagram ); if( AllSettings::GetMathLayoutRTL() ) AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); if( rParameter.b3DLook ) - ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme ); + xDiagram->setScheme( rParameter.eThreeDLookScheme ); - uno::Reference<beans::XPropertySet> xDiaProp(xDiagram, uno::UNO_QUERY); - if (xDiaProp.is()) + if (xDiagram.is()) { - xDiaProp->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues)); + xDiagram->setPropertyValue(CHART_UNONAME_SORT_BY_XVALUES, uno::Any(rParameter.bSortByXValues)); + + sal_Int32 nSplitPos; + try { + if (xTemplateProps.is()) { + xTemplateProps->getPropertyValue(u"SplitPos"_ustr) >>= nSplitPos; + xDiagram->setPropertyValue(u"SplitPos"_ustr, uno::Any(nSplitPos)); + } + } + catch( uno::Exception & ex ) + { + //not all templates need to support SplitPos + ex.Context.is();//to have debug information without compilation warnings + } + } } void ChartTypeDialogController::fillSubTypeList( ValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ ) @@ -358,7 +376,7 @@ void ChartTypeDialogController::showExtraControls(weld::Builder* /*pBuilder*/) void ChartTypeDialogController::hideExtraControls() const { } -void ChartTypeDialogController::fillExtraControls( const uno::Reference< XChartDocument >& /*xChartModel*/ +void ChartTypeDialogController::fillExtraControls( const rtl::Reference<::chart::ChartModel>& /*xChartModel*/ , const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const { } @@ -367,7 +385,6 @@ void ChartTypeDialogController::setTemplateProperties( const uno::Reference< bea } ColumnOrBarChartDialogController_Base::ColumnOrBarChartDialogController_Base() - : ChartTypeDialogController() { } ColumnOrBarChartDialogController_Base::~ColumnOrBarChartDialogController_Base() @@ -539,6 +556,61 @@ void BarChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, const Ch rSubTypeList.SetItemText( 4, SchResId( STR_DEEP ) ); } +HistogramChartDialogController::HistogramChartDialogController() +{ + bSupports3D = false; +} + +HistogramChartDialogController::~HistogramChartDialogController() +{ +} + +OUString HistogramChartDialogController::getName() +{ + return SchResId(STR_TYPE_HISTOGRAM); +} + +OUString HistogramChartDialogController::getImage() +{ + return BMP_TYPE_HISTOGRAM; +} + +const tTemplateServiceChartTypeParameterMap& HistogramChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap s_aTemplateMap{ + {"com.sun.star.chart2.template.Histogram" , ChartTypeParameter(1, false, false, GlobalStackMode_NONE)} + }; + return s_aTemplateMap; +} +void HistogramChartDialogController::fillSubTypeList(ValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/) +{ + rSubTypeList.Clear(); + rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_HISTOGRAM)); + rSubTypeList.SetItemText(1, SchResId(STR_HISTOGRAM)); +} + +void HistogramChartDialogController::adjustParameterToSubType(ChartTypeParameter& rParameter) +{ + rParameter.b3DLook = false; + + switch (rParameter.nSubTypeIndex) + { + case 2: + // Pareto Histogram + break; + default: + // Standard Histogram + rParameter.eStackMode = GlobalStackMode_NONE; // Ensure no stacking + rParameter.bXAxisWithValues = false; // Standard histogram may not need X-axis values + // Set default bin width or other relevant properties if needed + break; + } +} + +//========= +// PieChartDialogController +//========= + PieChartDialogController::PieChartDialogController() { } @@ -605,6 +677,157 @@ void PieChartDialogController::adjustParameterToSubType( ChartTypeParameter& rPa rParameter.eStackMode = GlobalStackMode_NONE; } +//========= +// OfPieChartDialogController +//========= + +OfPieChartDialogController::OfPieChartDialogController() +{ +} + +OfPieChartDialogController::~OfPieChartDialogController() +{ +} + +OUString OfPieChartDialogController::getName() +{ + return SchResId(STR_TYPE_OFPIE); +} + +OUString OfPieChartDialogController::getImage() +{ + return BMP_TYPE_OFPIE; +} + +const tTemplateServiceChartTypeParameterMap& OfPieChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap s_aTemplateMap{ + {"com.sun.star.chart2.template.BarOfPie" , ChartTypeParameter(1,false,false)}, + {"com.sun.star.chart2.template.PieOfPie" , ChartTypeParameter(2,false,false)}}; + return s_aTemplateMap; +} +void OfPieChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, const ChartTypeParameter& /*rParameter*/ ) +{ + rSubTypeList.Clear(); + + rSubTypeList.InsertItem(1, Image(StockImage::Yes, BMP_BAR_OF_PIE)); + rSubTypeList.InsertItem(2, Image(StockImage::Yes, BMP_PIE_OF_PIE)); + rSubTypeList.SetItemText( 1, SchResId( STR_BAR_OF_PIE ) ); + rSubTypeList.SetItemText( 2, SchResId( STR_PIE_OF_PIE ) ); +} + +bool OfPieChartDialogController::shouldShow_3DLookControl() const +{ + // Maybe a TODO? + return false; +} + +void OfPieChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + if(rParameter.eStackMode==GlobalStackMode_STACK_Z) + rParameter.eStackMode = GlobalStackMode_NONE; +} + +void OfPieChartDialogController::showExtraControls(weld::Builder* pBuilder) +{ + if (!m_xFT_CompositeSize) + { + m_xFT_CompositeSize = pBuilder->weld_label(u"compositesizeft"_ustr); + assert(m_xFT_CompositeSize); + } + if (!m_xMF_CompositeSize) + { + m_xMF_CompositeSize = pBuilder->weld_spin_button(u"compositesize"_ustr); + assert(m_xMF_CompositeSize); + + m_xMF_CompositeSize->set_increments(1, 10); + m_xMF_CompositeSize->set_range(2, 100); + + m_xMF_CompositeSize->connect_value_changed( LINK( this, + OfPieChartDialogController, ChangeCompositeSizeHdl ) ); + m_xMF_CompositeSize->set_sensitive(true); + } + + m_xFT_CompositeSize->show(); + m_xMF_CompositeSize->show(); +} + +void OfPieChartDialogController::hideExtraControls() const +{ + if (m_xFT_CompositeSize) + m_xFT_CompositeSize->hide(); + if (m_xMF_CompositeSize) + m_xMF_CompositeSize->hide(); +} + +void OfPieChartDialogController::fillExtraControls( + const rtl::Reference<::chart::ChartModel>& xChartModel + , const uno::Reference< beans::XPropertySet >& xTemplateProps ) const +{ + if (!m_xMF_CompositeSize) + return; + + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + if(!xDiagram.is()) + return; + + sal_Int32 nCompositeSize = 2; + + if(xTemplateProps.is()) + { + try + { + xTemplateProps->getPropertyValue( u"SplitPos"_ustr ) >>= nCompositeSize; + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + } + if( nCompositeSize < 2 ) + nCompositeSize = 2; + m_xMF_CompositeSize->set_value(nCompositeSize); + + // Limit based on number of entries in the series + const std::vector< rtl::Reference< DataSeries > > dataSeriesVec = xChartModel->getDataSeries(); + if (!dataSeriesVec.empty()) { + const rtl::Reference<DataSeries>& ds = dataSeriesVec[0]; + const DataSeries::tDataSequenceContainer data = ds->getDataSequences2(); + const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aValuesSeries( + DataSeriesHelper::getAllDataSequencesByRole( data , u"values"_ustr ) ); + + assert(!aValuesSeries.empty()); + + const uno::Reference< chart2::data::XDataSequence > xSeq( aValuesSeries.front()->getValues() ); + + // Allow all but one entry to be aggregated in the composite wedge + sal_Int32 nMaxCompositeSize = xSeq->getData().getLength() - 1; + + if( nMaxCompositeSize < 2 ) + nMaxCompositeSize = 2; + m_xMF_CompositeSize->set_max(nMaxCompositeSize); + } +} + +void OfPieChartDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& xTemplateProps ) const +{ + if( xTemplateProps.is()) + { + sal_Int32 nCompositeSize = m_xMF_CompositeSize->get_value(); + xTemplateProps->setPropertyValue( u"SplitPos"_ustr , uno::Any(nCompositeSize) ); + } +} + +IMPL_LINK_NOARG(OfPieChartDialogController, ChangeCompositeSizeHdl, weld::SpinButton&, void) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(); +} + +//========= +// LineChartDialogController +//========= + LineChartDialogController::LineChartDialogController() { } @@ -1122,11 +1345,11 @@ void CombiColumnLineChartDialogController::showExtraControls(weld::Builder* pBui { if (!m_xFT_NumberOfLines) { - m_xFT_NumberOfLines = pBuilder->weld_label("nolinesft"); + m_xFT_NumberOfLines = pBuilder->weld_label(u"nolinesft"_ustr); } if (!m_xMF_NumberOfLines) { - m_xMF_NumberOfLines = pBuilder->weld_spin_button("nolines"); + m_xMF_NumberOfLines = pBuilder->weld_spin_button(u"nolines"_ustr); m_xMF_NumberOfLines->set_increments(1, 10); m_xMF_NumberOfLines->set_range(1, 100); @@ -1147,15 +1370,13 @@ void CombiColumnLineChartDialogController::hideExtraControls() const } void CombiColumnLineChartDialogController::fillExtraControls( - const uno::Reference< XChartDocument >& xChartModel + const rtl::Reference<::chart::ChartModel>& xChartModel , const uno::Reference< beans::XPropertySet >& xTemplateProps ) const { if (!m_xMF_NumberOfLines) return; - uno::Reference< frame::XModel > xModel = xChartModel; - - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); if(!xDiagram.is()) return; @@ -1165,7 +1386,7 @@ void CombiColumnLineChartDialogController::fillExtraControls( { try { - xTemplateProps->getPropertyValue( "NumberOfLines" ) >>= nNumLines; + xTemplateProps->getPropertyValue( u"NumberOfLines"_ustr ) >>= nNumLines; } catch( const uno::Exception & ) { @@ -1176,7 +1397,7 @@ void CombiColumnLineChartDialogController::fillExtraControls( nNumLines = 0; m_xMF_NumberOfLines->set_value(nNumLines); - sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xModel ).size() - 1; + sal_Int32 nMaxLines = xChartModel->getDataSeries().size() - 1; if( nMaxLines < 0 ) nMaxLines = 0; m_xMF_NumberOfLines->set_max(nMaxLines); @@ -1186,7 +1407,7 @@ void CombiColumnLineChartDialogController::setTemplateProperties( const uno::Ref if( xTemplateProps.is() ) { sal_Int32 nNumLines = m_xMF_NumberOfLines->get_value(); - xTemplateProps->setPropertyValue( "NumberOfLines" , uno::Any(nNumLines) ); + xTemplateProps->setPropertyValue( u"NumberOfLines"_ustr , uno::Any(nNumLines) ); } } diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx index a58d24433b75..7cab156b530c 100644 --- a/chart2/source/controller/dialogs/DataBrowser.cxx +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -20,8 +20,9 @@ #include <svl/zforlist.hxx> #include "DataBrowser.hxx" -#include "DataBrowserModel.hxx" +#include <DataBrowserModel.hxx> #include <strings.hrc> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <DiagramHelper.hxx> #include <CommonConverters.hxx> @@ -30,21 +31,22 @@ #include <ResId.hxx> #include <bitmaps.hlst> #include <helpids.h> +#include <ChartModel.hxx> +#include <ChartType.hxx> #include <vcl/weld.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <vcl/virdev.hxx> -#include <rtl/math.hxx> #include <o3tl/safeint.hxx> #include <osl/diagnose.h> +#include <svl/numformat.hxx> #include <toolkit/helper/vclunohelper.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XChartType.hpp> #include <com/sun/star/container/XIndexReplace.hpp> #include <algorithm> +#include <limits> using namespace ::com::sun::star; @@ -86,7 +88,7 @@ namespace impl class SeriesHeaderEdit { public: - explicit SeriesHeaderEdit(std::unique_ptr<weld::Entry> xControl); + explicit SeriesHeaderEdit(std::unique_ptr<weld::Entry> xControl, sal_Int32 nHeader); void setStartColumn( sal_Int32 nStartColumn ); sal_Int32 getStartColumn() const { return m_nStartColumn;} @@ -115,7 +117,7 @@ private: bool m_bShowWarningBox; }; -SeriesHeaderEdit::SeriesHeaderEdit(std::unique_ptr<weld::Entry> xControl) +SeriesHeaderEdit::SeriesHeaderEdit(std::unique_ptr<weld::Entry> xControl, sal_Int32 nHeader) : m_xControl(std::move(xControl)) , m_nStartColumn(0) , m_bShowWarningBox(false) @@ -124,6 +126,8 @@ SeriesHeaderEdit::SeriesHeaderEdit(std::unique_ptr<weld::Entry> xControl) m_xControl->connect_changed(LINK(this, SeriesHeaderEdit, NameEdited)); m_xControl->connect_focus_in(LINK(this, SeriesHeaderEdit, NameFocusIn)); m_xControl->connect_mouse_press(LINK(this, SeriesHeaderEdit, MousePressHdl)); + + m_xControl->set_buildable_name(m_xControl->get_buildable_name() + OUString::number(nHeader)); } IMPL_LINK_NOARG(SeriesHeaderEdit, NameEdited, weld::Entry&, void) @@ -162,13 +166,13 @@ IMPL_LINK_NOARG(SeriesHeaderEdit, MousePressHdl, const MouseEvent&, bool) class SeriesHeader { public: - explicit SeriesHeader(weld::Container* pParent, weld::Container* pColorParent); + explicit SeriesHeader(weld::Container* pParent, weld::Container* pColorParent, sal_Int32 nHeader); ~SeriesHeader(); void SetColor( const Color & rCol ); void SetPos(); void SetWidth( sal_Int32 nWidth ); - void SetChartType( const Reference< chart2::XChartType > & xChartType, + void SetChartType( const rtl::Reference< ::chart::ChartType > & xChartType, bool bSwapXAndYAxis ); void SetSeriesName( const OUString & rName ); void SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol ); @@ -220,7 +224,7 @@ private: DECL_LINK( SeriesNameEdited, SeriesHeaderEdit&, void ); static OUString GetChartTypeImage( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ::chart::ChartType > & xChartType, bool bSwapXAndYAxis ); @@ -229,17 +233,17 @@ private: bool m_bSeriesNameChangePending; }; -SeriesHeader::SeriesHeader(weld::Container* pParent, weld::Container* pColorParent) - : m_aUpdateDataTimer("UpdateDataTimer") - , m_xBuilder1(Application::CreateBuilder(pParent, "modules/schart/ui/columnfragment.ui")) - , m_xBuilder2(Application::CreateBuilder(pColorParent, "modules/schart/ui/imagefragment.ui")) +SeriesHeader::SeriesHeader(weld::Container* pParent, weld::Container* pColorParent, sal_Int32 nHeader) + : m_aUpdateDataTimer( "SeriesHeader UpdateDataTimer" ) + , m_xBuilder1(Application::CreateBuilder(pParent, u"modules/schart/ui/columnfragment.ui"_ustr)) + , m_xBuilder2(Application::CreateBuilder(pColorParent, u"modules/schart/ui/imagefragment.ui"_ustr)) , m_pParent(pParent) , m_pColorParent(pColorParent) - , m_xContainer1(m_xBuilder1->weld_container("container")) - , m_xContainer2(m_xBuilder2->weld_container("container")) - , m_spSymbol(m_xBuilder1->weld_image("image")) - , m_spSeriesName(new SeriesHeaderEdit(m_xBuilder1->weld_entry("entry"))) - , m_spColorBar(m_xBuilder2->weld_image("image")) + , m_xContainer1(m_xBuilder1->weld_container(u"container"_ustr)) + , m_xContainer2(m_xBuilder2->weld_container(u"container"_ustr)) + , m_spSymbol(m_xBuilder1->weld_image(u"image"_ustr)) + , m_spSeriesName(new SeriesHeaderEdit(m_xBuilder1->weld_entry(u"entry"_ustr), nHeader)) + , m_spColorBar(m_xBuilder2->weld_image(u"image"_ustr)) , m_xDevice(Application::GetDefaultDevice()) , m_nStartCol( 0 ) , m_nEndCol( 0 ) @@ -247,7 +251,6 @@ SeriesHeader::SeriesHeader(weld::Container* pParent, weld::Container* pColorPare , m_bSeriesNameChangePending( false ) { m_aUpdateDataTimer.SetInvokeHandler(LINK(this, SeriesHeader, ImplUpdateDataHdl)); - m_aUpdateDataTimer.SetDebugName( "SeriesHeader UpdateDataTimer" ); m_aUpdateDataTimer.SetTimeout(4 * EDIT_UPDATEDATA_TIMEOUT); m_spSeriesName->SetModifyHdl(LINK(this, SeriesHeader, SeriesNameEdited)); @@ -290,20 +293,15 @@ void SeriesHeader::SetPos() // series name edit field m_spSeriesName->set_margin_start(2); - aSize.setWidth(nSymbolHeight); - aSize.setHeight(12); - aSize = m_xDevice->LogicToPixel(aSize, MapMode(MapUnit::MapAppFont)); - aSize.setWidth(m_nWidth - aSize.Width() - 2); - m_spSeriesName->set_size_request(aSize.Width(), aSize.Height()); + sal_Int32 nHeightPx = m_xDevice->LogicToPixel(Size(0, 12), MapMode(MapUnit::MapAppFont)).Height(); + m_spSeriesName->set_size_request(m_nWidth - aSize.Width() - 2, nHeightPx); // color bar - aSize.setHeight(3); - aSize = m_xDevice->LogicToPixel(aSize, MapMode(MapUnit::MapAppFont)); - aSize.setWidth(m_nWidth); - m_spColorBar->set_size_request(aSize.Width(), aSize.Height()); + nHeightPx = m_xDevice->LogicToPixel(Size(0, 3), MapMode(MapUnit::MapAppFont)).Height(); + m_spColorBar->set_size_request(m_nWidth, nHeightPx); ScopedVclPtr<VirtualDevice> xVirDev(m_spColorBar->create_virtual_device()); - xVirDev->SetOutputSizePixel(aSize); + xVirDev->SetOutputSizePixel(Size(m_nWidth, nHeightPx)); xVirDev->SetFillColor(m_aColor); xVirDev->SetLineColor(m_aColor); xVirDev->DrawRect(tools::Rectangle(Point(0, 0), aSize)); @@ -322,7 +320,7 @@ void SeriesHeader::SetPixelWidth( sal_Int32 nWidth ) } void SeriesHeader::SetChartType( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ChartType > & xChartType, bool bSwapXAndYAxis ) { @@ -380,7 +378,7 @@ bool SeriesHeader::HasFocus() const } OUString SeriesHeader::GetChartTypeImage( - const Reference< chart2::XChartType > & xChartType, + const rtl::Reference< ChartType > & xChartType, bool bSwapXAndYAxis ) { @@ -489,10 +487,8 @@ DataBrowser::DataBrowser(const css::uno::Reference<css::awt::XWindow> &rParent, m_rNumberEditController( new ::svt::FormattedFieldCellController( m_aNumberEditField.get() )), m_rTextEditController( new ::svt::EditCellController( m_aTextEditField.get() )) { - double fNan; - ::rtl::math::setNan( & fNan ); Formatter& rFormatter = m_aNumberEditField->get_formatter(); - rFormatter.SetDefaultValue( fNan ); + rFormatter.SetDefaultValue( std::numeric_limits<double>::quiet_NaN() ); rFormatter.TreatAsNumber( true ); RenewTable(); } @@ -621,7 +617,7 @@ void DataBrowser::RenewTable() GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() )); OUString aDefaultSeriesName(SchResId(STR_COLUMN_LABEL)); - replaceParamterInString( aDefaultSeriesName, "%COLUMNNUMBER", OUString::number( 24 ) ); + replaceParamterInString( aDefaultSeriesName, u"%COLUMNNUMBER", OUString::number( 24 ) ); sal_Int32 nColumnWidth = GetDataWindow().GetTextWidth( aDefaultSeriesName ) + GetDataWindow().LogicToPixel(Point(8 + impl::SeriesHeader::GetRelativeAppFontXPosForNameField(), 0), MapMode(MapUnit::MapAppFont)).X(); sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount(); @@ -642,22 +638,21 @@ void DataBrowser::RenewTable() Link<impl::SeriesHeaderEdit&,void> aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus )); Link<impl::SeriesHeaderEdit&,void> aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged )); - for (auto const& elemHeader : aHeaders) + for (size_t i = 0; i < aHeaders.size(); ++i) { - auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin ); - Reference< beans::XPropertySet > xSeriesProp( elemHeader.m_xDataSeries, uno::UNO_QUERY ); + auto const& elemHeader = aHeaders[i]; + auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin, i); Color nColor; // @todo: Set "DraftColor", i.e. interpolated colors for gradients, bitmaps, etc. - if( xSeriesProp.is() && - ( xSeriesProp->getPropertyValue( "Color" ) >>= nColor )) + if( elemHeader.m_xDataSeries.is() && + ( elemHeader.m_xDataSeries->getPropertyValue( u"Color"_ustr ) >>= nColor )) spHeader->SetColor( nColor ); spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis ); spHeader->SetSeriesName( - DataSeriesHelper::getDataSeriesLabel( - elemHeader.m_xDataSeries, - (elemHeader.m_xChartType.is() ? + elemHeader.m_xDataSeries->getLabelForRole( + elemHeader.m_xChartType.is() ? elemHeader.m_xChartType->getRoleOfSequenceForSeriesLabel() : - OUString("values-y")))); + u"values-y"_ustr)); // index is 1-based, as 0 is for the column that contains the row-numbers spHeader->SetRange( elemHeader.m_nStartColumn + 1, elemHeader.m_nEndColumn + 1 ); spHeader->SetGetFocusHdl( aFocusLink ); @@ -671,12 +666,12 @@ void DataBrowser::RenewTable() Invalidate(); } -OUString DataBrowser::GetColString( sal_Int32 nColumnId ) const +const OUString & DataBrowser::GetColString( sal_Int32 nColumnId ) const { OSL_ASSERT(m_apDataBrowserModel); if( nColumnId > 0 ) return m_apDataBrowserModel->getRoleOfColumn( nColumnId - 1 ); - return OUString(); + return EMPTY_OUSTRING; } OUString DataBrowser::GetCellText( sal_Int32 nRow, sal_uInt16 nColumnId ) const @@ -721,7 +716,7 @@ OUString DataBrowser::GetCellText( sal_Int32 nRow, sal_uInt16 nColumnId ) const // getDateTimeInputNumberFormat() instead of doing the // guess work. sal_Int32 nNumberFormat = DiagramHelper::getDateTimeInputNumberFormat( - Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY), fDouble ); + m_xChartDoc, fDouble ); Color nLabelColor; bool bColorChanged = false; aResult = m_spNumberFormatterWrapper->getFormattedString( @@ -741,16 +736,13 @@ OUString DataBrowser::GetCellText( sal_Int32 nRow, sal_uInt16 nColumnId ) const double DataBrowser::GetCellNumber( sal_Int32 nRow, sal_uInt16 nColumnId ) const { - double fResult; - ::rtl::math::setNan( & fResult ); - if(( nColumnId >= 1 ) && ( nRow >= 0 ) && m_apDataBrowserModel) { - fResult = m_apDataBrowserModel->getCellNumber( + return m_apDataBrowserModel->getCellNumber( static_cast< sal_Int32 >( nColumnId ) - 1, nRow ); } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } void DataBrowser::Resize() @@ -836,15 +828,13 @@ void DataBrowser::CellModified() } void DataBrowser::SetDataFromModel( - const Reference< chart2::XChartDocument > & xChartDoc, - const Reference< uno::XComponentContext > & xContext ) + const rtl::Reference<::chart::ChartModel> & xChartDoc ) { - m_xChartDoc.set( xChartDoc ); + m_xChartDoc = xChartDoc; - m_apDataBrowserModel.reset( new DataBrowserModel( m_xChartDoc, xContext )); + m_apDataBrowserModel.reset( new DataBrowserModel( m_xChartDoc )); m_spNumberFormatterWrapper = - std::make_shared<NumberFormatterWrapper>( - Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY )); + std::make_shared<NumberFormatterWrapper>(m_xChartDoc); Formatter& rFormatter = m_aNumberEditField->get_formatter(); rFormatter.SetFormatter( m_spNumberFormatterWrapper->getSvNumberFormatter() ); @@ -908,9 +898,9 @@ void DataBrowser::RemoveColumn() void DataBrowser::InsertRow() { - sal_Int32 nRowIdx = GetCurRow(); + sal_Int32 nRowIdx = GetCurRow(); - if( nRowIdx >= 0 && m_apDataBrowserModel) + if( nRowIdx >= 0 && m_apDataBrowserModel) { // save changes made to edit-field if( IsModified() ) @@ -923,9 +913,9 @@ void DataBrowser::InsertRow() void DataBrowser::RemoveRow() { - sal_Int32 nRowIdx = GetCurRow(); + sal_Int32 nRowIdx = GetCurRow(); - if( nRowIdx >= 0 && m_apDataBrowserModel) + if( nRowIdx >= 0 && m_apDataBrowserModel) { // save changes made to edit-field if( IsModified() ) @@ -953,7 +943,7 @@ void DataBrowser::MoveLeftColumn() // keep cursor in swapped column if(( 0 < GetCurColumnId() ) && ( GetCurColumnId() <= ColCount() - 1 )) { - Dispatch( BROWSER_CURSORLEFT ); + Dispatch(BrowserDispatchId::CURSORLEFT); } RenewTable(); } @@ -974,7 +964,7 @@ void DataBrowser::MoveRightColumn() // keep cursor in swapped column if( GetCurColumnId() < ColCount() - 1 ) { - Dispatch( BROWSER_CURSORRIGHT ); + Dispatch(BrowserDispatchId::CURSORRIGHT); } RenewTable(); } @@ -995,7 +985,7 @@ void DataBrowser::MoveUpRow() // keep cursor in swapped row if(( 0 < GetCurRow() ) && ( GetCurRow() <= GetRowCount() - 1 )) { - Dispatch( BROWSER_CURSORUP ); + Dispatch(BrowserDispatchId::CURSORUP); } RenewTable(); } @@ -1016,7 +1006,7 @@ void DataBrowser::MoveDownRow() // keep cursor in swapped row if( GetCurRow() < GetRowCount() - 1 ) { - Dispatch( BROWSER_CURSORDOWN ); + Dispatch(BrowserDispatchId::CURSORDOWN); } RenewTable(); } @@ -1274,21 +1264,21 @@ void DataBrowser::RenewSeriesHeaders() Link<impl::SeriesHeaderEdit&,void> aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus )); Link<impl::SeriesHeaderEdit&,void> aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged )); - for (auto const& elemHeader : aHeaders) + + for (size_t i = 0; i < aHeaders.size(); ++i) { - auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin ); - Reference< beans::XPropertySet > xSeriesProp(elemHeader.m_xDataSeries, uno::UNO_QUERY); + auto const& elemHeader = aHeaders[i]; + auto spHeader = std::make_shared<impl::SeriesHeader>( m_pColumnsWin, m_pColorsWin, i ); Color nColor; - if( xSeriesProp.is() && - ( xSeriesProp->getPropertyValue( "Color" ) >>= nColor )) + if( elemHeader.m_xDataSeries.is() && + ( elemHeader.m_xDataSeries->getPropertyValue( u"Color"_ustr ) >>= nColor )) spHeader->SetColor( nColor ); spHeader->SetChartType( elemHeader.m_xChartType, elemHeader.m_bSwapXAndYAxis ); spHeader->SetSeriesName( - DataSeriesHelper::getDataSeriesLabel( - elemHeader.m_xDataSeries, - (elemHeader.m_xChartType.is() ? + elemHeader.m_xDataSeries->getLabelForRole( + elemHeader.m_xChartType.is() ? elemHeader.m_xChartType->getRoleOfSequenceForSeriesLabel() : - OUString( "values-y")))); + u"values-y"_ustr)); spHeader->SetRange( elemHeader.m_nStartColumn + 1, elemHeader.m_nEndColumn + 1 ); spHeader->SetGetFocusHdl( aFocusLink ); spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink ); @@ -1365,18 +1355,17 @@ IMPL_LINK( DataBrowser, SeriesHeaderGotFocus, impl::SeriesHeaderEdit&, rEdit, vo IMPL_LINK( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit&, rEdit, void ) { - Reference< chart2::XDataSeries > xSeries( - m_apDataBrowserModel->getDataSeriesByColumn( rEdit.getStartColumn() - 1 )); - Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); - if( !xSource.is()) + rtl::Reference< DataSeries > xSeries = + m_apDataBrowserModel->getDataSeriesByColumn( rEdit.getStartColumn() - 1 ); + if( !xSeries.is()) return; - Reference< chart2::XChartType > xChartType( + rtl::Reference< ChartType > xChartType( m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType ); if( xChartType.is()) { - Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, xChartType->getRoleOfSequenceForSeriesLabel())); + uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSeq = + DataSeriesHelper::getDataSequenceByRole( xSeries, xChartType->getRoleOfSequenceForSeriesLabel()); if( xLabeledSeq.is()) { Reference< container::XIndexReplace > xIndexReplace( xLabeledSeq->getLabel(), uno::UNO_QUERY ); diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx index e0699a60d1b4..46c62ba63e3c 100644 --- a/chart2/source/controller/dialogs/DataBrowser.hxx +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -43,6 +43,7 @@ namespace chart class DataBrowserModel; class NumberFormatterWrapper; +class ChartModel; namespace impl { @@ -97,8 +98,7 @@ public: void SetReadOnly( bool bNewState ); bool IsReadOnly() const { return m_bIsReadOnly;} - void SetDataFromModel( const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc, - const css::uno::Reference< css::uno::XComponentContext > & xContext ); + void SetDataFromModel( const rtl::Reference<::chart::ChartModel> & xChartDoc ); // predicates to determine what actions are possible at the current cursor // position. This depends on the implementation of the according mutators @@ -145,7 +145,7 @@ public: void RenewSeriesHeaders(); private: - css::uno::Reference< css::chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; std::unique_ptr< DataBrowserModel > m_apDataBrowserModel; typedef std::vector< std::shared_ptr< impl::SeriesHeader > > tSeriesHeaderContainer; @@ -174,7 +174,7 @@ private: void RenewTable(); void ImplAdjustHeaderControls(); - OUString GetColString( sal_Int32 nColumnId ) const; + const OUString & GetColString( sal_Int32 nColumnId ) const; DECL_LINK( SeriesHeaderGotFocus, impl::SeriesHeaderEdit&, void ); DECL_LINK( SeriesHeaderChanged, impl::SeriesHeaderEdit&, void ); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx index c8359f74ab23..e3c4d35a685e 100644 --- a/chart2/source/controller/dialogs/DataBrowserModel.cxx +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -17,37 +17,36 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include "DataBrowserModel.hxx" #include "DialogModel.hxx" -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <DataBrowserModel.hxx> +#include <ChartType.hxx> +#include <ChartTypeManager.hxx> +#include <ChartView.hxx> +#include <Diagram.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <ControllerLockGuard.hxx> #include <StatisticsHelper.hxx> #include <ChartTypeHelper.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <ExplicitCategoriesProvider.hxx> - +#include <BaseCoordinateSystem.hxx> #include <ChartModel.hxx> #include <unonames.hxx> #include <com/sun/star/container/XIndexReplace.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> #include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> #include <com/sun/star/chart2/data/XTextualDataSequence.hpp> -#include <com/sun/star/util/XModifiable.hpp> #include <o3tl/safeint.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/property.hxx> -#include <rtl/math.hxx> - #include <algorithm> +#include <cstddef> +#include <limits> +#include <utility> using namespace ::com::sun::star; @@ -67,7 +66,7 @@ OUString lcl_getRole( { try { - xProp->getPropertyValue( "Role" ) >>= aResult; + xProp->getPropertyValue( u"Role"_ustr ) >>= aResult; } catch( const uno::Exception & ) { @@ -96,7 +95,7 @@ void lcl_copyDataSequenceProperties( } bool lcl_SequenceOfSeriesIsShared( - const Reference< chart2::XDataSeries > & xSeries, + const rtl::Reference< ::chart::DataSeries > & xSeries, const Reference< chart2::data::XDataSequence > & xValues ) { bool bResult = false; @@ -106,9 +105,8 @@ bool lcl_SequenceOfSeriesIsShared( { OUString aValuesRole( lcl_getRole( xValues )); OUString aValuesRep( xValues->getSourceRangeRepresentation()); - Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY_THROW ); - const Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); - for( Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aLSeq ) + const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aLSeq( xSeries->getDataSequences2()); + for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aLSeq ) if (labeledDataSeq.is() && DataSeriesHelper::getRole(labeledDataSeq) == aValuesRole) { // getValues().is(), because lcl_getRole checked that already @@ -124,24 +122,22 @@ bool lcl_SequenceOfSeriesIsShared( return bResult; } -typedef std::vector< Reference< chart2::data::XLabeledDataSequence > > lcl_tSharedSeqVec; +typedef std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > lcl_tSharedSeqVec; -lcl_tSharedSeqVec lcl_getSharedSequences( const Sequence< Reference< chart2::XDataSeries > > & rSeries ) +lcl_tSharedSeqVec lcl_getSharedSequences( const std::vector< rtl::Reference< DataSeries > > & rSeries ) { // @todo: if only some series share a sequence, those have to be duplicated // and made unshared for all series lcl_tSharedSeqVec aResult; // if we have only one series, we don't want any shared sequences - if( rSeries.getLength() <= 1 ) + if( rSeries.size() <= 1 ) return aResult; - Reference< chart2::data::XDataSource > xSource( rSeries[0], uno::UNO_QUERY ); - const Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); - for( Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aLSeq ) + for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : rSeries[0]->getDataSequences2() ) { Reference< chart2::data::XDataSequence > xValues( labeledDataSeq->getValues()); bool bShared = true; - for( sal_Int32 nSeriesIdx=1; nSeriesIdx<rSeries.getLength(); ++nSeriesIdx ) + for( std::size_t nSeriesIdx=1; nSeriesIdx<rSeries.size(); ++nSeriesIdx ) { bShared = lcl_SequenceOfSeriesIsShared( rSeries[nSeriesIdx], xValues ); if( !bShared ) @@ -190,10 +186,10 @@ private: struct lcl_RolesOfLSeqMatch { - explicit lcl_RolesOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : + explicit lcl_RolesOfLSeqMatch( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : m_aRole(DataSeriesHelper::getRole(xLSeq)) {} - bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) + bool operator() ( const uno::Reference< chart2::data::XLabeledDataSequence > & xLSeq ) { return DataSeriesHelper::getRole(xLSeq) == m_aRole; } @@ -201,16 +197,16 @@ private: OUString m_aRole; }; -bool lcl_ShowCategoriesAsDataLabel( const Reference< chart2::XDiagram > & xDiagram ) +bool lcl_ShowCategoriesAsDataLabel( const rtl::Reference< ::chart::Diagram > & xDiagram ) { - return !DiagramHelper::isCategoryDiagram(xDiagram); + return !xDiagram->isCategory(); } } // anonymous namespace struct DataBrowserModel::tDataColumn { - uno::Reference<chart2::XDataSeries> m_xDataSeries; + rtl::Reference<DataSeries> m_xDataSeries; OUString m_aUIRoleName; uno::Reference<chart2::data::XLabeledDataSequence> m_xLabeledDataSequence; eCellType m_eCellType; @@ -220,14 +216,14 @@ struct DataBrowserModel::tDataColumn tDataColumn() : m_eCellType( TEXT ), m_nNumberFormatKey( 0 ) {} // "full" CTOR tDataColumn( - const uno::Reference<chart2::XDataSeries> & xDataSeries, - const OUString& aUIRoleName, - const uno::Reference<chart2::data::XLabeledDataSequence>& xLabeledDataSequence, + rtl::Reference<DataSeries> xDataSeries, + OUString aUIRoleName, + uno::Reference<chart2::data::XLabeledDataSequence> xLabeledDataSequence, eCellType aCellType, sal_Int32 nNumberFormatKey ) : - m_xDataSeries( xDataSeries ), - m_aUIRoleName( aUIRoleName ), - m_xLabeledDataSequence( xLabeledDataSequence ), + m_xDataSeries(std::move( xDataSeries )), + m_aUIRoleName(std::move( aUIRoleName )), + m_xLabeledDataSequence(std::move( xLabeledDataSequence )), m_eCellType( aCellType ), m_nNumberFormatKey( nNumberFormatKey ) {} @@ -247,10 +243,9 @@ struct DataBrowserModel::implColumnLess }; DataBrowserModel::DataBrowserModel( - const Reference< chart2::XChartDocument > & xChartDoc, - const Reference< uno::XComponentContext > & xContext ) : + const rtl::Reference<::chart::ChartModel> & xChartDoc ) : m_xChartDocument( xChartDoc ), - m_apDialogModel( new DialogModel( xChartDoc, xContext )) + m_apDialogModel( new DialogModel( xChartDoc )) { updateFromModel(); } @@ -263,15 +258,15 @@ namespace struct lcl_DataSeriesOfHeaderMatches { explicit lcl_DataSeriesOfHeaderMatches( - const Reference< chart2::XDataSeries > & xSeriesToCompareWith ) : - m_xSeries( xSeriesToCompareWith ) + rtl::Reference< ::chart::DataSeries > xSeriesToCompareWith ) : + m_xSeries(std::move( xSeriesToCompareWith )) {} bool operator() ( const ::chart::DataBrowserModel::tDataHeader & rHeader ) { return (m_xSeries == rHeader.m_xDataSeries); } private: - Reference< chart2::XDataSeries > m_xSeries; + rtl::Reference< ::chart::DataSeries > m_xSeries; }; } @@ -289,18 +284,18 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) nAfterColumnIndex = getCategoryColumnCount()-1; sal_Int32 nStartCol = 0; - Reference<chart2::XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartDocument); - Reference<chart2::XChartType> xChartType; - Reference<chart2::XDataSeries> xSeries; + rtl::Reference< Diagram > xDiagram = m_xChartDocument->getFirstChartDiagram(); + rtl::Reference<ChartType> xChartType; + rtl::Reference<DataSeries> xSeries; if (o3tl::make_unsigned(nAfterColumnIndex) < m_aColumns.size()) // Get the data series at specific column position (if available). - xSeries.set( m_aColumns[nAfterColumnIndex].m_xDataSeries ); + xSeries = m_aColumns[nAfterColumnIndex].m_xDataSeries; sal_Int32 nSeriesNumberFormat = 0; if( xSeries.is()) { // Use the chart type of the currently selected data series. - xChartType.set( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries )); + xChartType = xDiagram->getChartTypeOfSeries( xSeries ); // Find the corresponding header and determine the last column of this // data series. @@ -311,14 +306,13 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) nStartCol = aIt->m_nEndColumn; // Get the number format too. - Reference< beans::XPropertySet > xSeriesProps( xSeries, uno::UNO_QUERY ); - if( xSeriesProps.is() ) - xSeriesProps->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nSeriesNumberFormat; + if( xSeries.is() ) + xSeries->getPropertyValue(CHART_UNONAME_NUMFMT) >>= nSeriesNumberFormat; } else { // No data series at specified column position. Use the first chart type. - xChartType.set( DiagramHelper::getChartTypeByIndex( xDiagram, 0 )); + xChartType = xDiagram->getChartTypeByIndex( 0 ); nStartCol = nAfterColumnIndex; } @@ -327,68 +321,59 @@ void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) // Get shared sequences of current series. Normally multiple data series // only share "values-x" sequences. (TODO: simplify this logic). - Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY ); - lcl_tSharedSeqVec aSharedSequences; - if( xSeriesCnt.is()) - aSharedSequences = lcl_getSharedSequences( xSeriesCnt->getDataSeries()); + lcl_tSharedSeqVec aSharedSequences = lcl_getSharedSequences( xChartType->getDataSeries2()); - Reference<chart2::XDataSeries> xNewSeries = + rtl::Reference<::chart::DataSeries> xNewSeries = m_apDialogModel->insertSeriesAfter(xSeries, xChartType, true); if (!xNewSeries.is()) // Failed to insert new data series to the model. Bail out. return; - Reference< chart2::data::XDataSource > xSource( xNewSeries, uno::UNO_QUERY ); - if (xSource.is()) + const std::vector<uno::Reference<chart2::data::XLabeledDataSequence> > & aLSequences = xNewSeries->getDataSequences2(); + sal_Int32 nSeqIdx = 0; + sal_Int32 nSeqSize = aLSequences.size(); + for (sal_Int32 nIndex = nStartCol; nSeqIdx < nSeqSize; ++nSeqIdx) { - Sequence<Reference<chart2::data::XLabeledDataSequence> > aLSequences = xSource->getDataSequences(); - sal_Int32 nSeqIdx = 0; - sal_Int32 nSeqSize = aLSequences.getLength(); - for (sal_Int32 nIndex = nStartCol; nSeqIdx < nSeqSize; ++nSeqIdx) - { - lcl_tSharedSeqVec::const_iterator aSharedIt( - std::find_if( aSharedSequences.begin(), aSharedSequences.end(), - lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] ))); + lcl_tSharedSeqVec::const_iterator aSharedIt( + std::find_if( aSharedSequences.begin(), aSharedSequences.end(), + lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] ))); - if( aSharedIt != aSharedSequences.end()) - { - // Shared sequence. Most likely "values-x" sequence. Copy it from existing sequence. - aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues()); - aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel()); - } - else - { - // Insert a new column in the internal data for the new sequence. - xDataProvider->insertSequence( nIndex - 1 ); - - // values - Reference< chart2::data::XDataSequence > xNewSeq( - xDataProvider->createDataSequenceByRangeRepresentation( - OUString::number( nIndex ))); - lcl_copyDataSequenceProperties( - aLSequences[nSeqIdx]->getValues(), xNewSeq ); - aLSequences[nSeqIdx]->setValues( xNewSeq ); - - // labels - Reference< chart2::data::XDataSequence > xNewLabelSeq( - xDataProvider->createDataSequenceByRangeRepresentation( - "label " + - OUString::number( nIndex ))); - lcl_copyDataSequenceProperties( - aLSequences[nSeqIdx]->getLabel(), xNewLabelSeq ); - aLSequences[nSeqIdx]->setLabel( xNewLabelSeq ); - ++nIndex; - } + if( aSharedIt != aSharedSequences.end()) + { + // Shared sequence. Most likely "values-x" sequence. Copy it from existing sequence. + aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues()); + aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel()); + } + else + { + // Insert a new column in the internal data for the new sequence. + xDataProvider->insertSequence( nIndex - 1 ); + + // values + Reference< chart2::data::XDataSequence > xNewSeq( + xDataProvider->createDataSequenceByRangeRepresentation( + OUString::number( nIndex ))); + lcl_copyDataSequenceProperties( + aLSequences[nSeqIdx]->getValues(), xNewSeq ); + aLSequences[nSeqIdx]->setValues( xNewSeq ); + + // labels + Reference< chart2::data::XDataSequence > xNewLabelSeq( + xDataProvider->createDataSequenceByRangeRepresentation( + "label " + + OUString::number( nIndex ))); + lcl_copyDataSequenceProperties( + aLSequences[nSeqIdx]->getLabel(), xNewLabelSeq ); + aLSequences[nSeqIdx]->setLabel( xNewLabelSeq ); + ++nIndex; } } if( nSeriesNumberFormat != 0 ) { //give the new series the same number format as the former series especially for bubble charts thus the bubble size values can be edited with same format immediately - Reference< beans::XPropertySet > xNewSeriesProps( xNewSeries, uno::UNO_QUERY ); - if( xNewSeriesProps.is() ) - xNewSeriesProps->setPropertyValue(CHART_UNONAME_NUMFMT , uno::Any(nSeriesNumberFormat)); + xNewSeries->setPropertyValue(CHART_UNONAME_NUMFMT , uno::Any(nSeriesNumberFormat)); } updateFromModel(); @@ -447,7 +432,7 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu return; } - const Reference<chart2::XDataSeries>& xSeries = m_aColumns[nAtColumnIndex].m_xDataSeries; + const rtl::Reference<DataSeries>& xSeries = m_aColumns[nAtColumnIndex].m_xDataSeries; m_apDialogModel->deleteSeries(xSeries, getHeaderForSeries(xSeries).m_xChartType); @@ -455,16 +440,14 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu //but do not delete sequences that are still in use by the remaining series Reference< chart2::XInternalDataProvider > xDataProvider( m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); - Reference< chart2::data::XDataSource > xSourceOfDeleted( xSeries, uno::UNO_QUERY ); - if (!xDataProvider.is() || !xSourceOfDeleted.is()) + if (!xDataProvider.is() || !xSeries.is()) { // Something went wrong. Bail out. updateFromModel(); return; } - Reference<chart2::XDataSeriesContainer> xSeriesCnt( - getHeaderForSeries(xSeries).m_xChartType, uno::UNO_QUERY); + rtl::Reference<ChartType> xSeriesCnt(getHeaderForSeries(xSeries).m_xChartType); if (!xSeriesCnt.is()) { // Unexpected happened. Bail out. @@ -474,13 +457,13 @@ void DataBrowserModel::removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColu // Collect all the remaining data sequences in the same chart type. The // deleted data series is already gone by this point. - std::vector<Reference<chart2::data::XLabeledDataSequence> > aAllDataSeqs = - DataSeriesHelper::getAllDataSequences(xSeriesCnt->getDataSeries()); + std::vector<uno::Reference<chart2::data::XLabeledDataSequence> > aAllDataSeqs = + DataSeriesHelper::getAllDataSequences(xSeriesCnt->getDataSeries2()); // Check if the sequences to be deleted are still referenced by any of // the other data series. If not, mark them for deletion. std::vector<sal_Int32> aSequenceIndexesToDelete; - const Sequence<Reference<chart2::data::XLabeledDataSequence> > aSequencesOfDeleted = xSourceOfDeleted->getDataSequences(); + const std::vector<uno::Reference<chart2::data::XLabeledDataSequence> > & aSequencesOfDeleted = xSeries->getDataSequences2(); for (auto const & labeledDataSeq : aSequencesOfDeleted) { // if not used by the remaining series this sequence can be deleted @@ -508,7 +491,7 @@ void DataBrowserModel::swapDataSeries( sal_Int32 nFirstColumnIndex ) OSL_ASSERT(m_apDialogModel); if( o3tl::make_unsigned( nFirstColumnIndex ) < m_aColumns.size() - 1 ) { - Reference< chart2::XDataSeries > xSeries( m_aColumns[nFirstColumnIndex].m_xDataSeries ); + rtl::Reference< DataSeries > xSeries( m_aColumns[nFirstColumnIndex].m_xDataSeries ); if( xSeries.is()) { m_apDialogModel->moveSeries( xSeries, DialogModel::MoveDirection::Down ); @@ -554,15 +537,17 @@ void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( const Reference< chart2::XDataSeries > & xSeries ) const { + rtl::Reference<DataSeries> pSeries = dynamic_cast<DataSeries*>(xSeries.get()); + assert(!xSeries || pSeries); for (auto const& elemHeader : m_aHeaders) { - if( elemHeader.m_xDataSeries == xSeries ) + if( elemHeader.m_xDataSeries == pSeries ) return elemHeader; } return tDataHeader(); } -Reference< chart2::XDataSeries > +rtl::Reference< DataSeries > DataBrowserModel::getDataSeriesByColumn( sal_Int32 nColumn ) const { tDataColumnVector::size_type nIndex( nColumn ); @@ -582,9 +567,6 @@ DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn ) double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { - double fResult; - ::rtl::math::setNan( & fResult ); - tDataColumnVector::size_type nIndex( nAtColumn ); if( nIndex < m_aColumns.size() && m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) @@ -595,10 +577,10 @@ double DataBrowserModel::getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ) { Sequence< double > aValues( xData->getNumericalData()); if( nAtRow < aValues.getLength()) - fResult = aValues[nAtRow]; + return aValues[nAtRow]; } } - return fResult; + return std::numeric_limits<double>::quiet_NaN(); } uno::Any DataBrowserModel::getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ) @@ -677,9 +659,8 @@ bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const m_apDialogModel->startControllerLockTimer(); //notify change directly to the model (this is necessary here as sequences for complex categories not known directly to the chart model so they do not notify their changes) (for complex categories see issue #i82971#) - Reference< util::XModifiable > xModifiable( m_xChartDocument, uno::UNO_QUERY ); - if( xModifiable.is() ) - xModifiable->setModified(true); + if( m_xChartDocument.is() ) + m_xChartDocument->setModified(true); } catch( const uno::Exception & ) { @@ -726,12 +707,12 @@ sal_Int32 DataBrowserModel::getMaxRowCount() const return nResult; } -OUString DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const +const OUString & DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const { if( nColumnIndex != -1 && o3tl::make_unsigned( nColumnIndex ) < m_aColumns.size()) return m_aColumns[ nColumnIndex ].m_aUIRoleName; - return OUString(); + return EMPTY_OUSTRING; } bool DataBrowserModel::isCategoriesColumn( sal_Int32 nColumnIndex ) const @@ -766,36 +747,32 @@ void DataBrowserModel::updateFromModel() m_aColumns.clear(); m_aHeaders.clear(); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram()); if( !xDiagram.is()) return; // set template at DialogModel - uno::Reference< lang::XMultiServiceFactory > xFact( m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ); - DiagramHelper::tTemplateWithServiceName aTemplateAndService = - DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); - if( aTemplateAndService.first.is()) - m_apDialogModel->setTemplate( aTemplateAndService.first ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = m_xChartDocument->getTypeManager(); + Diagram::tTemplateWithServiceName aTemplateAndService = + xDiagram->getTemplate( xChartTypeManager ); + if( aTemplateAndService.xChartTypeTemplate.is()) + m_apDialogModel->setTemplate( aTemplateAndService.xChartTypeTemplate ); sal_Int32 nHeaderStart = 0; sal_Int32 nHeaderEnd = 0; { - Reference< frame::XModel > xChartModel = m_xChartDocument; - ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get()); - if (!pModel) - return; - ExplicitCategoriesProvider aExplicitCategoriesProvider( ChartModelHelper::getFirstCoordinateSystem(xChartModel), *pModel ); - - const Sequence< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList( aExplicitCategoriesProvider.getSplitCategoriesList() ); - sal_Int32 nLevelCount = rSplitCategoriesList.getLength(); + ExplicitCategoriesProvider aExplicitCategoriesProvider( m_xChartDocument->getFirstCoordinateSystem(), *m_xChartDocument ); + + const std::vector< Reference< chart2::data::XLabeledDataSequence> >& rSplitCategoriesList = aExplicitCategoriesProvider.getSplitCategoriesList(); + sal_Int32 nLevelCount = rSplitCategoriesList.size(); for( sal_Int32 nL = 0; nL<nLevelCount; nL++ ) { - Reference< chart2::data::XLabeledDataSequence > xCategories( rSplitCategoriesList[nL] ); + const Reference< chart2::data::XLabeledDataSequence >& xCategories( rSplitCategoriesList[nL] ); if( !xCategories.is() ) continue; tDataColumn aCategories; - aCategories.m_xLabeledDataSequence.set( xCategories ); + aCategories.m_xLabeledDataSequence = xCategories; if( lcl_ShowCategoriesAsDataLabel( xDiagram )) aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); else @@ -806,109 +783,101 @@ void DataBrowserModel::updateFromModel() } } - Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); - if( !xCooSysCnt.is()) + if( !xDiagram.is()) return; - const Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); - for( Reference< chart2::XCoordinateSystem > const & coords : aCooSysSeq ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( xDiagram->getBaseCoordinateSystems()); + for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< chart2::XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - const Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + const std::vector< rtl::Reference< ChartType > > aChartTypes( coords->getChartTypes2()); sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( nullptr, coords, 0, 0 ); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + for( auto const & CT: aChartTypes ) { - Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); - if( xSeriesCnt.is()) - { - OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( aChartTypes[nCTIdx] ); + const rtl::Reference< ChartType >& xSeriesCnt( CT ); + OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( CT ); - const Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); - lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); - for (auto const& sharedSequence : aSharedSequences) - { - tDataColumn aSharedSequence; - aSharedSequence.m_xLabeledDataSequence = sharedSequence; - aSharedSequence.m_aUIRoleName = lcl_getUIRoleName(sharedSequence); - aSharedSequence.m_eCellType = NUMBER; - // as the sequences are shared it should be ok to take the first series - // @todo: dimension index 0 for x-values used here. This is just a guess. - // Also, the axis index is 0, as there is usually only one x-axis - aSharedSequence.m_nNumberFormatKey = nXAxisNumberFormat; - m_aColumns.push_back( aSharedSequence ); - ++nHeaderStart; - } - for( Reference< chart2::XDataSeries > const & dataSeries : aSeries ) + const std::vector< rtl::Reference< DataSeries > > & aSeries( xSeriesCnt->getDataSeries2()); + lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); + for (auto const& sharedSequence : aSharedSequences) + { + tDataColumn aSharedSequence; + aSharedSequence.m_xLabeledDataSequence = sharedSequence; + aSharedSequence.m_aUIRoleName = lcl_getUIRoleName(sharedSequence); + aSharedSequence.m_eCellType = NUMBER; + // as the sequences are shared it should be ok to take the first series + // @todo: dimension index 0 for x-values used here. This is just a guess. + // Also, the axis index is 0, as there is usually only one x-axis + aSharedSequence.m_nNumberFormatKey = nXAxisNumberFormat; + m_aColumns.push_back( aSharedSequence ); + ++nHeaderStart; + } + for( rtl::Reference< DataSeries > const & dataSeries : aSeries ) + { + tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); + const rtl::Reference< DataSeries >& xSeries( dataSeries ); + if( xSeries.is()) { - tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); - Reference< chart2::XDataSeries > xSeries( dataSeries ); - Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); - if( xSource.is()) + const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aLSeqs( xSeries->getDataSequences2()); + if( aLSeqs.empty() ) + continue; + nHeaderEnd = nHeaderStart; + + // @todo: dimension index 1 for y-values used here. This is just a guess + sal_Int32 nYAxisNumberFormatKey = + DataSeriesHelper::getNumberFormatKeyFromAxis( + dataSeries, coords, 1 ); + + sal_Int32 nSeqIdx=0; + for( ; nSeqIdx<static_cast<sal_Int32>(aLSeqs.size()); ++nSeqIdx ) { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqs( xSource->getDataSequences()); - if( !aLSeqs.hasElements() ) - continue; - nHeaderEnd = nHeaderStart; - - // @todo: dimension index 1 for y-values used here. This is just a guess - sal_Int32 nYAxisNumberFormatKey = - DataSeriesHelper::getNumberFormatKeyFromAxis( - dataSeries, coords, 1 ); - - sal_Int32 nSeqIdx=0; - for( ; nSeqIdx<aLSeqs.getLength(); ++nSeqIdx ) + sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey; + OUString aRole = DataSeriesHelper::getRole(aLSeqs[nSeqIdx]); + + if( aRole == aRoleForDataLabelNumberFormat ) { - sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey; - OUString aRole = DataSeriesHelper::getRole(aLSeqs[nSeqIdx]); - - if( aRole == aRoleForDataLabelNumberFormat ) - { - nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( - Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); - } - else if( aRole == "values-x" ) - nSequenceNumberFormatKey = nXAxisNumberFormat; - - if( std::none_of( aSharedSequences.begin(), aSharedSequences.end(), - lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) ) - { - // no shared sequence - m_aColumns.emplace_back( - dataSeries, - lcl_getUIRoleName( aLSeqs[nSeqIdx] ), - aLSeqs[nSeqIdx], - NUMBER, - nSequenceNumberFormatKey ); - ++nHeaderEnd; - } - // else skip + nSequenceNumberFormatKey = xSeries->getExplicitNumberFormatKeyForDataLabel(); } - bool bSwapXAndYAxis = false; - try + else if( aRole == "values-x" ) + nSequenceNumberFormatKey = nXAxisNumberFormat; + + if( std::none_of( aSharedSequences.begin(), aSharedSequences.end(), + lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) ) { - Reference< beans::XPropertySet > xProp( coords, uno::UNO_QUERY ); - xProp->getPropertyValue( "SwapXAndYAxis" ) >>= bSwapXAndYAxis; + // no shared sequence + m_aColumns.emplace_back( + dataSeries, + lcl_getUIRoleName( aLSeqs[nSeqIdx] ), + aLSeqs[nSeqIdx], + NUMBER, + nSequenceNumberFormatKey ); + ++nHeaderEnd; } - catch( const beans::UnknownPropertyException & ) {} + // else skip + } + bool bSwapXAndYAxis = false; + try + { + coords->getPropertyValue( u"SwapXAndYAxis"_ustr ) >>= bSwapXAndYAxis; + } + catch( const beans::UnknownPropertyException & ) {} - // add ranges for error bars if present for a series - if( StatisticsHelper::usesErrorBarRanges( dataSeries )) - addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); + // add ranges for error bars if present for a series + if( StatisticsHelper::usesErrorBarRanges( dataSeries )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, true ); - if( StatisticsHelper::usesErrorBarRanges( dataSeries, /* bYError = */ false )) - addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); + if( StatisticsHelper::usesErrorBarRanges( dataSeries, /* bYError = */ false )) + addErrorBarRanges( dataSeries, nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd, false ); - m_aHeaders.emplace_back( - dataSeries, - aChartTypes[nCTIdx], - bSwapXAndYAxis, - nHeaderStart, - nHeaderEnd - 1 ); + m_aHeaders.emplace_back( + dataSeries, + CT, + bSwapXAndYAxis, + nHeaderStart, + nHeaderEnd - 1 ); - nHeaderStart = nHeaderEnd; + nHeaderStart = nHeaderEnd; - std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() ); - } + std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() ); } } } @@ -916,35 +885,35 @@ void DataBrowserModel::updateFromModel() } void DataBrowserModel::addErrorBarRanges( - const Reference< chart2::XDataSeries > & xDataSeries, + const rtl::Reference< DataSeries > & xDataSeries, sal_Int32 nNumberFormatKey, sal_Int32 & rInOutSequenceIndex, sal_Int32 & rInOutHeaderEnd, bool bYError ) { try { - std::vector< Reference< chart2::data::XLabeledDataSequence > > aSequences; + std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aSequences; Reference< chart2::data::XDataSource > xErrorSource( StatisticsHelper::getErrorBars( xDataSeries, bYError ), uno::UNO_QUERY ); - Reference< chart2::data::XLabeledDataSequence > xErrorLSequence( + uno::Reference< chart2::data::XLabeledDataSequence > xErrorLSequence = StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( xErrorSource, /* bPositiveValue = */ true, - bYError )); + bYError ); if( xErrorLSequence.is()) aSequences.push_back( xErrorLSequence ); - xErrorLSequence.set( + xErrorLSequence = StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( xErrorSource, /* bPositiveValue = */ false, - bYError )); + bYError ); if( xErrorLSequence.is()) aSequences.push_back( xErrorLSequence ); - for (Reference<chart2::data::XLabeledDataSequence> const & rDataSequence : aSequences) + for (uno::Reference<chart2::data::XLabeledDataSequence> const & rDataSequence : aSequences) { m_aColumns.emplace_back(xDataSeries, lcl_getUIRoleName(rDataSequence), rDataSequence, NUMBER, nNumberFormatKey); diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx deleted file mode 100644 index b538e01de271..000000000000 --- a/chart2/source/controller/dialogs/DataBrowserModel.hxx +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <com/sun/star/uno/Reference.hxx> - -#include <memory> -#include <vector> - -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::uno { class XComponentContext; } - -namespace com::sun::star::chart2 { - class XDataSeries; - class XChartType; -} - -namespace chart -{ - -class DialogModel; - -class DataBrowserModel final -{ -public: - explicit DataBrowserModel( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDoc, - const css::uno::Reference< css::uno::XComponentContext > & xContext ); - ~DataBrowserModel(); - - /** Inserts a new data series after the data series to which the data column - with index nAfterColumnIndex belongs. - */ - void insertDataSeries( sal_Int32 nAfterColumnIndex ); - - /** Inserts a new text column for complex categories. - */ - void insertComplexCategoryLevel( sal_Int32 nAfterColumnIndex ); - - /** Removes a data series to which the data column with index nAtColumnIndex - belongs. - */ - void removeDataSeriesOrComplexCategoryLevel( sal_Int32 nAtColumnIndex ); - - /** Swaps the series to which the data column with index nFirstIndex belongs - with the next series (which starts at an index >= nFirstIndex + 1) - */ - void swapDataSeries( sal_Int32 nFirstIndex ); - void swapDataPointForAllSeries( sal_Int32 nFirstIndex ); - - void insertDataPointForAllSeries( sal_Int32 nAfterIndex ); - void removeDataPointForAllSeries( sal_Int32 nAtIndex ); - - enum eCellType - { - NUMBER, - TEXT, - TEXTORDATE - }; - - eCellType getCellType( sal_Int32 nAtColumn ) const; - /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan - double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - css::uno::Any getCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow ); - sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn ); - - /// returns </sal_True> if the number could successfully be set at the given position - bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); - /// returns </sal_True> if the text could successfully be set at the given position - bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const OUString & rText ); - bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const css::uno::Any & aValue ); - - sal_Int32 getColumnCount() const; - sal_Int32 getMaxRowCount() const; - - // returns the UI string of the corresponding role - OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; - bool isCategoriesColumn( sal_Int32 nColumnIndex ) const; - - struct tDataHeader - { - css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; - css::uno::Reference< css::chart2::XChartType > m_xChartType; - bool m_bSwapXAndYAxis; - sal_Int32 m_nStartColumn; - sal_Int32 m_nEndColumn; - - // default CTOR - tDataHeader() : - m_bSwapXAndYAxis( false ), - m_nStartColumn( -1 ), - m_nEndColumn( -1 ) - {} - // "full" CTOR - tDataHeader( - css::uno::Reference< css::chart2::XDataSeries > const & xDataSeries, - css::uno::Reference< css::chart2::XChartType > const &xChartType, - bool bSwapXAndYAxis, - sal_Int32 nStartColumn, - sal_Int32 nEndColumn ) : - m_xDataSeries( xDataSeries ), - m_xChartType( xChartType ), - m_bSwapXAndYAxis( bSwapXAndYAxis ), - m_nStartColumn( nStartColumn ), - m_nEndColumn( nEndColumn ) - {} - }; - - typedef std::vector< tDataHeader > tDataHeaderVector; - - const tDataHeaderVector& getDataHeaders() const { return m_aHeaders;} - - tDataHeader getHeaderForSeries( - const css::uno::Reference< css::chart2::XDataSeries > &xSeries ) const; - - css::uno::Reference< css::chart2::XDataSeries > - getDataSeriesByColumn( sal_Int32 nColumn ) const; - -private: - void updateFromModel(); - - void removeComplexCategoryLevel( sal_Int32 nAtColumnIndex ); - - void addErrorBarRanges( - const css::uno::Reference<css::chart2::XDataSeries > & xDataSeries, - sal_Int32 nNumberFormatKey, - sal_Int32 & rInOutSequenceIndex, - sal_Int32 & rInOutHeaderEnd, bool bYError ); - - sal_Int32 getCategoryColumnCount(); - - css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; - std::unique_ptr< DialogModel > m_apDialogModel; - - struct tDataColumn; - struct implColumnLess; - - typedef std::vector< tDataColumn > tDataColumnVector; - - tDataColumnVector m_aColumns; - tDataHeaderVector m_aHeaders; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx index b88d1f205d5d..1ea7ddfe56d1 100644 --- a/chart2/source/controller/dialogs/DialogModel.cxx +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -19,30 +19,31 @@ #include "DialogModel.hxx" #include <RangeSelectionHelper.hxx> +#include <DataInterpreter.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <DataSourceHelper.hxx> -#include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <strings.hrc> #include <ResId.hxx> #include <ControllerLockGuard.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> +#include <ChartTypeTemplate.hxx> #include <ThreeDHelper.hxx> #include <ChartModel.hxx> +#include <BaseCoordinateSystem.hxx> +#include <LabeledDataSequence.hxx> -#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/chart2/AxisType.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> #include <com/sun/star/chart2/XDataSeriesContainer.hpp> -#include <com/sun/star/chart2/data/XDataSink.hpp> -#include <comphelper/sequence.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <rtl/ustring.hxx> #include <utility> #include <algorithm> +#include <cstddef> #include <iterator> #include <numeric> @@ -54,16 +55,8 @@ using ::com::sun::star::uno::Sequence; namespace { -constexpr OUStringLiteral lcl_aLabelRole( u"label" ); +constexpr OUString lcl_aLabelRole( u"label"_ustr ); -struct lcl_ChartTypeToSeriesCnt -{ - Reference< XDataSeriesContainer > operator() ( - const Reference< XChartType > & xChartType ) - { - return Reference< XDataSeriesContainer >::query( xChartType ); - } -}; OUString lcl_ConvertRole( const OUString & rRoleString ) { @@ -106,72 +99,25 @@ lcl_tRoleIndexMap lcl_createRoleIndexMap() lcl_tRoleIndexMap aMap; sal_Int32 nIndex = 0; - aMap[ "label" ] = ++nIndex; - aMap[ "categories" ] = ++nIndex; - aMap[ "values-x" ] = ++nIndex; - aMap[ "values-y" ] = ++nIndex; - aMap[ "error-bars-x" ] = ++nIndex; - aMap[ "error-bars-x-positive" ] = ++nIndex; - aMap[ "error-bars-x-negative" ] = ++nIndex; - aMap[ "error-bars-y" ] = ++nIndex; - aMap[ "error-bars-y-positive" ] = ++nIndex; - aMap[ "error-bars-y-negative" ] = ++nIndex; - aMap[ "values-first" ] = ++nIndex; - aMap[ "values-min" ] = ++nIndex; - aMap[ "values-max" ] = ++nIndex; - aMap[ "values-last" ] = ++nIndex; - aMap[ "values-size" ] = ++nIndex; + aMap[ u"label"_ustr ] = ++nIndex; + aMap[ u"categories"_ustr ] = ++nIndex; + aMap[ u"values-x"_ustr ] = ++nIndex; + aMap[ u"values-y"_ustr ] = ++nIndex; + aMap[ u"error-bars-x"_ustr ] = ++nIndex; + aMap[ u"error-bars-x-positive"_ustr ] = ++nIndex; + aMap[ u"error-bars-x-negative"_ustr ] = ++nIndex; + aMap[ u"error-bars-y"_ustr ] = ++nIndex; + aMap[ u"error-bars-y-positive"_ustr ] = ++nIndex; + aMap[ u"error-bars-y-negative"_ustr ] = ++nIndex; + aMap[ u"values-first"_ustr ] = ++nIndex; + aMap[ u"values-min"_ustr ] = ++nIndex; + aMap[ u"values-max"_ustr ] = ++nIndex; + aMap[ u"values-last"_ustr ] = ++nIndex; + aMap[ u"values-size"_ustr ] = ++nIndex; return aMap; } -struct lcl_DataSeriesContainerAppend -{ - typedef Reference< XDataSeriesContainer > value_type; - typedef std::vector< ::chart::DialogModel::tSeriesWithChartTypeByName > tContainerType; - - explicit lcl_DataSeriesContainerAppend( tContainerType * rCnt ) - : m_rDestCnt( rCnt ) - {} - - lcl_DataSeriesContainerAppend & operator= ( const value_type & xVal ) - { - try - { - if( xVal.is()) - { - const Sequence< Reference< XDataSeries > > aSeq( xVal->getDataSeries()); - OUString aRole( "values-y" ); - Reference< XChartType > xCT( xVal, uno::UNO_QUERY ); - if( xCT.is()) - aRole = xCT->getRoleOfSequenceForSeriesLabel(); - for( Reference< XDataSeries > const & dataSeries : aSeq ) - { - m_rDestCnt->push_back( - ::chart::DialogModel::tSeriesWithChartTypeByName( - ::chart::DataSeriesHelper::getDataSeriesLabel( dataSeries, aRole ), - std::make_pair( dataSeries, xCT ))); - } - } - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - return *this; - } - - // Implement output operator requirements as required by std::copy (and - // implement prefix increment in terms of postfix increment to avoid unused - // member function warnings for the latter in the common case where - // std::copy would not actually need it): - lcl_DataSeriesContainerAppend & operator* () { return *this; } - lcl_DataSeriesContainerAppend & operator++ () { return operator++(0); } - lcl_DataSeriesContainerAppend & operator++ (int) { return *this; } - -private: - tContainerType * m_rDestCnt; -}; struct lcl_RolesWithRangeAppend { @@ -179,9 +125,9 @@ struct lcl_RolesWithRangeAppend typedef ::chart::DialogModel::tRolesWithRanges tContainerType; explicit lcl_RolesWithRangeAppend( tContainerType * rCnt, - const OUString & aLabelRole ) + OUString aLabelRole ) : m_rDestCnt( rCnt ), - m_aRoleForLabelSeq( aLabelRole ) + m_aRoleForLabelSeq(std::move( aLabelRole )) {} lcl_RolesWithRangeAppend & operator= ( const value_type & xVal ) @@ -196,7 +142,7 @@ struct lcl_RolesWithRangeAppend { OUString aRole; Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW ); - if( xProp->getPropertyValue( "Role" ) >>= aRole ) + if( xProp->getPropertyValue( u"Role"_ustr ) >>= aRole ) { m_rDestCnt->emplace(aRole, xSeq->getSourceRangeRepresentation()); // label @@ -237,16 +183,11 @@ private: namespace std { - template<> struct iterator_traits<lcl_DataSeriesContainerAppend> - { - typedef std::output_iterator_tag iterator_category; - typedef Reference< XDataSeriesContainer > value_type; - }; - template<> struct iterator_traits<lcl_RolesWithRangeAppend> { typedef std::output_iterator_tag iterator_category; typedef Reference< data::XLabeledDataSequence > value_type; + typedef value_type& reference; }; } @@ -258,75 +199,68 @@ void lcl_SetSequenceRole( { Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY ); if( xProp.is()) - xProp->setPropertyValue( "Role" , uno::Any( rRole )); + xProp->setPropertyValue( u"Role"_ustr , uno::Any( rRole )); } Sequence< OUString > lcl_CopyExcludingValuesFirst( Sequence< OUString > const & i_aInput ) { Sequence< OUString > aOutput( i_aInput.getLength()); + auto pOutput = aOutput.getArray(); int nSourceIndex, nDestIndex; for( nSourceIndex = nDestIndex = 0; nSourceIndex < i_aInput.getLength(); nSourceIndex++ ) { if( i_aInput[nSourceIndex] == "values-first" ) { aOutput.realloc( aOutput.getLength() - 1 ); + pOutput = aOutput.getArray(); } else { - aOutput[nDestIndex] = i_aInput[nSourceIndex]; + pOutput[nDestIndex] = i_aInput[nSourceIndex]; nDestIndex++; } } return aOutput; } -Reference< XDataSeries > lcl_CreateNewSeries( - const Reference< uno::XComponentContext > & xContext, - const Reference< XChartType > & xChartType, +rtl::Reference< ::chart::DataSeries > lcl_CreateNewSeries( + const rtl::Reference< ::chart::ChartType > & xChartType, sal_Int32 nNewSeriesIndex, sal_Int32 nTotalNumberOfSeriesInCTGroup, - const Reference< XDiagram > & xDiagram, - const Reference< XChartTypeTemplate > & xTemplate, + const rtl::Reference< ::chart::Diagram > & xDiagram, + const rtl::Reference< ::chart::ChartTypeTemplate > & xTemplate, bool bCreateDataCachedSequences ) { // create plain series - Reference< XDataSeries > xResult( - xContext->getServiceManager()->createInstanceWithContext( - "com.sun.star.chart2.DataSeries" , - xContext ), uno::UNO_QUERY ); + rtl::Reference< ::chart::DataSeries > xResult = new ::chart::DataSeries(); if( xTemplate.is()) { - Reference< beans::XPropertySet > xResultProp( xResult, uno::UNO_QUERY ); - if( xResultProp.is()) - { - // @deprecated: correct default color should be found by view - // without setting it as hard attribute - Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme()); - if( xColorScheme.is()) - xResultProp->setPropertyValue( "Color" , uno::Any( xColorScheme->getColorByIndex( nNewSeriesIndex ))); - } - sal_Int32 nGroupIndex=0; + // @deprecated: correct default color should be found by view + // without setting it as hard attribute + Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme()); + if( xColorScheme.is()) + xResult->setPropertyValue( u"Color"_ustr , uno::Any( xColorScheme->getColorByIndex( nNewSeriesIndex ))); + std::size_t nGroupIndex=0; if( xChartType.is()) { - Sequence< Reference< XChartType > > aCTs( - ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram )); - for( ; nGroupIndex<aCTs.getLength(); ++nGroupIndex) + std::vector< rtl::Reference< ::chart::ChartType > > aCTs = + xDiagram->getChartTypes(); + for( ; nGroupIndex < aCTs.size(); ++nGroupIndex) if( aCTs[nGroupIndex] == xChartType ) break; - if( nGroupIndex == aCTs.getLength()) + if( nGroupIndex == aCTs.size()) nGroupIndex = 0; } - xTemplate->applyStyle( xResult, nGroupIndex, nNewSeriesIndex, nTotalNumberOfSeriesInCTGroup ); + xTemplate->applyStyle2( xResult, nGroupIndex, nNewSeriesIndex, nTotalNumberOfSeriesInCTGroup ); } if( bCreateDataCachedSequences ) { // set chart type specific roles - Reference< data::XDataSink > xSink( xResult, uno::UNO_QUERY ); - if( xChartType.is() && xSink.is()) + if( xChartType.is() ) { - std::vector< Reference< data::XLabeledDataSequence > > aNewSequences; + std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aNewSequences; const OUString aRoleOfSeqForSeriesLabel = xChartType->getRoleOfSequenceForSeriesLabel(); const OUString aLabel(::chart::SchResId(STR_DATA_UNNAMED_SERIES)); Sequence< OUString > aPossibleRoles( xChartType->getSupportedMandatoryRoles()); @@ -335,11 +269,11 @@ Reference< XDataSeries > lcl_CreateNewSeries( //special handling for candlestick type if( xTemplate.is()) { - Reference< XDataInterpreter > xInterpreter( xTemplate->getDataInterpreter()); + rtl::Reference< ::chart::DataInterpreter > xInterpreter( xTemplate->getDataInterpreter2()); if( xInterpreter.is()) { sal_Int32 nStockVariant; - if( xInterpreter->getChartTypeSpecificData("stock variant") >>= nStockVariant ) + if( xInterpreter->getChartTypeSpecificData(u"stock variant"_ustr) >>= nStockVariant ) { if( nStockVariant == 0 || nStockVariant == 2) { //delete "values-first" role @@ -379,7 +313,7 @@ Reference< XDataSeries > lcl_CreateNewSeries( aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq )); } - xSink->setData( comphelper::containerToSequence( aNewSequences )); + xResult->setData( aNewSequences ); } } @@ -409,10 +343,8 @@ DialogModelTimeBasedInfo::DialogModelTimeBasedInfo(): } DialogModel::DialogModel( - const Reference< XChartDocument > & xChartDocument, - const Reference< uno::XComponentContext > & xContext ) : - m_xChartDocument( xChartDocument ), - m_xContext( xContext ), + rtl::Reference<::chart::ChartModel> xChartDocument ) : + m_xChartDocument(std::move( xChartDocument )), m_aTimerTriggeredControllerLock( m_xChartDocument ) { } @@ -426,7 +358,7 @@ DialogModel::~DialogModel() } void DialogModel::setTemplate( - const Reference< XChartTypeTemplate > & xTemplate ) + const rtl::Reference< ChartTypeTemplate > & xTemplate ) { m_xTemplate = xTemplate; } @@ -441,7 +373,7 @@ std::shared_ptr< RangeSelectionHelper > const & return m_spRangeSelectionHelper; } -Reference< frame::XModel > DialogModel::getChartModel() const +const rtl::Reference<::chart::ChartModel> & DialogModel::getChartModel() const { return m_xChartDocument; } @@ -454,30 +386,26 @@ Reference< data::XDataProvider > DialogModel::getDataProvider() const return xResult; } -std::vector< Reference< XDataSeriesContainer > > +std::vector< rtl::Reference< ChartType > > DialogModel::getAllDataSeriesContainers() const { - std::vector< Reference< XDataSeriesContainer > > aResult; + std::vector< rtl::Reference< ChartType > > aResult; try { - Reference< XDiagram > xDiagram; - if( m_xChartDocument.is()) - xDiagram.set( m_xChartDocument->getFirstDiagram()); + if( !m_xChartDocument ) + return {}; + rtl::Reference< Diagram > xDiagram = m_xChartDocument->getFirstChartDiagram(); if( xDiagram.is()) { - Reference< XCoordinateSystemContainer > xCooSysCnt( - xDiagram, uno::UNO_QUERY_THROW ); - const Sequence< Reference< XCoordinateSystem > > aCooSysSeq( - xCooSysCnt->getCoordinateSystems()); - for( Reference< XCoordinateSystem > const & coords : aCooSysSeq ) + const std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( + xDiagram->getBaseCoordinateSystems()); + for( rtl::Reference< BaseCoordinateSystem > const & coords : aCooSysSeq ) { - Reference< XChartTypeContainer > xCTCnt( coords, uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - std::transform( - aChartTypeSeq.begin(), aChartTypeSeq.end(), - std::back_inserter( aResult ), - lcl_ChartTypeToSeriesCnt() ); + aResult.insert(aResult.end(), + coords->getChartTypes2().begin(), + coords->getChartTypes2().end()); + } } } @@ -493,11 +421,29 @@ std::vector< DialogModel::tSeriesWithChartTypeByName > DialogModel::getAllDataSeriesWithLabel() const { std::vector< tSeriesWithChartTypeByName > aResult; - std::vector< Reference< XDataSeriesContainer > > aContainers( + std::vector< rtl::Reference< ChartType > > aContainers( getAllDataSeriesContainers()); - std::copy( aContainers.begin(), aContainers.end(), - lcl_DataSeriesContainerAppend( &aResult )); + for (const auto & rxChartType : aContainers ) + { + try + { + const std::vector< rtl::Reference< DataSeries > > & aSeq = rxChartType->getDataSeries2(); + OUString aRole = rxChartType->getRoleOfSequenceForSeriesLabel(); + for( rtl::Reference< DataSeries > const & dataSeries : aSeq ) + { + aResult.push_back( + ::chart::DialogModel::tSeriesWithChartTypeByName( + dataSeries->getLabelForRole( aRole ), + std::make_pair( dataSeries, rxChartType ))); + } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + } + return aResult; } @@ -522,15 +468,13 @@ void addMissingRoles(DialogModel::tRolesWithRanges& rResult, const uno::Sequence * @param xNewSeries new data series to insert. */ void addNewSeriesToContainer( - const Reference<XChartType>& xChartType, - const Reference<XDataSeries>& xSeries, - const Reference<XDataSeries>& xNewSeries ) + const rtl::Reference<ChartType>& xChartType, + const rtl::Reference<DataSeries>& xSeries, + const rtl::Reference<DataSeries>& xNewSeries ) { - Reference<XDataSeriesContainer> xSeriesCnt(xChartType, uno::UNO_QUERY_THROW); - auto aSeries = comphelper::sequenceToContainer<std::vector<Reference<XDataSeries> >>(xSeriesCnt->getDataSeries()); + auto aSeries = xChartType->getDataSeries2(); - std::vector<Reference<XDataSeries> >::iterator aIt = - std::find( aSeries.begin(), aSeries.end(), xSeries); + auto aIt = std::find( aSeries.begin(), aSeries.end(), xSeries); if( aIt == aSeries.end()) // if we have no series we insert at the first position. @@ -540,7 +484,7 @@ void addNewSeriesToContainer( ++aIt; aSeries.insert(aIt, xNewSeries); - xSeriesCnt->setDataSeries(comphelper::containerToSequence(aSeries)); + xChartType->setDataSeries(aSeries); } } @@ -548,7 +492,7 @@ void addNewSeriesToContainer( DialogModel::tRolesWithRanges DialogModel::getRolesWithRanges( const Reference< XDataSeries > & xSeries, const OUString & aRoleOfSequenceForLabel, - const Reference< chart2::XChartType > & xChartType ) + const rtl::Reference< ::chart::ChartType > & xChartType ) { DialogModel::tRolesWithRanges aResult; try @@ -580,54 +524,54 @@ DialogModel::tRolesWithRanges DialogModel::getRolesWithRanges( } void DialogModel::moveSeries( - const Reference< XDataSeries > & xSeries, + const rtl::Reference< DataSeries > & xSeries, MoveDirection eDirection ) { m_aTimerTriggeredControllerLock.startTimer(); ControllerLockGuardUNO aLockedControllers( m_xChartDocument ); - Reference< XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); - DiagramHelper::moveSeries( xDiagram, xSeries, eDirection==MoveDirection::Down ); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram()); + xDiagram->moveSeries( xSeries, eDirection==MoveDirection::Down ); } -Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( - const Reference< XDataSeries > & xSeries, - const Reference< XChartType > & xChartType, +rtl::Reference< ::chart::DataSeries > DialogModel::insertSeriesAfter( + const Reference< XDataSeries > & xUnoSeries, + const rtl::Reference< ::chart::ChartType > & xChartType, bool bCreateDataCachedSequences /* = false */ ) { m_aTimerTriggeredControllerLock.startTimer(); ControllerLockGuardUNO aLockedControllers( m_xChartDocument ); - Reference< XDataSeries > xNewSeries; + rtl::Reference< ::chart::DataSeries > xNewSeries; + rtl::Reference<DataSeries> xSeries = dynamic_cast<DataSeries*>(xUnoSeries.get()); + assert(xSeries || !xUnoSeries); try { - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); - ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram() ); + ThreeDLookScheme e3DScheme = xDiagram->detectScheme(); sal_Int32 nSeriesInChartType = 0; const sal_Int32 nTotalSeries = countSeries(); if( xChartType.is()) { - Reference< XDataSeriesContainer > xCnt( xChartType, uno::UNO_QUERY_THROW ); - nSeriesInChartType = xCnt->getDataSeries().getLength(); + nSeriesInChartType = xChartType->getDataSeries().getLength(); } // create new series - xNewSeries.set( + xNewSeries = lcl_CreateNewSeries( - m_xContext, xChartType, nTotalSeries, // new series' index nSeriesInChartType, xDiagram, m_xTemplate, - bCreateDataCachedSequences )); + bCreateDataCachedSequences ); // add new series to container if( xNewSeries.is()) addNewSeriesToContainer(xChartType, xSeries, xNewSeries); - ThreeDHelper::setScheme( xDiagram, e3DScheme ); + xDiagram->setScheme( e3DScheme ); } catch( const uno::Exception & ) { @@ -637,24 +581,25 @@ Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( } void DialogModel::deleteSeries( - const Reference< XDataSeries > & xSeries, - const Reference< XChartType > & xChartType ) + const rtl::Reference< DataSeries > & xSeries, + const rtl::Reference< ChartType > & xChartType ) { m_aTimerTriggeredControllerLock.startTimer(); ControllerLockGuardUNO aLockedControllers( m_xChartDocument ); - DataSeriesHelper::deleteSeries( xSeries, xChartType ); + xChartType->deleteSeries( xSeries ); } -Reference< data::XLabeledDataSequence > DialogModel::getCategories() const +uno::Reference< chart2::data::XLabeledDataSequence > DialogModel::getCategories() const { - Reference< data::XLabeledDataSequence > xResult; + uno::Reference< chart2::data::XLabeledDataSequence > xResult; try { if( m_xChartDocument.is()) { - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); - xResult.set( DiagramHelper::getCategoriesFromDiagram( xDiagram )); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram()); + if (xDiagram.is()) + xResult = xDiagram->getCategories(); } } catch( const uno::Exception & ) @@ -669,31 +614,38 @@ void DialogModel::setCategories( const Reference< chart2::data::XLabeledDataSequ if( !m_xChartDocument.is()) return; - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram()); if( !xDiagram.is()) return; // categories bool bSupportsCategories = true; - Reference< XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + rtl::Reference< ChartType > xFirstChartType( xDiagram->getChartTypeByIndex( 0 ) ); if( xFirstChartType.is() ) { - sal_Int32 nAxisType = ChartTypeHelper::getAxisType( xFirstChartType, 0 ); // x-axis + sal_Int32 nAxisType = xFirstChartType->getAxisType(0); // x-axis bSupportsCategories = (nAxisType == AxisType::CATEGORY); } - DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram, true, bSupportsCategories ); + xDiagram->setCategories( xCategories, true, bSupportsCategories ); } OUString DialogModel::getCategoriesRange() const { - Reference< data::XLabeledDataSequence > xLSeq( getCategories()); OUString aRange; - if( xLSeq.is()) + try { - Reference< data::XDataSequence > xSeq( xLSeq->getValues()); - if( xSeq.is()) - aRange = xSeq->getSourceRangeRepresentation(); + uno::Reference< chart2::data::XLabeledDataSequence > xLSeq( getCategories()); + if( xLSeq.is()) + { + Reference< data::XDataSequence > xSeq( xLSeq->getValues()); + if( xSeq.is()) + aRange = xSeq->getSourceRangeRepresentation(); + } + } + catch (const lang::DisposedException&) + { + TOOLS_WARN_EXCEPTION( "chart2", "unexpected exception caught" ); } return aRange; } @@ -701,8 +653,8 @@ OUString DialogModel::getCategoriesRange() const bool DialogModel::isCategoryDiagram() const { bool bRet = false; - if( m_xChartDocument.is()) - bRet = DiagramHelper::isCategoryDiagram( m_xChartDocument->getFirstDiagram() ); + if( m_xChartDocument.is() && m_xChartDocument->getFirstChartDiagram()) + bRet = m_xChartDocument->getFirstChartDiagram()->isCategory(); return bRet; } @@ -720,7 +672,7 @@ void DialogModel::detectArguments( if( m_xChartDocument.is()) { (void)DataSourceHelper::detectRangeSegmentation( - Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY_THROW ), + m_xChartDocument, rOutRangeString, aSequenceMapping, rOutUseColumns, rOutFirstCellAsLabel, rOutHasCategories ); } } @@ -759,22 +711,22 @@ void DialogModel::setData( Reference< chart2::data::XDataSource > xDataSource( xDataProvider->createDataSource( rArguments ) ); - Reference< chart2::XDataInterpreter > xInterpreter( - m_xTemplate->getDataInterpreter()); + rtl::Reference< ::chart::DataInterpreter > xInterpreter( + m_xTemplate->getDataInterpreter2()); if( xInterpreter.is()) { - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); - ThreeDLookScheme e3DScheme = ThreeDHelper::detectScheme( xDiagram ); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram() ); + ThreeDLookScheme e3DScheme = xDiagram->detectScheme(); - std::vector< Reference< XDataSeries > > aSeriesToReUse( - DiagramHelper::getDataSeriesFromDiagram( xDiagram )); + std::vector< rtl::Reference< DataSeries > > aSeriesToReUse = + xDiagram->getDataSeries(); applyInterpretedData( xInterpreter->interpretDataSource( xDataSource, rArguments, - comphelper::containerToSequence( aSeriesToReUse )), + aSeriesToReUse ), aSeriesToReUse); - ThreeDHelper::setScheme( xDiagram, e3DScheme ); + xDiagram->setScheme( e3DScheme ); } } catch( const uno::Exception & ) @@ -815,13 +767,13 @@ sal_Int32 DialogModel::GetRoleIndexForSorting( const OUString & rInternalRoleStr void DialogModel::applyInterpretedData( const InterpretedData & rNewData, - const std::vector< Reference< XDataSeries > > & rSeriesToReUse ) + const std::vector< rtl::Reference< DataSeries > > & rSeriesToReUse ) { if( ! m_xChartDocument.is()) return; m_aTimerTriggeredControllerLock.startTimer(); - Reference< XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + rtl::Reference< Diagram > xDiagram( m_xChartDocument->getFirstChartDiagram()); if( !xDiagram.is()) return; @@ -831,43 +783,40 @@ void DialogModel::applyInterpretedData( sal_Int32 nGroup = 0; sal_Int32 nSeriesCounter = 0; sal_Int32 nNewSeriesIndex = static_cast< sal_Int32 >( rSeriesToReUse.size()); - const sal_Int32 nOuterSize=rNewData.Series.getLength(); + const sal_Int32 nOuterSize=rNewData.Series.size(); for(; nGroup < nOuterSize; ++nGroup) { - Sequence< Reference< XDataSeries > > aSeries( rNewData.Series[ nGroup ] ); - const sal_Int32 nSeriesInGroup = aSeries.getLength(); + const std::vector< rtl::Reference< DataSeries > > & aSeries( rNewData.Series[ nGroup ] ); + const sal_Int32 nSeriesInGroup = aSeries.size(); for( sal_Int32 nSeries=0; nSeries<nSeriesInGroup; ++nSeries, ++nSeriesCounter ) { if( std::find( rSeriesToReUse.begin(), rSeriesToReUse.end(), aSeries[nSeries] ) == rSeriesToReUse.end()) { - Reference< beans::XPropertySet > xSeriesProp( aSeries[nSeries], uno::UNO_QUERY ); - if( xSeriesProp.is()) + if( aSeries[nSeries].is()) { // @deprecated: correct default color should be found by view // without setting it as hard attribute Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme()); if( xColorScheme.is()) - xSeriesProp->setPropertyValue( "Color" , + aSeries[nSeries]->setPropertyValue( u"Color"_ustr , uno::Any( xColorScheme->getColorByIndex( nSeriesCounter ))); } - m_xTemplate->applyStyle( aSeries[nSeries], nGroup, nNewSeriesIndex++, nSeriesInGroup ); + m_xTemplate->applyStyle2( aSeries[nSeries], nGroup, nNewSeriesIndex++, nSeriesInGroup ); } } } } // data series - std::vector< Reference< XDataSeriesContainer > > aSeriesCnt( getAllDataSeriesContainers()); - auto aNewSeries( - comphelper::sequenceToContainer<std::vector< Sequence< Reference< XDataSeries > > >>( rNewData.Series )); + std::vector< rtl::Reference< ChartType > > aSeriesCnt = getAllDataSeriesContainers(); - OSL_ASSERT( aSeriesCnt.size() == aNewSeries.size()); + OSL_ASSERT( aSeriesCnt.size() == rNewData.Series.size()); - std::vector< Sequence< Reference< XDataSeries > > >::const_iterator aSrcIt( aNewSeries.begin()); - std::vector< Reference< XDataSeriesContainer > >::iterator aDestIt( aSeriesCnt.begin()); - for(; aSrcIt != aNewSeries.end() && aDestIt != aSeriesCnt.end(); + auto aSrcIt = rNewData.Series.begin(); + auto aDestIt = aSeriesCnt.begin(); + for(; aSrcIt != rNewData.Series.end() && aDestIt != aSeriesCnt.end(); ++aSrcIt, ++aDestIt ) { try @@ -886,16 +835,13 @@ void DialogModel::applyInterpretedData( sal_Int32 DialogModel::countSeries() const { - std::vector< Reference< XDataSeriesContainer > > aCnt( getAllDataSeriesContainers()); + std::vector< rtl::Reference< ChartType > > aCnt( getAllDataSeriesContainers()); return std::accumulate( aCnt.begin(), aCnt.end(), 0, lcl_addSeriesNumber()); } ChartModel& DialogModel::getModel() const { - uno::Reference< frame::XModel > xModel = getChartModel(); - ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get()); - assert(pModel); - return *pModel; + return *m_xChartDocument; } } // namespace chart diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx index 99ce73949cd0..857803fe46f1 100644 --- a/chart2/source/controller/dialogs/DialogModel.hxx +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -20,6 +20,8 @@ #include <TimerTriggeredControllerLock.hxx> #include <rtl/ustring.hxx> +#include <rtl/ref.hxx> +#include <ChartTypeTemplate.hxx> #include <map> #include <memory> @@ -27,17 +29,10 @@ namespace chart { class ChartModel; } namespace com::sun::star::beans { struct PropertyValue; } -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::frame { class XModel; } -namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::uno { template <class E> class Sequence; } namespace com::sun::star::chart2 { - class XDataSeriesContainer; class XDataSeries; - class XChartType; - class XChartTypeTemplate; - struct InterpretedData; namespace data { class XDataProvider; class XLabeledDataSequence; @@ -46,7 +41,9 @@ namespace com::sun::star::chart2 { namespace chart { - +class ChartType; +class DataSeries; +struct InterpretedData; class RangeSelectionHelper; struct DialogModelTimeBasedInfo @@ -61,33 +58,31 @@ struct DialogModelTimeBasedInfo class DialogModel { public: - explicit DialogModel( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument, - const css::uno::Reference< css::uno::XComponentContext > & xContext ); + explicit DialogModel( rtl::Reference<::chart::ChartModel> xChartDocument ); ~DialogModel(); typedef std::pair< OUString, - std::pair< css::uno::Reference< css::chart2::XDataSeries >, - css::uno::Reference< css::chart2::XChartType > > > + std::pair< rtl::Reference< ::chart::DataSeries >, + rtl::Reference< ::chart::ChartType > > > tSeriesWithChartTypeByName; typedef std::map< OUString, OUString > tRolesWithRanges; void setTemplate( - const css::uno::Reference< css::chart2::XChartTypeTemplate > & xTemplate ); + const rtl::Reference< ::chart::ChartTypeTemplate > & xTemplate ); std::shared_ptr< RangeSelectionHelper > const & getRangeSelectionHelper() const; - css::uno::Reference< css::frame::XModel > + const rtl::Reference<::chart::ChartModel> & getChartModel() const; css::uno::Reference< css::chart2::data::XDataProvider > getDataProvider() const; - std::vector< css::uno::Reference< css::chart2::XDataSeriesContainer > > + std::vector< rtl::Reference< ::chart::ChartType > > getAllDataSeriesContainers() const; std::vector< tSeriesWithChartTypeByName > @@ -96,26 +91,26 @@ public: static tRolesWithRanges getRolesWithRanges( const css::uno::Reference< css::chart2::XDataSeries > & xSeries, const OUString & aRoleOfSequenceForLabel, - const css::uno::Reference< css::chart2::XChartType > & xChartType ); + const rtl::Reference< ::chart::ChartType > & xChartType ); enum class MoveDirection { Down, Up }; - void moveSeries( const css::uno::Reference< css::chart2::XDataSeries > & xSeries, + void moveSeries( const rtl::Reference< DataSeries > & xSeries, MoveDirection eDirection ); /// @return the newly inserted series - css::uno::Reference< - css::chart2::XDataSeries > insertSeriesAfter( + rtl::Reference< + ::chart::DataSeries > insertSeriesAfter( const css::uno::Reference< css::chart2::XDataSeries > & xSeries, - const css::uno::Reference< css::chart2::XChartType > & xChartType, + const rtl::Reference< ::chart::ChartType > & xChartType, bool bCreateDataCachedSequences = false ); void deleteSeries( - const css::uno::Reference< css::chart2::XDataSeries > & xSeries, - const css::uno::Reference< css::chart2::XChartType > & xChartType ); + const rtl::Reference< ::chart::DataSeries > & xSeries, + const rtl::Reference< ::chart::ChartType > & xChartType ); css::uno::Reference< css::chart2::data::XLabeledDataSequence > getCategories() const; @@ -150,14 +145,10 @@ public: ChartModel& getModel() const; private: - css::uno::Reference< css::chart2::XChartDocument > + rtl::Reference<::chart::ChartModel> m_xChartDocument; - css::uno::Reference< css::chart2::XChartTypeTemplate > - m_xTemplate; - - css::uno::Reference< css::uno::XComponentContext > - m_xContext; + rtl::Reference< ::chart::ChartTypeTemplate > m_xTemplate; mutable std::shared_ptr< RangeSelectionHelper > m_spRangeSelectionHelper; @@ -166,8 +157,8 @@ private: private: void applyInterpretedData( - const css::chart2::InterpretedData & rNewData, - const std::vector< css::uno::Reference< css::chart2::XDataSeries > > & rSeriesToReUse ); + const InterpretedData & rNewData, + const std::vector< rtl::Reference< ::chart::DataSeries > > & rSeriesToReUse ); sal_Int32 countSeries() const; diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx index 5eae3853add8..ef9893ca7ddb 100644 --- a/chart2/source/controller/dialogs/ObjectNameProvider.cxx +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -24,26 +24,30 @@ #include <ObjectNameProvider.hxx> #include <ResId.hxx> #include <strings.hrc> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <ChartType.hxx> +#include <Diagram.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <TitleHelper.hxx> #include <ExplicitCategoriesProvider.hxx> #include <CommonConverters.hxx> #include <NumberFormatterWrapper.hxx> #include <RegressionCurveHelper.hxx> +#include <BaseCoordinateSystem.hxx> +#include <RegressionCurveModel.hxx> +#include <RegressionCurveCalculator.hxx> #include <rtl/math.hxx> #include <rtl/ustring.hxx> #include <vcl/settings.hxx> #include <vcl/svapp.hxx> #include <unotools/localedatawrapper.hxx> -#include <com/sun/star/chart2/XTitle.hpp> #include <com/sun/star/chart2/MovingAverageType.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <o3tl/string_view.hxx> namespace chart { @@ -56,29 +60,29 @@ using ::com::sun::star::uno::Any; namespace { -OUString lcl_getDataSeriesName( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) +OUString lcl_getDataSeriesName( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel ) { OUString aRet; - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); if( xDiagram.is() && xSeries.is() ) { - Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); if( xChartType.is() ) { - aRet = ::chart::DataSeriesHelper::getDataSeriesLabel( - xSeries, xChartType->getRoleOfSequenceForSeriesLabel() ) ; + aRet = xSeries->getLabelForRole( + xChartType->getRoleOfSequenceForSeriesLabel() ) ; } } return aRet; } -OUString lcl_getFullSeriesName( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) +OUString lcl_getFullSeriesName( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel ) { OUString aRet(SchResId(STR_TIP_DATASERIES)); - OUString aWildcard( "%SERIESNAME" ); + OUString aWildcard( u"%SERIESNAME"_ustr ); sal_Int32 nIndex = aRet.indexOf( aWildcard ); if( nIndex != -1 ) aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); @@ -93,19 +97,17 @@ void lcl_addText( OUString& rOut, std::u16string_view rSeparator, std::u16string rOut+=rNext; } -OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal_Int32 nPointIndex, - const Reference< XCoordinateSystem >& xCooSys, +OUString lcl_getDataPointValueText( const rtl::Reference< DataSeries >& xSeries, sal_Int32 nPointIndex, + const rtl::Reference< BaseCoordinateSystem >& xCooSys, const Reference< frame::XModel >& xChartModel ) { OUString aRet; - Reference<data::XDataSource> xDataSource( - uno::Reference<data::XDataSource>( xSeries, uno::UNO_QUERY ) ); - if(!xDataSource.is()) + if(!xSeries.is()) return aRet; - Sequence< Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSequences = xSeries->getDataSequences2(); OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size; double fValue = 0; @@ -115,20 +117,22 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal Color nLabelColor;//dummy bool bColorChanged;//dummy - for(sal_Int32 nN = aDataSequences.getLength();nN--;) + for(sal_Int32 nN = aDataSequences.size();nN--;) { uno::Reference<data::XDataSequence> xDataSequence( aDataSequences[nN]->getValues()); if( !xDataSequence.is() ) continue; - Sequence< Any > aData( xDataSequence->getData() ); - if( nPointIndex >= aData.getLength() ) - continue; - uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY ); - if( xProp.is()) + + try { - try + Sequence< Any > aData( xDataSequence->getData() ); + + if( nPointIndex >= aData.getLength() ) + continue; + uno::Reference<beans::XPropertySet> xProp(xDataSequence, uno::UNO_QUERY ); + if( xProp.is()) { - uno::Any aARole = xProp->getPropertyValue( "Role" ); + uno::Any aARole = xProp->getPropertyValue( u"Role"_ustr ); OUString aRole; aARole >>= aRole; @@ -175,10 +179,14 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); } } - catch( const uno::Exception& ) - { - TOOLS_WARN_EXCEPTION("chart2", "" ); - } + } + catch (const lang::DisposedException&) + { + TOOLS_WARN_EXCEPTION( "chart2", "unexpected exception caught" ); + } + catch( const uno::Exception& ) + { + TOOLS_WARN_EXCEPTION("chart2", "" ); } } @@ -192,7 +200,7 @@ OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal aRet = aX; } - OUString aSeparator( " " ); + OUString aSeparator( u" "_ustr ); lcl_addText( aRet, aSeparator, aY ); lcl_addText( aRet, aSeparator, aY_First ); @@ -246,6 +254,7 @@ OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) } break; case OBJECTTYPE_AXIS_UNITLABEL: + case OBJECTTYPE_DATA_LABEL: aRet=SchResId(STR_OBJECT_LABEL);//@todo maybe a more concrete name break; case OBJECTTYPE_GRID: @@ -276,9 +285,6 @@ OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) case OBJECTTYPE_DATA_LABELS: aRet=SchResId(STR_OBJECT_DATALABELS); break; - case OBJECTTYPE_DATA_LABEL: - aRet=SchResId(STR_OBJECT_LABEL); - break; case OBJECTTYPE_DATA_ERRORS_X: aRet=SchResId(STR_OBJECT_ERROR_BARS_X); break; @@ -310,24 +316,27 @@ OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) case OBJECTTYPE_DATA_CURVE_EQUATION: aRet=SchResId(STR_OBJECT_CURVE_EQUATION); break; + case OBJECTTYPE_DATA_TABLE: + aRet=SchResId(STR_DATA_TABLE); + break; default: //OBJECTTYPE_UNKNOWN ; } return aRet; } -OUString ObjectNameProvider::getAxisName( const OUString& rObjectCID - , const uno::Reference< frame::XModel >& xChartModel ) +OUString ObjectNameProvider::getAxisName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ) { OUString aRet; - Reference< XAxis > xAxis( - ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = + dynamic_cast<::chart::Axis*>(ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ).get()); sal_Int32 nCooSysIndex = 0; sal_Int32 nDimensionIndex = 0; sal_Int32 nAxisIndex = 0; - AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex ); + AxisHelper::getIndicesForAxis( xAxis, xChartModel->getFirstChartDiagram(), nCooSysIndex, nDimensionIndex, nAxisIndex ); switch(nDimensionIndex) { @@ -392,14 +401,14 @@ OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) return aRet; } -OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel ) +OUString ObjectNameProvider::getTitleName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ) { OUString aRet; - Reference< XTitle > xTitle( - ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); - if( xTitle.is() ) + rtl::Reference<Title> xTitle = + dynamic_cast<Title*>(ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ).get()); + if( xTitle ) { TitleHelper::eTitleType eType; if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) ) @@ -411,16 +420,16 @@ OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID return aRet; } -OUString ObjectNameProvider::getGridName( const OUString& rObjectCID - , const uno::Reference< frame::XModel >& xChartModel ) +OUString ObjectNameProvider::getGridName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ) { OUString aRet; sal_Int32 nCooSysIndex = -1; sal_Int32 nDimensionIndex = -1; sal_Int32 nAxisIndex = -1; - Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( rObjectCID , xChartModel ) ); - AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ) + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( rObjectCID , xChartModel ); + AxisHelper::getIndicesForAxis( xAxis, xChartModel->getFirstChartDiagram() , nCooSysIndex , nDimensionIndex, nAxisIndex ); bool bMainGrid = (ObjectIdentifier::getObjectType( rObjectCID ) == OBJECTTYPE_GRID); @@ -464,12 +473,7 @@ OUString ObjectNameProvider::getGridName( const OUString& rObjectCID return aRet; } -OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Reference< chart2::XChartDocument >& xChartDocument ) -{ - return getHelpText( rObjectCID, Reference< frame::XModel >( xChartDocument ) ); -} - -OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Reference< frame::XModel >& xChartModel, bool bVerbose ) +OUString ObjectNameProvider::getHelpText( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel, bool bVerbose ) { OUString aRet; ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); @@ -501,14 +505,14 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe else aRet=SchResId(STR_TIP_DATAPOINT); - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); if( xDiagram.is() && xSeries.is() ) { - sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + sal_Int32 nPointIndex = o3tl::toInt32(ObjectIdentifier::getParticleID(rObjectCID)); //replace data point index - OUString aWildcard( "%POINTNUMBER" ); + OUString aWildcard( u"%POINTNUMBER"_ustr ); sal_Int32 nIndex = aRet.indexOf( aWildcard ); if( nIndex != -1 ) { @@ -520,8 +524,8 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe nIndex = aRet.indexOf( aWildcard ); if( nIndex != -1 ) { - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector = + xDiagram->getDataSeries(); sal_Int32 nSeriesIndex = -1; for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) { @@ -554,82 +558,76 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe if( bVerbose ) { aRet = SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS ); - Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); - Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); - if( xCurveCnt.is()) + if( xSeries.is()) { sal_Int32 nCurveIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); - Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) ); + rtl::Reference< RegressionCurveModel > xCurve = RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex); if( xCurve.is()) { try { - Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_SET_THROW ); + rtl::Reference< RegressionCurveCalculator > xCalculator( xCurve->getCurveCalculator() ); sal_Int32 aDegree = 2; sal_Int32 aPeriod = 2; sal_Int32 aMovingType = css::chart2::MovingAverageType::Prior; bool bForceIntercept = false; double aInterceptValue = 0.0; - OUString aXName ("x"), aYName ("f(x)"); + OUString aXName (u"x"_ustr), aYName (u"f(x)"_ustr); const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); sal_Unicode cDecSeparator = aNumDecimalSep[0]; - uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - if ( xProperties.is()) + xCurve->getPropertyValue( u"PolynomialDegree"_ustr) >>= aDegree; + xCurve->getPropertyValue( u"MovingAveragePeriod"_ustr) >>= aPeriod; + xCurve->getPropertyValue( u"MovingAverageType"_ustr) >>= aMovingType; + xCurve->getPropertyValue( u"ForceIntercept"_ustr) >>= bForceIntercept; + if (bForceIntercept) + xCurve->getPropertyValue( u"InterceptValue"_ustr) >>= aInterceptValue; + uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); + if( xEqProp.is()) { - xProperties->getPropertyValue( "PolynomialDegree") >>= aDegree; - xProperties->getPropertyValue( "MovingAveragePeriod") >>= aPeriod; - xProperties->getPropertyValue( "MovingAverageType") >>= aMovingType; - xProperties->getPropertyValue( "ForceIntercept") >>= bForceIntercept; - if (bForceIntercept) - xProperties->getPropertyValue( "InterceptValue") >>= aInterceptValue; - uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); - if( xEqProp.is()) - { - if ( !(xEqProp->getPropertyValue( "XName") >>= aXName) ) - aXName = "x"; - if ( !(xEqProp->getPropertyValue( "YName") >>= aYName) ) - aYName = "f(x)"; - } + if ( !(xEqProp->getPropertyValue( u"XName"_ustr) >>= aXName) ) + aXName = "x"; + if ( !(xEqProp->getPropertyValue( u"YName"_ustr) >>= aYName) ) + aYName = "f(x)"; } - xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, 2, aMovingType); + xCalculator->setRegressionProperties(aDegree, bForceIntercept, aInterceptValue, aPeriod, aMovingType); xCalculator->setXYNames ( aXName, aYName ); RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); // change text for Moving Average - OUString aWildcard( "%PERIOD" ); - sal_Int32 nIndex = xCalculator->getRepresentation().indexOf( aWildcard ); - if( nIndex != -1 ) - { // replace period - aRet = xCalculator->getRepresentation(); - aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::number(aPeriod) ); + if ( RegressionCurveHelper::getRegressionType( xCurve ) == SvxChartRegress::MovingAverage ) + { + aRet = xCalculator->getRepresentation(); } - - // replace formula - aWildcard = "%FORMULA"; - nIndex = aRet.indexOf( aWildcard ); - if( nIndex != -1 ) + else { - OUString aFormula ( xCalculator->getRepresentation() ); - if ( cDecSeparator != '.' ) + // replace formula + OUString aWildcard = u"%FORMULA"_ustr; + sal_Int32 nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) { - aFormula = aFormula.replace( '.', cDecSeparator ); + OUString aFormula ( xCalculator->getRepresentation() ); + if ( cDecSeparator != '.' ) + { + aFormula = aFormula.replace( '.', cDecSeparator ); + } + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aFormula ); } - aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aFormula ); - } - // replace r^2 - aWildcard = "%RSQUARED"; - nIndex = aRet.indexOf( aWildcard ); - if( nIndex != -1 ) - { - double fR( xCalculator->getCorrelationCoefficient()); - aRet = aRet.replaceAt( - nIndex, aWildcard.getLength(), - ::rtl::math::doubleToUString( - fR*fR, rtl_math_StringFormat_G, 4, cDecSeparator, true )); + // replace r^2 + aWildcard = "%RSQUARED"; + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + { + double fR( xCalculator->getCorrelationCoefficient()); + aRet = aRet.replaceAt( + nIndex, aWildcard.getLength(), + ::rtl::math::doubleToUString( + fR*fR, rtl_math_StringFormat_G, 4, cDecSeparator, true )); + } } } catch( const uno::Exception & ) @@ -641,14 +639,13 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe } else { - Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(rObjectCID , xChartModel)); - Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID(rObjectCID , xChartModel)); aRet += getName(eObjectType); - if( xCurveCnt.is()) + if( xSeries.is()) { sal_Int32 nCurveIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); - Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) ); + rtl::Reference< RegressionCurveModel > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex) ); if( xCurve.is()) { aRet += " (" + RegressionCurveHelper::getRegressionCurveName(xCurve) + " )"; @@ -661,23 +658,22 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe if( bVerbose ) { aRet = SchResId(STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS); - Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); - Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); - if( xCurveCnt.is()) + rtl::Reference< DataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); + if( xSeries.is()) { - Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt )); + rtl::Reference< RegressionCurveModel > xCurve( RegressionCurveHelper::getMeanValueLine( xSeries )); if( xCurve.is()) { try { - Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_SET_THROW ); + rtl::Reference< RegressionCurveCalculator > xCalculator( xCurve->getCurveCalculator() ); RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); const LocaleDataWrapper& rLocaleDataWrapper = Application::GetSettings().GetLocaleDataWrapper(); const OUString& aNumDecimalSep = rLocaleDataWrapper.getNumDecimalSep(); sal_Unicode cDecSeparator = aNumDecimalSep[0]; - OUString aWildcard( "%AVERAGE_VALUE" ); + OUString aWildcard( u"%AVERAGE_VALUE"_ustr ); sal_Int32 nIndex = aRet.indexOf( aWildcard ); // as the curve is constant, the value at any x-value is ok if( nIndex != -1 ) @@ -721,52 +717,51 @@ OUString ObjectNameProvider::getHelpText( const OUString& rObjectCID, const Refe return aRet; } -OUString ObjectNameProvider::getSelectedObjectText( const OUString & rObjectCID, const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument ) +OUString ObjectNameProvider::getSelectedObjectText( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartDocument ) { OUString aRet; ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); - Reference< frame::XModel > xChartModel = xChartDocument; if( eObjectType == OBJECTTYPE_DATA_POINT ) { aRet = SchResId( STR_STATUS_DATAPOINT_MARKED ); - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ); + rtl::Reference< Diagram > xDiagram( xChartDocument->getFirstChartDiagram() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument ); if( xDiagram.is() && xSeries.is() ) { - sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + sal_Int32 nPointIndex = o3tl::toInt32( ObjectIdentifier::getParticleID(rObjectCID) ); // replace data point index - replaceParamterInString( aRet, "%POINTNUMBER", OUString::number( nPointIndex + 1 )); + replaceParamterInString( aRet, u"%POINTNUMBER", OUString::number( nPointIndex + 1 )); // replace data series index { - std::vector< Reference< chart2::XDataSeries > > aSeriesVector( - DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + std::vector< rtl::Reference< DataSeries > > aSeriesVector( + xDiagram->getDataSeries() ); sal_Int32 nSeriesIndex = -1; for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) { if( aSeriesVector[nSeriesIndex] == xSeries ) break; } - replaceParamterInString( aRet, "%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) ); + replaceParamterInString( aRet, u"%SERIESNUMBER", OUString::number( nSeriesIndex + 1 ) ); } // replace point value - replaceParamterInString( aRet, "%POINTVALUES", lcl_getDataPointValueText( - xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) ); + replaceParamterInString( aRet, u"%POINTVALUES", lcl_getDataPointValueText( + xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartDocument ) ); } } else { // use the verbose text including the formula for trend lines const bool bVerbose( eObjectType == OBJECTTYPE_DATA_CURVE || eObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ); - const OUString aHelpText( getHelpText( rObjectCID, xChartModel, bVerbose )); + const OUString aHelpText( getHelpText( rObjectCID, xChartDocument, bVerbose )); if( !aHelpText.isEmpty()) { aRet = SchResId( STR_STATUS_OBJECT_MARKED ); - replaceParamterInString( aRet, "%OBJECTNAME", aHelpText ); + replaceParamterInString( aRet, u"%OBJECTNAME", aHelpText ); } } @@ -774,23 +769,22 @@ OUString ObjectNameProvider::getSelectedObjectText( const OUString & rObjectCID, } OUString ObjectNameProvider::getNameForCID( - const OUString& rObjectCID, - const uno::Reference< chart2::XChartDocument >& xChartDocument ) + std::u16string_view rObjectCID, + const rtl::Reference<::chart::ChartModel>& xChartDocument ) { ObjectType eType( ObjectIdentifier::getObjectType( rObjectCID )); - Reference< frame::XModel > xModel = xChartDocument; switch( eType ) { case OBJECTTYPE_AXIS: - return getAxisName( rObjectCID, xModel ); + return getAxisName( rObjectCID, xChartDocument ); case OBJECTTYPE_TITLE: - return getTitleName( rObjectCID, xModel ); + return getTitleName( rObjectCID, xChartDocument ); case OBJECTTYPE_GRID: case OBJECTTYPE_SUBGRID: - return getGridName( rObjectCID, xModel ); + return getGridName( rObjectCID, xChartDocument ); case OBJECTTYPE_DATA_SERIES: - return lcl_getFullSeriesName( rObjectCID, xModel ); + return lcl_getFullSeriesName( rObjectCID, xChartDocument ); case OBJECTTYPE_DATA_POINT: case OBJECTTYPE_DATA_LABELS: case OBJECTTYPE_DATA_LABEL: @@ -801,7 +795,7 @@ OUString ObjectNameProvider::getNameForCID( case OBJECTTYPE_DATA_CURVE: case OBJECTTYPE_DATA_CURVE_EQUATION: { - OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel ) + " "; + OUString aRet = lcl_getFullSeriesName( rObjectCID, xChartDocument ) + " "; if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) { aRet += getName( OBJECTTYPE_DATA_POINT ); @@ -814,15 +808,14 @@ OUString ObjectNameProvider::getNameForCID( } else if (eType == OBJECTTYPE_DATA_CURVE || eType == OBJECTTYPE_DATA_CURVE_EQUATION) { - Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xModel )); - Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartDocument )); aRet += " " + getName(eType); - if( xCurveCnt.is()) + if( xSeries.is()) { sal_Int32 nCurveIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); - Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xCurveCnt, nCurveIndex) ); + rtl::Reference< RegressionCurveModel > xCurve( RegressionCurveHelper::getRegressionCurveAtIndex(xSeries, nCurveIndex) ); if( xCurve.is()) { aRet += " (" + RegressionCurveHelper::getRegressionCurveName(xCurve) + ")"; @@ -844,16 +837,15 @@ OUString ObjectNameProvider::getNameForCID( OUString ObjectNameProvider::getName_ObjectForSeries( ObjectType eObjectType, - const OUString& rSeriesCID, - const uno::Reference< chart2::XChartDocument >& xChartDocument ) + std::u16string_view rSeriesCID, + const rtl::Reference<::chart::ChartModel>& xChartDocument ) { - uno::Reference< frame::XModel> xChartModel = xChartDocument; - Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartDocument ); if( xSeries.is() ) { OUString aRet = SchResId(STR_OBJECT_FOR_SERIES); - replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType ) ); - replaceParamterInString( aRet, "%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartModel ) ); + replaceParamterInString( aRet, u"%OBJECTNAME", getName( eObjectType ) ); + replaceParamterInString( aRet, u"%SERIESNAME", lcl_getDataSeriesName( rSeriesCID, xChartDocument ) ); return aRet; } else @@ -863,7 +855,7 @@ OUString ObjectNameProvider::getName_ObjectForSeries( OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) { OUString aRet = SchResId(STR_OBJECT_FOR_ALL_SERIES); - replaceParamterInString( aRet, "%OBJECTNAME", getName( eObjectType, true /*bPlural*/ ) ); + replaceParamterInString( aRet, u"%OBJECTNAME", getName( eObjectType, true /*bPlural*/ ) ); return aRet; } diff --git a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx index 8cd8f64c8383..1ae7b3377b25 100644 --- a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx +++ b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx @@ -20,9 +20,10 @@ #include <RangeSelectionHelper.hxx> #include <RangeSelectionListener.hxx> #include <com/sun/star/awt/XTopWindow.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <ChartModel.hxx> +#include <utility> using namespace ::com::sun::star; @@ -33,8 +34,8 @@ namespace chart { RangeSelectionHelper::RangeSelectionHelper( - const Reference< chart2::XChartDocument > & xChartDocument ) : - m_xChartDocument( xChartDocument ) + rtl::Reference<::chart::ChartModel> xChartDocument ) : + m_xChartDocument(std::move( xChartDocument )) {} RangeSelectionHelper::~RangeSelectionHelper() @@ -109,21 +110,21 @@ bool RangeSelectionHelper::chooseRange( Reference< sheet::XRangeSelection > xRangeSel( getRangeSelection()); if( xRangeSel.is()) { - Sequence< beans::PropertyValue > aArgs( 4 ); - aArgs[0] = beans::PropertyValue( - "InitialValue", -1, uno::Any( aCurrentRange ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[1] = beans::PropertyValue( - "Title", -1, - uno::Any( aUIString ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[2] = beans::PropertyValue( - "CloseOnMouseRelease", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); - aArgs[3] = beans::PropertyValue( - "MultiSelectionMode", -1, uno::Any( true ), - beans::PropertyState_DIRECT_VALUE ); - + Sequence< beans::PropertyValue > aArgs{ + beans::PropertyValue( + u"InitialValue"_ustr, -1, uno::Any( aCurrentRange ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + u"Title"_ustr, -1, + uno::Any( aUIString ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + u"CloseOnMouseRelease"_ustr, -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ), + beans::PropertyValue( + u"MultiSelectionMode"_ustr, -1, uno::Any( true ), + beans::PropertyState_DIRECT_VALUE ) + }; if( m_xRangeSelectionListener.is() ) stopRangeListening(); m_xRangeSelectionListener.set( Reference< sheet::XRangeSelectionListener >( diff --git a/chart2/source/controller/dialogs/RangeSelectionListener.cxx b/chart2/source/controller/dialogs/RangeSelectionListener.cxx index ca0d9ae2cd48..ec5d5f0ded43 100644 --- a/chart2/source/controller/dialogs/RangeSelectionListener.cxx +++ b/chart2/source/controller/dialogs/RangeSelectionListener.cxx @@ -18,20 +18,21 @@ */ #include <RangeSelectionListener.hxx> +#include <ChartModel.hxx> +#include <vcl/weld.hxx> +#include <utility> using namespace ::com::sun::star; -using ::com::sun::star::uno::Reference; - namespace chart { RangeSelectionListener::RangeSelectionListener( RangeSelectionListenerParent & rParent, - const OUString & rInitialRange, - const Reference< frame::XModel >& xModelToLockController ) : + OUString aInitialRange, + const rtl::Reference<::chart::ChartModel>& xModelToLockController ) : m_rParent( rParent ), - m_aRange( rInitialRange ), + m_aRange(std::move( aInitialRange )), m_aControllerLockGuard( xModelToLockController ) {} @@ -56,6 +57,23 @@ void SAL_CALL RangeSelectionListener::disposing( const lang::EventObject& /*Sour m_rParent.disposingRangeSelection(); } +void RangeSelectionListenerParent::enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) +{ + if (!pDialog) + return; + weld::Dialog* pDlg = pDialog->getDialog(); + // tdf#158753 save the current page when hiding the wizard, + // and restore it on showing the wizard to workaround that + // that GtkAssistant resets to page 0 on hide+show + weld::Assistant* pAss = dynamic_cast<weld::Assistant*>(pDlg); + if (pAss && bEnable) + m_sRestorePageIdent = pAss->get_current_page_ident(); + pDlg->set_modal(!bEnable); + pDlg->set_visible(!bEnable); + if (pAss && !bEnable) + pAss->set_current_page(m_sRestorePageIdent); +} + } // namespace chart /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx b/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx index 1215e7b40cdf..cee4af1fb013 100644 --- a/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx +++ b/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx @@ -17,19 +17,19 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/frame/XModel.hpp> #include <TimerTriggeredControllerLock.hxx> #include <ControllerLockGuard.hxx> +#include <ChartModel.hxx> +#include <utility> namespace chart { using namespace ::com::sun::star; TimerTriggeredControllerLock::TimerTriggeredControllerLock( - const uno::Reference<frame::XModel>& xModel) - : m_xModel(xModel) - , m_apControllerLockGuard() - , m_aTimer() + rtl::Reference<::chart::ChartModel> xModel) + : m_xModel(std::move(xModel)) + , m_aTimer("chart2 TimerTriggeredControllerLock") { m_aTimer.SetTimeout(4 * EDIT_UPDATEDATA_TIMEOUT); m_aTimer.SetInvokeHandler(LINK(this, TimerTriggeredControllerLock, TimerTimeout)); diff --git a/chart2/source/controller/dialogs/TitleDialogData.cxx b/chart2/source/controller/dialogs/TitleDialogData.cxx index e4e9099011a6..75d59bbb43b4 100644 --- a/chart2/source/controller/dialogs/TitleDialogData.cxx +++ b/chart2/source/controller/dialogs/TitleDialogData.cxx @@ -19,65 +19,61 @@ #include <sal/config.h> -#include <com/sun/star/frame/XModel.hpp> - #include <TitleDialogData.hxx> #include <TitleHelper.hxx> -#include <ChartModelHelper.hxx> +#include <Diagram.hxx> #include <AxisHelper.hxx> +#include <ChartModel.hxx> namespace chart { using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; -TitleDialogData::TitleDialogData( std::unique_ptr<ReferenceSizeProvider> pRefSizeProvider ) - : aPossibilityList(7) - , aExistenceList(7) +TitleDialogData::TitleDialogData( std::optional<ReferenceSizeProvider> pRefSizeProvider ) + : aPossibilityList{ true, true, true, true, true, true, true } + , aExistenceList{ false, false, false, false, false, false, false } , aTextList(7) , apReferenceSizeProvider( std::move(pRefSizeProvider) ) { - for (sal_Int32 i = 0; i < 7; i++) - { - aPossibilityList[i] = true; - aExistenceList[i] = false; - } } -void TitleDialogData::readFromModel( const uno::Reference< frame::XModel>& xChartModel ) +void TitleDialogData::readFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel ) { - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(xChartModel); + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); //get possibilities uno::Sequence< sal_Bool > aAxisPossibilityList; AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram ); - aPossibilityList[2]=aAxisPossibilityList[0];//x axis title - aPossibilityList[3]=aAxisPossibilityList[1];//y axis title - aPossibilityList[4]=aAxisPossibilityList[2];//z axis title - aPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title - aPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title + sal_Bool* pPossibilityList = aPossibilityList.getArray(); + pPossibilityList[2]=aAxisPossibilityList[0];//x axis title + pPossibilityList[3]=aAxisPossibilityList[1];//y axis title + pPossibilityList[4]=aAxisPossibilityList[2];//z axis title + pPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title + pPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title + sal_Bool* pExistenceList = aExistenceList.getArray(); + auto pTextList = aTextList.getArray(); //find out which title exists and get their text //main title: - for( sal_Int32 nTitleIndex = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN); - nTitleIndex < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END ); + for( auto nTitleIndex = +TitleHelper::TITLE_BEGIN; + nTitleIndex < +TitleHelper::NORMAL_TITLE_END; nTitleIndex++) { - uno::Reference< XTitle > xTitle = TitleHelper::getTitle( + rtl::Reference< Title > xTitle = TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel ); - aExistenceList[nTitleIndex] = xTitle.is(); - aTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle ); + pExistenceList[nTitleIndex] = xTitle.is(); + pTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle ); } } bool TitleDialogData::writeDifferenceToModel( - const uno::Reference< frame::XModel >& xChartModel + const rtl::Reference<::chart::ChartModel>& xChartModel , const uno::Reference< uno::XComponentContext >& xContext - , TitleDialogData* pOldState ) + , const TitleDialogData* pOldState ) { bool bChanged = false; - for( sal_Int32 nN = static_cast< sal_Int32 >( TitleHelper::TITLE_BEGIN ); - nN < static_cast< sal_Int32 >( TitleHelper::NORMAL_TITLE_END ); + for( auto nN = +TitleHelper::TITLE_BEGIN; + nN < +TitleHelper::NORMAL_TITLE_END; nN++) { if( !pOldState || ( pOldState->aExistenceList[nN] != aExistenceList[nN] ) ) @@ -86,7 +82,7 @@ bool TitleDialogData::writeDifferenceToModel( { TitleHelper::createTitle( static_cast< TitleHelper::eTitleType >( nN ), aTextList[nN], xChartModel, xContext, - apReferenceSizeProvider.get() ); + apReferenceSizeProvider.has_value() ? &*apReferenceSizeProvider : nullptr ); bChanged = true; } else @@ -98,11 +94,11 @@ bool TitleDialogData::writeDifferenceToModel( else if( !pOldState || ( pOldState->aTextList[nN] != aTextList[nN] ) ) { //change content - uno::Reference< XTitle > xTitle( + rtl::Reference< Title > xTitle( TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) ); if(xTitle.is()) { - TitleHelper::setCompleteString( aTextList[nN], xTitle, xContext ); + TitleHelper::setCompleteString( aTextList[nN], xTitle, xContext, nullptr, true ); bChanged = true; } } diff --git a/chart2/source/controller/dialogs/dlg_ChartType.cxx b/chart2/source/controller/dialogs/dlg_ChartType.cxx index 324eb06c8373..837f3f3acc25 100644 --- a/chart2/source/controller/dialogs/dlg_ChartType.cxx +++ b/chart2/source/controller/dialogs/dlg_ChartType.cxx @@ -19,22 +19,22 @@ #include <dlg_ChartType.hxx> #include "tp_ChartType.hxx" -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <ChartModel.hxx> +#include <utility> namespace chart { using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; ChartTypeDialog::ChartTypeDialog(weld::Window* pParent, - const uno::Reference<frame::XModel>& xChartModel) - : GenericDialogController(pParent, "modules/schart/ui/charttypedialog.ui", "ChartTypeDialog") - , m_xChartModel(xChartModel) - , m_xContentArea(m_xDialog->weld_content_area()) + rtl::Reference<::chart::ChartModel> xChartModel) + : GenericDialogController(pParent, u"modules/schart/ui/charttypedialog.ui"_ustr, + u"ChartTypeDialog"_ustr) + , m_xChartModel(std::move(xChartModel)) + , m_xContentArea(m_xBuilder->weld_container(u"content"_ustr)) { m_xChartTypeTabPage = std::make_unique<ChartTypeTabPage>( - m_xContentArea.get(), this, uno::Reference<XChartDocument>::query(m_xChartModel), - false /*don't show title description*/); + m_xContentArea.get(), this, m_xChartModel, false /*don't show title description*/); m_xChartTypeTabPage->initializePage(); } diff --git a/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx b/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx index 1a34d47b4f9c..c92148b036c0 100644 --- a/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx +++ b/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx @@ -19,12 +19,10 @@ #include <dlg_ChartType_UNO.hxx> #include <dlg_ChartType.hxx> +#include <ChartModel.hxx> #include <servicenames.hxx> #include <osl/mutex.hxx> #include <vcl/svapp.hxx> -#include <com/sun/star/frame/XModel.hpp> - -namespace com::sun::star::awt { class XWindow; } namespace chart { @@ -47,12 +45,12 @@ ChartTypeUnoDlg::~ChartTypeUnoDlg() // lang::XServiceInfo OUString SAL_CALL ChartTypeUnoDlg::getImplementationName() { - return CHART_TYPE_DIALOG_SERVICE_IMPLEMENTATION_NAME; + return u"com.sun.star.comp.chart2.ChartTypeDialog"_ustr; } css::uno::Sequence<OUString> SAL_CALL ChartTypeUnoDlg::getSupportedServiceNames() { - return { CHART_TYPE_DIALOG_SERVICE_NAME }; + return { u"com.sun.star.chart2.ChartTypeDialog"_ustr }; } uno::Sequence< sal_Int8 > SAL_CALL ChartTypeUnoDlg::getImplementationId() { @@ -64,7 +62,12 @@ void ChartTypeUnoDlg::implInitialize(const uno::Any& _rValue) if (_rValue >>= aProperty) { if (aProperty.Name == "ChartModel") - m_xChartModel.set(aProperty.Value,uno::UNO_QUERY); + { + uno::Reference<XInterface> xInt; + aProperty.Value >>= xInt; + assert(dynamic_cast<::chart::ChartModel*>(xInt.get())); + m_xChartModel = dynamic_cast<::chart::ChartModel*>(xInt.get()); + } else ChartTypeUnoDlg_BASE::implInitialize(_rValue); } @@ -74,7 +77,9 @@ void ChartTypeUnoDlg::implInitialize(const uno::Any& _rValue) std::unique_ptr<weld::DialogController> ChartTypeUnoDlg::createDialog(const css::uno::Reference<css::awt::XWindow>& rParent) { - return std::make_unique<ChartTypeDialog>(Application::GetFrameWeld(rParent), m_xChartModel); + ChartModel* pChartModel = dynamic_cast<ChartModel*>(rParent.get()); + assert(pChartModel); + return std::make_unique<ChartTypeDialog>(Application::GetFrameWeld(rParent), pChartModel); } uno::Reference<beans::XPropertySetInfo> SAL_CALL ChartTypeUnoDlg::getPropertySetInfo() diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx index da073c2f9956..ddfa7a3b4e3e 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx @@ -28,15 +28,17 @@ #include "tp_Wizard_TitlesAndObjects.hxx" #include "tp_DataSource.hxx" #include <ChartTypeTemplateProvider.hxx> +#include <ChartTypeTemplate.hxx> +#include <utility> #include "DialogModel.hxx" using namespace css; using vcl::RoadmapWizardTypes::WizardPath; +using vcl::RoadmapWizardTypes::PathId; namespace chart { -#define PATH_FULL 1 #define STATE_FIRST 0 #define STATE_CHARTTYPE STATE_FIRST #define STATE_SIMPLE_RANGE 1 @@ -44,16 +46,16 @@ namespace chart #define STATE_OBJECTS 3 #define STATE_LAST STATE_OBJECTS -CreationWizard::CreationWizard(weld::Window* pParent, const uno::Reference<frame::XModel>& xChartModel, - const uno::Reference<uno::XComponentContext>& xContext) +CreationWizard::CreationWizard(weld::Window* pParent, const rtl::Reference<::chart::ChartModel>& xChartModel, + uno::Reference<uno::XComponentContext> xContext) : vcl::RoadmapWizardMachine(pParent) - , m_xChartModel(xChartModel,uno::UNO_QUERY) - , m_xComponentContext(xContext) + , m_xChartModel(xChartModel) + , m_xComponentContext(std::move(xContext)) , m_pTemplateProvider(nullptr) , m_aTimerTriggeredControllerLock(xChartModel) , m_bCanTravel(true) { - m_pDialogModel.reset(new DialogModel(m_xChartModel, m_xComponentContext)); + m_pDialogModel.reset(new DialogModel(m_xChartModel)); defaultButton(WizardButtonFlags::FINISH); setTitleBase(SchResId(STR_DLG_CHART_WIZARD)); @@ -70,9 +72,10 @@ CreationWizard::CreationWizard(weld::Window* pParent, const uno::Reference<frame STATE_OBJECTS }; - declarePath(PATH_FULL, aPath); + declarePath(PathId::COMPLETE, aPath); - SetRoadmapHelpId(HID_SCH_WIZARD_ROADMAP); + // tdf#135935 ensure help ID is set when no element is clicked in the dialog + m_xAssistant->set_help_id(HID_SCH_WIZARD_ROADMAP); if (!m_pDialogModel->getModel().isDataFromSpreadsheet()) { @@ -92,7 +95,7 @@ std::unique_ptr<BuilderPage> CreationWizard::createPage(WizardState nState) { std::unique_ptr<vcl::OWizardPage> xRet; - OString sIdent(OString::number(nState)); + OUString sIdent(OUString::number(nState)); weld::Container* pPageContainer = m_xAssistant->append_page(sIdent); switch( nState ) @@ -171,7 +174,7 @@ void CreationWizard::setValidPage(BuilderPage* pTabPage) OUString CreationWizard::getStateDisplayName( WizardState nState ) const { - const char* pResId = nullptr; + TranslateId pResId; switch( nState ) { case STATE_CHARTTYPE: diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx index 0b2a87cd67c0..694397a83b5f 100644 --- a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx +++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx @@ -19,24 +19,28 @@ #include <dlg_CreationWizard_UNO.hxx> #include <dlg_CreationWizard.hxx> +#include <ChartModel.hxx> #include <servicenames.hxx> #include <TimerTriggeredControllerLock.hxx> +#include <utility> #include <vcl/svapp.hxx> +#include <vcl/weldutils.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/awt/Point.hpp> #include <com/sun/star/awt/Size.hpp> #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/frame/Desktop.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sfx2/viewsh.hxx> + namespace chart { using namespace ::com::sun::star; -CreationWizardUnoDlg::CreationWizardUnoDlg(const uno::Reference<uno::XComponentContext>& xContext) +CreationWizardUnoDlg::CreationWizardUnoDlg(uno::Reference<uno::XComponentContext> xContext) : OComponentHelper(m_aMutex) - , m_xCC(xContext) + , m_xCC(std::move(xContext)) , m_bUnlockControllersOnExecute(false) { uno::Reference< frame::XDesktop2 > xDesktop = frame::Desktop::create(m_xCC); @@ -53,7 +57,7 @@ CreationWizardUnoDlg::~CreationWizardUnoDlg() // lang::XServiceInfo OUString SAL_CALL CreationWizardUnoDlg::getImplementationName() { - return CHART_WIZARD_DIALOG_SERVICE_IMPLEMENTATION_NAME; + return u"com.sun.star.comp.chart2.WizardDialog"_ustr; } sal_Bool SAL_CALL CreationWizardUnoDlg::supportsService( const OUString& rServiceName ) @@ -63,7 +67,7 @@ sal_Bool SAL_CALL CreationWizardUnoDlg::supportsService( const OUString& rServic css::uno::Sequence< OUString > SAL_CALL CreationWizardUnoDlg::getSupportedServiceNames() { - return { CHART_WIZARD_DIALOG_SERVICE_NAME }; + return { u"com.sun.star.chart2.WizardDialog"_ustr }; } // XInterface @@ -165,10 +169,18 @@ void CreationWizardUnoDlg::createDialogOnDemand() m_xParentWindow = xFrame->getContainerWindow(); } } + + weld::Window* pParent(Application::GetFrameWeld(m_xParentWindow)); + if (!pParent) + { + if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(m_xParentWindow.get())) + pParent = dynamic_cast<weld::Window*>(pTunnel->getWidget()); + } + uno::Reference< XComponent > xKeepAlive( this ); if( m_xChartModel.is() ) { - m_xDialog = std::make_shared<CreationWizard>(Application::GetFrameWeld(m_xParentWindow), m_xChartModel, m_xCC); + m_xDialog = std::make_shared<CreationWizard>(pParent, m_xChartModel, m_xCC); } } @@ -218,7 +230,10 @@ void SAL_CALL CreationWizardUnoDlg::initialize( const uno::Sequence< uno::Any >& } else if( aProperty.Name == "ChartModel" ) { - aProperty.Value >>= m_xChartModel; + uno::Reference<XInterface> xInt; + aProperty.Value >>= xInt; + m_xChartModel = dynamic_cast<::chart::ChartModel*>(xInt.get()); + assert(m_xChartModel); } } } @@ -270,10 +285,10 @@ void SAL_CALL CreationWizardUnoDlg::setPropertyValue(const OUString& rPropertyNa else if( rPropertyName == "UnlockControllersOnExecute" ) { if( ! (rValue >>= m_bUnlockControllersOnExecute) ) - throw lang::IllegalArgumentException( "Property 'UnlockControllers' requires value of type boolean" , nullptr, 0 ); + throw lang::IllegalArgumentException( u"Property 'UnlockControllers' requires value of type boolean"_ustr , nullptr, 0 ); } else - throw beans::UnknownPropertyException( "unknown property was tried to set to chart wizard" , nullptr ); + throw beans::UnknownPropertyException( u"unknown property was tried to set to chart wizard"_ustr , nullptr ); } uno::Any SAL_CALL CreationWizardUnoDlg::getPropertyValue( const OUString& rPropertyName ) @@ -310,7 +325,7 @@ uno::Any SAL_CALL CreationWizardUnoDlg::getPropertyValue( const OUString& rPrope aRet <<= m_bUnlockControllersOnExecute; } else - throw beans::UnknownPropertyException( "unknown property was tried to get from chart wizard" , nullptr ); + throw beans::UnknownPropertyException( u"unknown property was tried to get from chart wizard"_ustr , nullptr ); return aRet; } diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx index 3cb9598cb2e9..a62a9d712693 100644 --- a/chart2/source/controller/dialogs/dlg_DataEditor.cxx +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -19,11 +19,10 @@ #include <dlg_DataEditor.hxx> #include "DataBrowser.hxx" -#include <comphelper/stl_types.hxx> +#include <ChartModel.hxx> #include <com/sun/star/awt/XWindow.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/frame/XStorable.hpp> +#include <utility> using namespace ::com::sun::star; using ::com::sun::star::uno::Reference; @@ -32,17 +31,17 @@ namespace chart { DataEditor::DataEditor(weld::Window* pParent, - const Reference< chart2::XChartDocument > & xChartDoc, + rtl::Reference<::chart::ChartModel> xChartDoc, const Reference< uno::XComponentContext > & xContext) - : GenericDialogController(pParent, "modules/schart/ui/chartdatadialog.ui", "ChartDataDialog") + : GenericDialogController(pParent, u"modules/schart/ui/chartdatadialog.ui"_ustr, u"ChartDataDialog"_ustr) , m_bReadOnly(false) - , m_xChartDoc(xChartDoc) + , m_xChartDoc(std::move(xChartDoc)) , m_xContext(xContext) - , m_xTbxData(m_xBuilder->weld_toolbar("toolbar")) - , m_xCloseBtn(m_xBuilder->weld_button("close")) - , m_xTable(m_xBuilder->weld_container("datawindow")) - , m_xColumns(m_xBuilder->weld_container("columns")) - , m_xColors(m_xBuilder->weld_container("colorcolumns")) + , m_xTbxData(m_xBuilder->weld_toolbar(u"toolbar"_ustr)) + , m_xCloseBtn(m_xBuilder->weld_button(u"close"_ustr)) + , m_xTable(m_xBuilder->weld_container(u"datawindow"_ustr)) + , m_xColumns(m_xBuilder->weld_container(u"columns"_ustr)) + , m_xColors(m_xBuilder->weld_container(u"colorcolumns"_ustr)) , m_xTableCtrlParent(m_xTable->CreateChildFrame()) , m_xBrwData(VclPtr<DataBrowser>::Create(m_xTableCtrlParent, m_xColumns.get(), m_xColors.get())) { @@ -57,13 +56,12 @@ DataEditor::DataEditor(weld::Window* pParent, m_xBrwData->SetCursorMovedHdl( LINK( this, DataEditor, BrowserCursorMovedHdl )); - m_xBrwData->SetDataFromModel( m_xChartDoc, m_xContext ); + m_xBrwData->SetDataFromModel( m_xChartDoc ); m_xBrwData->GrabFocus(); bool bReadOnly = true; - Reference< frame::XStorable > xStor( m_xChartDoc, uno::UNO_QUERY ); - if( xStor.is()) - bReadOnly = xStor->isReadonly(); + if( m_xChartDoc.is()) + bReadOnly = m_xChartDoc->isReadonly(); SetReadOnly( bReadOnly ); } @@ -75,7 +73,7 @@ DataEditor::~DataEditor() } // react on click (or keypress) on toolbar icon -IMPL_LINK(DataEditor, ToolboxHdl, const OString&, rId, void) +IMPL_LINK(DataEditor, ToolboxHdl, const OUString&, rId, void) { if (rId == "InsertRow") m_xBrwData->InsertRow(); @@ -105,16 +103,16 @@ IMPL_LINK_NOARG(DataEditor, BrowserCursorMovedHdl, DataBrowser*, void) bool bIsDataValid = m_xBrwData->IsEnableItem(); - m_xTbxData->set_item_sensitive("InsertRow", bIsDataValid && m_xBrwData->MayInsertRow() ); - m_xTbxData->set_item_sensitive("InsertColumn", bIsDataValid && m_xBrwData->MayInsertColumn() ); - m_xTbxData->set_item_sensitive("InsertTextColumn", bIsDataValid && m_xBrwData->MayInsertColumn() ); - m_xTbxData->set_item_sensitive("RemoveRow", m_xBrwData->MayDeleteRow() ); - m_xTbxData->set_item_sensitive("RemoveColumn", m_xBrwData->MayDeleteColumn() ); + m_xTbxData->set_item_sensitive(u"InsertRow"_ustr, bIsDataValid && m_xBrwData->MayInsertRow() ); + m_xTbxData->set_item_sensitive(u"InsertColumn"_ustr, bIsDataValid && m_xBrwData->MayInsertColumn() ); + m_xTbxData->set_item_sensitive(u"InsertTextColumn"_ustr, bIsDataValid && m_xBrwData->MayInsertColumn() ); + m_xTbxData->set_item_sensitive(u"RemoveRow"_ustr, m_xBrwData->MayDeleteRow() ); + m_xTbxData->set_item_sensitive(u"RemoveColumn"_ustr, m_xBrwData->MayDeleteColumn() ); - m_xTbxData->set_item_sensitive("MoveLeftColumn", bIsDataValid && m_xBrwData->MayMoveLeftColumns() ); - m_xTbxData->set_item_sensitive("MoveRightColumn", bIsDataValid && m_xBrwData->MayMoveRightColumns() ); - m_xTbxData->set_item_sensitive("MoveUpRow", bIsDataValid && m_xBrwData->MayMoveDownRows() ); - m_xTbxData->set_item_sensitive("MoveDownRow", bIsDataValid && m_xBrwData->MayMoveUpRows() ); + m_xTbxData->set_item_sensitive(u"MoveLeftColumn"_ustr, bIsDataValid && m_xBrwData->MayMoveLeftColumns() ); + m_xTbxData->set_item_sensitive(u"MoveRightColumn"_ustr, bIsDataValid && m_xBrwData->MayMoveRightColumns() ); + m_xTbxData->set_item_sensitive(u"MoveDownRow"_ustr, bIsDataValid && m_xBrwData->MayMoveDownRows() ); + m_xTbxData->set_item_sensitive(u"MoveUpRow"_ustr, bIsDataValid && m_xBrwData->MayMoveUpRows() ); } // disable all modifying controls @@ -123,15 +121,15 @@ void DataEditor::SetReadOnly( bool bReadOnly ) m_bReadOnly = bReadOnly; if( m_bReadOnly ) { - m_xTbxData->set_item_sensitive("InsertRow", false); - m_xTbxData->set_item_sensitive("InsertColumn", false); - m_xTbxData->set_item_sensitive("InsertTextColumn", false); - m_xTbxData->set_item_sensitive("RemoveRow", false); - m_xTbxData->set_item_sensitive("RemoveColumn", false); - m_xTbxData->set_item_sensitive("MoveLeftColumn", false); - m_xTbxData->set_item_sensitive("MoveRightColumn", false); - m_xTbxData->set_item_sensitive("MoveUpRow", false); - m_xTbxData->set_item_sensitive("MoveDownRow", false); + m_xTbxData->set_item_sensitive(u"InsertRow"_ustr, false); + m_xTbxData->set_item_sensitive(u"InsertColumn"_ustr, false); + m_xTbxData->set_item_sensitive(u"InsertTextColumn"_ustr, false); + m_xTbxData->set_item_sensitive(u"RemoveRow"_ustr, false); + m_xTbxData->set_item_sensitive(u"RemoveColumn"_ustr, false); + m_xTbxData->set_item_sensitive(u"MoveLeftColumn"_ustr, false); + m_xTbxData->set_item_sensitive(u"MoveRightColumn"_ustr, false); + m_xTbxData->set_item_sensitive(u"MoveUpRow"_ustr, false); + m_xTbxData->set_item_sensitive(u"MoveDownRow"_ustr, false); } m_xBrwData->SetReadOnly( m_bReadOnly ); diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx index b196b24d98d8..c00698fef60d 100644 --- a/chart2/source/controller/dialogs/dlg_DataSource.cxx +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -18,22 +18,20 @@ */ #include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <dlg_DataSource.hxx> #include <ChartTypeTemplateProvider.hxx> -#include <DiagramHelper.hxx> +#include <ChartTypeTemplate.hxx> +#include <Diagram.hxx> #include "DialogModel.hxx" +#include <ChartModel.hxx> #include "tp_RangeChooser.hxx" #include "tp_DataSource.hxx" using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; using namespace ::chart; -using ::com::sun::star::uno::Reference; - namespace chart { @@ -43,36 +41,33 @@ class DocumentChartTypeTemplateProvider : public ChartTypeTemplateProvider { public: explicit DocumentChartTypeTemplateProvider( - const Reference< chart2::XChartDocument > & xDoc ); + const rtl::Reference<::chart::ChartModel> & xDoc ); // ____ ChartTypeTemplateProvider ____ - virtual Reference< chart2::XChartTypeTemplate > getCurrentTemplate() const override; + virtual rtl::Reference< ::chart::ChartTypeTemplate > getCurrentTemplate() const override; private: - Reference< chart2::XChartTypeTemplate > m_xTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > m_xTemplate; }; } DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider( - const Reference< chart2::XChartDocument > & xDoc ) + const rtl::Reference<::chart::ChartModel> & xDoc ) { if( !xDoc.is()) return; - Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram()); + rtl::Reference< Diagram > xDia( xDoc->getFirstChartDiagram()); if( xDia.is()) { - DiagramHelper::tTemplateWithServiceName aResult( - DiagramHelper::getTemplateForDiagram( - xDia, - Reference< lang::XMultiServiceFactory >( - xDoc->getChartTypeManager(), uno::UNO_QUERY ) )); - m_xTemplate.set( aResult.first ); + Diagram::tTemplateWithServiceName aResult( + xDia->getTemplate( xDoc->getTypeManager() )); + m_xTemplate = aResult.xChartTypeTemplate; } } -Reference< chart2::XChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const +rtl::Reference< ::chart::ChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const { return m_xTemplate; } @@ -80,26 +75,26 @@ Reference< chart2::XChartTypeTemplate > DocumentChartTypeTemplateProvider::getCu sal_uInt16 DataSourceDialog::m_nLastPageId = 0; DataSourceDialog::DataSourceDialog(weld::Window * pParent, - const Reference< XChartDocument > & xChartDocument, - const Reference< uno::XComponentContext > & xContext) - : GenericDialogController(pParent, "modules/schart/ui/datarangedialog.ui", - "DataRangeDialog") + const rtl::Reference<::chart::ChartModel> & xChartDocument) + : GenericDialogController(pParent, u"modules/schart/ui/datarangedialog.ui"_ustr, + u"DataRangeDialog"_ustr) , m_apDocTemplateProvider(new DocumentChartTypeTemplateProvider(xChartDocument)) - , m_apDialogModel(new DialogModel(xChartDocument, xContext)) + , m_apDialogModel(new DialogModel(xChartDocument)) , m_bRangeChooserTabIsValid(true) , m_bDataSourceTabIsValid(true) , m_bTogglingEnabled(true) - , m_xTabControl(m_xBuilder->weld_notebook("tabcontrol")) - , m_xBtnOK(m_xBuilder->weld_button("ok")) + , m_xTabControl(m_xBuilder->weld_notebook(u"tabcontrol"_ustr)) + , m_xBtnOK(m_xBuilder->weld_button(u"ok"_ustr)) { - m_xRangeChooserTabPage = std::make_unique<RangeChooserTabPage>(m_xTabControl->get_page("range"), this, + m_xRangeChooserTabPage = std::make_unique<RangeChooserTabPage>(m_xTabControl->get_page(u"range"_ustr), this, *m_apDialogModel, m_apDocTemplateProvider.get(), true /* bHideDescription */ ); - m_xDataSourceTabPage = std::make_unique<DataSourceTabPage>(m_xTabControl->get_page("series"), this, + m_xDataSourceTabPage = std::make_unique<DataSourceTabPage>(m_xTabControl->get_page(u"series"_ustr), this, *m_apDialogModel, m_apDocTemplateProvider.get(), true /* bHideDescription */ ); m_xTabControl->connect_enter_page(LINK(this, DataSourceDialog, ActivatePageHdl)); m_xTabControl->connect_leave_page(LINK(this, DataSourceDialog, DeactivatePageHdl)); + m_xBtnOK->connect_clicked(LINK(this, DataSourceDialog, OkHdl)); ActivatePageHdl(m_xTabControl->get_current_page_ident()); if (m_nLastPageId != 0) { @@ -115,20 +110,21 @@ DataSourceDialog::~DataSourceDialog() m_nLastPageId = m_xTabControl->get_current_page(); } -short DataSourceDialog::run() +void DataSourceDialog::commitPages() { - short nResult = GenericDialogController::run(); - if( nResult == RET_OK ) - { - if( m_xRangeChooserTabPage ) - m_xRangeChooserTabPage->commitPage(); - if( m_xDataSourceTabPage ) - m_xDataSourceTabPage->commitPage(); - } - return nResult; + if (m_xRangeChooserTabPage) + m_xRangeChooserTabPage->commitPage(); + if (m_xDataSourceTabPage) + m_xDataSourceTabPage->commitPage(); +} + +IMPL_LINK_NOARG(DataSourceDialog, OkHdl, weld::Button&, void) +{ + commitPages(); + m_xDialog->response(RET_OK); } -IMPL_LINK(DataSourceDialog, ActivatePageHdl, const OString&, rPage, void) +IMPL_LINK(DataSourceDialog, ActivatePageHdl, const OUString&, rPage, void) { if (rPage == "range") m_xRangeChooserTabPage->Activate(); @@ -137,7 +133,7 @@ IMPL_LINK(DataSourceDialog, ActivatePageHdl, const OString&, rPage, void) } // allow/disallow user to leave page -IMPL_LINK_NOARG(DataSourceDialog, DeactivatePageHdl, const OString&, bool) +IMPL_LINK_NOARG(DataSourceDialog, DeactivatePageHdl, const OUString&, bool) { return m_bTogglingEnabled; } diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx index 3843263ad664..0fcdcaf164a9 100644 --- a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx @@ -23,14 +23,9 @@ namespace chart { InsertAxisOrGridDialogData::InsertAxisOrGridDialogData() - : aPossibilityList(6) - , aExistenceList(6) + : aPossibilityList{ true, true, true, true, true, true } + , aExistenceList{ false, false, false, false, false, false } { - sal_Int32 nN = 0; - for(nN=6;nN--;) - aPossibilityList[nN]=true; - for(nN=6;nN--;) - aExistenceList[nN]=false; } // SchAxisDlg @@ -39,17 +34,17 @@ SchAxisDlg::SchAxisDlg(weld::Window* pWindow, const InsertAxisOrGridDialogData& rInput, bool bAxisDlg) : GenericDialogController(pWindow, bAxisDlg ? - OUString("modules/schart/ui/insertaxisdlg.ui") : - OUString("modules/schart/ui/insertgriddlg.ui"), + u"modules/schart/ui/insertaxisdlg.ui"_ustr : + u"modules/schart/ui/insertgriddlg.ui"_ustr, bAxisDlg ? - OString("InsertAxisDialog") : - OString("InsertGridDialog")) - , m_xCbPrimaryX(m_xBuilder->weld_check_button("primaryX")) - , m_xCbPrimaryY(m_xBuilder->weld_check_button("primaryY")) - , m_xCbPrimaryZ(m_xBuilder->weld_check_button("primaryZ")) - , m_xCbSecondaryX(m_xBuilder->weld_check_button("secondaryX")) - , m_xCbSecondaryY(m_xBuilder->weld_check_button("secondaryY")) - , m_xCbSecondaryZ(m_xBuilder->weld_check_button("secondaryZ")) + u"InsertAxisDialog"_ustr : + u"InsertGridDialog"_ustr) + , m_xCbPrimaryX(m_xBuilder->weld_check_button(u"primaryX"_ustr)) + , m_xCbPrimaryY(m_xBuilder->weld_check_button(u"primaryY"_ustr)) + , m_xCbPrimaryZ(m_xBuilder->weld_check_button(u"primaryZ"_ustr)) + , m_xCbSecondaryX(m_xBuilder->weld_check_button(u"secondaryX"_ustr)) + , m_xCbSecondaryY(m_xBuilder->weld_check_button(u"secondaryY"_ustr)) + , m_xCbSecondaryZ(m_xBuilder->weld_check_button(u"secondaryZ"_ustr)) { if (bAxisDlg) { @@ -74,12 +69,13 @@ SchAxisDlg::SchAxisDlg(weld::Window* pWindow, void SchAxisDlg::getResult( InsertAxisOrGridDialogData& rOutput ) { - rOutput.aExistenceList[0]=m_xCbPrimaryX->get_active(); - rOutput.aExistenceList[1]=m_xCbPrimaryY->get_active(); - rOutput.aExistenceList[2]=m_xCbPrimaryZ->get_active(); - rOutput.aExistenceList[3]=m_xCbSecondaryX->get_active(); - rOutput.aExistenceList[4]=m_xCbSecondaryY->get_active(); - rOutput.aExistenceList[5]=m_xCbSecondaryZ->get_active(); + sal_Bool* pExistenceList = rOutput.aExistenceList.getArray(); + pExistenceList[0]=m_xCbPrimaryX->get_active(); + pExistenceList[1]=m_xCbPrimaryY->get_active(); + pExistenceList[2]=m_xCbPrimaryZ->get_active(); + pExistenceList[3]=m_xCbSecondaryX->get_active(); + pExistenceList[4]=m_xCbSecondaryY->get_active(); + pExistenceList[5]=m_xCbSecondaryZ->get_active(); } SchGridDlg::SchGridDlg(weld::Window* pParent, const InsertAxisOrGridDialogData& rInput) diff --git a/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx index 57817d883d66..c917e4f0fb82 100644 --- a/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx @@ -24,7 +24,7 @@ namespace chart { DataLabelsDialog::DataLabelsDialog(weld::Window* pWindow, const SfxItemSet& rInAttrs, SvNumberFormatter* pFormatter) - : GenericDialogController(pWindow, "modules/schart/ui/dlg_DataLabel.ui", "dlg_DataLabels") + : GenericDialogController(pWindow, u"modules/schart/ui/dlg_DataLabel.ui"_ustr, u"dlg_DataLabels"_ustr) , m_apDataLabelResources(new DataLabelResources(m_xBuilder.get(), pWindow, rInAttrs)) { m_apDataLabelResources->SetNumberFormatter( pFormatter ); diff --git a/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx new file mode 100644 index 000000000000..a2adef7c0f1a --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertDataTable.cxx @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <dlg_InsertDataTable.hxx> + +namespace chart +{ +InsertDataTableDialog::InsertDataTableDialog(weld::Window* pWindow) + : GenericDialogController(pWindow, u"modules/schart/ui/dlg_InsertDataTable.ui"_ustr, + u"InsertDataTableDialog"_ustr) + , m_aDataTablePropertiesResources(*m_xBuilder) + , m_xCbShowDataTable(m_xBuilder->weld_check_button(u"showDataTable"_ustr)) +{ + m_xCbShowDataTable->connect_toggled(LINK(this, InsertDataTableDialog, ShowDataTableToggle)); + init(m_aData); +} + +IMPL_LINK_NOARG(InsertDataTableDialog, ShowDataTableToggle, weld::Toggleable&, void) +{ + changeEnabled(); +} + +void InsertDataTableDialog::changeEnabled() +{ + bool bEnable = m_xCbShowDataTable->get_active(); + m_aDataTablePropertiesResources.setChecksSensitive(bEnable); + m_aData.mbShow = bEnable; +} + +void InsertDataTableDialog::init(DataTableDialogData const& rData) +{ + m_aData = rData; + m_aDataTablePropertiesResources.setHorizontalBorder(m_aData.mbHorizontalBorders); + m_aDataTablePropertiesResources.setVerticalBorder(m_aData.mbVerticalBorders); + m_aDataTablePropertiesResources.setOutline(m_aData.mbOutline); + m_aDataTablePropertiesResources.setKeys(m_aData.mbKeys); + m_xCbShowDataTable->set_active(m_aData.mbShow); + changeEnabled(); +} + +DataTableDialogData& InsertDataTableDialog::getDataTableDialogData() +{ + m_aData.mbShow = m_xCbShowDataTable->get_active(); + + m_aData.mbHorizontalBorders = m_aDataTablePropertiesResources.getHorizontalBorder(); + m_aData.mbVerticalBorders = m_aDataTablePropertiesResources.getVerticalBorder(); + m_aData.mbOutline = m_aDataTablePropertiesResources.getOutline(); + m_aData.mbKeys = m_aDataTablePropertiesResources.getKeys(); + + return m_aData; +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx index a7aeb35d72d6..9b098feb1b09 100644 --- a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -20,17 +20,15 @@ #include <dlg_InsertErrorBars.hxx> #include <res_ErrorBar.hxx> #include <chartview/ExplicitScaleValues.hxx> -#include <chartview/ExplicitValueProvider.hxx> -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <ChartView.hxx> #include <ObjectIdentifier.hxx> -#include <DiagramHelper.hxx> +#include <Diagram.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <ObjectNameProvider.hxx> +#include <DataSeries.hxx> -#include <com/sun/star/frame/XModel.hpp> -#include <comphelper/servicehelper.hxx> - -using ::com::sun::star::uno::Reference; using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -39,9 +37,9 @@ namespace chart InsertErrorBarsDialog::InsertErrorBarsDialog( weld::Window* pParent, const SfxItemSet& rMyAttrs, - const uno::Reference< chart2::XChartDocument > & xChartDocument, + const rtl::Reference<::chart::ChartModel> & xChartDocument, ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ ) - : GenericDialogController(pParent, "modules/schart/ui/dlg_InsertErrorBars.ui", "dlg_InsertErrorBars") + : GenericDialogController(pParent, u"modules/schart/ui/dlg_InsertErrorBars.ui"_ustr, u"dlg_InsertErrorBars"_ustr) , m_apErrorBarResources( new ErrorBarResources( m_xBuilder.get(), this, rMyAttrs, /* bNoneAvailable = */ true, eType )) @@ -64,19 +62,18 @@ void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMi } double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( - const Reference< frame::XModel >& xChartModel, - const Reference< uno::XInterface >& xChartView, - const OUString& rSelectedObjectCID ) + const rtl::Reference<::chart::ChartModel>& xChartModel, + const rtl::Reference<::chart::ChartView>& xChartView, + std::u16string_view rSelectedObjectCID ) { double fStepWidth = 0.001; - ExplicitValueProvider* pExplicitValueProvider( comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(xChartView) ); + ChartView* pExplicitValueProvider( xChartView.get() ); if( pExplicitValueProvider ) { - Reference< XAxis > xAxis; - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel ); - xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel ); + rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries ); if(!xAxis.is()) xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram ); if(xAxis.is()) diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx index f718366d7c8b..919a99ba1ffc 100644 --- a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx @@ -25,17 +25,18 @@ namespace chart using namespace ::com::sun::star; SchLegendDlg::SchLegendDlg(weld::Window* pWindow, const uno::Reference<uno::XComponentContext>& xCC) - : GenericDialogController(pWindow, "modules/schart/ui/dlg_InsertLegend.ui", "dlg_InsertLegend") + : GenericDialogController(pWindow, u"modules/schart/ui/dlg_InsertLegend.ui"_ustr, + u"dlg_InsertLegend"_ustr) , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xCC)) { } -void SchLegendDlg::init(const uno::Reference<frame::XModel>& xChartModel) +void SchLegendDlg::init(const rtl::Reference<::chart::ChartModel>& xChartModel) { m_xLegendPositionResources->writeToResources(xChartModel); } -void SchLegendDlg::writeToModel(const uno::Reference<frame::XModel>& xChartModel) const +void SchLegendDlg::writeToModel(const rtl::Reference<::chart::ChartModel>& xChartModel) const { m_xLegendPositionResources->writeToModel(xChartModel); } diff --git a/chart2/source/controller/dialogs/dlg_InsertTitle.cxx b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx index 03f942945823..5e96f9ae9c73 100644 --- a/chart2/source/controller/dialogs/dlg_InsertTitle.cxx +++ b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx @@ -24,7 +24,8 @@ namespace chart { SchTitleDlg::SchTitleDlg(weld::Window* pWindow, const TitleDialogData& rInput) - : GenericDialogController(pWindow, "modules/schart/ui/inserttitledlg.ui", "InsertTitleDialog") + : GenericDialogController(pWindow, u"modules/schart/ui/inserttitledlg.ui"_ustr, + u"InsertTitleDialog"_ustr) , m_xTitleResources(new TitleResources(*m_xBuilder, true)) { m_xDialog->set_title(ObjectNameProvider::getName(OBJECTTYPE_TITLE, true)); diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx index 3ba1bf68163f..968c437c049e 100644 --- a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx @@ -29,14 +29,15 @@ namespace chart { using namespace ::com::sun::star; -NumberFormatDialog::NumberFormatDialog(weld::Window* pParent, SfxItemSet& rSet) - : SfxSingleTabDialogController(pParent, &rSet, "cui/ui/formatnumberdialog.ui", "FormatNumberDialog") +NumberFormatDialog::NumberFormatDialog(weld::Window* pParent, const SfxItemSet& rSet) + : SfxSingleTabDialogController(pParent, &rSet, u"cui/ui/formatnumberdialog.ui"_ustr, u"FormatNumberDialog"_ustr) + , m_xContent( m_xBuilder->weld_container(u"content"_ustr) ) { SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ); if (fnCreatePage) { - std::unique_ptr<SfxTabPage> xTabPage = (*fnCreatePage)(get_content_area(), this, &rSet); + std::unique_ptr<SfxTabPage> xTabPage = (*fnCreatePage)(m_xContent.get(), this, &rSet); xTabPage->PageCreated(rSet); SetTabPage(std::move(xTabPage)); } @@ -48,7 +49,7 @@ SfxItemSet NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( SfxItemP SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, - SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE>{} ); + SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE> ); } } //namespace chart diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.hxx b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx index 3cb5107158b8..2bb84696ac57 100644 --- a/chart2/source/controller/dialogs/dlg_NumberFormat.hxx +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx @@ -20,10 +20,6 @@ #include <sfx2/basedlgs.hxx> -namespace weld -{ -class Window; -} class SfxItemSet; class SfxItemPool; @@ -31,8 +27,10 @@ namespace chart { class NumberFormatDialog : public SfxSingleTabDialogController { + std::unique_ptr<weld::Container> m_xContent; + public: - NumberFormatDialog(weld::Window* pParent, SfxItemSet& rSet); + NumberFormatDialog(weld::Window* pParent, const SfxItemSet& rSet); static SfxItemSet CreateEmptyItemSetForNumberFormatDialog(SfxItemPool& rItemPool); }; diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx index b941deab6ab9..8148bd6b880a 100644 --- a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include <dlg_ObjectProperties.hxx> #include <strings.hrc> #include "tp_AxisLabel.hxx" @@ -31,23 +35,29 @@ #include "tp_TitleRotation.hxx" #include "tp_PolarOptions.hxx" #include "tp_DataPointOption.hxx" +#include "tp_DataTable.hxx" +#include "tp_ChartColorPalette.hxx" #include <ResId.hxx> #include <ViewElementListProvider.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <ObjectNameProvider.hxx> +#include <DataSeries.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <NumberFormatterWrapper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <ExplicitCategoriesProvider.hxx> #include <ChartModel.hxx> #include <CommonConverters.hxx> #include <RegressionCalculationHelper.hxx> +#include <BaseCoordinateSystem.hxx> #include <com/sun/star/chart2/AxisType.hpp> #include <com/sun/star/chart2/XAxis.hpp> #include <svl/intitem.hxx> -#include <svl/languageoptions.hxx> +#include <svl/ctloptions.hxx> #include <svx/svxids.hrc> @@ -62,10 +72,8 @@ #include <svx/numinf.hxx> #include <svl/cjkoptions.hxx> -#include <tools/diagnose_ex.h> - -namespace com::sun::star::chart2 { class XChartType; } -namespace com::sun::star::chart2 { class XDataSeries; } +#include <utility> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -77,11 +85,10 @@ using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Exception; using ::com::sun::star::beans::XPropertySet; -ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const OUString& rObjectCID ) - : m_aObjectCID( rObjectCID ) +ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( OUString aObjectCID ) + : m_aObjectCID(std::move( aObjectCID )) , m_eObjectType( ObjectIdentifier::getObjectType( m_aObjectCID ) ) , m_bAffectsMultipleObjects(false) - , m_aLocalizedName() , m_bHasGeometryProperties(false) , m_bHasStatisticProperties(false) , m_bProvidesSecondaryYAxis(false) @@ -99,42 +106,43 @@ ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const OUString , m_bShowAxisOrigin(false) , m_bIsCrossingAxisIsCategoryAxis(false) , m_bSupportingCategoryPositioning(false) - , m_aCategories() , m_bComplexCategoriesAxis( false ) , m_nNbPoints( 0 ) { - OUString aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); - m_bAffectsMultipleObjects = (aParticleID == "ALLELEMENTS"); + std::u16string_view aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); + m_bAffectsMultipleObjects = (aParticleID == u"ALLELEMENTS"); } ObjectPropertiesDialogParameter::~ObjectPropertiesDialogParameter() { } -void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel >& xChartModel ) +void ObjectPropertiesDialogParameter::init( const rtl::Reference<::chart::ChartModel>& xChartModel ) { - m_xChartDocument.set( xChartModel, uno::UNO_QUERY ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel ); - uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + m_xChartDocument = xChartModel; + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aObjectCID, xChartModel ); + rtl::Reference< ChartType > xChartType = xChartModel->getChartTypeOfSeries( xSeries ); + sal_Int32 nDimensionCount = 0; + if (xDiagram) + nDimensionCount = xDiagram->getDimension(); bool bHasSeriesProperties = (m_eObjectType==OBJECTTYPE_DATA_SERIES); bool bHasDataPointproperties = (m_eObjectType==OBJECTTYPE_DATA_POINT); if( bHasSeriesProperties || bHasDataPointproperties ) { - m_bHasGeometryProperties = ChartTypeHelper::isSupportingGeometryProperties( xChartType, nDimensionCount ); - m_bHasAreaProperties = ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ); - m_bHasSymbolProperties = ChartTypeHelper::isSupportingSymbolProperties( xChartType, nDimensionCount ); - m_bIsPieChartDataPoint = bHasDataPointproperties && ChartTypeHelper::isSupportingStartingAngle( xChartType ); + m_bHasGeometryProperties = xChartType->isSupportingGeometryProperties(nDimensionCount ); + m_bHasAreaProperties = xChartType->isSupportingAreaProperties(nDimensionCount); + m_bHasSymbolProperties = xChartType->isSupportingSymbolProperties(nDimensionCount); + m_bIsPieChartDataPoint = bHasDataPointproperties && xChartType->isSupportingStartingAngle(); if( bHasSeriesProperties ) { - m_bHasStatisticProperties = ChartTypeHelper::isSupportingStatisticProperties( xChartType, nDimensionCount ); - m_bProvidesSecondaryYAxis = ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ); - m_bProvidesOverlapAndGapWidth = ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, nDimensionCount ); - m_bProvidesBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount ); - m_bProvidesStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType ); + m_bHasStatisticProperties = xChartType->isSupportingStatisticProperties(nDimensionCount); + m_bProvidesSecondaryYAxis = xChartType->isSupportingSecondaryAxis(nDimensionCount); + m_bProvidesOverlapAndGapWidth = xChartType->isSupportingOverlapAndGapWidthProperties(nDimensionCount); + m_bProvidesBarConnectors = xChartType->isSupportingBarConnectors(nDimensionCount); + m_bProvidesStartingAngle = xChartType->isSupportingStartingAngle(); m_bProvidesMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) .hasElements(); @@ -153,7 +161,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel if( m_bHasScaleProperties ) { - uno::Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( m_aObjectCID, xChartModel ) ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aObjectCID, xChartModel ); if( xAxis.is() ) { //no scale page for series axis @@ -164,17 +172,16 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel m_bHasNumberProperties = true; //is the crossing main axis a category axes?: - uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) ); - uno::Reference< XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) ); + rtl::Reference< Axis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ) ); if( xCrossingMainAxis.is() ) { ScaleData aScale( xCrossingMainAxis->getScaleData() ); m_bIsCrossingAxisIsCategoryAxis = ( aScale.AxisType == chart2::AxisType::CATEGORY ); if( m_bIsCrossingAxisIsCategoryAxis ) { - ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get()); - if (pModel) - m_aCategories = DiagramHelper::getExplicitSimpleCategories( *pModel ); + if (xChartModel) + m_aCategories = DiagramHelper::getExplicitSimpleCategories( *xChartModel ); } } @@ -185,23 +192,22 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel { xChartType = AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( xDiagram, nAxisIndex ); //show positioning controls only if they make sense - m_bSupportingAxisPositioning = ChartTypeHelper::isSupportingAxisPositioning( xChartType, nDimensionCount, nDimensionIndex ); + m_bSupportingAxisPositioning = xChartType->isSupportingAxisPositioning(nDimensionCount, nDimensionIndex); //show axis origin only for secondary y axis - if( nDimensionIndex==1 && nAxisIndex==1 && ChartTypeHelper::isSupportingBaseValue( xChartType ) ) + if( nDimensionIndex==1 && nAxisIndex==1 && xChartType->isSupportingBaseValue()) m_bShowAxisOrigin = true; if ( nDimensionIndex == 0 && ( aData.AxisType == chart2::AxisType::CATEGORY || aData.AxisType == chart2::AxisType::DATE ) ) { - ChartModel* pModel = dynamic_cast<ChartModel*>(xChartModel.get()); - if (pModel) + if (xChartModel) { - ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, *pModel ); + ExplicitCategoriesProvider aExplicitCategoriesProvider( xCooSys, *xChartModel ); m_bComplexCategoriesAxis = aExplicitCategoriesProvider.hasComplexCategories(); } if (!m_bComplexCategoriesAxis) - m_bSupportingCategoryPositioning = ChartTypeHelper::isSupportingCategoryPositioning( xChartType, nDimensionCount ); + m_bSupportingCategoryPositioning = xChartType->isSupportingCategoryPositioning(nDimensionCount); } } } @@ -213,14 +219,12 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel if( m_eObjectType == OBJECTTYPE_DATA_CURVE ) { - uno::Reference< data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); - Sequence< Reference< data::XLabeledDataSequence > > aDataSeqs( xSource->getDataSequences()); + const std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > & aDataSeqs( xSeries->getDataSequences2()); Sequence< double > aXValues, aYValues; bool bXValuesFound = false, bYValuesFound = false; m_nNbPoints = 0; - sal_Int32 i = 0; - for( i=0; - ! (bXValuesFound && bYValuesFound) && i<aDataSeqs.getLength(); + for( std::size_t i=0; + ! (bXValuesFound && bYValuesFound) && i<aDataSeqs.size(); ++i ) { try @@ -228,7 +232,7 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel Reference< data::XDataSequence > xSeq( aDataSeqs[i]->getValues()); Reference< XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW ); OUString aRole; - if( xProp->getPropertyValue( "Role" ) >>= aRole ) + if( xProp->getPropertyValue( u"Role"_ustr ) >>= aRole ) { if( !bXValuesFound && aRole == "values-x" ) { @@ -252,8 +256,9 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel // initialize with 1, 2, ... //first category (index 0) matches with real number 1.0 aXValues.realloc( aYValues.getLength() ); - for( i=0; i<aXValues.getLength(); ++i ) - aXValues[i] = i+1; + auto pXValues = aXValues.getArray(); + for( sal_Int32 i=0; i<aXValues.getLength(); ++i ) + pXValues[i] = i+1; bXValuesFound = true; } @@ -309,11 +314,11 @@ void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel const sal_uInt16 nNoArrowNoShadowDlg = 1101; -void SchAttribTabDlg::setSymbolInformation( std::unique_ptr<SfxItemSet> pSymbolShapeProperties, - std::unique_ptr<Graphic> pAutoSymbolGraphic ) +void SchAttribTabDlg::setSymbolInformation( SfxItemSet&& rSymbolShapeProperties, + std::optional<Graphic> oAutoSymbolGraphic ) { - m_pSymbolShapeProperties = std::move(pSymbolShapeProperties); - m_pAutoSymbolGraphic = std::move(pAutoSymbolGraphic); + m_oSymbolShapeProperties.emplace(std::move(rSymbolShapeProperties)); + m_oAutoSymbolGraphic = std::move(oAutoSymbolGraphic); } void SchAttribTabDlg::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ) @@ -326,7 +331,7 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, const ObjectPropertiesDialogParameter* pDialogParameter, const ViewElementListProvider* pViewElementListProvider, const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier) - : SfxTabDialogController(pParent, "modules/schart/ui/attributedialog.ui", "AttributeDialog", pAttr) + : SfxTabDialogController(pParent, u"modules/schart/ui/attributedialog.ui"_ustr, u"AttributeDialog"_ustr, pAttr) , m_pParameter( pDialogParameter ) , m_pViewElementListProvider( pViewElementListProvider ) , m_pNumberFormatter(nullptr) @@ -338,60 +343,61 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, m_xDialog->set_title(pDialogParameter->getLocalizedName()); - SvtCJKOptions aCJKOptions; - - switch (pDialogParameter->getObjectType()) + ObjectType eType = pDialogParameter->getObjectType(); + switch (eType) { case OBJECTTYPE_TITLE: - AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); - AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); - AddTabPage("transparent", SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); - AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); - AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); - AddTabPage("alignment", SchResId(STR_PAGE_ALIGNMENT), SchAlignmentTabPage::Create); - if( aCJKOptions.IsAsianTypographyEnabled() ) - AddTabPage("asian", SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + AddTabPage(u"alignment"_ustr, SchResId(STR_PAGE_ALIGNMENT), SchAlignmentTabPage::Create); + if( SvtCJKOptions::IsAsianTypographyEnabled() ) + AddTabPage(u"asian"_ustr, SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); break; case OBJECTTYPE_LEGEND: - AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); - AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); - AddTabPage("transparent", SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); - AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); - AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); - AddTabPage("legendpos", SchResId(STR_PAGE_POSITION), SchLegendPosTabPage::Create); - if (aCJKOptions.IsAsianTypographyEnabled()) - AddTabPage("asian", SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + AddTabPage(u"legendpos"_ustr, SchResId(STR_PAGE_POSITION), SchLegendPosTabPage::Create); + if (SvtCJKOptions::IsAsianTypographyEnabled()) + AddTabPage(u"asian"_ustr, SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); break; case OBJECTTYPE_DATA_SERIES: case OBJECTTYPE_DATA_POINT: if( m_pParameter->ProvidesSecondaryYAxis() || m_pParameter->ProvidesOverlapAndGapWidth() || m_pParameter->ProvidesMissingValueTreatments() ) - AddTabPage("options", SchResId(STR_PAGE_OPTIONS),SchOptionTabPage::Create); + AddTabPage(u"options"_ustr, SchResId(STR_PAGE_OPTIONS),SchOptionTabPage::Create); if( m_pParameter->ProvidesStartingAngle()) - AddTabPage("polaroptions", SchResId(STR_PAGE_OPTIONS), PolarOptionsTabPage::Create); + AddTabPage(u"polaroptions"_ustr, SchResId(STR_PAGE_OPTIONS), PolarOptionsTabPage::Create); if (m_pParameter->IsPieChartDataPoint()) - AddTabPage("datapointoption", SchResId(STR_PAGE_OPTIONS), DataPointOptionTabPage::Create); + AddTabPage(u"datapointoption"_ustr, SchResId(STR_PAGE_OPTIONS), DataPointOptionTabPage::Create); if( m_pParameter->HasGeometryProperties() ) - AddTabPage("layout", SchResId(STR_PAGE_LAYOUT), SchLayoutTabPage::Create); + AddTabPage(u"layout"_ustr, SchResId(STR_PAGE_LAYOUT), SchLayoutTabPage::Create); if(m_pParameter->HasAreaProperties()) { - AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); - AddTabPage("transparent", SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); } - AddTabPage("border", SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ), RID_SVXPAGE_LINE); + AddTabPage(u"border"_ustr, SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ), RID_SVXPAGE_LINE); + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); break; case OBJECTTYPE_DATA_LABEL: case OBJECTTYPE_DATA_LABELS: - AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); - AddTabPage("datalabels", SchResId(STR_OBJECT_DATALABELS), DataLabelsTabPage::Create); - AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); - AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); - if( aCJKOptions.IsAsianTypographyEnabled() ) - AddTabPage("asian", SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); + AddTabPage(u"datalabels"_ustr, SchResId(STR_OBJECT_DATALABELS), DataLabelsTabPage::Create); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + if( SvtCJKOptions::IsAsianTypographyEnabled() ) + AddTabPage(u"asian"_ustr, SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); break; @@ -399,29 +405,29 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, { if( m_pParameter->HasScaleProperties() ) { - AddTabPage("scale", SchResId(STR_PAGE_SCALE), ScaleTabPage::Create); + AddTabPage(u"scale"_ustr, SchResId(STR_PAGE_SCALE), ScaleTabPage::Create); //no positioning page for z axes so far as the tickmarks are not shown so far - AddTabPage("axispos", SchResId(STR_PAGE_POSITIONING), AxisPositionsTabPage::Create); + AddTabPage(u"axispos"_ustr, SchResId(STR_PAGE_POSITIONING), AxisPositionsTabPage::Create); } - AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); - AddTabPage("axislabel", SchResId(STR_OBJECT_LABEL), SchAxisLabelTabPage::Create); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"axislabel"_ustr, SchResId(STR_OBJECT_LABEL), SchAxisLabelTabPage::Create); if( m_pParameter->HasNumberProperties() ) - AddTabPage("numberformat", SchResId(STR_PAGE_NUMBERS), RID_SVXPAGE_NUMBERFORMAT); - AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); - AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); - if( aCJKOptions.IsAsianTypographyEnabled() ) - AddTabPage("asian", SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); + AddTabPage(u"numberformat"_ustr, SchResId(STR_PAGE_NUMBERS), RID_SVXPAGE_NUMBERFORMAT); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + if( SvtCJKOptions::IsAsianTypographyEnabled() ) + AddTabPage(u"asian"_ustr, SchResId(STR_PAGE_ASIAN), RID_SVXPAGE_PARA_ASIAN); break; } case OBJECTTYPE_DATA_ERRORS_X: - AddTabPage("xerrorbar", SchResId(STR_PAGE_XERROR_BARS), ErrorBarsTabPage::Create); - AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"xerrorbar"_ustr, SchResId(STR_PAGE_XERROR_BARS), ErrorBarsTabPage::Create); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); break; case OBJECTTYPE_DATA_ERRORS_Y: - AddTabPage("yerrorbar", SchResId(STR_PAGE_YERROR_BARS), ErrorBarsTabPage::Create); - AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"yerrorbar"_ustr, SchResId(STR_PAGE_YERROR_BARS), ErrorBarsTabPage::Create); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); break; case OBJECTTYPE_DATA_ERRORS_Z: @@ -431,12 +437,12 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, case OBJECTTYPE_SUBGRID: case OBJECTTYPE_DATA_AVERAGE_LINE: case OBJECTTYPE_DATA_STOCK_RANGE: - AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); break; case OBJECTTYPE_DATA_CURVE: - AddTabPage("trendline", SchResId(STR_PAGE_TRENDLINE_TYPE), TrendlineTabPage::Create); - AddTabPage("border", SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"trendline"_ustr, SchResId(STR_PAGE_TRENDLINE_TYPE), TrendlineTabPage::Create); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); break; case OBJECTTYPE_DATA_STOCK_LOSS: @@ -445,9 +451,11 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, case OBJECTTYPE_DIAGRAM_FLOOR: case OBJECTTYPE_DIAGRAM_WALL: case OBJECTTYPE_DIAGRAM: - AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); - AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); - AddTabPage("transparent", SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + if (eType != OBJECTTYPE_DATA_STOCK_LOSS && eType != OBJECTTYPE_DATA_STOCK_GAIN) + AddTabPage(u"colorpalette"_ustr, SchResId(STR_PAGE_COLOR_PALETTE), ChartColorPaletteTabPage::Create); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -455,19 +463,26 @@ SchAttribTabDlg::SchAttribTabDlg(weld::Window* pParent, case OBJECTTYPE_UNKNOWN: // nothing break; + case OBJECTTYPE_DATA_TABLE: + AddTabPage(u"datatable"_ustr, SchResId(STR_DATA_TABLE), DataTableTabPage::Create); + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_LINE), RID_SVXPAGE_LINE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + break; case OBJECTTYPE_DATA_CURVE_EQUATION: - AddTabPage("border", SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); - AddTabPage("area", SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); - AddTabPage("transparent", SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); - AddTabPage("fontname", SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); - AddTabPage("effects", SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); - AddTabPage("numberformat", SchResId(STR_PAGE_NUMBERS), RID_SVXPAGE_NUMBERFORMAT); - if (SvtLanguageOptions().IsCTLFontEnabled()) + AddTabPage(u"border"_ustr, SchResId(STR_PAGE_BORDER), RID_SVXPAGE_LINE); + AddTabPage(u"area"_ustr, SchResId(STR_PAGE_AREA), RID_SVXPAGE_AREA); + AddTabPage(u"transparent"_ustr, SchResId(STR_PAGE_TRANSPARENCY), RID_SVXPAGE_TRANSPARENCE); + AddTabPage(u"fontname"_ustr, SchResId(STR_PAGE_FONT), RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"effects"_ustr, SchResId(STR_PAGE_FONT_EFFECTS), RID_SVXPAGE_CHAR_EFFECTS); + AddTabPage(u"numberformat"_ustr, SchResId(STR_PAGE_NUMBERS), RID_SVXPAGE_NUMBERFORMAT); + if (SvtCTLOptions::IsCTLFontEnabled()) { /* When rotation is supported for equation text boxes, use SchAlignmentTabPage::Create here. The special SchAlignmentTabPage::CreateWithoutRotation can be deleted. */ - AddTabPage("alignment", SchResId(STR_PAGE_ALIGNMENT), SchAlignmentTabPage::CreateWithoutRotation); + AddTabPage(u"alignment"_ustr, SchResId(STR_PAGE_ALIGNMENT), SchAlignmentTabPage::CreateWithoutRotation); } break; default: @@ -484,7 +499,7 @@ SchAttribTabDlg::~SchAttribTabDlg() { } -void SchAttribTabDlg::PageCreated(const OString& rId, SfxTabPage &rPage) +void SchAttribTabDlg::PageCreated(const OUString& rId, SfxTabPage &rPage) { SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); if (rId == "border") @@ -498,10 +513,10 @@ void SchAttribTabDlg::PageCreated(const OString& rId, SfxTabPage &rPage) if( m_pParameter->HasSymbolProperties() ) { aSet.Put(OfaPtrItem(SID_OBJECT_LIST,m_pViewElementListProvider->GetSymbolList())); - if( m_pSymbolShapeProperties ) - aSet.Put(SfxTabDialogItem(SID_ATTR_SET,*m_pSymbolShapeProperties)); - if( m_pAutoSymbolGraphic ) - aSet.Put(SvxGraphicItem(*m_pAutoSymbolGraphic)); + if( m_oSymbolShapeProperties ) + aSet.Put(SfxTabDialogItem(SID_ATTR_SET, *m_oSymbolShapeProperties)); + if( m_oAutoSymbolGraphic ) + aSet.Put(SvxGraphicItem(*m_oAutoSymbolGraphic)); } rPage.PageCreated(aSet); } @@ -571,7 +586,7 @@ void SchAttribTabDlg::PageCreated(const OString& rId, SfxTabPage &rPage) } else if (rId == "numberformat") { - aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO))); + aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, SID_ATTR_NUMBERFORMAT_INFO)); rPage.PageCreated(aSet); } else if (rId == "xerrorbar") @@ -612,6 +627,14 @@ void SchAttribTabDlg::PageCreated(const OString& rId, SfxTabPage &rPage) pTrendlineTabPage->SetNbPoints( m_pParameter->getNbPoints() ); } } + else if (rId == "colorpalette") + { + auto* pColorPaletteTabPage = dynamic_cast<ChartColorPaletteTabPage*>( &rPage ); + if (pColorPaletteTabPage) + { + pColorPaletteTabPage->init(m_pParameter->getDocument()); + } + } } IMPL_LINK(SchAttribTabDlg, OKPressed, weld::Button&, rButton, void) diff --git a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx index f5fc702a2a76..4f4efb96085d 100644 --- a/chart2/source/controller/dialogs/dlg_ShapeFont.cxx +++ b/chart2/source/controller/dialogs/dlg_ShapeFont.cxx @@ -33,15 +33,15 @@ namespace chart ShapeFontDialog::ShapeFontDialog(weld::Window* pParent, const SfxItemSet* pAttr, const ViewElementListProvider* pViewElementListProvider) - : SfxTabDialogController(pParent, "modules/schart/ui/chardialog.ui", "CharDialog", pAttr) + : SfxTabDialogController(pParent, u"modules/schart/ui/chardialog.ui"_ustr, u"CharDialog"_ustr, pAttr) , m_pViewElementListProvider(pViewElementListProvider) { - AddTabPage("font", RID_SVXPAGE_CHAR_NAME); - AddTabPage("fonteffects", RID_SVXPAGE_CHAR_EFFECTS); - AddTabPage("position", RID_SVXPAGE_CHAR_POSITION ); + AddTabPage(u"font"_ustr, RID_SVXPAGE_CHAR_NAME); + AddTabPage(u"fonteffects"_ustr, RID_SVXPAGE_CHAR_EFFECTS); + AddTabPage(u"position"_ustr, RID_SVXPAGE_CHAR_POSITION ); } -void ShapeFontDialog::PageCreated(const OString& rId, SfxTabPage& rPage) +void ShapeFontDialog::PageCreated(const OUString& rId, SfxTabPage& rPage) { SfxAllItemSet aSet( *( GetInputSetImpl()->GetPool() ) ); if (rId == "font") diff --git a/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx index c990161cf6c8..9af94eef04d0 100644 --- a/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx +++ b/chart2/source/controller/dialogs/dlg_ShapeParagraph.cxx @@ -32,24 +32,22 @@ namespace chart ShapeParagraphDialog::ShapeParagraphDialog(weld::Window* pParent, const SfxItemSet* pAttr) - : SfxTabDialogController(pParent, "modules/schart/ui/paradialog.ui", "ParagraphDialog", pAttr) + : SfxTabDialogController(pParent, u"modules/schart/ui/paradialog.ui"_ustr, u"ParagraphDialog"_ustr, pAttr) { - SvtCJKOptions aCJKOptions; - - AddTabPage("labelTP_PARA_STD", RID_SVXPAGE_STD_PARAGRAPH); - AddTabPage("labelTP_PARA_ALIGN", RID_SVXPAGE_ALIGN_PARAGRAPH ); - if (aCJKOptions.IsAsianTypographyEnabled()) + AddTabPage(u"labelTP_PARA_STD"_ustr, RID_SVXPAGE_STD_PARAGRAPH); + AddTabPage(u"labelTP_PARA_ALIGN"_ustr, RID_SVXPAGE_ALIGN_PARAGRAPH ); + if (SvtCJKOptions::IsAsianTypographyEnabled()) { - AddTabPage("labelTP_PARA_ASIAN", RID_SVXPAGE_PARA_ASIAN); + AddTabPage(u"labelTP_PARA_ASIAN"_ustr, RID_SVXPAGE_PARA_ASIAN); } else { - RemoveTabPage("labelTP_PARA_ASIAN"); + RemoveTabPage(u"labelTP_PARA_ASIAN"_ustr); } - AddTabPage("labelTP_TABULATOR", RID_SVXPAGE_TABULATOR); + AddTabPage(u"labelTP_TABULATOR"_ustr, RID_SVXPAGE_TABULATOR); } -void ShapeParagraphDialog::PageCreated(const OString& rId, SfxTabPage& rPage) +void ShapeParagraphDialog::PageCreated(const OUString& rId, SfxTabPage& rPage) { if (rId == "labelTP_TABULATOR") { diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx index b81b7ecacbf1..e8f41a7ff39e 100644 --- a/chart2/source/controller/dialogs/dlg_View3D.cxx +++ b/chart2/source/controller/dialogs/dlg_View3D.cxx @@ -23,34 +23,31 @@ #include "tp_3D_SceneGeometry.hxx" #include "tp_3D_SceneAppearance.hxx" #include "tp_3D_SceneIllumination.hxx" -#include <ChartModelHelper.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> -#include <com/sun/star/frame/XModel.hpp> +#include <ChartModel.hxx> +#include <Diagram.hxx> namespace chart { using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; sal_uInt16 View3DDialog::m_nLastPageId = 0; -View3DDialog::View3DDialog(weld::Window* pParent, const uno::Reference< frame::XModel > & xChartModel) - : GenericDialogController(pParent, "modules/schart/ui/3dviewdialog.ui", "3DViewDialog") +View3DDialog::View3DDialog(weld::Window* pParent, const rtl::Reference<::chart::ChartModel> & xChartModel) + : GenericDialogController(pParent, u"modules/schart/ui/3dviewdialog.ui"_ustr, u"3DViewDialog"_ustr) , m_aControllerLocker(xChartModel) - , m_xTabControl(m_xBuilder->weld_notebook("tabcontrol")) + , m_xTabControl(m_xBuilder->weld_notebook(u"tabcontrol"_ustr)) { - uno::Reference< beans::XPropertySet > xSceneProperties( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + rtl::Reference< Diagram > xSceneProperties = xChartModel->getFirstChartDiagram(); - m_xTabControl->append_page("geometry", SchResId(STR_PAGE_PERSPECTIVE)); - m_xGeometry.reset(new ThreeD_SceneGeometry_TabPage(m_xTabControl->get_page("geometry"), xSceneProperties, m_aControllerLocker)); + m_xTabControl->append_page(u"geometry"_ustr, SchResId(STR_PAGE_PERSPECTIVE)); + m_xGeometry.reset(new ThreeD_SceneGeometry_TabPage(m_xTabControl->get_page(u"geometry"_ustr), xSceneProperties, m_aControllerLocker)); - m_xTabControl->append_page("appearance", SchResId(STR_PAGE_APPEARANCE)); - m_xAppearance.reset(new ThreeD_SceneAppearance_TabPage(m_xTabControl->get_page("appearance"), xChartModel, m_aControllerLocker)); + m_xTabControl->append_page(u"appearance"_ustr, SchResId(STR_PAGE_APPEARANCE)); + m_xAppearance.reset(new ThreeD_SceneAppearance_TabPage(m_xTabControl->get_page(u"appearance"_ustr), xChartModel, m_aControllerLocker)); - m_xTabControl->append_page("illumination", SchResId(STR_PAGE_ILLUMINATION)); - m_xIllumination.reset(new ThreeD_SceneIllumination_TabPage(m_xTabControl->get_page("illumination"), m_xDialog.get(), + m_xTabControl->append_page(u"illumination"_ustr, SchResId(STR_PAGE_ILLUMINATION)); + m_xIllumination.reset(new ThreeD_SceneIllumination_TabPage(m_xTabControl->get_page(u"illumination"_ustr), m_xDialog.get(), xSceneProperties, xChartModel)); m_xTabControl->connect_enter_page(LINK(this, View3DDialog, ActivatePageHdl)); @@ -58,7 +55,7 @@ View3DDialog::View3DDialog(weld::Window* pParent, const uno::Reference< frame::X m_xTabControl->set_current_page(m_nLastPageId); } -IMPL_LINK(View3DDialog, ActivatePageHdl, const OString&, rPage, void) +IMPL_LINK(View3DDialog, ActivatePageHdl, const OUString&, rPage, void) { if (rPage == "appearance") m_xAppearance->ActivatePage(); diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx b/chart2/source/controller/dialogs/res_BarGeometry.cxx index 182d391aac33..927906b06915 100644 --- a/chart2/source/controller/dialogs/res_BarGeometry.cxx +++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx @@ -24,18 +24,17 @@ namespace chart { BarGeometryResources::BarGeometryResources(weld::Builder* pBuilder) - : m_xFT_Geometry(pBuilder->weld_label("shapeft")) - , m_xLB_Geometry(pBuilder->weld_tree_view("shape")) + : m_xFT_Geometry(pBuilder->weld_label(u"shapeft"_ustr)) + , m_xLB_Geometry(pBuilder->weld_tree_view(u"shape"_ustr)) { - for (size_t i = 0; i < SAL_N_ELEMENTS(CHART_TYPE); ++i) + for (size_t i = 0; i < std::size(CHART_TYPE); ++i) m_xLB_Geometry->append_text(SchResId(CHART_TYPE[i])); - m_xLB_Geometry->set_size_request(-1, - m_xLB_Geometry->get_height_rows(SAL_N_ELEMENTS(CHART_TYPE))); + m_xLB_Geometry->set_size_request(-1, m_xLB_Geometry->get_height_rows(std::size(CHART_TYPE))); } void BarGeometryResources::connect_changed(const Link<weld::TreeView&, void>& rLink) { - m_xLB_Geometry->connect_changed(rLink); + m_xLB_Geometry->connect_selection_changed(rLink); } void BarGeometryResources::set_visible(bool bShow) diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx index 841b75d2f9ef..98db10ff1873 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.cxx +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -46,41 +46,36 @@ namespace const std::u16string_view our_aLBEntryMap[] = {u" ", u", ", u"; ", u"\n", u". "}; -bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, sal_uInt16 nValueWhich, sal_uInt16 nSourceFormatWhich, sal_uLong& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) +bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, TypedWhichId<SfxUInt32Item> nValueWhich, TypedWhichId<SfxBoolItem> nSourceFormatWhich, sal_uInt32& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) { bool bSet = false; - const SfxPoolItem *pItem1 = nullptr; - if( rSet.GetItemState( nValueWhich, true, &pItem1 ) == SfxItemState::SET ) + if( const SfxUInt32Item* pNumItem = rSet.GetItemIfSet( nValueWhich ) ) { - const SfxUInt32Item * pNumItem = dynamic_cast< const SfxUInt32Item * >( pItem1 ); - if( pNumItem ) - { - rnFormatKeyOut = pNumItem->GetValue(); - bSet = true; - } + rnFormatKeyOut = pNumItem->GetValue(); + bSet = true; } rbSourceFormatMixedStateOut=true; - const SfxPoolItem *pItem2 = nullptr; - if( rSet.GetItemState( nSourceFormatWhich, true, &pItem2 ) == SfxItemState::SET ) + if( const SfxBoolItem * pBoolItem = rSet.GetItemIfSet( nSourceFormatWhich ) ) { - const SfxBoolItem * pBoolItem = dynamic_cast< const SfxBoolItem * >( pItem2 ); - if( pBoolItem ) - { - rbSourceFormatOut = pBoolItem->GetValue(); - rbSourceFormatMixedStateOut=false; - } + rbSourceFormatOut = pBoolItem->GetValue(); + rbSourceFormatMixedStateOut=false; } return bSet; } -void lcl_setBoolItemToCheckBox(const SfxItemSet& rInAttrs, sal_uInt16 nWhichId, weld::CheckButton& rCheckbox) +void lcl_setBoolItemToCheckBox(const SfxItemSet& rInAttrs, TypedWhichId<SfxBoolItem> nWhichId, weld::CheckButton& rCheckbox, weld::TriStateEnabled& rTriState) { - const SfxPoolItem *pPoolItem = nullptr; - if( rInAttrs.GetItemState(nWhichId, true, &pPoolItem) == SfxItemState::SET ) - rCheckbox.set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + if( const SfxBoolItem* pPoolItem = rInAttrs.GetItemIfSet(nWhichId) ) + { + rCheckbox.set_active(pPoolItem->GetValue()); + rTriState.bTriStateEnabled = false; + } else + { rCheckbox.set_state(TRISTATE_INDET); + rTriState.bTriStateEnabled = true; + } } }//end anonymous namespace @@ -97,25 +92,25 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP , m_bSourceFormatForPercent(true) , m_pWindow(pParent) , m_pPool(rInAttrs.GetPool()) - , m_xCBNumber(pBuilder->weld_check_button("CB_VALUE_AS_NUMBER")) - , m_xPB_NumberFormatForValue(pBuilder->weld_button("PB_NUMBERFORMAT")) - , m_xCBPercent(pBuilder->weld_check_button("CB_VALUE_AS_PERCENTAGE")) - , m_xPB_NumberFormatForPercent(pBuilder->weld_button("PB_PERCENT_NUMBERFORMAT")) - , m_xFT_NumberFormatForPercent(pBuilder->weld_label("STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE")) - , m_xCBCategory(pBuilder->weld_check_button("CB_CATEGORY")) - , m_xCBSymbol(pBuilder->weld_check_button("CB_SYMBOL")) - , m_xCBDataSeries(pBuilder->weld_check_button("CB_DATA_SERIES_NAME")) - , m_xCBWrapText(pBuilder->weld_check_button("CB_WRAP_TEXT")) - , m_xLB_Separator(pBuilder->weld_combo_box("LB_TEXT_SEPARATOR")) - , m_xLB_LabelPlacement(pBuilder->weld_combo_box("LB_LABEL_PLACEMENT")) - , m_xBxOrientation(pBuilder->weld_widget("boxORIENTATION")) - , m_xFT_Dial(pBuilder->weld_label("CT_LABEL_DIAL")) - , m_xNF_Degrees(pBuilder->weld_metric_spin_button("NF_LABEL_DEGREES", FieldUnit::DEGREE)) - , m_xBxTextDirection(pBuilder->weld_widget("boxTXT_DIRECTION")) - , m_xLB_TextDirection(new TextDirectionListBox(pBuilder->weld_combo_box("LB_LABEL_TEXTDIR"))) + , m_xCBNumber(pBuilder->weld_check_button(u"CB_VALUE_AS_NUMBER"_ustr)) + , m_xPB_NumberFormatForValue(pBuilder->weld_button(u"PB_NUMBERFORMAT"_ustr)) + , m_xCBPercent(pBuilder->weld_check_button(u"CB_VALUE_AS_PERCENTAGE"_ustr)) + , m_xPB_NumberFormatForPercent(pBuilder->weld_button(u"PB_PERCENT_NUMBERFORMAT"_ustr)) + , m_xFT_NumberFormatForPercent(pBuilder->weld_label(u"STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE"_ustr)) + , m_xCBCategory(pBuilder->weld_check_button(u"CB_CATEGORY"_ustr)) + , m_xCBSymbol(pBuilder->weld_check_button(u"CB_SYMBOL"_ustr)) + , m_xCBDataSeries(pBuilder->weld_check_button(u"CB_DATA_SERIES_NAME"_ustr)) + , m_xCBWrapText(pBuilder->weld_check_button(u"CB_WRAP_TEXT"_ustr)) + , m_xLB_Separator(pBuilder->weld_combo_box(u"LB_TEXT_SEPARATOR"_ustr)) + , m_xLB_LabelPlacement(pBuilder->weld_combo_box(u"LB_LABEL_PLACEMENT"_ustr)) + , m_xBxOrientation(pBuilder->weld_widget(u"boxORIENTATION"_ustr)) + , m_xFT_Dial(pBuilder->weld_label(u"CT_LABEL_DIAL"_ustr)) + , m_xNF_Degrees(pBuilder->weld_metric_spin_button(u"NF_LABEL_DEGREES"_ustr, FieldUnit::DEGREE)) + , m_xBxTextDirection(pBuilder->weld_widget(u"boxTXT_DIRECTION"_ustr)) + , m_aLB_TextDirection(pBuilder->weld_combo_box(u"LB_LABEL_TEXTDIR"_ustr)) , m_xDC_Dial(new svx::DialControl) - , m_xDC_DialWin(new weld::CustomWeld(*pBuilder, "CT_DIAL", *m_xDC_Dial)) - , m_xCBCustomLeaderLines(pBuilder->weld_check_button("CB_CUSTOM_LEADER_LINES")) + , m_xDC_DialWin(new weld::CustomWeld(*pBuilder, u"CT_DIAL"_ustr, *m_xDC_Dial)) + , m_xCBCustomLeaderLines(pBuilder->weld_check_button(u"CB_CUSTOM_LEADER_LINES"_ustr)) { m_xDC_Dial->SetText(m_xFT_Dial->get_label()); @@ -126,9 +121,8 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP std::vector< sal_Int32 > aAvailablePlacementList; - const SfxPoolItem *pPoolItem = nullptr; - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, true, &pPoolItem) == SfxItemState::SET ) - aAvailablePlacementList = static_cast<const SfxIntegerListItem*>(pPoolItem)->GetList(); + if( const SfxIntegerListItem* pPlacementsItem = rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS) ) + aAvailablePlacementList = pPlacementsItem->GetList(); m_xLB_LabelPlacement->clear(); for( size_t nN=0; nN<aAvailablePlacementList.size(); ++nN ) @@ -154,9 +148,9 @@ DataLabelResources::DataLabelResources(weld::Builder* pBuilder, weld::Window* pP m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_NO_PERCENTVALUE, true, &pPoolItem) == SfxItemState::SET ) + if( const SfxBoolItem* pNoPercentValueItem = rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_NO_PERCENTVALUE) ) { - bool bForbidPercentValue = rInAttrs.Get( SCHATTR_DATADESCR_NO_PERCENTVALUE ).GetValue(); + bool bForbidPercentValue = pNoPercentValueItem->GetValue(); if( bForbidPercentValue ) m_xCBPercent->set_sensitive(false); } @@ -182,16 +176,22 @@ IMPL_LINK(DataLabelResources, NumberFormatDialogHdl, weld::Button&, rButton, voi } if (&rButton == m_xPB_NumberFormatForValue.get() && !m_xCBNumber->get_active()) + { m_xCBNumber->set_active(true); + m_aNumberState.bTriStateEnabled = false; + } else if (&rButton == m_xPB_NumberFormatForPercent.get() && !m_xCBPercent->get_active()) + { m_xCBPercent->set_active(true); + m_aPercentState.bTriStateEnabled = false; + } SfxItemSet aNumberSet = NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( *m_pPool ); - aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, static_cast<sal_uInt16>(SID_ATTR_NUMBERFORMAT_INFO))); + aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, SID_ATTR_NUMBERFORMAT_INFO)); bool bPercent = (&rButton == m_xPB_NumberFormatForPercent.get()); - sal_uLong& rnFormatKey = bPercent ? m_nNumberFormatForPercent : m_nNumberFormatForValue; + sal_uInt32& rnFormatKey = bPercent ? m_nNumberFormatForPercent : m_nNumberFormatForValue; bool& rUseSourceFormat = bPercent ? m_bSourceFormatForPercent : m_bSourceFormatForValue; bool& rbMixedState = bPercent ? m_bPercentFormatMixedState : m_bNumberFormatMixedState; bool& rbSourceMixedState = bPercent ? m_bPercentSourceMixedState : m_bSourceFormatMixedState; @@ -210,7 +210,7 @@ IMPL_LINK(DataLabelResources, NumberFormatDialogHdl, weld::Button&, rButton, voi if( pResult ) { bool bOldSource = rUseSourceFormat; - sal_uLong nOldFormat = rnFormatKey; + sal_uInt32 nOldFormat = rnFormatKey; bool bOldMixedState = rbMixedState || rbSourceMixedState; rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); @@ -221,8 +221,22 @@ IMPL_LINK(DataLabelResources, NumberFormatDialogHdl, weld::Button&, rButton, voi } } -IMPL_LINK_NOARG(DataLabelResources, CheckHdl, weld::Toggleable&, void) +IMPL_LINK(DataLabelResources, CheckHdl, weld::Toggleable&, rToggle, void) { + if (&rToggle == m_xCBNumber.get()) + m_aNumberState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBPercent.get()) + m_aPercentState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBCategory.get()) + m_aCategoryState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBSymbol.get()) + m_aSymbolState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBDataSeries.get()) + m_aDataSeriesState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBWrapText.get()) + m_aWrapTextState.ButtonToggled(rToggle); + else if (&rToggle == m_xCBCustomLeaderLines.get()) + m_aCustomLeaderLinesState.ButtonToggled(rToggle); EnableControls(); } @@ -305,8 +319,8 @@ void DataLabelResources::FillItemSet( SfxItemSet* rOutAttrs ) const rOutAttrs->Put( SfxInt32Item( SCHATTR_DATADESCR_PLACEMENT, nValue ) ); } - if (m_xLB_TextDirection->get_active() != -1) - rOutAttrs->Put( SvxFrameDirectionItem( m_xLB_TextDirection->get_active_id(), EE_PARA_WRITINGDIR ) ); + if (m_aLB_TextDirection.get_active() != -1) + rOutAttrs->Put( SvxFrameDirectionItem( m_aLB_TextDirection.get_active_id(), EE_PARA_WRITINGDIR ) ); if( m_xDC_Dial->IsVisible() ) { @@ -320,30 +334,29 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) // default state m_xCBSymbol->set_sensitive( false ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_NUMBER, *m_xCBNumber ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, *m_xCBPercent ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, *m_xCBCategory ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, *m_xCBSymbol ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME, *m_xCBDataSeries ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_WRAP_TEXT, *m_xCBWrapText ); - lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, *m_xCBCustomLeaderLines ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_NUMBER, *m_xCBNumber, m_aNumberState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, *m_xCBPercent, m_aPercentState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, *m_xCBCategory, m_aCategoryState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, *m_xCBSymbol, m_aSymbolState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_DATA_SERIES_NAME, *m_xCBDataSeries, m_aDataSeriesState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_WRAP_TEXT, *m_xCBWrapText, m_aWrapTextState ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_CUSTOM_LEADER_LINES, *m_xCBCustomLeaderLines, m_aCustomLeaderLinesState ); m_bNumberFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, m_nNumberFormatForValue, m_bSourceFormatForValue, m_bSourceFormatMixedState ); m_bPercentFormatMixedState = !lcl_ReadNumberFormatFromItemSet( rInAttrs, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_nNumberFormatForPercent, m_bSourceFormatForPercent , m_bPercentSourceMixedState); - const SfxPoolItem *pPoolItem = nullptr; - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, true, &pPoolItem) == SfxItemState::SET ) - for(size_t i=0; i < SAL_N_ELEMENTS(our_aLBEntryMap); ++i ) + if( const SfxStringItem* pSeparatorItem = rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_SEPARATOR) ) + for(size_t i=0; i < std::size(our_aLBEntryMap); ++i ) { - if( our_aLBEntryMap[i] == static_cast<const SfxStringItem*>(pPoolItem)->GetValue()) + if( our_aLBEntryMap[i] == pSeparatorItem->GetValue()) m_xLB_Separator->set_active( i ); } else m_xLB_Separator->set_active( 0 ); - if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, true, &pPoolItem) == SfxItemState::SET ) + if( const SfxInt32Item* pPlacementItem = rInAttrs.GetItemIfSet(SCHATTR_DATADESCR_PLACEMENT) ) { - sal_Int32 nPlacement = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + sal_Int32 nPlacement = pPlacementItem->GetValue(); std::map< sal_Int32, sal_uInt16 >::const_iterator aIt( m_aPlacementToListBoxMap.find(nPlacement) ); if(aIt!=m_aPlacementToListBoxMap.end()) { @@ -356,12 +369,12 @@ void DataLabelResources::Reset(const SfxItemSet& rInAttrs) else m_xLB_LabelPlacement->set_active(-1); - if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET ) - m_xLB_TextDirection->set_active_id( static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() ); + if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs.GetItemIfSet(EE_PARA_WRITINGDIR) ) + m_aLB_TextDirection.set_active_id( pDirectionItem->GetValue() ); - if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, true, &pPoolItem ) == SfxItemState::SET ) + if( const SdrAngleItem* pAngleItem = rInAttrs.GetItemIfSet( SCHATTR_TEXT_DEGREES ) ) { - Degree100 nDegrees = static_cast< const SdrAngleItem * >( pPoolItem )->GetValue(); + Degree100 nDegrees = pAngleItem->GetValue(); m_xDC_Dial->SetRotation( nDegrees ); } else diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx index 094291dc9a23..66a062d2ca24 100644 --- a/chart2/source/controller/dialogs/res_DataLabel.hxx +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -20,11 +20,11 @@ #include <svl/itemset.hxx> #include <svx/dialcontrol.hxx> +#include <TextDirectionListBox.hxx> #include <map> class SvNumberFormatter; -namespace chart { class TextDirectionListBox; } namespace chart { @@ -47,8 +47,8 @@ private: SvNumberFormatter* m_pNumberFormatter; bool m_bNumberFormatMixedState; bool m_bPercentFormatMixedState; - sal_uLong m_nNumberFormatForValue; - sal_uLong m_nNumberFormatForPercent; + sal_uInt32 m_nNumberFormatForValue; + sal_uInt32 m_nNumberFormatForPercent; bool m_bSourceFormatMixedState; bool m_bPercentSourceMixedState; @@ -58,6 +58,14 @@ private: weld::Window* m_pWindow; SfxItemPool* m_pPool; + weld::TriStateEnabled m_aNumberState; + weld::TriStateEnabled m_aPercentState; + weld::TriStateEnabled m_aCategoryState; + weld::TriStateEnabled m_aSymbolState; + weld::TriStateEnabled m_aDataSeriesState; + weld::TriStateEnabled m_aWrapTextState; + weld::TriStateEnabled m_aCustomLeaderLinesState; + std::unique_ptr<weld::CheckButton> m_xCBNumber; std::unique_ptr<weld::Button> m_xPB_NumberFormatForValue; std::unique_ptr<weld::CheckButton> m_xCBPercent; @@ -77,7 +85,7 @@ private: std::unique_ptr<weld::Widget> m_xBxTextDirection; - std::unique_ptr<TextDirectionListBox> m_xLB_TextDirection; + TextDirectionListBox m_aLB_TextDirection; std::unique_ptr<svx::DialControl> m_xDC_Dial; std::unique_ptr<weld::CustomWeld> m_xDC_DialWin; diff --git a/chart2/source/controller/dialogs/res_DataTableProperties.cxx b/chart2/source/controller/dialogs/res_DataTableProperties.cxx new file mode 100644 index 000000000000..493be52ea5bc --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataTableProperties.cxx @@ -0,0 +1,111 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <res_DataTableProperties.hxx> + +#include <chartview/ChartSfxItemIds.hxx> +#include <svl/eitem.hxx> + +using namespace css; + +namespace chart +{ +DataTablePropertiesResources::DataTablePropertiesResources(weld::Builder& rBuilder) + : m_xCbHorizontalBorder(rBuilder.weld_check_button(u"horizontalBorderCB"_ustr)) + , m_xCbVerticalBorder(rBuilder.weld_check_button(u"verticalBorderCB"_ustr)) + , m_xCbOutilne(rBuilder.weld_check_button(u"outlineCB"_ustr)) + , m_xCbKeys(rBuilder.weld_check_button(u"keysCB"_ustr)) +{ +} + +void DataTablePropertiesResources::setChecksSensitive(bool bSensitive) +{ + m_xCbHorizontalBorder->set_sensitive(bSensitive); + m_xCbVerticalBorder->set_sensitive(bSensitive); + m_xCbOutilne->set_sensitive(bSensitive); + m_xCbKeys->set_sensitive(bSensitive); +} + +void DataTablePropertiesResources::initFromItemSet(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem* pPoolItem = nullptr; + SfxItemState aState; + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, false, &pPoolItem); + if (aState == SfxItemState::INVALID) + { + m_xCbHorizontalBorder->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbHorizontalBorder->set_active( + static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_VERTICAL_BORDER, false, &pPoolItem); + if (aState == SfxItemState::INVALID) + { + m_xCbVerticalBorder->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbVerticalBorder->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_OUTLINE, false, &pPoolItem); + if (aState == SfxItemState::INVALID) + { + m_xCbOutilne->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbOutilne->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } + + aState = rInAttrs.GetItemState(SCHATTR_DATA_TABLE_KEYS, false, &pPoolItem); + if (aState == SfxItemState::INVALID) + { + m_xCbKeys->set_state(TRISTATE_INDET); + } + else + { + if (aState == SfxItemState::SET) + m_xCbKeys->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + } +} + +bool DataTablePropertiesResources::writeToItemSet(SfxItemSet& rOutAttrs) const +{ + if (m_xCbHorizontalBorder->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put( + SfxBoolItem(SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, m_xCbHorizontalBorder->get_active())); + } + if (m_xCbVerticalBorder->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put( + SfxBoolItem(SCHATTR_DATA_TABLE_VERTICAL_BORDER, m_xCbVerticalBorder->get_active())); + } + if (m_xCbOutilne->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_OUTLINE, m_xCbOutilne->get_active())); + } + if (m_xCbKeys->get_state() != TRISTATE_INDET) + { + rOutAttrs.Put(SfxBoolItem(SCHATTR_DATA_TABLE_KEYS, m_xCbKeys->get_active())); + } + return true; +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx index 39ee44909e61..1e30311ae28b 100644 --- a/chart2/source/controller/dialogs/res_ErrorBar.cxx +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -22,11 +22,12 @@ #include <RangeSelectionHelper.hxx> #include <helpids.h> #include <chartview/ChartSfxItemIds.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <vcl/weld.hxx> +#include <ChartModel.hxx> +#include "DialogModel.hxx" #include <rtl/math.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <osl/diagnose.h> #include <svl/stritem.hxx> @@ -39,12 +40,6 @@ using namespace ::com::sun::star; namespace { -void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pController) -{ - weld::Window* pWeldDialog = pController->getDialog(); - pWeldDialog->set_modal(!bEnable); - pWeldDialog->set_visible(!bEnable); -} sal_uInt16 lcl_getLbEntryPosByErrorKind( SvxChartKindError eErrorKind ) { @@ -56,14 +51,12 @@ sal_uInt16 lcl_getLbEntryPosByErrorKind( SvxChartKindError eErrorKind ) case SvxChartKindError::Percent: case SvxChartKindError::Const: case SvxChartKindError::Range: + case SvxChartKindError::Sigma: nResult = CHART_LB_FUNCTION_STD_DEV; break; case SvxChartKindError::Variant: nResult = CHART_LB_FUNCTION_VARIANCE; break; - case SvxChartKindError::Sigma: - nResult = CHART_LB_FUNCTION_STD_DEV; - break; case SvxChartKindError::BigError: nResult = CHART_LB_FUNCTION_ERROR_MARGIN; break; @@ -96,31 +89,31 @@ ErrorBarResources::ErrorBarResources(weld::Builder* pParent, weld::DialogControl , m_pCurrentRangeChoosingField( nullptr ) , m_bHasInternalDataProvider( true ) , m_bEnableDataTableDialog( true ) - , m_xRbNone(pParent->weld_radio_button("RB_NONE")) - , m_xRbConst(pParent->weld_radio_button("RB_CONST")) - , m_xRbPercent(pParent->weld_radio_button("RB_PERCENT")) - , m_xRbFunction(pParent->weld_radio_button("RB_FUNCTION")) - , m_xRbRange(pParent->weld_radio_button("RB_RANGE")) - , m_xLbFunction(pParent->weld_combo_box("LB_FUNCTION")) - , m_xFlParameters(pParent->weld_frame("framePARAMETERS")) - , m_xBxPositive(pParent->weld_widget("boxPOSITIVE")) - , m_xMfPositive(pParent->weld_metric_spin_button("MF_POSITIVE", FieldUnit::NONE)) - , m_xEdRangePositive(pParent->weld_entry("ED_RANGE_POSITIVE")) - , m_xIbRangePositive(pParent->weld_button("IB_RANGE_POSITIVE")) - , m_xBxNegative(pParent->weld_widget("boxNEGATIVE")) - , m_xMfNegative(pParent->weld_metric_spin_button("MF_NEGATIVE", FieldUnit::NONE)) - , m_xEdRangeNegative(pParent->weld_entry("ED_RANGE_NEGATIVE")) - , m_xIbRangeNegative(pParent->weld_button("IB_RANGE_NEGATIVE")) - , m_xCbSyncPosNeg(pParent->weld_check_button("CB_SYN_POS_NEG")) - , m_xRbBoth(pParent->weld_radio_button("RB_BOTH")) - , m_xRbPositive(pParent->weld_radio_button("RB_POSITIVE")) - , m_xRbNegative(pParent->weld_radio_button("RB_NEGATIVE")) - , m_xFiBoth(pParent->weld_image("FI_BOTH")) - , m_xFiPositive(pParent->weld_image("FI_POSITIVE")) - , m_xFiNegative(pParent->weld_image("FI_NEGATIVE")) - , m_xUIStringPos(pParent->weld_label("STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS")) - , m_xUIStringNeg(pParent->weld_label("STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS")) - , m_xUIStringRbRange(pParent->weld_label("STR_CONTROLTEXT_ERROR_BARS_FROM_DATA")) + , m_xRbNone(pParent->weld_radio_button(u"RB_NONE"_ustr)) + , m_xRbConst(pParent->weld_radio_button(u"RB_CONST"_ustr)) + , m_xRbPercent(pParent->weld_radio_button(u"RB_PERCENT"_ustr)) + , m_xRbFunction(pParent->weld_radio_button(u"RB_FUNCTION"_ustr)) + , m_xRbRange(pParent->weld_radio_button(u"RB_RANGE"_ustr)) + , m_xLbFunction(pParent->weld_combo_box(u"LB_FUNCTION"_ustr)) + , m_xFlParameters(pParent->weld_frame(u"framePARAMETERS"_ustr)) + , m_xBxPositive(pParent->weld_widget(u"boxPOSITIVE"_ustr)) + , m_xMfPositive(pParent->weld_metric_spin_button(u"MF_POSITIVE"_ustr, FieldUnit::NONE)) + , m_xEdRangePositive(pParent->weld_entry(u"ED_RANGE_POSITIVE"_ustr)) + , m_xIbRangePositive(pParent->weld_button(u"IB_RANGE_POSITIVE"_ustr)) + , m_xBxNegative(pParent->weld_widget(u"boxNEGATIVE"_ustr)) + , m_xMfNegative(pParent->weld_metric_spin_button(u"MF_NEGATIVE"_ustr, FieldUnit::NONE)) + , m_xEdRangeNegative(pParent->weld_entry(u"ED_RANGE_NEGATIVE"_ustr)) + , m_xIbRangeNegative(pParent->weld_button(u"IB_RANGE_NEGATIVE"_ustr)) + , m_xCbSyncPosNeg(pParent->weld_check_button(u"CB_SYN_POS_NEG"_ustr)) + , m_xRbBoth(pParent->weld_radio_button(u"RB_BOTH"_ustr)) + , m_xRbPositive(pParent->weld_radio_button(u"RB_POSITIVE"_ustr)) + , m_xRbNegative(pParent->weld_radio_button(u"RB_NEGATIVE"_ustr)) + , m_xFiBoth(pParent->weld_image(u"FI_BOTH"_ustr)) + , m_xFiPositive(pParent->weld_image(u"FI_POSITIVE"_ustr)) + , m_xFiNegative(pParent->weld_image(u"FI_NEGATIVE"_ustr)) + , m_xUIStringPos(pParent->weld_label(u"STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS"_ustr)) + , m_xUIStringNeg(pParent->weld_label(u"STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS"_ustr)) + , m_xUIStringRbRange(pParent->weld_label(u"STR_CONTROLTEXT_ERROR_BARS_FROM_DATA"_ustr)) { if( bNoneAvailable ) m_xRbNone->connect_toggled(LINK(this, ErrorBarResources, CategoryChosen)); @@ -165,17 +158,17 @@ void ErrorBarResources::SetErrorBarType( tErrorBarType eNewType ) } void ErrorBarResources::SetChartDocumentForRangeChoosing( - const uno::Reference< chart2::XChartDocument > & xChartDocument ) + const rtl::Reference<::chart::ChartModel> & xChartDocument ) { if( xChartDocument.is()) { m_bHasInternalDataProvider = xChartDocument->hasInternalDataProvider(); - uno::Reference< beans::XPropertySet > xProps( xChartDocument, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProps( static_cast<cppu::OWeakObject*>(xChartDocument.get()), uno::UNO_QUERY ); if ( xProps.is() ) { try { - xProps->getPropertyValue("EnableDataTableDialog") >>= m_bEnableDataTableDialog; + xProps->getPropertyValue(u"EnableDataTableDialog"_ustr) >>= m_bEnableDataTableDialog; } catch( const uno::Exception& ) { @@ -447,7 +440,7 @@ IMPL_LINK(ErrorBarResources, ChooseRange, weld::Button&, rButton, void) aUIString = m_xUIStringNeg->get_label(); } - lcl_enableRangeChoosing(true, m_pController); + enableRangeChoosing(true, m_pController); m_apRangeSelectionHelper->chooseRange( m_pCurrentRangeChoosingField->get_text(), aUIString, *this ); @@ -475,7 +468,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) // category m_eErrorKind = SvxChartKindError::NONE; SfxItemState aState = rInAttrs.GetItemState( SCHATTR_STAT_KIND_ERROR, true, &pPoolItem ); - m_bErrorKindUnique = ( aState != SfxItemState::DONTCARE ); + m_bErrorKindUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET ) m_eErrorKind = static_cast<const SvxChartKindErrorItem*>(pPoolItem)->GetValue(); @@ -515,16 +508,14 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) } // parameters - aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTPLUS, true, &pPoolItem ); - if( aState == SfxItemState::SET ) + if( const SvxDoubleItem* pDoubleItem = rInAttrs.GetItemIfSet( SCHATTR_STAT_CONSTPLUS ) ) { - m_fPlusValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + m_fPlusValue = pDoubleItem->GetValue(); } - aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTMINUS, true, &pPoolItem ); - if( aState == SfxItemState::SET ) + if( const SvxDoubleItem* pStatItem = rInAttrs.GetItemIfSet( SCHATTR_STAT_CONSTMINUS ) ) { - m_fMinusValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + m_fMinusValue = pStatItem->GetValue(); if( m_eErrorKind != SvxChartKindError::Range && m_fPlusValue == m_fMinusValue ) @@ -533,7 +524,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) // indicator aState = rInAttrs.GetItemState( SCHATTR_STAT_INDICATE, true, &pPoolItem ); - m_bIndicatorUnique = ( aState != SfxItemState::DONTCARE ); + m_bIndicatorUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET) m_eIndicate = static_cast<const SvxChartIndicateItem *>(pPoolItem)->GetValue(); @@ -562,7 +553,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) // ranges aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_POS, true, &pPoolItem ); - m_bRangePosUnique = ( aState != SfxItemState::DONTCARE ); + m_bRangePosUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET ) { OUString sRangePositive = static_cast< const SfxStringItem * >( pPoolItem )->GetValue(); @@ -570,7 +561,7 @@ void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) } aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_NEG, true, &pPoolItem ); - m_bRangeNegUnique = ( aState != SfxItemState::DONTCARE ); + m_bRangeNegUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET ) { OUString sRangeNegative = static_cast< const SfxStringItem * >( pPoolItem )->GetValue(); @@ -686,7 +677,7 @@ void ErrorBarResources::listeningFinished( m_pCurrentRangeChoosingField = nullptr; UpdateControlStates(); - lcl_enableRangeChoosing(false, m_pController); + enableRangeChoosing(false, m_pController); } void ErrorBarResources::disposingRangeSelection() diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx index 5ad9fe1ac63d..e1743886086a 100644 --- a/chart2/source/controller/dialogs/res_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx @@ -18,9 +18,10 @@ */ #include <res_LegendPosition.hxx> -#include <ChartModelHelper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> #include <ChartModel.hxx> +#include <Diagram.hxx> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> @@ -29,7 +30,8 @@ #include <chartview/ChartSfxItemIds.hxx> #include <svl/intitem.hxx> #include <svl/eitem.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <utility> #include <vcl/weld.hxx> namespace chart @@ -39,22 +41,22 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder) - : m_xRbtLeft(rBuilder.weld_radio_button("left")) - , m_xRbtRight(rBuilder.weld_radio_button("right")) - , m_xRbtTop(rBuilder.weld_radio_button("top")) - , m_xRbtBottom(rBuilder.weld_radio_button("bottom")) + : m_xRbtLeft(rBuilder.weld_radio_button(u"left"_ustr)) + , m_xRbtRight(rBuilder.weld_radio_button(u"right"_ustr)) + , m_xRbtTop(rBuilder.weld_radio_button(u"top"_ustr)) + , m_xRbtBottom(rBuilder.weld_radio_button(u"bottom"_ustr)) { impl_setRadioButtonToggleHdl(); } LegendPositionResources::LegendPositionResources(weld::Builder& rBuilder, - const uno::Reference< uno::XComponentContext >& xCC) - : m_xCC(xCC) - , m_xCbxShow(rBuilder.weld_check_button("show")) - , m_xRbtLeft(rBuilder.weld_radio_button("left")) - , m_xRbtRight(rBuilder.weld_radio_button("right")) - , m_xRbtTop(rBuilder.weld_radio_button("top")) - , m_xRbtBottom(rBuilder.weld_radio_button("bottom")) + uno::Reference< uno::XComponentContext > xCC) + : m_xCC(std::move(xCC)) + , m_xCbxShow(rBuilder.weld_check_button(u"show"_ustr)) + , m_xRbtLeft(rBuilder.weld_radio_button(u"left"_ustr)) + , m_xRbtRight(rBuilder.weld_radio_button(u"right"_ustr)) + , m_xRbtTop(rBuilder.weld_radio_button(u"top"_ustr)) + , m_xRbtBottom(rBuilder.weld_radio_button(u"bottom"_ustr)) { m_xCbxShow->connect_toggled( LINK( this, LegendPositionResources, PositionEnableHdl ) ); impl_setRadioButtonToggleHdl(); @@ -72,24 +74,24 @@ LegendPositionResources::~LegendPositionResources() { } -void LegendPositionResources::writeToResources( const uno::Reference< frame::XModel >& xChartModel ) +void LegendPositionResources::writeToResources( const rtl::Reference<::chart::ChartModel>& xChartModel ) { try { - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); - uno::Reference< beans::XPropertySet > xProp( xDiagram->getLegend(), uno::UNO_QUERY ); - if( xProp.is() ) + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + rtl::Reference< Legend > xLegend = xDiagram->getLegend2(); + if( xLegend.is() ) { //show bool bShowLegend = false; - xProp->getPropertyValue( "Show" ) >>= bShowLegend; + xLegend->getPropertyValue( u"Show"_ustr ) >>= bShowLegend; if (m_xCbxShow) m_xCbxShow->set_active( bShowLegend ); - PositionEnableHdl(*m_xCbxShow); + PositionEnable(); //position chart2::LegendPosition ePos; - xProp->getPropertyValue( "AnchorPosition" ) >>= ePos; + xLegend->getPropertyValue( u"AnchorPosition"_ustr ) >>= ePos; switch( ePos ) { case chart2::LegendPosition_LINE_START: @@ -114,17 +116,17 @@ void LegendPositionResources::writeToResources( const uno::Reference< frame::XMo } } -void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XModel >& xChartModel ) const +void LegendPositionResources::writeToModel( const rtl::Reference<::chart::ChartModel>& xChartModel ) const { try { bool bShowLegend = m_xCbxShow && m_xCbxShow->get_active(); - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartModel); - uno::Reference< beans::XPropertySet > xProp(LegendHelper::getLegend(rModel, m_xCC, bShowLegend), uno::UNO_QUERY); + ChartModel& rModel = *xChartModel; + rtl::Reference< Legend > xProp = LegendHelper::getLegend(rModel, m_xCC, bShowLegend); if( xProp.is() ) { //show - xProp->setPropertyValue( "Show" , uno::Any( bShowLegend )); + xProp->setPropertyValue( u"Show"_ustr , uno::Any( bShowLegend )); //position chart2::LegendPosition eNewPos; @@ -147,9 +149,9 @@ void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XM eExp = css::chart::ChartLegendExpansion_WIDE; } - xProp->setPropertyValue( "AnchorPosition" , uno::Any( eNewPos )); - xProp->setPropertyValue( "Expansion" , uno::Any( eExp )); - xProp->setPropertyValue( "RelativePosition" , uno::Any()); + xProp->setPropertyValue( u"AnchorPosition"_ustr , uno::Any( eNewPos )); + xProp->setPropertyValue( u"Expansion"_ustr , uno::Any( eExp )); + xProp->setPropertyValue( u"RelativePosition"_ustr , uno::Any()); } } catch( const uno::Exception & ) @@ -160,6 +162,11 @@ void LegendPositionResources::writeToModel( const css::uno::Reference< frame::XM IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::Toggleable&, void) { + PositionEnable(); +} + +void LegendPositionResources::PositionEnable() +{ bool bEnable = !m_xCbxShow || m_xCbxShow->get_active(); m_xRbtLeft->set_sensitive( bEnable ); @@ -172,10 +179,9 @@ IMPL_LINK_NOARG(LegendPositionResources, PositionEnableHdl, weld::Toggleable&, v void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) { - const SfxPoolItem* pPoolItem = nullptr; - if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pPosItem = rInAttrs.GetItemIfSet( SCHATTR_LEGEND_POS ) ) { - chart2::LegendPosition nLegendPosition = static_cast<chart2::LegendPosition>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue()); + chart2::LegendPosition nLegendPosition = static_cast<chart2::LegendPosition>(pPosItem->GetValue()); switch( nLegendPosition ) { case chart2::LegendPosition_LINE_START: @@ -195,10 +201,10 @@ void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) } } - if( m_xCbxShow && rInAttrs.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET ) + const SfxBoolItem* pShowItem; + if( m_xCbxShow && (pShowItem = rInAttrs.GetItemIfSet( SCHATTR_LEGEND_SHOW )) ) { - bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); - m_xCbxShow->set_active(bShow); + m_xCbxShow->set_active(pShowItem->GetValue()); } } diff --git a/chart2/source/controller/dialogs/res_Titles.cxx b/chart2/source/controller/dialogs/res_Titles.cxx index 7665e9ae4a5b..dda48b055320 100644 --- a/chart2/source/controller/dialogs/res_Titles.cxx +++ b/chart2/source/controller/dialogs/res_Titles.cxx @@ -24,20 +24,20 @@ namespace chart { TitleResources::TitleResources(weld::Builder& rBuilder, bool bShowSecondaryAxesTitle) - : m_xFT_Main(rBuilder.weld_label("labelMainTitle")) - , m_xFT_Sub(rBuilder.weld_label("labelSubTitle")) - , m_xEd_Main(rBuilder.weld_entry("maintitle")) - , m_xEd_Sub(rBuilder.weld_entry("subtitle")) - , m_xFT_XAxis(rBuilder.weld_label("labelPrimaryXaxis")) - , m_xFT_YAxis(rBuilder.weld_label("labelPrimaryYaxis")) - , m_xFT_ZAxis(rBuilder.weld_label("labelPrimaryZaxis")) - , m_xEd_XAxis(rBuilder.weld_entry("primaryXaxis")) - , m_xEd_YAxis(rBuilder.weld_entry("primaryYaxis")) - , m_xEd_ZAxis(rBuilder.weld_entry("primaryZaxis")) - , m_xFT_SecondaryXAxis(rBuilder.weld_label("labelSecondaryXAxis")) - , m_xFT_SecondaryYAxis(rBuilder.weld_label("labelSecondaryYAxis")) - , m_xEd_SecondaryXAxis(rBuilder.weld_entry("secondaryXaxis")) - , m_xEd_SecondaryYAxis(rBuilder.weld_entry("secondaryYaxis")) + : m_xFT_Main(rBuilder.weld_label(u"labelMainTitle"_ustr)) + , m_xFT_Sub(rBuilder.weld_label(u"labelSubTitle"_ustr)) + , m_xEd_Main(rBuilder.weld_entry(u"maintitle"_ustr)) + , m_xEd_Sub(rBuilder.weld_entry(u"subtitle"_ustr)) + , m_xFT_XAxis(rBuilder.weld_label(u"labelPrimaryXaxis"_ustr)) + , m_xFT_YAxis(rBuilder.weld_label(u"labelPrimaryYaxis"_ustr)) + , m_xFT_ZAxis(rBuilder.weld_label(u"labelPrimaryZaxis"_ustr)) + , m_xEd_XAxis(rBuilder.weld_entry(u"primaryXaxis"_ustr)) + , m_xEd_YAxis(rBuilder.weld_entry(u"primaryYaxis"_ustr)) + , m_xEd_ZAxis(rBuilder.weld_entry(u"primaryZaxis"_ustr)) + , m_xFT_SecondaryXAxis(rBuilder.weld_label(u"labelSecondaryXAxis"_ustr)) + , m_xFT_SecondaryYAxis(rBuilder.weld_label(u"labelSecondaryYAxis"_ustr)) + , m_xEd_SecondaryXAxis(rBuilder.weld_entry(u"secondaryXaxis"_ustr)) + , m_xEd_SecondaryYAxis(rBuilder.weld_entry(u"secondaryYaxis"_ustr)) { m_xFT_SecondaryXAxis->set_visible(bShowSecondaryAxesTitle); m_xFT_SecondaryYAxis->set_visible(bShowSecondaryAxesTitle); @@ -108,21 +108,23 @@ void TitleResources::writeToResources(const TitleDialogData& rInput) void TitleResources::readFromResources(TitleDialogData& rOutput) { - rOutput.aExistenceList[0] = !m_xEd_Main->get_text().isEmpty(); - rOutput.aExistenceList[1] = !m_xEd_Sub->get_text().isEmpty(); - rOutput.aExistenceList[2] = !m_xEd_XAxis->get_text().isEmpty(); - rOutput.aExistenceList[3] = !m_xEd_YAxis->get_text().isEmpty(); - rOutput.aExistenceList[4] = !m_xEd_ZAxis->get_text().isEmpty(); - rOutput.aExistenceList[5] = !m_xEd_SecondaryXAxis->get_text().isEmpty(); - rOutput.aExistenceList[6] = !m_xEd_SecondaryYAxis->get_text().isEmpty(); + sal_Bool* pExistenceList = rOutput.aExistenceList.getArray(); + pExistenceList[0] = !m_xEd_Main->get_text().isEmpty(); + pExistenceList[1] = !m_xEd_Sub->get_text().isEmpty(); + pExistenceList[2] = !m_xEd_XAxis->get_text().isEmpty(); + pExistenceList[3] = !m_xEd_YAxis->get_text().isEmpty(); + pExistenceList[4] = !m_xEd_ZAxis->get_text().isEmpty(); + pExistenceList[5] = !m_xEd_SecondaryXAxis->get_text().isEmpty(); + pExistenceList[6] = !m_xEd_SecondaryYAxis->get_text().isEmpty(); - rOutput.aTextList[0] = m_xEd_Main->get_text(); - rOutput.aTextList[1] = m_xEd_Sub->get_text(); - rOutput.aTextList[2] = m_xEd_XAxis->get_text(); - rOutput.aTextList[3] = m_xEd_YAxis->get_text(); - rOutput.aTextList[4] = m_xEd_ZAxis->get_text(); - rOutput.aTextList[5] = m_xEd_SecondaryXAxis->get_text(); - rOutput.aTextList[6] = m_xEd_SecondaryYAxis->get_text(); + auto pTextList = rOutput.aTextList.getArray(); + pTextList[0] = m_xEd_Main->get_text(); + pTextList[1] = m_xEd_Sub->get_text(); + pTextList[2] = m_xEd_XAxis->get_text(); + pTextList[3] = m_xEd_YAxis->get_text(); + pTextList[4] = m_xEd_ZAxis->get_text(); + pTextList[5] = m_xEd_SecondaryXAxis->get_text(); + pTextList[6] = m_xEd_SecondaryYAxis->get_text(); } } //namespace chart diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx index 8fc5e63ee2be..ce8a893702d7 100644 --- a/chart2/source/controller/dialogs/res_Trendline.cxx +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -24,8 +24,8 @@ #include <com/sun/star/chart2/MovingAverageType.hpp> #include <svl/intitem.hxx> +#include <svl/numformat.hxx> #include <svl/stritem.hxx> -#include <svl/zforlist.hxx> #include <vcl/formatter.hxx> #include <vcl/weld.hxx> @@ -46,30 +46,30 @@ TrendlineResources::TrendlineResources(weld::Builder& rBuilder, const SfxItemSet , m_bTrendLineUnique(true) , m_pNumFormatter(nullptr) , m_nNbPoints(0) - , m_xRB_Linear(rBuilder.weld_radio_button("linear")) - , m_xRB_Logarithmic(rBuilder.weld_radio_button("logarithmic")) - , m_xRB_Exponential(rBuilder.weld_radio_button("exponential")) - , m_xRB_Power(rBuilder.weld_radio_button("power")) - , m_xRB_Polynomial(rBuilder.weld_radio_button("polynomial")) - , m_xRB_MovingAverage(rBuilder.weld_radio_button("movingAverage")) - , m_xFI_Linear(rBuilder.weld_image("imageLinear")) - , m_xFI_Logarithmic(rBuilder.weld_image("imageLogarithmic")) - , m_xFI_Exponential(rBuilder.weld_image("imageExponential")) - , m_xFI_Power(rBuilder.weld_image("imagePower")) - , m_xFI_Polynomial(rBuilder.weld_image("imagePolynomial")) - , m_xFI_MovingAverage(rBuilder.weld_image("imageMovingAverage")) - , m_xNF_Degree(rBuilder.weld_spin_button("degree")) - , m_xNF_Period(rBuilder.weld_spin_button("period")) - , m_xEE_Name(rBuilder.weld_entry("entry_name")) - , m_xFmtFld_ExtrapolateForward(rBuilder.weld_formatted_spin_button("extrapolateForward")) - , m_xFmtFld_ExtrapolateBackward(rBuilder.weld_formatted_spin_button("extrapolateBackward")) - , m_xCB_SetIntercept(rBuilder.weld_check_button("setIntercept")) - , m_xFmtFld_InterceptValue(rBuilder.weld_formatted_spin_button("interceptValue")) - , m_xCB_ShowEquation(rBuilder.weld_check_button("showEquation")) - , m_xEE_XName(rBuilder.weld_entry("entry_Xname")) - , m_xEE_YName(rBuilder.weld_entry("entry_Yname")) - , m_xCB_ShowCorrelationCoeff(rBuilder.weld_check_button("showCorrelationCoefficient")) - , m_xCB_RegressionMovingType(rBuilder.weld_combo_box("combo_moving_type")) + , m_xRB_Linear(rBuilder.weld_radio_button(u"linear"_ustr)) + , m_xRB_Logarithmic(rBuilder.weld_radio_button(u"logarithmic"_ustr)) + , m_xRB_Exponential(rBuilder.weld_radio_button(u"exponential"_ustr)) + , m_xRB_Power(rBuilder.weld_radio_button(u"power"_ustr)) + , m_xRB_Polynomial(rBuilder.weld_radio_button(u"polynomial"_ustr)) + , m_xRB_MovingAverage(rBuilder.weld_radio_button(u"movingAverage"_ustr)) + , m_xFI_Linear(rBuilder.weld_image(u"imageLinear"_ustr)) + , m_xFI_Logarithmic(rBuilder.weld_image(u"imageLogarithmic"_ustr)) + , m_xFI_Exponential(rBuilder.weld_image(u"imageExponential"_ustr)) + , m_xFI_Power(rBuilder.weld_image(u"imagePower"_ustr)) + , m_xFI_Polynomial(rBuilder.weld_image(u"imagePolynomial"_ustr)) + , m_xFI_MovingAverage(rBuilder.weld_image(u"imageMovingAverage"_ustr)) + , m_xNF_Degree(rBuilder.weld_spin_button(u"degree"_ustr)) + , m_xNF_Period(rBuilder.weld_spin_button(u"period"_ustr)) + , m_xEE_Name(rBuilder.weld_entry(u"entry_name"_ustr)) + , m_xFmtFld_ExtrapolateForward(rBuilder.weld_formatted_spin_button(u"extrapolateForward"_ustr)) + , m_xFmtFld_ExtrapolateBackward(rBuilder.weld_formatted_spin_button(u"extrapolateBackward"_ustr)) + , m_xCB_SetIntercept(rBuilder.weld_check_button(u"setIntercept"_ustr)) + , m_xFmtFld_InterceptValue(rBuilder.weld_formatted_spin_button(u"interceptValue"_ustr)) + , m_xCB_ShowEquation(rBuilder.weld_check_button(u"showEquation"_ustr)) + , m_xEE_XName(rBuilder.weld_entry(u"entry_Xname"_ustr)) + , m_xEE_YName(rBuilder.weld_entry(u"entry_Yname"_ustr)) + , m_xCB_ShowCorrelationCoeff(rBuilder.weld_check_button(u"showCorrelationCoefficient"_ustr)) + , m_xCB_RegressionMovingType(rBuilder.weld_combo_box(u"combo_moving_type"_ustr)) { FillValueSets(); @@ -126,38 +126,37 @@ IMPL_LINK_NOARG(TrendlineResources, SelectTrendLine, weld::Toggleable&, void) void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) { - const SfxPoolItem *pPoolItem = nullptr; - - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_CURVE_NAME, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxStringItem* pCurveNameItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_CURVE_NAME ) ) { - OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue(); + OUString aName = pCurveNameItem->GetValue(); m_xEE_Name->set_text(aName); } else { - m_xEE_Name->set_text(""); + m_xEE_Name->set_text(u""_ustr); } - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_XNAME, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxStringItem* pRegressionXNameItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_XNAME ) ) { - OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue(); + OUString aName = pRegressionXNameItem->GetValue(); m_xEE_XName->set_text(aName); } else { - m_xEE_XName->set_text("x"); + m_xEE_XName->set_text(u"x"_ustr); } - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_YNAME, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxStringItem* pRegressionYNameItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_YNAME ) ) { - OUString aName = static_cast< const SfxStringItem* >(pPoolItem)->GetValue(); + OUString aName = pRegressionYNameItem->GetValue(); m_xEE_YName->set_text(aName); } else { - m_xEE_YName->set_text("f(x)"); + m_xEE_YName->set_text(u"f(x)"_ustr); } + const SfxPoolItem* pPoolItem = nullptr; SfxItemState aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem ); - m_bTrendLineUnique = ( aState != SfxItemState::DONTCARE ); + m_bTrendLineUnique = ( aState != SfxItemState::INVALID ); if( aState == SfxItemState::SET ) { const SvxChartRegressItem * pItem = dynamic_cast< const SvxChartRegressItem * >( pPoolItem ); @@ -167,9 +166,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } } - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_DEGREE, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pDegreeItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_DEGREE ) ) { - sal_Int32 nDegree = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nDegree = pDegreeItem->GetValue(); m_xNF_Degree->set_value( nDegree ); } else @@ -179,9 +178,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_xNF_Degree->save_value(); - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_PERIOD, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pPeriodItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_PERIOD ) ) { - sal_Int32 nPeriod = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nPeriod = pPeriodItem->GetValue(); m_xNF_Period->set_value( nPeriod ); } else @@ -192,28 +191,28 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_xNF_Period->save_value(); double nValue = 0.0; - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, true, &pPoolItem ) == SfxItemState::SET ) + if( const SvxDoubleItem* pForwardItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD ) ) { - nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ; + nValue = pForwardItem->GetValue() ; } lcl_setValue(*m_xFmtFld_ExtrapolateForward, nValue); nValue = 0.0; - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, true, &pPoolItem ) == SfxItemState::SET ) + if( const SvxDoubleItem* pBackwardItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD ) ) { - nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ; + nValue = pBackwardItem->GetValue() ; } lcl_setValue(*m_xFmtFld_ExtrapolateBackward, nValue); nValue = 0.0; - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_INTERCEPT_VALUE, true, &pPoolItem ) == SfxItemState::SET ) + if( const SvxDoubleItem* pValueItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_INTERCEPT_VALUE ) ) { - nValue = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue() ; + nValue = pValueItem->GetValue() ; } lcl_setValue(*m_xFmtFld_InterceptValue, nValue); aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SET_INTERCEPT, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_SetIntercept->set_state(TRISTATE_INDET); } @@ -224,7 +223,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_ShowEquation->set_state(TRISTATE_INDET); } @@ -235,7 +234,7 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) } aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, true, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_INDET); } @@ -245,9 +244,9 @@ void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) m_xCB_ShowCorrelationCoeff->set_active( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); } - if( rInAttrs.GetItemState( SCHATTR_REGRESSION_MOVING_TYPE, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pMovingTypeItem = rInAttrs.GetItemIfSet( SCHATTR_REGRESSION_MOVING_TYPE ) ) { - sal_Int32 nMovingType = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nMovingType = pMovingTypeItem->GetValue(); if (nMovingType == MovingAverageType::Prior) m_xCB_RegressionMovingType->set_active(0); else if (nMovingType == MovingAverageType::Central) @@ -373,10 +372,8 @@ void TrendlineResources::UpdateControlStates() m_xFmtFld_InterceptValue->set_sensitive( bInterceptAvailable ); if( bMovingAverage ) { - m_xCB_ShowEquation->set_state(TRISTATE_FALSE); m_xCB_ShowCorrelationCoeff->set_state(TRISTATE_FALSE); } - m_xCB_ShowEquation->set_sensitive( !bMovingAverage ); m_xCB_ShowCorrelationCoeff->set_sensitive( !bMovingAverage ); m_xCB_RegressionMovingType->set_sensitive(bMovingAverage); m_xNF_Period->set_sensitive(bMovingAverage); @@ -429,8 +426,6 @@ void TrendlineResources::SetNbPoints( sal_Int32 nNbPoints ) IMPL_LINK_NOARG(TrendlineResources, ShowEquation, weld::Toggleable&, void) { - m_xEE_XName->set_sensitive(m_xCB_ShowEquation->get_active()); - m_xEE_YName->set_sensitive(m_xCB_ShowEquation->get_active()); UpdateControlStates(); } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx index 707c0eff3617..9e0127f23180 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -18,14 +18,13 @@ */ #include "tp_3D_SceneAppearance.hxx" -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> #include <ThreeDHelper.hxx> #include <ControllerLockGuard.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> +#include <Diagram.hxx> #include <com/sun/star/drawing/ShadeMode.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <utility> #include <vcl/svapp.hxx> using namespace ::com::sun::star; @@ -48,16 +47,15 @@ struct lcl_ModelProperties {} }; -lcl_ModelProperties lcl_getPropertiesFromModel( uno::Reference< frame::XModel > const & xModel ) +lcl_ModelProperties lcl_getPropertiesFromModel( rtl::Reference<::chart::ChartModel> const & xModel ) { lcl_ModelProperties aProps; try { - uno::Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( xModel ) ); - uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY_THROW ); - xDiaProp->getPropertyValue( "D3DSceneShadeMode" ) >>= aProps.m_aShadeMode; + rtl::Reference< ::chart::Diagram > xDiagram( xModel->getFirstChartDiagram() ); + xDiagram->getPropertyValue( u"D3DSceneShadeMode"_ustr ) >>= aProps.m_aShadeMode; ::chart::ThreeDHelper::getRoundedEdgesAndObjectLines( xDiagram, aProps.m_nRoundedEdges, aProps.m_nObjectLines ); - aProps.m_eScheme = ::chart::ThreeDHelper::detectScheme( xDiagram ); + aProps.m_eScheme = xDiagram->detectScheme(); } catch( const uno::Exception & ) { @@ -66,13 +64,12 @@ lcl_ModelProperties lcl_getPropertiesFromModel( uno::Reference< frame::XModel > return aProps; } -void lcl_setShadeModeAtModel( uno::Reference< frame::XModel > const & xModel, drawing::ShadeMode aShadeMode ) +void lcl_setShadeModeAtModel( rtl::Reference<::chart::ChartModel> const & xModel, drawing::ShadeMode aShadeMode ) { try { - uno::Reference< beans::XPropertySet > xDiaProp( - ::chart::ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY_THROW ); - xDiaProp->setPropertyValue( "D3DSceneShadeMode" , uno::Any( aShadeMode )); + rtl::Reference< ::chart::Diagram > xDiaProp = xModel->getFirstChartDiagram(); + xDiaProp->setPropertyValue( u"D3DSceneShadeMode"_ustr , uno::Any( aShadeMode )); } catch( const uno::Exception & ) { @@ -90,18 +87,18 @@ namespace chart #define POS_3DSCHEME_CUSTOM 2 ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage(weld::Container* pParent, - const uno::Reference<frame::XModel>& xChartModel, + rtl::Reference<::chart::ChartModel> xChartModel, ControllerLockHelper& rControllerLockHelper) - : m_xChartModel(xChartModel) + : m_xChartModel(std::move(xChartModel)) , m_bUpdateOtherControls(true) , m_bCommitToModel(true) , m_rControllerLockHelper(rControllerLockHelper) - , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneAppearance.ui")) - , m_xContainer(m_xBuilder->weld_container("tp_3D_SceneAppearance")) - , m_xLB_Scheme(m_xBuilder->weld_combo_box("LB_SCHEME")) - , m_xCB_Shading(m_xBuilder->weld_check_button("CB_SHADING")) - , m_xCB_ObjectLines(m_xBuilder->weld_check_button("CB_OBJECTLINES")) - , m_xCB_RoundedEdge(m_xBuilder->weld_check_button("CB_ROUNDEDEDGE")) + , m_xBuilder(Application::CreateBuilder(pParent, u"modules/schart/ui/tp_3D_SceneAppearance.ui"_ustr)) + , m_xContainer(m_xBuilder->weld_container(u"tp_3D_SceneAppearance"_ustr)) + , m_xLB_Scheme(m_xBuilder->weld_combo_box(u"LB_SCHEME"_ustr)) + , m_xCB_Shading(m_xBuilder->weld_check_button(u"CB_SHADING"_ustr)) + , m_xCB_ObjectLines(m_xBuilder->weld_check_button(u"CB_OBJECTLINES"_ustr)) + , m_xCB_RoundedEdge(m_xBuilder->weld_check_button(u"CB_ROUNDEDEDGE"_ustr)) { m_aCustom = m_xLB_Scheme->get_text(POS_3DSCHEME_CUSTOM); m_xLB_Scheme->remove(POS_3DSCHEME_CUSTOM); @@ -161,7 +158,7 @@ void ThreeD_SceneAppearance_TabPage::applyRoundedEdgeAndObjectLinesToModel() // locked controllers ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); ThreeDHelper::setRoundedEdgesAndObjectLines( - ::chart::ChartModelHelper::findDiagram( m_xChartModel ), nCurrentRoundedEdges, nObjectLines ); + m_xChartModel->getFirstChartDiagram(), nCurrentRoundedEdges, nObjectLines ); } void ThreeD_SceneAppearance_TabPage::applyShadeModeToModel() @@ -272,12 +269,12 @@ IMPL_LINK_NOARG(ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, weld::ComboBox& // locked controllers ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); - uno::Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( m_xChartModel ) ); + rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); if( m_xLB_Scheme->get_active() == POS_3DSCHEME_REALISTIC ) - ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme::ThreeDLookScheme_Realistic ); + xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Realistic ); else if( m_xLB_Scheme->get_active() == POS_3DSCHEME_SIMPLE ) - ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme::ThreeDLookScheme_Simple ); + xDiagram->setScheme( ThreeDLookScheme::ThreeDLookScheme_Simple ); else { OSL_FAIL( "Invalid Entry selected" ); diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx index 1f13240b0015..0f5d82d10f1d 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx @@ -21,17 +21,17 @@ #include <vcl/weld.hxx> namespace chart { class ControllerLockHelper; } -namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; class ThreeD_SceneAppearance_TabPage { public: ThreeD_SceneAppearance_TabPage( weld::Container* pParent, - const css::uno::Reference< css::frame::XModel > & xChartModel, + rtl::Reference<::chart::ChartModel> xChartModel, ControllerLockHelper & rControllerLockHelper ); void ActivatePage(); ~ThreeD_SceneAppearance_TabPage(); @@ -47,7 +47,7 @@ private: void updateScheme(); private: - css::uno::Reference<css::frame::XModel> m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; bool m_bUpdateOtherControls; bool m_bCommitToModel; diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx index fca47ad13d45..99755db26f9e 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -19,13 +19,15 @@ #include "tp_3D_SceneGeometry.hxx" -#include <DiagramHelper.hxx> +#include <Diagram.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <ThreeDHelper.hxx> #include <ControllerLockGuard.hxx> #include <com/sun/star/drawing/ProjectionMode.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/helpers.hxx> +#include <utility> #include <vcl/svapp.hxx> namespace chart @@ -44,27 +46,29 @@ void lcl_SetMetricFieldLimits(weld::MetricSpinButton& rField, sal_Int64 nLimit) } ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage(weld::Container* pParent, - const uno::Reference< beans::XPropertySet > & xSceneProperties, + rtl::Reference< ::chart::Diagram > xDiagram, ControllerLockHelper & rControllerLockHelper) - : m_xSceneProperties( xSceneProperties ) + : m_xDiagram(std::move( xDiagram )) + , m_aAngleTimer("chart2 ThreeD_SceneGeometry_TabPage m_aAngleTimer") + , m_aPerspectiveTimer("chart2 ThreeD_SceneGeometry_TabPage m_aPerspectiveTimer") , m_nXRotation(0) , m_nYRotation(0) , m_nZRotation(0) , m_bAngleChangePending( false ) , m_bPerspectiveChangePending( false ) , m_rControllerLockHelper( rControllerLockHelper ) - , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneGeometry.ui")) - , m_xContainer(m_xBuilder->weld_container("tp_3DSceneGeometry")) - , m_xCbxRightAngledAxes(m_xBuilder->weld_check_button("CBX_RIGHT_ANGLED_AXES")) - , m_xMFXRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_X_ROTATION", FieldUnit::DEGREE)) - , m_xMFYRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_Y_ROTATION", FieldUnit::DEGREE)) - , m_xFtZRotation(m_xBuilder->weld_label("FT_Z_ROTATION")) - , m_xMFZRotation(m_xBuilder->weld_metric_spin_button("MTR_FLD_Z_ROTATION", FieldUnit::DEGREE)) - , m_xCbxPerspective(m_xBuilder->weld_check_button("CBX_PERSPECTIVE")) - , m_xMFPerspective(m_xBuilder->weld_metric_spin_button("MTR_FLD_PERSPECTIVE", FieldUnit::PERCENT)) + , m_xBuilder(Application::CreateBuilder(pParent, u"modules/schart/ui/tp_3D_SceneGeometry.ui"_ustr)) + , m_xContainer(m_xBuilder->weld_container(u"tp_3DSceneGeometry"_ustr)) + , m_xCbxRightAngledAxes(m_xBuilder->weld_check_button(u"CBX_RIGHT_ANGLED_AXES"_ustr)) + , m_xMFXRotation(m_xBuilder->weld_metric_spin_button(u"MTR_FLD_X_ROTATION"_ustr, FieldUnit::DEGREE)) + , m_xMFYRotation(m_xBuilder->weld_metric_spin_button(u"MTR_FLD_Y_ROTATION"_ustr, FieldUnit::DEGREE)) + , m_xFtZRotation(m_xBuilder->weld_label(u"FT_Z_ROTATION"_ustr)) + , m_xMFZRotation(m_xBuilder->weld_metric_spin_button(u"MTR_FLD_Z_ROTATION"_ustr, FieldUnit::DEGREE)) + , m_xCbxPerspective(m_xBuilder->weld_check_button(u"CBX_PERSPECTIVE"_ustr)) + , m_xMFPerspective(m_xBuilder->weld_metric_spin_button(u"MTR_FLD_PERSPECTIVE"_ustr, FieldUnit::PERCENT)) { double fXAngle, fYAngle, fZAngle; - ThreeDHelper::getRotationAngleFromDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); + m_xDiagram->getRotationAngle( fXAngle, fYAngle, fZAngle ); fXAngle = basegfx::rad2deg(fXAngle); fYAngle = basegfx::rad2deg(fYAngle); @@ -95,12 +99,12 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage(weld::Container* pPar m_xMFZRotation->connect_value_changed( aAngleEditedLink ); drawing::ProjectionMode aProjectionMode = drawing::ProjectionMode_PERSPECTIVE; - m_xSceneProperties->getPropertyValue( "D3DScenePerspective" ) >>= aProjectionMode; + m_xDiagram->getPropertyValue( u"D3DScenePerspective"_ustr ) >>= aProjectionMode; m_xCbxPerspective->set_active( aProjectionMode == drawing::ProjectionMode_PERSPECTIVE ); m_xCbxPerspective->connect_toggled( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveToggled )); sal_Int32 nPerspectivePercentage = 20; - m_xSceneProperties->getPropertyValue( "Perspective" ) >>= nPerspectivePercentage; + m_xDiagram->getPropertyValue( u"Perspective"_ustr ) >>= nPerspectivePercentage; m_xMFPerspective->set_value(nPerspectivePercentage, FieldUnit::PERCENT); m_aPerspectiveTimer.SetTimeout(nTimeout); @@ -109,11 +113,11 @@ ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage(weld::Container* pPar m_xMFPerspective->set_sensitive( m_xCbxPerspective->get_active() ); //RightAngledAxes - uno::Reference< chart2::XDiagram > xDiagram( m_xSceneProperties, uno::UNO_QUERY ); - if (ChartTypeHelper::isSupportingRightAngledAxes(DiagramHelper::getChartTypeByIndex(xDiagram, 0))) + auto xChartType = m_xDiagram->getChartTypeByIndex(0); + if (xChartType.is() && xChartType->isSupportingRightAngledAxes()) { bool bRightAngledAxes = false; - m_xSceneProperties->getPropertyValue( "RightAngledAxes" ) >>= bRightAngledAxes; + m_xDiagram->getPropertyValue( u"RightAngledAxes"_ustr ) >>= bRightAngledAxes; m_xCbxRightAngledAxes->connect_toggled( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled )); m_xCbxRightAngledAxes->set_active( bRightAngledAxes ); RightAngledAxesToggled(*m_xCbxRightAngledAxes); @@ -155,7 +159,7 @@ void ThreeD_SceneGeometry_TabPage::applyAnglesToModel() fYAngle = basegfx::deg2rad(fYAngle); fZAngle = basegfx::deg2rad(fZAngle); - ThreeDHelper::setRotationAngleToDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); + m_xDiagram->setRotationAngle( fXAngle, fYAngle, fZAngle ); m_bAngleChangePending = false; m_aAngleTimer.Stop(); @@ -186,8 +190,8 @@ void ThreeD_SceneGeometry_TabPage::applyPerspectiveToModel() try { - m_xSceneProperties->setPropertyValue( "D3DScenePerspective" , uno::Any( aMode )); - m_xSceneProperties->setPropertyValue( "Perspective" , uno::Any( static_cast<sal_Int32>(m_xMFPerspective->get_value(FieldUnit::PERCENT)) )); + m_xDiagram->setPropertyValue( u"D3DScenePerspective"_ustr , uno::Any( aMode )); + m_xDiagram->setPropertyValue( u"Perspective"_ustr , uno::Any( static_cast<sal_Int32>(m_xMFPerspective->get_value(FieldUnit::PERCENT)) )); } catch( const uno::Exception & ) { @@ -230,7 +234,7 @@ IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, weld::Togg m_xMFXRotation->set_value(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nXRotation), ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())), FieldUnit::DEGREE); m_xMFYRotation->set_value(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nYRotation), ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())), FieldUnit::DEGREE); - m_xMFZRotation->set_text(""); + m_xMFZRotation->set_text(u""_ustr); lcl_SetMetricFieldLimits( *m_xMFXRotation, static_cast<sal_Int64>(ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())); lcl_SetMetricFieldLimits( *m_xMFYRotation, static_cast<sal_Int64>(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())); @@ -245,7 +249,8 @@ IMPL_LINK_NOARG(ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, weld::Togg m_xMFZRotation->set_value(m_nZRotation, FieldUnit::DEGREE); } - ThreeDHelper::switchRightAngledAxes( m_xSceneProperties, m_xCbxRightAngledAxes->get_active() ); + if (m_xDiagram) + m_xDiagram->switchRightAngledAxes( m_xCbxRightAngledAxes->get_active() ); } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx index ca7f75ebea0d..027070048501 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx @@ -20,18 +20,19 @@ #include <vcl/timer.hxx> #include <vcl/weld.hxx> +#include <rtl/ref.hxx> -namespace com::sun::star::beans { class XPropertySet; } namespace chart { class ControllerLockHelper; } namespace chart { +class Diagram; class ThreeD_SceneGeometry_TabPage { public: ThreeD_SceneGeometry_TabPage(weld::Container* pWindow, - const css::uno::Reference< css::beans::XPropertySet > & xSceneProperties, + rtl::Reference< ::chart::Diagram > xDiagram, ControllerLockHelper & rControllerLockHelper); ~ThreeD_SceneGeometry_TabPage(); @@ -54,7 +55,7 @@ private: void applyAnglesToModel(); void applyPerspectiveToModel(); - css::uno::Reference< css::beans::XPropertySet > m_xSceneProperties; + rtl::Reference< ::chart::Diagram > m_xDiagram; Timer m_aAngleTimer; Timer m_aPerspectiveTimer; diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx index c4b28162d08c..4a43cbbadaeb 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -20,16 +20,18 @@ #include "tp_3D_SceneIllumination.hxx" #include <CommonConverters.hxx> #include <ControllerLockGuard.hxx> +#include <ChartModel.hxx> #include <svx/colorbox.hxx> #include <svx/float3d.hxx> #include <svx/strings.hrc> #include <svx/dialmgr.hxx> -#include <svtools/colrdlg.hxx> #include <svx/svx3ditems.hxx> #include <svx/svddef.hxx> +#include <utility> +#include <vcl/ColorDialog.hxx> #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -67,7 +69,6 @@ struct LightSourceInfo LightSourceInfo::LightSourceInfo() : pButton(nullptr) - , aLightSource() { aLightSource.nDiffuseColor = Color(0xffffff); // white aLightSource.aDirection = drawing::Direction3D(1,1,1); @@ -99,7 +100,7 @@ namespace void lcl_selectColor(ColorListBox& rListBox, const Color& rColor) { rListBox.SetNoSelection(); - rListBox.SelectEntry(std::make_pair(rColor, lcl_makeColorName(rColor))); + rListBox.SelectEntry({rColor, lcl_makeColorName(rColor)}); } ::chart::LightSource lcl_getLightSourceFromProperties( @@ -138,7 +139,7 @@ namespace try { xSceneProperties->setPropertyValue( "D3DSceneLightColor" + aIndex, - uno::makeAny( rLightSource.nDiffuseColor )); + uno::Any( rLightSource.nDiffuseColor )); xSceneProperties->setPropertyValue( "D3DSceneLightDirection" + aIndex, uno::Any( rLightSource.aDirection )); xSceneProperties->setPropertyValue( "D3DSceneLightOn" + aIndex, @@ -156,7 +157,7 @@ namespace Color nResult; try { - xSceneProperties->getPropertyValue("D3DSceneAmbientColor") >>= nResult; + xSceneProperties->getPropertyValue(u"D3DSceneAmbientColor"_ustr) >>= nResult; } catch( const uno::Exception & ) { @@ -171,8 +172,8 @@ namespace { try { - xSceneProperties->setPropertyValue("D3DSceneAmbientColor", - uno::makeAny( rColor )); + xSceneProperties->setPropertyValue(u"D3DSceneAmbientColor"_ustr, + uno::Any( rColor )); } catch( const uno::Exception & ) { @@ -183,55 +184,55 @@ namespace ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage(weld::Container* pParent, weld::Window* pTopLevel, - const uno::Reference< beans::XPropertySet > & xSceneProperties, - const uno::Reference< frame::XModel >& xChartModel) - : m_xSceneProperties( xSceneProperties ) + uno::Reference< beans::XPropertySet > xSceneProperties, + const rtl::Reference<::chart::ChartModel>& xChartModel) + : m_xSceneProperties(std::move( xSceneProperties )) , m_aTimerTriggeredControllerLock( xChartModel ) , m_bInCommitToModel( false ) , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage, fillControlsFromModel ) ) , m_xChartModel( xChartModel ) , m_pTopLevel(pTopLevel) - , m_xBuilder(Application::CreateBuilder(pParent, "modules/schart/ui/tp_3D_SceneIllumination.ui")) - , m_xContainer(m_xBuilder->weld_container("tp_3D_SceneIllumination")) - , m_xBtn_Light1(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_1"))) - , m_xBtn_Light2(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_2"))) - , m_xBtn_Light3(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_3"))) - , m_xBtn_Light4(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_4"))) - , m_xBtn_Light5(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_5"))) - , m_xBtn_Light6(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_6"))) - , m_xBtn_Light7(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_7"))) - , m_xBtn_Light8(new LightButton(m_xBuilder->weld_toggle_button("BTN_LIGHT_8"))) - , m_xLB_LightSource(new ColorListBox(m_xBuilder->weld_menu_button("LB_LIGHTSOURCE"), [this]{ return m_pTopLevel; })) - , m_xBtn_LightSource_Color(m_xBuilder->weld_button("BTN_LIGHTSOURCE_COLOR")) - , m_xLB_AmbientLight(new ColorListBox(m_xBuilder->weld_menu_button("LB_AMBIENTLIGHT"), [this]{ return m_pTopLevel; })) - , m_xBtn_AmbientLight_Color(m_xBuilder->weld_button("BTN_AMBIENT_COLOR")) - , m_xHoriScale(m_xBuilder->weld_scale("hori")) - , m_xVertScale(m_xBuilder->weld_scale("vert")) - , m_xBtn_Corner(m_xBuilder->weld_button("corner")) + , m_xBuilder(Application::CreateBuilder(pParent, u"modules/schart/ui/tp_3D_SceneIllumination.ui"_ustr)) + , m_xContainer(m_xBuilder->weld_container(u"tp_3D_SceneIllumination"_ustr)) + , m_aBtn_Light1(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_1"_ustr)) + , m_aBtn_Light2(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_2"_ustr)) + , m_aBtn_Light3(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_3"_ustr)) + , m_aBtn_Light4(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_4"_ustr)) + , m_aBtn_Light5(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_5"_ustr)) + , m_aBtn_Light6(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_6"_ustr)) + , m_aBtn_Light7(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_7"_ustr)) + , m_aBtn_Light8(m_xBuilder->weld_toggle_button(u"BTN_LIGHT_8"_ustr)) + , m_xLB_LightSource(new ColorListBox(m_xBuilder->weld_menu_button(u"LB_LIGHTSOURCE"_ustr), [this]{ return m_pTopLevel; })) + , m_xBtn_LightSource_Color(m_xBuilder->weld_button(u"BTN_LIGHTSOURCE_COLOR"_ustr)) + , m_xLB_AmbientLight(new ColorListBox(m_xBuilder->weld_menu_button(u"LB_AMBIENTLIGHT"_ustr), [this]{ return m_pTopLevel; })) + , m_xBtn_AmbientLight_Color(m_xBuilder->weld_button(u"BTN_AMBIENT_COLOR"_ustr)) + , m_xHoriScale(m_xBuilder->weld_scale(u"hori"_ustr)) + , m_xVertScale(m_xBuilder->weld_scale(u"vert"_ustr)) + , m_xBtn_Corner(m_xBuilder->weld_button(u"corner"_ustr)) , m_xPreview(new Svx3DLightControl) - , m_xPreviewWnd(new weld::CustomWeld(*m_xBuilder, "CTL_LIGHT_PREVIEW", *m_xPreview)) + , m_xPreviewWnd(new weld::CustomWeld(*m_xBuilder, u"CTL_LIGHT_PREVIEW"_ustr, *m_xPreview)) , m_xCtl_Preview(new SvxLightCtl3D(*m_xPreview, *m_xHoriScale, *m_xVertScale, *m_xBtn_Corner)) { m_pLightSourceInfoList.reset(new LightSourceInfo[8]); - m_pLightSourceInfoList[0].pButton = m_xBtn_Light1.get(); - m_pLightSourceInfoList[1].pButton = m_xBtn_Light2.get(); - m_pLightSourceInfoList[2].pButton = m_xBtn_Light3.get(); - m_pLightSourceInfoList[3].pButton = m_xBtn_Light4.get(); - m_pLightSourceInfoList[4].pButton = m_xBtn_Light5.get(); - m_pLightSourceInfoList[5].pButton = m_xBtn_Light6.get(); - m_pLightSourceInfoList[6].pButton = m_xBtn_Light7.get(); - m_pLightSourceInfoList[7].pButton = m_xBtn_Light8.get(); + m_pLightSourceInfoList[0].pButton = &m_aBtn_Light1; + m_pLightSourceInfoList[1].pButton = &m_aBtn_Light2; + m_pLightSourceInfoList[2].pButton = &m_aBtn_Light3; + m_pLightSourceInfoList[3].pButton = &m_aBtn_Light4; + m_pLightSourceInfoList[4].pButton = &m_aBtn_Light5; + m_pLightSourceInfoList[5].pButton = &m_aBtn_Light6; + m_pLightSourceInfoList[6].pButton = &m_aBtn_Light7; + m_pLightSourceInfoList[7].pButton = &m_aBtn_Light8; fillControlsFromModel(nullptr); - m_xBtn_Light1->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light2->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light3->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light4->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light5->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light6->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light7->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); - m_xBtn_Light8->connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light1.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light2.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light3.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light4.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light5.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light6.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light7.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light8.connect_clicked( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); m_xLB_AmbientLight->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); m_xLB_LightSource->SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); @@ -242,13 +243,15 @@ ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage(weld::Contain m_xCtl_Preview->SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) ); m_xCtl_Preview->SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) ); - ClickLightSourceButtonHdl(*m_xBtn_Light2->get_widget()); + ClickLightSourceButtonHdl(*m_aBtn_Light2.get_widget()); m_aModelChangeListener.startListening( uno::Reference< util::XModifyBroadcaster >(m_xSceneProperties, uno::UNO_QUERY) ); } ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage() { + // drop page view before the widget it paints to is destroyed + m_xPreview->ClearPageView(); } IMPL_LINK_NOARG(ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void*, void) @@ -353,9 +356,9 @@ IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, weld::Button&, rBut bool bIsAmbientLight = (&rButton == m_xBtn_AmbientLight_Color.get()); ColorListBox* pListBox = bIsAmbientLight ? m_xLB_AmbientLight.get() : m_xLB_LightSource.get(); - SvColorDialog aColorDlg; + ColorDialog aColorDlg(m_pTopLevel); aColorDlg.SetColor( pListBox->GetSelectEntryColor() ); - if( aColorDlg.Execute(m_pTopLevel) != RET_OK ) + if (aColorDlg.Execute() != RET_OK) return; Color aColor( aColorDlg.GetColor()); @@ -434,20 +437,20 @@ IMPL_LINK(ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, weld::But bool bIsChecked = pInfo->pButton->get_prev_active(); ControllerLockGuardUNO aGuard( m_xChartModel ); - for( nL=0; nL<8; nL++) + for (sal_Int32 i = 0; i < 8; ++i) { - LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton; + LightButton* pLightButton = m_pLightSourceInfoList[i].pButton; if (pLightButton == pButton) { pLightButton->set_active(true); if (!pLightButton->get_widget()->has_focus()) pLightButton->get_widget()->grab_focus(); - m_pLightSourceInfoList[nL].pButton->set_prev_active(true); + m_pLightSourceInfoList[i].pButton->set_prev_active(true); } else { pLightButton->set_active(false); - m_pLightSourceInfoList[nL].pButton->set_prev_active(false); + m_pLightSourceInfoList[i].pButton->set_prev_active(false); } } diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx index 29cc518631ad..98a1f3273620 100644 --- a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx @@ -22,6 +22,7 @@ #include <TimerTriggeredControllerLock.hxx> #include <vcl/weld.hxx> #include <svx/dlgctl3d.hxx> +#include <svx/float3d.hxx> namespace com::sun::star::beans { @@ -29,19 +30,18 @@ class XPropertySet; } class ColorListBox; -class LightButton; namespace chart { struct LightSourceInfo; +class ChartModel; class ThreeD_SceneIllumination_TabPage { public: - ThreeD_SceneIllumination_TabPage( - weld::Container* pParent, weld::Window* pTopLevel, - const css::uno::Reference<css::beans::XPropertySet>& xSceneProperties, - const css::uno::Reference<css::frame::XModel>& xChartModel); + ThreeD_SceneIllumination_TabPage(weld::Container* pParent, weld::Window* pTopLevel, + css::uno::Reference<css::beans::XPropertySet> xSceneProperties, + const rtl::Reference<::chart::ChartModel>& xChartModel); ~ThreeD_SceneIllumination_TabPage(); private: @@ -68,19 +68,19 @@ private: bool m_bInCommitToModel; ModifyListenerCallBack m_aModelChangeListener; - css::uno::Reference<css::frame::XModel> m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; weld::Window* m_pTopLevel; std::unique_ptr<weld::Builder> m_xBuilder; std::unique_ptr<weld::Container> m_xContainer; - std::unique_ptr<LightButton> m_xBtn_Light1; - std::unique_ptr<LightButton> m_xBtn_Light2; - std::unique_ptr<LightButton> m_xBtn_Light3; - std::unique_ptr<LightButton> m_xBtn_Light4; - std::unique_ptr<LightButton> m_xBtn_Light5; - std::unique_ptr<LightButton> m_xBtn_Light6; - std::unique_ptr<LightButton> m_xBtn_Light7; - std::unique_ptr<LightButton> m_xBtn_Light8; + LightButton m_aBtn_Light1; + LightButton m_aBtn_Light2; + LightButton m_aBtn_Light3; + LightButton m_aBtn_Light4; + LightButton m_aBtn_Light5; + LightButton m_aBtn_Light6; + LightButton m_aBtn_Light7; + LightButton m_aBtn_Light8; std::unique_ptr<ColorListBox> m_xLB_LightSource; std::unique_ptr<weld::Button> m_xBtn_LightSource_Color; std::unique_ptr<ColorListBox> m_xLB_AmbientLight; diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx index 9871bfa4187a..396086bb46a6 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.cxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -24,7 +24,6 @@ #include <svx/chrtitem.hxx> #include <svx/sdangitm.hxx> -#include <svl/intitem.hxx> #include <editeng/eeitem.hxx> #include <editeng/frmdiritem.hxx> @@ -32,31 +31,30 @@ namespace chart { SchAxisLabelTabPage::SchAxisLabelTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_axisLabel.ui", "AxisLabelTabPage", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_axisLabel.ui"_ustr, u"AxisLabelTabPage"_ustr, &rInAttrs) , m_bShowStaggeringControls( true ) , m_nInitialDegrees( 0 ) , m_bHasInitialDegrees( true ) , m_bInitialStacking( false ) , m_bHasInitialStacking( true ) , m_bComplexCategories( false ) - , m_xCbShowDescription(m_xBuilder->weld_check_button("showlabelsCB")) - , m_xFlOrder(m_xBuilder->weld_label("orderL")) - , m_xRbSideBySide(m_xBuilder->weld_radio_button("tile")) - , m_xRbUpDown(m_xBuilder->weld_radio_button("odd")) - , m_xRbDownUp(m_xBuilder->weld_radio_button("even")) - , m_xRbAuto(m_xBuilder->weld_radio_button("auto")) - , m_xFlTextFlow(m_xBuilder->weld_label("textflowL")) - , m_xCbTextOverlap(m_xBuilder->weld_check_button("overlapCB")) - , m_xCbTextBreak(m_xBuilder->weld_check_button("breakCB")) - , m_xFtABCD(m_xBuilder->weld_label("labelABCD")) - , m_xFlOrient(m_xBuilder->weld_label("labelTextOrient")) - , m_xFtRotate(m_xBuilder->weld_label("degreeL")) - , m_xNfRotate(m_xBuilder->weld_metric_spin_button("OrientDegree", FieldUnit::DEGREE)) - , m_xCbStacked(m_xBuilder->weld_check_button("stackedCB")) - , m_xFtTextDirection(m_xBuilder->weld_label("textdirL")) - , m_xLbTextDirection(new TextDirectionListBox(m_xBuilder->weld_combo_box("textdirLB"))) + , m_xCbShowDescription(m_xBuilder->weld_check_button(u"showlabelsCB"_ustr)) + , m_xFlOrder(m_xBuilder->weld_label(u"orderL"_ustr)) + , m_xRbSideBySide(m_xBuilder->weld_radio_button(u"tile"_ustr)) + , m_xRbUpDown(m_xBuilder->weld_radio_button(u"odd"_ustr)) + , m_xRbDownUp(m_xBuilder->weld_radio_button(u"even"_ustr)) + , m_xRbAuto(m_xBuilder->weld_radio_button(u"auto"_ustr)) + , m_xFlTextFlow(m_xBuilder->weld_label(u"textflowL"_ustr)) + , m_xCbTextOverlap(m_xBuilder->weld_check_button(u"overlapCB"_ustr)) + , m_xCbTextBreak(m_xBuilder->weld_check_button(u"breakCB"_ustr)) + , m_xFtABCD(m_xBuilder->weld_label(u"labelABCD"_ustr)) + , m_xFtRotate(m_xBuilder->weld_label(u"degreeL"_ustr)) + , m_xNfRotate(m_xBuilder->weld_metric_spin_button(u"OrientDegree"_ustr, FieldUnit::DEGREE)) + , m_xCbStacked(m_xBuilder->weld_check_button(u"stackedCB"_ustr)) + , m_xFtTextDirection(m_xBuilder->weld_label(u"textdirL"_ustr)) + , m_aLbTextDirection(m_xBuilder->weld_combo_box(u"textdirLB"_ustr)) , m_xCtrlDial(new svx::DialControl) - , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialCtrl", *m_xCtrlDial)) + , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, u"dialCtrl"_ustr, *m_xCtrlDial)) { m_xCtrlDial->SetText(m_xFtABCD->get_label()); m_xCtrlDial->SetLinkedField(m_xNfRotate.get()); @@ -73,7 +71,6 @@ SchAxisLabelTabPage::~SchAxisLabelTabPage() { m_xCtrlDialWin.reset(); m_xCtrlDial.reset(); - m_xLbTextDirection.reset(); } std::unique_ptr<SfxTabPage> SchAxisLabelTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rAttrs) @@ -125,8 +122,8 @@ bool SchAxisLabelTabPage::FillItemSet( SfxItemSet* rOutAttrs ) if( m_xCbShowDescription->get_state() != TRISTATE_INDET ) rOutAttrs->Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, m_xCbShowDescription->get_active() ) ); - if (m_xLbTextDirection->get_active() != -1) - rOutAttrs->Put( SvxFrameDirectionItem( m_xLbTextDirection->get_active_id(), EE_PARA_WRITINGDIR ) ); + if (m_aLbTextDirection.get_active() != -1) + rOutAttrs->Put( SvxFrameDirectionItem( m_aLbTextDirection.get_active_id(), EE_PARA_WRITINGDIR ) ); return true; } @@ -137,7 +134,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs ) // show description SfxItemState aState = rInAttrs->GetItemState( SCHATTR_AXIS_SHOWDESCR, false, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCbShowDescription->set_state( TRISTATE_INDET ); } @@ -160,7 +157,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs ) if( aState == SfxItemState::SET ) m_nInitialDegrees = static_cast< const SdrAngleItem * >( pPoolItem )->GetValue(); - m_bHasInitialDegrees = aState != SfxItemState::DONTCARE; + m_bHasInitialDegrees = aState != SfxItemState::INVALID; if( m_bHasInitialDegrees ) m_xCtrlDial->SetRotation( m_nInitialDegrees ); else @@ -172,19 +169,19 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs ) if( aState == SfxItemState::SET ) m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); - m_bHasInitialStacking = aState != SfxItemState::DONTCARE; + m_bHasInitialStacking = aState != SfxItemState::INVALID; if( m_bHasInitialDegrees ) m_xCbStacked->set_state(m_bInitialStacking ? TRISTATE_TRUE : TRISTATE_FALSE); else m_xCbStacked->set_state(TRISTATE_INDET); StackedToggleHdl(*m_xCbStacked); - if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET ) - m_xLbTextDirection->set_active_id( static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() ); + if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet( EE_PARA_WRITINGDIR ) ) + m_aLbTextDirection.set_active_id( pDirectionItem->GetValue() ); // Text overlap ---------- aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_OVERLAP, false, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCbTextOverlap->set_state( TRISTATE_INDET ); } @@ -201,7 +198,7 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs ) // text break ---------- aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_BREAK, false, &pPoolItem ); - if( aState == SfxItemState::DONTCARE ) + if( aState == SfxItemState::INVALID ) { m_xCbTextBreak->set_state( TRISTATE_INDET ); } @@ -223,10 +220,9 @@ void SchAxisLabelTabPage::Reset( const SfxItemSet* rInAttrs ) // text order ---------- if( m_bShowStaggeringControls ) { - aState = rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_ORDER, false, &pPoolItem ); - if( aState == SfxItemState::SET ) + if( const SvxChartTextOrderItem* pOrderItem = rInAttrs->GetItemIfSet( SCHATTR_AXIS_LABEL_ORDER, false ) ) { - SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); + SvxChartTextOrder eOrder = pOrderItem->GetValue(); switch( eOrder ) { @@ -297,7 +293,7 @@ IMPL_LINK_NOARG(SchAxisLabelTabPage, ToggleShowLabel, weld::Toggleable&, void) m_xCbTextBreak->set_sensitive( bEnable ); m_xFtTextDirection->set_sensitive( bEnable ); - m_xLbTextDirection->set_sensitive( bEnable ); + m_aLbTextDirection.set_sensitive( bEnable ); } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx index a94a030fe9a1..f3062163e28c 100644 --- a/chart2/source/controller/dialogs/tp_AxisLabel.hxx +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -21,15 +21,13 @@ #include <sfx2/tabdlg.hxx> #include <svx/dialcontrol.hxx> #include <tools/degree.hxx> +#include <TextDirectionListBox.hxx> -namespace chart { class TextDirectionListBox; } namespace weld { class CheckButton; class CustomWeld; class Label; class RadioButton; - class SpinButton; - class ToggleButton; } namespace chart @@ -56,12 +54,11 @@ private: std::unique_ptr<weld::CheckButton> m_xCbTextOverlap; std::unique_ptr<weld::CheckButton> m_xCbTextBreak; std::unique_ptr<weld::Label> m_xFtABCD; - std::unique_ptr<weld::Label> m_xFlOrient; std::unique_ptr<weld::Label> m_xFtRotate; std::unique_ptr<weld::MetricSpinButton> m_xNfRotate; std::unique_ptr<weld::CheckButton> m_xCbStacked; std::unique_ptr<weld::Label> m_xFtTextDirection; - std::unique_ptr<TextDirectionListBox> m_xLbTextDirection; + TextDirectionListBox m_aLbTextDirection; std::unique_ptr<svx::DialControl> m_xCtrlDial; std::unique_ptr<weld::CustomWeld> m_xCtrlDialWin; diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx index d4e7fa218023..2faddaad81dd 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.cxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -33,29 +33,26 @@ namespace chart { AxisPositionsTabPage::AxisPositionsTabPage(weld::Container* pPage, weld::DialogController* pController,const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_AxisPositions.ui", "tp_AxisPositions", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_AxisPositions.ui"_ustr, u"tp_AxisPositions"_ustr, &rInAttrs) , m_pNumFormatter(nullptr) , m_bCrossingAxisIsCategoryAxis(false) - , m_aCategories() , m_bSupportAxisPositioning(false) , m_bSupportCategoryPositioning(false) - , m_xFL_AxisLine(m_xBuilder->weld_frame("FL_AXIS_LINE")) - , m_xLB_CrossesAt(m_xBuilder->weld_combo_box("LB_CROSSES_OTHER_AXIS_AT")) - , m_xED_CrossesAt(m_xBuilder->weld_formatted_spin_button("EDT_CROSSES_OTHER_AXIS_AT")) - , m_xED_CrossesAtCategory(m_xBuilder->weld_combo_box( "EDT_CROSSES_OTHER_AXIS_AT_CATEGORY")) - , m_xCB_AxisBetweenCategories(m_xBuilder->weld_check_button("CB_AXIS_BETWEEN_CATEGORIES")) - , m_xFL_Position(m_xBuilder->weld_frame("FL_POSITION")) - , m_xRB_On(m_xBuilder->weld_radio_button("RB_ON")) - , m_xRB_Between(m_xBuilder->weld_radio_button("RB_BETWEEN")) - , m_xFL_Labels(m_xBuilder->weld_frame("FL_LABELS")) - , m_xLB_PlaceLabels(m_xBuilder->weld_combo_box("LB_PLACE_LABELS")) - , m_xED_LabelDistance(m_xBuilder->weld_formatted_spin_button("EDT_AXIS_LABEL_DISTANCE")) - , m_xCB_TicksInner(m_xBuilder->weld_check_button("CB_TICKS_INNER")) - , m_xCB_TicksOuter(m_xBuilder->weld_check_button("CB_TICKS_OUTER")) - , m_xCB_MinorInner(m_xBuilder->weld_check_button("CB_MINOR_INNER")) - , m_xCB_MinorOuter(m_xBuilder->weld_check_button("CB_MINOR_OUTER")) - , m_xBxPlaceTicks(m_xBuilder->weld_widget("boxPLACE_TICKS")) - , m_xLB_PlaceTicks(m_xBuilder->weld_combo_box("LB_PLACE_TICKS")) + , m_xFL_AxisLine(m_xBuilder->weld_frame(u"FL_AXIS_LINE"_ustr)) + , m_xLB_CrossesAt(m_xBuilder->weld_combo_box(u"LB_CROSSES_OTHER_AXIS_AT"_ustr)) + , m_xED_CrossesAt(m_xBuilder->weld_formatted_spin_button(u"EDT_CROSSES_OTHER_AXIS_AT"_ustr)) + , m_xED_CrossesAtCategory(m_xBuilder->weld_combo_box( u"EDT_CROSSES_OTHER_AXIS_AT_CATEGORY"_ustr)) + , m_xFL_Position(m_xBuilder->weld_frame(u"FL_POSITION"_ustr)) + , m_xRB_On(m_xBuilder->weld_radio_button(u"RB_ON"_ustr)) + , m_xRB_Between(m_xBuilder->weld_radio_button(u"RB_BETWEEN"_ustr)) + , m_xFL_Labels(m_xBuilder->weld_frame(u"FL_LABELS"_ustr)) + , m_xLB_PlaceLabels(m_xBuilder->weld_combo_box(u"LB_PLACE_LABELS"_ustr)) + , m_xCB_TicksInner(m_xBuilder->weld_check_button(u"CB_TICKS_INNER"_ustr)) + , m_xCB_TicksOuter(m_xBuilder->weld_check_button(u"CB_TICKS_OUTER"_ustr)) + , m_xCB_MinorInner(m_xBuilder->weld_check_button(u"CB_MINOR_INNER"_ustr)) + , m_xCB_MinorOuter(m_xBuilder->weld_check_button(u"CB_MINOR_OUTER"_ustr)) + , m_xBxPlaceTicks(m_xBuilder->weld_widget(u"boxPLACE_TICKS"_ustr)) + , m_xLB_PlaceTicks(m_xBuilder->weld_combo_box(u"LB_PLACE_TICKS"_ustr)) { m_xLB_CrossesAt->connect_changed(LINK(this, AxisPositionsTabPage, CrossesAtSelectHdl)); m_xLB_PlaceLabels->connect_changed(LINK(this, AxisPositionsTabPage, PlaceLabelsSelectHdl)); @@ -101,8 +98,8 @@ bool AxisPositionsTabPage::FillItemSet(SfxItemSet* rOutAttrs) rOutAttrs->Put( SfxInt32Item( SCHATTR_AXIS_LABEL_POSITION, nLabelPos )); // tick marks - tools::Long nTicks=0; - tools::Long nMinorTicks=0; + sal_Int32 nTicks=0; + sal_Int32 nMinorTicks=0; if(m_xCB_MinorInner->get_active()) nMinorTicks|=CHAXIS_MARK_INNER; @@ -130,7 +127,7 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xED_CrossesAtCategory->set_visible( m_bCrossingAxisIsCategoryAxis ); if (m_bCrossingAxisIsCategoryAxis) { - for( auto const & cat : std::as_const(m_aCategories) ) + for (auto const& cat : m_aCategories) m_xED_CrossesAtCategory->append_text(cat); } @@ -143,13 +140,12 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) } //fill controls - const SfxPoolItem *pPoolItem = nullptr; //axis line - if(rInAttrs->GetItemState(SCHATTR_AXIS_POSITION,true, &pPoolItem)== SfxItemState::SET) + if(SfxInt32Item const * pPositionItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_POSITION)) { bool bZero = false; - sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nPos = pPositionItem->GetValue(); if(nPos==0) { //switch to value @@ -163,11 +159,12 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xLB_CrossesAt->set_active( nPos ); CrossesAtSelectHdl( *m_xLB_CrossesAt ); - if( rInAttrs->GetItemState(SCHATTR_AXIS_POSITION_VALUE,true, &pPoolItem)== SfxItemState::SET || bZero ) + const SvxDoubleItem* pPosValueItem; + if( (pPosValueItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_POSITION_VALUE)) || bZero ) { double fCrossover = 0.0; if( !bZero ) - fCrossover = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + fCrossover = pPosValueItem->GetValue(); if( m_bCrossingAxisIsCategoryAxis ) m_xED_CrossesAtCategory->set_active( static_cast<sal_uInt16>(::rtl::math::round(fCrossover-1.0)) ); else @@ -179,7 +176,7 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) else { m_xED_CrossesAtCategory->set_active(-1); - m_xED_CrossesAt->set_text(""); + m_xED_CrossesAt->set_text(u""_ustr); } } else @@ -189,9 +186,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) } // shifted category position - if (m_bSupportCategoryPositioning && rInAttrs->GetItemState(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION, true, &pPoolItem) == SfxItemState::SET) + const SfxBoolItem* pCatPosItem; + if (m_bSupportCategoryPositioning && (pCatPosItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION))) { - if (static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()) + if (pCatPosItem->GetValue()) m_xRB_Between->set_active(true); else m_xRB_On->set_active(true); @@ -200,9 +198,9 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xFL_Position->hide(); // Labels - if( rInAttrs->GetItemState( SCHATTR_AXIS_LABEL_POSITION, false, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pLabelPosItem = rInAttrs->GetItemIfSet( SCHATTR_AXIS_LABEL_POSITION, false) ) { - sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nPos = pLabelPosItem->GetValue(); if( nPos < m_xLB_PlaceLabels->get_count() ) m_xLB_PlaceLabels->set_active( nPos ); } @@ -212,10 +210,10 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) // Tick marks tools::Long nTicks = 0, nMinorTicks = 0; - if (rInAttrs->GetItemState(SCHATTR_AXIS_TICKS,true, &pPoolItem)== SfxItemState::SET) - nTicks = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); - if (rInAttrs->GetItemState(SCHATTR_AXIS_HELPTICKS,true, &pPoolItem)== SfxItemState::SET) - nMinorTicks = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + if (const SfxInt32Item* pTicksItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_TICKS)) + nTicks = pTicksItem->GetValue(); + if (const SfxInt32Item* pHelpTicksItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_HELPTICKS)) + nMinorTicks = pHelpTicksItem->GetValue(); m_xCB_TicksInner->set_active(bool(nTicks&CHAXIS_MARK_INNER)); m_xCB_TicksOuter->set_active(bool(nTicks&CHAXIS_MARK_OUTER)); @@ -223,9 +221,9 @@ void AxisPositionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xCB_MinorOuter->set_active(bool(nMinorTicks&CHAXIS_MARK_OUTER)); // Tick position - if( rInAttrs->GetItemState( SCHATTR_AXIS_MARK_POSITION, false, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pMarkPosItem = rInAttrs->GetItemIfSet( SCHATTR_AXIS_MARK_POSITION, false) ) { - sal_Int32 nPos = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + sal_Int32 nPos = pMarkPosItem->GetValue(); if( nPos < m_xLB_PlaceTicks->get_count() ) m_xLB_PlaceTicks->set_active( nPos ); } @@ -262,10 +260,9 @@ void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) rCrossFormatter.SetFormatter(m_pNumFormatter); rCrossFormatter.UseInputStringForFormatting(); - const SfxPoolItem *pPoolItem = nullptr; - if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxUInt32Item* pNumFormatItem = GetItemSet().GetItemIfSet(SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT) ) { - sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); + sal_uInt32 nFmt = pNumFormatItem->GetValue(); rCrossFormatter.SetFormatKey(nFmt); } } @@ -298,7 +295,7 @@ IMPL_LINK_NOARG(AxisPositionsTabPage, CrossesAtSelectHdl, weld::ComboBox&, void) if (m_xED_CrossesAt->get_text().isEmpty()) m_xED_CrossesAt->GetFormatter().SetValue(0.0); - if (m_xED_CrossesAtCategory->get_active() == -1) + if (m_xED_CrossesAtCategory->get_active() == -1 && m_xED_CrossesAtCategory->get_count()) m_xED_CrossesAtCategory->set_active(0); PlaceLabelsSelectHdl(*m_xLB_PlaceLabels); diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.hxx b/chart2/source/controller/dialogs/tp_AxisPositions.hxx index d7f18242dd42..0b570d651d1f 100644 --- a/chart2/source/controller/dialogs/tp_AxisPositions.hxx +++ b/chart2/source/controller/dialogs/tp_AxisPositions.hxx @@ -20,6 +20,8 @@ #include <sfx2/tabdlg.hxx> +class SvNumberFormatter; + namespace chart { class AxisPositionsTabPage : public SfxTabPage @@ -60,7 +62,6 @@ private: //member: std::unique_ptr<weld::ComboBox> m_xLB_CrossesAt; std::unique_ptr<weld::FormattedSpinButton> m_xED_CrossesAt; std::unique_ptr<weld::ComboBox> m_xED_CrossesAtCategory; - std::unique_ptr<weld::CheckButton> m_xCB_AxisBetweenCategories; std::unique_ptr<weld::Frame> m_xFL_Position; std::unique_ptr<weld::RadioButton> m_xRB_On; @@ -68,7 +69,6 @@ private: //member: std::unique_ptr<weld::Frame> m_xFL_Labels; std::unique_ptr<weld::ComboBox> m_xLB_PlaceLabels; - std::unique_ptr<weld::FormattedSpinButton> m_xED_LabelDistance; std::unique_ptr<weld::CheckButton> m_xCB_TicksInner; std::unique_ptr<weld::CheckButton> m_xCB_TicksOuter; diff --git a/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx b/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx new file mode 100644 index 000000000000..c52148c9dc17 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartColorPalette.cxx @@ -0,0 +1,188 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "tp_ChartColorPalette.hxx" + +#include <ChartColorPaletteHelper.hxx> +#include <ChartModel.hxx> +#include <chartview/ChartSfxItemIds.hxx> +#include <svx/chrtitem.hxx> +#include <vcl/svapp.hxx> + +namespace chart +{ +ChartColorPaletteTabPage::ChartColorPaletteTabPage(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet& rInAttrs) + : SfxTabPage(pPage, pController, "modules/schart/ui/tp_ChartColorPalette.ui", + "tp_ChartColorPalette", &rInAttrs) + , mxColorfulValueSet(new ChartColorPalettes) + , mxColorfulValueSetWin( + new weld::CustomWeld(*m_xBuilder, "colorful_palettes", *mxColorfulValueSet)) + , mxMonoValueSet(new ChartColorPalettes) + , mxMonoValueSetWin( + new weld::CustomWeld(*m_xBuilder, "monochromatic_palettes", *mxMonoValueSet)) +{ + mxColorfulValueSet->SetColCount(2); + mxColorfulValueSet->SetLineCount(2); + mxColorfulValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + mxMonoValueSet->SetColCount(2); + mxMonoValueSet->SetLineCount(3); + mxMonoValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + mxColorfulValueSet->SetOptimalSize(); + mxColorfulValueSet->SetSelectHdl( + LINK(this, ChartColorPaletteTabPage, SelectColorfulValueSetHdl)); + + mxMonoValueSet->SetOptimalSize(); + mxMonoValueSet->SetSelectHdl(LINK(this, ChartColorPaletteTabPage, SelectMonoValueSetHdl)); +} + +ChartColorPaletteTabPage::~ChartColorPaletteTabPage() +{ + mxColorfulValueSetWin.reset(); + mxColorfulValueSet.reset(); + mxMonoValueSetWin.reset(); + mxMonoValueSet.reset(); +} + +std::unique_ptr<SfxTabPage> ChartColorPaletteTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rInAttrs) +{ + return std::make_unique<ChartColorPaletteTabPage>(pPage, pController, *rInAttrs); +} + +void ChartColorPaletteTabPage::init(const rtl::Reference<ChartModel>& xChartModel) +{ + assert(xChartModel); + mxChartModel = xChartModel; + + const std::shared_ptr<model::Theme> pTheme = mxChartModel->getDocumentTheme(); + mxHelper = std::make_unique<ChartColorPaletteHelper>(pTheme); + + selectItem(mxChartModel->getColorPaletteType(), mxChartModel->getColorPaletteIndex() + 1); + initColorPalettes(); +} + +void ChartColorPaletteTabPage::initColorPalettes() const +{ + if (!mxHelper) + return; + // colorful palettes + for (size_t i = 0; i < ChartColorPaletteHelper::ColorfulPaletteSize; ++i) + mxColorfulValueSet->insert(mxHelper->getColorPalette(ChartColorPaletteType::Colorful, i)); + // monotonic palettes + for (size_t i = 0; i < ChartColorPaletteHelper::MonotonicPaletteSize; ++i) + mxMonoValueSet->insert(mxHelper->getColorPalette(ChartColorPaletteType::Monochromatic, i)); +} + +void ChartColorPaletteTabPage::selectItem(const ChartColorPaletteType eType, + const sal_uInt32 nIndex) const +{ + switch (eType) + { + default: + case ChartColorPaletteType::Unknown: + mxColorfulValueSet->SetNoSelection(); + mxMonoValueSet->SetNoSelection(); + break; + case ChartColorPaletteType::Colorful: + mxMonoValueSet->SetNoSelection(); + mxColorfulValueSet->SelectItem(nIndex); + break; + case ChartColorPaletteType::Monochromatic: + mxColorfulValueSet->SetNoSelection(); + mxMonoValueSet->SelectItem(nIndex); + break; + } +} + +bool ChartColorPaletteTabPage::FillItemSet(SfxItemSet* pOutAttrs) +{ + ChartColorPaletteType eType = ChartColorPaletteType::Unknown; + sal_uInt32 nIndex = 0; + + if (!mxColorfulValueSet->IsNoSelection()) + { + eType = ChartColorPaletteType::Colorful; + nIndex = mxColorfulValueSet->GetSelectedItemId() - 1; + } + else if (!mxMonoValueSet->IsNoSelection()) + { + eType = ChartColorPaletteType::Monochromatic; + nIndex = mxMonoValueSet->GetSelectedItemId() - 1; + } + + pOutAttrs->Put(SvxChartColorPaletteItem(eType, nIndex, SCHATTR_COLOR_PALETTE)); + + return true; +} + +void ChartColorPaletteTabPage::Reset(const SfxItemSet*) +{ + selectItem(mxChartModel->getColorPaletteType(), mxChartModel->getColorPaletteIndex() + 1); +} + +DeactivateRC ChartColorPaletteTabPage::DeactivatePage(SfxItemSet* pItemSet) +{ + if (pItemSet) + FillItemSet(pItemSet); + + return DeactivateRC::LeavePage; +} + +IMPL_LINK_NOARG(ChartColorPaletteTabPage, SelectColorfulValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxColorfulValueSet); + if (nIndex != static_cast<sal_uInt32>(-1)) + { + mxMonoValueSet->SetNoSelection(); + } +} + +IMPL_LINK_NOARG(ChartColorPaletteTabPage, SelectMonoValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxMonoValueSet); + if (nIndex != static_cast<sal_uInt32>(-1)) + { + mxColorfulValueSet->SetNoSelection(); + } +} + +sal_uInt32 +ChartColorPaletteTabPage::SelectValueSetHdl(const std::unique_ptr<ChartColorPalettes>& xValueSet) +{ + const sal_uInt32 nItemId = xValueSet->GetSelectedItemId(); + + if (!nItemId) + return static_cast<sal_uInt32>(-1); + + const sal_uInt32 nIndex = nItemId - 1; + + if (xValueSet->getPalette(nIndex)) + { + return nIndex; + } + return static_cast<sal_uInt32>(-1); +} +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx b/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx new file mode 100644 index 000000000000..02cfe3cd5c94 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartColorPalette.hxx @@ -0,0 +1,64 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#pragma once + +#include <sfx2/tabdlg.hxx> +#include <ChartColorPalettes.hxx> + +namespace chart +{ +class ChartModel; +class ChartColorPaletteHelper; + +class ChartColorPaletteTabPage final : public SfxTabPage +{ +public: + ChartColorPaletteTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs); + ~ChartColorPaletteTabPage() override; + + static std::unique_ptr<SfxTabPage> + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs); + + bool FillItemSet(SfxItemSet* pOutAttrs) override; + void Reset(const SfxItemSet* rInAttrs) override; + DeactivateRC DeactivatePage(SfxItemSet* pItemSet) override; + + void init(const rtl::Reference<ChartModel>& xChartModel); + +private: + void selectItem(ChartColorPaletteType eType, sal_uInt32 nIndex) const; + void initColorPalettes() const; + +private: + rtl::Reference<ChartModel> mxChartModel; + std::unique_ptr<ChartColorPaletteHelper> mxHelper; + std::unique_ptr<ChartColorPalettes> mxColorfulValueSet; + std::unique_ptr<weld::CustomWeld> mxColorfulValueSetWin; + std::unique_ptr<ChartColorPalettes> mxMonoValueSet; + std::unique_ptr<weld::CustomWeld> mxMonoValueSetWin; + + DECL_LINK(SelectColorfulValueSetHdl, ValueSet*, void); + DECL_LINK(SelectMonoValueSetHdl, ValueSet*, void); + static sal_uInt32 SelectValueSetHdl(const std::unique_ptr<ChartColorPalettes>& xValueSet); +}; +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx index 19084e9e5180..45f5b277ef7e 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.cxx +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -19,42 +19,43 @@ #include "tp_ChartType.hxx" #include <ChartResourceGroups.hxx> +#include <ChartTypeManager.hxx> #include <strings.hrc> #include <ResId.hxx> -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <ChartModel.hxx> +#include <ChartTypeTemplate.hxx> +#include <Diagram.hxx> #include <unonames.hxx> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <svtools/valueset.hxx> +#include <utility> #include <vcl/weld.hxx> #include <vcl/outdev.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; -ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogController* pController, const uno::Reference< XChartDocument >& xChartModel, +ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogController* pController, rtl::Reference<::chart::ChartModel> xChartModel, bool bShowDescription) - : OWizardPage(pPage, pController, "modules/schart/ui/tp_ChartType.ui", "tp_ChartType") + : OWizardPage(pPage, pController, u"modules/schart/ui/tp_ChartType.ui"_ustr, u"tp_ChartType"_ustr) , m_pDim3DLookResourceGroup( new Dim3DLookResourceGroup(m_xBuilder.get()) ) , m_pStackingResourceGroup( new StackingResourceGroup(m_xBuilder.get()) ) , m_pSplineResourceGroup( new SplineResourceGroup(m_xBuilder.get(), pController->getDialog()) ) , m_pGeometryResourceGroup( new GeometryResourceGroup(m_xBuilder.get()) ) , m_pSortByXValuesResourceGroup( new SortByXValuesResourceGroup(m_xBuilder.get()) ) - , m_xChartModel( xChartModel ) + , m_xChartModel(std::move( xChartModel )) , m_aChartTypeDialogControllerList(0) , m_pCurrentMainType(nullptr) , m_nChangingCalls(0) , m_aTimerTriggeredControllerLock( m_xChartModel ) - , m_xFT_ChooseType(m_xBuilder->weld_label("FT_CAPTION_FOR_WIZARD")) - , m_xMainTypeList(m_xBuilder->weld_tree_view("charttype")) - , m_xSubTypeList(new ValueSet(m_xBuilder->weld_scrolled_window("subtypewin", true))) - , m_xSubTypeListWin(new weld::CustomWeld(*m_xBuilder, "subtype", *m_xSubTypeList)) + , m_xFT_ChooseType(m_xBuilder->weld_label(u"FT_CAPTION_FOR_WIZARD"_ustr)) + , m_xMainTypeList(m_xBuilder->weld_tree_view(u"charttype"_ustr)) + , m_xSubTypeList(new ValueSet(m_xBuilder->weld_scrolled_window(u"subtypewin"_ustr, true))) + , m_xSubTypeListWin(new weld::CustomWeld(*m_xBuilder, u"subtype"_ustr, *m_xSubTypeList)) { Size aSize(m_xSubTypeList->GetDrawingArea()->get_ref_device().LogicToPixel(Size(150, 50), MapMode(MapUnit::MapAppFont))); m_xSubTypeListWin->set_size_request(aSize.Width(), aSize.Height()); @@ -70,21 +71,25 @@ ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogControlle SetPageTitle(SchResId(STR_PAGE_CHARTTYPE)); - m_xMainTypeList->connect_changed(LINK(this, ChartTypeTabPage, SelectMainTypeHdl)); + m_xMainTypeList->connect_selection_changed(LINK(this, ChartTypeTabPage, SelectMainTypeHdl)); m_xSubTypeList->SetSelectHdl( LINK( this, ChartTypeTabPage, SelectSubTypeHdl ) ); m_xSubTypeList->SetStyle(m_xSubTypeList->GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_FLATVALUESET | WB_3DLOOK ); + // Set number of columns in chart type selector. + // TODO: Ideally this would not be hard-coded, but determined + // programmatically based on the maximum number of chart types across all + // controllers. m_xSubTypeList->SetColCount(4); m_xSubTypeList->SetLineCount(1); bool bEnableComplexChartTypes = true; - uno::Reference< beans::XPropertySet > xProps( m_xChartModel, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProps( static_cast<cppu::OWeakObject*>(m_xChartModel.get()), uno::UNO_QUERY ); if ( xProps.is() ) { try { - xProps->getPropertyValue("EnableComplexChartTypes") >>= bEnableComplexChartTypes; + xProps->getPropertyValue(u"EnableComplexChartTypes"_ustr) >>= bEnableComplexChartTypes; } catch( const uno::Exception& ) { @@ -94,7 +99,9 @@ ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogControlle m_aChartTypeDialogControllerList.push_back(std::make_unique<ColumnChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<BarChartDialogController>()); + m_aChartTypeDialogControllerList.push_back(std::make_unique<HistogramChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<PieChartDialogController>()); + m_aChartTypeDialogControllerList.push_back(std::make_unique<OfPieChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<AreaChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<LineChartDialogController>()); if (bEnableComplexChartTypes) @@ -113,7 +120,7 @@ ChartTypeTabPage::ChartTypeTabPage(weld::Container* pPage, weld::DialogControlle for (auto const& elem : m_aChartTypeDialogControllerList) { - m_xMainTypeList->append("", elem->getName(), elem->getImage()); + m_xMainTypeList->append(u""_ustr, elem->getName(), elem->getImage()); elem->setChangeListener( this ); } @@ -159,7 +166,8 @@ void ChartTypeTabPage::commitToModel( const ChartTypeParameter& rParameter ) return; m_aTimerTriggeredControllerLock.startTimer(); - m_pCurrentMainType->commitToModel( rParameter, m_xChartModel ); + uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY ); + m_pCurrentMainType->commitToModel( rParameter, m_xChartModel, xTemplateProps ); } void ChartTypeTabPage::stateChanged() @@ -177,16 +185,15 @@ void ChartTypeTabPage::stateChanged() commitToModel( aParameter ); //detect the new ThreeDLookScheme - uno::Reference<XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); + rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); // tdf#124295 - select always a 3D scheme - if (ThreeDLookScheme aThreeDLookScheme = ThreeDHelper::detectScheme(xDiagram); + if (ThreeDLookScheme aThreeDLookScheme = xDiagram->detectScheme(); aThreeDLookScheme != ThreeDLookScheme::ThreeDLookScheme_Unknown) aParameter.eThreeDLookScheme = aThreeDLookScheme; try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch ( const uno::Exception& ) { @@ -243,16 +250,18 @@ void ChartTypeTabPage::selectMainType() m_pCurrentMainType->adjustParameterToMainType( aParameter ); commitToModel( aParameter ); //detect the new ThreeDLookScheme - aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) ); + aParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Unknown; + rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); + if (xDiagram) + aParameter.eThreeDLookScheme = m_xChartModel->getFirstChartDiagram()->detectScheme(); if (!aParameter.b3DLook && aParameter.eThreeDLookScheme != ThreeDLookScheme::ThreeDLookScheme_Realistic) aParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic; - uno::Reference<XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; + if (xDiagram) + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch ( const uno::Exception& ) { @@ -260,7 +269,7 @@ void ChartTypeTabPage::selectMainType() } fillAllControls( aParameter ); - uno::Reference< beans::XPropertySet > xTemplateProps( getCurrentTemplate(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY ); m_pCurrentMainType->fillExtraControls(m_xChartModel,xTemplateProps); } @@ -302,11 +311,12 @@ void ChartTypeTabPage::initializePage() { if( !m_xChartModel.is() ) return; - uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartModel ) ); - DiagramHelper::tTemplateWithServiceName aTemplate = - DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ); - OUString aServiceName( aTemplate.second ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = m_xChartModel->getTypeManager(); + rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); + Diagram::tTemplateWithServiceName aTemplate; + if (xDiagram) + aTemplate = xDiagram->getTemplate( xChartTypeManager ); + OUString aServiceName( aTemplate.sServiceName ); bool bFound = false; @@ -319,20 +329,19 @@ void ChartTypeTabPage::initializePage() m_xMainTypeList->select(nM); showAllControls(*elem); - uno::Reference< beans::XPropertySet > xTemplateProps( aTemplate.first, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xTemplateProps( static_cast<cppu::OWeakObject*>(aTemplate.xChartTypeTemplate.get()), uno::UNO_QUERY ); ChartTypeParameter aParameter = elem->getChartTypeParameterForService( aServiceName, xTemplateProps ); m_pCurrentMainType = getSelectedMainType(); //set ThreeDLookScheme - aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( xDiagram ); + aParameter.eThreeDLookScheme = xDiagram->detectScheme(); if (!aParameter.b3DLook && aParameter.eThreeDLookScheme != ThreeDLookScheme::ThreeDLookScheme_Realistic) aParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic; try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch (const uno::Exception&) { @@ -349,7 +358,8 @@ void ChartTypeTabPage::initializePage() if( !bFound ) { - m_xSubTypeList->Hide(); + m_xMainTypeList->show(); + m_xSubTypeList->Show(); m_pDim3DLookResourceGroup->showControls( false ); m_pStackingResourceGroup->showControls( false ); m_pSplineResourceGroup->showControls( false ); @@ -363,14 +373,14 @@ bool ChartTypeTabPage::commitPage( ::vcl::WizardTypes::CommitPageReason /*eReaso return true; // return false if this page should not be left } -uno::Reference< XChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const +rtl::Reference< ChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const { if( m_pCurrentMainType && m_xChartModel.is() ) { ChartTypeParameter aParameter( getCurrentParamter() ); m_pCurrentMainType->adjustParameterToSubType( aParameter ); - uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY ); - return m_pCurrentMainType->getCurrentTemplate( aParameter, xTemplateManager ); + rtl::Reference< ::chart::ChartTypeManager > xChartTypeManager = m_xChartModel->getTypeManager(); + return m_pCurrentMainType->getCurrentTemplate( aParameter, xChartTypeManager ); } return nullptr; } diff --git a/chart2/source/controller/dialogs/tp_ChartType.hxx b/chart2/source/controller/dialogs/tp_ChartType.hxx index e7f8e1980bd8..c01b599f58d5 100644 --- a/chart2/source/controller/dialogs/tp_ChartType.hxx +++ b/chart2/source/controller/dialogs/tp_ChartType.hxx @@ -45,14 +45,14 @@ class ChartTypeTabPage final : public ResourceChangeListener, public vcl::OWizar { public: ChartTypeTabPage( weld::Container* pPage, weld::DialogController* pController - , const css::uno::Reference< css::chart2::XChartDocument >& xChartModel + , rtl::Reference<::chart::ChartModel> xChartModel , bool bShowDescription = true ); virtual ~ChartTypeTabPage() override; virtual void initializePage() override; virtual bool commitPage( ::vcl::WizardTypes::CommitPageReason eReason ) override; - virtual css::uno::Reference< css::chart2::XChartTypeTemplate > getCurrentTemplate() const override; + virtual rtl::Reference< ::chart::ChartTypeTemplate > getCurrentTemplate() const override; private: ChartTypeDialogController* getSelectedMainType(); @@ -74,7 +74,7 @@ private: std::unique_ptr<GeometryResourceGroup> m_pGeometryResourceGroup; std::unique_ptr<SortByXValuesResourceGroup> m_pSortByXValuesResourceGroup; - css::uno::Reference< css::chart2::XChartDocument > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; std::vector< std::unique_ptr<ChartTypeDialogController> > m_aChartTypeDialogControllerList; ChartTypeDialogController* m_pCurrentMainType; diff --git a/chart2/source/controller/dialogs/tp_DataLabel.cxx b/chart2/source/controller/dialogs/tp_DataLabel.cxx index 3594e3e8ffeb..0bd8f6831f27 100644 --- a/chart2/source/controller/dialogs/tp_DataLabel.cxx +++ b/chart2/source/controller/dialogs/tp_DataLabel.cxx @@ -23,7 +23,7 @@ namespace chart { DataLabelsTabPage::DataLabelsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_DataLabel.ui", "tp_DataLabel", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_DataLabel.ui"_ustr, u"tp_DataLabel"_ustr, &rInAttrs) , m_aDataLabelResources(m_xBuilder.get(), pController->getDialog(), rInAttrs) { } diff --git a/chart2/source/controller/dialogs/tp_DataPointOption.cxx b/chart2/source/controller/dialogs/tp_DataPointOption.cxx index 7fb9f230ed7e..c7bdebde8370 100644 --- a/chart2/source/controller/dialogs/tp_DataPointOption.cxx +++ b/chart2/source/controller/dialogs/tp_DataPointOption.cxx @@ -27,9 +27,9 @@ namespace chart DataPointOptionTabPage::DataPointOptionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_DataPointOption.ui", - "tp_DataPointOption", &rInAttrs) - , m_xCBHideLegendEntry(m_xBuilder->weld_check_button("CB_LEGEND_ENTRY_HIDDEN")) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_DataPointOption.ui"_ustr, + u"tp_DataPointOption"_ustr, &rInAttrs) + , m_xCBHideLegendEntry(m_xBuilder->weld_check_button(u"CB_LEGEND_ENTRY_HIDDEN"_ustr)) { } @@ -53,12 +53,10 @@ bool DataPointOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs) void DataPointOptionTabPage::Reset(const SfxItemSet* rInAttrs) { - const SfxPoolItem* pPoolItem = nullptr; - - if (rInAttrs->GetItemState(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, true, &pPoolItem) - == SfxItemState::SET) + if (const SfxBoolItem* pEntryItem + = rInAttrs->GetItemIfSet(SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY)) { - bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + bool bVal = pEntryItem->GetValue(); m_xCBHideLegendEntry->set_active(bVal); } } diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx index 8586bd7260c7..4cc12689ebc9 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.cxx +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -20,33 +20,32 @@ #include "tp_DataSource.hxx" #include <strings.hrc> #include <ResId.hxx> +#include <ChartType.hxx> #include <ChartTypeTemplateProvider.hxx> +#include <ChartTypeTemplate.hxx> +#include <ChartModel.hxx> #include <RangeSelectionHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <ControllerLockGuard.hxx> #include <DataSourceHelper.hxx> +#include <LabeledDataSequence.hxx> #include "DialogModel.hxx" +#include <o3tl/safeint.hxx> #include <TabPageNotifiable.hxx> -#include <com/sun/star/chart2/XChartType.hpp> -#include <com/sun/star/chart2/XDataSeries.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/chart2/data/XDataSink.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace { -constexpr OUStringLiteral lcl_aLabelRole( u"label" ); +constexpr OUString lcl_aLabelRole( u"label"_ustr ); void lcl_UpdateCurrentRange(weld::TreeView& rOutListBox, const OUString & rRole, const OUString& rRange) @@ -56,7 +55,7 @@ void lcl_UpdateCurrentRange(weld::TreeView& rOutListBox, const OUString & rRole, { rOutListBox.set_text(nEntry, ::chart::DialogModel::ConvertRoleFromInternalToUI(rRole), 0); rOutListBox.set_text(nEntry, rRange, 1); - ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry).toInt64()); + ::chart::SeriesEntry* pEntry = weld::fromId<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry)); pEntry->m_sRole = rRole; } } @@ -68,11 +67,10 @@ bool lcl_UpdateCurrentSeriesName(weld::TreeView& rOutListBox) return false; bool bResult = false; - ::chart::SeriesEntry * pEntry = reinterpret_cast<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry).toInt64()); + ::chart::SeriesEntry * pEntry = weld::fromId<::chart::SeriesEntry*>(rOutListBox.get_id(nEntry)); if (pEntry->m_xDataSeries.is() && pEntry->m_xChartType.is()) { - OUString aLabel(::chart::DataSeriesHelper::getDataSeriesLabel( - pEntry->m_xDataSeries, + OUString aLabel(pEntry->m_xDataSeries->getLabelForRole( pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel())); if (!aLabel.isEmpty()) { @@ -90,7 +88,7 @@ OUString lcl_GetSelectedRole(const weld::TreeView& rRoleListBox, bool bUITransla { if (bUITranslated) return rRoleListBox.get_text(nEntry); - ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(rRoleListBox.get_id(nEntry).toInt64()); + ::chart::SeriesEntry* pEntry = weld::fromId<::chart::SeriesEntry*>(rRoleListBox.get_id(nEntry)); return pEntry->m_sRole; } return OUString(); @@ -107,48 +105,36 @@ OUString lcl_GetSelectedRolesRange( const weld::TreeView& rRoleListBox ) OUString lcl_GetSequenceNameForLabel(const ::chart::SeriesEntry* pEntry) { - OUString aResult("values-y"); + OUString aResult(u"values-y"_ustr); if (pEntry && pEntry->m_xChartType.is()) aResult = pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel(); return aResult; } -void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) -{ - if (!pDialog) - return; - weld::Dialog* pDlg = pDialog->getDialog(); - pDlg->set_modal(!bEnable); - pDlg->set_visible(!bEnable); -} - void lcl_addLSequenceToDataSource( - const Reference< chart2::data::XLabeledDataSequence > & xLSequence, - const Reference< chart2::data::XDataSource > & xSource ) + const uno::Reference< chart2::data::XLabeledDataSequence > & xLSequence, + const Reference< ::chart::DataSeries > & xSource ) { - Reference< data::XDataSink > xSink( xSource, uno::UNO_QUERY ); - if( xSink.is()) + if( xSource.is()) { - Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences()); - aData.realloc( aData.getLength() + 1 ); - aData[ aData.getLength() - 1 ] = xLSequence; - xSink->setData( aData ); + std::vector< uno::Reference< chart2::data::XLabeledDataSequence > > aData = xSource->getDataSequences2(); + aData.push_back( xLSequence ); + xSource->setData( aData ); } } -Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( - const Reference< chart2::data::XDataSource > & xDataSource ) +uno::Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( + const rtl::Reference< ::chart::DataSeries > & xDataSource ) { - Reference< chart2::data::XLabeledDataSequence > xResult; - const Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); + uno::Reference< chart2::data::XLabeledDataSequence > xResult; - for( Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : aSequences ) + for( uno::Reference< chart2::data::XLabeledDataSequence > const & labeledDataSeq : xDataSource->getDataSequences2() ) { // no values are set but a label exists if( ! labeledDataSeq->getValues().is() && labeledDataSeq->getLabel().is()) { - xResult.set( labeledDataSeq ); + xResult = labeledDataSeq; break; } } @@ -165,28 +151,28 @@ DataSourceTabPage::DataSourceTabPage(weld::Container* pPage, weld::DialogControl DialogModel & rDialogModel, ChartTypeTemplateProvider* pTemplateProvider, bool bHideDescription /* = false */) - : ::vcl::OWizardPage(pPage, pController, "modules/schart/ui/tp_DataSource.ui", "tp_DataSource") + : ::vcl::OWizardPage(pPage, pController, u"modules/schart/ui/tp_DataSource.ui"_ustr, u"tp_DataSource"_ustr) , m_pTemplateProvider(pTemplateProvider) , m_rDialogModel(rDialogModel) , m_pCurrentRangeChoosingField( nullptr ) , m_bIsDirty( false ) , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) - , m_xFT_CAPTION(m_xBuilder->weld_label("FT_CAPTION_FOR_WIZARD")) - , m_xFT_SERIES(m_xBuilder->weld_label("FT_SERIES")) - , m_xLB_SERIES(m_xBuilder->weld_tree_view("LB_SERIES")) - , m_xBTN_ADD(m_xBuilder->weld_button("BTN_ADD")) - , m_xBTN_REMOVE(m_xBuilder->weld_button("BTN_REMOVE")) - , m_xBTN_UP(m_xBuilder->weld_button("BTN_UP")) - , m_xBTN_DOWN(m_xBuilder->weld_button("BTN_DOWN")) - , m_xFT_ROLE(m_xBuilder->weld_label("FT_ROLE")) - , m_xLB_ROLE(m_xBuilder->weld_tree_view("LB_ROLE")) - , m_xFT_RANGE(m_xBuilder->weld_label("FT_RANGE")) - , m_xEDT_RANGE(m_xBuilder->weld_entry("EDT_RANGE")) - , m_xIMB_RANGE_MAIN(m_xBuilder->weld_button("IMB_RANGE_MAIN")) - , m_xFT_CATEGORIES(m_xBuilder->weld_label("FT_CATEGORIES")) - , m_xFT_DATALABELS(m_xBuilder->weld_label("FT_DATALABELS")) - , m_xEDT_CATEGORIES(m_xBuilder->weld_entry("EDT_CATEGORIES")) - , m_xIMB_RANGE_CAT(m_xBuilder->weld_button("IMB_RANGE_CAT")) + , m_xFT_CAPTION(m_xBuilder->weld_label(u"FT_CAPTION_FOR_WIZARD"_ustr)) + , m_xFT_SERIES(m_xBuilder->weld_label(u"FT_SERIES"_ustr)) + , m_xLB_SERIES(m_xBuilder->weld_tree_view(u"LB_SERIES"_ustr)) + , m_xBTN_ADD(m_xBuilder->weld_button(u"BTN_ADD"_ustr)) + , m_xBTN_REMOVE(m_xBuilder->weld_button(u"BTN_REMOVE"_ustr)) + , m_xBTN_UP(m_xBuilder->weld_button(u"BTN_UP"_ustr)) + , m_xBTN_DOWN(m_xBuilder->weld_button(u"BTN_DOWN"_ustr)) + , m_xFT_ROLE(m_xBuilder->weld_label(u"FT_ROLE"_ustr)) + , m_xLB_ROLE(m_xBuilder->weld_tree_view(u"LB_ROLE"_ustr)) + , m_xFT_RANGE(m_xBuilder->weld_label(u"FT_RANGE"_ustr)) + , m_xEDT_RANGE(m_xBuilder->weld_entry(u"EDT_RANGE"_ustr)) + , m_xIMB_RANGE_MAIN(m_xBuilder->weld_button(u"IMB_RANGE_MAIN"_ustr)) + , m_xFT_CATEGORIES(m_xBuilder->weld_label(u"FT_CATEGORIES"_ustr)) + , m_xFT_DATALABELS(m_xBuilder->weld_label(u"FT_DATALABELS"_ustr)) + , m_xEDT_CATEGORIES(m_xBuilder->weld_entry(u"EDT_CATEGORIES"_ustr)) + , m_xIMB_RANGE_CAT(m_xBuilder->weld_button(u"IMB_RANGE_CAT"_ustr)) { m_xLB_SERIES->set_size_request(m_xLB_SERIES->get_approximate_digit_width() * 25, m_xLB_SERIES->get_height_rows(10)); @@ -198,8 +184,9 @@ DataSourceTabPage::DataSourceTabPage(weld::Container* pPage, weld::DialogControl SetPageTitle(SchResId(STR_OBJECT_DATASERIES_PLURAL)); // set handlers - m_xLB_SERIES->connect_changed(LINK(this, DataSourceTabPage, SeriesSelectionChangedHdl)); - m_xLB_ROLE->connect_changed(LINK(this, DataSourceTabPage, RoleSelectionChangedHdl)); + m_xLB_SERIES->connect_selection_changed( + LINK(this, DataSourceTabPage, SeriesSelectionChangedHdl)); + m_xLB_ROLE->connect_selection_changed(LINK(this, DataSourceTabPage, RoleSelectionChangedHdl)); m_xIMB_RANGE_MAIN->connect_clicked(LINK(this, DataSourceTabPage, MainRangeButtonClickedHdl)); m_xIMB_RANGE_CAT->connect_clicked(LINK(this, DataSourceTabPage, CategoriesRangeButtonClickedHdl)); @@ -214,8 +201,7 @@ DataSourceTabPage::DataSourceTabPage(weld::Container* pPage, weld::DialogControl m_xEDT_CATEGORIES->connect_changed(LINK( this, DataSourceTabPage, RangeModifiedHdl)); // init controls - std::vector<int> aWidths; - aWidths.push_back(m_xLB_ROLE->get_approximate_digit_width() * 20); + std::vector<int> aWidths { o3tl::narrowing<int>(m_xLB_ROLE->get_approximate_digit_width() * 20) }; m_xLB_ROLE->set_column_fixed_widths(aWidths); m_xLB_ROLE->show(); @@ -231,7 +217,7 @@ void DataSourceTabPage::InsertRoleLBEntry(const OUString& rRole, const OUString& m_aEntries.emplace_back(new SeriesEntry); SeriesEntry* pEntry = m_aEntries.back().get(); pEntry->m_sRole = rRole; - m_xLB_ROLE->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), + m_xLB_ROLE->append(weld::toId(pEntry), ::chart::DialogModel::ConvertRoleFromInternalToUI(rRole)); m_xLB_ROLE->set_text(m_xLB_ROLE->n_children() - 1, rRange, 1); } @@ -325,13 +311,13 @@ void DataSourceTabPage::updateControlsFromDialogModel() void DataSourceTabPage::fillSeriesListBox() { - Reference< XDataSeries > xSelected; + rtl::Reference< DataSeries > xSelected; SeriesEntry* pEntry = nullptr; int nEntry = m_xLB_SERIES->get_selected_index(); if (nEntry != -1) { - pEntry = reinterpret_cast<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); - xSelected.set(pEntry->m_xDataSeries); + pEntry = weld::fromId<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry)); + xSelected = pEntry->m_xDataSeries; } bool bHasSelectedEntry = (pEntry != nullptr); @@ -355,7 +341,7 @@ void DataSourceTabPage::fillSeriesListBox() OUString aResString(::chart::SchResId( STR_DATA_UNNAMED_SERIES_WITH_INDEX )); // replace index of unnamed series - static const OUStringLiteral aReplacementStr( u"%NUMBER" ); + static constexpr OUString aReplacementStr( u"%NUMBER"_ustr ); sal_Int32 nIndex = aResString.indexOf( aReplacementStr ); if( nIndex != -1 ) aLabel = aResString.replaceAt( @@ -370,9 +356,9 @@ void DataSourceTabPage::fillSeriesListBox() m_aEntries.emplace_back(new SeriesEntry); pEntry = m_aEntries.back().get(); - pEntry->m_xDataSeries.set(series.second.first); - pEntry->m_xChartType.set(series.second.second); - m_xLB_SERIES->append(OUString::number(reinterpret_cast<sal_Int64>(pEntry)), aLabel); + pEntry->m_xDataSeries = series.second.first; + pEntry->m_xChartType = series.second.second; + m_xLB_SERIES->append(weld::toId(pEntry), aLabel); if (bHasSelectedEntry && series.second.first == xSelected) nSelectedEntry = nEntry; ++nEntry; @@ -389,7 +375,7 @@ void DataSourceTabPage::fillRoleListBox() int nSeriesEntry = m_xLB_SERIES->get_selected_index(); SeriesEntry* pSeriesEntry = nullptr; if (nSeriesEntry != -1) - pSeriesEntry = reinterpret_cast<SeriesEntry*>(m_xLB_SERIES->get_id(nSeriesEntry).toInt64()); + pSeriesEntry = weld::fromId<SeriesEntry*>(m_xLB_SERIES->get_id(nSeriesEntry)); bool bHasSelectedEntry = (pSeriesEntry != nullptr); int nRoleIndex = m_xLB_ROLE->get_selected_index(); @@ -485,7 +471,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, RoleSelectionChangedHdl, weld::TreeView&, voi OUString aSelectedRange = lcl_GetSelectedRolesRange( *m_xLB_ROLE ); // replace role in fixed text label - static const OUStringLiteral aReplacementStr( u"%VALUETYPE" ); + static constexpr OUString aReplacementStr( u"%VALUETYPE"_ustr ); sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); if( nIndex != -1 ) { @@ -516,7 +502,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, weld::Button&, voi OUString aUIStr(SchResId(STR_DATA_SELECT_RANGE_FOR_SERIES)); // replace role - OUString aReplacement( "%VALUETYPE" ); + OUString aReplacement( u"%VALUETYPE"_ustr ); sal_Int32 nIndex = aUIStr.indexOf( aReplacement ); if( nIndex != -1 ) { @@ -532,7 +518,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, MainRangeButtonClickedHdl, weld::Button&, voi m_xLB_SERIES->get_text(nEntry)); } - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aSelectedRolesRange, aUIStr, *this ); } else @@ -548,7 +534,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, CategoriesRangeButtonClickedHdl, weld::Button return; OUString aStr(SchResId(m_xFT_CATEGORIES->get_visible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS)); - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( m_rDialogModel.getCategoriesRange(), aStr, *this ); } @@ -557,23 +543,23 @@ IMPL_LINK_NOARG(DataSourceTabPage, AddButtonClickedHdl, weld::Button&, void) { m_rDialogModel.startControllerLockTimer(); int nEntry = m_xLB_SERIES->get_selected_index(); - Reference< XDataSeries > xSeriesToInsertAfter; - Reference< XChartType > xChartTypeForNewSeries; + rtl::Reference< DataSeries > xSeriesToInsertAfter; + rtl::Reference< ChartType > xChartTypeForNewSeries; if( m_pTemplateProvider ) m_rDialogModel.setTemplate( m_pTemplateProvider->getCurrentTemplate()); if (nEntry != -1) { - ::chart::SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); - xSeriesToInsertAfter.set(pEntry->m_xDataSeries); - xChartTypeForNewSeries.set(pEntry->m_xChartType); + ::chart::SeriesEntry* pEntry = weld::fromId<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry)); + xSeriesToInsertAfter = pEntry->m_xDataSeries; + xChartTypeForNewSeries = pEntry->m_xChartType; } else { - std::vector< Reference< XDataSeriesContainer > > aCntVec( + std::vector< rtl::Reference< ChartType > > aCntVec( m_rDialogModel.getAllDataSeriesContainers()); if( ! aCntVec.empty()) - xChartTypeForNewSeries.set( aCntVec.front(), uno::UNO_QUERY ); + xChartTypeForNewSeries = aCntVec.front(); } OSL_ENSURE( xChartTypeForNewSeries.is(), "Cannot insert new series" ); @@ -600,15 +586,15 @@ IMPL_LINK_NOARG(DataSourceTabPage, RemoveButtonClickedHdl, weld::Button&, void) if (nEntry == -1) return; - SeriesEntry* pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); - Reference< XDataSeries > xNewSelSeries; + SeriesEntry* pEntry = weld::fromId<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry)); + rtl::Reference< DataSeries > xNewSelSeries; SeriesEntry * pNewSelEntry = nullptr; if (nEntry + 1 < m_xLB_SERIES->n_children()) - pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry + 1).toInt64()); + pNewSelEntry = weld::fromId<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry + 1)); else if (nEntry > 0) - pNewSelEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry - 1).toInt64()); + pNewSelEntry = weld::fromId<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(nEntry - 1)); if (pNewSelEntry) - xNewSelSeries.set(pNewSelEntry->m_xDataSeries); + xNewSelSeries = pNewSelEntry->m_xDataSeries; m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); setDirty(); @@ -621,7 +607,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, RemoveButtonClickedHdl, weld::Button&, void) { for (int i = 0; i < m_xLB_SERIES->n_children(); ++i) { - pEntry = reinterpret_cast<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(i).toInt64()); + pEntry = weld::fromId<::chart::SeriesEntry*>(m_xLB_SERIES->get_id(i)); if (pEntry->m_xDataSeries == xNewSelSeries) { m_xLB_SERIES->select(i); @@ -639,7 +625,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, UpButtonClickedHdl, weld::Button&, void) int nEntry = m_xLB_SERIES->get_selected_index(); SeriesEntry* pEntry = nullptr; if (nEntry != -1) - pEntry = reinterpret_cast<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); + pEntry = weld::fromId<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry)); bool bHasSelectedEntry = (pEntry != nullptr); @@ -659,7 +645,7 @@ IMPL_LINK_NOARG(DataSourceTabPage, DownButtonClickedHdl, weld::Button&, void) int nEntry = m_xLB_SERIES->get_selected_index(); SeriesEntry* pEntry = nullptr; if (nEntry != -1) - pEntry = reinterpret_cast<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry).toInt64()); + pEntry = weld::fromId<SeriesEntry*>(m_xLB_SERIES->get_id(nEntry)); bool bHasSelectedEntry = (pEntry != nullptr); @@ -726,7 +712,7 @@ void DataSourceTabPage::listeningFinished( m_pCurrentRangeChoosingField = nullptr; updateControlState(); - lcl_enableRangeChoosing(false, m_pDialogController); + enableRangeChoosing(false, m_pDialogController); } void DataSourceTabPage::disposingRangeSelection() @@ -748,7 +734,7 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) if (bAll || (pField == m_xEDT_CATEGORIES.get())) { - Reference< data::XLabeledDataSequence > xLabeledSeq( m_rDialogModel.getCategories() ); + uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( m_rDialogModel.getCategories() ); if( xDataProvider.is()) { OUString aRange(m_xEDT_CATEGORIES->get_text()); @@ -757,7 +743,7 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) // create or change categories if( !xLabeledSeq.is()) { - xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence() ); + xLabeledSeq = DataSourceHelper::createLabeledDataSequence(); m_rDialogModel.setCategories( xLabeledSeq ); } try @@ -773,7 +759,7 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) else if( xLabeledSeq.is()) { // clear existing categories - xLabeledSeq.set(nullptr); + xLabeledSeq.clear(); m_rDialogModel.setCategories( xLabeledSeq ); } } @@ -782,7 +768,7 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) int nSeriesEntry = m_xLB_SERIES->get_selected_index(); SeriesEntry* pSeriesEntry = nullptr; if (nSeriesEntry != -1) - pSeriesEntry = reinterpret_cast<SeriesEntry*>(m_xLB_SERIES->get_id(nSeriesEntry).toInt64()); + pSeriesEntry = weld::fromId<SeriesEntry*>(m_xLB_SERIES->get_id(nSeriesEntry)); bool bHasSelectedEntry = (pSeriesEntry != nullptr); if( bHasSelectedEntry ) @@ -800,9 +786,8 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) if( bIsLabel ) aSequenceRole = aSequenceNameForLabel; - Reference< data::XDataSource > xSource( pSeriesEntry->m_xDataSeries, uno::UNO_QUERY_THROW ); - Reference< data::XLabeledDataSequence > xLabeledSeq( - DataSeriesHelper::getDataSequenceByRole( xSource, aSequenceRole )); + uno::Reference< chart2::data::XLabeledDataSequence > xLabeledSeq = + DataSeriesHelper::getDataSequenceByRole( pSeriesEntry->m_xDataSeries, aSequenceRole ); if( xDataProvider.is()) { @@ -811,12 +796,12 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) if( ! xLabeledSeq.is()) { // check if there is already an "orphan" label sequence - xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); + xLabeledSeq = lcl_findLSequenceWithOnlyLabel( pSeriesEntry->m_xDataSeries ); if( ! xLabeledSeq.is()) { // no corresponding labeled data sequence for label found - xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence() ); - lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); + xLabeledSeq = DataSourceHelper::createLabeledDataSequence(); + lcl_addLSequenceToDataSource( xLabeledSeq, pSeriesEntry->m_xDataSeries ); } } if( xLabeledSeq.is()) @@ -840,10 +825,10 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) // "$Sheet1.$A$1" aRange = xNewSeq->getSourceRangeRepresentation(); Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); - xProp->setPropertyValue( "Role" , uno::Any( OUString(lcl_aLabelRole) )); + xProp->setPropertyValue( u"Role"_ustr , uno::Any( lcl_aLabelRole )); //Labels should always include hidden cells, regardless of the setting chosen - xProp->setPropertyValue( "IncludeHiddenCells", uno::Any(true)); + xProp->setPropertyValue( u"IncludeHiddenCells"_ustr, uno::Any(true)); xLabeledSeq->setLabel( xNewSeq ); } } @@ -875,15 +860,15 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) aRange = xNewSeq->getSourceRangeRepresentation(); Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); - xProp->setPropertyValue( "Role" , uno::Any( aSelectedRole )); + xProp->setPropertyValue( u"Role"_ustr , uno::Any( aSelectedRole )); if( !xLabeledSeq.is()) { if( aSelectedRole == aSequenceNameForLabel ) - xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); + xLabeledSeq = lcl_findLSequenceWithOnlyLabel( pSeriesEntry->m_xDataSeries ); if( ! xLabeledSeq.is()) { - xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence() ); - lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); + xLabeledSeq = DataSourceHelper::createLabeledDataSequence(); + lcl_addLSequenceToDataSource( xLabeledSeq, pSeriesEntry->m_xDataSeries ); } } xLabeledSeq->setValues( xNewSeq ); @@ -908,9 +893,8 @@ bool DataSourceTabPage::updateModelFromControl(const weld::Entry* pField) { try { - Reference< util::XModifiable > xModifiable( m_rDialogModel.getChartModel(), uno::UNO_QUERY ); - if( xModifiable.is() ) - xModifiable->setModified( true ); + if( m_rDialogModel.getChartModel() ) + m_rDialogModel.getChartModel()->setModified( true ); const DialogModelTimeBasedInfo& rInfo = m_rDialogModel.getTimeBasedInfo(); if(rInfo.bTimeBased) { diff --git a/chart2/source/controller/dialogs/tp_DataSource.hxx b/chart2/source/controller/dialogs/tp_DataSource.hxx index 1b6ba9862168..40219d917f9c 100644 --- a/chart2/source/controller/dialogs/tp_DataSource.hxx +++ b/chart2/source/controller/dialogs/tp_DataSource.hxx @@ -18,6 +18,9 @@ */ #pragma once +#include <DataSeries.hxx> +#include <ChartType.hxx> + #include <vcl/wizardmachine.hxx> #include <RangeSelectionListener.hxx> @@ -29,8 +32,9 @@ namespace chart { class TabPageNotifiable; } namespace chart { - +class ChartType; class ChartTypeTemplateProvider; +class DataSeries; class DialogModel; class SeriesEntry @@ -39,10 +43,10 @@ public: OUString m_sRole; /// the corresponding data series - css::uno::Reference< css::chart2::XDataSeries > m_xDataSeries; + rtl::Reference< ::chart::DataSeries > m_xDataSeries; /// the chart type that contains the series (via XDataSeriesContainer) - css::uno::Reference< css::chart2::XChartType > m_xChartType; + rtl::Reference< ::chart::ChartType > m_xChartType; }; class DataSourceTabPage final : diff --git a/chart2/source/controller/dialogs/tp_DataTable.cxx b/chart2/source/controller/dialogs/tp_DataTable.cxx new file mode 100644 index 000000000000..acf447501483 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataTable.cxx @@ -0,0 +1,43 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "tp_DataTable.hxx" + +namespace chart +{ +DataTableTabPage::DataTableTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_DataTable.ui"_ustr, + u"DataTableTabPage"_ustr, &rInAttrs) + , m_aDataTablePropertiesResources(*m_xBuilder) +{ +} + +DataTableTabPage::~DataTableTabPage() = default; + +std::unique_ptr<SfxTabPage> DataTableTabPage::Create(weld::Container* pPage, + weld::DialogController* pController, + const SfxItemSet* rAttrs) +{ + return std::make_unique<DataTableTabPage>(pPage, pController, *rAttrs); +} + +bool DataTableTabPage::FillItemSet(SfxItemSet* pOutAttrs) +{ + return m_aDataTablePropertiesResources.writeToItemSet(*pOutAttrs); +} + +void DataTableTabPage::Reset(const SfxItemSet* pInAttrs) +{ + m_aDataTablePropertiesResources.initFromItemSet(*pInAttrs); +} + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_DataTable.hxx b/chart2/source/controller/dialogs/tp_DataTable.hxx new file mode 100644 index 000000000000..00ab64cf89ce --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataTable.hxx @@ -0,0 +1,37 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <sfx2/tabdlg.hxx> +#include <res_DataTableProperties.hxx> + +namespace chart +{ +/** Tab page for the data table properties */ +class DataTableTabPage : public SfxTabPage +{ +private: + DataTablePropertiesResources m_aDataTablePropertiesResources; + +public: + DataTableTabPage(weld::Container* pPage, weld::DialogController* pController, + const SfxItemSet& rInAttrs); + virtual ~DataTableTabPage() override; + + static std::unique_ptr<SfxTabPage> + Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs); + + virtual bool FillItemSet(SfxItemSet* rOutAttrs) override; + virtual void Reset(const SfxItemSet* rInAttrs) override; +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.cxx b/chart2/source/controller/dialogs/tp_ErrorBars.cxx index 94a3d6c77173..8c63332e5e7d 100644 --- a/chart2/source/controller/dialogs/tp_ErrorBars.cxx +++ b/chart2/source/controller/dialogs/tp_ErrorBars.cxx @@ -25,7 +25,7 @@ namespace chart { ErrorBarsTabPage::ErrorBarsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_ErrorBars.ui", "tp_ErrorBars", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_ErrorBars.ui"_ustr, u"tp_ErrorBars"_ustr, &rInAttrs) , m_aErrorBarResources(m_xBuilder.get(), pController, rInAttrs, /* bNoneAvailable = */ false) { } @@ -57,7 +57,7 @@ void ErrorBarsTabPage::SetErrorBarType( ErrorBarResources::tErrorBarType eNewTyp } void ErrorBarsTabPage::SetChartDocumentForRangeChoosing( - const uno::Reference< chart2::XChartDocument > & xChartDocument ) + const rtl::Reference<::chart::ChartModel> & xChartDocument ) { m_aErrorBarResources.SetChartDocumentForRangeChoosing( xChartDocument ); } diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.hxx b/chart2/source/controller/dialogs/tp_ErrorBars.hxx index 354006a26889..159de22b0d03 100644 --- a/chart2/source/controller/dialogs/tp_ErrorBars.hxx +++ b/chart2/source/controller/dialogs/tp_ErrorBars.hxx @@ -21,9 +21,11 @@ #include <res_ErrorBar.hxx> #include <sfx2/tabdlg.hxx> +#include <rtl/ref.hxx> namespace chart { +class ChartModel; class ErrorBarsTabPage : public SfxTabPage { @@ -33,7 +35,7 @@ public: void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); void SetErrorBarType( ErrorBarResources::tErrorBarType eNewType ); void SetChartDocumentForRangeChoosing( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument ); + const rtl::Reference<::chart::ChartModel> & xChartDocument ); static std::unique_ptr<SfxTabPage> Create( weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rInAttrs ); virtual bool FillItemSet( SfxItemSet* rOutAttrs ) override; diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx index 04697e75efc9..6c059cec7795 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.cxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -28,16 +28,15 @@ namespace chart { SchLegendPosTabPage::SchLegendPosTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_LegendPosition.ui", "tp_LegendPosition", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_LegendPosition.ui"_ustr, u"tp_LegendPosition"_ustr, &rInAttrs) , m_aLegendPositionResources(*m_xBuilder) - , m_xLbTextDirection(new TextDirectionListBox(m_xBuilder->weld_combo_box("LB_LEGEND_TEXTDIR"))) - , m_xCBLegendNoOverlay(m_xBuilder->weld_check_button("CB_NO_OVERLAY")) + , m_aLbTextDirection(m_xBuilder->weld_combo_box(u"LB_LEGEND_TEXTDIR"_ustr)) + , m_xCBLegendNoOverlay(m_xBuilder->weld_check_button(u"CB_NO_OVERLAY"_ustr)) { } SchLegendPosTabPage::~SchLegendPosTabPage() { - m_xLbTextDirection.reset(); } std::unique_ptr<SfxTabPage> SchLegendPosTabPage::Create(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet* rOutAttrs) @@ -49,8 +48,8 @@ bool SchLegendPosTabPage::FillItemSet(SfxItemSet* rOutAttrs) { m_aLegendPositionResources.writeToItemSet(*rOutAttrs); - if (m_xLbTextDirection->get_active() != -1) - rOutAttrs->Put(SvxFrameDirectionItem(m_xLbTextDirection->get_active_id(), EE_PARA_WRITINGDIR)); + if (m_aLbTextDirection.get_active() != -1) + rOutAttrs->Put(SvxFrameDirectionItem(m_aLbTextDirection.get_active_id(), EE_PARA_WRITINGDIR)); if (m_xCBLegendNoOverlay->get_visible()) rOutAttrs->Put(SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, m_xCBLegendNoOverlay->get_active())); @@ -62,13 +61,12 @@ void SchLegendPosTabPage::Reset(const SfxItemSet* rInAttrs) { m_aLegendPositionResources.initFromItemSet(*rInAttrs); - const SfxPoolItem* pPoolItem = nullptr; - if( rInAttrs->GetItemState( EE_PARA_WRITINGDIR, true, &pPoolItem ) == SfxItemState::SET ) - m_xLbTextDirection->set_active_id( static_cast<const SvxFrameDirectionItem*>(pPoolItem)->GetValue() ); + if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet( EE_PARA_WRITINGDIR ) ) + m_aLbTextDirection.set_active_id( pDirectionItem->GetValue() ); - if (rInAttrs->GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pNoOverlayItem = rInAttrs->GetItemIfSet(SCHATTR_LEGEND_NO_OVERLAY)) { - bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + bool bVal = pNoOverlayItem->GetValue(); m_xCBLegendNoOverlay->set_active(bVal); } } diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx index 9e5f32d281a7..4534501b5209 100644 --- a/chart2/source/controller/dialogs/tp_LegendPosition.hxx +++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx @@ -21,8 +21,7 @@ #include <sfx2/tabdlg.hxx> #include <res_LegendPosition.hxx> - -namespace chart { class TextDirectionListBox; } +#include <TextDirectionListBox.hxx> namespace chart { @@ -32,7 +31,7 @@ class SchLegendPosTabPage : public SfxTabPage private: LegendPositionResources m_aLegendPositionResources; - std::unique_ptr<TextDirectionListBox> m_xLbTextDirection; + TextDirectionListBox m_aLbTextDirection; std::unique_ptr<weld::CheckButton> m_xCBLegendNoOverlay; public: diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx b/chart2/source/controller/dialogs/tp_PointGeometry.cxx index 88116ee890e1..e9f1d1b957d7 100644 --- a/chart2/source/controller/dialogs/tp_PointGeometry.cxx +++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx @@ -29,7 +29,7 @@ namespace chart { SchLayoutTabPage::SchLayoutTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_ChartType.ui", "tp_ChartType", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_ChartType.ui"_ustr, u"tp_ChartType"_ustr, &rInAttrs) { m_pGeometryResources.reset(new BarGeometryResources(m_xBuilder.get())); } @@ -62,11 +62,9 @@ bool SchLayoutTabPage::FillItemSet(SfxItemSet* rOutAttrs) void SchLayoutTabPage::Reset(const SfxItemSet* rInAttrs) { - const SfxPoolItem *pPoolItem = nullptr; - - if (rInAttrs->GetItemState(SCHATTR_STYLE_SHAPE,true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pShapeItem = rInAttrs->GetItemIfSet(SCHATTR_STYLE_SHAPE)) { - tools::Long nVal = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + tools::Long nVal = pShapeItem->GetValue(); if(m_pGeometryResources) { m_pGeometryResources->select(static_cast<sal_uInt16>(nVal)); diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.cxx b/chart2/source/controller/dialogs/tp_PolarOptions.cxx index 59422b3a613e..cb646e3266be 100644 --- a/chart2/source/controller/dialogs/tp_PolarOptions.cxx +++ b/chart2/source/controller/dialogs/tp_PolarOptions.cxx @@ -21,7 +21,6 @@ #include <chartview/ChartSfxItemIds.hxx> #include <svl/eitem.hxx> -#include <svl/intitem.hxx> #include <svx/sdangitm.hxx> #include <officecfg/Office/Compatibility.hxx> @@ -29,14 +28,14 @@ namespace chart { PolarOptionsTabPage::PolarOptionsTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_PolarOptions.ui", "tp_PolarOptions", &rInAttrs) - , m_xCB_Clockwise(m_xBuilder->weld_check_button("CB_CLOCKWISE")) - , m_xFL_StartingAngle(m_xBuilder->weld_frame("frameANGLE")) - , m_xNF_StartingAngle(m_xBuilder->weld_metric_spin_button("NF_STARTING_ANGLE", FieldUnit::DEGREE)) - , m_xFL_PlotOptions(m_xBuilder->weld_frame("framePLOT_OPTIONS")) - , m_xCB_IncludeHiddenCells(m_xBuilder->weld_check_button("CB_INCLUDE_HIDDEN_CELLS_POLAR")) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_PolarOptions.ui"_ustr, u"tp_PolarOptions"_ustr, &rInAttrs) + , m_xCB_Clockwise(m_xBuilder->weld_check_button(u"CB_CLOCKWISE"_ustr)) + , m_xFL_StartingAngle(m_xBuilder->weld_frame(u"frameANGLE"_ustr)) + , m_xNF_StartingAngle(m_xBuilder->weld_metric_spin_button(u"NF_STARTING_ANGLE"_ustr, FieldUnit::DEGREE)) + , m_xFL_PlotOptions(m_xBuilder->weld_frame(u"framePLOT_OPTIONS"_ustr)) + , m_xCB_IncludeHiddenCells(m_xBuilder->weld_check_button(u"CB_INCLUDE_HIDDEN_CELLS_POLAR"_ustr)) , m_xAngleDial(new svx::DialControl) - , m_xAngleDialWin(new weld::CustomWeld(*m_xBuilder, "CT_ANGLE_DIAL", *m_xAngleDial)) + , m_xAngleDialWin(new weld::CustomWeld(*m_xBuilder, u"CT_ANGLE_DIAL"_ustr, *m_xAngleDial)) { m_xAngleDial->SetLinkedField(m_xNF_StartingAngle.get()); } @@ -70,11 +69,9 @@ bool PolarOptionsTabPage::FillItemSet( SfxItemSet* rOutAttrs ) void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs) { - const SfxPoolItem *pPoolItem = nullptr; - - if (rInAttrs->GetItemState(SCHATTR_STARTING_ANGLE, true, &pPoolItem) == SfxItemState::SET) + if (const SdrAngleItem* pAngleItem = rInAttrs->GetItemIfSet(SCHATTR_STARTING_ANGLE)) { - Degree100 nTmp = static_cast<const SdrAngleItem*>(pPoolItem)->GetValue(); + Degree100 nTmp = pAngleItem->GetValue(); m_xAngleDial->SetRotation( nTmp ); } else @@ -82,18 +79,20 @@ void PolarOptionsTabPage::Reset(const SfxItemSet* rInAttrs) m_xFL_StartingAngle->hide(); } // tdf#108059 Hide clockwise orientation checkbox in OOXML-heavy environments it would be useless anyways - if (!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get() && rInAttrs->GetItemState(SCHATTR_CLOCKWISE, true, &pPoolItem) == SfxItemState::SET) + const SfxBoolItem* pClockWiseItem = nullptr; + if (!officecfg::Office::Compatibility::View::ClockwisePieChartDirection::get() && + (pClockWiseItem = rInAttrs->GetItemIfSet(SCHATTR_CLOCKWISE))) { - bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + bool bCheck = pClockWiseItem->GetValue(); m_xCB_Clockwise->set_active(bCheck); } else { m_xCB_Clockwise->hide(); } - if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pHiddenCellsItem = rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS)) { - bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + bool bVal = pHiddenCellsItem->GetValue(); m_xCB_IncludeHiddenCells->set_active(bVal); } else diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.hxx b/chart2/source/controller/dialogs/tp_PolarOptions.hxx index eba4018052af..51ad7a809be0 100644 --- a/chart2/source/controller/dialogs/tp_PolarOptions.hxx +++ b/chart2/source/controller/dialogs/tp_PolarOptions.hxx @@ -25,7 +25,6 @@ namespace weld { class CheckButton; class CustomWeld; class Frame; - class SpinButton; } namespace chart diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx index e0ceccec2fe0..4977569e2c13 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.cxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -20,6 +20,7 @@ #include "tp_RangeChooser.hxx" #include <DataSourceHelper.hxx> #include <ChartTypeTemplateProvider.hxx> +#include <ChartTypeTemplate.hxx> #include "DialogModel.hxx" #include <RangeSelectionHelper.hxx> #include <TabPageNotifiable.hxx> @@ -40,15 +41,6 @@ namespace } } - void lcl_enableRangeChoosing(bool bEnable, weld::DialogController* pDialog) - { - if (!pDialog) - return; - weld::Dialog* pDlg = pDialog->getDialog(); - pDlg->set_modal(!bEnable); - pDlg->set_visible(!bEnable); - } - } // anonymous namespace namespace chart @@ -61,28 +53,26 @@ using ::com::sun::star::uno::Sequence; RangeChooserTabPage::RangeChooserTabPage(weld::Container* pPage, weld::DialogController* pController, DialogModel & rDialogModel, ChartTypeTemplateProvider* pTemplateProvider, bool bHideDescription /* = false */) - : OWizardPage(pPage, pController, "modules/schart/ui/tp_RangeChooser.ui", "tp_RangeChooser") + : OWizardPage(pPage, pController, u"modules/schart/ui/tp_RangeChooser.ui"_ustr, u"tp_RangeChooser"_ustr) , m_nChangingControlCalls(0) , m_bIsDirty(false) - , m_aLastValidRangeString() , m_pTemplateProvider(pTemplateProvider) , m_rDialogModel( rDialogModel ) , m_pTabPageNotifiable(dynamic_cast<TabPageNotifiable*>(pController)) - , m_xFT_Caption(m_xBuilder->weld_label("FT_CAPTION_FOR_WIZARD")) - , m_xFT_Range(m_xBuilder->weld_label("FT_RANGE")) - , m_xED_Range(m_xBuilder->weld_entry("ED_RANGE")) - , m_xIB_Range(m_xBuilder->weld_button("IB_RANGE")) - , m_xRB_Rows(m_xBuilder->weld_radio_button("RB_DATAROWS")) - , m_xRB_Columns(m_xBuilder->weld_radio_button("RB_DATACOLS")) - , m_xCB_FirstRowAsLabel(m_xBuilder->weld_check_button("CB_FIRST_ROW_ASLABELS")) - , m_xCB_FirstColumnAsLabel(m_xBuilder->weld_check_button("CB_FIRST_COLUMN_ASLABELS")) - , m_xFTTitle(m_xBuilder->weld_label("STR_PAGE_DATA_RANGE")) - , m_xFL_TimeBased(m_xBuilder->weld_widget("separator1")) - , m_xCB_TimeBased(m_xBuilder->weld_check_button("CB_TIME_BASED")) - , m_xFT_TimeStart(m_xBuilder->weld_label("label1")) - , m_xEd_TimeStart(m_xBuilder->weld_entry("ED_TIME_BASED_START")) - , m_xFT_TimeEnd(m_xBuilder->weld_label("label2")) - , m_xEd_TimeEnd(m_xBuilder->weld_entry("ED_TIME_BASED_END")) + , m_xFT_Caption(m_xBuilder->weld_label(u"FT_CAPTION_FOR_WIZARD"_ustr)) + , m_xED_Range(m_xBuilder->weld_entry(u"ED_RANGE"_ustr)) + , m_xIB_Range(m_xBuilder->weld_button(u"IB_RANGE"_ustr)) + , m_xRB_Rows(m_xBuilder->weld_radio_button(u"RB_DATAROWS"_ustr)) + , m_xRB_Columns(m_xBuilder->weld_radio_button(u"RB_DATACOLS"_ustr)) + , m_xCB_FirstRowAsLabel(m_xBuilder->weld_check_button(u"CB_FIRST_ROW_ASLABELS"_ustr)) + , m_xCB_FirstColumnAsLabel(m_xBuilder->weld_check_button(u"CB_FIRST_COLUMN_ASLABELS"_ustr)) + , m_xFTTitle(m_xBuilder->weld_label(u"STR_PAGE_DATA_RANGE"_ustr)) + , m_xFL_TimeBased(m_xBuilder->weld_widget(u"separator1"_ustr)) + , m_xCB_TimeBased(m_xBuilder->weld_check_button(u"CB_TIME_BASED"_ustr)) + , m_xFT_TimeStart(m_xBuilder->weld_label(u"label1"_ustr)) + , m_xEd_TimeStart(m_xBuilder->weld_entry(u"ED_TIME_BASED_START"_ustr)) + , m_xFT_TimeEnd(m_xBuilder->weld_label(u"label2"_ustr)) + , m_xEd_TimeEnd(m_xBuilder->weld_entry(u"ED_TIME_BASED_END"_ustr)) { m_xFT_Caption->set_visible(!bHideDescription); @@ -192,7 +182,7 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() if( !m_xCurrentChartTypeTemplate.is() ) { if(m_pTemplateProvider) - m_xCurrentChartTypeTemplate.set( m_pTemplateProvider->getCurrentTemplate()); + m_xCurrentChartTypeTemplate = m_pTemplateProvider->getCurrentTemplate(); if( !m_xCurrentChartTypeTemplate.is()) { OSL_FAIL( "Need a template to change data source" ); @@ -216,8 +206,8 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() if(bTimeBased) { aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = - beans::PropertyValue( "TimeBased", -1, uno::Any(bTimeBased), + aArguments.getArray()[aArguments.getLength() - 1] = + beans::PropertyValue( u"TimeBased"_ustr, -1, uno::Any(bTimeBased), beans::PropertyState_DIRECT_VALUE ); } @@ -227,8 +217,8 @@ void RangeChooserTabPage::changeDialogModelAccordingToControls() m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate ); aArguments.realloc( aArguments.getLength() + 1 ); - aArguments[aArguments.getLength() - 1] = - beans::PropertyValue( "CellRangeRepresentation" , -1, + aArguments.getArray()[aArguments.getLength() - 1] = + beans::PropertyValue( u"CellRangeRepresentation"_ustr , -1, uno::Any( m_aLastValidRangeString ), beans::PropertyState_DIRECT_VALUE ); m_rDialogModel.setData( aArguments ); @@ -338,7 +328,7 @@ IMPL_LINK_NOARG(RangeChooserTabPage, ChooseRangeHdl, weld::Button&, void) OUString aRange = m_xED_Range->get_text(); OUString aTitle = m_xFTTitle->get_label(); - lcl_enableRangeChoosing(true, m_pDialogController); + enableRangeChoosing(true, m_pDialogController); m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this ); } @@ -362,7 +352,7 @@ void RangeChooserTabPage::listeningFinished( const OUString & rNewRange ) if( isValid()) changeDialogModelAccordingToControls(); - lcl_enableRangeChoosing(false, m_pDialogController); + enableRangeChoosing(false, m_pDialogController); } void RangeChooserTabPage::disposingRangeSelection() diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.hxx b/chart2/source/controller/dialogs/tp_RangeChooser.hxx index 7d4e1a4183c2..428e8a127dd9 100644 --- a/chart2/source/controller/dialogs/tp_RangeChooser.hxx +++ b/chart2/source/controller/dialogs/tp_RangeChooser.hxx @@ -24,11 +24,10 @@ #include <vcl/wizardmachine.hxx> namespace chart { class TabPageNotifiable; } -namespace com::sun::star::chart2 { class XChartTypeTemplate; } namespace chart { - +class ChartTypeTemplate; class ChartTypeTemplateProvider; class DialogModel; @@ -72,14 +71,13 @@ private: bool m_bIsDirty; OUString m_aLastValidRangeString; - css::uno::Reference< css::chart2::XChartTypeTemplate > m_xCurrentChartTypeTemplate; + rtl::Reference< ::chart::ChartTypeTemplate > m_xCurrentChartTypeTemplate; ChartTypeTemplateProvider* m_pTemplateProvider; DialogModel & m_rDialogModel; TabPageNotifiable * m_pTabPageNotifiable; std::unique_ptr<weld::Label> m_xFT_Caption; - std::unique_ptr<weld::Label> m_xFT_Range; std::unique_ptr<weld::Entry> m_xED_Range; std::unique_ptr<weld::Button> m_xIB_Range; std::unique_ptr<weld::RadioButton> m_xRB_Rows; diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx index db2ba248ee8e..8d7ce3d9ff58 100644 --- a/chart2/source/controller/dialogs/tp_Scale.cxx +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -26,9 +26,11 @@ #include <svx/svxids.hrc> #include <osl/diagnose.h> +#include <sfx2/dialoghelper.hxx> #include <svx/chrtitem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> +#include <svl/numformat.hxx> #include <vcl/formatter.hxx> #include <vcl/weld.hxx> #include <svl/zformat.hxx> @@ -52,7 +54,7 @@ void lcl_setValue(weld::FormattedSpinButton& rFmtField, double fValue) } ScaleTabPage::ScaleTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_Scale.ui", "tp_Scale", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_Scale.ui"_ustr, u"tp_Scale"_ustr, &rInAttrs) , fMin(0.0) , fMax(0.0) , fStepMain(0.0) @@ -65,31 +67,31 @@ ScaleTabPage::ScaleTabPage(weld::Container* pPage, weld::DialogController* pCont , m_bAllowDateAxis(false) , pNumFormatter(nullptr) , m_bShowAxisOrigin(false) - , m_xCbxReverse(m_xBuilder->weld_check_button("CBX_REVERSE")) - , m_xCbxLogarithm(m_xBuilder->weld_check_button("CBX_LOGARITHM")) - , m_xBxType(m_xBuilder->weld_widget("boxTYPE")) - , m_xLB_AxisType(m_xBuilder->weld_combo_box("LB_AXIS_TYPE")) - , m_xBxMinMax(m_xBuilder->weld_widget("gridMINMAX")) - , m_xFmtFldMin(m_xBuilder->weld_formatted_spin_button("EDT_MIN")) - , m_xCbxAutoMin(m_xBuilder->weld_check_button("CBX_AUTO_MIN")) - , m_xFmtFldMax(m_xBuilder->weld_formatted_spin_button("EDT_MAX")) - , m_xCbxAutoMax(m_xBuilder->weld_check_button("CBX_AUTO_MAX")) - , m_xBxResolution(m_xBuilder->weld_widget("boxRESOLUTION")) - , m_xLB_TimeResolution(m_xBuilder->weld_combo_box("LB_TIME_RESOLUTION")) - , m_xCbx_AutoTimeResolution(m_xBuilder->weld_check_button("CBX_AUTO_TIME_RESOLUTION")) - , m_xTxtMain(m_xBuilder->weld_label("TXT_STEP_MAIN")) - , m_xFmtFldStepMain(m_xBuilder->weld_formatted_spin_button("EDT_STEP_MAIN")) - , m_xMt_MainDateStep(m_xBuilder->weld_spin_button("MT_MAIN_DATE_STEP")) - , m_xLB_MainTimeUnit(m_xBuilder->weld_combo_box("LB_MAIN_TIME_UNIT")) - , m_xCbxAutoStepMain(m_xBuilder->weld_check_button("CBX_AUTO_STEP_MAIN")) - , m_xTxtHelpCount(m_xBuilder->weld_label("TXT_STEP_HELP_COUNT")) - , m_xTxtHelp(m_xBuilder->weld_label("TXT_STEP_HELP")) - , m_xMtStepHelp(m_xBuilder->weld_spin_button("MT_STEPHELP")) - , m_xLB_HelpTimeUnit(m_xBuilder->weld_combo_box("LB_HELP_TIME_UNIT")) - , m_xCbxAutoStepHelp(m_xBuilder->weld_check_button("CBX_AUTO_STEP_HELP")) - , m_xFmtFldOrigin(m_xBuilder->weld_formatted_spin_button("EDT_ORIGIN")) - , m_xCbxAutoOrigin(m_xBuilder->weld_check_button("CBX_AUTO_ORIGIN")) - , m_xBxOrigin(m_xBuilder->weld_widget("boxORIGIN")) + , m_xCbxReverse(m_xBuilder->weld_check_button(u"CBX_REVERSE"_ustr)) + , m_xCbxLogarithm(m_xBuilder->weld_check_button(u"CBX_LOGARITHM"_ustr)) + , m_xBxType(m_xBuilder->weld_widget(u"boxTYPE"_ustr)) + , m_xLB_AxisType(m_xBuilder->weld_combo_box(u"LB_AXIS_TYPE"_ustr)) + , m_xBxMinMax(m_xBuilder->weld_widget(u"gridMINMAX"_ustr)) + , m_xFmtFldMin(m_xBuilder->weld_formatted_spin_button(u"EDT_MIN"_ustr)) + , m_xCbxAutoMin(m_xBuilder->weld_check_button(u"CBX_AUTO_MIN"_ustr)) + , m_xFmtFldMax(m_xBuilder->weld_formatted_spin_button(u"EDT_MAX"_ustr)) + , m_xCbxAutoMax(m_xBuilder->weld_check_button(u"CBX_AUTO_MAX"_ustr)) + , m_xBxResolution(m_xBuilder->weld_widget(u"boxRESOLUTION"_ustr)) + , m_xLB_TimeResolution(m_xBuilder->weld_combo_box(u"LB_TIME_RESOLUTION"_ustr)) + , m_xCbx_AutoTimeResolution(m_xBuilder->weld_check_button(u"CBX_AUTO_TIME_RESOLUTION"_ustr)) + , m_xTxtMain(m_xBuilder->weld_label(u"TXT_STEP_MAIN"_ustr)) + , m_xFmtFldStepMain(m_xBuilder->weld_formatted_spin_button(u"EDT_STEP_MAIN"_ustr)) + , m_xMt_MainDateStep(m_xBuilder->weld_spin_button(u"MT_MAIN_DATE_STEP"_ustr)) + , m_xLB_MainTimeUnit(m_xBuilder->weld_combo_box(u"LB_MAIN_TIME_UNIT"_ustr)) + , m_xCbxAutoStepMain(m_xBuilder->weld_check_button(u"CBX_AUTO_STEP_MAIN"_ustr)) + , m_xTxtHelpCount(m_xBuilder->weld_label(u"TXT_STEP_HELP_COUNT"_ustr)) + , m_xTxtHelp(m_xBuilder->weld_label(u"TXT_STEP_HELP"_ustr)) + , m_xMtStepHelp(m_xBuilder->weld_spin_button(u"MT_STEPHELP"_ustr)) + , m_xLB_HelpTimeUnit(m_xBuilder->weld_combo_box(u"LB_HELP_TIME_UNIT"_ustr)) + , m_xCbxAutoStepHelp(m_xBuilder->weld_check_button(u"CBX_AUTO_STEP_HELP"_ustr)) + , m_xFmtFldOrigin(m_xBuilder->weld_formatted_spin_button(u"EDT_ORIGIN"_ustr)) + , m_xCbxAutoOrigin(m_xBuilder->weld_check_button(u"CBX_AUTO_ORIGIN"_ustr)) + , m_xBxOrigin(m_xBuilder->weld_widget(u"boxORIGIN"_ustr)) { m_xCbxAutoMin->connect_toggled(LINK(this, ScaleTabPage, EnableValueHdl)); m_xCbxAutoMax->connect_toggled(LINK(this, ScaleTabPage, EnableValueHdl)); @@ -270,19 +272,18 @@ void ScaleTabPage::Reset(const SfxItemSet* rInAttrs) if(!pNumFormatter) return; - const SfxPoolItem *pPoolItem = nullptr; - if (rInAttrs->GetItemState(SCHATTR_AXIS_ALLOW_DATEAXIS, true, &pPoolItem) == SfxItemState::SET) - m_bAllowDateAxis = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + if (const SfxBoolItem* pDateAxisItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_ALLOW_DATEAXIS)) + m_bAllowDateAxis = pDateAxisItem->GetValue(); m_nAxisType=chart2::AxisType::REALNUMBER; - if (rInAttrs->GetItemState(SCHATTR_AXISTYPE, true, &pPoolItem) == SfxItemState::SET) - m_nAxisType = static_cast<int>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue()); + if (const SfxInt32Item* pAxisTypeItem = rInAttrs->GetItemIfSet(SCHATTR_AXISTYPE)) + m_nAxisType = static_cast<int>(pAxisTypeItem->GetValue()); if( m_nAxisType==chart2::AxisType::DATE && !m_bAllowDateAxis ) m_nAxisType=chart2::AxisType::CATEGORY; if( m_bAllowDateAxis ) { bool bAutoDateAxis = false; - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_DATEAXIS, true, &pPoolItem) == SfxItemState::SET) - bAutoDateAxis = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + if (const SfxBoolItem* pDateAxisItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_DATEAXIS)) + bAutoDateAxis = pDateAxisItem->GetValue(); sal_uInt16 nPos = 0; if( m_nAxisType==chart2::AxisType::DATE ) @@ -301,74 +302,74 @@ void ScaleTabPage::Reset(const SfxItemSet* rInAttrs) m_xCbxAutoOrigin->set_active(true); m_xCbx_AutoTimeResolution->set_active(true); - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MIN,true,&pPoolItem) == SfxItemState::SET) - m_xCbxAutoMin->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + if (const SfxBoolItem* pAutoMinItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_MIN)) + m_xCbxAutoMin->set_active(pAutoMinItem->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_MIN,true, &pPoolItem) == SfxItemState::SET) + if (const SvxDoubleItem* pAxisMinItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_MIN)) { - fMin = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + fMin = pAxisMinItem->GetValue(); lcl_setValue( *m_xFmtFldMin, fMin ); m_xFmtFldMin->save_value(); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_MAX,true, &pPoolItem) == SfxItemState::SET) - m_xCbxAutoMax->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + if (const SfxBoolItem* pAutoMaxItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_MAX)) + m_xCbxAutoMax->set_active(pAutoMaxItem->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_MAX,true, &pPoolItem) == SfxItemState::SET) + if (const SvxDoubleItem* pAxisMaxItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_MAX)) { - fMax = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + fMax = pAxisMaxItem->GetValue(); lcl_setValue( *m_xFmtFldMax, fMax ); m_xFmtFldMax->save_value(); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,true, &pPoolItem) == SfxItemState::SET) - m_xCbxAutoStepMain->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); + if (const SfxBoolItem* pAutoStepMainItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_STEP_MAIN)) + m_xCbxAutoStepMain->set_active(pAutoStepMainItem->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_MAIN,true, &pPoolItem) == SfxItemState::SET) + if (const SvxDoubleItem* pStepMainItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_STEP_MAIN)) { - fStepMain = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + fStepMain = pStepMainItem->GetValue(); lcl_setValue( *m_xFmtFldStepMain, fStepMain ); m_xFmtFldStepMain->save_value(); m_xMt_MainDateStep->set_value( static_cast<sal_Int32>(fStepMain) ); m_xMt_MainDateStep->save_value(); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,true, &pPoolItem) == SfxItemState::SET) - m_xCbxAutoStepHelp->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_LOGARITHM,true, &pPoolItem) == SfxItemState::SET) - m_xCbxLogarithm->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_REVERSE,true, &pPoolItem) == SfxItemState::SET) - m_xCbxReverse->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_STEP_HELP,true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pAutoStepHelpItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_STEP_HELP)) + m_xCbxAutoStepHelp->set_active(pAutoStepHelpItem->GetValue()); + if (const SfxBoolItem* pLogItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_LOGARITHM)) + m_xCbxLogarithm->set_active(pLogItem->GetValue()); + if (const SfxBoolItem* pReverseItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_REVERSE)) + m_xCbxReverse->set_active(pReverseItem->GetValue()); + if (const SfxInt32Item* pStepHelpItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_STEP_HELP)) { - nStepHelp = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + nStepHelp = pStepHelpItem->GetValue(); m_xMtStepHelp->set_value( nStepHelp ); m_xMtStepHelp->save_value(); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,true, &pPoolItem) == SfxItemState::SET) - m_xCbxAutoOrigin->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_ORIGIN,true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pOriginItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_ORIGIN)) + m_xCbxAutoOrigin->set_active(pOriginItem->GetValue()); + if (const SvxDoubleItem* pOriginItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_ORIGIN)) { - fOrigin = static_cast<const SvxDoubleItem*>(pPoolItem)->GetValue(); + fOrigin = pOriginItem->GetValue(); lcl_setValue( *m_xFmtFldOrigin, fOrigin ); m_xFmtFldOrigin->save_value(); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_AUTO_TIME_RESOLUTION,true, &pPoolItem) == SfxItemState::SET) - m_xCbx_AutoTimeResolution->set_active(static_cast<const SfxBoolItem*>(pPoolItem)->GetValue()); - if (rInAttrs->GetItemState(SCHATTR_AXIS_TIME_RESOLUTION,true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pAutoTimeResItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_AUTO_TIME_RESOLUTION)) + m_xCbx_AutoTimeResolution->set_active(pAutoTimeResItem->GetValue()); + if (const SfxInt32Item* pTimeResItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_TIME_RESOLUTION)) { - m_nTimeResolution = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + m_nTimeResolution = pTimeResItem->GetValue(); m_xLB_TimeResolution->set_active( m_nTimeResolution ); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_MAIN_TIME_UNIT,true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pMainTimeUnitItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_MAIN_TIME_UNIT)) { - m_nMainTimeUnit = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + m_nMainTimeUnit = pMainTimeUnitItem->GetValue(); m_xLB_MainTimeUnit->set_active( m_nMainTimeUnit ); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_HELP_TIME_UNIT,true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pHelpTimeUnitItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_HELP_TIME_UNIT)) { - m_nHelpTimeUnit = static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + m_nHelpTimeUnit = pHelpTimeUnitItem->GetValue(); m_xLB_HelpTimeUnit->set_active( m_nHelpTimeUnit ); } @@ -395,7 +396,7 @@ DeactivateRC ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) nStepFmt = 0; weld::Widget* pControl = nullptr; - const char* pErrStrId = nullptr; + TranslateId pErrStrId; double fDummy; fMax = m_xFmtFldMax->GetFormatter().GetValue(); @@ -523,12 +524,12 @@ void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) void ScaleTabPage::SetNumFormat() { - const SfxPoolItem *pPoolItem = nullptr; + const SfxUInt32Item *pNumFormatItem = GetItemSet().GetItemIfSet( SID_ATTR_NUMBERFORMAT_VALUE ); - if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, true, &pPoolItem ) != SfxItemState::SET ) + if( !pNumFormatItem ) return; - sal_uLong nFmt = static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); + sal_uInt32 nFmt = pNumFormatItem->GetValue(); Formatter& rFmtFldMax = m_xFmtFldMax->GetFormatter(); rFmtFldMax.SetFormatKey(nFmt); @@ -557,6 +558,12 @@ void ScaleTabPage::SetNumFormat() nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME, pFormat->GetLanguage() ); else nFmt = pNumFormatter->GetStandardFormat( SvNumFormatType::TIME ); + + // tdf#141625 give enough space to see full date+time + int nWidestTime(m_xFmtFldMin->get_pixel_size(getWidestDateTime(Application::GetSettings().GetLocaleDataWrapper(), true)).Width()); + int nWidthChars = std::ceil(nWidestTime / m_xFmtFldMin->get_approximate_digit_width()) + 1; + m_xFmtFldMin->set_width_chars(nWidthChars); + m_xFmtFldMax->set_width_chars(nWidthChars); } if( m_nAxisType == chart2::AxisType::DATE && ( eType != SvNumFormatType::DATE && eType != SvNumFormatType::DATETIME) ) @@ -583,9 +590,9 @@ void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) m_bShowAxisOrigin = true; } -bool ScaleTabPage::ShowWarning(const char* pResIdMessage, weld::Widget* pControl /* = nullptr */) +bool ScaleTabPage::ShowWarning(TranslateId pResIdMessage, weld::Widget* pControl /* = nullptr */) { - if (pResIdMessage == nullptr) + if (!pResIdMessage) return false; std::unique_ptr<weld::MessageDialog> xWarn(Application::CreateMessageDialog(GetFrameWeld(), diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx index 101e6df1cede..928637101a67 100644 --- a/chart2/source/controller/dialogs/tp_Scale.hxx +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -19,6 +19,9 @@ #pragma once #include <sfx2/tabdlg.hxx> +#include <unotools/resmgr.hxx> + +class SvNumberFormatter; namespace chart { @@ -98,7 +101,7 @@ private: @return false, if nResIdMessage was 0, true otherwise */ - bool ShowWarning(const char* pResIdMessage, weld::Widget* pControl); + bool ShowWarning(TranslateId pResIdMessage, weld::Widget* pControl); void HideAllControls(); }; diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx index 15976e89fea8..ee6dabc07a6f 100644 --- a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx @@ -31,26 +31,26 @@ namespace chart { SchOptionTabPage::SchOptionTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_SeriesToAxis.ui", "TP_OPTIONS", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_SeriesToAxis.ui"_ustr, u"TP_OPTIONS"_ustr, &rInAttrs) , m_nAllSeriesAxisIndex(0) , m_bProvidesSecondaryYAxis(true) , m_bProvidesOverlapAndGapWidth(false) , m_bProvidesBarConnectors(false) - , m_xGrpAxis(m_xBuilder->weld_widget("frameGrpAxis")) - , m_xRbtAxis1(m_xBuilder->weld_radio_button("RBT_OPT_AXIS_1")) - , m_xRbtAxis2(m_xBuilder->weld_radio_button("RBT_OPT_AXIS_2")) - , m_xGrpBar(m_xBuilder->weld_widget("frameSettings")) - , m_xMTGap(m_xBuilder->weld_metric_spin_button("MT_GAP", FieldUnit::PERCENT)) - , m_xMTOverlap(m_xBuilder->weld_metric_spin_button("MT_OVERLAP", FieldUnit::PERCENT)) - , m_xCBConnect(m_xBuilder->weld_check_button("CB_CONNECTOR")) - , m_xCBAxisSideBySide(m_xBuilder->weld_check_button("CB_BARS_SIDE_BY_SIDE")) - , m_xGrpPlotOptions(m_xBuilder->weld_widget("frameFL_PLOT_OPTIONS")) - , m_xGridPlotOptions(m_xBuilder->weld_widget("gridPLOT_OPTIONS")) - , m_xRB_DontPaint(m_xBuilder->weld_radio_button("RB_DONT_PAINT")) - , m_xRB_AssumeZero(m_xBuilder->weld_radio_button("RB_ASSUME_ZERO")) - , m_xRB_ContinueLine(m_xBuilder->weld_radio_button("RB_CONTINUE_LINE")) - , m_xCBIncludeHiddenCells(m_xBuilder->weld_check_button("CB_INCLUDE_HIDDEN_CELLS")) - , m_xCBHideLegendEntry(m_xBuilder->weld_check_button("CB_LEGEND_ENTRY_HIDDEN")) + , m_xGrpAxis(m_xBuilder->weld_widget(u"frameGrpAxis"_ustr)) + , m_xRbtAxis1(m_xBuilder->weld_radio_button(u"RBT_OPT_AXIS_1"_ustr)) + , m_xRbtAxis2(m_xBuilder->weld_radio_button(u"RBT_OPT_AXIS_2"_ustr)) + , m_xGrpBar(m_xBuilder->weld_widget(u"frameSettings"_ustr)) + , m_xMTGap(m_xBuilder->weld_metric_spin_button(u"MT_GAP"_ustr, FieldUnit::PERCENT)) + , m_xMTOverlap(m_xBuilder->weld_metric_spin_button(u"MT_OVERLAP"_ustr, FieldUnit::PERCENT)) + , m_xCBConnect(m_xBuilder->weld_check_button(u"CB_CONNECTOR"_ustr)) + , m_xCBAxisSideBySide(m_xBuilder->weld_check_button(u"CB_BARS_SIDE_BY_SIDE"_ustr)) + , m_xGrpPlotOptions(m_xBuilder->weld_widget(u"frameFL_PLOT_OPTIONS"_ustr)) + , m_xGridPlotOptions(m_xBuilder->weld_widget(u"gridPLOT_OPTIONS"_ustr)) + , m_xRB_DontPaint(m_xBuilder->weld_radio_button(u"RB_DONT_PAINT"_ustr)) + , m_xRB_AssumeZero(m_xBuilder->weld_radio_button(u"RB_ASSUME_ZERO"_ustr)) + , m_xRB_ContinueLine(m_xBuilder->weld_radio_button(u"RB_CONTINUE_LINE"_ustr)) + , m_xCBIncludeHiddenCells(m_xBuilder->weld_check_button(u"CB_INCLUDE_HIDDEN_CELLS"_ustr)) + , m_xCBHideLegendEntry(m_xBuilder->weld_check_button(u"CB_LEGEND_ENTRY_HIDDEN"_ustr)) { m_xRbtAxis1->connect_toggled(LINK(this, SchOptionTabPage, EnableHdl)); m_xRbtAxis2->connect_toggled(LINK(this, SchOptionTabPage, EnableHdl)); @@ -113,13 +113,11 @@ bool SchOptionTabPage::FillItemSet(SfxItemSet* rOutAttrs) void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) { - const SfxPoolItem *pPoolItem = nullptr; - m_xRbtAxis1->set_active(true); m_xRbtAxis2->set_active(false); - if (rInAttrs->GetItemState(SCHATTR_AXIS,true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pAxisItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS)) { - tools::Long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + tools::Long nVal = pAxisItem->GetValue(); if(nVal==CHART_AXIS_SECONDARY_Y) { m_xRbtAxis2->set_active(true); @@ -128,34 +126,34 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) } tools::Long nTmp; - if (rInAttrs->GetItemState(SCHATTR_BAR_GAPWIDTH, true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pGapWidthItem = rInAttrs->GetItemIfSet(SCHATTR_BAR_GAPWIDTH)) { - nTmp = static_cast<tools::Long>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue()); + nTmp = static_cast<tools::Long>(pGapWidthItem->GetValue()); m_xMTGap->set_value(nTmp, FieldUnit::PERCENT); } - if (rInAttrs->GetItemState(SCHATTR_BAR_OVERLAP, true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pOverlapItem = rInAttrs->GetItemIfSet(SCHATTR_BAR_OVERLAP)) { - nTmp = static_cast<tools::Long>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue()); + nTmp = static_cast<tools::Long>(pOverlapItem->GetValue()); m_xMTOverlap->set_value(nTmp, FieldUnit::PERCENT); } - if (rInAttrs->GetItemState(SCHATTR_BAR_CONNECT, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pConnectItem = rInAttrs->GetItemIfSet(SCHATTR_BAR_CONNECT)) { - bool bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + bool bCheck = pConnectItem->GetValue(); m_xCBConnect->set_active(bCheck); } - if (rInAttrs->GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, true, &pPoolItem) == SfxItemState::SET) + if (const SfxInt32Item* pAllSeriesItem = rInAttrs->GetItemIfSet(SCHATTR_AXIS_FOR_ALL_SERIES)) { - m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + m_nAllSeriesAxisIndex = pAllSeriesItem->GetValue(); m_xCBAxisSideBySide->set_sensitive(false); } - if (rInAttrs->GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pPerAxisItem = rInAttrs->GetItemIfSet(SCHATTR_GROUP_BARS_PER_AXIS)) { // model property is "group bars per axis", UI feature is the other way // round: "show bars side by side" - bool bCheck = ! static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + bool bCheck = ! pPerAxisItem->GetValue(); m_xCBAxisSideBySide->set_active( bCheck ); } else @@ -166,10 +164,12 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) //missing value treatment { std::vector< sal_Int32 > aMissingValueTreatments; - if( rInAttrs->GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, true, &pPoolItem) == SfxItemState::SET ) - aMissingValueTreatments = static_cast<const SfxIntegerListItem*>(pPoolItem)->GetList(); + if (const SfxIntegerListItem* pValueTreatmentsItem = rInAttrs->GetItemIfSet(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS)) + aMissingValueTreatments = pValueTreatmentsItem->GetList(); - if ( aMissingValueTreatments.size()>1 && rInAttrs->GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,true, &pPoolItem) == SfxItemState::SET) + const SfxInt32Item* pMissingValueTreatmentItem; + if ( aMissingValueTreatments.size()>1 && + (pMissingValueTreatmentItem = rInAttrs->GetItemIfSet(SCHATTR_MISSING_VALUE_TREATMENT)) ) { m_xRB_DontPaint->set_sensitive(false); m_xRB_AssumeZero->set_sensitive(false); @@ -185,7 +185,7 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) m_xRB_ContinueLine->set_sensitive(true); } - tools::Long nVal=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + tools::Long nVal=pMissingValueTreatmentItem->GetValue(); if(nVal==css::chart::MissingValueTreatment::LEAVE_GAP) m_xRB_DontPaint->set_active(true); else if(nVal==css::chart::MissingValueTreatment::USE_ZERO) @@ -200,9 +200,9 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) } // Include hidden cells - if (rInAttrs->GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pHiddenCellsItem = rInAttrs->GetItemIfSet(SCHATTR_INCLUDE_HIDDEN_CELLS)) { - bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + bool bVal = pHiddenCellsItem->GetValue(); m_xCBIncludeHiddenCells->set_active(bVal); } else @@ -215,9 +215,9 @@ void SchOptionTabPage::Reset(const SfxItemSet* rInAttrs) m_xGrpPlotOptions->hide(); } - if (rInAttrs->GetItemState(SCHATTR_HIDE_LEGEND_ENTRY, true, &pPoolItem) == SfxItemState::SET) + if (const SfxBoolItem* pEntryItem = rInAttrs->GetItemIfSet(SCHATTR_HIDE_LEGEND_ENTRY)) { - bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + bool bVal = pEntryItem->GetValue(); m_xCBHideLegendEntry->set_active(bVal); } diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx index 6b163f3c8815..48001d4fb7b8 100644 --- a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx @@ -24,7 +24,6 @@ namespace weld { class CheckButton; class MetricSpinButton; class RadioButton; - class ToggleButton; class Widget; } diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx b/chart2/source/controller/dialogs/tp_TitleRotation.cxx index 8ff1c926d091..11a3795fb3cd 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.cxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx @@ -24,7 +24,6 @@ #include <editeng/eeitem.hxx> #include <editeng/frmdiritem.hxx> -#include <svl/intitem.hxx> #include <svx/sdangitm.hxx> namespace chart @@ -32,15 +31,14 @@ namespace chart SchAlignmentTabPage::SchAlignmentTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs, bool bWithRotation) - : SfxTabPage(pPage, pController, "modules/schart/ui/titlerotationtabpage.ui", "TitleRotationTabPage", &rInAttrs) - , m_xFtRotate(m_xBuilder->weld_label("degreeL")) - , m_xNfRotate(m_xBuilder->weld_metric_spin_button("OrientDegree", FieldUnit::DEGREE)) - , m_xCbStacked(m_xBuilder->weld_check_button("stackedCB")) - , m_xFtTextDirection(m_xBuilder->weld_label("textdirL")) - , m_xFtABCD(m_xBuilder->weld_label("labelABCD")) - , m_xLbTextDirection(new TextDirectionListBox(m_xBuilder->weld_combo_box("textdirLB"))) + : SfxTabPage(pPage, pController, u"modules/schart/ui/titlerotationtabpage.ui"_ustr, u"TitleRotationTabPage"_ustr, &rInAttrs) + , m_xFtRotate(m_xBuilder->weld_label(u"degreeL"_ustr)) + , m_xNfRotate(m_xBuilder->weld_metric_spin_button(u"OrientDegree"_ustr, FieldUnit::DEGREE)) + , m_xCbStacked(m_xBuilder->weld_check_button(u"stackedCB"_ustr)) + , m_xFtABCD(m_xBuilder->weld_label(u"labelABCD"_ustr)) + , m_aLbTextDirection(m_xBuilder->weld_combo_box(u"textdirLB"_ustr)) , m_xCtrlDial(new svx::DialControl) - , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, "dialCtrl", *m_xCtrlDial)) + , m_xCtrlDialWin(new weld::CustomWeld(*m_xBuilder, u"dialCtrl"_ustr, *m_xCtrlDial)) { m_xCtrlDial->SetLinkedField(m_xNfRotate.get()); m_xCtrlDial->SetText(m_xFtABCD->get_label()); @@ -73,7 +71,6 @@ SchAlignmentTabPage::~SchAlignmentTabPage() { m_xCtrlDialWin.reset(); m_xCtrlDial.reset(); - m_xLbTextDirection.reset(); } std::unique_ptr<SfxTabPage> SchAlignmentTabPage::Create(weld::Container* pPage, weld::DialogController* pController, @@ -97,7 +94,7 @@ bool SchAlignmentTabPage::FillItemSet(SfxItemSet* rOutAttrs) Degree100 nDegrees = bStacked ? 0_deg100 : m_xCtrlDial->GetRotation(); rOutAttrs->Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, nDegrees ) ); - SvxFrameDirection aDirection( m_xLbTextDirection->get_active_id() ); + SvxFrameDirection aDirection( m_aLbTextDirection.get_active_id() ); rOutAttrs->Put( SvxFrameDirectionItem( aDirection, EE_PARA_WRITINGDIR ) ); return true; @@ -115,8 +112,8 @@ void SchAlignmentTabPage::Reset(const SfxItemSet* rInAttrs) m_xCbStacked->set_active(bStacked); StackedToggleHdl(*m_xCbStacked); - if( rInAttrs->GetItemState(EE_PARA_WRITINGDIR, true, &pItem) == SfxItemState::SET) - m_xLbTextDirection->set_active_id(static_cast<const SvxFrameDirectionItem*>(pItem)->GetValue()); + if( const SvxFrameDirectionItem* pDirectionItem = rInAttrs->GetItemIfSet(EE_PARA_WRITINGDIR) ) + m_aLbTextDirection.set_active_id(pDirectionItem->GetValue()); } } //namespace chart diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.hxx b/chart2/source/controller/dialogs/tp_TitleRotation.hxx index b303e4d3596c..559212ddf293 100644 --- a/chart2/source/controller/dialogs/tp_TitleRotation.hxx +++ b/chart2/source/controller/dialogs/tp_TitleRotation.hxx @@ -20,14 +20,12 @@ #include <sfx2/tabdlg.hxx> #include <svx/dialcontrol.hxx> +#include <TextDirectionListBox.hxx> -namespace chart { class TextDirectionListBox; } namespace weld { class CheckButton; class CustomWeld; class Label; - class SpinButton; - class ToggleButton; } namespace chart @@ -39,9 +37,8 @@ private: std::unique_ptr<weld::Label> m_xFtRotate; std::unique_ptr<weld::MetricSpinButton> m_xNfRotate; std::unique_ptr<weld::CheckButton> m_xCbStacked; - std::unique_ptr<weld::Label> m_xFtTextDirection; std::unique_ptr<weld::Label> m_xFtABCD; - std::unique_ptr<TextDirectionListBox> m_xLbTextDirection; + TextDirectionListBox m_aLbTextDirection; std::unique_ptr<svx::DialControl> m_xCtrlDial; std::unique_ptr<weld::CustomWeld> m_xCtrlDialWin; diff --git a/chart2/source/controller/dialogs/tp_Trendline.cxx b/chart2/source/controller/dialogs/tp_Trendline.cxx index fe25959bdd51..cace8a073b87 100644 --- a/chart2/source/controller/dialogs/tp_Trendline.cxx +++ b/chart2/source/controller/dialogs/tp_Trendline.cxx @@ -23,7 +23,7 @@ namespace chart { TrendlineTabPage::TrendlineTabPage(weld::Container* pPage, weld::DialogController* pController, const SfxItemSet& rInAttrs) - : SfxTabPage(pPage, pController, "modules/schart/ui/tp_Trendline.ui", "TP_TRENDLINE", &rInAttrs) + : SfxTabPage(pPage, pController, u"modules/schart/ui/tp_Trendline.ui"_ustr, u"TP_TRENDLINE"_ustr, &rInAttrs) , m_aTrendlineResources(*m_xBuilder, rInAttrs) { } diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx index f99fd203b231..480bf3fe20b6 100644 --- a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx @@ -20,11 +20,11 @@ #include "tp_Wizard_TitlesAndObjects.hxx" #include <res_Titles.hxx> #include <res_LegendPosition.hxx> -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <Diagram.hxx> #include <AxisHelper.hxx> #include <ControllerLockGuard.hxx> -#include <com/sun/star/frame/XModel.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <utility> namespace chart { @@ -32,18 +32,18 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; TitlesAndObjectsTabPage::TitlesAndObjectsTabPage(weld::Container* pPage, weld::DialogController* pController, - const uno::Reference< XChartDocument >& xChartModel, + rtl::Reference<::chart::ChartModel> xChartModel, const uno::Reference< uno::XComponentContext >& xContext ) - : OWizardPage(pPage, pController, "modules/schart/ui/wizelementspage.ui", "WizElementsPage") + : OWizardPage(pPage, pController, u"modules/schart/ui/wizelementspage.ui"_ustr, u"WizElementsPage"_ustr) , m_xTitleResources(new TitleResources(*m_xBuilder, false)) , m_xLegendPositionResources(new LegendPositionResources(*m_xBuilder, xContext)) - , m_xChartModel(xChartModel) + , m_xChartModel(std::move(xChartModel)) , m_xCC(xContext) , m_bCommitToModel(true) , m_aTimerTriggeredControllerLock( m_xChartModel ) - , m_xCB_Grid_X(m_xBuilder->weld_check_button("x")) - , m_xCB_Grid_Y(m_xBuilder->weld_check_button("y")) - , m_xCB_Grid_Z(m_xBuilder->weld_check_button("z")) + , m_xCB_Grid_X(m_xBuilder->weld_check_button(u"x"_ustr)) + , m_xCB_Grid_Y(m_xBuilder->weld_check_button(u"y"_ustr)) + , m_xCB_Grid_Z(m_xBuilder->weld_check_button(u"z"_ustr)) { m_xTitleResources->connect_changed( LINK( this, TitlesAndObjectsTabPage, ChangeEditHdl )); m_xLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); @@ -75,7 +75,7 @@ void TitlesAndObjectsTabPage::initializePage() //init grid checkboxes { - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel ); + rtl::Reference< Diagram > xDiagram = m_xChartModel->getFirstChartDiagram(); uno::Sequence< sal_Bool > aPossibilityList; uno::Sequence< sal_Bool > aExistenceList; AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, false ); @@ -101,7 +101,7 @@ bool TitlesAndObjectsTabPage::commitPage( ::vcl::WizardTypes::CommitPageReason / void TitlesAndObjectsTabPage::commitToModel() { m_aTimerTriggeredControllerLock.startTimer(); - uno::Reference< frame::XModel > xModel = m_xChartModel; + rtl::Reference<::chart::ChartModel> xModel = m_xChartModel; ControllerLockGuardUNO aLockedControllers( xModel ); @@ -120,13 +120,14 @@ void TitlesAndObjectsTabPage::commitToModel() //commit grid changes to model { - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); uno::Sequence< sal_Bool > aOldExistenceList; AxisHelper::getAxisOrGridExistence( aOldExistenceList, xDiagram, false ); uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList); - aNewExistenceList[0] = m_xCB_Grid_X->get_active(); - aNewExistenceList[1] = m_xCB_Grid_Y->get_active(); - aNewExistenceList[2] = m_xCB_Grid_Z->get_active(); + sal_Bool* pNewExistenceList = aNewExistenceList.getArray(); + pNewExistenceList[0] = m_xCB_Grid_X->get_active(); + pNewExistenceList[1] = m_xCB_Grid_Y->get_active(); + pNewExistenceList[2] = m_xCB_Grid_Z->get_active(); AxisHelper::changeVisibilityOfGrids( xDiagram , aOldExistenceList, aNewExistenceList ); } diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx index b31231633a21..c63c885d1d4e 100644 --- a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx @@ -22,22 +22,23 @@ #include <TimerTriggeredControllerLock.hxx> #include <vcl/wizardmachine.hxx> +#include <rtl/ref.hxx> #include <memory> namespace chart { class LegendPositionResources; } namespace chart { class TitleResources; } -namespace com::sun::star::chart2 { class XChartDocument; } namespace com::sun::star::uno { class XComponentContext; } namespace chart { +class ChartModel; class TitlesAndObjectsTabPage final : public vcl::OWizardPage { public: TitlesAndObjectsTabPage(weld::Container* pPage, weld::DialogController* pController, - const css::uno::Reference< css::chart2::XChartDocument >& xChartModel, + rtl::Reference<::chart::ChartModel> xChartModel, const css::uno::Reference< css::uno::XComponentContext >& xContext); virtual ~TitlesAndObjectsTabPage() override; @@ -54,7 +55,7 @@ private: std::unique_ptr< TitleResources > m_xTitleResources; std::unique_ptr< LegendPositionResources > m_xLegendPositionResources; - css::uno::Reference< css::chart2::XChartDocument > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; css::uno::Reference< css::uno::XComponentContext> m_xCC; bool m_bCommitToModel; diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx index 66769a1dee91..74be51a5ee11 100644 --- a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -19,9 +19,11 @@ #include <DrawViewWrapper.hxx> #include <chartview/DrawModelWrapper.hxx> -#include <ConfigurationAccess.hxx> #include <unotools/lingucfg.hxx> +#include <unotools/syslocale.hxx> +#include <unotools/localedatawrapper.hxx> +#include <editeng/eeitem.hxx> #include <editeng/langitem.hxx> #include <svl/intitem.hxx> #include <svl/itempool.hxx> @@ -31,13 +33,15 @@ #include <svx/svdetc.hxx> #include <svx/svdoutl.hxx> #include <svx/svxids.hrc> -#include <svx/unoshape.hxx> #include <editeng/fhgtitem.hxx> +#include <osl/diagnose.h> -#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/drawing/XShape.hpp> #include <sfx2/objsh.hxx> +#include <sfx2/viewsh.hxx> #include <svx/helperhittest3d.hxx> +#include <officecfg/Office/Calc.hxx> using namespace ::com::sun::star; @@ -77,7 +81,6 @@ DrawViewWrapper::DrawViewWrapper( { SetBufferedOutputAllowed(true); SetBufferedOverlayAllowed(true); - SetPagePaintingAllowed(true); // #i12587# support for shapes in chart SdrOutliner* pOutliner = getOutliner(); @@ -87,12 +90,12 @@ DrawViewWrapper::DrawViewWrapper( SvtLinguConfig aLinguConfig; SvtLinguOptions aLinguOptions; aLinguConfig.GetOptions( aLinguOptions ); - pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage, EE_CHAR_LANGUAGE ) ); - pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) ); - pOutlinerPool->SetPoolDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) ); + pOutlinerPool->SetUserDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage, EE_CHAR_LANGUAGE ) ); + pOutlinerPool->SetUserDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CJK, EE_CHAR_LANGUAGE_CJK ) ); + pOutlinerPool->SetUserDefaultItem( SvxLanguageItem( aLinguOptions.nDefaultLanguage_CTL, EE_CHAR_LANGUAGE_CTL ) ); // set font height without changing SdrEngineDefaults - pOutlinerPool->SetPoolDefaultItem( SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT ) ); // 12pt + pOutlinerPool->SetUserDefaultItem( SvxFontHeightItem( 423, 100, EE_CHAR_FONTHEIGHT ) ); // 12pt } // #i121463# Use big handles by default @@ -120,7 +123,7 @@ void DrawViewWrapper::ReInit() tools::Rectangle aRect(Point(0,0), aOutputSize); SetWorkArea(aRect); - ShowSdrPage(GetModel()->GetPage(0)); + ShowSdrPage(GetModel().GetPage(0)); } DrawViewWrapper::~DrawViewWrapper() @@ -166,7 +169,7 @@ SdrObject* DrawViewWrapper::getHitObject( const Point& rPnt ) const //3d objects need a special treatment //because the simple PickObj method is not accurate in this case for performance reasons - E3dObject* pE3d = dynamic_cast< E3dObject* >(pRet); + E3dObject* pE3d = DynCastE3dObject(pRet); if( pE3d ) { E3dScene* pScene(pE3d->getRootE3dSceneFromE3dObject()); @@ -209,10 +212,23 @@ void DrawViewWrapper::setMarkHandleProvider( MarkHandleProvider* pMarkHandleProv void DrawViewWrapper::CompleteRedraw(OutputDevice* pOut, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* /* pRedirector */) { - svtools::ColorConfig aColorConfig; - Color aFillColor( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor ); + Color aFillColor; + if (const SfxViewShell* pViewShell = SfxViewShell::Current()) + aFillColor = pViewShell->GetColorConfigColor(svtools::DOCCOLOR); + else + { + svtools::ColorConfig aColorConfig; + aFillColor = aColorConfig.GetColorValue(svtools::DOCCOLOR).nColor; + } SetApplicationBackgroundColor(aFillColor); + + SdrOutliner& rOutliner = GetModel().GetDrawOutliner(); + Color aOldBackColor = rOutliner.GetBackgroundColor(); + rOutliner.SetBackgroundColor(aFillColor); + E3dView::CompleteRedraw( pOut, rReg ); + + rOutliner.SetBackgroundColor(aOldBackColor); } SdrObject* DrawViewWrapper::getSelectedObject() const @@ -253,16 +269,24 @@ SdrOutliner* DrawViewWrapper::getOutliner() const SfxItemSet DrawViewWrapper::getPositionAndSizeItemSetFromMarkedObject() const { + SvtSysLocale aSysLocale; + MeasurementSystem eSys = aSysLocale.GetLocaleData().getMeasurementSystemEnum(); + sal_uInt16 nAttrMetric; + if( eSys == MeasurementSystem::Metric ) + nAttrMetric = officecfg::Office::Calc::Layout::Other::MeasureUnit::Metric::get(); + else + nAttrMetric = officecfg::Office::Calc::Layout::Other::MeasureUnit::NonMetric::get(); + SfxItemSet aFullSet( - GetModel()->GetItemPool(), + GetModel().GetItemPool(), svl::Items< SDRATTR_CORNER_RADIUS, SDRATTR_CORNER_RADIUS, SID_ATTR_TRANSFORM_POS_X, SID_ATTR_TRANSFORM_ANGLE, SID_ATTR_TRANSFORM_PROTECT_POS, SID_ATTR_TRANSFORM_AUTOHEIGHT, - SID_ATTR_METRIC, SID_ATTR_METRIC>{}); + SID_ATTR_METRIC, SID_ATTR_METRIC>); SfxItemSet aGeoSet( E3dView::GetGeoAttrFromMarked() ); aFullSet.Put( aGeoSet ); - aFullSet.Put( SfxUInt16Item(SID_ATTR_METRIC,static_cast< sal_uInt16 >( ConfigurationAccess::getFieldUnit()))); + aFullSet.Put( SfxUInt16Item(SID_ATTR_METRIC, nAttrMetric) ); return aFullSet; } @@ -283,7 +307,7 @@ bool DrawViewWrapper::IsObjectHit( SdrObject const * pObj, const Point& rPnt ) if(pObj) { tools::Rectangle aRect(pObj->GetCurrentBoundRect()); - return aRect.IsInside(rPnt); + return aRect.Contains(rPnt); } return false; } @@ -291,8 +315,8 @@ bool DrawViewWrapper::IsObjectHit( SdrObject const * pObj, const Point& rPnt ) void DrawViewWrapper::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) { //prevent wrong reselection of objects - SdrModel* pSdrModel( GetModel() ); - if( pSdrModel && pSdrModel->isLocked() ) + SdrModel& rSdrModel = GetModel(); + if (rSdrModel.isLocked()) return; const SdrHint* pSdrHint = ( rHint.GetId() == SfxHintId::ThisIsAnSdrHint ? static_cast<const SdrHint*>(&rHint) : nullptr ); diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx index 2f037e767f18..51b163d1fccd 100644 --- a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx +++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx @@ -26,14 +26,13 @@ #include <com/sun/star/drawing/Direction3D.hpp> #include <o3tl/safeint.hxx> #include <svx/xtable.hxx> -#include <svl/itempool.hxx> #include <svtools/ctrltool.hxx> #include <vcl/svapp.hxx> #include <svx/svdobj.hxx> #include <vcl/virdev.hxx> #include <svx/svdview.hxx> #include <svx/svdpage.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -110,20 +109,16 @@ SdrObjList* ViewElementListProvider::GetSymbolList() const { //@todo use mutex - //get shape factory - uno::Reference<lang::XMultiServiceFactory> xShapeFactory( - m_pDrawModelWrapper->getShapeFactory()); - //get hidden draw page (target): - uno::Reference<drawing::XShapes> xTarget = m_pDrawModelWrapper->getHiddenDrawPage(); + rtl::Reference<SvxDrawPage> xTarget = m_pDrawModelWrapper->getHiddenDrawPage(); //create symbols via uno and convert to native sdr objects drawing::Direction3D aSymbolSize(220, 220, 0); // should be 250, but 250 -> 280 ?? - uno::Reference<drawing::XShapes> xSymbols - = DataPointSymbolSupplier::create2DSymbolList(xShapeFactory, xTarget, aSymbolSize); + rtl::Reference< SvxShapeGroup > xSymbols + = DataPointSymbolSupplier::create2DSymbolList(xTarget, aSymbolSize); SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( - uno::Reference<drawing::XShape>(xSymbols, uno::UNO_QUERY)); + uno::Reference<drawing::XShape>(static_cast<cppu::OWeakObject*>(xSymbols.get()), uno::UNO_QUERY)); if (pSdrObject) pSymbolList = pSdrObject->GetSubList(); } @@ -143,7 +138,7 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co nStandardSymbol*=-1; if( o3tl::make_unsigned(nStandardSymbol) >= pSymbolList->GetObjCount() ) nStandardSymbol %= pSymbolList->GetObjCount(); - SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol); + rtl::Reference<SdrObject> pObj = pSymbolList->GetObj(nStandardSymbol); ScopedVclPtrInstance< VirtualDevice > pVDev; pVDev->SetMapMode(MapMode(MapUnit::Map100thMM)); @@ -151,7 +146,6 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co std::unique_ptr<SdrModel> pModel( new SdrModel()); - pModel->GetItemPool().FreezeIdRanges(); rtl::Reference<SdrPage> pPage = new SdrPage( *pModel, false ); pPage->SetSize(Size(1000,1000)); pModel->InsertPage( pPage.get(), 0 ); @@ -162,8 +156,8 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co // directly clone to target SdrModel pObj = pObj->CloneSdrObject(*pModel); - pPage->NbcInsertObject(pObj); - aView.MarkObj(pObj,pPageView); + pPage->NbcInsertObject(pObj.get()); + aView.MarkObj(pObj.get(),pPageView); if( pSymbolShapeProperties ) pObj->SetMergedItemSet(*pSymbolShapeProperties); @@ -176,7 +170,9 @@ Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, co aView.UnmarkAll(); pObj=pPage->RemoveObject(0); - SdrObject::Free( pObj ); + // these need to die before the associated SdrModel + pObj.clear(); + pPage.clear(); return aGraph; } diff --git a/chart2/source/controller/inc/AccessibleBase.hxx b/chart2/source/controller/inc/AccessibleBase.hxx index 88f4ef79ffb2..011bdfa48b88 100644 --- a/chart2/source/controller/inc/AccessibleBase.hxx +++ b/chart2/source/controller/inc/AccessibleBase.hxx @@ -23,24 +23,18 @@ #include <com/sun/star/accessibility/XAccessible.hpp> #include <com/sun/star/accessibility/XAccessibleContext.hpp> #include <com/sun/star/accessibility/XAccessibleComponent.hpp> -#include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XEventListener.hpp> -#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> -#include <comphelper/accessibleeventnotifier.hxx> +#include <comphelper/OAccessible.hxx> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> -#include <rtl/ref.hxx> #include <tools/color.hxx> +#include <unotools/weakref.hxx> +#include <vcl/window.hxx> #include <map> #include <vector> #include <memory> -#include <MutexContainer.hxx> - namespace com::sun::star::awt { class XWindow; } -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::view { class XSelectionSupplier; } -namespace utl { class AccessibleStateSetHelper; } class SdrView; @@ -54,7 +48,9 @@ namespace chart { class AccessibleBase; +class ChartView; class ObjectHierarchy; +class ChartController; typedef ObjectIdentifier AccessibleUniqueId; @@ -62,10 +58,10 @@ struct AccessibleElementInfo { AccessibleUniqueId m_aOID; - css::uno::WeakReference< css::chart2::XChartDocument > m_xChartDocument; - css::uno::WeakReference< css::view::XSelectionSupplier > m_xSelectionSupplier; - css::uno::WeakReference< css::uno::XInterface > m_xView; - css::uno::WeakReference< css::awt::XWindow > m_xWindow; + unotools::WeakReference< ::chart::ChartModel > m_xChartDocument; + unotools::WeakReference< ::chart::ChartController > m_xChartController; + unotools::WeakReference< ::chart::ChartView > m_xView; + VclPtr<vcl::Window> m_pWindow; std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy; @@ -74,23 +70,9 @@ struct AccessibleElementInfo ::accessibility::IAccessibleViewForwarder* m_pViewForwarder; }; -namespace impl -{ -typedef ::cppu::WeakComponentImplHelper< - css::accessibility::XAccessible, - css::accessibility::XAccessibleContext, - css::accessibility::XAccessibleComponent, - css::accessibility::XAccessibleEventBroadcaster, - css::lang::XServiceInfo, - css::lang::XEventListener - > AccessibleBase_Base; -} - /** Base class for all Chart Accessibility objects */ -class AccessibleBase : - public MutexContainer, - public impl::AccessibleBase_Base +class AccessibleBase : public comphelper::OAccessible { public: enum class EventType @@ -99,7 +81,7 @@ public: LOST_SELECTION }; - AccessibleBase( const AccessibleElementInfo & rAccInfo, + AccessibleBase( AccessibleElementInfo aAccInfo, bool bMayHaveChildren, bool bAlwaysTransparent ); virtual ~AccessibleBase() override; @@ -108,14 +90,6 @@ protected: // for all calls to protected methods it is assumed that the mutex is locked // unless calls outside via UNO, e.g. event notification, are done - /** @param bThrowException if true, a DisposedException is thrown if the - object is already disposed - @return true, if the component is already disposed and bThrowException is false, - false otherwise - @throws css::lang::DisposedException - */ - bool CheckDisposeState( bool bThrowException = true ) const; - /** Events coming from the core have to be processed in this methods. The default implementation returns false, which indicates that the object is not interested in the event. To react on events you have to implement @@ -135,14 +109,14 @@ protected: @throws css::uno::RuntimeException */ - void AddState( sal_Int16 aState ); + void AddState( sal_Int64 aState ); /** Removes a state from the set if the set contains the state, otherwise nothing is done. @throws css::uno::RuntimeException */ - void RemoveState( sal_Int16 aState ); + void RemoveState( sal_Int64 aState ); /** has to be overridden by derived classes that support child elements. With this method a rescan is initiated that should result in a correct @@ -183,17 +157,6 @@ protected: */ virtual css::awt::Point GetUpperLeftOnScreen() const; - /** This method creates an AccessibleEventObject and sends it to all - listeners that are currently listening to this object - - If bSendGlobally is true, the event is also broadcast via - vcl::unohelper::NotifyAccessibleStateEventGlobally() - */ - void BroadcastAccEvent( sal_Int16 nId, - const css::uno::Any & rNew, - const css::uno::Any & rOld, - bool bSendGlobally = false ) const; - /** Removes all children from the internal lists and broadcasts child remove events. @@ -209,14 +172,14 @@ protected: @throws css::uno::RuntimeException */ virtual css::uno::Reference< css::accessibility::XAccessible > - ImplGetAccessibleChildById( sal_Int32 i ) const; + ImplGetAccessibleChildById( sal_Int64 i ) const; /** Is called from getAccessibleChildCount(). Before this method is called, an update of children is done if necessary. @throws css::uno::RuntimeException */ - virtual sal_Int32 ImplGetAccessibleChildCount() const; + virtual sal_Int64 ImplGetAccessibleChildCount() const; const AccessibleElementInfo& GetInfo() const { return m_aAccInfo;} void SetInfo( const AccessibleElementInfo & rNewInfo ); @@ -225,16 +188,13 @@ protected: // ________ WeakComponentImplHelper (XComponent::dispose) ________ virtual void SAL_CALL disposing() override; - // ________ XAccessible ________ - virtual css::uno::Reference< css::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() override; - // ________ XAccessibleContext ________ - virtual sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL - getAccessibleChild( sal_Int32 i ) override; + getAccessibleChild( sal_Int64 i ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override; - virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; /// @return AccessibleRole.SHAPE virtual sal_Int16 SAL_CALL getAccessibleRole() override; // has to be implemented by derived classes @@ -242,43 +202,22 @@ protected: // throw (css::uno::RuntimeException); virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL - getAccessibleStateSet() override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; virtual css::lang::Locale SAL_CALL getLocale() override; // has to be implemented by derived classes // virtual OUString SAL_CALL getAccessibleDescription() // throw (css::uno::RuntimeException); + // OAccessible + virtual css::awt::Rectangle implGetBounds() override; + // ________ XAccessibleComponent ________ - virtual sal_Bool SAL_CALL containsPoint( - const css::awt::Point& aPoint ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const css::awt::Point& aPoint ) override; - // has to be defined in derived classes - virtual css::awt::Rectangle SAL_CALL getBounds() override; - virtual css::awt::Point SAL_CALL getLocation() override; - virtual css::awt::Point SAL_CALL getLocationOnScreen() override; - virtual css::awt::Size SAL_CALL getSize() override; virtual void SAL_CALL grabFocus() override; virtual sal_Int32 SAL_CALL getForeground() override; virtual sal_Int32 SAL_CALL getBackground() override; - // ________ XServiceInfo ________ - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( - const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - - // ________ XEventListener ________ - virtual void SAL_CALL disposing( - const css::lang::EventObject& Source ) override; - - // ________ XAccessibleEventBroadcaster ________ - virtual void SAL_CALL addAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - virtual void SAL_CALL removeAccessibleEventListener( - const css::uno::Reference< css::accessibility::XAccessibleEventListener >& xListener ) override; - private: enum eColorType { @@ -288,28 +227,20 @@ private: Color getColor( eColorType eColType ); private: - /** type of the vector containing the accessible children - */ - typedef std::vector< css::uno::Reference< css::accessibility::XAccessible > > ChildListVectorType; /** type of the hash containing a vector index for every AccessibleUniqueId of the object in the child list */ - typedef std::map< ObjectIdentifier, css::uno::Reference< css::accessibility::XAccessible > > ChildOIDMap; + typedef std::map<ObjectIdentifier, rtl::Reference<AccessibleBase>> ChildOIDMap; - bool m_bIsDisposed; const bool m_bMayHaveChildren; bool m_bChildrenInitialized; - ChildListVectorType m_aChildList; + std::vector<rtl::Reference<AccessibleBase>> m_aChildList; ChildOIDMap m_aChildOIDMap; - ::comphelper::AccessibleEventNotifier::TClientId m_nEventNotifierId; - - /** Implementation helper for getAccessibleStateSet() - - Note: This member must come before m_aStateSet! + /** for getAccessibleStateSet() */ - rtl::Reference<::utl::AccessibleStateSetHelper> m_xStateSetHelper; + sal_Int64 m_nStateSet; AccessibleElementInfo m_aAccInfo; const bool m_bAlwaysTransparent; @@ -317,10 +248,8 @@ private: state is checked. This variable is monitored by the solar mutex! - - Note: declared volatile to enable double-check-locking */ - volatile bool m_bStateSetInitialized; + bool m_bStateSetInitialized; }; } // namespace chart diff --git a/chart2/source/controller/inc/AccessibleChartView.hxx b/chart2/source/controller/inc/AccessibleChartView.hxx index 814666e34016..9a973f80843a 100644 --- a/chart2/source/controller/inc/AccessibleChartView.hxx +++ b/chart2/source/controller/inc/AccessibleChartView.hxx @@ -19,6 +19,7 @@ #pragma once #include "AccessibleBase.hxx" +#include "ChartWindow.hxx" #include <cppuhelper/implbase.hxx> #include <cppuhelper/weakref.hxx> #include <com/sun/star/lang/XInitialization.hpp> @@ -27,9 +28,6 @@ #include <memory> namespace com::sun::star::accessibility { class XAccessible; } -namespace com::sun::star::awt { class XWindow; } -namespace com::sun::star::frame { class XModel; } -namespace com::sun::star::view { class XSelectionSupplier; } namespace accessibility { @@ -38,37 +36,32 @@ class IAccessibleViewForwarder; namespace chart { +class ChartView; -namespace impl -{ -typedef ::cppu::ImplInheritanceHelper< - ::chart::AccessibleBase, - css::lang::XInitialization, - css::view::XSelectionChangeListener > - AccessibleChartView_Base; -} - -class AccessibleChartView : - public impl::AccessibleChartView_Base +class AccessibleChartView final + : public cppu::ImplInheritanceHelper<chart::AccessibleBase, css::view::XSelectionChangeListener> { public: - AccessibleChartView(SdrView* pView ); + AccessibleChartView( SdrView* pView ); virtual ~AccessibleChartView() override; AccessibleChartView() = delete; - // ____ WeakComponentHelper (called from XComponent::dispose()) ____ - using AccessibleBase::disposing; + virtual void SAL_CALL disposing() override; - // ____ lang::XInitialization ____ // 0: view::XSelectionSupplier offers notifications for selection changes and access to the selection itself // 1: frame::XModel representing the chart model - offers access to object data // 2: lang::XInterface representing the normal chart view - offers access to some extra object data // 3: accessibility::XAccessible representing the parent accessible - // 4: awt::XWindow representing the view's window (is a vcl Window) + // 4: ChartWindow representing the view's window // all arguments are only valid until next initialization - don't keep them longer - virtual void SAL_CALL initialize( - const css::uno::Sequence< css::uno::Any >& aArguments ) override; + void initialize( ChartController& rChartController, + const rtl::Reference<::chart::ChartModel>& xChartModel, + const rtl::Reference<::chart::ChartView>& xChartView, + const css::uno::Reference< css::accessibility::XAccessible >& xParent, + ChartWindow* pNewChartWindow); + // used to disconnect from view + void initialize(); // ____ view::XSelectionChangeListener ____ virtual void SAL_CALL selectionChanged( const css::lang::EventObject& aEvent ) override; @@ -79,13 +72,12 @@ public: // ________ XAccessibleContext ________ virtual OUString SAL_CALL getAccessibleDescription() override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override; - virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; virtual OUString SAL_CALL getAccessibleName() override; virtual sal_Int16 SAL_CALL getAccessibleRole() override; - // ________ XAccessibleComponent ________ - virtual css::awt::Rectangle SAL_CALL getBounds() override; - virtual css::awt::Point SAL_CALL getLocationOnScreen() override; + // OAccessible + virtual css::awt::Rectangle implGetBounds() override; protected: // ________ AccessibleChartElement ________ @@ -101,10 +93,10 @@ private: // methods css::awt::Rectangle GetWindowPosSize() const; private: // members - css::uno::WeakReference< css::view::XSelectionSupplier > m_xSelectionSupplier; - css::uno::WeakReference< css::frame::XModel > m_xChartModel; - css::uno::WeakReference< css::uno::XInterface > m_xChartView; - css::uno::WeakReference< css::awt::XWindow > m_xWindow; + unotools::WeakReference< ::chart::ChartController > m_xChartController; + unotools::WeakReference< ::chart::ChartModel > m_xChartModel; + unotools::WeakReference< ChartView > m_xChartView; + VclPtr<ChartWindow> m_pChartWindow; css::uno::WeakReference< css::accessibility::XAccessible > m_xParent; std::shared_ptr< ObjectHierarchy > m_spObjectHierarchy; diff --git a/chart2/source/controller/inc/AccessibleTextHelper.hxx b/chart2/source/controller/inc/AccessibleTextHelper.hxx index 0a174caaf70d..ccdf1ed6bd61 100644 --- a/chart2/source/controller/inc/AccessibleTextHelper.hxx +++ b/chart2/source/controller/inc/AccessibleTextHelper.hxx @@ -18,17 +18,13 @@ */ #pragma once -#include <memory> -#include <MutexContainer.hxx> -#include <cppuhelper/compbase.hxx> -#include <com/sun/star/lang/XInitialization.hpp> +#include <comphelper/OAccessible.hxx> +#include <comphelper/compbase.hxx> +#include <svx/AccessibleTextHelper.hxx> +#include <vcl/window.hxx> #include <com/sun/star/accessibility/XAccessibleContext.hpp> +#include <com/sun/star/awt/XWindow.hpp> -// forward declaration of helper class from svx -namespace accessibility -{ -class AccessibleTextHelper; -} namespace chart { @@ -37,21 +33,18 @@ class DrawViewWrapper; namespace impl { -typedef ::cppu::WeakComponentImplHelper< - css::lang::XInitialization, +typedef comphelper::WeakComponentImplHelper< css::accessibility::XAccessibleContext > AccessibleTextHelper_Base; } -class AccessibleTextHelper : - public MutexContainer, +class AccessibleTextHelper final : public impl::AccessibleTextHelper_Base { public: explicit AccessibleTextHelper( DrawViewWrapper * pDrawViewWrapper ); virtual ~AccessibleTextHelper() override; - // ____ XInitialization ____ /** Must be called at least once for this helper class to work. mandatory parameter 0: type string. This is the CID that is used to find @@ -61,27 +54,28 @@ public: mandatory parameter 1: type XAccessible. Is used as EventSource for the ::accessibility::AccessibleTextHelper (svx) - mandatory parameter 2: type awt::XWindow. The Window that shows the + mandatory parameter 2: type vcl::Window. The Window that shows the text currently. */ - virtual void SAL_CALL initialize( - const css::uno::Sequence< css::uno::Any >& aArguments ) override; + void initialize(const OUString& aCID, + const rtl::Reference<comphelper::OAccessible>& rEventSource, + vcl::Window* pWindow); // ____ XAccessibleContext ____ - virtual ::sal_Int32 SAL_CALL getAccessibleChildCount() override; + virtual sal_Int64 SAL_CALL getAccessibleChildCount() override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleChild( - ::sal_Int32 i ) override; + sal_Int64 i ) override; virtual css::uno::Reference< css::accessibility::XAccessible > SAL_CALL getAccessibleParent() override; - virtual ::sal_Int32 SAL_CALL getAccessibleIndexInParent() override; + virtual sal_Int64 SAL_CALL getAccessibleIndexInParent() override; virtual ::sal_Int16 SAL_CALL getAccessibleRole() override; virtual OUString SAL_CALL getAccessibleDescription() override; virtual OUString SAL_CALL getAccessibleName() override; virtual css::uno::Reference< css::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() override; - virtual css::uno::Reference< css::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() override; + virtual sal_Int64 SAL_CALL getAccessibleStateSet() override; virtual css::lang::Locale SAL_CALL getLocale() override; private: - std::unique_ptr<::accessibility::AccessibleTextHelper> m_pTextHelper; + std::optional<::accessibility::AccessibleTextHelper> m_oTextHelper; DrawViewWrapper * m_pDrawViewWrapper; }; diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx index 7f42853d1088..c14ef82bd595 100644 --- a/chart2/source/controller/inc/AxisItemConverter.hxx +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -19,30 +19,34 @@ #pragma once #include "ItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::beans { class XPropertySet; } namespace com::sun::star::chart2 { class XAxis; } namespace com::sun::star::chart2 { class XChartDocument; } +namespace chart { class Axis; } namespace chart { struct ExplicitIncrementData; } namespace chart { struct ExplicitScaleData; } +namespace chart { class ChartModel; } class SdrModel; namespace chart::wrapper { -class AxisItemConverter : public ItemConverter +class AxisItemConverter final : public ItemConverter { public: AxisItemConverter( const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference<css::chart2::XChartDocument> & xChartDoc, + const rtl::Reference<::chart::ChartModel> & xChartDoc, ExplicitScaleData const * pScale, ExplicitIncrementData const * pIncrement, - const css::awt::Size* pRefSize ); + const std::optional<css::awt::Size>& pRefSize ); virtual ~AxisItemConverter() override; @@ -50,7 +54,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; @@ -58,11 +62,9 @@ protected: private: std::vector< std::unique_ptr<ItemConverter> > m_aConverters; - css::uno::Reference< - css::chart2::XAxis > m_xAxis; + rtl::Reference<::chart::Axis> m_xAxis; - css::uno::Reference< - css::chart2::XChartDocument > m_xChartDoc; + rtl::Reference<::chart::ChartModel>m_xChartDoc; std::unique_ptr<ExplicitScaleData> m_pExplicitScale; std::unique_ptr<ExplicitIncrementData> m_pExplicitIncrement; diff --git a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx index 4322c8c391fd..65ff58ea45ab 100644 --- a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx @@ -35,14 +35,14 @@ public: CharacterPropertyItemConverter( const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, - const css::awt::Size* pRefSize, - const OUString & rRefSizePropertyName, + const std::optional<css::awt::Size>& pRefSize, + OUString aRefSizePropertyName, const css::uno::Reference<css::beans::XPropertySet>& rRefSizePropSet = css::uno::Reference<css::beans::XPropertySet>() ); virtual ~CharacterPropertyItemConverter() override; private: - virtual const sal_uInt16* GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) override; diff --git a/chart2/source/controller/inc/ChartController.hxx b/chart2/source/controller/inc/ChartController.hxx index 09fda2b6fb00..e86438675e8e 100644 --- a/chart2/source/controller/inc/ChartController.hxx +++ b/chart2/source/controller/inc/ChartController.hxx @@ -19,6 +19,8 @@ #pragma once #include <LifeTime.hxx> +#include <ReferenceSizeProvider.hxx> +#include "AccessibleChartView.hxx" #include "CommandDispatchContainer.hxx" #include "SelectionHelper.hxx" @@ -34,16 +36,14 @@ #include <com/sun/star/util/XModeChangeListener.hpp> #include <com/sun/star/util/XCloseListener.hpp> #include <com/sun/star/util/XModifyListener.hpp> -#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XController2.hpp> #include <com/sun/star/frame/XLayoutManagerListener.hpp> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <memory> #include <string_view> namespace com::sun::star::accessibility { class XAccessible; } -namespace com::sun::star::accessibility { class XAccessibleContext; } namespace com::sun::star::awt { class XFocusListener; } namespace com::sun::star::awt { class XKeyListener; } namespace com::sun::star::awt { class XMouseListener; } @@ -56,12 +56,9 @@ namespace com::sun::star::document { class XUndoManager; } namespace com::sun::star::frame { class XDispatch; } namespace com::sun::star::frame { class XLayoutManagerEventBroadcaster; } namespace com::sun::star::graphic { class XGraphic; } -namespace com::sun::star::lang { class XInitialization; } namespace com::sun::star::uno { class XComponentContext; } -namespace com::sun::star::util { class XCloseable; } namespace com::sun::star::view { class XSelectionSupplier; } - class SdrModel; namespace svt @@ -83,25 +80,25 @@ namespace chart { class UndoGuard; +class ChartView; class ChartWindow; class DrawModelWrapper; class DrawViewWrapper; -class ReferenceSizeProvider; class ViewElementListProvider; +class Diagram; +class AccessibleTextHelper; enum ChartDrawMode { CHARTDRAW_INSERT, CHARTDRAW_SELECT }; -class ChartController : public ::cppu::WeakImplHelper < - css::frame::XController //comprehends XComponent (required interface) +class ChartController final : public ::cppu::WeakImplHelper < + css::frame::XController2 //comprehends XComponent (css::frame::XController is required interface) ,css::frame::XDispatchProvider //(required interface) ,css::view::XSelectionSupplier //(optional interface) ,css::ui::XContextMenuInterception //(optional interface) ,css::util::XCloseListener //(needed for communication with XModel) - ,css::lang::XServiceInfo ,css::frame::XDispatch ,css::awt::XWindow //this is the Window Controller part of this Controller, that will be given to a Frame via setComponent - ,css::lang::XMultiServiceFactory ,css::util::XModifyListener ,css::util::XModeChangeListener ,css::frame::XLayoutManagerListener @@ -109,16 +106,11 @@ class ChartController : public ::cppu::WeakImplHelper < { public: ChartController() = delete; - explicit ChartController(css::uno::Reference< css::uno::XComponentContext > const & xContext); + explicit ChartController(css::uno::Reference< css::uno::XComponentContext > xContext); virtual ~ChartController() override; OUString GetContextName(); - // css::lang::XServiceInfo - virtual OUString SAL_CALL getImplementationName() override; - virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override; - virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override; - // css::frame::XController (required interface) virtual void SAL_CALL attachFrame( const css::uno::Reference< css::frame::XFrame > & xFrame ) override; @@ -141,6 +133,12 @@ public: virtual sal_Bool SAL_CALL suspend( sal_Bool bSuspend ) override; + // css::frame::XController2 + virtual css::uno::Reference<css::awt::XWindow> SAL_CALL getComponentWindow() override; + virtual OUString SAL_CALL getViewControllerName() override; + virtual css::uno::Sequence<css::beans::PropertyValue> SAL_CALL getCreationArguments() override; + virtual css::uno::Reference<css::ui::XSidebarProvider> SAL_CALL getSidebar() override; + // css::lang::XComponent (base of XController) virtual void SAL_CALL dispose() override; @@ -261,16 +259,6 @@ public: virtual void SAL_CALL removePaintListener( const css::uno::Reference< css::awt::XPaintListener >& xListener ) override; - // css::lang XMultiServiceFactory - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstance( const OUString& aServiceSpecifier ) override; - virtual css::uno::Reference< css::uno::XInterface > SAL_CALL - createInstanceWithArguments( const OUString& ServiceSpecifier, - const css::uno::Sequence< - css::uno::Any >& Arguments ) override; - virtual css::uno::Sequence< OUString > SAL_CALL - getAvailableServiceNames() override; - // css::util::XModifyListener virtual void SAL_CALL modified( const css::lang::EventObject& aEvent ) override; @@ -315,13 +303,23 @@ public: ::Point aAtLogicPosition, bool bIsBalloonHelp, OUString & rOutQuickHelpText, css::awt::Rectangle & rOutEqualRect ); - css::uno::Reference< css::accessibility::XAccessible > CreateAccessible(); + rtl::Reference<AccessibleChartView> CreateAccessible(); + + /** Creates a helper accessibility class that must be initialized via initialize(). For + parameters see + + The returned object should not be used directly. Instead a proxy object + should use this helper to retrieve its children and add them to its own + children. + */ + rtl::Reference< ::chart::AccessibleTextHelper > createAccessibleTextContext(); static bool isObjectDeleteable( const css::uno::Any& rSelection ); void setDrawMode( ChartDrawMode eMode ) { m_eDrawMode = eMode; } bool isShapeContext() const; + bool IsTextEdit() const; ViewElementListProvider getViewElementListProvider(); DrawModelWrapper* GetDrawModelWrapper(); @@ -334,26 +332,29 @@ public: void NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> ); - css::uno::Reference<css::uno::XInterface> const & getChartView() const; + rtl::Reference<::chart::ChartView> const & getChartView() const { return m_xChartView; } + + rtl::Reference<::chart::ChartModel> getChartModel(); + rtl::Reference<::chart::Diagram> getFirstDiagram(); + + Selection getSelectionMember() { return m_aSelection; } private: class TheModel : public salhelper::SimpleReferenceObject { public: - explicit TheModel( const css::uno::Reference< - css::frame::XModel > & xModel ); + explicit TheModel( rtl::Reference<::chart::ChartModel> xModel ); virtual ~TheModel() override; void addListener( ChartController* pController ); void removeListener( ChartController* pController ); void tryTermination(); - const css::uno::Reference< css::frame::XModel >& + const rtl::Reference<::chart::ChartModel>& getModel() const { return m_xModel;} private: - css::uno::Reference< css::frame::XModel > m_xModel; - css::uno::Reference< css::util::XCloseable > m_xCloseable; + rtl::Reference<::chart::ChartModel> m_xModel; //the ownership between model and controller is not clear at first //each controller might consider himself as owner of the model first @@ -387,7 +388,7 @@ private: //view css::uno::Reference<css::awt::XWindow> m_xViewWindow; - css::uno::Reference<css::uno::XInterface> m_xChartView; + rtl::Reference<::chart::ChartView> m_xChartView; std::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper; std::unique_ptr<DrawViewWrapper> m_pDrawViewWrapper; @@ -418,7 +419,7 @@ private: rtl::Reference<svx::sidebar::SelectionChangeHandler> mpSelectionChangeHandler; bool impl_isDisposedOrSuspended() const; - std::unique_ptr<ReferenceSizeProvider> impl_createReferenceSizeProvider(); + ReferenceSizeProvider impl_createReferenceSizeProvider(); void impl_adaptDataSeriesAutoResize(); void impl_createDrawViewController(); @@ -428,7 +429,7 @@ private: void executeDispatch_ObjectProperties(); void executeDispatch_FormatObject( std::u16string_view rDispatchCommand ); void executeDlg_ObjectProperties( const OUString& rObjectCID ); - bool executeDlg_ObjectProperties_withoutUndoGuard( const OUString& rObjectCID, bool bSuccessOnUnchanged ); + void executeDlg_ObjectProperties_withUndoGuard( std::shared_ptr<UndoGuard> aUndoGuard, const OUString& rObjectCID, bool bSuccessOnUnchanged ); void executeDispatch_ChartType(); @@ -439,6 +440,10 @@ private: void executeDispatch_InsertAxes(); void executeDispatch_InsertGrid(); + void executeDispatch_InsertDataTable(); + void executeDispatch_DeleteDataTable(); + void executeDispatch_OpenInsertDataTableDialog(); + void executeDispatch_InsertMenu_DataLabels(); void executeDispatch_InsertMenu_Trendlines(); void executeDispatch_InsertMenu_MeanValues(); @@ -478,6 +483,8 @@ private: void executeDispatch_MoveSeries( bool bForward ); bool EndTextEdit(); + css::uno::Sequence< css::uno::Reference<css::chart2::XFormattedString >> GetFormattedTitle( + const EditTextObject& aEdit, const css::uno::Reference< css::drawing::XShape >& xShape ); void executeDispatch_View3D(); void executeDispatch_PositionAndSize( const ::css::uno::Sequence< ::css::beans::PropertyValue >* pArgs = nullptr ); @@ -487,6 +494,40 @@ private: void executeDispatch_NewArrangement(); void executeDispatch_ScaleText(); + static void executeDispatch_FontBold( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontName( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + static void executeDispatch_FontHeight( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + static void executeDispatch_FontItalic( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontUnderline( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + static void executeDispatch_FontStrikeout( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontShadowed( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontColor( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + static void executeDispatch_FontGrow( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontShrink( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontReset( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontSpacing( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs); + static void executeDispatch_FontSuperScript( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + static void executeDispatch_FontSubScript( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties); + void executeDispatch_Paste(); void executeDispatch_Copy(); void executeDispatch_Cut(); @@ -498,17 +539,17 @@ private: void executeDispatch_LOKSetTextSelection(int nType, int nX, int nY); void executeDispatch_LOKPieSegmentDragging(int nOffset); void executeDispatch_FillColor(sal_uInt32 nColor); - void executeDispatch_FillGradient(OUString sJSONGradient); + void executeDispatch_FillGradient(std::u16string_view sJSONGradient); void executeDispatch_LineColor(sal_uInt32 nColor); void executeDispatch_LineWidth(sal_uInt32 nWidth); - void sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle); + void sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle); void impl_ShapeControllerDispatch( const css::util::URL& rURL, const css::uno::Sequence< css::beans::PropertyValue >& rArgs ); DECL_LINK( DoubleClickWaitingHdl, Timer*, void ); - void execute_DoubleClick( const Point* pMousePixel ); + void execute_DoubleClick( const Point* pMousePixel, bool &bEditText ); void startDoubleClickWaiting(); void stopDoubleClickWaiting(); @@ -516,7 +557,7 @@ private: void impl_notifySelectionChangeListeners(); void impl_invalidateAccessible(); void impl_initializeAccessible(); - void impl_initializeAccessible( const css::uno::Reference< css::lang::XInitialization >& xInit ); + void impl_initializeAccessible( AccessibleChartView& xInit ); //sets the model member to null if it equals the parameter //returns true if successful @@ -530,19 +571,9 @@ private: /// @return </sal_True>, if resize/move was successful bool impl_moveOrResizeObject( const OUString & rCID, eMoveOrResizeType eType, double fAmountLogicX, double fAmountLogicY ); - bool impl_DragDataPoint( const OUString & rCID, double fOffset ); - - static const o3tl::sorted_vector< OUString >& impl_getAvailableCommands(); + bool impl_DragDataPoint( std::u16string_view rCID, double fOffset ); - /** Creates a helper accessibility class that must be initialized via XInitialization. For - parameters see - - The returned object should not be used directly. Instead a proxy object - should use this helper to retrieve its children and add them to its own - children. - */ - css::uno::Reference< css::accessibility::XAccessibleContext > - impl_createAccessibleTextContext(); + static const o3tl::sorted_vector< std::u16string_view >& impl_getAvailableCommands(); void impl_PasteGraphic( css::uno::Reference< css::graphic::XGraphic > const & xGraphic, const ::Point & aPosition ); diff --git a/chart2/source/controller/inc/ChartDocumentWrapper.hxx b/chart2/source/controller/inc/ChartDocumentWrapper.hxx index 7eeb4646bfc7..5957a7e2942f 100644 --- a/chart2/source/controller/inc/ChartDocumentWrapper.hxx +++ b/chart2/source/controller/inc/ChartDocumentWrapper.hxx @@ -26,15 +26,19 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <cppuhelper/implbase.hxx> #include <unotools/eventlisteneradapter.hxx> - +#include <rtl/ref.hxx> +#include <svx/unopage.hxx> #include <memory> namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::util { class XRefreshable; } +namespace chart { class ChartView; } namespace chart::wrapper { - +class DiagramWrapper; +class LegendWrapper; +class TitleWrapper; class Chart2ModelContact; class ChartDocumentWrapper_Base : public ::cppu::ImplInheritanceHelper @@ -48,7 +52,7 @@ class ChartDocumentWrapper_Base : public ::cppu::ImplInheritanceHelper { }; -class ChartDocumentWrapper : public ChartDocumentWrapper_Base +class ChartDocumentWrapper final : public ChartDocumentWrapper_Base , public ::utl::OEventListenerAdapter { public: @@ -72,9 +76,7 @@ public: css::uno::Reference< css::drawing::XShapes > getAdditionalShapes() const; /// @throws css::uno::RuntimeException - css::uno::Reference< css::drawing::XDrawPage > impl_getDrawPage() const; - -protected: + rtl::Reference<SvxDrawPage> impl_getDrawPage() const; // ____ chart::XChartDocument ____ virtual css::uno::Reference< css::drawing::XShape > SAL_CALL getTitle() override; @@ -137,6 +139,10 @@ protected: virtual std::vector< std::unique_ptr<WrappedProperty> > createWrappedProperties() override; virtual css::uno::Reference< css::beans::XPropertySet > getInnerPropertySet() override; + // ____ XPropertySet ____ + virtual void SAL_CALL setPropertyValue(const OUString& rPropertyName, + const css::uno::Any& rValue) override; + private: //methods void impl_resetAddIn(); @@ -145,18 +151,18 @@ private: //member css::uno::Reference< css::uno::XInterface > m_xDelegator; - css::uno::Reference< css::drawing::XShape > m_xTitle; - css::uno::Reference< css::drawing::XShape > m_xSubTitle; - css::uno::Reference< css::drawing::XShape > m_xLegend; + rtl::Reference< TitleWrapper > m_xTitle; + rtl::Reference< TitleWrapper > m_xSubTitle; + rtl::Reference< LegendWrapper > m_xLegend; css::uno::Reference< css::chart::XChartData > m_xChartData; - css::uno::Reference< css::chart::XDiagram > m_xDiagram; + rtl::Reference< DiagramWrapper > m_xDiagram; css::uno::Reference< css::beans::XPropertySet > m_xArea; css::uno::Reference< css::util::XRefreshable > m_xAddIn; OUString m_aBaseDiagram; bool m_bUpdateAddIn; - css::uno::Reference< css::uno::XInterface > m_xChartView; + rtl::Reference< ChartView > m_xChartView; css::uno::Reference< css::lang::XMultiServiceFactory> m_xShapeFactory; diff --git a/chart2/source/controller/inc/ChartToolbarController.hxx b/chart2/source/controller/inc/ChartToolbarController.hxx index 647cd59a6685..ce493bba674b 100644 --- a/chart2/source/controller/inc/ChartToolbarController.hxx +++ b/chart2/source/controller/inc/ChartToolbarController.hxx @@ -9,8 +9,7 @@ #pragma once -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <com/sun/star/frame/XToolbarController.hpp> #include <com/sun/star/frame/XStatusListener.hpp> @@ -23,13 +22,12 @@ namespace com::sun::star::frame { class XFramesSupplier; } namespace chart { -typedef cppu::WeakComponentImplHelper< +typedef comphelper::WeakComponentImplHelper< css::frame::XToolbarController, css::frame::XStatusListener, css::util::XUpdatable, css::lang::XInitialization, css::lang::XServiceInfo> ChartToolbarControllerBase; -class ChartToolbarController : private cppu::BaseMutex, - public ChartToolbarControllerBase +class ChartToolbarController final : public ChartToolbarControllerBase { public: ChartToolbarController(const css::uno::Sequence<css::uno::Any>& rProperties); @@ -69,7 +67,7 @@ public: // XUpdatable virtual void SAL_CALL update() override; - using cppu::WeakComponentImplHelperBase::disposing; + using comphelper::WeakComponentImplHelperBase::disposing; private: diff --git a/chart2/source/controller/inc/ChartWindow.hxx b/chart2/source/controller/inc/ChartWindow.hxx index e7aa36d91cc8..918805cb3a8a 100644 --- a/chart2/source/controller/inc/ChartWindow.hxx +++ b/chart2/source/controller/inc/ChartWindow.hxx @@ -29,7 +29,7 @@ class ChartController; thus the controller can perform appropriate actions */ -class ChartWindow : public vcl::Window +class ChartWindow final : public vcl::Window { public: ChartWindow( ChartController* pController, vcl::Window* pParent, WinBits nStyle ); @@ -53,15 +53,8 @@ public: virtual void DataChanged( const DataChangedEvent& rDCEvt ) override; virtual void RequestHelp( const HelpEvent& rHEvt ) override; - /// For LibreOfficeKit, we need to route these to the mouse events. - virtual void LogicMouseButtonDown(const MouseEvent&) override; - virtual void LogicMouseButtonUp(const MouseEvent&) override; - virtual void LogicMouseMove(const MouseEvent&) override; - void ForceInvalidate(); - virtual void Invalidate( InvalidateFlags nFlags = InvalidateFlags::NONE ) override; - virtual void Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags = InvalidateFlags::NONE ) override; - virtual void Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags = InvalidateFlags::NONE ) override; + virtual void ImplInvalidate( const vcl::Region* rRegion, InvalidateFlags nFlags ) override; /// Notify the LOK client about an invalidated area. virtual void LogicInvalidate( const tools::Rectangle* pRectangle ) override; diff --git a/chart2/source/controller/inc/CommandDispatchContainer.hxx b/chart2/source/controller/inc/CommandDispatchContainer.hxx index 523b798c7893..a7c6111a3f4c 100644 --- a/chart2/source/controller/inc/CommandDispatchContainer.hxx +++ b/chart2/source/controller/inc/CommandDispatchContainer.hxx @@ -18,7 +18,7 @@ */ #pragma once -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> #include <o3tl/sorted_vector.hxx> #include <map> @@ -26,14 +26,13 @@ namespace com::sun::star::frame { class XController; } namespace com::sun::star::frame { class XDispatch; } -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::frame { struct DispatchDescriptor; } namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::util { struct URL; } namespace chart { - +class ChartModel; class DrawCommandDispatch; class ShapeController; @@ -73,14 +72,14 @@ public: const css::uno::Reference< css::uno::XComponentContext > & xContext ); void setModel( - const css::uno::Reference< css::frame::XModel > & xModel ); + const rtl::Reference<::chart::ChartModel> & xModel ); /** Set a chart dispatcher that is used for all commands contained in rChartCommands */ void setChartDispatch( const css::uno::Reference< css::frame::XDispatch >& rChartDispatch, - const o3tl::sorted_vector< OUString > & rChartCommands ); + const o3tl::sorted_vector< std::u16string_view > & rChartCommands ); /** Returns the dispatch that is able to do the command given in rURL, if implemented here. If the URL is not implemented here, it should be @@ -122,10 +121,10 @@ private: mutable tDisposeVector m_aToBeDisposedDispatches; css::uno::Reference< css::uno::XComponentContext > m_xContext; - css::uno::WeakReference< css::frame::XModel > m_xModel; + unotools::WeakReference< ::chart::ChartModel > m_xModel; css::uno::Reference< css::frame::XDispatch > m_xChartDispatcher; - o3tl::sorted_vector< OUString > m_aChartCommands; + o3tl::sorted_vector< std::u16string_view > m_aChartCommands; DrawCommandDispatch* m_pDrawCommandDispatch; ShapeController* m_pShapeController; diff --git a/chart2/source/controller/inc/ConfigurationAccess.hxx b/chart2/source/controller/inc/ConfigurationAccess.hxx deleted file mode 100644 index 2fb4636d2217..000000000000 --- a/chart2/source/controller/inc/ConfigurationAccess.hxx +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <tools/fldunit.hxx> - -namespace chart::ConfigurationAccess -{ -/** @descr Retrieve the FieldUnit to be used for the UI. This unit is retrieved - from the registry settings of the Calc application. - - If this setting can not be found there is a fallback to cm which is the most - common setting worldwide (or not?) - - @return the FieldUnit enum. See <vcl/fldunit.hxx> for definition - */ -FieldUnit getFieldUnit(); - -} //namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx index f2fbfdf9ca99..5d75b3057cfd 100644 --- a/chart2/source/controller/inc/DataPointItemConverter.hxx +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -20,34 +20,35 @@ #include "ItemConverter.hxx" #include "GraphicPropertyItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> #include <com/sun/star/uno/Sequence.h> #include <tools/color.hxx> - +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::chart2 { class XDataSeries; } namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } - +namespace chart { class ChartModel; } +namespace chart { class DataSeries; } class SdrModel; namespace chart::wrapper { -class DataPointItemConverter : public ItemConverter +class DataPointItemConverter final : public ItemConverter { public: DataPointItemConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, + const rtl::Reference<::chart::ChartModel>& xChartModel, const css::uno::Reference<css::uno::XComponentContext>& xContext, const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, - const css::uno::Reference<css::chart2::XDataSeries>& xSeries, + const rtl::Reference<::chart::DataSeries>& xSeries, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference<css::lang::XMultiServiceFactory>& xNamedPropertyContainerFactory, GraphicObjectType eMapTo, - const css::awt::Size* pRefSize = nullptr, + const std::optional<css::awt::Size>& pRefSize = std::nullopt, bool bDataSeries = false, bool bUseSpecialFillColor = false, sal_Int32 nSpecialFillColor = 0, @@ -62,7 +63,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; @@ -80,7 +81,7 @@ private: bool m_bForbidPercentValue; bool m_bHideLegendEntry; sal_Int32 m_nPointIndex; - css::uno::Reference<css::chart2::XDataSeries> m_xSeries; + rtl::Reference<::chart::DataSeries> m_xSeries; }; } diff --git a/chart2/source/controller/inc/DataTableItemConverter.hxx b/chart2/source/controller/inc/DataTableItemConverter.hxx new file mode 100644 index 000000000000..f3809632f8a5 --- /dev/null +++ b/chart2/source/controller/inc/DataTableItemConverter.hxx @@ -0,0 +1,56 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include "ItemConverter.hxx" +#include <rtl/ref.hxx> +#include <vector> + +namespace com::sun::star::awt +{ +struct Size; +} +namespace com::sun::star::beans +{ +class XPropertySet; +} +namespace chart +{ +class ChartModel; +} + +class SdrModel; + +namespace chart::wrapper +{ +/** Convert data table properties to and from ItemSet and UNO PropertySet */ +class DataTableItemConverter final : public ItemConverter +{ +public: + DataTableItemConverter(const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, + SfxItemPool& rItemPool, SdrModel& rDrawModel, + const rtl::Reference<::chart::ChartModel>& xChartDoc); + + virtual ~DataTableItemConverter() override; + + virtual void FillItemSet(SfxItemSet& rOutItemSet) const override; + virtual bool ApplyItemSet(const SfxItemSet& rItemSet) override; + +protected: + virtual const WhichRangesContainer& GetWhichPairs() const override; + virtual bool GetItemProperty(tWhichIdType nWhichId, + tPropertyNameWithMemberId& rOutProperty) const override; + +private: + std::vector<std::unique_ptr<ItemConverter>> m_aConverters; +}; +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/DrawViewWrapper.hxx b/chart2/source/controller/inc/DrawViewWrapper.hxx index 70a1baf40da6..28c2a927ec19 100644 --- a/chart2/source/controller/inc/DrawViewWrapper.hxx +++ b/chart2/source/controller/inc/DrawViewWrapper.hxx @@ -43,7 +43,7 @@ protected: ~MarkHandleProvider() {} }; -class DrawViewWrapper : public E3dView +class DrawViewWrapper final : public E3dView { public: DrawViewWrapper( diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx index e370ddd99fe0..50b2fbe3f73b 100644 --- a/chart2/source/controller/inc/ErrorBarItemConverter.hxx +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -20,31 +20,32 @@ #pragma once #include "ItemConverter.hxx" +#include <rtl/ref.hxx> namespace com::sun::star::frame { class XModel; } namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } namespace chart::wrapper { -class ErrorBarItemConverter : public ItemConverter +class ErrorBarItemConverter final : public ItemConverter { public: ErrorBarItemConverter( - const css::uno::Reference< css::frame::XModel > & xChartModel, + const rtl::Reference< ChartModel > & xChartModel, const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const css::uno::Reference< css::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ); + SdrModel& rDrawModel ); virtual ~ErrorBarItemConverter() override; virtual void FillItemSet( SfxItemSet & rOutItemSet ) const override; virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; diff --git a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx index fd221336b774..afb9dd0a0c40 100644 --- a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx +++ b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx @@ -20,10 +20,14 @@ #include "ItemConverter.hxx" +#include <rtl/ref.hxx> + namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } + namespace chart::wrapper { @@ -35,19 +39,19 @@ enum class GraphicObjectType LineAndFillProperties }; -class GraphicPropertyItemConverter : public ItemConverter +class GraphicPropertyItemConverter final : public ItemConverter { public: GraphicPropertyItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference< css::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + rtl::Reference< ChartModel > xChartModel, GraphicObjectType eObjectType ); virtual ~GraphicPropertyItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; @@ -56,7 +60,7 @@ protected: private: GraphicObjectType m_GraphicObjectType; SdrModel & m_rDrawModel; - css::uno::Reference< css::lang::XMultiServiceFactory > m_xNamedPropertyTableFactory; + rtl::Reference<ChartModel> m_xChartModel; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/inc/ItemConverter.hxx b/chart2/source/controller/inc/ItemConverter.hxx index 80b6c9cd2119..031a633c22d8 100644 --- a/chart2/source/controller/inc/ItemConverter.hxx +++ b/chart2/source/controller/inc/ItemConverter.hxx @@ -73,7 +73,7 @@ public: reading/writing converted items */ ItemConverter( - const css::uno::Reference< css::beans::XPropertySet > & rPropertySet , + css::uno::Reference< css::beans::XPropertySet > xPropertySet , SfxItemPool& rItemPool ); virtual ~ItemConverter() override; @@ -116,18 +116,9 @@ public: protected: - /** implement this method to provide an array of which-ranges of the form: - - const sal_uInt16 aMyPairs[] = - { - from_1, to_1, - from_2, to_2, - ... - from_n, to_n, - 0 - }; + /** implement this method to provide an array of which-ranges */ - virtual const sal_uInt16 * GetWhichPairs() const = 0; + virtual const WhichRangesContainer& GetWhichPairs() const = 0; /** implement this method to return a Property object for a given which id. diff --git a/chart2/source/controller/inc/LegendItemConverter.hxx b/chart2/source/controller/inc/LegendItemConverter.hxx index efa167db0856..4d3d8fd87e59 100644 --- a/chart2/source/controller/inc/LegendItemConverter.hxx +++ b/chart2/source/controller/inc/LegendItemConverter.hxx @@ -19,26 +19,28 @@ #pragma once #include "ItemConverter.hxx" - +#include <com/sun/star/awt/Size.hpp> +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } namespace chart::wrapper { -class LegendItemConverter : public ItemConverter +class LegendItemConverter final : public ItemConverter { public: LegendItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference< css::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, - const css::awt::Size* pRefSize ); + const rtl::Reference< ChartModel > & xChartModel, + const std::optional<css::awt::Size>& pRefSize ); virtual ~LegendItemConverter() override; @@ -46,7 +48,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; diff --git a/chart2/source/controller/inc/MultipleChartConverters.hxx b/chart2/source/controller/inc/MultipleChartConverters.hxx index 6a9110d45be2..ce24aba49309 100644 --- a/chart2/source/controller/inc/MultipleChartConverters.hxx +++ b/chart2/source/controller/inc/MultipleChartConverters.hxx @@ -19,82 +19,80 @@ #pragma once #include "MultipleItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <rtl/ref.hxx> +#include <optional> -namespace com::sun::star::awt { struct Size; } -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::lang { class XMultiServiceFactory; } - +namespace chart { class ChartModel; } class SdrModel; namespace chart::wrapper { -class AllAxisItemConverter : public MultipleItemConverter +class AllAxisItemConverter final : public MultipleItemConverter { public: AllAxisItemConverter( - const css::uno::Reference<css::frame::XModel> & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::awt::Size* pRefSize ); + const std::optional<css::awt::Size>& pRefSize ); virtual ~AllAxisItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; -class AllGridItemConverter : public MultipleItemConverter +class AllGridItemConverter final : public MultipleItemConverter { public: AllGridItemConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, + const rtl::Reference<::chart::ChartModel>& xChartModel, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const css::uno::Reference<css::lang::XMultiServiceFactory> & xNamedPropertyContainerFactory ); + SdrModel& rDrawModel ); virtual ~AllGridItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; -class AllDataLabelItemConverter : public MultipleItemConverter +class AllDataLabelItemConverter final : public MultipleItemConverter { public: AllDataLabelItemConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, + const rtl::Reference<::chart::ChartModel>& xChartModel, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const css::uno::Reference<css::lang::XMultiServiceFactory>& xNamedPropertyContainerFactory ); + SdrModel& rDrawModel ); virtual ~AllDataLabelItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; -class AllTitleItemConverter : public MultipleItemConverter +class AllTitleItemConverter final : public MultipleItemConverter { public: AllTitleItemConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, - SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference<css::lang::XMultiServiceFactory>& xNamedPropertyContainerFactory ); + const rtl::Reference<::chart::ChartModel>& xChartModel, + SfxItemPool& rItemPool, SdrModel& rDrawModel ); virtual ~AllTitleItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; -class AllSeriesStatisticsConverter : public MultipleItemConverter +class AllSeriesStatisticsConverter final : public MultipleItemConverter { public: AllSeriesStatisticsConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, SfxItemPool& rItemPool ); + const rtl::Reference<::chart::ChartModel>& xChartModel, SfxItemPool& rItemPool ); virtual ~AllSeriesStatisticsConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx b/chart2/source/controller/inc/ObjectHierarchy.hxx index 6ba57f17b545..e034d218fb27 100644 --- a/chart2/source/controller/inc/ObjectHierarchy.hxx +++ b/chart2/source/controller/inc/ObjectHierarchy.hxx @@ -18,23 +18,17 @@ */ #pragma once +#include <ChartModel.hxx> #include <ObjectIdentifier.hxx> +#include <map> +#include <vector> namespace com::sun::star::awt { struct KeyEvent; } -namespace com::sun::star::chart2 { class XChartDocument; } - -#include <memory> -#include <vector> namespace chart { -class ExplicitValueProvider; - -namespace impl -{ -class ImplObjectHierarchy; -} +class ChartView; class ObjectHierarchy { @@ -47,8 +41,8 @@ public: used for keyboard navigation). */ explicit ObjectHierarchy( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument, - ExplicitValueProvider * pExplicitValueProvider, + const rtl::Reference<::chart::ChartModel> & xChartDocument, + ChartView * pExplicitValueProvider, bool bFlattenDiagram = false, bool bOrderingForElementSelector = false ); ~ObjectHierarchy(); @@ -57,11 +51,10 @@ public: static bool isRootNode( const ObjectIdentifier& rOID ); /// equal to getChildren( getRootNodeOID()) - tChildContainer getTopLevelChildren() const; - bool hasChildren( const ObjectIdentifier& rParent ) const; - tChildContainer getChildren( const ObjectIdentifier& rParent ) const; - - tChildContainer getSiblings( const ObjectIdentifier& rNode ) const; + const tChildContainer& getTopLevelChildren() const; + bool hasChildren(const ObjectIdentifier& rParent) const; + const tChildContainer& getChildren(const ObjectIdentifier& rParent) const; + const tChildContainer& getSiblings(const ObjectIdentifier& rNode) const; /// The result is empty, if the node cannot be found in the tree ObjectIdentifier getParent( const ObjectIdentifier& rNode ) const; @@ -69,16 +62,43 @@ public: sal_Int32 getIndexInParent( const ObjectIdentifier& rNode ) const; private: - - std::unique_ptr< impl::ImplObjectHierarchy > m_apImpl; + void createTree( const rtl::Reference<::chart::ChartModel> & xChartDocument ); + void createAxesTree( + tChildContainer & rContainer, + const rtl::Reference<::chart::ChartModel> & xChartDoc, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + void createDiagramTree( + tChildContainer& rContainer, + const rtl::Reference<::chart::ChartModel>& xChartDoc, + const rtl::Reference< ::chart::Diagram >& xDiagram ); + void createDataSeriesTree( + tChildContainer & rOutDiagramSubContainer, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + static void createWallAndFloor( + tChildContainer & rContainer, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + void createLegendTree( + tChildContainer & rContainer, + const rtl::Reference<::chart::ChartModel> & xChartDoc, + const rtl::Reference< ::chart::Diagram > & xDiagram ); + void createAdditionalShapesTree(tChildContainer& rContainer); + ObjectIdentifier getParentImpl( + const ObjectIdentifier& rParentOID, + const ObjectIdentifier& rOID ) const; + + typedef std::map<ObjectIdentifier, tChildContainer> tChildMap; + tChildMap m_aChildMap; + ChartView* m_pExplicitValueProvider; + bool m_bFlattenDiagram; + bool m_bOrderingForElementSelector; }; class ObjectKeyNavigation { public: - explicit ObjectKeyNavigation( const ObjectIdentifier & rCurrentOID, - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument, - ExplicitValueProvider * pExplicitValueProvider ); + explicit ObjectKeyNavigation( ObjectIdentifier aCurrentOID, + rtl::Reference<::chart::ChartModel> xChartDocument, + ChartView * pExplicitValueProvider ); bool handleKeyEvent( const css::awt::KeyEvent & rEvent ); const ObjectIdentifier& getCurrentSelection() const { return m_aCurrentOID;} @@ -95,8 +115,8 @@ private: bool veryLast(); ObjectIdentifier m_aCurrentOID; - css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; - ExplicitValueProvider * m_pExplicitValueProvider; + rtl::Reference<::chart::ChartModel> m_xChartDocument; + ChartView * m_pExplicitValueProvider; }; } // namespace chart diff --git a/chart2/source/controller/inc/ObjectNameProvider.hxx b/chart2/source/controller/inc/ObjectNameProvider.hxx index 07551aefa1d7..7035ba916081 100644 --- a/chart2/source/controller/inc/ObjectNameProvider.hxx +++ b/chart2/source/controller/inc/ObjectNameProvider.hxx @@ -22,9 +22,6 @@ #include <ObjectIdentifier.hxx> #include <TitleHelper.hxx> -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::frame { class XModel; } - namespace chart { @@ -35,34 +32,33 @@ class ObjectNameProvider { public: static OUString getName( ObjectType eObjectType, bool bPlural=false ); - static OUString getAxisName( const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); - static OUString getGridName( const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); - static OUString getTitleName( const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); + static OUString getAxisName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString getGridName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); + static OUString getTitleName( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); static OUString getTitleNameByType( TitleHelper::eTitleType eType ); static OUString getNameForCID( - const OUString& rObjectCID, - const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument ); + std::u16string_view rObjectCID, + const rtl::Reference<::chart::ChartModel>& xChartDocument ); static OUString getName_ObjectForSeries( ObjectType eObjectType, - const OUString& rSeriesCID, - const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument ); + std::u16string_view rSeriesCID, + const rtl::Reference<::chart::ChartModel>& xChartDocument ); static OUString getName_ObjectForAllSeries( ObjectType eObjectType ); /** Provides help texts for the various chart elements. The parameter rObjectCID has to be a ClassifiedIdentifier - see class ObjectIdentifier. */ - static OUString getHelpText( const OUString& rObjectCID, const css::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, bool bVerbose=false ); - static OUString getHelpText( const OUString& rObjectCID, const css::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ); + static OUString getHelpText( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel, bool bVerbose=false ); /** This is used for showing the currently selected object in the status bar (command "Context") */ - static OUString getSelectedObjectText( const OUString & rObjectCID, const css::uno::Reference< css::chart2::XChartDocument >& xChartDocument ); + static OUString getSelectedObjectText( std::u16string_view rObjectCID, const rtl::Reference<::chart::ChartModel>& xChartDocument ); }; } //namespace chart diff --git a/chart2/source/controller/inc/PositionAndSizeHelper.hxx b/chart2/source/controller/inc/PositionAndSizeHelper.hxx index d1c72c20bd1f..a8e25e33963e 100644 --- a/chart2/source/controller/inc/PositionAndSizeHelper.hxx +++ b/chart2/source/controller/inc/PositionAndSizeHelper.hxx @@ -21,7 +21,6 @@ #include <ObjectIdentifier.hxx> -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::awt { struct Rectangle; } namespace chart @@ -36,8 +35,8 @@ public: , const css::awt::Rectangle& rOldPositionAndSize , const css::awt::Rectangle& rPageRectangle ); - static bool moveObject( const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel + static bool moveObject( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel , const css::awt::Rectangle& rNewPositionAndSize , const css::awt::Rectangle& rOldPositionAndSize , const css::awt::Rectangle& rPageRectangle ); diff --git a/chart2/source/controller/inc/RangeSelectionHelper.hxx b/chart2/source/controller/inc/RangeSelectionHelper.hxx deleted file mode 100644 index f04d763e1636..000000000000 --- a/chart2/source/controller/inc/RangeSelectionHelper.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <com/sun/star/uno/Reference.h> -#include <com/sun/star/uno/Sequence.h> -#include <rtl/ustring.hxx> - -namespace com::sun::star::beans { struct PropertyValue; } -namespace com::sun::star::chart2 { class XChartDocument; } - -namespace com::sun::star { - namespace sheet{ - class XRangeSelection; - class XRangeSelectionListener; - } -} - -namespace chart -{ - -class RangeSelectionListenerParent; - -class RangeSelectionHelper -{ -public: - explicit RangeSelectionHelper( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument ); - ~RangeSelectionHelper(); - - bool hasRangeSelection(); - css::uno::Reference< css::sheet::XRangeSelection > const & getRangeSelection(); - void raiseRangeSelectionDocument(); - bool chooseRange( - const OUString & aCurrentRange, - const OUString & aUIString, - RangeSelectionListenerParent & rListenerParent ); - void stopRangeListening( bool bRemoveListener = true ); - bool verifyCellRange( const OUString & rRangeStr ); - bool verifyArguments( const css::uno::Sequence< css::beans::PropertyValue >& rArguments ); - -private: - css::uno::Reference< css::sheet::XRangeSelection > - m_xRangeSelection; - - css::uno::Reference< css::chart2::XChartDocument > - m_xChartDocument; - - css::uno::Reference< css::sheet::XRangeSelectionListener > - m_xRangeSelectionListener; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/RangeSelectionListener.hxx b/chart2/source/controller/inc/RangeSelectionListener.hxx deleted file mode 100644 index f060a2aa95d3..000000000000 --- a/chart2/source/controller/inc/RangeSelectionListener.hxx +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#pragma once - -#include <ControllerLockGuard.hxx> -#include <cppuhelper/implbase.hxx> -#include <com/sun/star/sheet/XRangeSelectionListener.hpp> - -namespace com::sun::star::frame -{ -class XModel; -} - -namespace chart -{ -class RangeSelectionListenerParent -{ -public: - virtual void listeningFinished(const OUString& rNewRange) = 0; - virtual void disposingRangeSelection() = 0; - -protected: - ~RangeSelectionListenerParent() {} -}; - -class RangeSelectionListener : public ::cppu::WeakImplHelper<css::sheet::XRangeSelectionListener> -{ -public: - explicit RangeSelectionListener( - RangeSelectionListenerParent& rParent, const OUString& rInitialRange, - const css::uno::Reference<css::frame::XModel>& xModelToLockController); - virtual ~RangeSelectionListener() override; - -protected: - // ____ XRangeSelectionListener ____ - virtual void SAL_CALL done(const css::sheet::RangeSelectionEvent& aEvent) override; - virtual void SAL_CALL aborted(const css::sheet::RangeSelectionEvent& aEvent) override; - - // ____ XEventListener ____ - virtual void SAL_CALL disposing(const css::lang::EventObject& Source) override; - -private: - RangeSelectionListenerParent& m_rParent; - OUString m_aRange; - ControllerLockGuardUNO m_aControllerLockGuard; -}; - -} // namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/RegressionCurveItemConverter.hxx b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx index c5e1665d61a0..3849a2179387 100644 --- a/chart2/source/controller/inc/RegressionCurveItemConverter.hxx +++ b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx @@ -19,31 +19,31 @@ #pragma once #include "ItemConverter.hxx" +#include <rtl/ref.hxx> -namespace com::sun::star::chart2 { class XRegressionCurveContainer; } namespace com::sun::star::lang { class XMultiServiceFactory; } - +namespace chart { class DataSeries; } class SdrModel; namespace chart::wrapper { -class RegressionCurveItemConverter : public ItemConverter +class RegressionCurveItemConverter final : public ItemConverter { public: RegressionCurveItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, - const css::uno::Reference< css::chart2::XRegressionCurveContainer > & xRegCurveCnt, + rtl::Reference< ::chart::DataSeries > xRegCurveCnt, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference< css::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ); + const rtl::Reference< ChartModel > & xChartModel ); virtual ~RegressionCurveItemConverter() override; virtual void FillItemSet( SfxItemSet & rOutItemSet ) const override; virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; @@ -51,7 +51,7 @@ protected: private: std::shared_ptr< ItemConverter > m_spGraphicConverter; - css::uno::Reference< css::chart2::XRegressionCurveContainer > m_xCurveContainer; + rtl::Reference< ::chart::DataSeries > m_xCurveContainer; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/inc/RegressionEquationItemConverter.hxx b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx index df05d6e7f8e8..e0b0bac2bae9 100644 --- a/chart2/source/controller/inc/RegressionEquationItemConverter.hxx +++ b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx @@ -19,26 +19,28 @@ #pragma once #include "ItemConverter.hxx" - +#include <com/sun/star/awt/Size.hpp> +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::beans { class XPropertySet; } namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } namespace chart::wrapper { -class RegressionEquationItemConverter : public ItemConverter +class RegressionEquationItemConverter final : public ItemConverter { public: RegressionEquationItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference< css::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, - const css::awt::Size* pRefSize ); + const rtl::Reference< ChartModel > & xChartModel, + const std::optional<css::awt::Size>& pRefSize ); virtual ~RegressionEquationItemConverter() override; @@ -46,7 +48,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; diff --git a/chart2/source/controller/inc/SelectionHelper.hxx b/chart2/source/controller/inc/SelectionHelper.hxx index c5c2ed551510..f468f974d6db 100644 --- a/chart2/source/controller/inc/SelectionHelper.hxx +++ b/chart2/source/controller/inc/SelectionHelper.hxx @@ -38,7 +38,8 @@ public: //methods const ObjectIdentifier& getSelectedOID() const { return m_aSelectedOID;} bool isResizeableObjectSelected() const; - bool isRotateableObjectSelected( const css::uno::Reference< css::frame::XModel >& xChartModel ) const; + bool isRotateableObjectSelected( const rtl::Reference<::chart::ChartModel>& xChartModel ) const; + bool isTitleObjectSelected() const; bool isDragableObjectSelected() const; bool isAdditionalShapeSelected() const; @@ -72,7 +73,7 @@ private: //member ObjectIdentifier m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing; }; -class SelectionHelper : public MarkHandleProvider +class SelectionHelper final : public MarkHandleProvider { public: static bool findNamedParent( SdrObject*& pInOutObject @@ -92,11 +93,11 @@ public: DrawViewWrapper const & rDrawViewWrapper, bool bGetDiagramInsteadOf_Wall=false ); - static bool isRotateableObject( const OUString& rCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); + static bool isRotateableObject( std::u16string_view rCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ); explicit SelectionHelper( SdrObject* pSelectedObj ); - virtual ~SelectionHelper(); + ~SelectionHelper(); //MarkHandleProvider: virtual bool getMarkHandles( SdrHdlList& rHdlList ) override; diff --git a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx index d43c7cb6d234..febccf806ccb 100644 --- a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx +++ b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx @@ -20,33 +20,35 @@ #include "ItemConverter.hxx" #include <com/sun/star/uno/Sequence.h> +#include <rtl/ref.hxx> -namespace com::sun::star::chart2 { class XCoordinateSystem; } -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } +namespace chart { class ChartModel; } +namespace chart { class BaseCoordinateSystem; } +namespace chart { class DataSeries; } namespace chart::wrapper { -class SeriesOptionsItemConverter : public ItemConverter +class SeriesOptionsItemConverter final : public ItemConverter { public: SeriesOptionsItemConverter( - const css::uno::Reference< css::frame::XModel > & xChartModel, - const css::uno::Reference< css::uno::XComponentContext > & xContext, - const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, + const rtl::Reference<::chart::ChartModel> & xChartModel, + css::uno::Reference< css::uno::XComponentContext > xContext, + const rtl::Reference<::chart::DataSeries> & rPropertySet, SfxItemPool& rItemPool ); virtual ~SeriesOptionsItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) override; private: - css::uno::Reference< css::frame::XModel > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; css::uno::Reference< css::uno::XComponentContext> m_xCC; bool m_bAttachToMainAxis; @@ -64,7 +66,7 @@ private: sal_Int32 m_nStartingAngle; bool m_bClockwise; - css::uno::Reference< css::chart2::XCoordinateSystem > m_xCooSys; + rtl::Reference< ::chart::BaseCoordinateSystem > m_xCooSys; css::uno::Sequence< sal_Int32 > m_aSupportedMissingValueTreatments; sal_Int32 m_nMissingValueTreatment; diff --git a/chart2/source/controller/inc/ShapeController.h b/chart2/source/controller/inc/ShapeController.h deleted file mode 100644 index 392c28d2fe4c..000000000000 --- a/chart2/source/controller/inc/ShapeController.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef CHART_SHAPECONTROLLER_H -#define CHART_SHAPECONTROLLER_H - -//Command Ids: -#define COMMAND_ID_FORMAT_LINE 1 -#define COMMAND_ID_FORMAT_AREA 2 -#define COMMAND_ID_TEXT_ATTRIBUTES 3 -#define COMMAND_ID_TRANSFORM_DIALOG 4 -#define COMMAND_ID_OBJECT_TITLE_DESCRIPTION 5 -#define COMMAND_ID_RENAME_OBJECT 6 -#define COMMAND_ID_BRING_TO_FRONT 8 -#define COMMAND_ID_FORWARD 9 -#define COMMAND_ID_BACKWARD 10 -#define COMMAND_ID_SEND_TO_BACK 11 -#define COMMAND_ID_FONT_DIALOG 15 -#define COMMAND_ID_PARAGRAPH_DIALOG 16 - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx index 5d9fb544c605..7868a9014f7c 100644 --- a/chart2/source/controller/inc/StatisticsItemConverter.hxx +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -19,30 +19,31 @@ #pragma once #include "ItemConverter.hxx" +#include <rtl/ref.hxx> -namespace com::sun::star::frame { class XModel; } +namespace chart { class ChartModel; } namespace chart::wrapper { -class StatisticsItemConverter : public ItemConverter +class StatisticsItemConverter final : public ItemConverter { public: StatisticsItemConverter( - const css::uno::Reference< css::frame::XModel > & xChartModel, + rtl::Reference<::chart::ChartModel> xChartModel, const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool ); virtual ~StatisticsItemConverter() override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; virtual bool ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet & rItemSet ) override; private: - css::uno::Reference< css::frame::XModel > m_xModel; + rtl::Reference<::chart::ChartModel> m_xModel; }; } // namespace chart::wrapper diff --git a/chart2/source/controller/inc/TabPageNotifiable.hxx b/chart2/source/controller/inc/TabPageNotifiable.hxx index 440cda2de9aa..16450f28f781 100644 --- a/chart2/source/controller/inc/TabPageNotifiable.hxx +++ b/chart2/source/controller/inc/TabPageNotifiable.hxx @@ -18,16 +18,13 @@ */ #pragma once -// color to use as foreground for an invalid range -#define RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR COL_WHITE -// color to use as background for an invalid range -#define RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR Color(0xff6563) +#include <sal/types.h> class BuilderPage; namespace chart { -class TabPageNotifiable +class SAL_LOPLUGIN_ANNOTATE("crosscast") TabPageNotifiable { public: virtual void setInvalidPage(BuilderPage* pTabPage) = 0; diff --git a/chart2/source/controller/inc/TextDirectionListBox.hxx b/chart2/source/controller/inc/TextDirectionListBox.hxx index 208e0df6cf02..d346a23cb45d 100644 --- a/chart2/source/controller/inc/TextDirectionListBox.hxx +++ b/chart2/source/controller/inc/TextDirectionListBox.hxx @@ -23,7 +23,7 @@ namespace chart { -class TextDirectionListBox : public svx::FrameDirectionListBox +class TextDirectionListBox final : public svx::FrameDirectionListBox { public: explicit TextDirectionListBox(std::unique_ptr<weld::ComboBox> pControl); diff --git a/chart2/source/controller/inc/TextLabelItemConverter.hxx b/chart2/source/controller/inc/TextLabelItemConverter.hxx index ebe1b3961d89..cb5406cf6a01 100644 --- a/chart2/source/controller/inc/TextLabelItemConverter.hxx +++ b/chart2/source/controller/inc/TextLabelItemConverter.hxx @@ -20,25 +20,28 @@ #include "ItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> #include <com/sun/star/uno/Sequence.h> - +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::chart2 { class XDataSeries; } namespace com::sun::star::frame { class XModel; } +namespace chart { class ChartModel; } +namespace chart { class DataSeries; } namespace chart::wrapper { -class TextLabelItemConverter : public ItemConverter +class TextLabelItemConverter final : public ItemConverter { public: TextLabelItemConverter( - const css::uno::Reference<css::frame::XModel>& xChartModel, + const rtl::Reference<::chart::ChartModel>& xChartModel, const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, - const css::uno::Reference<css::chart2::XDataSeries>& xSeries, + const rtl::Reference<::chart::DataSeries>& xSeries, SfxItemPool& rItemPool, - const css::awt::Size* pRefSize, + const std::optional<css::awt::Size>& pRefSize, bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat ); @@ -49,7 +52,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16* GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; @@ -64,7 +67,7 @@ private: bool mbDataSeries:1; bool mbForbidPercentValue:1; - css::uno::Reference<css::chart2::XDataSeries> m_xSeries; + rtl::Reference<::chart::DataSeries> m_xSeries; }; } diff --git a/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx b/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx deleted file mode 100644 index f8e899df1d19..000000000000 --- a/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx +++ /dev/null @@ -1,56 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#pragma once - -#include <com/sun/star/uno/Reference.h> -#include <vcl/timer.hxx> - -#include <memory> - -namespace com::sun::star::frame -{ -class XModel; -} -namespace chart -{ -class ControllerLockGuardUNO; -} - -namespace chart -{ -class TimerTriggeredControllerLock final -{ -public: - TimerTriggeredControllerLock(const css::uno::Reference<css::frame::XModel>& xModel); - ~TimerTriggeredControllerLock(); - - void startTimer(); - -private: - css::uno::Reference<css::frame::XModel> m_xModel; - std::unique_ptr<ControllerLockGuardUNO> m_apControllerLockGuard; - AutoTimer m_aTimer; - - DECL_LINK(TimerTimeout, Timer*, void); -}; - -} //namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/TitleDialogData.hxx b/chart2/source/controller/inc/TitleDialogData.hxx index c69205169699..862eb8ad6193 100644 --- a/chart2/source/controller/inc/TitleDialogData.hxx +++ b/chart2/source/controller/inc/TitleDialogData.hxx @@ -19,31 +19,31 @@ #pragma once #include <ReferenceSizeProvider.hxx> -#include <memory> #include <com/sun/star/uno/Sequence.hxx> +#include <rtl/ref.hxx> -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } namespace chart { +class ChartModel; struct TitleDialogData { css::uno::Sequence< sal_Bool > aPossibilityList; css::uno::Sequence< sal_Bool > aExistenceList; css::uno::Sequence< OUString > aTextList; - std::unique_ptr< ReferenceSizeProvider > apReferenceSizeProvider; + std::optional< ReferenceSizeProvider > apReferenceSizeProvider; - TitleDialogData(std::unique_ptr<ReferenceSizeProvider> pReferenzeSizeProvider = nullptr); + TitleDialogData(std::optional<ReferenceSizeProvider> pReferenzeSizeProvider = std::nullopt); - void readFromModel( const css::uno::Reference< css::frame::XModel >& xChartModel ); + void readFromModel( const rtl::Reference<::chart::ChartModel>& xChartModel ); /* return true if anything has changed; when pOldState is NULL then all data are written to the model */ - bool writeDifferenceToModel( const css::uno::Reference< css::frame::XModel >& xChartModel + bool writeDifferenceToModel( const rtl::Reference<::chart::ChartModel>& xChartModel , const css::uno::Reference< css::uno::XComponentContext >& xContext - , TitleDialogData* pOldState=nullptr ); + , const TitleDialogData* pOldState=nullptr ); }; } //namespace chart diff --git a/chart2/source/controller/inc/TitleItemConverter.hxx b/chart2/source/controller/inc/TitleItemConverter.hxx index bc8e87e10cf0..917db7ef9cb6 100644 --- a/chart2/source/controller/inc/TitleItemConverter.hxx +++ b/chart2/source/controller/inc/TitleItemConverter.hxx @@ -20,23 +20,26 @@ #include "ItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <rtl/ref.hxx> +#include <optional> #include <vector> -namespace com::sun::star::awt { struct Size; } namespace com::sun::star::lang { class XMultiServiceFactory; } class SdrModel; +namespace chart { class ChartModel; } namespace chart::wrapper { -class TitleItemConverter : public ItemConverter +class TitleItemConverter final : public ItemConverter { public: TitleItemConverter( const css::uno::Reference<css::beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const css::uno::Reference<css::lang::XMultiServiceFactory>& xNamedPropertyContainerFactory, - const css::awt::Size* pRefSize ); + const rtl::Reference<ChartModel>& xChartModel, + const std::optional<css::awt::Size>& pRefSize ); virtual ~TitleItemConverter() override; @@ -44,7 +47,7 @@ public: virtual bool ApplyItemSet( const SfxItemSet & rItemSet ) override; protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const override; virtual void FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutItemSet ) const override; diff --git a/chart2/source/controller/inc/dlg_ChartType.hxx b/chart2/source/controller/inc/dlg_ChartType.hxx index d2864f3fd577..427369e9a88e 100644 --- a/chart2/source/controller/inc/dlg_ChartType.hxx +++ b/chart2/source/controller/inc/dlg_ChartType.hxx @@ -19,24 +19,21 @@ #pragma once #include <vcl/weld.hxx> - -namespace com::sun::star::frame -{ -class XModel; -} +#include <rtl/ref.hxx> namespace chart { +class ChartModel; class ChartTypeTabPage; -class ChartTypeDialog : public weld::GenericDialogController + +class ChartTypeDialog final : public weld::GenericDialogController { public: - ChartTypeDialog(weld::Window* pWindow, - const css::uno::Reference<css::frame::XModel>& xChartModel); + ChartTypeDialog(weld::Window* pWindow, rtl::Reference<::chart::ChartModel> xChartModel); virtual ~ChartTypeDialog() override; private: - css::uno::Reference<css::frame::XModel> m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; std::unique_ptr<weld::Container> m_xContentArea; std::unique_ptr<ChartTypeTabPage> m_xChartTypeTabPage; }; diff --git a/chart2/source/controller/inc/dlg_ChartType_UNO.hxx b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx index c3aaa4222a6a..ca79b25367de 100644 --- a/chart2/source/controller/inc/dlg_ChartType_UNO.hxx +++ b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx @@ -22,13 +22,14 @@ #include <comphelper/proparrhlp.hxx> #include <svtools/genericunodialog.hxx> -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::beans { class XPropertySetInfo; } namespace chart { +class ChartModel; + typedef ::svt::OGenericUnoDialog ChartTypeUnoDlg_BASE; -class ChartTypeUnoDlg : public ChartTypeUnoDlg_BASE +class ChartTypeUnoDlg final : public ChartTypeUnoDlg_BASE ,public ::comphelper::OPropertyArrayUsageHelper< ChartTypeUnoDlg > { public: @@ -57,7 +58,7 @@ private: ChartTypeUnoDlg(const ChartTypeUnoDlg&) = delete; void operator =(const ChartTypeUnoDlg&) = delete; - css::uno::Reference< css::frame::XModel > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; }; } //namespace chart diff --git a/chart2/source/controller/inc/dlg_CreationWizard.hxx b/chart2/source/controller/inc/dlg_CreationWizard.hxx index a8edc627e860..152545d0bfce 100644 --- a/chart2/source/controller/inc/dlg_CreationWizard.hxx +++ b/chart2/source/controller/inc/dlg_CreationWizard.hxx @@ -19,36 +19,32 @@ #pragma once -#include "TimerTriggeredControllerLock.hxx" +#include <TimerTriggeredControllerLock.hxx> #include "TabPageNotifiable.hxx" -#include <vcl/roadmapwizard.hxx> +#include <rtl/ref.hxx> +#include <vcl/roadmapwizardmachine.hxx> #include <memory> -namespace com::sun::star::chart2 -{ -class XChartDocument; -} namespace com::sun::star::uno { class XComponentContext; } using vcl::WizardTypes::WizardState; -using vcl::WizardTypes::CommitPageReason; namespace chart { -class DialogModel; +class ChartModel; class ChartTypeTemplateProvider; +class DialogModel; -class CreationWizard : public vcl::RoadmapWizardMachine, public TabPageNotifiable +class CreationWizard final : public vcl::RoadmapWizardMachine, public TabPageNotifiable { public: - CreationWizard(weld::Window* pParent, - const css::uno::Reference<css::frame::XModel>& xChartModel, - const css::uno::Reference<css::uno::XComponentContext>& xContext); + CreationWizard(weld::Window* pParent, const rtl::Reference<::chart::ChartModel>& xChartModel, + css::uno::Reference<css::uno::XComponentContext> xContext); CreationWizard() = delete; virtual ~CreationWizard() override; @@ -67,7 +63,7 @@ protected: private: virtual std::unique_ptr<BuilderPage> createPage(WizardState nState) override; - css::uno::Reference<css::chart2::XChartDocument> m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; css::uno::Reference<css::uno::XComponentContext> m_xComponentContext; ChartTypeTemplateProvider* m_pTemplateProvider; std::unique_ptr<DialogModel> m_pDialogModel; diff --git a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx index b58b918c249d..68dbe78432da 100644 --- a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx +++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx @@ -19,7 +19,7 @@ #pragma once -#include <MutexContainer.hxx> +#include <cppuhelper/basemutex.hxx> #include <cppuhelper/component.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/frame/XTerminateListener.hpp> @@ -27,20 +27,19 @@ #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/ui/dialogs/XAsynchronousExecutableDialog.hpp> +#include <rtl/ref.hxx> #include "dlg_CreationWizard.hxx" #include <tools/link.hxx> namespace com::sun::star::awt { class XWindow; } -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } -class VclWindowEvent; - namespace chart { +class ChartModel; -class CreationWizardUnoDlg : public MutexContainer +class CreationWizardUnoDlg final : public cppu::BaseMutex , public ::cppu::OComponentHelper , public css::ui::dialogs::XAsynchronousExecutableDialog , public css::lang::XServiceInfo @@ -51,7 +50,7 @@ class CreationWizardUnoDlg : public MutexContainer public: CreationWizardUnoDlg() = delete; - CreationWizardUnoDlg( const css::uno::Reference< css::uno::XComponentContext >& xContext ); + CreationWizardUnoDlg( css::uno::Reference< css::uno::XComponentContext > xContext ); virtual ~CreationWizardUnoDlg() override; // XInterface @@ -101,7 +100,7 @@ private: DECL_STATIC_LINK(CreationWizardUnoDlg, InstallLOKNotifierHdl, void*, vcl::ILibreOfficeKitNotifier*); private: - css::uno::Reference< css::frame::XModel > m_xChartModel; + rtl::Reference< ::chart::ChartModel > m_xChartModel; css::uno::Reference< css::uno::XComponentContext> m_xCC; css::uno::Reference< css::awt::XWindow > m_xParentWindow; diff --git a/chart2/source/controller/inc/dlg_DataEditor.hxx b/chart2/source/controller/inc/dlg_DataEditor.hxx index 7f0c8141c15a..f7e335ac36fa 100644 --- a/chart2/source/controller/inc/dlg_DataEditor.hxx +++ b/chart2/source/controller/inc/dlg_DataEditor.hxx @@ -20,26 +20,20 @@ #pragma once #include <vcl/weld.hxx> +#include <rtl/ref.hxx> namespace com::sun::star::uno { class XComponentContext; } -namespace comphelper { template <class Tp, class Arg> class mem_fun1_t; } - -namespace com::sun::star { - namespace chart2 { - class XChartDocument; - } -} namespace chart { - +class ChartModel; class DataBrowser; -class DataEditor : public weld::GenericDialogController +class DataEditor final : public weld::GenericDialogController { public: DataEditor(weld::Window* pParent, - const css::uno::Reference<css::chart2::XChartDocument> & xChartDoc, + rtl::Reference<::chart::ChartModel> xChartDoc, const css::uno::Reference<css::uno::XComponentContext> & xContext); virtual ~DataEditor() override; @@ -50,7 +44,7 @@ public: private: bool m_bReadOnly; - css::uno::Reference<css::chart2::XChartDocument> m_xChartDoc; + rtl::Reference<::chart::ChartModel> m_xChartDoc; css::uno::Reference<css::uno::XComponentContext> m_xContext; std::unique_ptr<weld::Toolbar> m_xTbxData; @@ -62,7 +56,7 @@ private: VclPtr<DataBrowser> m_xBrwData; /// handles actions of the toolbox - DECL_LINK( ToolboxHdl, const OString&, void ); + DECL_LINK( ToolboxHdl, const OUString&, void ); /// is called, if the cursor of the table has moved DECL_LINK( BrowserCursorMovedHdl, DataBrowser*, void); }; diff --git a/chart2/source/controller/inc/dlg_DataSource.hxx b/chart2/source/controller/inc/dlg_DataSource.hxx index 1e505ff63ef6..9da88e8de0ba 100644 --- a/chart2/source/controller/inc/dlg_DataSource.hxx +++ b/chart2/source/controller/inc/dlg_DataSource.hxx @@ -18,24 +18,19 @@ */ #pragma once -#include <vcl/weld.hxx> - #include "TabPageNotifiable.hxx" - -namespace com::sun::star::chart2 { class XChartDocument; } -namespace com::sun::star::uno { class XComponentContext; } - +#include <vcl/weld.hxx> #include <memory> class BuilderPage; namespace chart { - -class RangeChooserTabPage; -class DataSourceTabPage; +class ChartModel; class ChartTypeTemplateProvider; +class DataSourceTabPage; class DialogModel; +class RangeChooserTabPage; class DataSourceDialog final : public weld::GenericDialogController, @@ -44,20 +39,18 @@ class DataSourceDialog final : public: explicit DataSourceDialog( weld::Window * pParent, - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument, - const css::uno::Reference< css::uno::XComponentContext > & xContext ); + const rtl::Reference<::chart::ChartModel> & xChartDocument ); virtual ~DataSourceDialog() override; - // from GenericDialogController base - virtual short run() override; - // TabPageNotifiable virtual void setInvalidPage( BuilderPage * pTabPage ) override; virtual void setValidPage( BuilderPage * pTabPage ) override; private: - DECL_LINK(ActivatePageHdl, const OString&, void); - DECL_LINK(DeactivatePageHdl, const OString&, bool); + DECL_LINK(ActivatePageHdl, const OUString&, void); + DECL_LINK(DeactivatePageHdl, const OUString&, bool); + DECL_LINK(OkHdl, weld::Button&, void); + void commitPages(); std::unique_ptr< ChartTypeTemplateProvider > m_apDocTemplateProvider; std::unique_ptr< DialogModel > m_apDialogModel; diff --git a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx index d799f1765078..2b265c7d6541 100644 --- a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx +++ b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx @@ -38,7 +38,6 @@ struct InsertAxisOrGridDialogData \************************************************************************/ class SchAxisDlg : public weld::GenericDialogController { -protected: std::unique_ptr<weld::CheckButton> m_xCbPrimaryX; std::unique_ptr<weld::CheckButton> m_xCbPrimaryY; std::unique_ptr<weld::CheckButton> m_xCbPrimaryZ; @@ -57,7 +56,7 @@ public: |* Grid dialog |* \************************************************************************/ -class SchGridDlg : public SchAxisDlg +class SchGridDlg final : public SchAxisDlg { public: SchGridDlg(weld::Window* pParent, const InsertAxisOrGridDialogData& rInput); diff --git a/chart2/source/controller/inc/dlg_InsertDataLabel.hxx b/chart2/source/controller/inc/dlg_InsertDataLabel.hxx index 54c280ade2fc..7777db3c9696 100644 --- a/chart2/source/controller/inc/dlg_InsertDataLabel.hxx +++ b/chart2/source/controller/inc/dlg_InsertDataLabel.hxx @@ -28,7 +28,7 @@ namespace chart { class DataLabelResources; -class DataLabelsDialog : public weld::GenericDialogController +class DataLabelsDialog final : public weld::GenericDialogController { private: std::unique_ptr<DataLabelResources> m_apDataLabelResources; diff --git a/chart2/source/controller/inc/dlg_InsertDataTable.hxx b/chart2/source/controller/inc/dlg_InsertDataTable.hxx new file mode 100644 index 000000000000..cd77099864c4 --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertDataTable.hxx @@ -0,0 +1,52 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <vcl/weld.hxx> +#include "res_DataTableProperties.hxx" + +namespace chart +{ +/** The data table properties (data) used by the dialog */ +struct DataTableDialogData +{ + bool mbShow = true; + bool mbHorizontalBorders = false; + bool mbVerticalBorders = false; + bool mbOutline = false; + bool mbKeys = false; +}; + +/** The dialog to change the data table specific properties */ +class InsertDataTableDialog final : public weld::GenericDialogController +{ +private: + DataTablePropertiesResources m_aDataTablePropertiesResources; + std::unique_ptr<weld::CheckButton> m_xCbShowDataTable; + + DataTableDialogData m_aData; + + DECL_LINK(ShowDataTableToggle, weld::Toggleable&, void); + + void changeEnabled(); + +public: + InsertDataTableDialog(weld::Window* pParent); + + /** Set the initial state of the data table properties */ + void init(DataTableDialogData const& rData); + + /** Get the state of the data table properties from the dialog */ + DataTableDialogData& getDataTableDialogData(); +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/dlg_InsertErrorBars.hxx b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx index d4ef7ec80ef2..cdadc18c3f09 100644 --- a/chart2/source/controller/inc/dlg_InsertErrorBars.hxx +++ b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx @@ -24,26 +24,23 @@ #include "res_ErrorBar.hxx" -namespace com::sun::star::frame -{ -class XModel; -} - namespace chart { -class InsertErrorBarsDialog : public weld::GenericDialogController +class ChartView; + +class InsertErrorBarsDialog final : public weld::GenericDialogController { public: InsertErrorBarsDialog(weld::Window* pParent, const SfxItemSet& rMyAttrs, - const css::uno::Reference<css::chart2::XChartDocument>& xChartDocument, + const rtl::Reference<::chart::ChartModel>& xChartDocument, ErrorBarResources::tErrorBarType eType); void SetAxisMinorStepWidthForErrorBarDecimals(double fMinorStepWidth); - static double getAxisMinorStepWidthForErrorBarDecimals( - const css::uno::Reference<css::frame::XModel>& xChartModel, - const css::uno::Reference<css::uno::XInterface>& xChartView, - const OUString& rSelectedObjectCID); + static double + getAxisMinorStepWidthForErrorBarDecimals(const rtl::Reference<::chart::ChartModel>& xChartModel, + const rtl::Reference<::chart::ChartView>& xChartView, + std::u16string_view rSelectedObjectCID); void FillItemSet(SfxItemSet& rOutAttrs); diff --git a/chart2/source/controller/inc/dlg_InsertLegend.hxx b/chart2/source/controller/inc/dlg_InsertLegend.hxx index de073bb0f0bb..265f486f4a80 100644 --- a/chart2/source/controller/inc/dlg_InsertLegend.hxx +++ b/chart2/source/controller/inc/dlg_InsertLegend.hxx @@ -19,18 +19,19 @@ #pragma once #include <vcl/weld.hxx> +#include <rtl/ref.hxx> #include <memory> #include "res_LegendPosition.hxx" -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } namespace chart { +class ChartModel; -class SchLegendDlg : public weld::GenericDialogController +class SchLegendDlg final : public weld::GenericDialogController { private: std::unique_ptr<LegendPositionResources> m_xLegendPositionResources; @@ -38,8 +39,8 @@ private: public: SchLegendDlg(weld::Window* pParent, const css::uno::Reference< css::uno::XComponentContext>& xCC); - void init( const css::uno::Reference< css::frame::XModel >& xChartModel ); - void writeToModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) const; + void init( const rtl::Reference<::chart::ChartModel>& xChartModel ); + void writeToModel( const rtl::Reference<::chart::ChartModel>& xChartModel ) const; }; } //namespace chart diff --git a/chart2/source/controller/inc/dlg_InsertTitle.hxx b/chart2/source/controller/inc/dlg_InsertTitle.hxx index 77c3926b3134..096628529e9f 100644 --- a/chart2/source/controller/inc/dlg_InsertTitle.hxx +++ b/chart2/source/controller/inc/dlg_InsertTitle.hxx @@ -24,7 +24,7 @@ namespace chart { -class SchTitleDlg : public weld::GenericDialogController +class SchTitleDlg final : public weld::GenericDialogController { private: std::unique_ptr<TitleResources> m_xTitleResources; diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx index 3a7e87fbe6dc..f16aee1e611b 100644 --- a/chart2/source/controller/inc/dlg_ObjectProperties.hxx +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -20,9 +20,11 @@ #include <ObjectIdentifier.hxx> #include <sfx2/tabdlg.hxx> +#include <vcl/graph.hxx> + +class SvNumberFormatter; namespace com::sun::star::util { class XNumberFormatsSupplier; } -class Graphic; namespace chart { @@ -30,10 +32,10 @@ namespace chart class ObjectPropertiesDialogParameter final { public: - ObjectPropertiesDialogParameter( const OUString& rObjectCID ); + ObjectPropertiesDialogParameter( OUString aObjectCID ); ~ObjectPropertiesDialogParameter(); - void init( const css::uno::Reference< css::frame::XModel >& xModel ); + void init( const rtl::Reference<::chart::ChartModel>& xModel ); ObjectType getObjectType() const { return m_eObjectType;} const OUString& getLocalizedName() const { return m_aLocalizedName;} @@ -57,7 +59,7 @@ public: bool IsSupportingCategoryPositioning() const { return m_bSupportingCategoryPositioning;} const css::uno::Sequence< OUString >& GetCategories() const { return m_aCategories;} - const css::uno::Reference< css::chart2::XChartDocument >& + const rtl::Reference<::chart::ChartModel>& getDocument() const { return m_xChartDocument;} bool IsComplexCategoriesAxis() const { return m_bComplexCategoriesAxis;} @@ -92,7 +94,7 @@ private: bool m_bSupportingCategoryPositioning; css::uno::Sequence< OUString > m_aCategories; - css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; + rtl::Reference<::chart::ChartModel> m_xChartDocument; bool m_bComplexCategoriesAxis; @@ -107,22 +109,22 @@ private: class ViewElementListProvider; -class SchAttribTabDlg : public SfxTabDialogController +class SchAttribTabDlg final : public SfxTabDialogController { private: const ObjectPropertiesDialogParameter * const m_pParameter; const ViewElementListProvider* const m_pViewElementListProvider; SvNumberFormatter* m_pNumberFormatter; - std::unique_ptr<SfxItemSet> m_pSymbolShapeProperties; - std::unique_ptr<Graphic> m_pAutoSymbolGraphic; + std::optional<SfxItemSet> m_oSymbolShapeProperties; + std::optional<Graphic> m_oAutoSymbolGraphic; double m_fAxisMinorStepWidthForErrorBarDecimals; bool m_bOKPressed; DECL_LINK(OKPressed, weld::Button&, void); - virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage& rPage) override; public: SchAttribTabDlg(weld::Window* pParent, const SfxItemSet* pAttr, @@ -133,7 +135,7 @@ public: //pSymbolShapeProperties: Properties to be set on the symbollist shapes //pAutoSymbolGraphic: Graphic to be shown if AutoSymbol gets selected - void setSymbolInformation( std::unique_ptr<SfxItemSet> pSymbolShapeProperties, std::unique_ptr<Graphic> pAutoSymbolGraphic ); + void setSymbolInformation( SfxItemSet&& rSymbolShapeProperties, std::optional<Graphic> oAutoSymbolGraphic ); void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); diff --git a/chart2/source/controller/inc/dlg_ShapeFont.hxx b/chart2/source/controller/inc/dlg_ShapeFont.hxx index 372ce9a15b2a..cfeb002fb92d 100644 --- a/chart2/source/controller/inc/dlg_ShapeFont.hxx +++ b/chart2/source/controller/inc/dlg_ShapeFont.hxx @@ -26,14 +26,14 @@ class ViewElementListProvider; /** dialog for font properties of shapes */ -class ShapeFontDialog : public SfxTabDialogController +class ShapeFontDialog final : public SfxTabDialogController { public: ShapeFontDialog(weld::Window* pParent, const SfxItemSet* pAttr, const ViewElementListProvider* pViewElementListProvider); private: - virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage& rPage) override; const ViewElementListProvider* m_pViewElementListProvider; }; diff --git a/chart2/source/controller/inc/dlg_ShapeParagraph.hxx b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx index 28d04a33eff4..15d0c014d848 100644 --- a/chart2/source/controller/inc/dlg_ShapeParagraph.hxx +++ b/chart2/source/controller/inc/dlg_ShapeParagraph.hxx @@ -24,13 +24,13 @@ namespace chart { /** dialog for paragraph properties of shapes */ -class ShapeParagraphDialog : public SfxTabDialogController +class ShapeParagraphDialog final : public SfxTabDialogController { public: ShapeParagraphDialog(weld::Window* pParent, const SfxItemSet* pAttr); private: - virtual void PageCreated(const OString& rId, SfxTabPage& rPage) override; + virtual void PageCreated(const OUString& rId, SfxTabPage& rPage) override; }; } // namespace chart diff --git a/chart2/source/controller/inc/dlg_View3D.hxx b/chart2/source/controller/inc/dlg_View3D.hxx index e31668e01f38..1fda6745fbe1 100644 --- a/chart2/source/controller/inc/dlg_View3D.hxx +++ b/chart2/source/controller/inc/dlg_View3D.hxx @@ -21,27 +21,22 @@ #include <vcl/weld.hxx> #include <ControllerLockGuard.hxx> -namespace com::sun::star::frame -{ -class XModel; -} - namespace chart { class ThreeD_SceneGeometry_TabPage; class ThreeD_SceneAppearance_TabPage; class ThreeD_SceneIllumination_TabPage; -class View3DDialog : public weld::GenericDialogController +class View3DDialog final : public weld::GenericDialogController { public: - View3DDialog(weld::Window* pWindow, const css::uno::Reference<css::frame::XModel>& xChartModel); + View3DDialog(weld::Window* pWindow, const rtl::Reference<::chart::ChartModel>& xChartModel); virtual ~View3DDialog() override; virtual short run() override; private: - DECL_LINK(ActivatePageHdl, const OString&, void); + DECL_LINK(ActivatePageHdl, const OUString&, void); ControllerLockHelper m_aControllerLocker; diff --git a/chart2/source/controller/inc/helpids.h b/chart2/source/controller/inc/helpids.h index 2867867d6323..775ec1489b42 100644 --- a/chart2/source/controller/inc/helpids.h +++ b/chart2/source/controller/inc/helpids.h @@ -17,18 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#ifndef CHART_HELPIDS_H -#define CHART_HELPIDS_H +#pragma once -#define HID_SCH_WIN_DOCUMENT "CHART2_HID_SCH_WIN_DOCUMENT" -#define HID_SCH_ERROR_BARS_FROM_DATA "CHART2_SCH_ERROR_BARS_FROM_DATA" +#include <rtl/ustring.hxx> +inline constexpr OUString HID_SCH_WIN_DOCUMENT = u"CHART2_HID_SCH_WIN_DOCUMENT"_ustr; +inline constexpr OUString HID_SCH_ERROR_BARS_FROM_DATA = u"CHART2_SCH_ERROR_BARS_FROM_DATA"_ustr; -#define HID_SCH_WIZARD_ROADMAP "CHART2_HID_SCH_WIZARD_ROADMAP" -#define HID_SCH_DATA_SERIES_LABEL "CHART2_HID_SCH_DATA_SERIES_LABEL" - -#endif +inline constexpr OUString HID_SCH_WIZARD_ROADMAP = u"CHART2_HID_SCH_WIZARD_ROADMAP"_ustr; +inline constexpr OUString HID_SCH_DATA_SERIES_LABEL = u"CHART2_HID_SCH_DATA_SERIES_LABEL"_ustr; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/res_DataTableProperties.hxx b/chart2/source/controller/inc/res_DataTableProperties.hxx new file mode 100644 index 000000000000..4b2aaa4f2ef7 --- /dev/null +++ b/chart2/source/controller/inc/res_DataTableProperties.hxx @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#pragma once + +#include <svl/itemset.hxx> +#include <vcl/weld.hxx> + +namespace chart +{ +/** The shared UI elements for the data table properties */ +class DataTablePropertiesResources final +{ +private: + std::unique_ptr<weld::CheckButton> m_xCbHorizontalBorder; + std::unique_ptr<weld::CheckButton> m_xCbVerticalBorder; + std::unique_ptr<weld::CheckButton> m_xCbOutilne; + std::unique_ptr<weld::CheckButton> m_xCbKeys; + +public: + DataTablePropertiesResources(weld::Builder& rBuilder); + + void initFromItemSet(SfxItemSet const& rInAttrs); + bool writeToItemSet(SfxItemSet& rOutAttrs) const; + void setChecksSensitive(bool bSensitive); + + bool getHorizontalBorder() { return m_xCbHorizontalBorder->get_active(); } + void setHorizontalBorder(bool bActive) { m_xCbHorizontalBorder->set_active(bActive); } + + bool getVerticalBorder() { return m_xCbVerticalBorder->get_active(); } + void setVerticalBorder(bool bActive) { m_xCbVerticalBorder->set_active(bActive); } + + bool getOutline() { return m_xCbOutilne->get_active(); } + void setOutline(bool bActive) { m_xCbOutilne->set_active(bActive); } + + bool getKeys() { return m_xCbKeys->get_active(); } + void setKeys(bool bActive) { m_xCbKeys->set_active(bActive); } +}; + +} //namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx index 09380c921d3c..4fcd21226261 100644 --- a/chart2/source/controller/inc/res_ErrorBar.hxx +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -22,9 +22,9 @@ #include <tools/link.hxx> #include <svl/itemset.hxx> #include <svx/chrtitem.hxx> -#include "RangeSelectionListener.hxx" +#include <RangeSelectionListener.hxx> +#include <rtl/ref.hxx> -namespace com::sun::star::chart2 { class XChartDocument; } namespace weld { class Builder; } namespace weld { class Button; } namespace weld { class CheckButton; } @@ -41,10 +41,10 @@ namespace weld { class Widget; } namespace chart { - +class ChartModel; class RangeSelectionHelper; -class ErrorBarResources : public RangeSelectionListenerParent +class ErrorBarResources final : public RangeSelectionListenerParent { public: enum tErrorBarType @@ -55,12 +55,12 @@ public: ErrorBarResources( weld::Builder* pParent, weld::DialogController* pControllerDialog, const SfxItemSet& rInAttrs, bool bNoneAvailable, chart::ErrorBarResources::tErrorBarType eType = ERROR_BAR_Y); - virtual ~ErrorBarResources(); + ~ErrorBarResources(); void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); void SetErrorBarType( tErrorBarType eNewType ); void SetChartDocumentForRangeChoosing( - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument ); + const rtl::Reference<::chart::ChartModel> & xChartDocument ); void Reset(const SfxItemSet& rInAttrs); void FillItemSet(SfxItemSet& rOutAttrs) const; diff --git a/chart2/source/controller/inc/res_LegendPosition.hxx b/chart2/source/controller/inc/res_LegendPosition.hxx index 87b96ab558fc..32f065642051 100644 --- a/chart2/source/controller/inc/res_LegendPosition.hxx +++ b/chart2/source/controller/inc/res_LegendPosition.hxx @@ -20,8 +20,8 @@ #include <svl/itemset.hxx> #include <tools/link.hxx> +#include <rtl/ref.hxx> -namespace com::sun::star::frame { class XModel; } namespace com::sun::star::uno { class XComponentContext; } namespace weld { class Builder; } namespace weld { class CheckButton; } @@ -30,6 +30,7 @@ namespace weld { class Toggleable; } namespace chart { +class ChartModel; class LegendPositionResources final { @@ -38,12 +39,12 @@ public: //constructor without Display checkbox LegendPositionResources(weld::Builder& rBuilder); //constructor inclusive Display checkbox - LegendPositionResources(weld::Builder& rBuilder, const css::uno::Reference< - css::uno::XComponentContext>& xCC ); + LegendPositionResources(weld::Builder& rBuilder, css::uno::Reference< + css::uno::XComponentContext> xCC ); ~LegendPositionResources(); - void writeToResources( const css::uno::Reference< css::frame::XModel >& xChartModel ); - void writeToModel( const css::uno::Reference< css::frame::XModel >& xChartModel ) const; + void writeToResources( const rtl::Reference<::chart::ChartModel>& xChartModel ); + void writeToModel( const rtl::Reference<::chart::ChartModel>& xChartModel ) const; void initFromItemSet( const SfxItemSet& rInAttrs ); void writeToItemSet( SfxItemSet& rOutAttrs ) const; @@ -55,6 +56,7 @@ public: private: void impl_setRadioButtonToggleHdl(); + void PositionEnable(); private: css::uno::Reference< css::uno::XComponentContext> m_xCC; diff --git a/chart2/source/controller/inc/uiobject.hxx b/chart2/source/controller/inc/uiobject.hxx index 01dc8b500043..6de63f5d3fdf 100644 --- a/chart2/source/controller/inc/uiobject.hxx +++ b/chart2/source/controller/inc/uiobject.hxx @@ -14,12 +14,12 @@ #include "ChartWindow.hxx" -class ChartUIObject : public UIObject +class ChartUIObject final : public UIObject { public: ChartUIObject(const VclPtr<chart::ChartWindow>& xChartWindow, - const OUString& rCID); + OUString aCID); StringMap get_state() override; @@ -32,6 +32,8 @@ public: virtual OUString get_type() const override; + virtual bool equals(const UIObject& rOther) const override; + private: OUString maCID; @@ -41,7 +43,7 @@ private: DECL_LINK(PostCommand, void*, void); }; -class ChartWindowUIObject : public WindowUIObject +class ChartWindowUIObject final : public WindowUIObject { VclPtr<chart::ChartWindow> mxChartWindow; diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx index 297b3de704ee..a5880942aad9 100644 --- a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -23,13 +23,17 @@ #include <GraphicPropertyItemConverter.hxx> #include <chartview/ChartSfxItemIds.hxx> #include <chartview/ExplicitScaleValues.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include "SchWhichPairs.hxx" -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <CommonConverters.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> +#include <Diagram.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> +#include <ChartView.hxx> #include <memory> #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> @@ -37,10 +41,8 @@ #include <com/sun/star/chart/ChartAxisPosition.hpp> #include <com/sun/star/chart/TimeInterval.hpp> #include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp> #include <com/sun/star/chart2/AxisType.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <osl/diagnose.h> #include <o3tl/any.hxx> @@ -79,15 +81,13 @@ AxisItemConverter::AxisItemConverter( const Reference< beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const Reference< chart2::XChartDocument > & xChartDoc, + const rtl::Reference<::chart::ChartModel> & xChartDoc, ::chart::ExplicitScaleData const * pScale /* = NULL */, ::chart::ExplicitIncrementData const * pIncrement /* = NULL */, - const awt::Size* pRefSize ) : + const std::optional<awt::Size>& pRefSize ) : ItemConverter( rPropertySet, rItemPool ), m_xChartDoc( xChartDoc ) { - Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY ); - if( pScale ) m_pExplicitScale.reset( new ::chart::ExplicitScaleData( *pScale ) ); if( pIncrement ) @@ -95,13 +95,13 @@ AxisItemConverter::AxisItemConverter( m_aConverters.emplace_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, + xChartDoc, GraphicObjectType::LineProperties )); m_aConverters.emplace_back( - new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); + new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); - m_xAxis.set( Reference< chart2::XAxis >( rPropertySet, uno::UNO_QUERY ) ); - OSL_ASSERT( m_xAxis.is()); + m_xAxis = dynamic_cast<::chart::Axis*>(rPropertySet.get()); + assert(m_xAxis); } AxisItemConverter::~AxisItemConverter() @@ -128,7 +128,7 @@ bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * AxisItemConverter::GetWhichPairs() const +const WhichRangesContainer& AxisItemConverter::GetWhichPairs() const { // must span all used items! return nAxisWhichPairs; @@ -161,57 +161,57 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI if( !m_xAxis.is() ) return; - const chart2::ScaleData& rScale( m_xAxis->getScaleData() ); - const chart2::IncrementData& rIncrement( rScale.IncrementData ); - const uno::Sequence< chart2::SubIncrement >& rSubIncrements( rScale.IncrementData.SubIncrements ); - const TimeIncrement& rTimeIncrement( rScale.TimeIncrement ); - bool bDateAxis = (rScale.AxisType == chart2::AxisType::DATE); + const chart2::ScaleData aScale( m_xAxis->getScaleData() ); + const chart2::IncrementData& rIncrement( aScale.IncrementData ); + const uno::Sequence< chart2::SubIncrement >& rSubIncrements( aScale.IncrementData.SubIncrements ); + const TimeIncrement& rTimeIncrement( aScale.TimeIncrement ); + bool bDateAxis = (aScale.AxisType == chart2::AxisType::DATE); if( m_pExplicitScale ) bDateAxis = (m_pExplicitScale->AxisType == chart2::AxisType::DATE); switch( nWhichId ) { case SCHATTR_AXIS_AUTO_MAX: - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Maximum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); break; case SCHATTR_AXIS_MAX: { double fMax = 10.0; - if( rScale.Maximum >>= fMax ) - rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); + if( aScale.Maximum >>= fMax ) + rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); else { if( m_pExplicitScale ) fMax = m_pExplicitScale->Maximum; - rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); + rOutItemSet.Put( SvxDoubleItem( fMax, SCHATTR_AXIS_MAX ) ); } } break; case SCHATTR_AXIS_AUTO_MIN: - rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(rScale.Minimum) ) ); + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); break; case SCHATTR_AXIS_MIN: { double fMin = 0.0; - if( rScale.Minimum >>= fMin ) - rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) ); + if( aScale.Minimum >>= fMin ) + rOutItemSet.Put( SvxDoubleItem( fMin, SCHATTR_AXIS_MIN ) ); else if( m_pExplicitScale ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, SCHATTR_AXIS_MIN )); } break; case SCHATTR_AXIS_LOGARITHM: { - bool bValue = AxisHelper::isLogarithmic( rScale.Scaling ); + bool bValue = AxisHelper::isLogarithmic( aScale.Scaling ); rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); } break; case SCHATTR_AXIS_REVERSE: - rOutItemSet.Put( SfxBoolItem( nWhichId, (rScale.Orientation == AxisOrientation_REVERSE) )); + rOutItemSet.Put( SfxBoolItem( nWhichId, (aScale.Orientation == AxisOrientation_REVERSE) )); break; // Increment @@ -237,17 +237,17 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI { TimeInterval aTimeInterval; if( rTimeIncrement.MajorTimeInterval >>= aTimeInterval ) - rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, nWhichId )); + rOutItemSet.Put( SvxDoubleItem(aTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); else if( m_pExplicitIncrement ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->MajorTimeInterval.Number, SCHATTR_AXIS_STEP_MAIN )); } else { double fDistance = 1.0; if( rIncrement.Distance >>= fDistance ) - rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId )); + rOutItemSet.Put( SvxDoubleItem(fDistance, SCHATTR_AXIS_STEP_MAIN )); else if( m_pExplicitIncrement ) - rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, SCHATTR_AXIS_STEP_MAIN )); } break; @@ -306,7 +306,7 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI break; case SCHATTR_AXIS_TIME_RESOLUTION: { - tools::Long nTimeResolution=0; + sal_Int32 nTimeResolution=0; if( rTimeIncrement.TimeResolution >>= nTimeResolution ) rOutItemSet.Put( SfxInt32Item( nWhichId, nTimeResolution ) ); else if( m_pExplicitScale ) @@ -316,26 +316,26 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI case SCHATTR_AXIS_AUTO_ORIGIN: { - rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(rScale.Origin) ))); + rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); } break; case SCHATTR_AXIS_ORIGIN: { double fOrigin = 0.0; - if( !(rScale.Origin >>= fOrigin) ) + if( !(aScale.Origin >>= fOrigin) ) { if( m_pExplicitScale ) fOrigin = m_pExplicitScale->Origin; } - rOutItemSet.Put( SvxDoubleItem( fOrigin, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( fOrigin, SCHATTR_AXIS_ORIGIN )); } break; case SCHATTR_AXIS_POSITION: { css::chart::ChartAxisPosition eAxisPos( css::chart::ChartAxisPosition_ZERO ); - GetPropertySet()->getPropertyValue( "CrossoverPosition" ) >>= eAxisPos; + GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eAxisPos; rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(eAxisPos) ) ); } break; @@ -343,8 +343,8 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI case SCHATTR_AXIS_POSITION_VALUE: { double fValue = 0.0; - if( GetPropertySet()->getPropertyValue( "CrossoverValue" ) >>= fValue ) - rOutItemSet.Put( SvxDoubleItem( fValue, nWhichId ) ); + if( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fValue ) + rOutItemSet.Put( SvxDoubleItem( fValue, SCHATTR_AXIS_POSITION_VALUE ) ); } break; @@ -353,12 +353,12 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI //read only item //necessary tp display the crossing value with an appropriate format - Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); - Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); + rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); - sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( xCrossingMainAxis, xCooSys, m_xChartDoc); rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); @@ -366,13 +366,13 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI break; case SCHATTR_AXIS_SHIFTED_CATEGORY_POSITION: - rOutItemSet.Put(SfxBoolItem(nWhichId, rScale.ShiftedCategoryPosition)); + rOutItemSet.Put(SfxBoolItem(nWhichId, aScale.ShiftedCategoryPosition)); break; case SCHATTR_AXIS_LABEL_POSITION: { css::chart::ChartAxisLabelPosition ePos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); - GetPropertySet()->getPropertyValue( "LabelPosition" ) >>= ePos; + GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= ePos; rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); } break; @@ -380,7 +380,7 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI case SCHATTR_AXIS_MARK_POSITION: { css::chart::ChartAxisMarkPosition ePos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); - GetPropertySet()->getPropertyValue( "MarkPosition" ) >>= ePos; + GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= ePos; rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast<sal_Int32>(ePos) ) ); } break; @@ -390,9 +390,9 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI // convert double to int (times 100) double fVal = 0; - if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fVal ) + if( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fVal ) { - rOutItemSet.Put( SdrAngleItem( nWhichId, Degree100(static_cast< sal_Int32 >( + rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >( ::rtl::math::round( fVal * 100.0 )) ) )); } } @@ -402,11 +402,11 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI { if( m_pExplicitScale ) { - Reference< chart2::XCoordinateSystem > xCooSys( + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); - sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( m_xAxis, xCooSys, m_xChartDoc); rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); @@ -423,20 +423,21 @@ void AxisItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet & rOutI break; case SCHATTR_AXISTYPE: - rOutItemSet.Put( SfxInt32Item( nWhichId, rScale.AxisType )); + rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); break; case SCHATTR_AXIS_AUTO_DATEAXIS: - rOutItemSet.Put( SfxBoolItem( nWhichId, rScale.AutoDateAxis )); + rOutItemSet.Put( SfxBoolItem( nWhichId, aScale.AutoDateAxis )); break; case SCHATTR_AXIS_ALLOW_DATEAXIS: { - Reference< chart2::XCoordinateSystem > xCooSys( - AxisHelper::getCoordinateSystemOfAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; AxisHelper::getIndicesForAxis(m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ); - bool bChartTypeAllowsDateAxis = ChartTypeHelper::isSupportingDateAxis( AxisHelper::getChartTypeByIndex( xCooSys, 0 ), nDimensionIndex ); + auto xChartType = AxisHelper::getChartTypeByIndex(xCooSys, 0); + bool bChartTypeAllowsDateAxis = xChartType.is() ? xChartType->isSupportingDateAxis(nDimensionIndex) : true; rOutItemSet.Put( SfxBoolItem( nWhichId, bChartTypeAllowsDateAxis )); } break; @@ -616,7 +617,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet if( aScale.IncrementData.SubIncrements.hasElements() && aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) { - aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount.clear(); bSetScale = true; } if( aScale.TimeIncrement.MinorTimeInterval.hasValue() ) @@ -661,7 +662,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) { OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); - aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + aScale.IncrementData.SubIncrements.getArray()[0].IntervalCount = aValue; bSetScale = true; } } @@ -714,24 +715,24 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet if( !AxisHelper::isAxisPositioningEnabled() ) { //keep old and new settings for axis positioning in sync somehow - Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) { - Reference< beans::XPropertySet > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ), uno::UNO_QUERY ); + rtl::Reference< Axis > xCrossingMainAxis = AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ); if( xCrossingMainAxis.is() ) { double fValue = 0.0; if( aValue >>= fValue ) { - xCrossingMainAxis->setPropertyValue( "CrossoverPosition" , uno::Any( css::chart::ChartAxisPosition_VALUE )); - xCrossingMainAxis->setPropertyValue( "CrossoverValue" , uno::Any( fValue )); + xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_VALUE )); + xCrossingMainAxis->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); } else - xCrossingMainAxis->setPropertyValue( "CrossoverPosition" , uno::Any( css::chart::ChartAxisPosition_START )); + xCrossingMainAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( css::chart::ChartAxisPosition_START )); } } } @@ -746,21 +747,22 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet static_cast<css::chart::ChartAxisPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); css::chart::ChartAxisPosition eOldAxisPos( css::chart::ChartAxisPosition_ZERO ); - bool bPropExisted = ( GetPropertySet()->getPropertyValue( "CrossoverPosition" ) >>= eOldAxisPos ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOldAxisPos ); if( !bPropExisted || ( eOldAxisPos != eAxisPos )) { - GetPropertySet()->setPropertyValue( "CrossoverPosition" , uno::Any( eAxisPos )); + GetPropertySet()->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eAxisPos )); bChangedOtherwise = true; //move the parallel axes to the other side if necessary if( eAxisPos==css::chart::ChartAxisPosition_START || eAxisPos==css::chart::ChartAxisPosition_END ) { - Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY ); + rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); + rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); if( xParallelAxis.is() ) { css::chart::ChartAxisPosition eOtherPos; - if( xParallelAxis->getPropertyValue( "CrossoverPosition" ) >>= eOtherPos ) + if( xParallelAxis->getPropertyValue( u"CrossoverPosition"_ustr ) >>= eOtherPos ) { if( eOtherPos == eAxisPos ) { @@ -768,7 +770,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet (eAxisPos==css::chart::ChartAxisPosition_START) ? css::chart::ChartAxisPosition_END : css::chart::ChartAxisPosition_START; - xParallelAxis->setPropertyValue( "CrossoverPosition" , uno::Any( eOppositePos )); + xParallelAxis->setPropertyValue( u"CrossoverPosition"_ustr , uno::Any( eOppositePos )); } } } @@ -782,23 +784,23 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet double fValue = static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); double fOldValue = 0.0; - bool bPropExisted = ( GetPropertySet()->getPropertyValue( "CrossoverValue" ) >>= fOldValue ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"CrossoverValue"_ustr ) >>= fOldValue ); if( !bPropExisted || ( fOldValue != fValue )) { - GetPropertySet()->setPropertyValue( "CrossoverValue" , uno::Any( fValue )); + GetPropertySet()->setPropertyValue( u"CrossoverValue"_ustr , uno::Any( fValue )); bChangedOtherwise = true; //keep old and new settings for axis positioning in sync somehow { - Reference< chart2::XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( - m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, m_xChartDoc->getFirstChartDiagram() ) ); sal_Int32 nDimensionIndex=0; sal_Int32 nAxisIndex=0; if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 ) { - Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); + rtl::Reference< Axis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); if( xCrossingMainAxis.is() ) { ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() ); @@ -829,21 +831,22 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet static_cast<css::chart::ChartAxisLabelPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); css::chart::ChartAxisLabelPosition eOldPos( css::chart::ChartAxisLabelPosition_NEAR_AXIS ); - bool bPropExisted = ( GetPropertySet()->getPropertyValue( "LabelPosition" ) >>= eOldPos ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"LabelPosition"_ustr ) >>= eOldPos ); if( !bPropExisted || ( eOldPos != ePos )) { - GetPropertySet()->setPropertyValue( "LabelPosition" , uno::Any( ePos )); + GetPropertySet()->setPropertyValue( u"LabelPosition"_ustr , uno::Any( ePos )); bChangedOtherwise = true; //move the parallel axes to the other side if necessary if( ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START || ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_END ) { - Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY ); + rtl::Reference<Diagram> xDiagram = m_xChartDoc->getFirstChartDiagram(); + rtl::Reference< Axis > xParallelAxis = AxisHelper::getParallelAxis( m_xAxis, xDiagram ); if( xParallelAxis.is() ) { css::chart::ChartAxisLabelPosition eOtherPos; - if( xParallelAxis->getPropertyValue( "LabelPosition" ) >>= eOtherPos ) + if( xParallelAxis->getPropertyValue( u"LabelPosition"_ustr ) >>= eOtherPos ) { if( eOtherPos == ePos ) { @@ -851,7 +854,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet (ePos==css::chart::ChartAxisLabelPosition_OUTSIDE_START) ? css::chart::ChartAxisLabelPosition_OUTSIDE_END : css::chart::ChartAxisLabelPosition_OUTSIDE_START; - xParallelAxis->setPropertyValue( "LabelPosition" , uno::Any( eOppositePos )); + xParallelAxis->setPropertyValue( u"LabelPosition"_ustr , uno::Any( eOppositePos )); } } } @@ -866,11 +869,11 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet static_cast<css::chart::ChartAxisMarkPosition>(static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue()); css::chart::ChartAxisMarkPosition eOldPos( css::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); - bool bPropExisted = ( GetPropertySet()->getPropertyValue( "MarkPosition" ) >>= eOldPos ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue( u"MarkPosition"_ustr ) >>= eOldPos ); if( !bPropExisted || ( eOldPos != ePos )) { - GetPropertySet()->setPropertyValue( "MarkPosition" , uno::Any( ePos )); + GetPropertySet()->setPropertyValue( u"MarkPosition"_ustr , uno::Any( ePos )); bChangedOtherwise = true; } } @@ -878,17 +881,14 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet case SCHATTR_TEXT_DEGREES: { - // convert int to double (divided by 100) - double fVal = static_cast< double >( - static_cast< const SdrAngleItem & >( - rItemSet.Get( nWhichId )).GetValue().get()) / 100.0; + double fVal = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); double fOldVal = 0.0; bool bPropExisted = - ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal ); + ( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fOldVal ); if( ! bPropExisted || fOldVal != fVal ) { - GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fVal )); + GetPropertySet()->setPropertyValue( u"TextRotation"_ustr , uno::Any( fVal )); bChangedOtherwise = true; } } @@ -899,8 +899,7 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet if( m_pExplicitScale ) { bool bUseSourceFormat = - static_cast< const SfxBoolItem & >( - rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE )).GetValue(); + rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE ).GetValue(); if( ! bUseSourceFormat ) { @@ -942,11 +941,11 @@ bool AxisItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSet } else { - Reference< chart2::XCoordinateSystem > xCooSys( - AxisHelper::getCoordinateSystemOfAxis( - m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + rtl::Reference< BaseCoordinateSystem > xCooSys = + AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, m_xChartDoc->getFirstChartDiagram() ); - sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + sal_Int32 nFormatKey = ChartView::getExplicitNumberFormatKeyForAxis( m_xAxis, xCooSys, m_xChartDoc); aValue <<= nFormatKey; diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx index 49945b2f5803..a924d6db1803 100644 --- a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -33,7 +33,8 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart2/XFormattedString.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -73,11 +74,11 @@ CharacterPropertyItemConverter::CharacterPropertyItemConverter( CharacterPropertyItemConverter::CharacterPropertyItemConverter( const uno::Reference< beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, - const awt::Size* pRefSize, - const OUString & rRefSizePropertyName, + const std::optional<awt::Size>& pRefSize, + OUString aRefSizePropertyName, const uno::Reference< beans::XPropertySet > & rRefSizePropSet ) : ItemConverter( rPropertySet, rItemPool ), - m_aRefSizePropertyName( rRefSizePropertyName ), + m_aRefSizePropertyName(std::move( aRefSizePropertyName )), m_xRefSizePropSet( rRefSizePropSet.is() ? rRefSizePropSet : rPropertySet ) { if (pRefSize) @@ -87,7 +88,7 @@ CharacterPropertyItemConverter::CharacterPropertyItemConverter( CharacterPropertyItemConverter::~CharacterPropertyItemConverter() {} -const sal_uInt16 * CharacterPropertyItemConverter::GetWhichPairs() const +const WhichRangesContainer& CharacterPropertyItemConverter::GetWhichPairs() const { return nCharacterPropertyWhichPairs; } @@ -141,21 +142,21 @@ void CharacterPropertyItemConverter::FillSpecialItem( SvxUnderlineItem aItem(LINESTYLE_NONE, EE_CHAR_UNDERLINE); bool bModified = false; - uno::Any aValue( GetPropertySet()->getPropertyValue( "CharUnderline" )); + uno::Any aValue( GetPropertySet()->getPropertyValue( u"CharUnderline"_ustr )); if( aValue.hasValue()) { aItem.PutValue( aValue, MID_TL_STYLE ); bModified = true; } - aValue = GetPropertySet()->getPropertyValue( "CharUnderlineHasColor" ); + aValue = GetPropertySet()->getPropertyValue( u"CharUnderlineHasColor"_ustr ); if( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) ) { aItem.PutValue( aValue, MID_TL_HASCOLOR ); bModified = true; } - aValue = GetPropertySet()->getPropertyValue( "CharUnderlineColor" ); + aValue = GetPropertySet()->getPropertyValue( u"CharUnderlineColor"_ustr ); if( aValue.hasValue()) { aItem.PutValue( aValue, MID_TL_COLOR ); @@ -172,21 +173,21 @@ void CharacterPropertyItemConverter::FillSpecialItem( SvxOverlineItem aItem( LINESTYLE_NONE, EE_CHAR_OVERLINE ); bool bModified = false; - uno::Any aValue( GetPropertySet()->getPropertyValue( "CharOverline" ) ); + uno::Any aValue( GetPropertySet()->getPropertyValue( u"CharOverline"_ustr ) ); if ( aValue.hasValue() ) { aItem.PutValue( aValue, MID_TL_STYLE ); bModified = true; } - aValue = GetPropertySet()->getPropertyValue( "CharOverlineHasColor" ); + aValue = GetPropertySet()->getPropertyValue( u"CharOverlineHasColor"_ustr ); if ( aValue.hasValue() && *o3tl::doAccess<bool>(aValue) ) { aItem.PutValue( aValue, MID_TL_HASCOLOR ); bModified = true; } - aValue = GetPropertySet()->getPropertyValue( "CharOverlineColor" ); + aValue = GetPropertySet()->getPropertyValue( u"CharOverlineColor"_ustr ); if ( aValue.hasValue() ) { aItem.PutValue( aValue, MID_TL_COLOR ); @@ -376,27 +377,27 @@ bool CharacterPropertyItemConverter::ApplySpecialItem( if( rItem.QueryValue( aValue, MID_TL_STYLE )) { - if( aValue != GetPropertySet()->getPropertyValue( "CharUnderline" )) + if( aValue != GetPropertySet()->getPropertyValue( u"CharUnderline"_ustr )) { - GetPropertySet()->setPropertyValue( "CharUnderline" , aValue ); + GetPropertySet()->setPropertyValue( u"CharUnderline"_ustr , aValue ); bChanged = true; } } if( rItem.QueryValue( aValue, MID_TL_COLOR )) { - if( aValue != GetPropertySet()->getPropertyValue( "CharUnderlineColor" )) + if( aValue != GetPropertySet()->getPropertyValue( u"CharUnderlineColor"_ustr )) { - GetPropertySet()->setPropertyValue( "CharUnderlineColor" , aValue ); + GetPropertySet()->setPropertyValue( u"CharUnderlineColor"_ustr , aValue ); bChanged = true; } } if( rItem.QueryValue( aValue, MID_TL_HASCOLOR )) { - if( aValue != GetPropertySet()->getPropertyValue( "CharUnderlineHasColor" )) + if( aValue != GetPropertySet()->getPropertyValue( u"CharUnderlineHasColor"_ustr )) { - GetPropertySet()->setPropertyValue( "CharUnderlineHasColor" , aValue ); + GetPropertySet()->setPropertyValue( u"CharUnderlineHasColor"_ustr , aValue ); bChanged = true; } } @@ -409,27 +410,27 @@ bool CharacterPropertyItemConverter::ApplySpecialItem( if ( rItem.QueryValue( aValue, MID_TL_STYLE ) ) { - if ( aValue != GetPropertySet()->getPropertyValue( "CharOverline" ) ) + if ( aValue != GetPropertySet()->getPropertyValue( u"CharOverline"_ustr ) ) { - GetPropertySet()->setPropertyValue( "CharOverline" , aValue ); + GetPropertySet()->setPropertyValue( u"CharOverline"_ustr , aValue ); bChanged = true; } } if ( rItem.QueryValue( aValue, MID_TL_COLOR ) ) { - if ( aValue != GetPropertySet()->getPropertyValue( "CharOverlineColor" ) ) + if ( aValue != GetPropertySet()->getPropertyValue( u"CharOverlineColor"_ustr ) ) { - GetPropertySet()->setPropertyValue( "CharOverlineColor" , aValue ); + GetPropertySet()->setPropertyValue( u"CharOverlineColor"_ustr , aValue ); bChanged = true; } } if ( rItem.QueryValue( aValue, MID_TL_HASCOLOR ) ) { - if ( aValue != GetPropertySet()->getPropertyValue( "CharOverlineHasColor" ) ) + if ( aValue != GetPropertySet()->getPropertyValue( u"CharOverlineHasColor"_ustr ) ) { - GetPropertySet()->setPropertyValue( "CharOverlineHasColor" , aValue ); + GetPropertySet()->setPropertyValue( u"CharOverlineHasColor"_ustr , aValue ); bChanged = true; } } diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx index 589972740e86..aa8f21231120 100644 --- a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -25,9 +25,12 @@ #include <CharacterPropertyItemConverter.hxx> #include <StatisticsItemConverter.hxx> #include <SeriesOptionsItemConverter.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> -#include <DiagramHelper.hxx> -#include <ChartModelHelper.hxx> +#include <DataSeriesProperties.hxx> +#include <Diagram.hxx> +#include <ChartModel.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <unonames.hxx> @@ -37,7 +40,8 @@ #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/XModel.hpp> + +#include <comphelper/sequence.hxx> #include <svx/xflclit.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> @@ -46,9 +50,8 @@ #include <editeng/brushitem.hxx> #include <svl/ilstitem.hxx> #include <svx/sdangitm.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/graph.hxx> -#include <oox/helper/containerhelper.hxx> #include <rtl/math.hxx> #include <svx/tabline.hxx> @@ -57,6 +60,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; namespace chart::wrapper { @@ -102,7 +106,7 @@ bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSe bool bChanged = false; if( !xPropertySet.is() ) return bChanged; - OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" ); + OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr; sal_uInt16 nSourceWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE; if( rItemSet.GetItemState( nSourceWhich ) != SfxItemState::SET ) @@ -128,11 +132,11 @@ bool lcl_NumberFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxItemSe uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) ); if( bOverwriteAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY); + rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if( aValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( aPropertyName, aOldValue ) ) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( aPropertyName, aValue ); bChanged = true; } } @@ -149,7 +153,7 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxIte bool bChanged = false; if( !xPropertySet.is() ) return bChanged; - OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(CHART_UNONAME_NUMFMT) : OUString( "PercentageNumberFormat" ); + OUString aPropertyName = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr; sal_uInt16 nFormatWhich = (nWhichId==SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE; if( rItemSet.GetItemState( nWhichId ) != SfxItemState::SET ) @@ -176,11 +180,11 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxIte uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) ); if( bOverwriteAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY); + rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if( aNewValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( aPropertyName, aOldValue ) ) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( aPropertyName, aNewValue ); bChanged = true; } } @@ -196,15 +200,14 @@ bool lcl_UseSourceFormatFromItemToPropertySet( sal_uInt16 nWhichId, const SfxIte } // anonymous namespace DataPointItemConverter::DataPointItemConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, const uno::Reference< uno::XComponentContext > & xContext, const uno::Reference< beans::XPropertySet > & rPropertySet, - const uno::Reference< XDataSeries > & xSeries, + const rtl::Reference< DataSeries > & xSeries, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference<lang::XMultiServiceFactory>& xNamedPropertyContainerFactory, GraphicObjectType eMapTo, - const awt::Size* pRefSize, + const std::optional<awt::Size>& pRefSize, bool bDataSeries, bool bUseSpecialFillColor, sal_Int32 nSpecialFillColor, @@ -219,37 +222,38 @@ DataPointItemConverter::DataPointItemConverter( m_nSpecialFillColor(ColorTransparency, nSpecialFillColor), m_nNumberFormat(nNumberFormat), m_nPercentNumberFormat(nPercentNumberFormat), - m_aAvailableLabelPlacements(), m_bForbidPercentValue(true), m_bHideLegendEntry(false), m_nPointIndex(nPointIndex), m_xSeries(xSeries) { m_aConverters.emplace_back( new GraphicPropertyItemConverter( - rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo )); - m_aConverters.emplace_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); + rPropertySet, rItemPool, rDrawModel, xChartModel, eMapTo )); + m_aConverters.emplace_back( new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); if( bDataSeries ) { + assert(dynamic_cast<DataSeries*>(rPropertySet.get())); m_aConverters.emplace_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool )); - m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool )); + m_aConverters.emplace_back( new SeriesOptionsItemConverter( xChartModel, xContext, + dynamic_cast<DataSeries*>(rPropertySet.get()), rItemPool )); } - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); - uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); bool bFound = false; bool bAmbiguous = false; - bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + bool bSwapXAndY = xDiagram->getVertical( bFound, bAmbiguous ); m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, bSwapXAndY, xSeries ); - m_bForbidPercentValue = ChartTypeHelper::getAxisType( xChartType, 0 ) != AxisType::CATEGORY; + m_bForbidPercentValue = xChartType.is() ? xChartType->getAxisType(0) != AxisType::CATEGORY : false; if (bDataSeries) return; - uno::Reference<beans::XPropertySet> xSeriesProp(xSeries, uno::UNO_QUERY); uno::Sequence<sal_Int32> deletedLegendEntriesSeq; - xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq; - for (auto& deletedLegendEntry : deletedLegendEntriesSeq) + // "DeletedLegendEntries" + xSeries->getFastPropertyValue(PROP_DATASERIES_DELETED_LEGEND_ENTRIES) >>= deletedLegendEntriesSeq; + for (const auto& deletedLegendEntry : deletedLegendEntriesSeq) { if (nPointIndex == deletedLegendEntry) { @@ -289,7 +293,7 @@ bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * DataPointItemConverter::GetWhichPairs() const +const WhichRangesContainer& DataPointItemConverter::GetWhichPairs() const { // must span all used items! if( m_bDataSeries ) @@ -336,12 +340,12 @@ bool DataPointItemConverter::ApplySpecialItem( rValue = rItem.GetValue(); if( m_bOverwriteLabelsForAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( bOldValue != bool(rValue) || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, CHART_UNONAME_LABEL , aOldValue ) ) + xSeries->hasAttributedDataPointDifferentValue( CHART_UNONAME_LABEL , aOldValue ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL , uno::Any( aLabel ) ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_LABEL , uno::Any( aLabel ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); bChanged = true; } } @@ -374,20 +378,20 @@ bool DataPointItemConverter::ApplySpecialItem( try { OUString aOldValue; - GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aOldValue; + GetPropertySet()->getPropertyValue( u"LabelSeparator"_ustr ) >>= aOldValue; if( m_bOverwriteLabelsForAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( aOldValue != aNewValue || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelSeparator" , uno::Any( aOldValue ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"LabelSeparator"_ustr , uno::Any( aOldValue ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelSeparator" , uno::Any( aNewValue ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"LabelSeparator"_ustr , uno::Any( aNewValue ) ); bChanged = true; } } else if( aOldValue != aNewValue ) { - GetPropertySet()->setPropertyValue( "LabelSeparator" , uno::Any( aNewValue )); + GetPropertySet()->setPropertyValue( u"LabelSeparator"_ustr , uno::Any( aNewValue )); bChanged = true; } } @@ -405,20 +409,20 @@ bool DataPointItemConverter::ApplySpecialItem( { bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); bool bOld = false; - GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld; + GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bOld; if( m_bOverwriteLabelsForAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( bOld!=bNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::Any( bNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"TextWordWrap"_ustr, uno::Any( bNew ) ); bChanged = true; } } else if( bOld!=bNew ) { - GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew )); + GetPropertySet()->setPropertyValue( u"TextWordWrap"_ustr, uno::Any( bNew )); bChanged = true; } } @@ -437,21 +441,22 @@ bool DataPointItemConverter::ApplySpecialItem( sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); sal_Int32 nOld = -1; RelativePosition aCustomLabelPosition; - GetPropertySet()->getPropertyValue("LabelPlacement") >>= nOld; + GetPropertySet()->getPropertyValue(u"LabelPlacement"_ustr) >>= nOld; if( m_bOverwriteLabelsForAttributedDataPointsAlso ) { - Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if( nOld!=nNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "LabelPlacement" , uno::Any( nOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"LabelPlacement"_ustr , uno::Any( nOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "LabelPlacement" , uno::Any( nNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"LabelPlacement"_ustr , uno::Any( nNew ) ); bChanged = true; } } - else if( nOld!=nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) ) + else if( nOld!=nNew || (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition) ) { - GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew)); - GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any()); + GetPropertySet()->setPropertyValue(u"LabelPlacement"_ustr, uno::Any(nNew)); + GetPropertySet()->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any()); + GetPropertySet()->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any()); bChanged = true; } } @@ -469,7 +474,7 @@ bool DataPointItemConverter::ApplySpecialItem( rItemSet.Get( nWhichId )).GetValue(); chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol; + GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol; sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol ); if( nStyle != nOldStyle ) @@ -496,9 +501,9 @@ bool DataPointItemConverter::ApplySpecialItem( } if( bDeleteSymbol ) - GetPropertySet()->setPropertyValue( "Symbol" , uno::Any()); + GetPropertySet()->setPropertyValue( u"Symbol"_ustr , uno::Any()); else - GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol )); + GetPropertySet()->setPropertyValue( u"Symbol"_ustr , uno::Any( aSymbol )); bChanged = true; } } @@ -510,14 +515,14 @@ bool DataPointItemConverter::ApplySpecialItem( rItemSet.Get( nWhichId )).GetSize(); chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol; + GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol; if( aSize.getWidth() != aSymbol.Size.Width || aSize.getHeight() != aSymbol.Size.Height ) { aSymbol.Size.Width = aSize.getWidth(); aSymbol.Size.Height = aSize.getHeight(); - GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol )); + GetPropertySet()->setPropertyValue( u"Symbol"_ustr , uno::Any( aSymbol )); bChanged = true; } } @@ -536,11 +541,11 @@ bool DataPointItemConverter::ApplySpecialItem( { aXGraphicAny <<= xGraphic; chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol; + GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol; if( aSymbol.Graphic != xGraphic ) { - aSymbol.Graphic = xGraphic; - GetPropertySet()->setPropertyValue( "Symbol" , uno::Any( aSymbol )); + aSymbol.Graphic = std::move(xGraphic); + GetPropertySet()->setPropertyValue( u"Symbol"_ustr , uno::Any( aSymbol )); bChanged = true; } } @@ -550,16 +555,14 @@ bool DataPointItemConverter::ApplySpecialItem( case SCHATTR_TEXT_DEGREES: { - double fValue = static_cast< double >( - static_cast< const SdrAngleItem & >( - rItemSet.Get( nWhichId )).GetValue().get()) / 100.0; + double fValue = toDegrees(rItemSet.Get(SCHATTR_TEXT_DEGREES).GetValue()); double fOldValue = 0.0; bool bPropExisted = - ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldValue ); + ( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fOldValue ); if( ! bPropExisted || fOldValue != fValue ) { - GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fValue )); + GetPropertySet()->setPropertyValue( u"TextRotation"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -571,17 +574,18 @@ bool DataPointItemConverter::ApplySpecialItem( if (bHideLegendEntry != m_bHideLegendEntry) { uno::Sequence<sal_Int32> deletedLegendEntriesSeq; - Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); - xSeriesProp->getPropertyValue("DeletedLegendEntries") >>= deletedLegendEntriesSeq; + // "DeletedLegendEntries" + m_xSeries->getFastPropertyValue(PROP_DATASERIES_DELETED_LEGEND_ENTRIES) >>= deletedLegendEntriesSeq; std::vector<sal_Int32> deletedLegendEntries; - for (auto& deletedLegendEntry : deletedLegendEntriesSeq) + for (const auto& deletedLegendEntry : deletedLegendEntriesSeq) { if (bHideLegendEntry || m_nPointIndex != deletedLegendEntry) deletedLegendEntries.push_back(deletedLegendEntry); } if (bHideLegendEntry) deletedLegendEntries.push_back(m_nPointIndex); - xSeriesProp->setPropertyValue("DeletedLegendEntries", uno::makeAny(oox::ContainerHelper::vectorToSequence(deletedLegendEntries))); + // "DeletedLegendEntries" + m_xSeries->setFastPropertyValue(PROP_DATASERIES_DELETED_LEGEND_ENTRIES, uno::Any(comphelper::containerToSequence(deletedLegendEntries))); } } break; @@ -592,10 +596,9 @@ bool DataPointItemConverter::ApplySpecialItem( { bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue(); bool bOld = true; - Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); - if( (xSeriesProp->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew ) + if( (m_xSeries->getFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES) >>= bOld) && bOld != bNew ) { - xSeriesProp->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew)); + m_xSeries->setFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, uno::Any(bNew)); bChanged = true; } } @@ -631,13 +634,13 @@ void DataPointItemConverter::FillSpecialItem( rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); - if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + DataSeries* pDataSeries = m_bOverwriteLabelsForAttributedDataPointsAlso + ? dynamic_cast<DataSeries*>(GetPropertySet().get()) + : nullptr; + if (pDataSeries && pDataSeries->hasAttributedDataPointDifferentValue( + CHART_UNONAME_LABEL, uno::Any(aLabel))) { - if( DataSeriesHelper::hasAttributedDataPointDifferentValue( - Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL , uno::Any(aLabel) ) ) - { - rOutItemSet.InvalidateItem(nWhichId); - } + rOutItemSet.InvalidateItem(nWhichId); } } } @@ -655,7 +658,7 @@ void DataPointItemConverter::FillSpecialItem( case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: { sal_Int32 nKey = 0; - if( !(GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ) >>= nKey) ) + if( !(GetPropertySet()->getPropertyValue( u"PercentageNumberFormat"_ustr ) >>= nKey) ) nKey = m_nPercentNumberFormat; rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey )); } @@ -687,7 +690,7 @@ void DataPointItemConverter::FillSpecialItem( { TOOLS_WARN_EXCEPTION("chart2", ""); } - bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( "PercentageNumberFormat" ).hasValue() && !bUseSourceFormat; + bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue( u"PercentageNumberFormat"_ustr ).hasValue() && !bUseSourceFormat; rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet )); } break; @@ -697,7 +700,7 @@ void DataPointItemConverter::FillSpecialItem( try { OUString aValue; - GetPropertySet()->getPropertyValue( "LabelSeparator" ) >>= aValue; + GetPropertySet()->getPropertyValue( u"LabelSeparator"_ustr ) >>= aValue; rOutItemSet.Put( SfxStringItem( nWhichId, aValue )); } catch( const uno::Exception& ) @@ -712,7 +715,7 @@ void DataPointItemConverter::FillSpecialItem( try { bool bValue = false; - GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue; + GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bValue; rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); } catch( const uno::Exception& ) @@ -728,9 +731,9 @@ void DataPointItemConverter::FillSpecialItem( { sal_Int32 nPlacement=0; RelativePosition aCustomLabelPosition; - if( !m_bOverwriteLabelsForAttributedDataPointsAlso && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition) ) + if( !m_bOverwriteLabelsForAttributedDataPointsAlso && (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition) ) rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM)); - else if( GetPropertySet()->getPropertyValue( "LabelPlacement" ) >>= nPlacement ) + else if( GetPropertySet()->getPropertyValue( u"LabelPlacement"_ustr ) >>= nPlacement ) rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement )); else if( m_aAvailableLabelPlacements.hasElements() ) rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] )); @@ -759,8 +762,7 @@ void DataPointItemConverter::FillSpecialItem( try { bool bValue = true; - Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); - if( xSeriesProp->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue ) + if( m_xSeries->getFastPropertyValue( PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES ) >>= bValue ) rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); } catch (const uno::Exception&) @@ -773,7 +775,7 @@ void DataPointItemConverter::FillSpecialItem( case SCHATTR_STYLE_SYMBOL: { chart2::Symbol aSymbol; - if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol ) + if( GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol ) rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) )); } break; @@ -781,7 +783,7 @@ void DataPointItemConverter::FillSpecialItem( case SCHATTR_SYMBOL_SIZE: { chart2::Symbol aSymbol; - if( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol ) + if( GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol ) rOutItemSet.Put( SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) )); } @@ -790,7 +792,7 @@ void DataPointItemConverter::FillSpecialItem( case SCHATTR_SYMBOL_BRUSH: { chart2::Symbol aSymbol; - if(( GetPropertySet()->getPropertyValue( "Symbol" ) >>= aSymbol ) + if(( GetPropertySet()->getPropertyValue( u"Symbol"_ustr ) >>= aSymbol ) && aSymbol.Graphic.is() ) { rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH )); @@ -802,9 +804,9 @@ void DataPointItemConverter::FillSpecialItem( { double fValue = 0; - if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fValue ) + if( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fValue ) { - rOutItemSet.Put( SdrAngleItem( nWhichId, Degree100(static_cast< sal_Int32 >( + rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >( ::rtl::math::round( fValue * 100.0 ) ) ))); } } diff --git a/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx new file mode 100644 index 000000000000..e152bf298dfc --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/DataTableItemConverter.cxx @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include <DataTableItemConverter.hxx> +#include <ItemPropertyMap.hxx> +#include <CharacterPropertyItemConverter.hxx> +#include <GraphicPropertyItemConverter.hxx> +#include <chartview/ChartSfxItemIds.hxx> +#include "SchWhichPairs.hxx" +#include <ChartModel.hxx> +#include <memory> + +using namespace css; + +namespace chart::wrapper +{ +namespace +{ +ItemPropertyMapType& lclDataTablePropertyMap() +{ + static ItemPropertyMapType aPropertyMap{ + { SCHATTR_DATA_TABLE_HORIZONTAL_BORDER, { "HBorder", 0 } }, + { SCHATTR_DATA_TABLE_VERTICAL_BORDER, { "VBorder", 0 } }, + { SCHATTR_DATA_TABLE_OUTLINE, { "Outline", 0 } }, + { SCHATTR_DATA_TABLE_KEYS, { "Keys", 0 } }, + }; + return aPropertyMap; +}; +} + +DataTableItemConverter::DataTableItemConverter( + const uno::Reference<beans::XPropertySet>& rPropertySet, SfxItemPool& rItemPool, + SdrModel& rDrawModel, const rtl::Reference<::chart::ChartModel>& xChartDoc) + : ItemConverter(rPropertySet, rItemPool) +{ + m_aConverters.emplace_back(new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, xChartDoc, GraphicObjectType::LineProperties)); + m_aConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool)); +} + +DataTableItemConverter::~DataTableItemConverter() = default; + +void DataTableItemConverter::FillItemSet(SfxItemSet& rOutItemSet) const +{ + for (const auto& pConv : m_aConverters) + { + pConv->FillItemSet(rOutItemSet); + } + + // own items + ItemConverter::FillItemSet(rOutItemSet); +} + +bool DataTableItemConverter::ApplyItemSet(const SfxItemSet& rItemSet) +{ + bool bResult = false; + + for (const auto& pConv : m_aConverters) + { + bResult = pConv->ApplyItemSet(rItemSet) || bResult; + } + + // own items + return ItemConverter::ApplyItemSet(rItemSet) || bResult; +} + +const WhichRangesContainer& DataTableItemConverter::GetWhichPairs() const +{ + return nDataTableWhichPairs; +} + +bool DataTableItemConverter::GetItemProperty(tWhichIdType nWhichId, + tPropertyNameWithMemberId& rOutProperty) const +{ + ItemPropertyMapType& rMap(lclDataTablePropertyMap()); + auto aIt = rMap.find(nWhichId); + if (aIt == rMap.cend()) + return false; + + rOutProperty = (*aIt).second; + + return true; +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx index 5a8114c215c9..f97ae631ee02 100644 --- a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx @@ -22,6 +22,7 @@ #include <StatisticsHelper.hxx> #include <GraphicPropertyItemConverter.hxx> +#include <ChartModel.hxx> #include <svl/stritem.hxx> #include <svx/chrtitem.hxx> @@ -30,7 +31,8 @@ #include <com/sun/star/chart2/XInternalDataProvider.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -45,8 +47,8 @@ void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBar try { - xErrorBarProp->getPropertyValue( "PositiveError" ) >>= rOutPosError; - xErrorBarProp->getPropertyValue( "NegativeError" ) >>= rOutNegError; + xErrorBarProp->getPropertyValue( u"PositiveError"_ustr ) >>= rOutPosError; + xErrorBarProp->getPropertyValue( u"NegativeError"_ustr ) >>= rOutNegError; } catch( const uno::Exception & ) { @@ -63,8 +65,8 @@ void lcl_getErrorIndicatorValues( try { - xErrorBarProp->getPropertyValue( "ShowPositiveError" ) >>= rOutShowPosError; - xErrorBarProp->getPropertyValue( "ShowNegativeError" ) >>= rOutShowNegError; + xErrorBarProp->getPropertyValue( u"ShowPositiveError"_ustr ) >>= rOutShowPosError; + xErrorBarProp->getPropertyValue( u"ShowNegativeError"_ustr ) >>= rOutShowNegError; } catch( const uno::Exception & ) { @@ -78,17 +80,16 @@ namespace chart::wrapper { ErrorBarItemConverter::ErrorBarItemConverter( - const uno::Reference< frame::XModel > & xModel, + const rtl::Reference< ChartModel > & xChartModel, const uno::Reference< beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) : + SdrModel& rDrawModel ) : ItemConverter( rPropertySet, rItemPool ), m_spGraphicConverter( std::make_shared<GraphicPropertyItemConverter>( rPropertySet, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, + xChartModel, GraphicObjectType::LineProperties )), - m_xModel( xModel ) + m_xModel(xChartModel) {} ErrorBarItemConverter::~ErrorBarItemConverter() @@ -110,7 +111,7 @@ bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * ErrorBarItemConverter::GetWhichPairs() const +const WhichRangesContainer& ErrorBarItemConverter::GetWhichPairs() const { // must span all used items! return nErrorBarWhichPairs; @@ -169,7 +170,7 @@ bool ErrorBarItemConverter::ApplySpecialItem( nStyle = css::chart::ErrorBarStyle::FROM_DATA; break; } - xErrorBarProp->setPropertyValue( "ErrorBarStyle" , uno::Any( nStyle )); + xErrorBarProp->setPropertyValue( u"ErrorBarStyle"_ustr , uno::Any( nStyle )); bChanged = true; } } @@ -190,8 +191,8 @@ bool ErrorBarItemConverter::ApplySpecialItem( if( ! ( ::rtl::math::approxEqual( fPos, fValue ) && ::rtl::math::approxEqual( fNeg, fValue ))) { - xErrorBarProp->setPropertyValue( "PositiveError" , uno::Any( fValue )); - xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"PositiveError"_ustr , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"NegativeError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -207,7 +208,7 @@ bool ErrorBarItemConverter::ApplySpecialItem( if( ! ::rtl::math::approxEqual( fPos, fValue )) { - GetPropertySet()->setPropertyValue( "PositiveError" , uno::Any( fValue )); + GetPropertySet()->setPropertyValue( u"PositiveError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -225,7 +226,7 @@ bool ErrorBarItemConverter::ApplySpecialItem( if( ! ::rtl::math::approxEqual( fNeg, fValue )) { - xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"NegativeError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -248,8 +249,8 @@ bool ErrorBarItemConverter::ApplySpecialItem( if( bShowPos != bNewIndPos || bShowNeg != bNewIndNeg ) { - xErrorBarProp->setPropertyValue( "ShowPositiveError" , uno::Any( bNewIndPos )); - xErrorBarProp->setPropertyValue( "ShowNegativeError" , uno::Any( bNewIndNeg )); + xErrorBarProp->setPropertyValue( u"ShowPositiveError"_ustr , uno::Any( bNewIndPos )); + xErrorBarProp->setPropertyValue( u"ShowNegativeError"_ustr , uno::Any( bNewIndNeg )); bChanged = true; } } @@ -326,7 +327,7 @@ void ErrorBarItemConverter::FillSpecialItem( uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); sal_Int32 nStyle = 0; - if( xErrorBarProp->getPropertyValue( "ErrorBarStyle" ) >>= nStyle ) + if( xErrorBarProp->getPropertyValue( u"ErrorBarStyle"_ustr ) >>= nStyle ) { switch( nStyle ) { @@ -346,6 +347,8 @@ void ErrorBarItemConverter::FillSpecialItem( eErrorKind = SvxChartKindError::StdError; break; case css::chart::ErrorBarStyle::FROM_DATA: eErrorKind = SvxChartKindError::Range; break; + default: + eErrorKind = SvxChartKindError::NONE; break; } } rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR )); @@ -356,7 +359,7 @@ void ErrorBarItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_PERCENT )); } break; @@ -364,7 +367,7 @@ void ErrorBarItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_BIGERROR )); } break; @@ -372,7 +375,7 @@ void ErrorBarItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( fPos, SCHATTR_STAT_CONSTPLUS )); } break; @@ -380,7 +383,7 @@ void ErrorBarItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( fNeg, SCHATTR_STAT_CONSTMINUS )); } break; diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx index f553ff16bc34..301abe03397c 100644 --- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -19,10 +19,12 @@ #include <GraphicPropertyItemConverter.hxx> #include "SchWhichPairs.hxx" +#include <ChartModel.hxx> #include <ItemPropertyMap.hxx> #include <PropertyHelper.hxx> #include <CommonConverters.hxx> #include <editeng/memberids.h> +#include <svx/chrtitem.hxx> #include <svx/unomid.hxx> #include <svx/xflbmtit.hxx> #include <svx/xflbstit.hxx> @@ -39,7 +41,8 @@ #include <com/sun/star/drawing/BitmapMode.hpp> #include <com/sun/star/container/XNameAccess.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -137,37 +140,42 @@ GraphicPropertyItemConverter::GraphicPropertyItemConverter( beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + rtl::Reference< ChartModel > xChartModel, GraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) : ItemConverter( rPropertySet, rItemPool ), m_GraphicObjectType( eObjectType ), m_rDrawModel( rDrawModel ), - m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory ) -{} + m_xChartModel(std::move( xChartModel )) +{ +} GraphicPropertyItemConverter::~GraphicPropertyItemConverter() {} -const sal_uInt16 * GraphicPropertyItemConverter::GetWhichPairs() const +const WhichRangesContainer& GraphicPropertyItemConverter::GetWhichPairs() const { - const sal_uInt16 * pResult = nullptr; - switch( m_GraphicObjectType ) { case GraphicObjectType::LineDataPoint: case GraphicObjectType::FilledDataPoint: - pResult = nRowWhichPairs; break; + return nRowWhichPairs; case GraphicObjectType::LineProperties: - pResult = nLinePropertyWhichPairs; break; + return nLinePropertyWhichPairs; case GraphicObjectType::LineAndFillProperties: - pResult = nLineAndFillPropertyWhichPairs; break; + return nLineAndFillPropertyWhichPairs; } - return pResult; + static const WhichRangesContainer empty; + return empty; } bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const { + if (nWhichId == SCHATTR_COLOR_PALETTE) + { + return false; + } + ItemPropertyMapType::const_iterator aEndIt; ItemPropertyMapType::const_iterator aIt; @@ -217,7 +225,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( case XATTR_FILLBMP_STRETCH: { drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT; - if( GetPropertySet()->getPropertyValue( "FillBitmapMode" ) >>= aMode ) + if( GetPropertySet()->getPropertyValue( u"FillBitmapMode"_ustr ) >>= aMode ) { rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT )); rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH )); @@ -232,8 +240,8 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "TransparencyGradientName" ) - : OUString( "FillTransparenceGradientName" ); + ? u"TransparencyGradientName"_ustr + : u"FillTransparenceGradientName"_ustr; uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName )); if( aValue.hasValue()) @@ -242,7 +250,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( aItem.PutValue( aValue, MID_NAME ); lcl_SetContentForNamedProperty( - m_xNamedPropertyTableFactory, "com.sun.star.drawing.TransparencyGradientTable" , + m_xChartModel, u"com.sun.star.drawing.TransparencyGradientTable"_ustr , aItem, MID_FILLGRADIENT ); // this is important to enable the item @@ -267,8 +275,8 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "GradientStepCount" ) - : OUString( "FillGradientStepCount" ); + ? u"GradientStepCount"_ustr + : u"FillGradientStepCount"_ustr; uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) ); if( hasLongOrShortValue(aValue) ) @@ -283,19 +291,19 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "BorderDashName" ) - : OUString( "LineDashName" ); + ? u"BorderDashName"_ustr + : u"LineDashName"_ustr; XLineDashItem aItem; aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); lcl_SetContentForNamedProperty( - m_xNamedPropertyTableFactory, "com.sun.star.drawing.DashTable" , + m_xChartModel, u"com.sun.star.drawing.DashTable"_ustr , aItem, MID_LINEDASH ); // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - std::unique_ptr<XLineDashItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XLineDashItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( std::move(pItemToPut) ); @@ -309,19 +317,19 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "GradientName" ) - : OUString( "FillGradientName" ); + ? u"GradientName"_ustr + : u"FillGradientName"_ustr; XFillGradientItem aItem; aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); lcl_SetContentForNamedProperty( - m_xNamedPropertyTableFactory, "com.sun.star.drawing.GradientTable" , + m_xChartModel, u"com.sun.star.drawing.GradientTable"_ustr , aItem, MID_FILLGRADIENT ); // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - std::unique_ptr<XFillGradientItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillGradientItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); if(pItemToPut) rOutItemSet.Put(std::move(pItemToPut) ); @@ -335,19 +343,19 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "HatchName" ) - : OUString( "FillHatchName" ); + ? u"HatchName"_ustr + : u"FillHatchName"_ustr; XFillHatchItem aItem; aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); lcl_SetContentForNamedProperty( - m_xNamedPropertyTableFactory, "com.sun.star.drawing.HatchTable" , + m_xChartModel, u"com.sun.star.drawing.HatchTable"_ustr , aItem, MID_FILLHATCH ); // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - std::unique_ptr<XFillHatchItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillHatchItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( std::move(pItemToPut) ); @@ -360,15 +368,15 @@ void GraphicPropertyItemConverter::FillSpecialItem( if( lcl_supportsFillProperties( m_GraphicObjectType )) { XFillBitmapItem aItem; - aItem.PutValue( GetPropertySet()->getPropertyValue( "FillBitmapName" ), MID_NAME ); + aItem.PutValue( GetPropertySet()->getPropertyValue( u"FillBitmapName"_ustr ), MID_NAME ); lcl_SetContentForNamedProperty( - m_xNamedPropertyTableFactory, "com.sun.star.drawing.BitmapTable" , + m_xChartModel, u"com.sun.star.drawing.BitmapTable"_ustr , aItem, MID_BITMAP ); // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - std::unique_ptr<XFillBitmapItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillBitmapItem> pItemToPut = aItem.checkForUniqueItem( m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( std::move(pItemToPut) ); @@ -383,10 +391,10 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "BorderTransparency" ) + ? u"BorderTransparency"_ustr : (m_GraphicObjectType == GraphicObjectType::LineDataPoint) - ? OUString( "Transparency" ) - : OUString( "LineTransparence" ); + ? u"Transparency"_ustr + : u"LineTransparence"_ustr; XLineTransparenceItem aItem; aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), 0 ); @@ -402,8 +410,8 @@ void GraphicPropertyItemConverter::FillSpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "Transparency" ) - : OUString( "FillTransparence" ); + ? u"Transparency"_ustr + : u"FillTransparence"_ustr; XFillTransparenceItem aItem; aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), 0 ); @@ -426,7 +434,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( case XATTR_FILLBMP_STRETCH: if( lcl_supportsFillProperties( m_GraphicObjectType )) { - static const OUStringLiteral aModePropName(u"FillBitmapMode"); + static constexpr OUString aModePropName(u"FillBitmapMode"_ustr); bool bStretched = rItemSet.Get( XATTR_FILLBMP_STRETCH ).GetValue(); drawing::BitmapMode aMode = (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT); @@ -448,7 +456,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( case XATTR_FILLBMP_TILE: if( lcl_supportsFillProperties( m_GraphicObjectType )) { - static const OUStringLiteral aModePropName(u"FillBitmapMode"); + static constexpr OUString aModePropName(u"FillBitmapMode"_ustr); bool bTiled = rItemSet.Get( XATTR_FILLBMP_TILE ).GetValue(); drawing::BitmapMode aMode = (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT); @@ -469,8 +477,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "TransparencyGradientName" ) - : OUString( "FillTransparenceGradientName" ); + ? u"TransparencyGradientName"_ustr + : u"FillTransparenceGradientName"_ustr; const XFillFloatTransparenceItem & rItem = static_cast< const XFillFloatTransparenceItem & >( @@ -486,7 +494,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( OUString aPreferredName; aValue >>= aPreferredName; aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable( - aGradient, m_xNamedPropertyTableFactory, aPreferredName ); + aGradient, m_xChartModel, aPreferredName ); if( aValue != GetPropertySet()->getPropertyValue( aPropName )) { @@ -520,8 +528,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "GradientStepCount" ) - : OUString( "FillGradientStepCount" ); + ? u"GradientStepCount"_ustr + : u"FillGradientStepCount"_ustr; sal_Int16 nStepCount = static_cast< const XGradientStepCountItem & >( rItemSet.Get( nWhichId )).GetValue(); @@ -540,8 +548,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "BorderDashName" ) - : OUString( "LineDashName" ); + ? u"BorderDashName"_ustr + : u"LineDashName"_ustr; const XLineDashItem & rItem = static_cast< const XLineDashItem & >( @@ -557,7 +565,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( OUString aPreferredName; aValue >>= aPreferredName; aValue <<= PropertyHelper::addLineDashUniqueNameToTable( - aLineDash, m_xNamedPropertyTableFactory, aPreferredName ); + aLineDash, m_xChartModel, aPreferredName ); GetPropertySet()->setPropertyValue( aPropName, aValue ); bChanged = true; @@ -572,8 +580,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "GradientName" ) - : OUString( "FillGradientName" ); + ? u"GradientName"_ustr + : u"FillGradientName"_ustr; const XFillGradientItem & rItem = static_cast< const XFillGradientItem & >( @@ -589,7 +597,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( OUString aPreferredName; aValue >>= aPreferredName; aValue <<= PropertyHelper::addGradientUniqueNameToTable( - aGradient, m_xNamedPropertyTableFactory, aPreferredName ); + aGradient, m_xChartModel, aPreferredName ); GetPropertySet()->setPropertyValue( aPropName, aValue ); bChanged = true; @@ -605,8 +613,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "HatchName" ) - : OUString( "FillHatchName" ); + ? u"HatchName"_ustr + : u"FillHatchName"_ustr; const XFillHatchItem & rItem = static_cast< const XFillHatchItem & >( @@ -622,7 +630,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( OUString aPreferredName; aValue >>= aPreferredName; aValue <<= PropertyHelper::addHatchUniqueNameToTable( - aHatch, m_xNamedPropertyTableFactory, aPreferredName ); + aHatch, m_xChartModel, aPreferredName ); GetPropertySet()->setPropertyValue( aPropName, aValue ); bChanged = true; @@ -642,7 +650,7 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( if( rItem.QueryValue( aValue, MID_NAME )) { - if( aValue != GetPropertySet()->getPropertyValue( "FillBitmapName" )) + if( aValue != GetPropertySet()->getPropertyValue( u"FillBitmapName"_ustr )) { // add Bitmap to list uno::Any aBitmap; @@ -650,9 +658,9 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( OUString aPreferredName; aValue >>= aPreferredName; aValue <<= PropertyHelper::addBitmapUniqueNameToTable( - aBitmap, m_xNamedPropertyTableFactory, aPreferredName ); + aBitmap, m_xChartModel, aPreferredName ); - GetPropertySet()->setPropertyValue( "FillBitmapName" , aValue ); + GetPropertySet()->setPropertyValue( u"FillBitmapName"_ustr , aValue ); bChanged = true; } } @@ -666,10 +674,10 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "BorderTransparency" ) + ? u"BorderTransparency"_ustr : (m_GraphicObjectType == GraphicObjectType::LineDataPoint) - ? OUString( "Transparency" ) - : OUString( "LineTransparence" ); + ? u"Transparency"_ustr + : u"LineTransparence"_ustr; const XLineTransparenceItem & rItem = static_cast< const XLineTransparenceItem & >( @@ -705,8 +713,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( { OUString aPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "Transparency" ) - : OUString( "FillTransparence" ); + ? u"Transparency"_ustr + : u"FillTransparence"_ustr; const XFillTransparenceItem & rItem = static_cast< const XFillTransparenceItem & >( @@ -728,8 +736,8 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( // if linear or no transparence is set, delete the gradient OUString aTransGradPropName = (m_GraphicObjectType == GraphicObjectType::FilledDataPoint) - ? OUString( "TransparencyGradientName" ) - : OUString( "FillTransparenceGradientName" ); + ? u"TransparencyGradientName"_ustr + : u"FillTransparenceGradientName"_ustr; GetPropertySet()->setPropertyValue( aTransGradPropName, uno::Any( OUString() )); @@ -742,6 +750,15 @@ bool GraphicPropertyItemConverter::ApplySpecialItem( } } break; + case SCHATTR_COLOR_PALETTE: + { + const auto& rItem = static_cast<const SvxChartColorPaletteItem&>(rItemSet.Get(nWhichId)); + m_xChartModel->setColorPalette(rItem.GetType(), rItem.GetIndex()); + const auto oColorPalette = m_xChartModel->getCurrentColorPalette(); + if (oColorPalette) + m_xChartModel->applyColorPaletteToDataSeries(*oColorPalette); + } + break; } return bChanged; diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx index a99d848d0c8c..1a4eebf91127 100644 --- a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -25,17 +25,19 @@ #include <svl/itemiter.hxx> #include <svl/whiter.hxx> #include <svx/svxids.hrc> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <sal/log.hxx> +#include <utility> +#include <chartview/ChartSfxItemIds.hxx> using namespace ::com::sun::star; namespace chart::wrapper { ItemConverter::ItemConverter( - const uno::Reference< beans::XPropertySet > & rPropertySet, + uno::Reference< beans::XPropertySet > xPropertySet, SfxItemPool& rItemPool ) : - m_xPropertySet( rPropertySet ), + m_xPropertySet(std::move( xPropertySet )), m_rItemPool( rItemPool ) { resetPropertySet( m_xPropertySet ); @@ -75,20 +77,18 @@ void ItemConverter::_disposing( const lang::EventObject& ) void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const { - const sal_uInt16 * pRanges = rOutItemSet.GetRanges(); + const WhichRangesContainer& pRanges = rOutItemSet.GetRanges(); tPropertyNameWithMemberId aProperty; SfxItemPool & rPool = GetItemPool(); - assert(pRanges != nullptr); + assert(!pRanges.empty()); OSL_ASSERT( m_xPropertySetInfo.is()); OSL_ASSERT( m_xPropertySet.is()); - while( (*pRanges) != 0) + for(const auto& rPair : pRanges) { - sal_uInt16 nBeg = *pRanges; - ++pRanges; - sal_uInt16 nEnd = *pRanges; - ++pRanges; + sal_uInt16 nBeg = rPair.first; + sal_uInt16 nEnd = rPair.second; OSL_ASSERT( nBeg <= nEnd ); for( sal_uInt16 nWhich = nBeg; nWhich <= nEnd; ++nWhich ) @@ -96,7 +96,7 @@ void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const if( GetItemProperty( nWhich, aProperty )) { // put the Property into the itemset - std::unique_ptr<SfxPoolItem> pItem(rPool.GetDefaultItem( nWhich ).Clone()); + std::unique_ptr<SfxPoolItem> pItem(rPool.GetUserOrPoolDefaultItem( nWhich ).Clone()); if( pItem ) { @@ -157,9 +157,31 @@ bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) tPropertyNameWithMemberId aProperty; uno::Any aValue; + // tdf#165491 the Item with WhichID SCHATTR_STAT_KIND_ERROR *has* to + // be handled 1st since it sets additional information about the + // ErrorBarStyle at uno::Reference< beans::XPropertySet > xErrorBarProp + // that the processing of the *other* Items already need access to, + // see 'case SCHATTR_STAT_KIND_ERROR' in + // StatisticsItemConverter::ApplySpecialItem. This worked before the + // change of SfxItemSet to use a std::unordered_set since the order + // of Items was fix and - since SCHATTR_STAT_KIND_ERROR had the + // lowest WhichID - was handled 1st. Not sure if that was by purpose + // and it was known that this was necessary - there are no comments + // hinting to that. In general it is bad style to rely on the 'order' + // of Items being processed - there is no order defined in general. + { + const SfxPoolItem* pItem(nullptr); + if (SfxItemState::SET == rItemSet.GetItemState(SCHATTR_STAT_KIND_ERROR, false, &pItem)) + if(!GetItemProperty(pItem->Which(), aProperty)) + bItemsChanged = ApplySpecialItem(pItem->Which(), rItemSet); + } + for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem()) { - if( rItemSet.GetItemState( pItem->Which(), false ) == SfxItemState::SET ) + if (SCHATTR_STAT_KIND_ERROR == pItem->Which()) + continue; + + if( aIter.GetItemState( false ) == SfxItemState::SET ) { if( GetItemProperty( pItem->Which(), aProperty )) { @@ -200,7 +222,8 @@ void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItem while (nWhich) { - if ((rSourceSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::SET) && + SfxItemState nSourceItemState = aIter.GetItemState(true, &pPoolItem); + if ((nSourceItemState == SfxItemState::SET) && (rDestSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::SET)) { if (rSourceSet.Get(nWhich) != rDestSet.Get(nWhich)) @@ -211,7 +234,7 @@ void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItem } } } - else if( rSourceSet.GetItemState(nWhich, true, &pPoolItem) == SfxItemState::DONTCARE ) + else if( nSourceItemState == SfxItemState::INVALID ) rDestSet.InvalidateItem(nWhich); nWhich = aIter.NextWhich (); diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx index 9ae14be68a21..e58dbc544f37 100644 --- a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -21,13 +21,14 @@ #include "SchWhichPairs.hxx" #include <GraphicPropertyItemConverter.hxx> #include <CharacterPropertyItemConverter.hxx> +#include <ChartModel.hxx> #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include <svl/intitem.hxx> #include <svl/eitem.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <memory> @@ -40,16 +41,16 @@ LegendItemConverter::LegendItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, - const awt::Size* pRefSize ) : + const rtl::Reference< ChartModel > & xChartModel, + const std::optional<awt::Size>& pRefSize ) : ItemConverter( rPropertySet, rItemPool ) { m_aConverters.emplace_back( new GraphicPropertyItemConverter( - rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, + rPropertySet, rItemPool, rDrawModel, xChartModel, GraphicObjectType::LineAndFillProperties )); m_aConverters.emplace_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize, - "ReferencePageSize" )); + u"ReferencePageSize"_ustr )); } LegendItemConverter::~LegendItemConverter() @@ -76,7 +77,7 @@ bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * LegendItemConverter::GetWhichPairs() const +const WhichRangesContainer& LegendItemConverter::GetWhichPairs() const { // must span all used items! return nLegendWhichPairs; @@ -96,15 +97,14 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSe { case SCHATTR_LEGEND_SHOW: { - const SfxPoolItem* pPoolItem = nullptr; - if( rInItemSet.GetItemState( SCHATTR_LEGEND_SHOW, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxBoolItem* pShowItem = rInItemSet.GetItemIfSet( SCHATTR_LEGEND_SHOW ) ) { - bool bShow = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + bool bShow = pShowItem->GetValue(); bool bWasShown = true; - if( ! (GetPropertySet()->getPropertyValue( "Show" ) >>= bWasShown) || + if( ! (GetPropertySet()->getPropertyValue( u"Show"_ustr ) >>= bWasShown) || ( bWasShown != bShow )) { - GetPropertySet()->setPropertyValue( "Show" , uno::Any( bShow )); + GetPropertySet()->setPropertyValue( u"Show"_ustr , uno::Any( bShow )); bChanged = true; } } @@ -113,10 +113,9 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSe break; case SCHATTR_LEGEND_POS: { - const SfxPoolItem* pPoolItem = nullptr; - if( rInItemSet.GetItemState( SCHATTR_LEGEND_POS, true, &pPoolItem ) == SfxItemState::SET ) + if( const SfxInt32Item* pPosItem = rInItemSet.GetItemIfSet( SCHATTR_LEGEND_POS ) ) { - chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(static_cast<const SfxInt32Item*>(pPoolItem)->GetValue()); + chart2::LegendPosition eNewPos = static_cast<chart2::LegendPosition>(pPosItem->GetValue()); css::chart::ChartLegendExpansion eExpansion = css::chart::ChartLegendExpansion_HIGH; switch( eNewPos ) @@ -136,12 +135,12 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSe try { chart2::LegendPosition eOldPos; - if( ! ( GetPropertySet()->getPropertyValue( "AnchorPosition" ) >>= eOldPos ) || + if( ! ( GetPropertySet()->getPropertyValue( u"AnchorPosition"_ustr ) >>= eOldPos ) || ( eOldPos != eNewPos )) { - GetPropertySet()->setPropertyValue( "AnchorPosition" , uno::Any( eNewPos )); - GetPropertySet()->setPropertyValue( "Expansion" , uno::Any( eExpansion )); - GetPropertySet()->setPropertyValue( "RelativePosition" , uno::Any()); + GetPropertySet()->setPropertyValue( u"AnchorPosition"_ustr , uno::Any( eNewPos )); + GetPropertySet()->setPropertyValue( u"Expansion"_ustr , uno::Any( eExpansion )); + GetPropertySet()->setPropertyValue( u"RelativePosition"_ustr , uno::Any()); bChanged = true; } } @@ -154,15 +153,14 @@ bool LegendItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxItemSe break; case SCHATTR_LEGEND_NO_OVERLAY: { - const SfxPoolItem* pPoolItem = nullptr; - if(rInItemSet.GetItemState(SCHATTR_LEGEND_NO_OVERLAY, true, &pPoolItem) == SfxItemState::SET) + if(const SfxBoolItem* pNoOverlayItem = rInItemSet.GetItemIfSet(SCHATTR_LEGEND_NO_OVERLAY)) { - bool bOverlay = !static_cast<const SfxBoolItem *>(pPoolItem)->GetValue(); + bool bOverlay = !pNoOverlayItem->GetValue(); bool bOldOverlay = false; - if(!(GetPropertySet()->getPropertyValue("Overlay") >>= bOldOverlay) || + if(!(GetPropertySet()->getPropertyValue(u"Overlay"_ustr) >>= bOldOverlay) || (bOldOverlay != bOverlay)) { - GetPropertySet()->setPropertyValue("Overlay", uno::Any(bOverlay)); + GetPropertySet()->setPropertyValue(u"Overlay"_ustr, uno::Any(bOverlay)); bChanged = true; } } @@ -182,21 +180,21 @@ void LegendItemConverter::FillSpecialItem( case SCHATTR_LEGEND_SHOW: { bool bShow = true; - GetPropertySet()->getPropertyValue( "Show" ) >>= bShow; + GetPropertySet()->getPropertyValue( u"Show"_ustr ) >>= bShow; rOutItemSet.Put( SfxBoolItem(SCHATTR_LEGEND_SHOW, bShow) ); } break; case SCHATTR_LEGEND_POS: { chart2::LegendPosition eLegendPos( chart2::LegendPosition_LINE_END ); - GetPropertySet()->getPropertyValue( "AnchorPosition" ) >>= eLegendPos; + GetPropertySet()->getPropertyValue( u"AnchorPosition"_ustr ) >>= eLegendPos; rOutItemSet.Put( SfxInt32Item(SCHATTR_LEGEND_POS, static_cast<sal_Int32>(eLegendPos) ) ); } break; case SCHATTR_LEGEND_NO_OVERLAY: { bool bOverlay = false; - GetPropertySet()->getPropertyValue("Overlay") >>= bOverlay; + GetPropertySet()->getPropertyValue(u"Overlay"_ustr) >>= bOverlay; rOutItemSet.Put(SfxBoolItem(SCHATTR_LEGEND_NO_OVERLAY, !bOverlay)); } break; diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx index 8351e5bf02ab..a6dbf6d2faac 100644 --- a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx +++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx @@ -24,39 +24,37 @@ #include <StatisticsItemConverter.hxx> #include <GraphicPropertyItemConverter.hxx> #include <DataPointItemConverter.hxx> -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <Diagram.hxx> +#include <DataSeries.hxx> +#include <GridProperties.hxx> #include <TitleHelper.hxx> #include <TitleItemConverter.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> -#include <chartview/ExplicitValueProvider.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XDataSeries.hpp> -#include <com/sun/star/chart2/XTitle.hpp> -#include <com/sun/star/util/XNumberFormatsSupplier.hpp> -#include <com/sun/star/chart2/XAxis.hpp> +#include <ChartView.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace chart::wrapper { AllAxisItemConverter::AllAxisItemConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const awt::Size* pRefSize ) + const std::optional<awt::Size>& pRefSize ) : MultipleItemConverter( rItemPool ) { - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - const Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( Reference< XAxis > const & axis : aElementList ) + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + const std::vector< rtl::Reference< Axis > > aElementList = AxisHelper::getAllAxesOfDiagram( xDiagram ); + for( rtl::Reference< Axis > const & axis : aElementList ) { - uno::Reference< beans::XPropertySet > xObjectProperties(axis, uno::UNO_QUERY); m_aConverters.emplace_back( new ::chart::wrapper::AxisItemConverter( - xObjectProperties, rItemPool, rDrawModel, - uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), nullptr, nullptr, + uno::Reference< beans::XPropertySet >(axis), + rItemPool, rDrawModel, + xChartModel, nullptr, nullptr, pRefSize)); } } @@ -65,25 +63,24 @@ AllAxisItemConverter::~AllAxisItemConverter() { } -const sal_uInt16 * AllAxisItemConverter::GetWhichPairs() const +const WhichRangesContainer& AllAxisItemConverter::GetWhichPairs() const { // must span all used items! return nAllAxisWhichPairs; } AllGridItemConverter::AllGridItemConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) + SdrModel& rDrawModel ) : MultipleItemConverter( rItemPool ) { - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - const Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); - for( Reference< beans::XPropertySet > const & xObjectProperties : aElementList ) + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + std::vector< rtl::Reference< GridProperties > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); + for( rtl::Reference< GridProperties > const & xObjectProperties : aElementList ) { m_aConverters.emplace_back( new ::chart::wrapper::GraphicPropertyItemConverter( - xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, + xObjectProperties, rItemPool, rDrawModel, xChartModel, ::chart::wrapper::GraphicObjectType::LineProperties ) ); } } @@ -92,36 +89,34 @@ AllGridItemConverter::~AllGridItemConverter() { } -const sal_uInt16 * AllGridItemConverter::GetWhichPairs() const +const WhichRangesContainer& AllGridItemConverter::GetWhichPairs() const { // must span all used items! return nGridWhichPairs; } AllDataLabelItemConverter::AllDataLabelItemConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) + SdrModel& rDrawModel ) : MultipleItemConverter( rItemPool ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::ChartModelHelper::getDataSeries( xChartModel )); + std::vector< rtl::Reference< DataSeries > > aSeriesList = + xChartModel->getDataSeries(); for (auto const& series : aSeriesList) { - uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY); uno::Reference< uno::XComponentContext> xContext;//do not need Context for label properties - sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties ); - sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( - xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); + sal_Int32 nNumberFormat = series->getExplicitNumberFormatKeyForDataLabel(); + sal_Int32 nPercentNumberFormat=ChartView::getExplicitPercentageNumberFormatKeyForDataLabel( + series,xChartModel); m_aConverters.emplace_back( new ::chart::wrapper::DataPointItemConverter( - xChartModel, xContext, xObjectProperties, series, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, GraphicObjectType::FilledDataPoint, - nullptr, true, false, 0, true, nNumberFormat, nPercentNumberFormat)); + xChartModel, xContext, series, series, rItemPool, rDrawModel, + GraphicObjectType::FilledDataPoint, + std::nullopt, true, false, 0, true, nNumberFormat, nPercentNumberFormat)); } } @@ -129,28 +124,27 @@ AllDataLabelItemConverter::~AllDataLabelItemConverter() { } -const sal_uInt16 * AllDataLabelItemConverter::GetWhichPairs() const +const WhichRangesContainer& AllDataLabelItemConverter::GetWhichPairs() const { // must span all used items! return nDataLabelWhichPairs; } AllTitleItemConverter::AllTitleItemConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool, - SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) + SdrModel& rDrawModel ) : MultipleItemConverter( rItemPool ) { for(sal_Int32 nTitle = TitleHelper::TITLE_BEGIN; nTitle < TitleHelper::NORMAL_TITLE_END; nTitle++ ) { - uno::Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( TitleHelper::eTitleType(nTitle), xChartModel ) ); if(!xTitle.is()) continue; - uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY); m_aConverters.emplace_back( new ::chart::wrapper::TitleItemConverter( - xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, nullptr)); + uno::Reference< beans::XPropertySet >( xTitle ), + rItemPool, rDrawModel, xChartModel, std::nullopt)); } } @@ -158,32 +152,31 @@ AllTitleItemConverter::~AllTitleItemConverter() { } -const sal_uInt16 * AllTitleItemConverter::GetWhichPairs() const +const WhichRangesContainer& AllTitleItemConverter::GetWhichPairs() const { // must span all used items! return nTitleWhichPairs; } AllSeriesStatisticsConverter::AllSeriesStatisticsConverter( - const uno::Reference< frame::XModel > & xChartModel, + const rtl::Reference<::chart::ChartModel> & xChartModel, SfxItemPool& rItemPool ) : MultipleItemConverter( rItemPool ) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( - ::chart::ChartModelHelper::getDataSeries( xChartModel )); + std::vector< rtl::Reference< DataSeries > > aSeriesList = + xChartModel->getDataSeries(); for (auto const& series : aSeriesList) { - uno::Reference< beans::XPropertySet > xObjectProperties(series, uno::UNO_QUERY); m_aConverters.emplace_back( new ::chart::wrapper::StatisticsItemConverter( - xChartModel, xObjectProperties, rItemPool )); + xChartModel, series, rItemPool )); } } AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter() {} -const sal_uInt16 * AllSeriesStatisticsConverter::GetWhichPairs() const +const WhichRangesContainer& AllSeriesStatisticsConverter::GetWhichPairs() const { // must span all used items! return nStatWhichPairs; diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx index 7fe5d2acad41..721f1247f439 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -18,9 +18,12 @@ */ #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <RegressionCurveItemConverter.hxx> #include "SchWhichPairs.hxx" #include <GraphicPropertyItemConverter.hxx> +#include <DataSeries.hxx> +#include <ChartModel.hxx> #include <com/sun/star/chart2/XRegressionCurve.hpp> #include <osl/diagnose.h> @@ -28,6 +31,7 @@ #include <svl/eitem.hxx> #include <svl/intitem.hxx> #include <svl/stritem.hxx> +#include <utility> using namespace ::com::sun::star; @@ -65,12 +69,12 @@ void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::R } } -void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID) +void lclConvertToItemSetDouble(SfxItemSet& rItemSet, TypedWhichId<SvxDoubleItem> nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID) { OSL_ASSERT(xProperties.is()); if( xProperties.is() ) { - double aValue = static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue(); + double aValue = rItemSet.Get( nWhichId ).GetValue(); if(xProperties->getPropertyValue( aPropertyID ) >>= aValue) { rItemSet.Put(SvxDoubleItem( aValue, nWhichId )); @@ -85,16 +89,16 @@ namespace chart::wrapper RegressionCurveItemConverter::RegressionCurveItemConverter( const uno::Reference< beans::XPropertySet >& rPropertySet, - const uno::Reference< chart2::XRegressionCurveContainer >& xContainer, + rtl::Reference< DataSeries > xContainer, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) : + const rtl::Reference< ChartModel > & xChartModel ) : ItemConverter( rPropertySet, rItemPool ), m_spGraphicConverter( std::make_shared<GraphicPropertyItemConverter>( rPropertySet, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, + xChartModel, GraphicObjectType::LineProperties )), - m_xCurveContainer( xContainer ) + m_xCurveContainer(std::move( xContainer )) {} RegressionCurveItemConverter::~RegressionCurveItemConverter() @@ -116,7 +120,7 @@ bool RegressionCurveItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * RegressionCurveItemConverter::GetWhichPairs() const +const WhichRangesContainer& RegressionCurveItemConverter::GetWhichPairs() const { // must span all used items! return nRegressionCurveWhichPairs; @@ -166,84 +170,84 @@ bool RegressionCurveItemConverter::ApplySpecialItem( case SCHATTR_REGRESSION_DEGREE: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "PolynomialDegree"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"PolynomialDegree"_ustr); } break; case SCHATTR_REGRESSION_PERIOD: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"MovingAveragePeriod"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"ExtrapolateForward"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"ExtrapolateBackward"_ustr); } break; case SCHATTR_REGRESSION_SET_INTERCEPT: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, u"ForceIntercept"_ustr); } break; case SCHATTR_REGRESSION_INTERCEPT_VALUE: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"InterceptValue"_ustr); } break; case SCHATTR_REGRESSION_CURVE_NAME: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, u"CurveName"_ustr); } break; case SCHATTR_REGRESSION_MOVING_TYPE: { uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"MovingAverageType"_ustr); } break; case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, u"ShowEquation"_ustr); } break; case SCHATTR_REGRESSION_XNAME: { uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "XName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, u"XName"_ustr); } break; case SCHATTR_REGRESSION_YNAME: { uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "YName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, u"YName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_COEFF: { uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, u"ShowCorrelationCoefficient"_ustr); } break; @@ -271,73 +275,73 @@ void RegressionCurveItemConverter::FillSpecialItem(sal_uInt16 nWhichId, SfxItemS case SCHATTR_REGRESSION_DEGREE: { - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"PolynomialDegree"_ustr); } break; case SCHATTR_REGRESSION_PERIOD: { - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"MovingAveragePeriod"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: { - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, xProperties, u"ExtrapolateForward"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: { - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, xProperties, u"ExtrapolateBackward"_ustr); } break; case SCHATTR_REGRESSION_SET_INTERCEPT: { - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, u"ForceIntercept"_ustr); } break; case SCHATTR_REGRESSION_INTERCEPT_VALUE: { - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_INTERCEPT_VALUE, xProperties, u"InterceptValue"_ustr); } break; case SCHATTR_REGRESSION_CURVE_NAME: { - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, u"CurveName"_ustr); } break; case SCHATTR_REGRESSION_MOVING_TYPE: { - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"MovingAverageType"_ustr); } break; case SCHATTR_REGRESSION_SHOW_EQUATION: { - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowEquation"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), u"ShowEquation"_ustr); } break; case SCHATTR_REGRESSION_XNAME: { - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "XName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), u"XName"_ustr); } break; case SCHATTR_REGRESSION_YNAME: { - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "YName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), u"YName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_COEFF: { - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), "ShowCorrelationCoefficient"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xCurve->getEquationProperties(), u"ShowCorrelationCoefficient"_ustr); } break; } diff --git a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx index 234d2b5ba47f..5487d8d2e757 100644 --- a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx @@ -22,6 +22,7 @@ #include <ItemPropertyMap.hxx> #include <GraphicPropertyItemConverter.hxx> #include <CharacterPropertyItemConverter.hxx> +#include <ChartModel.hxx> #include <unonames.hxx> #include <com/sun/star/beans/XPropertySet.hpp> @@ -48,17 +49,17 @@ RegressionEquationItemConverter::RegressionEquationItemConverter( const css::uno::Reference< css::beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, - const awt::Size* pRefSize ) : + const rtl::Reference< ChartModel > & xChartModel, + const std::optional<awt::Size>& pRefSize ) : ItemConverter( rPropertySet, rItemPool ) { m_aConverters.emplace_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, + xChartModel, GraphicObjectType::LineAndFillProperties )); m_aConverters.emplace_back( - new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); + new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); } RegressionEquationItemConverter::~RegressionEquationItemConverter() @@ -85,7 +86,7 @@ bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet & rItemSet return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * RegressionEquationItemConverter::GetWhichPairs() const +const WhichRangesContainer& RegressionEquationItemConverter::GetWhichPairs() const { // must span all used items! return nRegEquationWhichPairs; diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx index 94d22f401d70..8216c4b32337 100644 --- a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -18,6 +18,7 @@ */ #pragma once +#include <svl/whichranges.hxx> #include <svx/svxids.hrc> #include <svx/xdef.hxx> #include <svx/svddef.hxx> @@ -25,68 +26,56 @@ #include <chartview/ChartSfxItemIds.hxx> -const sal_uInt16 nTitleWhichPairs[] = -{ +const WhichRangesContainer nTitleWhichPairs(svl::Items< SCHATTR_TEXT_START, SCHATTR_TEXT_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx EE_ITEMS_START, EE_ITEMS_END, // Characters - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); -const sal_uInt16 nAxisWhichPairs[] = -{ +const WhichRangesContainer nAxisWhichPairs(svl::Items< SCHATTR_TEXT_START, SCHATTR_TEXT_END, SCHATTR_AXIS_START, SCHATTR_AXIS_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx EE_ITEMS_START, EE_ITEMS_END, // Characters SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, // 11432 svx/svxids.hrc - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); -const sal_uInt16 nAllAxisWhichPairs[] = -{ +const WhichRangesContainer nAllAxisWhichPairs(svl::Items< SCHATTR_TEXT_START, SCHATTR_TEXT_END, SCHATTR_AXIS_LABEL_START, SCHATTR_AXIS_LABEL_END, XATTR_LINE_FIRST, XATTR_LINE_LAST, EE_ITEMS_START, EE_ITEMS_END, // Characters - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); -const sal_uInt16 nGridWhichPairs[] = -{ - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - 0 -}; +const WhichRangesContainer nGridWhichPairs(svl::Items< + XATTR_LINE_FIRST, XATTR_LINE_LAST // 1000 - 1016 svx/xdef.hxx +>); -const sal_uInt16 nLegendWhichPairs[] = -{ +const WhichRangesContainer nLegendWhichPairs(svl::Items< SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx EE_ITEMS_START, EE_ITEMS_END, // Characters - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); -const sal_uInt16 nDataLabelWhichPairs[] = -{ +const WhichRangesContainer nDataLabelWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ - SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ - 0 -}; + SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE /* 11432 svx/svxids.hrc */ +>); -const sal_uInt16 nDataPointWhichPairs[] = -{ +const WhichRangesContainer nDataPointWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ @@ -99,12 +88,10 @@ const sal_uInt16 nDataPointWhichPairs[] = EE_ITEMS_START, EE_ITEMS_END, /* 3994 - 4037 editeng/eeitem.hxx */ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING +>); -const sal_uInt16 nTextLabelWhichPairs[] = -{ +const WhichRangesContainer nTextLabelWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_SYMBOL, SCHATTR_STYLE_SYMBOL, @@ -115,21 +102,17 @@ const sal_uInt16 nTextLabelWhichPairs[] = EE_ITEMS_START, EE_ITEMS_END, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING +>); -const sal_uInt16 nSeriesOptionsWhichPairs[] = -{ +const WhichRangesContainer nSeriesOptionsWhichPairs(svl::Items< SCHATTR_AXIS,SCHATTR_AXIS, /* 69 sch/schattr.hxx*/ SCHATTR_BAR_OVERLAP,SCHATTR_BAR_CONNECT, /* 98 - 100 (incl. SCHATTR_GAPWIDTH) */ - SCHATTR_GROUP_BARS_PER_AXIS,SCHATTR_AXIS_FOR_ALL_SERIES, - 0 -}; + SCHATTR_GROUP_BARS_PER_AXIS,SCHATTR_AXIS_FOR_ALL_SERIES +>); // nDataPointWhichPairs + nSeriesOptionsWhichPairs -const sal_uInt16 nRowWhichPairs[] = -{ +const WhichRangesContainer nRowWhichPairs(svl::Items< SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.hxx*/ SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ @@ -139,69 +122,63 @@ const sal_uInt16 nRowWhichPairs[] = SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_HIDE_DATA_POINT_LEGEND_ENTRY, SCHATTR_BAR_OVERLAP,SCHATTR_BAR_CONNECT, /* 98 - 100 (incl. SCHATTR_GAPWIDTH) */ SCHATTR_GROUP_BARS_PER_AXIS,SCHATTR_AXIS_FOR_ALL_SERIES, + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, /* 1000 - 1016 svx/xdef.hxx */ XATTR_FILL_FIRST, XATTR_FILL_LAST, /* 1018 - 1046 svx/xdef.hxx */ SDRATTR_3D_FIRST, SDRATTR_3D_LAST, /* 1244 - 1334 svx/svddef.hxx */ EE_ITEMS_START, EE_ITEMS_END, /* 3994 - 4037 editeng/eeitem.hxx */ SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, /* 10585 - 10585 svx/svxids.hrc */ SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, /* 11432 svx/svxids.hrc */ - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING +>); -const sal_uInt16 nStatWhichPairs[]= -{ +const WhichRangesContainer nStatWhichPairs(svl::Items< SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx - SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 - 0 -}; + SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END // 108 - 109 +>); -const sal_uInt16 nErrorBarWhichPairs[]= -{ +const WhichRangesContainer nErrorBarWhichPairs(svl::Items< SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - 0 -}; + XATTR_LINE_FIRST, XATTR_LINE_LAST // 1000 - 1016 svx/xdef.hxx +>); // for CharacterProperties -const sal_uInt16 nCharacterPropertyWhichPairs[] = -{ +const WhichRangesContainer nCharacterPropertyWhichPairs(svl::Items< EE_ITEMS_START, EE_ITEMS_END, // Characters - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); -const sal_uInt16 nLinePropertyWhichPairs[] = -{ - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - 0 -}; +const WhichRangesContainer nLinePropertyWhichPairs(svl::Items< + XATTR_LINE_FIRST, XATTR_LINE_LAST // 1000 - 1016 svx/xdef.hxx +>); -const sal_uInt16 nLineAndFillPropertyWhichPairs[] = -{ +const WhichRangesContainer nLineAndFillPropertyWhichPairs(svl::Items< + SCHATTR_COLOR_PALETTE_START, SCHATTR_COLOR_PALETTE_END, // 107 - 107 XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx - SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx - 0 -}; + SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST // 1067 - 1078 svx/svddef.hxx +>); -const sal_uInt16 nRegressionCurveWhichPairs[] = -{ +const WhichRangesContainer nRegressionCurveWhichPairs(svl::Items< SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 - XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx - 0 -}; + XATTR_LINE_FIRST, XATTR_LINE_LAST // 1000 - 1016 svx/xdef.hxx +>); -const sal_uInt16 nRegEquationWhichPairs[] = -{ +const WhichRangesContainer nRegEquationWhichPairs(svl::Items< XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx EE_ITEMS_START, EE_ITEMS_END, // Characters SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc - SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, // Characters - 0 -}; + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING // Characters +>); + +const WhichRangesContainer nDataTableWhichPairs(svl::Items< + SCHATTR_DATA_TABLE_START, SCHATTR_DATA_TABLE_END, + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx + EE_ITEMS_START, EE_ITEMS_END +>); /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx index fc25407d1a58..96c27372090a 100644 --- a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -20,20 +20,22 @@ #include <SeriesOptionsItemConverter.hxx> #include "SchWhichPairs.hxx" -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <ChartTypeHelper.hxx> #include <DataSeriesHelper.hxx> #include <ChartModel.hxx> - -#include <com/sun/star/chart2/XDataSeries.hpp> +#include <BaseCoordinateSystem.hxx> #include <svl/eitem.hxx> #include <svl/intitem.hxx> #include <svl/ilstitem.hxx> #include <svx/sdangitm.hxx> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; @@ -42,13 +44,13 @@ namespace chart::wrapper { SeriesOptionsItemConverter::SeriesOptionsItemConverter( - const uno::Reference< frame::XModel >& xChartModel - , const uno::Reference< uno::XComponentContext > & xContext - , const uno::Reference< beans::XPropertySet >& xPropertySet + const rtl::Reference<::chart::ChartModel>& xChartModel + , uno::Reference< uno::XComponentContext > xContext + , const rtl::Reference< ::chart::DataSeries >& xDataSeries , SfxItemPool& rItemPool ) - : ItemConverter( xPropertySet, rItemPool ) + : ItemConverter( xDataSeries, rItemPool ) , m_xChartModel(xChartModel) - , m_xCC(xContext) + , m_xCC(std::move(xContext)) , m_bAttachToMainAxis(true) , m_bSupportingOverlapAndGapWidthProperties(false) , m_bSupportingBarConnectors(false) @@ -60,7 +62,6 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( , m_bSupportingStartingAngle(false) , m_nStartingAngle(90) , m_bClockwise(false) - , m_aSupportedMissingValueTreatments() , m_nMissingValueTreatment(0) , m_bSupportingPlottingOfHiddenCells(false) , m_bIncludeHiddenCells(true) @@ -68,40 +69,37 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( { try { - uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY ); - - m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + m_bAttachToMainAxis = xDataSeries->isAttachedToMainAxis(); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); - uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); - uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); + rtl::Reference< Diagram > xDiagram( xChartModel->getFirstChartDiagram() ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( xDataSeries, xDiagram ); if( m_xCooSys.is() ) { - uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) ); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 0, m_xCooSys ); chart2::ScaleData aScale( xAxis->getScaleData() ); m_bClockwise = (aScale.Orientation == chart2::AxisOrientation_REVERSE); } - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - m_bSupportingOverlapAndGapWidthProperties = ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, nDimensionCount ); + sal_Int32 nDimensionCount = xDiagram->getDimension(); + m_bSupportingOverlapAndGapWidthProperties = xChartType.is() ? + xChartType->isSupportingOverlapAndGapWidthProperties(nDimensionCount) : false; if( m_bSupportingOverlapAndGapWidthProperties ) { - sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nAxisIndex = xDataSeries->getAttachedAxisIndex(); uno::Sequence< sal_Int32 > aBarPositionSequence; - uno::Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + if( xChartType.is() ) { - if( xChartTypeProps->getPropertyValue( "OverlapSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( u"OverlapSequence"_ustr ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nBarOverlap = aBarPositionSequence[nAxisIndex]; } - if( xChartTypeProps->getPropertyValue( "GapwidthSequence" ) >>= aBarPositionSequence ) + if( xChartType->getPropertyValue( u"GapwidthSequence"_ustr ) >>= aBarPositionSequence ) { if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) m_nGapWidth = aBarPositionSequence[nAxisIndex]; @@ -109,46 +107,44 @@ SeriesOptionsItemConverter::SeriesOptionsItemConverter( } } - m_bSupportingBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount ); - if( m_bSupportingBarConnectors && xDiagramProperties.is() ) + m_bSupportingBarConnectors = xChartType.is() ? xChartType->isSupportingBarConnectors(nDimensionCount) : false; + if( m_bSupportingBarConnectors && xDiagram.is() ) { - xDiagramProperties->getPropertyValue( "ConnectBars" ) >>= m_bConnectBars; + xDiagram->getPropertyValue( u"ConnectBars"_ustr ) >>= m_bConnectBars; } - m_bSupportingAxisSideBySide = ChartTypeHelper::isSupportingAxisSideBySide( xChartType, nDimensionCount ); - if( m_bSupportingAxisSideBySide && xDiagramProperties.is() ) + m_bSupportingAxisSideBySide = xChartType.is() ? xChartType->isSupportingAxisSideBySide(nDimensionCount) : false; + if( m_bSupportingAxisSideBySide && xDiagram.is() ) { - xDiagramProperties->getPropertyValue( "GroupBarsPerAxis" ) >>= m_bGroupBarsPerAxis; + xDiagram->getPropertyValue( u"GroupBarsPerAxis"_ustr ) >>= m_bGroupBarsPerAxis; } - m_bSupportingStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType ); + m_bSupportingStartingAngle = xChartType.is() ? xChartType->isSupportingStartingAngle() : false; if( m_bSupportingStartingAngle ) { - xDiagramProperties->getPropertyValue( "StartingAngle" ) >>= m_nStartingAngle; + xDiagram->getPropertyValue( u"StartingAngle"_ustr ) >>= m_nStartingAngle; } m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ); - m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment( - ChartModelHelper::findDiagram(m_xChartModel), xChartType ); + m_nMissingValueTreatment = xDiagram->getCorrectedMissingValueTreatment( xChartType ); - uno::Reference< XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xProp( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( m_xChartModel->getDataProvider(), uno::UNO_QUERY ); if( xProp.is() ) { try { //test whether the data provider offers this property - xProp->getPropertyValue( "IncludeHiddenCells" ); + xProp->getPropertyValue( u"IncludeHiddenCells"_ustr ); //if not exception is thrown the property is offered m_bSupportingPlottingOfHiddenCells = true; - xDiagramProperties->getPropertyValue( "IncludeHiddenCells" ) >>= m_bIncludeHiddenCells; + xDiagram->getPropertyValue( u"IncludeHiddenCells"_ustr ) >>= m_bIncludeHiddenCells; } catch( const beans::UnknownPropertyException& ) { } } - m_bHideLegendEntry = !xPropertySet->getPropertyValue("ShowLegendEntry").get<bool>(); + m_bHideLegendEntry = !xDataSeries->getPropertyValue(u"ShowLegendEntry"_ustr).get<bool>(); } catch( const uno::Exception & ) { @@ -160,7 +156,7 @@ SeriesOptionsItemConverter::~SeriesOptionsItemConverter() { } -const sal_uInt16 * SeriesOptionsItemConverter::GetWhichPairs() const +const WhichRangesContainer& SeriesOptionsItemConverter::GetWhichPairs() const { // must span all used items! return nSeriesOptionsWhichPairs; @@ -184,8 +180,9 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( bAttachToMainAxis != m_bAttachToMainAxis ) { //change model: - bChanged = DiagramHelper::attachSeriesToAxis( bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() ) - , ChartModelHelper::findDiagram(m_xChartModel), m_xCC ); + rtl::Reference<DataSeries> xDataSeries = dynamic_cast<DataSeries*>( GetPropertySet().get() ); + bChanged = m_xChartModel->getFirstChartDiagram()->attachSeriesToAxis( bAttachToMainAxis, xDataSeries + , m_xCC ); if( bChanged ) m_bAttachToMainAxis = bAttachToMainAxis; @@ -201,34 +198,31 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf sal_Int32& rBarPosition = ( nWhichId == SCHATTR_BAR_OVERLAP ) ? m_nBarOverlap : m_nGapWidth; rBarPosition = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); - OUString aPropName("GapwidthSequence" ); + OUString aPropName(u"GapwidthSequence"_ustr ); if( nWhichId == SCHATTR_BAR_OVERLAP ) aPropName = "OverlapSequence"; - uno::Reference< XDataSeries > xDataSeries( GetPropertySet(), uno::UNO_QUERY ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(m_xChartModel) ); - uno::Reference< beans::XPropertySet > xChartTypeProps( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ), uno::UNO_QUERY ); - if( xChartTypeProps.is() ) + rtl::Reference< DataSeries > xDataSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) ); + rtl::Reference< Diagram > xDiagram( m_xChartModel->getFirstChartDiagram() ); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xDataSeries ) ); + if( xChartType.is() ) { - sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + sal_Int32 nAxisIndex = xDataSeries->getAttachedAxisIndex(); uno::Sequence< sal_Int32 > aBarPositionSequence; - if( xChartTypeProps.is() ) + if( xChartType->getPropertyValue( aPropName ) >>= aBarPositionSequence ) { - if( xChartTypeProps->getPropertyValue( aPropName ) >>= aBarPositionSequence ) + bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); + if(!bGroupBarsPerAxis) { - bool bGroupBarsPerAxis = rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS ).GetValue(); - if(!bGroupBarsPerAxis) - { - //set the same value for all axes - for( auto & pos : aBarPositionSequence ) - pos = rBarPosition; - } - else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) - aBarPositionSequence[nAxisIndex] = rBarPosition; - - xChartTypeProps->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); - bChanged = true; + //set the same value for all axes + for( auto & pos : asNonConstRange(aBarPositionSequence) ) + pos = rBarPosition; } + else if( nAxisIndex >= 0 && nAxisIndex < aBarPositionSequence.getLength() ) + aBarPositionSequence.getArray()[nAxisIndex] = rBarPosition; + + xChartType->setPropertyValue( aPropName, uno::Any(aBarPositionSequence) ); + bChanged = true; } } } @@ -242,12 +236,12 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingBarConnectors ) { bool bOldConnectBars = false; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() && - (xDiagramProperties->getPropertyValue( "ConnectBars" ) >>= bOldConnectBars) && + (xDiagramProperties->getPropertyValue( u"ConnectBars"_ustr ) >>= bOldConnectBars) && bOldConnectBars != m_bConnectBars ) { - xDiagramProperties->setPropertyValue( "ConnectBars" , uno::Any(m_bConnectBars) ); + xDiagramProperties->setPropertyValue( u"ConnectBars"_ustr , uno::Any(m_bConnectBars) ); bChanged = true; } } @@ -261,12 +255,12 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingAxisSideBySide ) { bool bOldGroupBarsPerAxis = true; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() && - (xDiagramProperties->getPropertyValue( "GroupBarsPerAxis" ) >>= bOldGroupBarsPerAxis) && + (xDiagramProperties->getPropertyValue( u"GroupBarsPerAxis"_ustr ) >>= bOldGroupBarsPerAxis) && bOldGroupBarsPerAxis != m_bGroupBarsPerAxis ) { - xDiagramProperties->setPropertyValue( "GroupBarsPerAxis" , uno::Any(m_bGroupBarsPerAxis) ); + xDiagramProperties->setPropertyValue( u"GroupBarsPerAxis"_ustr , uno::Any(m_bGroupBarsPerAxis) ); bChanged = true; } } @@ -278,10 +272,10 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf if( m_bSupportingStartingAngle ) { m_nStartingAngle = static_cast< const SdrAngleItem & >( rItemSet.Get( nWhichId )).GetValue().get() / 100; - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() ) { - xDiagramProperties->setPropertyValue( "StartingAngle" , uno::Any(m_nStartingAngle) ); + xDiagramProperties->setPropertyValue( u"StartingAngle"_ustr , uno::Any(m_nStartingAngle) ); bChanged = true; } } @@ -294,7 +288,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf rItemSet.Get( nWhichId )).GetValue(); if( m_xCooSys.is() ) { - uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) ); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( 1, 0, m_xCooSys ); if( xAxis.is() ) { chart2::ScaleData aScaleData( xAxis->getScaleData() ); @@ -315,10 +309,10 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf { try { - uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + rtl::Reference< Diagram > xDiagramProperties( m_xChartModel->getFirstChartDiagram() ); if( xDiagramProperties.is() ) { - xDiagramProperties->setPropertyValue( "MissingValueTreatment" , uno::Any( nNew )); + xDiagramProperties->setPropertyValue( u"MissingValueTreatment"_ustr , uno::Any( nNew )); bChanged = true; } } @@ -337,9 +331,8 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf bool bIncludeHiddenCells = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue(); if (bIncludeHiddenCells != m_bIncludeHiddenCells) { - ChartModel* pModel = dynamic_cast<ChartModel*>(m_xChartModel.get()); - if (pModel) - bChanged = ChartModelHelper::setIncludeHiddenCells( bIncludeHiddenCells, *pModel ); + if (m_xChartModel) + bChanged = m_xChartModel->setIncludeHiddenCells( bIncludeHiddenCells ); } } } @@ -349,7 +342,7 @@ bool SeriesOptionsItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const Sf bool bHideLegendEntry = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue(); if (bHideLegendEntry != m_bHideLegendEntry) { - GetPropertySet()->setPropertyValue("ShowLegendEntry", css::uno::makeAny(!bHideLegendEntry)); + GetPropertySet()->setPropertyValue(u"ShowLegendEntry"_ustr, css::uno::Any(!bHideLegendEntry)); } } break; @@ -399,7 +392,7 @@ void SeriesOptionsItemConverter::FillSpecialItem( case SCHATTR_STARTING_ANGLE: { if( m_bSupportingStartingAngle ) - rOutItemSet.Put( SdrAngleItem(nWhichId, Degree100(m_nStartingAngle*100)) ); + rOutItemSet.Put( SdrAngleItem(SCHATTR_STARTING_ANGLE, Degree100(m_nStartingAngle*100)) ); break; } case SCHATTR_CLOCKWISE: diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx index d9ec4ea1f534..99816e894396 100644 --- a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -20,9 +20,10 @@ #include <StatisticsItemConverter.hxx> #include "SchWhichPairs.hxx" #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <ErrorBar.hxx> #include <StatisticsHelper.hxx> - +#include <ChartModel.hxx> #include <unonames.hxx> #include <svl/stritem.hxx> @@ -31,10 +32,10 @@ #include <rtl/math.hxx> #include <com/sun/star/chart2/XInternalDataProvider.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -49,7 +50,7 @@ uno::Reference< beans::XPropertySet > lcl_GetErrorBar( if( xProp.is()) try { - ( xProp->getPropertyValue( bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X) ) >>= xResult ); + ( xProp->getPropertyValue( bYError ? CHART_UNONAME_ERRORBAR_Y : CHART_UNONAME_ERRORBAR_X ) >>= xResult ); } catch( const uno::Exception & ) { @@ -72,8 +73,8 @@ void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBar try { - xErrorBarProp->getPropertyValue( "PositiveError" ) >>= rOutPosError; - xErrorBarProp->getPropertyValue( "NegativeError" ) >>= rOutNegError; + xErrorBarProp->getPropertyValue( u"PositiveError"_ustr ) >>= rOutPosError; + xErrorBarProp->getPropertyValue( u"NegativeError"_ustr ) >>= rOutNegError; } catch( const uno::Exception & ) { @@ -90,8 +91,8 @@ void lcl_getErrorIndicatorValues( try { - xErrorBarProp->getPropertyValue( "ShowPositiveError" ) >>= rOutShowPosError; - xErrorBarProp->getPropertyValue( "ShowNegativeError" ) >>= rOutShowNegError; + xErrorBarProp->getPropertyValue( u"ShowPositiveError"_ustr ) >>= rOutShowPosError; + xErrorBarProp->getPropertyValue( u"ShowNegativeError"_ustr ) >>= rOutShowNegError; } catch( const uno::Exception & ) { @@ -107,10 +108,9 @@ uno::Reference< beans::XPropertySet > lcl_getEquationProperties( // ensure that a trendline is on if( pItemSet ) { - const SfxPoolItem *pPoolItem = nullptr; - if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem ) == SfxItemState::SET ) + if( const SvxChartRegressItem* pRegressionItem = pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) ) { - SvxChartRegress eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue(); + SvxChartRegress eRegress = pRegressionItem->GetValue(); bEquationExists = ( eRegress != SvxChartRegress::NONE ); } } @@ -118,8 +118,8 @@ uno::Reference< beans::XPropertySet > lcl_getEquationProperties( if( bEquationExists ) { uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY ); - uno::Reference< chart2::XRegressionCurve > xCurve( - ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt )); + rtl::Reference< ::chart::RegressionCurveModel > xCurve = + ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ); if( xCurve.is()) { return xCurve->getEquationProperties(); @@ -137,10 +137,9 @@ uno::Reference< beans::XPropertySet > lcl_getCurveProperties( // ensure that a trendline is on if( pItemSet ) { - const SfxPoolItem *pPoolItem = nullptr; - if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, true, &pPoolItem ) == SfxItemState::SET ) + if( const SvxChartRegressItem* pRegressionItem = pItemSet->GetItemIfSet( SCHATTR_REGRESSION_TYPE ) ) { - SvxChartRegress eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue(); + SvxChartRegress eRegress = pRegressionItem->GetValue(); bExists = ( eRegress != SvxChartRegress::NONE ); } } @@ -148,13 +147,10 @@ uno::Reference< beans::XPropertySet > lcl_getCurveProperties( if( bExists ) { uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY ); - uno::Reference< chart2::XRegressionCurve > xCurve( + rtl::Reference< ::chart::RegressionCurveModel > xCurve( ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt )); if( xCurve.is()) - { - uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - return xProperties; - } + return xCurve; } return uno::Reference< beans::XPropertySet >(); @@ -192,12 +188,12 @@ void lclConvertToItemSet(SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::R } } -void lclConvertToItemSetDouble(SfxItemSet& rItemSet, sal_uInt16 nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID) +void lclConvertToItemSetDouble(SfxItemSet& rItemSet, TypedWhichId<SvxDoubleItem> nWhichId, const uno::Reference<beans::XPropertySet>& xProperties, const OUString& aPropertyID) { OSL_ASSERT(xProperties.is()); if( xProperties.is() ) { - double aValue = static_cast<const SvxDoubleItem&>(rItemSet.Get( nWhichId )).GetValue(); + double aValue = rItemSet.Get( nWhichId ).GetValue(); if(xProperties->getPropertyValue( aPropertyID ) >>= aValue) { rItemSet.Put(SvxDoubleItem( aValue, nWhichId )); @@ -211,11 +207,11 @@ namespace chart::wrapper { StatisticsItemConverter::StatisticsItemConverter( - const uno::Reference< frame::XModel > & xModel, + rtl::Reference<::chart::ChartModel> xModel, const uno::Reference< beans::XPropertySet > & rPropertySet, SfxItemPool& rItemPool ) : ItemConverter( rPropertySet, rItemPool ), - m_xModel( xModel ) + m_xModel(std::move( xModel )) { } @@ -223,7 +219,7 @@ StatisticsItemConverter::~StatisticsItemConverter() { } -const sal_uInt16 * StatisticsItemConverter::GetWhichPairs() const +const WhichRangesContainer& StatisticsItemConverter::GetWhichPairs() const { // must span all used items! return nStatWhichPairs; @@ -309,11 +305,11 @@ bool StatisticsItemConverter::ApplySpecialItem( if( !xErrorBarProp.is() ) { xErrorBarProp = lcl_GetDefaultErrorBar(); - GetPropertySet()->setPropertyValue( bYError ? OUString(CHART_UNONAME_ERRORBAR_Y) : OUString(CHART_UNONAME_ERRORBAR_X), + GetPropertySet()->setPropertyValue( bYError ? CHART_UNONAME_ERRORBAR_Y : CHART_UNONAME_ERRORBAR_X, uno::Any( xErrorBarProp )); } - xErrorBarProp->setPropertyValue( "ErrorBarStyle" , uno::Any( nStyle )); + xErrorBarProp->setPropertyValue( u"ErrorBarStyle"_ustr , uno::Any( nStyle )); bChanged = true; } } @@ -340,8 +336,8 @@ bool StatisticsItemConverter::ApplySpecialItem( ! ( ::rtl::math::approxEqual( fPos, fValue ) && ::rtl::math::approxEqual( fNeg, fValue ))) { - xErrorBarProp->setPropertyValue( "PositiveError" , uno::Any( fValue )); - xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"PositiveError"_ustr , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"NegativeError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -365,7 +361,7 @@ bool StatisticsItemConverter::ApplySpecialItem( if( bOldHasErrorBar && ! ::rtl::math::approxEqual( fPos, fValue )) { - xErrorBarProp->setPropertyValue( "PositiveError" , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"PositiveError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -388,7 +384,7 @@ bool StatisticsItemConverter::ApplySpecialItem( if( bOldHasErrorBar && ! ::rtl::math::approxEqual( fNeg, fValue )) { - xErrorBarProp->setPropertyValue( "NegativeError" , uno::Any( fValue )); + xErrorBarProp->setPropertyValue( u"NegativeError"_ustr , uno::Any( fValue )); bChanged = true; } } @@ -436,84 +432,84 @@ bool StatisticsItemConverter::ApplySpecialItem( case SCHATTR_REGRESSION_DEGREE: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "PolynomialDegree"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"PolynomialDegree"_ustr); } break; case SCHATTR_REGRESSION_PERIOD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAveragePeriod"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"MovingAveragePeriod"_ustr); } break; case SCHATTR_REGRESSION_MOVING_TYPE: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, "MovingAverageType"); + bChanged = lclConvertToPropertySet<sal_Int32, SfxInt32Item>(rItemSet, nWhichId, xProperties, u"MovingAverageType"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateForward"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"ExtrapolateForward"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "ExtrapolateBackward"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"ExtrapolateBackward"_ustr); } break; case SCHATTR_REGRESSION_SET_INTERCEPT: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, "ForceIntercept"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xProperties, u"ForceIntercept"_ustr); } break; case SCHATTR_REGRESSION_INTERCEPT_VALUE: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, "InterceptValue"); + bChanged = lclConvertToPropertySet<double, SvxDoubleItem>(rItemSet, nWhichId, xProperties, u"InterceptValue"_ustr); } break; case SCHATTR_REGRESSION_CURVE_NAME: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, "CurveName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xProperties, u"CurveName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowEquation"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, u"ShowEquation"_ustr); } break; case SCHATTR_REGRESSION_XNAME: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "XName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, u"XName"_ustr); } break; case SCHATTR_REGRESSION_YNAME: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, "YName"); + bChanged = lclConvertToPropertySet<OUString, SfxStringItem>(rItemSet, nWhichId, xEqProp, u"YName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_COEFF: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); - bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient"); + bChanged = lclConvertToPropertySet<bool, SfxBoolItem>(rItemSet, nWhichId, xEqProp, u"ShowCorrelationCoefficient"_ustr); } break; @@ -539,8 +535,8 @@ bool StatisticsItemConverter::ApplySpecialItem( ( bShowPos != bNewIndPos || bShowNeg != bNewIndNeg )) { - xErrorBarProp->setPropertyValue( "ShowPositiveError" , uno::Any( bNewIndPos )); - xErrorBarProp->setPropertyValue( "ShowNegativeError" , uno::Any( bNewIndNeg )); + xErrorBarProp->setPropertyValue( u"ShowPositiveError"_ustr , uno::Any( bNewIndPos )); + xErrorBarProp->setPropertyValue( u"ShowNegativeError"_ustr , uno::Any( bNewIndNeg )); bChanged = true; } } @@ -553,18 +549,17 @@ bool StatisticsItemConverter::ApplySpecialItem( rItemSet.Get(SCHATTR_STAT_ERRORBAR_TYPE).GetValue(); uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetErrorBar( GetPropertySet(), bYError), uno::UNO_QUERY ); - uno::Reference< chart2::XChartDocument > xChartDoc( m_xModel, uno::UNO_QUERY ); uno::Reference< chart2::data::XDataProvider > xDataProvider; - if( xChartDoc.is()) - xDataProvider.set( xChartDoc->getDataProvider()); + if( m_xModel.is()) + xDataProvider.set( m_xModel->getDataProvider()); if( xErrorBarSource.is() && xDataProvider.is()) { OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue()); bool bApplyNewRange = false; bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS ); - if( xChartDoc->hasInternalDataProvider()) + if( m_xModel->hasInternalDataProvider()) { if( !aNewRange.isEmpty()) { @@ -628,7 +623,7 @@ void StatisticsItemConverter::FillSpecialItem( if( xErrorBarProp.is() ) { sal_Int32 nStyle = 0; - if( xErrorBarProp->getPropertyValue( "ErrorBarStyle" ) >>= nStyle ) + if( xErrorBarProp->getPropertyValue( u"ErrorBarStyle"_ustr ) >>= nStyle ) { switch( nStyle ) { @@ -664,7 +659,7 @@ void StatisticsItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_PERCENT )); } } break; @@ -678,7 +673,7 @@ void StatisticsItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, SCHATTR_STAT_BIGERROR )); } } break; @@ -692,7 +687,7 @@ void StatisticsItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( fPos, SCHATTR_STAT_CONSTPLUS )); } } break; @@ -706,7 +701,7 @@ void StatisticsItemConverter::FillSpecialItem( { double fPos(0.0), fNeg(0.0); lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); - rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); + rOutItemSet.Put( SvxDoubleItem( fNeg, SCHATTR_STAT_CONSTMINUS )); } } break; @@ -725,84 +720,84 @@ void StatisticsItemConverter::FillSpecialItem( { uno::Reference<beans::XPropertySet> xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "PolynomialDegree"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"PolynomialDegree"_ustr); } break; case SCHATTR_REGRESSION_PERIOD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAveragePeriod"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"MovingAveragePeriod"_ustr); } break; case SCHATTR_REGRESSION_MOVING_TYPE: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, "MovingAverageType"); + lclConvertToItemSet<sal_Int32, SfxInt32Item>(rOutItemSet, nWhichId, xProperties, u"MovingAverageType"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateForward"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_FORWARD, xProperties, u"ExtrapolateForward"_ustr); } break; case SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "ExtrapolateBackward"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_EXTRAPOLATE_BACKWARD, xProperties, u"ExtrapolateBackward"_ustr); } break; case SCHATTR_REGRESSION_SET_INTERCEPT: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, "ForceIntercept"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xProperties, u"ForceIntercept"_ustr); } break; case SCHATTR_REGRESSION_INTERCEPT_VALUE: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSetDouble(rOutItemSet, nWhichId, xProperties, "InterceptValue"); + lclConvertToItemSetDouble(rOutItemSet, SCHATTR_REGRESSION_INTERCEPT_VALUE, xProperties, u"InterceptValue"_ustr); } break; case SCHATTR_REGRESSION_CURVE_NAME: { uno::Reference< beans::XPropertySet > xProperties( lcl_getCurveProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, "CurveName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xProperties, u"CurveName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowEquation"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, u"ShowEquation"_ustr); } break; case SCHATTR_REGRESSION_XNAME: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, "XName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, u"XName"_ustr); } break; case SCHATTR_REGRESSION_YNAME: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, "YName"); + lclConvertToItemSet<OUString, SfxStringItem>(rOutItemSet, nWhichId, xEqProp, u"YName"_ustr); } break; case SCHATTR_REGRESSION_SHOW_COEFF: { uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), nullptr )); - lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, "ShowCorrelationCoefficient"); + lclConvertToItemSet<bool, SfxBoolItem>(rOutItemSet, nWhichId, xEqProp, u"ShowCorrelationCoefficient"_ustr); } break; diff --git a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx index f7849456d401..de12adcc9739 100644 --- a/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TextLabelItemConverter.cxx @@ -19,10 +19,13 @@ #include <TextLabelItemConverter.hxx> #include <CharacterPropertyItemConverter.hxx> -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> -#include <DiagramHelper.hxx> +#include <DataSeriesProperties.hxx> +#include <Diagram.hxx> #include <ItemPropertyMap.hxx> #include "SchWhichPairs.hxx" #include <unonames.hxx> @@ -35,7 +38,7 @@ #include <svl/stritem.hxx> #include <svx/tabline.hxx> #include <svx/sdangitm.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/graph.hxx> #include <rtl/math.hxx> @@ -44,12 +47,12 @@ #include <com/sun/star/chart2/DataPointLabel.hpp> #include <com/sun/star/chart2/Symbol.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <memory> using namespace com::sun::star; using namespace com::sun::star::chart2; using com::sun::star::uno::Reference; +using namespace ::chart::DataSeriesProperties; namespace chart::wrapper { @@ -98,7 +101,7 @@ bool numberFormatFromItemToPropertySet( if (!xPropertySet.is()) return bChanged; - OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? OUString(CHART_UNONAME_NUMFMT) : OUString("PercentageNumberFormat"); + OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr; sal_uInt16 nSourceWhich = (nWhichId == SID_ATTR_NUMBERFORMAT_VALUE) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE; if (rItemSet.GetItemState(nSourceWhich) != SfxItemState::SET) @@ -123,11 +126,11 @@ bool numberFormatFromItemToPropertySet( uno::Any aOldValue = xPropertySet->getPropertyValue(aPropertyName); if (bOverwriteDataPoints) { - Reference<chart2::XDataSeries> xSeries(xPropertySet, uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries( dynamic_cast<DataSeries*>(xPropertySet.get()) ); if (aValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(aPropertyName, aOldValue)) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aValue); + xSeries->setPropertyAlsoToAllAttributedDataPoints(aPropertyName, aValue); bChanged = true; } } @@ -146,7 +149,7 @@ bool useSourceFormatFromItemToPropertySet( bool bChanged = false; if (!xPropertySet.is()) return bChanged; - OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? OUString(CHART_UNONAME_NUMFMT) : OUString("PercentageNumberFormat"); + OUString aPropertyName = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? CHART_UNONAME_NUMFMT : u"PercentageNumberFormat"_ustr; sal_uInt16 nFormatWhich = (nWhichId == SID_ATTR_NUMBERFORMAT_SOURCE) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE; if (rItemSet.GetItemState(nWhichId) != SfxItemState::SET) @@ -173,11 +176,11 @@ bool useSourceFormatFromItemToPropertySet( uno::Any aOldValue(xPropertySet->getPropertyValue(aPropertyName)); if (bOverwriteDataPoints) { - Reference<chart2::XDataSeries> xSeries(xPropertySet, uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(xPropertySet.get())); if (aNewValue != aOldValue || - ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, aPropertyName, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(aPropertyName, aOldValue)) { - ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, aPropertyName, aNewValue); + xSeries->setPropertyAlsoToAllAttributedDataPoints(aPropertyName, aNewValue); bChanged = true; } } @@ -193,10 +196,10 @@ bool useSourceFormatFromItemToPropertySet( } // anonymous namespace TextLabelItemConverter::TextLabelItemConverter( - const uno::Reference<frame::XModel>& xChartModel, + const rtl::Reference<::chart::ChartModel>& xChartModel, const uno::Reference<beans::XPropertySet>& rPropertySet, - const uno::Reference<XDataSeries>& xSeries, - SfxItemPool& rItemPool, const awt::Size* pRefSize, + const rtl::Reference<DataSeries>& xSeries, + SfxItemPool& rItemPool, const std::optional<awt::Size>& pRefSize, bool bDataSeries, sal_Int32 nNumberFormat, sal_Int32 nPercentNumberFormat ) : ItemConverter(rPropertySet, rItemPool), mnNumberFormat(nNumberFormat), @@ -205,16 +208,16 @@ TextLabelItemConverter::TextLabelItemConverter( mbForbidPercentValue(true), m_xSeries(xSeries) { - maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, "ReferencePageSize")); + maConverters.emplace_back(new CharacterPropertyItemConverter(rPropertySet, rItemPool, pRefSize, u"ReferencePageSize"_ustr)); - uno::Reference<XDiagram> xDiagram(ChartModelHelper::findDiagram(xChartModel)); - uno::Reference<XChartType> xChartType(DiagramHelper::getChartTypeOfSeries(xDiagram, xSeries)); + rtl::Reference< Diagram > xDiagram(xChartModel->getFirstChartDiagram()); + rtl::Reference< ChartType > xChartType(xDiagram->getChartTypeOfSeries(xSeries)); bool bFound = false; bool bAmbiguous = false; - bool bSwapXAndY = DiagramHelper::getVertical(xDiagram, bFound, bAmbiguous); + bool bSwapXAndY = xDiagram->getVertical(bFound, bAmbiguous); maAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements(xChartType, bSwapXAndY, xSeries); - mbForbidPercentValue = ChartTypeHelper::getAxisType(xChartType, 0) != AxisType::CATEGORY; + mbForbidPercentValue = xChartType.is() ? xChartType->getAxisType(0) != AxisType::CATEGORY : false; } TextLabelItemConverter::~TextLabelItemConverter() @@ -241,7 +244,7 @@ bool TextLabelItemConverter::ApplyItemSet( const SfxItemSet& rItemSet ) return ItemConverter::ApplyItemSet(rItemSet) || bResult; } -const sal_uInt16* TextLabelItemConverter::GetWhichPairs() const +const WhichRangesContainer& TextLabelItemConverter::GetWhichPairs() const { // must span all used items! return nTextLabelWhichPairs; @@ -285,12 +288,12 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte rValue = rItem.GetValue(); if (mbDataSeries) { - Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (bOldValue != bool(rValue) || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, CHART_UNONAME_LABEL, aOldValue)) + xSeries->hasAttributedDataPointDifferentValue(CHART_UNONAME_LABEL, aOldValue)) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel)); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); + xSeries->setPropertyAlsoToAllAttributedDataPoints(CHART_UNONAME_LABEL, uno::Any(aLabel)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any()); bChanged = true; } } @@ -320,20 +323,20 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte try { OUString aOldValue; - GetPropertySet()->getPropertyValue("LabelSeparator") >>= aOldValue; + GetPropertySet()->getPropertyValue(u"LabelSeparator"_ustr) >>= aOldValue; if (mbDataSeries) { - Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (aOldValue != aNewValue || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, "LabelSeparator", uno::Any(aOldValue))) + xSeries->hasAttributedDataPointDifferentValue(u"LabelSeparator"_ustr, uno::Any(aOldValue))) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "LabelSeparator", uno::Any(aNewValue)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(u"LabelSeparator"_ustr, uno::Any(aNewValue)); bChanged = true; } } else if (aOldValue != aNewValue) { - GetPropertySet()->setPropertyValue("LabelSeparator", uno::Any(aNewValue)); + GetPropertySet()->setPropertyValue(u"LabelSeparator"_ustr, uno::Any(aNewValue)); bChanged = true; } } @@ -350,20 +353,20 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { bool bNew = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); bool bOld = false; - GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bOld; + GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bOld; if( mbDataSeries ) { - Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + rtl::Reference< DataSeries > xSeries( dynamic_cast<DataSeries*>(GetPropertySet().get()) ); if( bOld!=bNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, "TextWordWrap", uno::Any( bOld ) ) ) + xSeries->hasAttributedDataPointDifferentValue( u"TextWordWrap"_ustr, uno::Any( bOld ) ) ) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, "TextWordWrap", uno::Any( bNew ) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( u"TextWordWrap"_ustr, uno::Any( bNew ) ); bChanged = true; } } else if( bOld!=bNew ) { - GetPropertySet()->setPropertyValue( "TextWordWrap", uno::Any( bNew )); + GetPropertySet()->setPropertyValue( u"TextWordWrap"_ustr, uno::Any( bNew )); bChanged = true; } } @@ -380,21 +383,22 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte sal_Int32 nNew = static_cast<const SfxInt32Item&>(rItemSet.Get(nWhichId)).GetValue(); sal_Int32 nOld = -1; RelativePosition aCustomLabelPosition; - GetPropertySet()->getPropertyValue("LabelPlacement") >>= nOld; + GetPropertySet()->getPropertyValue(u"LabelPlacement"_ustr) >>= nOld; if (mbDataSeries) { - Reference<chart2::XDataSeries> xSeries(GetPropertySet(), uno::UNO_QUERY); + rtl::Reference<DataSeries> xSeries(dynamic_cast<DataSeries*>(GetPropertySet().get())); if (nOld != nNew || - DataSeriesHelper::hasAttributedDataPointDifferentValue(xSeries, "LabelPlacement", uno::Any(nOld))) + xSeries->hasAttributedDataPointDifferentValue(u"LabelPlacement"_ustr, uno::Any(nOld))) { - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints(xSeries, "LabelPlacement", uno::Any(nNew)); + xSeries->setPropertyAlsoToAllAttributedDataPoints(u"LabelPlacement"_ustr, uno::Any(nNew)); bChanged = true; } } - else if (nOld != nNew || (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition)) + else if (nOld != nNew || (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition)) { - GetPropertySet()->setPropertyValue("LabelPlacement", uno::Any(nNew)); - GetPropertySet()->setPropertyValue("CustomLabelPosition", uno::Any()); + GetPropertySet()->setPropertyValue(u"LabelPlacement"_ustr, uno::Any(nNew)); + GetPropertySet()->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any()); + GetPropertySet()->setPropertyValue(u"CustomLabelSize"_ustr, uno::Any()); bChanged = true; } } @@ -411,7 +415,7 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte rItemSet.Get(nWhichId)).GetValue(); chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol; + GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; sal_Int32 nOldStyle = getSymbolStyleForSymbol(aSymbol); if (nStyle != nOldStyle) @@ -438,9 +442,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte } if (bDeleteSymbol) - GetPropertySet()->setPropertyValue("Symbol", uno::Any()); + GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any()); else - GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol)); + GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); bChanged = true; } } @@ -451,14 +455,14 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte rItemSet.Get(nWhichId)).GetSize(); chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol; + GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; if (aSize.getWidth() != aSymbol.Size.Width || aSize.getHeight() != aSymbol.Size.Height) { aSymbol.Size.Width = aSize.getWidth(); aSymbol.Size.Height = aSize.getHeight(); - GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol)); + GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); bChanged = true; } } @@ -476,11 +480,11 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { aXGraphicAny <<= xGraphic; chart2::Symbol aSymbol; - GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol; + GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol; if (aSymbol.Graphic != xGraphic) { - aSymbol.Graphic = xGraphic; - GetPropertySet()->setPropertyValue("Symbol", uno::Any(aSymbol)); + aSymbol.Graphic = std::move(xGraphic); + GetPropertySet()->setPropertyValue(u"Symbol"_ustr, uno::Any(aSymbol)); bChanged = true; } } @@ -494,11 +498,11 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte rItemSet.Get(nWhichId)).GetValue().get()) / 100.0; double fOldValue = 0.0; bool bPropExisted = - (GetPropertySet()->getPropertyValue("TextRotation") >>= fOldValue); + (GetPropertySet()->getPropertyValue(u"TextRotation"_ustr) >>= fOldValue); if (!bPropExisted || fOldValue != fValue) { - GetPropertySet()->setPropertyValue("TextRotation", uno::Any(fValue)); + GetPropertySet()->setPropertyValue(u"TextRotation"_ustr, uno::Any(fValue)); bChanged = true; } } @@ -509,10 +513,9 @@ bool TextLabelItemConverter::ApplySpecialItem( sal_uInt16 nWhichId, const SfxIte { bool bNew = static_cast<const SfxBoolItem&>(rItemSet.Get(nWhichId)).GetValue(); bool bOld = true; - Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); - if( (xSeriesProp->getPropertyValue("ShowCustomLeaderLines") >>= bOld) && bOld != bNew ) + if( (m_xSeries->getFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES) >>= bOld) && bOld != bNew ) { - xSeriesProp->setPropertyValue("ShowCustomLeaderLines", uno::Any(bNew)); + m_xSeries->setFastPropertyValue(PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES, uno::Any(bNew)); bChanged = true; } } @@ -547,13 +550,13 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); - if (mbDataSeries) + DataSeries* pDataSeries = mbDataSeries + ? dynamic_cast<DataSeries*>(GetPropertySet().get()) + : nullptr; + if (pDataSeries && pDataSeries->hasAttributedDataPointDifferentValue( + CHART_UNONAME_LABEL, uno::Any(aLabel))) { - if (DataSeriesHelper::hasAttributedDataPointDifferentValue( - Reference<chart2::XDataSeries>(GetPropertySet(), uno::UNO_QUERY), CHART_UNONAME_LABEL, uno::Any(aLabel))) - { - rOutItemSet.InvalidateItem(nWhichId); - } + rOutItemSet.InvalidateItem(nWhichId); } } } @@ -569,7 +572,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: { sal_Int32 nKey = 0; - if (!(GetPropertySet()->getPropertyValue("PercentageNumberFormat") >>= nKey)) + if (!(GetPropertySet()->getPropertyValue(u"PercentageNumberFormat"_ustr) >>= nKey)) nKey = mnPercentNumberFormat; rOutItemSet.Put(SfxUInt32Item(nWhichId, nKey)); } @@ -600,7 +603,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r { TOOLS_WARN_EXCEPTION("chart2", ""); } - bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue("PercentageNumberFormat").hasValue() && !bUseSourceFormat; + bool bNumberFormatIsSet = GetPropertySet()->getPropertyValue(u"PercentageNumberFormat"_ustr).hasValue() && !bUseSourceFormat; rOutItemSet.Put(SfxBoolItem(nWhichId, !bNumberFormatIsSet)); } break; @@ -609,7 +612,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r try { OUString aValue; - GetPropertySet()->getPropertyValue("LabelSeparator") >>= aValue; + GetPropertySet()->getPropertyValue(u"LabelSeparator"_ustr) >>= aValue; rOutItemSet.Put(SfxStringItem(nWhichId, aValue)); } catch (const uno::Exception&) @@ -623,7 +626,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r try { bool bValue = false; - GetPropertySet()->getPropertyValue( "TextWordWrap" ) >>= bValue; + GetPropertySet()->getPropertyValue( u"TextWordWrap"_ustr ) >>= bValue; rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); } catch( const uno::Exception& ) @@ -638,9 +641,9 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r { sal_Int32 nPlacement = 0; RelativePosition aCustomLabelPosition; - if (!mbDataSeries && (GetPropertySet()->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition)) + if (!mbDataSeries && (GetPropertySet()->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition)) rOutItemSet.Put(SfxInt32Item(nWhichId, css::chart::DataLabelPlacement::CUSTOM)); - else if (GetPropertySet()->getPropertyValue("LabelPlacement") >>= nPlacement) + else if (GetPropertySet()->getPropertyValue(u"LabelPlacement"_ustr) >>= nPlacement) rOutItemSet.Put(SfxInt32Item(nWhichId, nPlacement)); else if (maAvailableLabelPlacements.hasElements()) rOutItemSet.Put(SfxInt32Item(nWhichId, maAvailableLabelPlacements[0])); @@ -666,8 +669,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r try { bool bValue = true; - Reference<beans::XPropertySet> xSeriesProp(m_xSeries, uno::UNO_QUERY); - if( xSeriesProp->getPropertyValue( "ShowCustomLeaderLines" ) >>= bValue ) + if( m_xSeries->getFastPropertyValue( PROP_DATASERIES_SHOW_CUSTOM_LEADERLINES ) >>= bValue ) rOutItemSet.Put(SfxBoolItem(nWhichId, bValue)); } catch (const uno::Exception&) @@ -679,14 +681,14 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r case SCHATTR_STYLE_SYMBOL: { chart2::Symbol aSymbol; - if (GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol) + if (GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) rOutItemSet.Put(SfxInt32Item(nWhichId, getSymbolStyleForSymbol(aSymbol))); } break; case SCHATTR_SYMBOL_SIZE: { chart2::Symbol aSymbol; - if (GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol) + if (GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) rOutItemSet.Put( SvxSizeItem(nWhichId, Size(aSymbol.Size.Width, aSymbol.Size.Height))); } @@ -694,7 +696,7 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r case SCHATTR_SYMBOL_BRUSH: { chart2::Symbol aSymbol; - if ((GetPropertySet()->getPropertyValue("Symbol") >>= aSymbol) + if ((GetPropertySet()->getPropertyValue(u"Symbol"_ustr) >>= aSymbol) && aSymbol.Graphic.is()) { rOutItemSet.Put( @@ -706,10 +708,10 @@ void TextLabelItemConverter::FillSpecialItem( sal_uInt16 nWhichId, SfxItemSet& r { double fValue = 0; - if (GetPropertySet()->getPropertyValue("TextRotation") >>= fValue) + if (GetPropertySet()->getPropertyValue(u"TextRotation"_ustr) >>= fValue) { rOutItemSet.Put( - SdrAngleItem(nWhichId, Degree100(static_cast<sal_Int32>(rtl::math::round(fValue * 100.0))))); + SdrAngleItem(SCHATTR_TEXT_DEGREES, Degree100(static_cast<sal_Int32>(rtl::math::round(fValue * 100.0))))); } } break; diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx index 9109bc3ea3a1..23341ac287bd 100644 --- a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx @@ -23,7 +23,7 @@ #include <GraphicPropertyItemConverter.hxx> #include <CharacterPropertyItemConverter.hxx> #include <MultipleItemConverter.hxx> -#include <svl/intitem.hxx> +#include <ChartModel.hxx> #include <svx/sdangitm.hxx> #include <rtl/math.hxx> @@ -51,11 +51,11 @@ public: FormattedStringsConverter( const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings, SfxItemPool & rItemPool, - const awt::Size* pRefSize, + const std::optional<awt::Size>& pRefSize, const uno::Reference< beans::XPropertySet > & xParentProp ); protected: - virtual const sal_uInt16 * GetWhichPairs() const override; + virtual const WhichRangesContainer& GetWhichPairs() const override; }; } // anonymous namespace @@ -63,7 +63,7 @@ protected: FormattedStringsConverter::FormattedStringsConverter( const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings, SfxItemPool & rItemPool, - const awt::Size* pRefSize, + const std::optional<awt::Size>& pRefSize, const uno::Reference< beans::XPropertySet > & xParentProp ) : MultipleItemConverter( rItemPool ) { @@ -76,14 +76,14 @@ FormattedStringsConverter::FormattedStringsConverter( if( bHasRefSize ) m_aConverters.emplace_back( new CharacterPropertyItemConverter( - xProp, rItemPool, pRefSize, "ReferencePageSize", xParentProp)); + xProp, rItemPool, pRefSize, u"ReferencePageSize"_ustr, xParentProp)); else m_aConverters.emplace_back( new CharacterPropertyItemConverter( xProp, rItemPool )); } } } -const sal_uInt16 * FormattedStringsConverter::GetWhichPairs() const +const WhichRangesContainer& FormattedStringsConverter::GetWhichPairs() const { return nCharacterPropertyWhichPairs; } @@ -92,13 +92,13 @@ TitleItemConverter::TitleItemConverter( const uno::Reference<beans::XPropertySet> & rPropertySet, SfxItemPool& rItemPool, SdrModel& rDrawModel, - const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, - const awt::Size* pRefSize ) : + const rtl::Reference< ChartModel > & xChartModel, + const std::optional<awt::Size>& pRefSize ) : ItemConverter( rPropertySet, rItemPool ) { m_aConverters.emplace_back( new GraphicPropertyItemConverter( rPropertySet, rItemPool, rDrawModel, - xNamedPropertyContainerFactory, + xChartModel, GraphicObjectType::LineAndFillProperties )); // CharacterProperties are not at the title but at its contained XFormattedString objects @@ -139,7 +139,7 @@ bool TitleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) return ItemConverter::ApplyItemSet( rItemSet ) || bResult; } -const sal_uInt16 * TitleItemConverter::GetWhichPairs() const +const WhichRangesContainer& TitleItemConverter::GetWhichPairs() const { // must span all used items! return nTitleWhichPairs; @@ -172,11 +172,11 @@ bool TitleItemConverter::ApplySpecialItem( rItemSet.Get( nWhichId )).GetValue().get()) / 100.0; double fOldVal = 0.0; bool bPropExisted = - ( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fOldVal ); + ( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fOldVal ); if( ! bPropExisted || fOldVal != fVal ) { - GetPropertySet()->setPropertyValue( "TextRotation" , uno::Any( fVal )); + GetPropertySet()->setPropertyValue( u"TextRotation"_ustr , uno::Any( fVal )); bChanged = true; } } @@ -196,9 +196,9 @@ void TitleItemConverter::FillSpecialItem( // convert double to int (times 100) double fVal = 0; - if( GetPropertySet()->getPropertyValue( "TextRotation" ) >>= fVal ) + if( GetPropertySet()->getPropertyValue( u"TextRotation"_ustr ) >>= fVal ) { - rOutItemSet.Put( SdrAngleItem( nWhichId, Degree100(static_cast< sal_Int32 >( + rOutItemSet.Put( SdrAngleItem( SCHATTR_TEXT_DEGREES, Degree100(static_cast< sal_Int32 >( ::rtl::math::round( fVal * 100.0 ) ) ))); } } diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx index 5adc15f78a09..d49f49497f9f 100644 --- a/chart2/source/controller/main/ChartController.cxx +++ b/chart2/source/controller/main/ChartController.cxx @@ -20,68 +20,69 @@ #include <memory> #include <sal/config.h> +#include <config_wasm_strip.h> #include <ChartController.hxx> +#include <ChartView.hxx> #include <servicenames.hxx> #include <ResId.hxx> #include <dlg_DataSource.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include "ControllerCommandDispatch.hxx" +#include <DataSeries.hxx> +#include <Diagram.hxx> #include <strings.hrc> -#include <chartview/ExplicitValueProvider.hxx> #include <ChartViewHelper.hxx> #include <ChartWindow.hxx> #include <chartview/DrawModelWrapper.hxx> #include <DrawViewWrapper.hxx> #include <ObjectIdentifier.hxx> -#include <DiagramHelper.hxx> #include <ControllerLockGuard.hxx> #include "UndoGuard.hxx" #include "ChartDropTargetHelper.hxx" #include <dlg_ChartType.hxx> +#if !ENABLE_WASM_STRIP_ACCESSIBILITY #include <AccessibleChartView.hxx> +#endif #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" #include "UndoActions.hxx" #include <ViewElementListProvider.hxx> -#include <cppuhelper/supportsservice.hxx> -#include <comphelper/servicehelper.hxx> +#include <comphelper/dispatchcommand.hxx> +#include <BaseCoordinateSystem.hxx> -#include <com/sun/star/awt/XWindowPeer.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/data/XDataReceiver.hpp> #include <com/sun/star/frame/XController2.hpp> #include <com/sun/star/util/CloseVetoException.hpp> -#include <com/sun/star/util/XModeChangeBroadcaster.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/frame/LayoutManagerEvents.hpp> #include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp> -#include <com/sun/star/document/XUndoManagerSupplier.hpp> #include <com/sun/star/ui/XSidebar.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <com/sun/star/chart2/XDataProviderAccess.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> #include <sal/log.hxx> #include <tools/debug.hxx> #include <svx/sidebar/SelectionChangeHandler.hxx> #include <toolkit/helper/vclunohelper.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <vcl/weld.hxx> #include <osl/mutex.hxx> +#include <comphelper/lok.hxx> #include <sfx2/sidebar/SidebarController.hxx> - +#include <com/sun/star/awt/XVclWindowPeer.hpp> #include <com/sun/star/frame/XLayoutManager.hpp> // this is needed to properly destroy the unique_ptr to the AcceleratorExecute // object in the DTOR #include <svtools/acceleratorexecute.hxx> #include <svx/ActionDescriptionProvider.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> + +#include <editeng/fontitem.hxx> // enable the following define to let the controller listen to model changes and // react on this by rebuilding the view @@ -96,16 +97,13 @@ using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; using ::com::sun::star::uno::Sequence; -ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext) : +ChartController::ChartController(uno::Reference<uno::XComponentContext> xContext) : m_aLifeTimeManager( nullptr ), m_bSuspended( false ), - m_xCC(xContext), //@todo is it allowed to hold this context?? - m_aModelMutex(), + m_xCC(std::move(xContext)), m_aModel( nullptr, m_aModelMutex ), - m_xViewWindow(), - m_xChartView(), - m_pDrawModelWrapper(), m_eDragMode(SdrDragMode::Move), + m_aDoubleClickTimer("chart2 ChartController m_aDoubleClickTimer"), m_bWaitingForDoubleClick(false), m_bWaitingForMouseUp(false), m_bFieldButtonDown(false), @@ -125,12 +123,10 @@ ChartController::~ChartController() stopDoubleClickWaiting(); } -ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel ) : - m_xModel( xModel ), +ChartController::TheModel::TheModel( rtl::Reference<::chart::ChartModel> xModel ) : + m_xModel(std::move( xModel )), m_bOwnership( true ) { - m_xCloseable = - uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY ); } ChartController::TheModel::~TheModel() @@ -139,33 +135,22 @@ ChartController::TheModel::~TheModel() void ChartController::TheModel::addListener( ChartController* pController ) { - if(m_xCloseable.is()) + if(m_xModel) { //if you need to be able to veto against the destruction of the model // you must add as a close listener //otherwise you 'can' add as closelistener or 'must' add as dispose event listener - m_xCloseable->addCloseListener( - static_cast<util::XCloseListener*>(pController) ); - } - else if( m_xModel.is() ) - { - //we need to add as dispose event listener - m_xModel->addEventListener( + m_xModel->addCloseListener( static_cast<util::XCloseListener*>(pController) ); } - } void ChartController::TheModel::removeListener( ChartController* pController ) { - if(m_xCloseable.is()) - m_xCloseable->removeCloseListener( - static_cast<util::XCloseListener*>(pController) ); - - else if( m_xModel.is() ) - m_xModel->removeEventListener( + if(m_xModel) + m_xModel->removeCloseListener( static_cast<util::XCloseListener*>(pController) ); } @@ -176,7 +161,7 @@ void ChartController::TheModel::tryTermination() try { - if(m_xCloseable.is()) + if(m_xModel.is()) { try { @@ -184,7 +169,7 @@ void ChartController::TheModel::tryTermination() //I think yes, because there might be other CloseListeners later in the list which might be interested still //but make sure that we do not throw the CloseVetoException here ourselves //so stop listening before trying to terminate or check the source of queryclosing event - m_xCloseable->close(true); + m_xModel->close(true); m_bOwnership = false; } @@ -199,12 +184,6 @@ void ChartController::TheModel::tryTermination() } } - else if( m_xModel.is() ) - { - //@todo correct?? - m_xModel->dispose(); - return; - } } catch(const uno::Exception&) { @@ -248,26 +227,17 @@ bool ChartController::TheModelRef::is() const namespace { -css::uno::Reference<css::chart2::XChartType> getChartType( - const css::uno::Reference<css::chart2::XChartDocument>& xChartDoc) +rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& xChartDoc) { - Reference <chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram(); - if (!xDiagram.is()) { - return css::uno::Reference<css::chart2::XChartType>(); - } - - Reference< chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, uno::UNO_QUERY_THROW ); - - Sequence< Reference< chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems()); - if (!xCooSysSequence.hasElements()) { - return css::uno::Reference<css::chart2::XChartType>(); - } - - Reference< chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], uno::UNO_QUERY_THROW ); + rtl::Reference<Diagram > xDiagram = xChartDoc->getFirstChartDiagram(); + if (!xDiagram.is()) + return nullptr; - Sequence< Reference< chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); + const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems()); + if (xCooSysSequence.empty()) + return nullptr; - return xChartTypeSequence[0]; + return xCooSysSequence[0]->getChartTypes2()[0]; } } @@ -279,42 +249,49 @@ OUString ChartController::GetContextName() uno::Any aAny = getSelection(); if (!aAny.hasValue()) - return "Chart"; + return u"Chart"_ustr; OUString aCID; aAny >>= aCID; if (aCID.isEmpty()) - return "Chart"; + return u"Chart"_ustr; ObjectType eObjectID = ObjectIdentifier::getObjectType(aCID); switch (eObjectID) { case OBJECTTYPE_DATA_SERIES: - return "Series"; + return u"Series"_ustr; case OBJECTTYPE_DATA_ERRORS_X: case OBJECTTYPE_DATA_ERRORS_Y: case OBJECTTYPE_DATA_ERRORS_Z: - return "ErrorBar"; + return u"ErrorBar"_ustr; case OBJECTTYPE_AXIS: - return "Axis"; + return u"Axis"_ustr; case OBJECTTYPE_GRID: - return "Grid"; + return u"Grid"_ustr; case OBJECTTYPE_DIAGRAM: { - css::uno::Reference<css::chart2::XChartType> xChartType = getChartType(css::uno::Reference<css::chart2::XChartDocument>(getModel(), uno::UNO_QUERY)); + rtl::Reference<ChartType> xChartType = getChartType(getChartModel()); if (xChartType.is() && xChartType->getChartType() == "com.sun.star.chart2.PieChartType") - return "ChartElements"; + return u"ChartElements"_ustr; break; } case OBJECTTYPE_DATA_CURVE: case OBJECTTYPE_DATA_AVERAGE_LINE: - return "Trendline"; + return u"Trendline"_ustr; + case OBJECTTYPE_TITLE: + return u"ChartTitle"_ustr; + case OBJECTTYPE_LEGEND: + return u"ChartLegend"_ustr; + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + return u"ChartLabel"_ustr; default: break; } - return "Chart"; + return u"Chart"_ustr; } // private methods @@ -332,27 +309,6 @@ bool ChartController::impl_isDisposedOrSuspended() const return false; } -// lang::XServiceInfo - -OUString SAL_CALL ChartController::getImplementationName() -{ - return CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME; -} - -sal_Bool SAL_CALL ChartController::supportsService( const OUString& rServiceName ) -{ - return cppu::supportsService(this, rServiceName); -} - -css::uno::Sequence< OUString > SAL_CALL ChartController::getSupportedServiceNames() -{ - return { - CHART_CONTROLLER_SERVICE_NAME, - "com.sun.star.frame.Controller" - //// @todo : add additional services if you support any further - }; -} - namespace { uno::Reference<ui::XSidebar> getSidebarFromModel(const uno::Reference<frame::XModel>& xModel) @@ -388,19 +344,6 @@ void SAL_CALL ChartController::attachFrame( if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended? return; //behave passive if already disposed or suspended - mpSelectionChangeHandler->Connect(); - - uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel()); - if (xSidebar.is()) - { - auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()); - assert(pSidebar); - sfx2::sidebar::SidebarController::registerSidebarForFrame(pSidebar, this); - pSidebar->updateModel(getModel()); - css::lang::EventObject aEvent; - mpSelectionChangeHandler->selectionChanged(aEvent); - } - if(m_xFrame.is()) //what happens, if we do have a Frame already?? { //@todo? throw exception? @@ -411,6 +354,20 @@ void SAL_CALL ChartController::attachFrame( //--attach frame m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent + // Only notify after setting the frame, otherwise notification will fail + mpSelectionChangeHandler->Connect(); + + uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel()); + if (xSidebar.is()) + { + auto pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get()); + assert(pSidebar); + pSidebar->registerSidebarForFrame(this); + pSidebar->updateModel(getChartModel()); + css::lang::EventObject aEvent; + mpSelectionChangeHandler->selectionChanged(aEvent); + } + //add as disposelistener to the frame (due to persistent reference) ??...: //the frame is considered to be owner of this controller and will live longer than we do @@ -439,8 +396,7 @@ void SAL_CALL ChartController::attachFrame( m_xViewWindow.set( pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); pChartWindow->Show(); m_apDropTargetHelper.reset( - new ChartDropTargetHelper( pChartWindow->GetDropTarget(), - uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY ))); + new ChartDropTargetHelper( pChartWindow->GetDropTarget(), getChartModel())); impl_createDrawViewController(); } @@ -453,23 +409,23 @@ void SAL_CALL ChartController::attachFrame( try { uno::Reference< css::frame::XLayoutManager > xLayoutManager; - xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager; + xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager; if ( xLayoutManager.is() ) { xLayoutManager->lock(); - xLayoutManager->requestElement( "private:resource/menubar/menubar" ); + xLayoutManager->requestElement( u"private:resource/menubar/menubar"_ustr ); //@todo: createElement should become unnecessary, remove when #i79198# is fixed - xLayoutManager->createElement( "private:resource/toolbar/standardbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/standardbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/standardbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/standardbar"_ustr ); //@todo: createElement should become unnecessary, remove when #i79198# is fixed - xLayoutManager->createElement( "private:resource/toolbar/toolbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/toolbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/toolbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/toolbar"_ustr ); // #i12587# support for shapes in chart - xLayoutManager->createElement( "private:resource/toolbar/drawbar" ); - xLayoutManager->requestElement( "private:resource/toolbar/drawbar" ); + xLayoutManager->createElement( u"private:resource/toolbar/drawbar"_ustr ); + xLayoutManager->requestElement( u"private:resource/toolbar/drawbar"_ustr ); - xLayoutManager->requestElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->requestElement( u"private:resource/statusbar/statusbar"_ustr ); xLayoutManager->unlock(); // add as listener to get notified when @@ -532,14 +488,11 @@ void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent if( m_aSelection.hasSelection() ) this->impl_selectObjectAndNotiy(); else - ChartModelHelper::triggerRangeHighlighting( getModel() ); + getChartModel()->triggerRangeHighlighting(); impl_initializeAccessible(); - { - if( pChartWindow ) - pChartWindow->Invalidate(); - } + pChartWindow->Invalidate(); } m_bConnectingToView = false; @@ -560,23 +513,24 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo return false; //behave passive if already disposed or suspended aGuard.clear(); - TheModelRef aNewModelRef( new TheModel( xModel), m_aModelMutex); + ::chart::ChartModel* pChartModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pChartModel); + + TheModelRef aNewModelRef( new TheModel(pChartModel), m_aModelMutex); TheModelRef aOldModelRef(m_aModel,m_aModelMutex); m_aModel = aNewModelRef; //--handle relations to the old model if any if( aOldModelRef.is() ) { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); m_pDrawModelWrapper.reset(); aOldModelRef->removeListener( this ); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aOldModelRef->getModel().is()) + aOldModelRef->getModel()->removeModifyListener( this ); #endif } @@ -604,23 +558,20 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo aGuard.clear(); #ifdef TEST_ENABLE_MODIFY_LISTENER - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->addModifyListener( this ); + if( aNewModelRef->getModel().is()) + aNewModelRef->getModel()->addModifyListener( this ); #endif // #i119999# Do not do this per default to allow the user to deselect the chart OLE with a single press to ESC // select chart area per default: // select( uno::Any( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ) ); - uno::Reference< lang::XMultiServiceFactory > xFact( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xFact = getChartModel(); if( xFact.is()) { - m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + m_xChartView = xFact->createChartView(); GetDrawModelWrapper(); - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->addModeChangeListener(this); + m_xChartView->addModeChangeListener(this); } //the frameloader is responsible to call xModel->connectController @@ -631,8 +582,7 @@ sal_Bool SAL_CALL ChartController::attachModel( const uno::Reference< frame::XMo pChartWindow->Invalidate(); } - uno::Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( getChartModel()->getUndoManager(), uno::UNO_SET_THROW ); return true; } @@ -647,6 +597,11 @@ uno::Reference< frame::XFrame > SAL_CALL ChartController::getFrame() uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() { + return getChartModel(); +} + +rtl::Reference<::chart::ChartModel> ChartController::getChartModel() +{ //provides access to currently attached model //returns the currently attached model @@ -655,7 +610,12 @@ uno::Reference< frame::XModel > SAL_CALL ChartController::getModel() if(aModelRef.is()) return aModelRef->getModel(); - return uno::Reference< frame::XModel > (); + return nullptr; +} + +rtl::Reference<::chart::Diagram> ChartController::getFirstDiagram() +{ + return getChartModel()->getFirstChartDiagram(); } uno::Any SAL_CALL ChartController::getViewData() @@ -711,6 +671,24 @@ sal_Bool SAL_CALL ChartController::suspend( sal_Bool bSuspend ) return true; } +// css::frame::XController2 + +css::uno::Reference<css::awt::XWindow> SAL_CALL ChartController::getComponentWindow() +{ + // it is a special characteristic of ChartController + // that it simultaneously provides the XWindow functionality + return this; +} + +OUString SAL_CALL ChartController::getViewControllerName() { return {}; } + +css::uno::Sequence<css::beans::PropertyValue> SAL_CALL ChartController::getCreationArguments() +{ + return {}; +} + +css::uno::Reference<css::ui::XSidebarProvider> SAL_CALL ChartController::getSidebar() { return {}; } + void ChartController::impl_createDrawViewController() { SolarMutexGuard aGuard; @@ -718,8 +696,21 @@ void ChartController::impl_createDrawViewController() { if( m_pDrawModelWrapper ) { + bool bLokCalcGlobalRTL = false; + if(comphelper::LibreOfficeKit::isActive() && AllSettings::GetLayoutRTL()) + { + rtl::Reference< ChartModel > xChartModel = getChartModel(); + if (xChartModel.is()) + { + uno::Reference<css::sheet::XSpreadsheetDocument> xSSDoc(xChartModel->getParent(), uno::UNO_QUERY); + if (xSSDoc.is()) + bLokCalcGlobalRTL = true; + } + } + m_pDrawViewWrapper.reset( new DrawViewWrapper(m_pDrawModelWrapper->getSdrModel(),GetChartWindow()->GetOutDev()) ); - m_pDrawViewWrapper->attachParentReferenceDevice( getModel() ); + m_pDrawViewWrapper->SetNegativeX(bLokCalcGlobalRTL); + m_pDrawViewWrapper->attachParentReferenceDevice( getChartModel() ); } } } @@ -746,10 +737,10 @@ void SAL_CALL ChartController::dispose() if (getModel().is()) { - uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getModel()); + uno::Reference<ui::XSidebar> xSidebar = getSidebarFromModel(getChartModel()); if (sfx2::sidebar::SidebarController* pSidebar = dynamic_cast<sfx2::sidebar::SidebarController*>(xSidebar.get())) { - sfx2::sidebar::SidebarController::unregisterSidebarForFrame(pSidebar, this); + pSidebar->unregisterSidebarForFrame(this); } } @@ -772,7 +763,7 @@ void SAL_CALL ChartController::dispose() if( m_aModel.is()) { uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener; - uno::Reference< chart2::data::XDataReceiver > xDataReceiver( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xDataReceiver = getChartModel(); if( xDataReceiver.is() ) xSelectionChangeListener.set( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY ); if( xSelectionChangeListener.is() ) @@ -785,9 +776,8 @@ void SAL_CALL ChartController::dispose() //--release all resources and references { - uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); - if( xViewBroadcaster.is() ) - xViewBroadcaster->removeModeChangeListener(this); + if( m_xChartView.is() ) + m_xChartView->removeModeChangeListener(this); impl_invalidateAccessible(); SolarMutexGuard aSolarGuard; @@ -806,7 +796,7 @@ void SAL_CALL ChartController::dispose() if( m_xLayoutManagerEventBroadcaster.is()) { m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this ); - m_xLayoutManagerEventBroadcaster.set( nullptr ); + m_xLayoutManagerEventBroadcaster.clear(); } m_xFrame.clear(); @@ -817,7 +807,7 @@ void SAL_CALL ChartController::dispose() if( aModelRef.is()) { - uno::Reference< frame::XModel > xModel( aModelRef->getModel() ); + rtl::Reference< ChartModel > xModel( aModelRef->getModel() ); if(xModel.is()) xModel->disconnectController( uno::Reference< frame::XController >( this )); @@ -825,9 +815,8 @@ void SAL_CALL ChartController::dispose() #ifdef TEST_ENABLE_MODIFY_LISTENER try { - uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY ); - if( xMBroadcaster.is()) - xMBroadcaster->removeModifyListener( this ); + if( aModelRef->getModel().is()) + aModelRef->getModel()->removeModifyListener( this ); } catch( const uno::Exception & ) { @@ -853,12 +842,12 @@ void SAL_CALL ChartController::dispose() void SAL_CALL ChartController::addEventListener( const uno::Reference<lang::XEventListener>& xListener ) { - SolarMutexGuard aGuard; if( impl_isDisposedOrSuspended() )//@todo? allow adding of listeners in suspend mode? return; //behave passive if already disposed or suspended //--add listener - m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<lang::XEventListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aEventListeners.addInterface( aGuard2, xListener ); } void SAL_CALL ChartController::removeEventListener( @@ -869,7 +858,8 @@ void SAL_CALL ChartController::removeEventListener( return; //behave passive if already disposed or suspended //--remove listener - m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<lang::XEventListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aEventListeners.removeInterface( aGuard2, xListener ); } // util::XCloseListener @@ -884,7 +874,7 @@ void SAL_CALL ChartController::queryClosing( if( !aModelRef.is() ) return; - if( aModelRef->getModel() != rSource.Source ) + if( uno::Reference<XInterface>(static_cast<cppu::OWeakObject*>(aModelRef->getModel().get())) != rSource.Source ) { OSL_FAIL( "queryClosing was called on a controller from an unknown source" ); return; @@ -928,7 +918,7 @@ bool ChartController::impl_releaseThisModel( bool bReleaseModel = false; { ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex ); - if( m_aModel.is() && m_aModel->getModel() == xModel ) + if( m_aModel.is() && uno::Reference< uno::XInterface >(static_cast<cppu::OWeakObject*>(m_aModel->getModel().get())) == xModel ) { m_aModel = nullptr; m_xUndoManager.clear(); @@ -950,7 +940,7 @@ void SAL_CALL ChartController::disposing( if( !impl_releaseThisModel( rSource.Source )) { if( rSource.Source == m_xLayoutManagerEventBroadcaster ) - m_xLayoutManagerEventBroadcaster.set( nullptr ); + m_xLayoutManagerEventBroadcaster.clear(); } } @@ -964,8 +954,8 @@ void SAL_CALL ChartController::layoutEvent( Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY ); if( xLM.is()) { - xLM->createElement( "private:resource/statusbar/statusbar" ); - xLM->requestElement( "private:resource/statusbar/statusbar" ); + xLM->createElement( u"private:resource/statusbar/statusbar"_ustr ); + xLM->requestElement( u"private:resource/statusbar/statusbar"_ustr ); } } } @@ -1038,7 +1028,7 @@ uno::Reference<frame::XDispatch> SAL_CALL if ( !m_aLifeTimeManager.impl_isDisposed() && getModel().is() ) { - if( !rTargetFrameName.isEmpty() && rTargetFrameName == "_self" ) + if (rTargetFrameName == "_self") return m_aDispatchContainer.getDispatchForURL( rURL ); } return uno::Reference< frame::XDispatch > (); @@ -1129,7 +1119,7 @@ void SAL_CALL ChartController::dispatch( } else if(aCommand.startsWith("FillGradient")) { - this->executeDispatch_FillGradient(aCommand.copy(aCommand.indexOf('=') + 1)); + this->executeDispatch_FillGradient(aCommand.subView(aCommand.indexOf('=') + 1)); } else if(aCommand == "Paste") this->executeDispatch_Paste(); @@ -1141,7 +1131,7 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_SourceData(); else if(aCommand == "Update" ) //Update Chart { - ChartViewHelper::setViewToDirtyState( getModel() ); + ChartViewHelper::setViewToDirtyState( getChartModel() ); SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); if( pChartWindow ) @@ -1174,6 +1164,8 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_InsertErrorBars(false); else if( aCommand == "InsertMenuYErrorBars" ) this->executeDispatch_InsertErrorBars(true); + else if( aCommand == "InsertMenuDataTable" ) + this->executeDispatch_OpenInsertDataTableDialog(); else if( aCommand == "InsertSymbol" ) this->executeDispatch_InsertSpecialCharacter(); else if( aCommand == "InsertTrendline" ) @@ -1228,6 +1220,10 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_DeleteMajorGrid(); else if( aCommand == "DeleteMinorGrid" ) this->executeDispatch_DeleteMinorGrid(); + else if( aCommand == "InsertDataTable" ) + this->executeDispatch_InsertDataTable(); + else if( aCommand == "DeleteDataTable" ) + this->executeDispatch_DeleteDataTable(); //format objects else if( aCommand == "FormatSelection" ) this->executeDispatch_ObjectProperties(); @@ -1242,7 +1238,9 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_PositionAndSize(); } } - else if( lcl_isFormatObjectCommand(aCommand) ) + else if ( aCommand == "FontDialog" ) + this->impl_ShapeControllerDispatch(rURL, rArgs); + else if (lcl_isFormatObjectCommand(aCommand)) this->executeDispatch_FormatObject(rURL.Path); //more format else if( aCommand == "DiagramType" ) @@ -1281,6 +1279,127 @@ void SAL_CALL ChartController::dispatch( this->executeDispatch_ToggleGridVertical(); else if( aCommand == "ScaleText" ) this->executeDispatch_ScaleText(); + else if( aCommand == "Bold" || aCommand == "CharFontName" || aCommand == "FontHeight" + || aCommand == "Italic" || aCommand == "Underline" || aCommand == "Strikeout" + || aCommand == "Shadowed" || aCommand == "Color" || aCommand == "FontColor" + || aCommand == "Grow" || aCommand == "Shrink" || aCommand == "ResetAttributes" + || aCommand == "SuperScript" || aCommand == "SubScript" + || aCommand == "Spacing" + ) + { + try + { + OUString aCID(m_aSelection.getSelectedCID()); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); + if (xChartModel.is()) + { + // if the selected is title... we should get the text properties instead... + // or the selected text properties + std::vector<Reference<beans::XPropertySet>> xProperties; + xProperties.emplace(xProperties.end(), + ObjectIdentifier::getObjectPropertySet(aCID, xChartModel)); + + if (ObjectIdentifier::getObjectType(aCID) == OBJECTTYPE_TITLE) + { + Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY); + if (xTitle.is()) + { + OutlinerView* pOutlinerView = nullptr; + if (m_pDrawViewWrapper) + { + pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + } + // if the Title is not in edit mode + if (!pOutlinerView) + { + const Sequence<Reference<chart2::XFormattedString>> aStrings( + xTitle->getText()); + xProperties.pop_back(); + for (int i = 0; i < aStrings.getLength(); i++) + { + Reference<beans::XPropertySet> xTitlePropSet(aStrings[i], + uno::UNO_QUERY); + xProperties.push_back(xTitlePropSet); + } + } + // Todo: implement the edit mode case here. + // the edited text attributes are a bit different from the properties + // SfxItemSet aItemSet = pOutlinerView->GetAttribs(); + } + } + bool bAllPropertiesExist = (xProperties.size() > 0); + for (std::size_t i = 0; i < xProperties.size(); i++) + { + if (!xProperties[i].is()) + bAllPropertiesExist = false; + } + if (bAllPropertiesExist) + { + if (aCommand == "Bold") + { + executeDispatch_FontBold(xProperties); + } + else if (aCommand == "CharFontName") + { + executeDispatch_FontName(xProperties, rArgs); + } + else if (aCommand == "FontHeight") + { + executeDispatch_FontHeight(xProperties, rArgs); + } + else if (aCommand == "Italic") + { + executeDispatch_FontItalic(xProperties); + } + else if (aCommand == "Underline") + { + executeDispatch_FontUnderline(xProperties, rArgs); + } + else if (aCommand == "Strikeout") + { + executeDispatch_FontStrikeout(xProperties); + } + else if (aCommand == "Shadowed") + { + executeDispatch_FontShadowed(xProperties); + } + else if (aCommand == "Color" || aCommand == "FontColor") + { + executeDispatch_FontColor(xProperties, rArgs); + } + else if (aCommand == "Grow") + { + executeDispatch_FontGrow(xProperties); + } + else if (aCommand == "Shrink") + { + executeDispatch_FontShrink(xProperties); + } + else if (aCommand == "ResetAttributes") + { + executeDispatch_FontReset(xProperties); + } + else if (aCommand == "Spacing") + { + executeDispatch_FontSpacing(xProperties, rArgs); + } + else if (aCommand == "SuperScript") + { + executeDispatch_FontSuperScript(xProperties); + } + else if (aCommand == "SubScript") + { + executeDispatch_FontSubScript(xProperties); + } + } + } + } + catch (const uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + + } else if( aCommand == "StatusBarVisible" ) { // workaround: this should not be necessary. @@ -1288,24 +1407,26 @@ void SAL_CALL ChartController::dispatch( if( xPropSet.is() ) { uno::Reference< css::frame::XLayoutManager > xLayoutManager; - xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager; + xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager; if ( xLayoutManager.is() ) { - bool bIsVisible( xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" )); + bool bIsVisible( xLayoutManager->isElementVisible( u"private:resource/statusbar/statusbar"_ustr )); if( bIsVisible ) { - xLayoutManager->hideElement( "private:resource/statusbar/statusbar" ); - xLayoutManager->destroyElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->hideElement( u"private:resource/statusbar/statusbar"_ustr ); + xLayoutManager->destroyElement( u"private:resource/statusbar/statusbar"_ustr ); } else { - xLayoutManager->createElement( "private:resource/statusbar/statusbar" ); - xLayoutManager->showElement( "private:resource/statusbar/statusbar" ); + xLayoutManager->createElement( u"private:resource/statusbar/statusbar"_ustr ); + xLayoutManager->showElement( u"private:resource/statusbar/statusbar"_ustr ); } // @todo: update menu state (checkmark next to "Statusbar"). } } } + else if( aCommand == "ChangeTheme" ) + comphelper::dispatchCommand(u".uno:ChangeTheme"_ustr, getFrame(), rArgs); } void SAL_CALL ChartController::addStatusListener( @@ -1340,34 +1461,36 @@ void SAL_CALL ChartController::releaseContextMenuInterceptor( void ChartController::executeDispatch_ChartType() { - UndoLiveUpdateGuard aUndoGuard( - SchResId( STR_ACTION_EDIT_CHARTTYPE ), m_xUndoManager ); + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_CHARTTYPE), + m_xUndoManager); SolarMutexGuard aSolarGuard; //prepare and open dialog - ChartTypeDialog aDlg(GetChartFrame(), getModel()); - if (aDlg.run() == RET_OK) - { - impl_adaptDataSeriesAutoResize(); - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<ChartTypeDialog>(GetChartFrame(), getChartModel()); + weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) { + if (nResult == RET_OK) + { + impl_adaptDataSeriesAutoResize(); + xUndoGuard->commit(); + } + }); } void ChartController::executeDispatch_SourceData() { //convert properties to ItemSet - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference< ::chart::ChartModel > xChartDoc = getChartModel(); OSL_ENSURE( xChartDoc.is(), "Invalid XChartDocument" ); if( !xChartDoc.is() ) return; // If there is a data table we should ask user if we really want to destroy it // and switch to data ranges. - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); + ChartModel& rModel = *xChartDoc; if ( rModel.hasInternalDataProvider() ) { // Check if we will able to create data provider later - css::uno::Reference< com::sun::star::chart2::XDataProviderAccess > xCreatorDoc( + css::uno::Reference< css::chart2::XDataProviderAccess > xCreatorDoc( rModel.getParent(), uno::UNO_QUERY); if (!xCreatorDoc.is()) return; @@ -1392,27 +1515,27 @@ void ChartController::executeDispatch_SourceData() rModel.attachDataProvider(xDataProvider); } } - - UndoLiveUpdateGuard aUndoGuard( - SchResId(STR_ACTION_EDIT_DATA_RANGES), m_xUndoManager); - + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>(SchResId(STR_ACTION_EDIT_DATA_RANGES), + m_xUndoManager); SolarMutexGuard aSolarGuard; - ::chart::DataSourceDialog aDlg(GetChartFrame(), xChartDoc, m_xCC); - if (aDlg.run() == RET_OK) - { - impl_adaptDataSeriesAutoResize(); - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<DataSourceDialog>(GetChartFrame(), xChartDoc); + weld::DialogController::runAsync(aDlg, [this, xUndoGuard=std::move(xUndoGuard)](int nResult) { + if (nResult == RET_OK) + { + impl_adaptDataSeriesAutoResize(); + xUndoGuard->commit(); + } + }); } void ChartController::executeDispatch_MoveSeries( bool bForward ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); //get selected series OUString aObjectCID(m_aSelection.getSelectedCID()); - uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels? - aObjectCID, getModel() ) ); + rtl::Reference< DataSeries > xGivenDataSeries = ObjectIdentifier::getDataSeriesForCID( //yyy todo also legend entries and labels? + aObjectCID, getChartModel() ); UndoGuardWithSelection aUndoGuard( ActionDescriptionProvider::createDescription( @@ -1420,7 +1543,7 @@ void ChartController::executeDispatch_MoveSeries( bool bForward ) SchResId(STR_OBJECT_DATASERIES)), m_xUndoManager ); - bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( getModel() ), xGivenDataSeries, bForward ); + bool bChanged = getFirstDiagram()->moveSeries( xGivenDataSeries, bForward ); if( bChanged ) { m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); @@ -1428,33 +1551,6 @@ void ChartController::executeDispatch_MoveSeries( bool bForward ) } } -// ____ XMultiServiceFactory ____ -uno::Reference< uno::XInterface > SAL_CALL - ChartController::createInstance( const OUString& aServiceSpecifier ) -{ - uno::Reference< uno::XInterface > xResult; - - if( aServiceSpecifier == CHART_ACCESSIBLE_TEXT_SERVICE_NAME ) - xResult.set( impl_createAccessibleTextContext()); - return xResult; -} - -uno::Reference< uno::XInterface > SAL_CALL - ChartController::createInstanceWithArguments( - const OUString& ServiceSpecifier, - const uno::Sequence< uno::Any >& /* Arguments */ ) -{ - // ignore Arguments - return createInstance( ServiceSpecifier ); -} - -uno::Sequence< OUString > SAL_CALL - ChartController::getAvailableServiceNames() -{ - uno::Sequence< OUString > aServiceNames { CHART_ACCESSIBLE_TEXT_SERVICE_NAME }; - return aServiceNames; -} - // ____ XModifyListener ____ void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ ) @@ -1474,7 +1570,7 @@ void ChartController::NotifyUndoActionHdl( std::unique_ptr<SdrUndoAction> pUndoA try { - const Reference< document::XUndoManagerSupplier > xSuppUndo( getModel(), uno::UNO_QUERY_THROW ); + rtl::Reference< ChartModel > xSuppUndo = getChartModel(); const Reference< document::XUndoManager > xUndoManager( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); const Reference< document::XUndoAction > xAction( new impl::ShapeUndoElement( std::move(pUndoAction) ) ); xUndoManager->addUndoAction( xAction ); @@ -1489,9 +1585,8 @@ DrawModelWrapper* ChartController::GetDrawModelWrapper() { if( !m_pDrawModelWrapper ) { - ExplicitValueProvider* pProvider = comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView ); - if( pProvider ) - m_pDrawModelWrapper = pProvider->getDrawModelWrapper(); + if( m_xChartView ) + m_pDrawModelWrapper = m_xChartView->getDrawModelWrapper(); if ( m_pDrawModelWrapper ) { m_pDrawModelWrapper->getSdrModel().SetNotifyUndoActionHdl( @@ -1545,127 +1640,135 @@ void ChartController::SetAndApplySelection(const Reference<drawing::XShape>& rxS } } - - -uno::Reference< XAccessible > ChartController::CreateAccessible() +rtl::Reference<AccessibleChartView> ChartController::CreateAccessible() { - uno::Reference< XAccessible > xResult = new AccessibleChartView( GetDrawViewWrapper() ); - impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) ); +#if !ENABLE_WASM_STRIP_ACCESSIBILITY + rtl::Reference< AccessibleChartView > xResult = new AccessibleChartView( GetDrawViewWrapper() ); + impl_initializeAccessible( *xResult ); return xResult; +#else + return {}; +#endif } void ChartController::impl_invalidateAccessible() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); if( pChartWindow ) { - Reference< lang::XInitialization > xInit( pChartWindow->GetAccessible(false), uno::UNO_QUERY ); - if(xInit.is()) + Reference<XAccessible> xAccessible = pChartWindow->GetAccessible(false); + if (xAccessible.is()) { - uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible - xInit->initialize(aArguments); + //empty arguments -> invalid accessible + dynamic_cast<AccessibleChartView&>(*xAccessible).initialize(); } } +#endif } void ChartController::impl_initializeAccessible() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - this->impl_initializeAccessible( Reference< lang::XInitialization >( pChartWindow->GetAccessible(false), uno::UNO_QUERY ) ); + if( !pChartWindow ) + return; + Reference<XAccessible> xInit = pChartWindow->GetAccessible(false); + if(xInit.is()) + impl_initializeAccessible( dynamic_cast<AccessibleChartView&>(*xInit) ); +#endif } -void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit ) +#if !ENABLE_WASM_STRIP_ACCESSIBILITY +void ChartController::impl_initializeAccessible( AccessibleChartView& rAccChartView ) { - if(!xInit.is()) - return; + SolarMutexGuard aGuard; - uno::Sequence< uno::Any > aArguments(5); - aArguments[0] <<= uno::Reference<view::XSelectionSupplier>(this); - aArguments[1] <<= getModel(); - aArguments[2] <<= m_xChartView; uno::Reference< XAccessible > xParent; - { - SolarMutexGuard aGuard; - auto pChartWindow(GetChartWindow()); - if( pChartWindow ) - { - vcl::Window* pParentWin( pChartWindow->GetAccessibleParentWindow()); - if( pParentWin ) - xParent.set( pParentWin->GetAccessible()); - } - } - aArguments[3] <<= xParent; - aArguments[4] <<= m_xViewWindow; - xInit->initialize(aArguments); + ChartWindow* pChartWindow = GetChartWindow(); + if( pChartWindow ) + xParent.set(pChartWindow->GetAccessibleParent()); + + rAccChartView.initialize(*this, getChartModel(), m_xChartView, xParent, pChartWindow); } +#else +void ChartController::impl_initializeAccessible( AccessibleChartView& /* rAccChartView */) {} +#endif -const o3tl::sorted_vector< OUString >& ChartController::impl_getAvailableCommands() +const o3tl::sorted_vector< std::u16string_view >& ChartController::impl_getAvailableCommands() { - static const o3tl::sorted_vector< OUString > s_AvailableCommands { + static const o3tl::sorted_vector< std::u16string_view > s_AvailableCommands { // commands for container forward - "AddDirect", "NewDoc", "Open", - "Save", "SaveAs", "SendMail", - "EditDoc", "ExportDirectToPDF", "PrintDefault", + u"AddDirect", u"NewDoc", u"Open", + u"Save", u"SaveAs", u"SendMail", + u"EditDoc", u"ExportDirectToPDF", u"PrintDefault", // own commands - "Cut", "Copy", "Paste", - "DataRanges", "DiagramData", + u"Cut", u"Copy", u"Paste", + u"DataRanges", u"DiagramData", // insert objects - "InsertMenuTitles", "InsertTitles", - "InsertMenuLegend", "InsertLegend", "DeleteLegend", - "InsertMenuDataLabels", - "InsertMenuAxes", "InsertRemoveAxes", "InsertMenuGrids", - "InsertSymbol", - "InsertTrendlineEquation", "InsertTrendlineEquationAndR2", - "InsertR2Value", "DeleteR2Value", - "InsertMenuTrendlines", "InsertTrendline", - "InsertMenuMeanValues", "InsertMeanValue", - "InsertMenuXErrorBars", "InsertXErrorBars", - "InsertMenuYErrorBars", "InsertYErrorBars", - "InsertDataLabels", "InsertDataLabel", - "DeleteTrendline", "DeleteMeanValue", "DeleteTrendlineEquation", - "DeleteXErrorBars", "DeleteYErrorBars", - "DeleteDataLabels", "DeleteDataLabel", + u"InsertMenuTitles", u"InsertTitles", + u"InsertMenuLegend", u"InsertLegend", u"DeleteLegend", + u"InsertMenuDataLabels", + u"InsertMenuAxes", u"InsertRemoveAxes", u"InsertMenuGrids", + u"InsertSymbol", + u"InsertTrendlineEquation", u"InsertTrendlineEquationAndR2", + u"InsertR2Value", u"DeleteR2Value", + u"InsertMenuTrendlines", u"InsertTrendline", + u"InsertMenuMeanValues", u"InsertMeanValue", + u"InsertMenuXErrorBars", u"InsertXErrorBars", + u"InsertMenuYErrorBars", u"InsertYErrorBars", + u"InsertDataLabels", u"InsertDataLabel", + u"DeleteTrendline", u"DeleteMeanValue", u"DeleteTrendlineEquation", + u"DeleteXErrorBars", u"DeleteYErrorBars", + u"DeleteDataLabels", u"DeleteDataLabel", + u"InsertMenuDataTable", + u"InsertDataTable", u"DeleteDataTable", //format objects - "FormatSelection", "TransformDialog", - "DiagramType", "View3D", - "Forward", "Backward", - "MainTitle", "SubTitle", - "XTitle", "YTitle", "ZTitle", - "SecondaryXTitle", "SecondaryYTitle", - "AllTitles", "Legend", - "DiagramAxisX", "DiagramAxisY", "DiagramAxisZ", - "DiagramAxisA", "DiagramAxisB", "DiagramAxisAll", - "DiagramGridXMain", "DiagramGridYMain", "DiagramGridZMain", - "DiagramGridXHelp", "DiagramGridYHelp", "DiagramGridZHelp", - "DiagramGridAll", - "DiagramWall", "DiagramFloor", "DiagramArea", + u"FormatSelection", u"FontDialog", u"TransformDialog", + u"DiagramType", u"View3D", + u"Forward", u"Backward", + u"MainTitle", u"SubTitle", + u"XTitle", u"YTitle", u"ZTitle", + u"SecondaryXTitle", u"SecondaryYTitle", + u"AllTitles", u"Legend", + u"DiagramAxisX", u"DiagramAxisY", u"DiagramAxisZ", + u"DiagramAxisA", u"DiagramAxisB", u"DiagramAxisAll", + u"DiagramGridXMain", u"DiagramGridYMain", u"DiagramGridZMain", + u"DiagramGridXHelp", u"DiagramGridYHelp", u"DiagramGridZHelp", + u"DiagramGridAll", + u"DiagramWall", u"DiagramFloor", u"DiagramArea", //context menu - format objects entries - "FormatWall", "FormatFloor", "FormatChartArea", - "FormatLegend", + u"FormatWall", u"FormatFloor", u"FormatChartArea", + u"FormatLegend", - "FormatAxis", "FormatTitle", - "FormatDataSeries", "FormatDataPoint", - "ResetAllDataPoints", "ResetDataPoint", - "FormatDataLabels", "FormatDataLabel", - "FormatMeanValue", "FormatTrendline", "FormatTrendlineEquation", - "FormatXErrorBars", "FormatYErrorBars", - "FormatStockLoss", "FormatStockGain", + u"FormatAxis", u"FormatTitle", + u"FormatDataSeries", u"FormatDataPoint", + u"ResetAllDataPoints", u"ResetDataPoint", + u"FormatDataLabels", u"FormatDataLabel", + u"FormatMeanValue", u"FormatTrendline", u"FormatTrendlineEquation", + u"FormatXErrorBars", u"FormatYErrorBars", + u"FormatStockLoss", u"FormatStockGain", - "FormatMajorGrid", "InsertMajorGrid", "DeleteMajorGrid", - "FormatMinorGrid", "InsertMinorGrid", "DeleteMinorGrid", - "InsertAxis", "DeleteAxis", "InsertAxisTitle", + u"FormatMajorGrid", u"InsertMajorGrid", u"DeleteMajorGrid", + u"FormatMinorGrid", u"InsertMinorGrid", u"DeleteMinorGrid", + u"InsertAxis", u"DeleteAxis", u"InsertAxisTitle", // toolbar commands - "ToggleGridHorizontal", "ToggleGridVertical", "ToggleLegend", "ScaleText", - "NewArrangement", "Update", - "DefaultColors", "BarWidth", "NumberOfLines", - "ArrangeRow", - "StatusBarVisible", - "ChartElementSelector"}; + u"ToggleGridHorizontal", u"ToggleGridVertical", u"ToggleLegend", u"ScaleText", + u"NewArrangement", u"Update", + u"DefaultColors", u"BarWidth", u"NumberOfLines", + u"ArrangeRow", + u"StatusBarVisible", + u"ChartElementSelector", + + // sidebar commands + u"CharFontName" , u"FontHeight" , u"Italic", u"Underline", + u"Bold", u"Strikeout",u"Shadowed", u"Color", u"FontColor", u"ResetAttributes", + u"Grow", u"Shrink", u"Spacing", u"SuperScript", u"SubScript" + }; return s_AvailableCommands; } @@ -1676,11 +1779,4 @@ ViewElementListProvider ChartController::getViewElementListProvider() } //namespace chart -extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * -com_sun_star_comp_chart2_ChartController_get_implementation(css::uno::XComponentContext *context, - css::uno::Sequence<css::uno::Any> const &) -{ - return cppu::acquire(new chart::ChartController(context)); -} - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx index e9820cab3cce..1e0c8c3dc96f 100644 --- a/chart2/source/controller/main/ChartController_EditData.cxx +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -17,8 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <ChartWindow.hxx> #include <ChartController.hxx> +#include <ChartModel.hxx> #include <dlg_DataEditor.hxx> #include "UndoGuard.hxx" @@ -26,19 +26,15 @@ #include <strings.hrc> #include <vcl/svapp.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> using namespace ::com::sun::star; -using ::com::sun::star::uno::Reference; - namespace chart { void ChartController::executeDispatch_EditData() { - Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); - if (xChartDoc.is()) + if (rtl::Reference<::chart::ChartModel> xChartDoc = getChartModel()) { SolarMutexGuard aSolarGuard; UndoLiveUpdateGuardWithData aUndoGuard( diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx index 04c27782c375..5b930ee7190c 100644 --- a/chart2/source/controller/main/ChartController_Insert.cxx +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -25,13 +25,15 @@ #include <dlg_InsertLegend.hxx> #include <dlg_InsertErrorBars.hxx> #include <dlg_InsertTitle.hxx> +#include <dlg_InsertDataTable.hxx> #include <dlg_ObjectProperties.hxx> -#include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <TitleHelper.hxx> -#include <DiagramHelper.hxx> +#include <DataSeries.hxx> +#include <Diagram.hxx> +#include <GridProperties.hxx> #include <chartview/DrawModelWrapper.hxx> #include <chartview/ChartSfxItemIds.hxx> #include <NumberFormatterWrapper.hxx> @@ -49,33 +51,32 @@ #include <ErrorBarItemConverter.hxx> #include <DataSeriesHelper.hxx> #include <ObjectNameProvider.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> +#include <DataTable.hxx> +#include <RegressionCurveModel.hxx> #include <com/sun/star/chart2/XRegressionCurve.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> #include <svx/ActionDescriptionProvider.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace { -void lcl_InsertMeanValueLine( const uno::Reference< chart2::XDataSeries > & xSeries ) +void lcl_InsertMeanValueLine( const rtl::Reference< ::chart::DataSeries > & xSeries ) { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - xSeries, uno::UNO_QUERY ); - if( xRegCurveCnt.is()) + if( xSeries.is()) { ::chart::RegressionCurveHelper::addMeanValueLine( - xRegCurveCnt, uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); + xSeries, xSeries); } } @@ -86,35 +87,37 @@ namespace chart void ChartController::executeDispatch_InsertAxes() { - UndoGuard aUndoGuard( + auto xUndoGuard = std::make_shared<UndoGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AXES )), m_xUndoManager ); try { - InsertAxisOrGridDialogData aDialogInput; - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(getModel()); - AxisHelper::getAxisOrGridExistence( aDialogInput.aExistenceList, xDiagram ); - AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram ); + auto xDialogInput = std::make_shared<InsertAxisOrGridDialogData>(); + rtl::Reference< Diagram > xDiagram = getFirstDiagram(); + AxisHelper::getAxisOrGridExistence( xDialogInput->aExistenceList, xDiagram ); + AxisHelper::getAxisOrGridPossibilities( xDialogInput->aPossibilityList, xDiagram ); SolarMutexGuard aGuard; - SchAxisDlg aDlg(GetChartFrame(), aDialogInput); - if (aDlg.run() == RET_OK) - { - // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); - - InsertAxisOrGridDialogData aDialogOutput; - aDlg.getResult(aDialogOutput); - std::unique_ptr< ReferenceSizeProvider > pRefSizeProvider( - impl_createReferenceSizeProvider()); - bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram - , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC - , pRefSizeProvider.get() ); - if( bChanged ) - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<SchAxisDlg>(GetChartFrame(), *xDialogInput); + weld::DialogController::runAsync(aDlg, [this, aDlg, xDialogInput=std::move(xDialogInput), + xUndoGuard=std::move(xUndoGuard)](int nResult) { + if ( nResult == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuardUNO aCLGuard( getChartModel() ); + + InsertAxisOrGridDialogData aDialogOutput; + aDlg->getResult(aDialogOutput); + ReferenceSizeProvider aRefSizeProvider(impl_createReferenceSizeProvider()); + bool bChanged = AxisHelper::changeVisibilityOfAxes( getFirstDiagram() + , xDialogInput->aExistenceList, aDialogOutput.aExistenceList, m_xCC + , &aRefSizeProvider ); + if( bChanged ) + xUndoGuard->commit(); + } + }); } catch(const uno::RuntimeException&) { @@ -132,7 +135,7 @@ void ChartController::executeDispatch_InsertGrid() try { InsertAxisOrGridDialogData aDialogInput; - uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(getModel()); + rtl::Reference< Diagram > xDiagram = getFirstDiagram(); AxisHelper::getAxisOrGridExistence( aDialogInput.aExistenceList, xDiagram, false ); AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, false ); @@ -141,7 +144,7 @@ void ChartController::executeDispatch_InsertGrid() if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); InsertAxisOrGridDialogData aDialogOutput; aDlg.getResult( aDialogOutput ); bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram @@ -156,30 +159,146 @@ void ChartController::executeDispatch_InsertGrid() } } +void ChartController::executeDispatch_OpenInsertDataTableDialog() +{ + SolarMutexGuard aGuard; + + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + + InsertDataTableDialog aDialog(GetChartFrame()); + { + // init values + DataTableDialogData aData; + auto xDataTable = xDiagram->getDataTable(); + aData.mbShow = xDataTable.is(); + if (xDataTable.is()) + { + uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY); + + uno::Any aAny = xProperties->getPropertyValue(u"HBorder"_ustr); + if (aAny.has<bool>()) + aData.mbHorizontalBorders = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue(u"VBorder"_ustr); + if (aAny.has<bool>()) + aData.mbVerticalBorders = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue(u"Outline"_ustr); + if (aAny.has<bool>()) + aData.mbOutline = aAny.get<bool>(); + + aAny = xProperties->getPropertyValue(u"Keys"_ustr); + if (aAny.has<bool>()) + aData.mbKeys = aAny.get<bool>(); + } + aDialog.init(aData); + } + + // show the dialog + if (aDialog.run() == RET_OK) + { + bool bChanged = false; + + auto& rDialogData = aDialog.getDataTableDialogData(); + auto xDataTable = xDiagram->getDataTable(); + if (!rDialogData.mbShow && xDataTable.is()) + { + xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + bChanged = true; + } + else if (rDialogData.mbShow && !xDataTable.is()) + { + uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable); + if (xNewDataTable.is()) + { + xDiagram->setDataTable(xNewDataTable); + bChanged = true; + } + } + + // Set the properties + xDataTable = xDiagram->getDataTable(); + if (rDialogData.mbShow && xDataTable.is()) + { + uno::Reference<beans::XPropertySet> xProperties(xDataTable, uno::UNO_QUERY); + xProperties->setPropertyValue(u"HBorder"_ustr , uno::Any(rDialogData.mbHorizontalBorders)); + xProperties->setPropertyValue(u"VBorder"_ustr , uno::Any(rDialogData.mbVerticalBorders)); + xProperties->setPropertyValue(u"Outline"_ustr , uno::Any(rDialogData.mbOutline)); + xProperties->setPropertyValue(u"Keys"_ustr , uno::Any(rDialogData.mbKeys)); + bChanged = true; + } + + if (bChanged) + aUndoGuard.commit(); + } +} + +/** Create and insert a data table to the chart */ +void ChartController::executeDispatch_InsertDataTable() +{ + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Insert, SchResId(STR_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + + + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + auto xDataTable = xDiagram->getDataTable(); + if (!xDataTable.is()) + { + uno::Reference<chart2::XDataTable> xNewDataTable(new DataTable); + if (xNewDataTable.is()) + { + xDiagram->setDataTable(xNewDataTable); + aUndoGuard.commit(); + } + } +} + +/** Delete a data table from the chart */ +void ChartController::executeDispatch_DeleteDataTable() +{ + auto aUndoDescription = ActionDescriptionProvider::createDescription(ActionDescriptionProvider::ActionType::Delete, SchResId(STR_DATA_TABLE)); + UndoGuard aUndoGuard(aUndoDescription, m_xUndoManager); + + rtl::Reference<Diagram> xDiagram = getFirstDiagram(); + auto xDataTable = xDiagram->getDataTable(); + if (xDataTable.is()) + { + // insert a empty data table reference + xDiagram->setDataTable(uno::Reference<chart2::XDataTable>()); + aUndoGuard.commit(); + } +} + void ChartController::executeDispatch_InsertTitles() { - UndoGuard aUndoGuard( + auto xUndoGuard = std::make_shared<UndoGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_TITLES )), m_xUndoManager ); try { - TitleDialogData aDialogInput; - aDialogInput.readFromModel( getModel() ); + auto xDialogInput = std::make_shared<TitleDialogData>(); + xDialogInput->readFromModel( getChartModel() ); SolarMutexGuard aGuard; - SchTitleDlg aDlg(GetChartFrame(), aDialogInput); - if (aDlg.run() == RET_OK) - { - // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); - TitleDialogData aDialogOutput(impl_createReferenceSizeProvider()); - aDlg.getResult(aDialogOutput); - bool bChanged = aDialogOutput.writeDifferenceToModel( getModel(), m_xCC, &aDialogInput ); - if( bChanged ) - aUndoGuard.commit(); - } + auto aDlg = std::make_shared<SchTitleDlg>(GetChartFrame(), *xDialogInput); + weld::DialogController::runAsync(aDlg, [this, aDlg, xDialogInput=std::move(xDialogInput), + xUndoGuard=std::move(xUndoGuard)](int nResult){ + if ( nResult == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuardUNO aCLGuard( getChartModel() ); + TitleDialogData aDialogOutput( impl_createReferenceSizeProvider() ); + aDlg->getResult( aDialogOutput ); + bool bChanged = aDialogOutput.writeDifferenceToModel( getChartModel(), m_xCC, xDialogInput.get() ); + if( bChanged ) + xUndoGuard->commit(); + } + }); } catch(const uno::RuntimeException&) { @@ -194,8 +313,7 @@ void ChartController::executeDispatch_DeleteLegend() ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_LEGEND )), m_xUndoManager ); - ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel()); - LegendHelper::hideLegend(rModel); + LegendHelper::hideLegend(*getChartModel()); aUndoGuard.commit(); } @@ -206,8 +324,7 @@ void ChartController::executeDispatch_InsertLegend() ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_LEGEND )), m_xUndoManager ); - ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel()); - LegendHelper::showLegend(rModel, m_xCC); + LegendHelper::showLegend(*getChartModel(), m_xCC); aUndoGuard.commit(); } @@ -223,12 +340,12 @@ void ChartController::executeDispatch_OpenLegendDialog() //prepare and open dialog SolarMutexGuard aGuard; SchLegendDlg aDlg(GetChartFrame(), m_xCC); - aDlg.init( getModel() ); + aDlg.init( getChartModel() ); if (aDlg.run() == RET_OK) { // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); - aDlg.writeToModel( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); + aDlg.writeToModel( getChartModel() ); aUndoGuard.commit(); } } @@ -240,36 +357,32 @@ void ChartController::executeDispatch_OpenLegendDialog() void ChartController::executeDispatch_InsertMenu_DataLabels() { - UndoGuard aUndoGuard( + std::shared_ptr<UndoGuard> aUndoGuard = std::make_shared<UndoGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_DATALABELS )), m_xUndoManager ); //if a series is selected insert labels for that series only: - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel()); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel()); if( xSeries.is() ) { // add labels - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + xSeries->insertDataLabelsToSeriesAndAllPoints(); OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) + "=" ); OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles( ObjectIdentifier::getSeriesParticleFromCID(m_aSelection.getSelectedCID()), aChildParticle ); - bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true ); - if( bSuccess ) - aUndoGuard.commit(); + ChartController::executeDlg_ObjectProperties_withUndoGuard( aUndoGuard, aObjectCID, true ); return; } - try { wrapper::AllDataLabelItemConverter aItemConverter( - getModel(), + getChartModel(), m_pDrawModelWrapper->GetItemPool(), - m_pDrawModelWrapper->getSdrModel(), - uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY )); + m_pDrawModelWrapper->getSdrModel() ); SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); aItemConverter.FillItemSet( aItemSet ); @@ -277,8 +390,7 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() SolarMutexGuard aGuard; //get number formatter - uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( getModel(), uno::UNO_QUERY ); - NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + NumberFormatterWrapper aNumberFormatterWrapper( getChartModel() ); SvNumberFormatter* pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); DataLabelsDialog aDlg(GetChartFrame(), aItemSet, pNumberFormatter); @@ -288,10 +400,10 @@ void ChartController::executeDispatch_InsertMenu_DataLabels() SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); aDlg.FillItemSet(aOutItemSet); // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now if( bChanged ) - aUndoGuard.commit(); + aUndoGuard->commit(); } } catch(const uno::RuntimeException&) @@ -307,7 +419,7 @@ void ChartController::executeDispatch_InsertMeanValue() ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AVERAGE_LINE )), m_xUndoManager ); lcl_InsertMeanValueLine( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), - getModel() ) ); + getChartModel() ) ); aUndoGuard.commit(); } @@ -318,17 +430,17 @@ void ChartController::executeDispatch_InsertMenu_MeanValues() ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_AVERAGE_LINE )), m_xUndoManager ); - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { //if a series is selected insert mean value only for that series: lcl_InsertMeanValueLine( xSeries ); } - else + else if (rtl::Reference<Diagram> xDiagram = getFirstDiagram()) { - std::vector< uno::Reference< chart2::XDataSeries > > aSeries( - DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( getModel() ))); + std::vector< rtl::Reference< DataSeries > > aSeries = + xDiagram->getDataSeries(); for( const auto& xSrs : aSeries ) lcl_InsertMeanValueLine( xSrs ); @@ -340,8 +452,8 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() { OUString aCID = m_aSelection.getSelectedCID(); - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( aCID, getModel() ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() ); if( !xSeries.is() ) return; @@ -351,60 +463,58 @@ void ChartController::executeDispatch_InsertMenu_Trendlines() void ChartController::executeDispatch_InsertTrendline() { - uno::Reference< chart2::XRegressionCurveContainer > xRegressionCurveContainer( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel()), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegressionCurveContainer = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel()); if( !xRegressionCurveContainer.is() ) return; - UndoLiveUpdateGuard aUndoGuard( + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE )), m_xUndoManager ); - uno::Reference< chart2::XRegressionCurve > xCurve = + rtl::Reference< RegressionCurveModel > xCurve = RegressionCurveHelper::addRegressionCurve( SvxChartRegress::Linear, xRegressionCurveContainer ); - uno::Reference< beans::XPropertySet > xProperties( xCurve, uno::UNO_QUERY ); - - if( !xProperties.is()) + if( !xCurve.is()) return; - wrapper::RegressionCurveItemConverter aItemConverter( - xProperties, xRegressionCurveContainer, m_pDrawModelWrapper->getSdrModel().GetItemPool(), + auto aItemConverter = std::make_shared<wrapper::RegressionCurveItemConverter>( + xCurve, xRegressionCurveContainer, m_pDrawModelWrapper->getSdrModel().GetItemPool(), m_pDrawModelWrapper->getSdrModel(), - uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY )); + getChartModel() ); // open dialog - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); - aItemConverter.FillItemSet( aItemSet ); + SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet(); + aItemConverter->FillItemSet( aItemSet ); ObjectPropertiesDialogParameter aDialogParameter( ObjectIdentifier::createDataCurveCID( ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()), RegressionCurveHelper::getRegressionCurveIndex( xRegressionCurveContainer, xCurve ), false )); - aDialogParameter.init( getModel() ); + aDialogParameter.init( getChartModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); SolarMutexGuard aGuard; - SchAttribTabDlg aDialog( - GetChartFrame(), &aItemSet, &aDialogParameter, - &aViewElementListProvider, - uno::Reference< util::XNumberFormatsSupplier >( - getModel(), uno::UNO_QUERY ) ); + auto aDialog = std::make_shared<SchAttribTabDlg>(GetChartFrame(), &aItemSet, &aDialogParameter, + &aViewElementListProvider, getChartModel()); // note: when a user pressed "OK" but didn't change any settings in the // dialog, the SfxTabDialog returns "Cancel" - if( aDialog.run() == RET_OK || aDialog.DialogWasClosedWithOK()) - { - const SfxItemSet* pOutItemSet = aDialog.GetOutputItemSet(); - if( pOutItemSet ) + SfxTabDialogController::runAsync(aDialog, [this, aDialog, aItemConverter = std::move(aItemConverter), + xUndoGuard=std::move(xUndoGuard)](int nResult) { + if ( nResult == RET_OK || aDialog->DialogWasClosedWithOK() ) { - ControllerLockGuardUNO aCLGuard( getModel() ); - aItemConverter.ApplyItemSet( *pOutItemSet ); + const SfxItemSet* pOutItemSet = aDialog->GetOutputItemSet(); + if( pOutItemSet ) + { + ControllerLockGuardUNO aCLGuard( getChartModel() ); + aItemConverter->ApplyItemSet( *pOutItemSet ); + } + xUndoGuard->commit(); } - aUndoGuard.commit(); - } + }); } void ChartController::executeDispatch_InsertErrorBars( bool bYError ) @@ -412,12 +522,12 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) ObjectType objType = bYError ? OBJECTTYPE_DATA_ERRORS_Y : OBJECTTYPE_DATA_ERRORS_X; //if a series is selected insert error bars for that series only: - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is()) { - UndoLiveUpdateGuard aUndoGuard( + auto xUndoGuard = std::make_shared<UndoLiveUpdateGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( bYError ? STR_OBJECT_ERROR_BARS_Y : STR_OBJECT_ERROR_BARS_X )), @@ -430,47 +540,48 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) bYError)); // get an appropriate item converter - wrapper::ErrorBarItemConverter aItemConverter( - getModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(), - m_pDrawModelWrapper->getSdrModel(), - uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY )); + auto aItemConverter = std::make_shared<wrapper::ErrorBarItemConverter> ( + getChartModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(), + m_pDrawModelWrapper->getSdrModel() ); // open dialog - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + SfxItemSet aItemSet = aItemConverter->CreateEmptyItemSet(); aItemSet.Put(SfxBoolItem(SCHATTR_STAT_ERRORBAR_TYPE,bYError)); - aItemConverter.FillItemSet( aItemSet ); + aItemConverter->FillItemSet( aItemSet ); ObjectPropertiesDialogParameter aDialogParameter( ObjectIdentifier::createClassifiedIdentifierWithParent( objType, u"", m_aSelection.getSelectedCID())); - aDialogParameter.init( getModel() ); + aDialogParameter.init( getChartModel() ); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); SolarMutexGuard aGuard; - SchAttribTabDlg aDlg( + auto aDlg = std::make_shared<SchAttribTabDlg>( GetChartFrame(), &aItemSet, &aDialogParameter, &aViewElementListProvider, - uno::Reference< util::XNumberFormatsSupplier >( - getModel(), uno::UNO_QUERY ) ); - aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), + getChartModel() ); + aDlg->SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, m_aSelection.getSelectedCID())); // note: when a user pressed "OK" but didn't change any settings in the // dialog, the SfxTabDialog returns "Cancel" - if (aDlg.run() == RET_OK || aDlg.DialogWasClosedWithOK()) - { - const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); - if( pOutItemSet ) + SfxTabDialogController::runAsync(aDlg, [this, aDlg, aItemConverter=std::move(aItemConverter), + xUndoGuard=std::move(xUndoGuard)](int nResult) { + if ( nResult == RET_OK || aDlg->DialogWasClosedWithOK() ) { - ControllerLockGuardUNO aCLGuard( getModel() ); - aItemConverter.ApplyItemSet( *pOutItemSet ); + const SfxItemSet* pOutItemSet = aDlg->GetOutputItemSet(); + if( pOutItemSet ) + { + ControllerLockGuardUNO aCLGuard( getChartModel() ); + aItemConverter->ApplyItemSet( *pOutItemSet ); + } + xUndoGuard->commit(); } - aUndoGuard.commit(); - } + }); } else { //if no series is selected insert error bars for all series - UndoGuard aUndoGuard( + auto xUndoGuard = std::make_shared<UndoGuard>( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, ObjectNameProvider::getName_ObjectForAllSeries( objType ) ), @@ -478,32 +589,35 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) try { - wrapper::AllSeriesStatisticsConverter aItemConverter( - getModel(), m_pDrawModelWrapper->GetItemPool() ); - SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); - aItemConverter.FillItemSet( aItemSet ); + auto xItemConverter = std::make_shared<wrapper::AllSeriesStatisticsConverter>( + getChartModel(), m_pDrawModelWrapper->GetItemPool() ); + SfxItemSet aItemSet = xItemConverter->CreateEmptyItemSet(); + xItemConverter->FillItemSet( aItemSet ); //prepare and open dialog SolarMutexGuard aGuard; - InsertErrorBarsDialog aDlg( + auto aDlg = std::make_shared<InsertErrorBarsDialog>( GetChartFrame(), aItemSet, - uno::Reference< chart2::XChartDocument >( getModel(), uno::UNO_QUERY ), + getChartModel(), bYError ? ErrorBarResources::ERROR_BAR_Y : ErrorBarResources::ERROR_BAR_X); - aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, OUString() ) ); - - if (aDlg.run() == RET_OK) - { - SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); - aDlg.FillItemSet( aOutItemSet ); - - // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); - bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now - if( bChanged ) - aUndoGuard.commit(); - } + aDlg->SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getChartModel(), m_xChartView, u"" ) ); + + weld::DialogController::runAsync(aDlg, [this, aDlg, xItemConverter=std::move(xItemConverter), + xUndoGuard=std::move(xUndoGuard)](int nResult) { + if ( nResult == RET_OK ) + { + SfxItemSet aOutItemSet = xItemConverter->CreateEmptyItemSet(); + aDlg->FillItemSet( aOutItemSet ); + + // lock controllers till end of block + ControllerLockGuardUNO aCLGuard( getChartModel() ); + bool bChanged = xItemConverter->ApplyItemSet( aOutItemSet );//model should be changed now + if( bChanged ) + xUndoGuard->commit(); + } + }); } catch(const uno::RuntimeException&) { @@ -515,11 +629,11 @@ void ChartController::executeDispatch_InsertErrorBars( bool bYError ) void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) { uno::Reference< chart2::XRegressionCurve > xRegCurve( - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ), uno::UNO_QUERY ); if( !xRegCurve.is() ) { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegCurveCnt = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); } if( !xRegCurve.is()) @@ -532,10 +646,10 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE_EQUATION )), m_xUndoManager ); - xEqProp->setPropertyValue( "ShowEquation", uno::Any( true )); - xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); - xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x)") )); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( bInsertR2 )); + xEqProp->setPropertyValue( u"ShowEquation"_ustr, uno::Any( true )); + xEqProp->setPropertyValue( u"XName"_ustr, uno::Any( u"x"_ustr )); + xEqProp->setPropertyValue( u"YName"_ustr, uno::Any( u"f(x)"_ustr )); + xEqProp->setPropertyValue( u"ShowCorrelationCoefficient"_ustr, uno::Any( bInsertR2 )); aUndoGuard.commit(); } } @@ -543,14 +657,14 @@ void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) void ChartController::executeDispatch_InsertR2Value() { uno::Reference< beans::XPropertySet > xEqProp = - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ); if( xEqProp.is()) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE_EQUATION )), m_xUndoManager ); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( true )); + xEqProp->setPropertyValue( u"ShowCorrelationCoefficient"_ustr, uno::Any( true )); aUndoGuard.commit(); } } @@ -558,22 +672,22 @@ void ChartController::executeDispatch_InsertR2Value() void ChartController::executeDispatch_DeleteR2Value() { uno::Reference< beans::XPropertySet > xEqProp = - ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ); + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ); if( xEqProp.is()) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_CURVE_EQUATION )), m_xUndoManager ); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false )); + xEqProp->setPropertyValue( u"ShowCorrelationCoefficient"_ustr, uno::Any( false )); aUndoGuard.commit(); } } void ChartController::executeDispatch_DeleteMeanValue() { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegCurveCnt = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -587,8 +701,8 @@ void ChartController::executeDispatch_DeleteMeanValue() void ChartController::executeDispatch_DeleteTrendline() { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegCurveCnt = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -602,8 +716,8 @@ void ChartController::executeDispatch_DeleteTrendline() void ChartController::executeDispatch_DeleteTrendlineEquation() { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegCurveCnt = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -617,8 +731,8 @@ void ChartController::executeDispatch_DeleteTrendlineEquation() void ChartController::executeDispatch_DeleteErrorBars( bool bYError ) { - uno::Reference< chart2::XDataSeries > xDataSeries( - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() )); + rtl::Reference< DataSeries > xDataSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xDataSeries.is()) { UndoGuard aUndoGuard( @@ -632,14 +746,14 @@ void ChartController::executeDispatch_DeleteErrorBars( bool bYError ) void ChartController::executeDispatch_InsertDataLabels() { - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_DATALABELS )), m_xUndoManager ); - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + xSeries->insertDataLabelsToSeriesAndAllPoints(); aUndoGuard.commit(); } } @@ -649,20 +763,20 @@ void ChartController::executeDispatch_InsertDataLabel() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_LABEL )), m_xUndoManager ); - DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); + DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ) ); aUndoGuard.commit(); } void ChartController::executeDispatch_DeleteDataLabels() { - uno::Reference< chart2::XDataSeries > xSeries = - ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_DATALABELS )), m_xUndoManager ); - DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); + xSeries->deleteDataLabelsFromSeriesAndAllPoints(); aUndoGuard.commit(); } } @@ -672,7 +786,7 @@ void ChartController::executeDispatch_DeleteDataLabel() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_LABEL )), m_xUndoManager ); - DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ) ); + DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getChartModel() ) ); aUndoGuard.commit(); } @@ -681,7 +795,7 @@ void ChartController::executeDispatch_ResetAllDataPoints() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format, SchResId( STR_OBJECT_DATAPOINTS )), m_xUndoManager ); - uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) xSeries->resetAllDataPoints(); aUndoGuard.commit(); @@ -691,7 +805,7 @@ void ChartController::executeDispatch_ResetDataPoint() UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Format, SchResId( STR_OBJECT_DATAPOINT )), m_xUndoManager ); - uno::Reference< chart2::XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xSeries.is() ) { sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); @@ -704,18 +818,18 @@ void ChartController::executeDispatch_InsertAxisTitle() { try { - uno::Reference< XTitle > xTitle; + rtl::Reference< Title > xTitle; { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Insert, SchResId( STR_OBJECT_TITLE )), m_xUndoManager ); - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); sal_Int32 nDimensionIndex = -1; sal_Int32 nCooSysIndex = -1; sal_Int32 nAxisIndex = -1; - AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(getModel()), nCooSysIndex, nDimensionIndex, nAxisIndex ); + AxisHelper::getIndicesForAxis( xAxis, getFirstDiagram(), nCooSysIndex, nDimensionIndex, nAxisIndex ); TitleHelper::eTitleType eTitleType = TitleHelper::X_AXIS_TITLE; if( nDimensionIndex==0 ) @@ -725,8 +839,8 @@ void ChartController::executeDispatch_InsertAxisTitle() else eTitleType = TitleHelper::Z_AXIS_TITLE; - std::unique_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); - xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getModel(), m_xCC, apRefSizeProvider.get() ); + ReferenceSizeProvider aRefSizeProvider( impl_createReferenceSizeProvider()); + xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), getChartModel(), m_xCC, &aRefSizeProvider ); aUndoGuard.commit(); } } @@ -745,7 +859,7 @@ void ChartController::executeDispatch_InsertAxis() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeAxisVisible( xAxis ); @@ -767,7 +881,7 @@ void ChartController::executeDispatch_DeleteAxis() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { AxisHelper::makeAxisInvisible( xAxis ); @@ -789,10 +903,10 @@ void ChartController::executeDispatch_InsertMajorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { - AxisHelper::makeGridVisible( xAxis->getGridProperties() ); + AxisHelper::makeGridVisible( xAxis->getGridProperties2() ); aUndoGuard.commit(); } } @@ -811,10 +925,10 @@ void ChartController::executeDispatch_DeleteMajorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { - AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); + AxisHelper::makeGridInvisible( xAxis->getGridProperties2() ); aUndoGuard.commit(); } } @@ -833,11 +947,11 @@ void ChartController::executeDispatch_InsertMinorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { - const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( Reference< beans::XPropertySet > const & props : aSubGrids) + std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() ); + for( rtl::Reference< GridProperties > const & props : aSubGrids) AxisHelper::makeGridVisible( props ); aUndoGuard.commit(); } @@ -857,11 +971,11 @@ void ChartController::executeDispatch_DeleteMinorGrid() try { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); if( xAxis.is() ) { - const Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - for( Reference< beans::XPropertySet > const & props : aSubGrids) + std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() ); + for( rtl::Reference< ::chart::GridProperties > const & props : aSubGrids) AxisHelper::makeGridInvisible( props ); aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx index c6af3878bdd7..6bdedb0565b7 100644 --- a/chart2/source/controller/main/ChartController_Position.cxx +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -19,31 +19,27 @@ #include <ChartController.hxx> -#include <ChartWindow.hxx> #include <DrawViewWrapper.hxx> #include <PositionAndSizeHelper.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartView.hxx> #include "UndoGuard.hxx" #include <ObjectNameProvider.hxx> #include <DiagramHelper.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <CommonConverters.hxx> #include <svx/ActionDescriptionProvider.hxx> -#include <comphelper/servicehelper.hxx> #include <svx/svxids.hrc> #include <svx/rectenum.hxx> #include <svl/intitem.hxx> #include <svx/svxdlg.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <vcl/svapp.hxx> #include <memory> namespace chart { using namespace ::com::sun::star; -using namespace ::com::sun::star::chart2; static void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt::Rectangle& rPosAndSize, const awt::Size& rOriginalSize ) { @@ -54,19 +50,18 @@ static void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, awt:: RectPoint eRP = RectPoint::LT; - const SfxPoolItem* pPoolItem=nullptr; //read position - if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,true,&pPoolItem)==SfxItemState::SET) - nPosX= static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); - if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,true,&pPoolItem)==SfxItemState::SET) - nPosY=static_cast<const SfxInt32Item*>(pPoolItem)->GetValue(); + if (const SfxInt32Item* pPosXItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_X)) + nPosX = pPosXItem->GetValue(); + if (const SfxInt32Item* pPosYItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_POS_Y)) + nPosY = pPosYItem->GetValue(); //read size - if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,true,&pPoolItem)==SfxItemState::SET) - nSizX=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); - if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,true,&pPoolItem)==SfxItemState::SET) - nSizY=static_cast<const SfxUInt32Item*>(pPoolItem)->GetValue(); - if (rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,true,&pPoolItem)==SfxItemState::SET) - eRP=static_cast<RectPoint>(static_cast<const SfxUInt16Item*>(pPoolItem)->GetValue()); + if (const SfxUInt32Item* pWidthItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_WIDTH)) + nSizX = pWidthItem->GetValue(); + if (const SfxUInt32Item* pHeightItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_HEIGHT)) + nSizY = pHeightItem->GetValue(); + if (const SfxUInt16Item* pSizeItem = rItemSet.GetItemIfSet(SID_ATTR_TRANSFORM_SIZE_POINT)) + eRP=static_cast<RectPoint>(pSizeItem->GetValue()); switch( eRP ) { @@ -150,26 +145,21 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence if (!pPool) return; - sal_uInt16 nWhich; for (const auto& aProp: *pArgs) { sal_Int32 nValue = 0; aProp.Value >>= nValue; if (aProp.Name == "TransformPosX") { - nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_X); - aItemSet.Put(SfxInt32Item(nWhich, nValue)); + aItemSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_X, nValue)); } else if (aProp.Name == "TransformPosY") { - nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_POS_Y); - aItemSet.Put(SfxInt32Item(nWhich, nValue)); + aItemSet.Put(SfxInt32Item(SID_ATTR_TRANSFORM_POS_Y, nValue)); } else if (aProp.Name == "TransformWidth") { - nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_WIDTH); - aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue))); + aItemSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_WIDTH, static_cast<sal_uInt32>(nValue))); } else if (aProp.Name == "TransformHeight") { - nWhich = pPool->GetWhich(SID_ATTR_TRANSFORM_HEIGHT); - aItemSet.Put(SfxUInt32Item(nWhich, static_cast<sal_uInt32>(nValue))); + aItemSet.Put(SfxUInt32Item(SID_ATTR_TRANSFORM_HEIGHT, static_cast<sal_uInt32>(nValue))); } } } @@ -177,23 +167,21 @@ void ChartController::executeDispatch_PositionAndSize(const ::css::uno::Sequence if(pOutItemSet || pArgs) { awt::Rectangle aOldObjectRect; - ExplicitValueProvider* pProvider(comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); - if( pProvider ) - aOldObjectRect = pProvider->getRectangleOfObject(aCID); + if( m_xChartView ) + aOldObjectRect = m_xChartView->getRectangleOfObject(aCID); awt::Rectangle aNewObjectRect; lcl_getPositionAndSizeFromItemSet( aItemSet, aNewObjectRect, ToSize(aOldObjectRect) ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); awt::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); bool bChanged = false; if ( eObjectType == OBJECTTYPE_LEGEND ) { - ChartModel& rModel = dynamic_cast<ChartModel&>(*getModel()); - bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, false , true); + bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning(*getChartModel(), false , true); } - bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getModel() + bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID(), getChartModel() , aNewObjectRect, aOldObjectRect, aPageRect ); if( bMoved || bChanged ) aUndoGuard.commit(); diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx index e7a35fef3410..762d730d0539 100644 --- a/chart2/source/controller/main/ChartController_Properties.cxx +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -18,12 +18,11 @@ */ #include <ChartController.hxx> -#include <ChartWindow.hxx> +#include <ChartView.hxx> #include <chartview/DrawModelWrapper.hxx> #include <chartview/ChartSfxItemIds.hxx> #include <ObjectIdentifier.hxx> #include <chartview/ExplicitScaleValues.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <dlg_ObjectProperties.hxx> #include <dlg_View3D.hxx> #include <dlg_InsertErrorBars.hxx> @@ -34,15 +33,19 @@ #include <MultipleChartConverters.hxx> #include <TitleItemConverter.hxx> #include <LegendItemConverter.hxx> +#include <DataTableItemConverter.hxx> #include <RegressionCurveItemConverter.hxx> #include <RegressionEquationItemConverter.hxx> #include <ErrorBarItemConverter.hxx> -#include <ChartModelHelper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <TitleHelper.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> -#include <ColorPerPointHelper.hxx> -#include <DiagramHelper.hxx> +#include <ChartModel.hxx> +#include <DataSeries.hxx> +#include <DataSeriesProperties.hxx> +#include <Diagram.hxx> #include <ControllerLockGuard.hxx> #include "UndoGuard.hxx" #include <ObjectNameProvider.hxx> @@ -50,30 +53,30 @@ #include <strings.hrc> #include <ReferenceSizeProvider.hxx> #include <RegressionCurveHelper.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <RegressionCurveModel.hxx> +#include <o3tl/string_view.hxx> #include <com/sun/star/util/CloseVetoException.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <comphelper/servicehelper.hxx> #include <memory> #include <vcl/svapp.hxx> #include <svx/ActionDescriptionProvider.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; namespace { wrapper::ItemConverter* createItemConverter( - const OUString & aObjectCID, const uno::Reference<frame::XModel>& xChartModel, + std::u16string_view aObjectCID, const rtl::Reference<::chart::ChartModel>& xChartModel, const uno::Reference<uno::XComponentContext>& xContext, SdrModel& rDrawModel, - ExplicitValueProvider* pExplicitValueProvider, ReferenceSizeProvider const * pRefSizeProvider ) + ChartView* pExplicitValueProvider, ReferenceSizeProvider const * pRefSizeProvider ) { wrapper::ItemConverter* pItemConverter=nullptr; @@ -85,8 +88,8 @@ wrapper::ItemConverter* createItemConverter( return nullptr; } - OUString aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); - bool bAffectsMultipleObjects = aParticleID == "ALLELEMENTS"; + std::u16string_view aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); + bool bAffectsMultipleObjects = aParticleID == u"ALLELEMENTS"; if( !bAffectsMultipleObjects ) { uno::Reference< beans::XPropertySet > xObjectProperties = @@ -96,55 +99,49 @@ wrapper::ItemConverter* createItemConverter( //create itemconverter for a single object switch(eObjectType) { + case OBJECTTYPE_DATA_STOCK_LOSS: + case OBJECTTYPE_DATA_STOCK_GAIN: + case OBJECTTYPE_DIAGRAM_WALL: + case OBJECTTYPE_DIAGRAM_FLOOR: case OBJECTTYPE_PAGE: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineAndFillProperties ); break; case OBJECTTYPE_TITLE: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset(new awt::Size(pRefSizeProvider->getPageSize())); + pRefSize.emplace(pRefSizeProvider->getPageSize()); pItemConverter = new wrapper::TitleItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference<lang::XMultiServiceFactory>(xChartModel, uno::UNO_QUERY), - pRefSize.get()); + xChartModel, + pRefSize); } break; case OBJECTTYPE_LEGEND: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + pRefSize.emplace( pRefSizeProvider->getPageSize() ); pItemConverter = new wrapper::LegendItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference<lang::XMultiServiceFactory>(xChartModel, uno::UNO_QUERY), - pRefSize.get()); + xChartModel, + pRefSize); } break; case OBJECTTYPE_LEGEND_ENTRY: break; case OBJECTTYPE_DIAGRAM: break; - case OBJECTTYPE_DIAGRAM_WALL: - case OBJECTTYPE_DIAGRAM_FLOOR: - pItemConverter = new wrapper::GraphicPropertyItemConverter( - xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), - wrapper::GraphicObjectType::LineAndFillProperties ); - break; case OBJECTTYPE_AXIS: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); - - uno::Reference< beans::XPropertySet > xDiaProp; - xDiaProp.set( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + pRefSize.emplace( pRefSizeProvider->getPageSize() ); // the second property set contains the property CoordinateOrigin // nOriginIndex is the index of the corresponding index of the @@ -154,15 +151,15 @@ wrapper::ItemConverter* createItemConverter( ExplicitIncrementData aExplicitIncrement; if( pExplicitValueProvider ) pExplicitValueProvider->getExplicitValuesForAxis( - uno::Reference< XAxis >( xObjectProperties, uno::UNO_QUERY ), + dynamic_cast< Axis* >( xObjectProperties.get() ), aExplicitScale, aExplicitIncrement ); pItemConverter = new wrapper::AxisItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), + xChartModel, &aExplicitScale, &aExplicitIncrement, - pRefSize.get() ); + pRefSize ); } break; case OBJECTTYPE_AXIS_UNITLABEL: @@ -170,40 +167,40 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_LABELS: case OBJECTTYPE_DATA_LABEL: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + pRefSize.emplace( pRefSizeProvider->getPageSize() ); - uno::Reference<XDataSeries> xSeries = ObjectIdentifier::getDataSeriesForCID(aObjectCID, xChartModel); + rtl::Reference<DataSeries> xSeries = ObjectIdentifier::getDataSeriesForCID(aObjectCID, xChartModel); bool bDataSeries = eObjectType == OBJECTTYPE_DATA_LABELS; - sal_Int32 nNumberFormat = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties ); - sal_Int32 nPercentNumberFormat = ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( - xObjectProperties,uno::Reference<util::XNumberFormatsSupplier>(xChartModel, uno::UNO_QUERY)); + sal_Int32 nNumberFormat = xSeries->getExplicitNumberFormatKeyForDataLabel(); + sal_Int32 nPercentNumberFormat = ChartView::getExplicitPercentageNumberFormatKeyForDataLabel( + xObjectProperties, xChartModel); pItemConverter = new wrapper::TextLabelItemConverter( xChartModel, xObjectProperties, xSeries, - rDrawModel.GetItemPool(), pRefSize.get(), bDataSeries, + rDrawModel.GetItemPool(), pRefSize, bDataSeries, nNumberFormat, nPercentNumberFormat); } break; case OBJECTTYPE_DATA_SERIES: case OBJECTTYPE_DATA_POINT: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + pRefSize.emplace( pRefSizeProvider->getPageSize() ); wrapper::GraphicObjectType eMapTo = wrapper::GraphicObjectType::FilledDataPoint; - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); - uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); + rtl::Reference< ChartType > xChartType = xChartModel->getChartTypeOfSeries( xSeries ); - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ) ) + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + sal_Int32 nDimensionCount = xDiagram->getDimension(); + if (xChartType.is() && !xChartType->isSupportingAreaProperties(nDimensionCount)) eMapTo = wrapper::GraphicObjectType::LineDataPoint; bool bDataSeries = eObjectType == OBJECTTYPE_DATA_SERIES; @@ -214,14 +211,14 @@ wrapper::ItemConverter* createItemConverter( sal_Int32 nPointIndex = -1; /*-1 for whole series*/ if(!bDataSeries) { - nPointIndex = aParticleID.toInt32(); - uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); + nPointIndex = o3tl::toInt32(aParticleID); bool bVaryColorsByPoint = false; - if( xSeriesProp.is() && - (xSeriesProp->getPropertyValue("VaryColorsByPoint") >>= bVaryColorsByPoint) && + if( xSeries.is() && + // "VaryColorsByPoint" + (xSeries->getFastPropertyValue(PROP_DATASERIES_VARY_COLORS_BY_POINT) >>= bVaryColorsByPoint) && bVaryColorsByPoint ) { - if( !ColorPerPointHelper::hasPointOwnColor( xSeriesProp, nPointIndex, xObjectProperties ) ) + if( !xSeries->hasPointOwnColor( nPointIndex, xObjectProperties ) ) { bUseSpecialFillColor = true; OSL_ASSERT( xDiagram.is()); @@ -231,14 +228,13 @@ wrapper::ItemConverter* createItemConverter( } } } - sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties ); - sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( - xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); + sal_Int32 nNumberFormat=xSeries->getExplicitNumberFormatKeyForDataLabel(); + sal_Int32 nPercentNumberFormat=ChartView::getExplicitPercentageNumberFormatKeyForDataLabel( + xObjectProperties, xChartModel); pItemConverter = new wrapper::DataPointItemConverter( xChartModel, xContext, xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), - eMapTo, pRefSize.get(), bDataSeries, bUseSpecialFillColor, nSpecialFillColor, true, + eMapTo, pRefSize, bDataSeries, bUseSpecialFillColor, nSpecialFillColor, true, nNumberFormat, nPercentNumberFormat, nPointIndex ); break; } @@ -247,7 +243,7 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_AVERAGE_LINE: pItemConverter = new wrapper::GraphicPropertyItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + rDrawModel, xChartModel, wrapper::GraphicObjectType::LineProperties ); break; @@ -256,37 +252,37 @@ wrapper::ItemConverter* createItemConverter( case OBJECTTYPE_DATA_ERRORS_Z: pItemConverter = new wrapper::ErrorBarItemConverter( xChartModel, xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel ); break; case OBJECTTYPE_DATA_CURVE: pItemConverter = new wrapper::RegressionCurveItemConverter( - xObjectProperties, uno::Reference< chart2::XRegressionCurveContainer >( - ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ), uno::UNO_QUERY ), - rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + xObjectProperties, + ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ), + rDrawModel.GetItemPool(), rDrawModel, + xChartModel); break; case OBJECTTYPE_DATA_CURVE_EQUATION: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset(new awt::Size(pRefSizeProvider->getPageSize())); + pRefSize.emplace(pRefSizeProvider->getPageSize()); pItemConverter = new wrapper::RegressionEquationItemConverter( xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, - uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), - pRefSize.get()); + xChartModel, + pRefSize); break; } case OBJECTTYPE_DATA_STOCK_RANGE: break; - case OBJECTTYPE_DATA_STOCK_LOSS: - case OBJECTTYPE_DATA_STOCK_GAIN: - pItemConverter = new wrapper::GraphicPropertyItemConverter( + case OBJECTTYPE_DATA_TABLE: + { + pItemConverter = new wrapper::DataTableItemConverter( xObjectProperties, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), - wrapper::GraphicObjectType::LineAndFillProperties ); - break; + rDrawModel, xChartModel); + } + break; default: //OBJECTTYPE_UNKNOWN break; } @@ -298,23 +294,23 @@ wrapper::ItemConverter* createItemConverter( { case OBJECTTYPE_TITLE: pItemConverter = new wrapper::AllTitleItemConverter( xChartModel, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel ); break; case OBJECTTYPE_AXIS: { - std::unique_ptr<awt::Size> pRefSize; + std::optional<awt::Size> pRefSize; if (pRefSizeProvider) - pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + pRefSize.emplace( pRefSizeProvider->getPageSize() ); pItemConverter = new wrapper::AllAxisItemConverter( xChartModel, rDrawModel.GetItemPool(), - rDrawModel, pRefSize.get()); + rDrawModel, pRefSize ); } break; case OBJECTTYPE_GRID: case OBJECTTYPE_SUBGRID: pItemConverter = new wrapper::AllGridItemConverter( xChartModel, rDrawModel.GetItemPool(), - rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + rDrawModel ); break; default: //for this type it is not supported to change all elements at once break; @@ -324,7 +320,7 @@ wrapper::ItemConverter* createItemConverter( return pItemConverter; } -OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel > & xChartModel ) +OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel> & xChartModel ) { if( rDispatchCommand == "AllTitles") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, u"ALLELEMENTS" ); @@ -343,11 +339,11 @@ OUString lcl_getTitleCIDForCommand( std::string_view rDispatchCommand, const uno else if( rDispatchCommand == "SecondaryYTitle" ) nTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; - uno::Reference< XTitle > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); + rtl::Reference< Title > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ); } -OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel>& xChartModel ) { if( rDispatchCommand == "DiagramAxisAll") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS, u"ALLELEMENTS" ); @@ -375,14 +371,14 @@ OUString lcl_getAxisCIDForCommand( std::string_view rDispatchCommand, const uno: nDimensionIndex=1; bMainAxis=false; } - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); - uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ); return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ); } -OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel>& xChartModel ) { - uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + rtl::Reference< Diagram > xDiagram = xChartModel->getFirstChartDiagram(); if( rDispatchCommand == "DiagramGridAll") return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, u"ALLELEMENTS" ); @@ -417,7 +413,7 @@ OUString lcl_getGridCIDForCommand( std::string_view rDispatchCommand, const uno: nDimensionIndex=2; bMainGrid=false; } - uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, true/*bMainAxis*/, xDiagram ) ); + rtl::Reference< Axis > xAxis = AxisHelper::getAxis( nDimensionIndex, true/*bMainAxis*/, xDiagram ); sal_Int32 nSubGridIndex= bMainGrid ? -1 : 0; OUString aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGridIndex ) ); @@ -432,14 +428,12 @@ OUString lcl_getErrorCIDForCommand( const ObjectType eDispatchType, const Object return ObjectIdentifier::createClassifiedIdentifierWithParent( eDispatchType, u"", rSelectedCID ); } -OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const OUString& rSelectedCID ) +OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const rtl::Reference<::chart::ChartModel> & xChartDocument, const OUString& rSelectedCID ) { ObjectType eObjectType = OBJECTTYPE_UNKNOWN; - uno::Reference< frame::XModel > xChartModel = xChartDocument; const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel ); - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartDocument ); //legend if( rDispatchCommand == "Legend" || rDispatchCommand == "FormatLegend" ) @@ -474,7 +468,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "AllTitles" ) { - return lcl_getTitleCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getTitleCIDForCommand( rDispatchCommand, xChartDocument ); } //axis else if( rDispatchCommand == "DiagramAxisX" @@ -485,7 +479,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "DiagramAxisAll" ) { - return lcl_getAxisCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getAxisCIDForCommand( rDispatchCommand, xChartDocument ); } //grid else if( rDispatchCommand == "DiagramGridYMain" @@ -497,7 +491,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un || rDispatchCommand == "DiagramGridAll" ) { - return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel ); + return lcl_getGridCIDForCommand( rDispatchCommand, xChartDocument ); } //data series else if( rDispatchCommand == "FormatDataSeries" ) @@ -529,7 +523,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32(); + sal_Int32 nPointIndex = o3tl::toInt32(ObjectIdentifier::getParticleID( rSelectedCID )); if( nPointIndex>=0 ) { OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ); @@ -550,8 +544,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un else return ObjectIdentifier::createDataCurveCID( ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), - RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, - RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) ), true ); + RegressionCurveHelper::getRegressionCurveIndex( xSeries, + RegressionCurveHelper::getMeanValueLine( xSeries ) ), true ); } //trend line else if( rDispatchCommand == "FormatTrendline" ) @@ -561,8 +555,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un else return ObjectIdentifier::createDataCurveCID( ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), - RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, - RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ), false ); + RegressionCurveHelper::getRegressionCurveIndex( xSeries, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ) ), false ); } //trend line equation else if( rDispatchCommand == "FormatTrendlineEquation" ) @@ -572,8 +566,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un else return ObjectIdentifier::createDataCurveEquationCID( ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), - RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, - RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ) ); + RegressionCurveHelper::getRegressionCurveIndex( xSeries, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ) ) ); } // y error bars else if( rDispatchCommand == "FormatXErrorBars" ) @@ -592,8 +586,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartDocument ); } } // major grid @@ -603,8 +597,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDocument ); } } @@ -615,8 +609,8 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un return rSelectedCID; else { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); - return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ ); + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartDocument ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDocument, 0 /*sub grid index*/ ); } } // title @@ -652,7 +646,7 @@ OUString lcl_getObjectCIDForCommand( std::string_view rDispatchCommand, const un void ChartController::executeDispatch_FormatObject(std::u16string_view rDispatchCommand) { - uno::Reference< XChartDocument > xChartDocument( getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDocument( getChartModel() ); OString aCommand( OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) ); OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() ); executeDlg_ObjectProperties( rObjectCID ); @@ -676,7 +670,7 @@ OUString lcl_getFormatCIDforSelectedCID( const OUString& rSelectedCID ) // some legend entries are handled as if they were data series if( eObjectType==OBJECTTYPE_LEGEND_ENTRY ) { - OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); + std::u16string_view aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); aFormatCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); } @@ -693,24 +687,22 @@ void ChartController::executeDlg_ObjectProperties( const OUString& rSelectedObje { OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); - UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( - ActionDescriptionProvider::ActionType::Format, - ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), - m_xUndoManager ); + auto xUndoGuard = std::make_shared<UndoGuard>( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::ActionType::Format, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), + m_xUndoManager ); - bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); - if( bSuccess ) - aUndoGuard.commit(); + ChartController::executeDlg_ObjectProperties_withUndoGuard(std::move(xUndoGuard), aObjectCID, false ); } -bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( - const OUString& rObjectCID, bool bSuccessOnUnchanged ) +void ChartController::executeDlg_ObjectProperties_withUndoGuard( + std::shared_ptr<UndoGuard> xUndoGuard, const OUString& rObjectCID, bool bSuccessOnUnchanged ) { //return true if the properties were changed successfully - bool bRet = false; if( rObjectCID.isEmpty() ) { - return bRet; + return; } try { @@ -718,26 +710,28 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); if( eObjectType==OBJECTTYPE_UNKNOWN ) { - return bRet; + return; } if( eObjectType==OBJECTTYPE_DIAGRAM_WALL || eObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) { - if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( getModel() ) ) ) - return bRet; + if( !getFirstDiagram()->isSupportingFloorAndWall() ) + return; } //convert properties to ItemSet - std::unique_ptr<ReferenceSizeProvider> pRefSizeProv(impl_createReferenceSizeProvider()); + ReferenceSizeProvider aRefSizeProv(impl_createReferenceSizeProvider()); + + rtl::Reference<::chart::ChartModel> xChartDoc(getChartModel()); - std::unique_ptr<wrapper::ItemConverter> pItemConverter( - createItemConverter( rObjectCID, getModel(), m_xCC, + std::shared_ptr<wrapper::ItemConverter> pItemConverter( + createItemConverter( rObjectCID, xChartDoc, m_xCC, m_pDrawModelWrapper->getSdrModel(), - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>(m_xChartView), - pRefSizeProv.get())); + m_xChartView.get(), + &aRefSizeProv)); if (!pItemConverter) - return bRet; + return; SfxItemSet aItemSet = pItemConverter->CreateEmptyItemSet(); @@ -748,52 +742,52 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( //prepare dialog ObjectPropertiesDialogParameter aDialogParameter( rObjectCID ); - aDialogParameter.init( getModel() ); + aDialogParameter.init(xChartDoc); ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); SolarMutexGuard aGuard; - SchAttribTabDlg aDlg( - GetChartFrame(), &aItemSet, &aDialogParameter, - &aViewElementListProvider, - uno::Reference< util::XNumberFormatsSupplier >( - getModel(), uno::UNO_QUERY ) ); + std::shared_ptr<SchAttribTabDlg> aDlgPtr = std::make_shared<SchAttribTabDlg>( + GetChartFrame(), &aItemSet, &aDialogParameter, + &aViewElementListProvider, + xChartDoc); if(aDialogParameter.HasSymbolProperties()) { uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( rObjectCID, getModel() ); - wrapper::DataPointItemConverter aSymbolItemConverter( getModel(), m_xCC - , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, getModel() ) + ObjectIdentifier::getObjectPropertySet( rObjectCID, xChartDoc ); + wrapper::DataPointItemConverter aSymbolItemConverter( xChartDoc, m_xCC + , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, xChartDoc ) , m_pDrawModelWrapper->getSdrModel().GetItemPool() , m_pDrawModelWrapper->getSdrModel() - , uno::Reference< lang::XMultiServiceFactory >( getModel(), uno::UNO_QUERY ) , wrapper::GraphicObjectType::FilledDataPoint ); - std::unique_ptr<SfxItemSet> pSymbolShapeProperties(new SfxItemSet( aSymbolItemConverter.CreateEmptyItemSet() )); - aSymbolItemConverter.FillItemSet( *pSymbolShapeProperties ); + SfxItemSet aSymbolShapeProperties(aSymbolItemConverter.CreateEmptyItemSet() ); + aSymbolItemConverter.FillItemSet( aSymbolShapeProperties ); sal_Int32 const nStandardSymbol=0;//@todo get from somewhere - std::unique_ptr<Graphic> pAutoSymbolGraphic(new Graphic( aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, pSymbolShapeProperties.get() ) )); + std::optional<Graphic> oAutoSymbolGraphic(std::in_place, aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, &aSymbolShapeProperties ) ); // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic - aDlg.setSymbolInformation( std::move(pSymbolShapeProperties), std::move(pAutoSymbolGraphic) ); + aDlgPtr->setSymbolInformation( std::move(aSymbolShapeProperties), std::move(oAutoSymbolGraphic) ); } if( aDialogParameter.HasStatisticProperties() ) { - aDlg.SetAxisMinorStepWidthForErrorBarDecimals( - InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( getModel(), m_xChartView, rObjectCID ) ); + aDlgPtr->SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( xChartDoc, m_xChartView, rObjectCID ) ); } //open the dialog - if (aDlg.run() == RET_OK || (bSuccessOnUnchanged && aDlg.DialogWasClosedWithOK())) + SfxTabDialogController::runAsync(aDlgPtr, [aDlgPtr, xChartDoc, pItemConverter=std::move(pItemConverter), + bSuccessOnUnchanged, xUndoGuard=std::move(xUndoGuard)] (int nResult) { - const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); - if(pOutItemSet) - { - ControllerLockGuardUNO aCLGuard( getModel()); - (void)pItemConverter->ApplyItemSet(*pOutItemSet); //model should be changed now - bRet = true; + if (nResult == RET_OK || (bSuccessOnUnchanged && aDlgPtr->DialogWasClosedWithOK())) { + const SfxItemSet* pOutItemSet = aDlgPtr->GetOutputItemSet(); + if(pOutItemSet) { + ControllerLockGuardUNO aCLGuard(xChartDoc); + (void)pItemConverter->ApplyItemSet(*pOutItemSet); //model should be changed now + xUndoGuard->commit(); + } } - } + }); } catch( const util::CloseVetoException& ) { @@ -801,7 +795,6 @@ bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( catch( const uno::RuntimeException& ) { } - return bRet; } void ChartController::executeDispatch_View3D() @@ -814,7 +807,7 @@ void ChartController::executeDispatch_View3D() //open dialog SolarMutexGuard aSolarGuard; - View3DDialog aDlg(GetChartFrame(), getModel()); + View3DDialog aDlg(GetChartFrame(), getChartModel()); if (aDlg.run() == RET_OK) aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx index 217accdde083..0cd974176672 100644 --- a/chart2/source/controller/main/ChartController_TextEdit.cxx +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -17,18 +17,26 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_wasm_strip.h> + #include <ChartController.hxx> #include <ResId.hxx> #include "UndoGuard.hxx" #include <DrawViewWrapper.hxx> #include <ChartWindow.hxx> +#include <ChartModel.hxx> +#include <ChartView.hxx> #include <TitleHelper.hxx> #include <ObjectIdentifier.hxx> #include <ControllerLockGuard.hxx> +#include <comphelper/diagnose_ex.hxx> +#if !ENABLE_WASM_STRIP_ACCESSIBILITY #include <AccessibleTextHelper.hxx> +#endif #include <strings.hrc> #include <chartview/DrawModelWrapper.hxx> +#include <osl/diagnose.h> #include <svx/svdoutl.hxx> #include <svx/svxdlg.hxx> @@ -36,9 +44,12 @@ #include <editeng/editids.hrc> #include <vcl/svapp.hxx> #include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/chart2/XTitle.hpp> +#include <com/sun/star/beans/XPropertySetInfo.hpp> +#include <com/sun/star/text/XTextCursor.hpp> +#include <com/sun/star/chart2/FormattedString.hpp> #include <svl/stritem.hxx> #include <editeng/fontitem.hxx> +#include <editeng/section.hxx> #include <memory> namespace chart @@ -66,9 +77,8 @@ void ChartController::StartTextEdit( const Point* pMousePixel ) SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); //#i77362 change notification for changes on additional shapes are missing - uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY ); - if( xChartViewProps.is() ) - xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::Any(true) ); + if( m_xChartView.is() ) + m_xChartView->setPropertyValue( u"SdrViewIsInEditMode"_ustr, uno::Any(true) ); auto pChartWindow(GetChartWindow()); @@ -111,43 +121,102 @@ bool ChartController::EndTextEdit() m_pDrawViewWrapper->SdrEndTextEdit(); //#i77362 change notification for changes on additional shapes are missing - uno::Reference< beans::XPropertySet > xChartViewProps( m_xChartView, uno::UNO_QUERY ); - if( xChartViewProps.is() ) - xChartViewProps->setPropertyValue( "SdrViewIsInEditMode", uno::Any(false) ); + if( m_xChartView.is() ) + m_xChartView->setPropertyValue( u"SdrViewIsInEditMode"_ustr, uno::Any(false) ); SdrObject* pTextObject = m_pDrawViewWrapper->getTextEditObject(); if(!pTextObject) return false; - SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject(); - if( pParaObj && pOutliner ) + if( !pParaObj ) + return true; + + OUString aObjectCID = m_aSelection.getSelectedCID(); + if ( !aObjectCID.isEmpty() ) { - pOutliner->SetText( *pParaObj ); + uno::Reference< beans::XPropertySet > xPropSet = + ObjectIdentifier::getObjectPropertySet( aObjectCID, getChartModel() ); - OUString aString = pOutliner->GetText( - pOutliner->GetParagraph( 0 ), - pOutliner->GetParagraphCount() ); + // lock controllers till end of block + ControllerLockGuardUNO aCLGuard( getChartModel() ); - OUString aObjectCID = m_aSelection.getSelectedCID(); - if ( !aObjectCID.isEmpty() ) - { - uno::Reference< beans::XPropertySet > xPropSet = - ObjectIdentifier::getObjectPropertySet( aObjectCID, getModel() ); + uno::Sequence< uno::Reference< chart2::XFormattedString > > aNewFormattedTitle = + GetFormattedTitle(pParaObj->GetTextObject(), pTextObject->getUnoShape()); + + Title* pTitle = dynamic_cast<Title*>(xPropSet.get()); + TitleHelper::setFormattedString(pTitle, aNewFormattedTitle); + + OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!"); + if (m_pTextActionUndoGuard) + m_pTextActionUndoGuard->commit(); + } + m_pTextActionUndoGuard.reset(); + return true; +} + +uno::Sequence< uno::Reference< chart2::XFormattedString > > ChartController::GetFormattedTitle( + const EditTextObject& aEdit, const uno::Reference< drawing::XShape >& xShape ) +{ + std::vector < uno::Reference< chart2::XFormattedString > > aNewStrings; + if (!xShape.is()) + return comphelper::containerToSequence(aNewStrings); + + uno::Reference< text::XText > xText(xShape, uno::UNO_QUERY); + if (!xText.is()) + return comphelper::containerToSequence(aNewStrings); + + uno::Reference< text::XTextCursor > xSelectionCursor(xText->createTextCursor()); + if (!xSelectionCursor.is()) + return comphelper::containerToSequence(aNewStrings); + + xSelectionCursor->gotoStart(false); + + std::vector<editeng::Section> aSecAttrs; + aEdit.GetAllSections(aSecAttrs); + + for (editeng::Section const& rSection : aSecAttrs) + { + if (!xSelectionCursor->isCollapsed()) + xSelectionCursor->collapseToEnd(); + + xSelectionCursor->goRight(rSection.mnEnd - rSection.mnStart, true); + + OUString aNewString = xSelectionCursor->getString(); - // lock controllers till end of block - ControllerLockGuardUNO aCLGuard( getModel() ); + bool bNextPara = (aEdit.GetParagraphCount() > 1 && rSection.mnParagraph != aEdit.GetParagraphCount() - 1 && + aEdit.GetTextLen(rSection.mnParagraph) <= rSection.mnEnd); - TitleHelper::setCompleteString( aString, uno::Reference< - css::chart2::XTitle >::query( xPropSet ), m_xCC ); + uno::Reference< chart2::XFormattedString2 > xFmtStr = chart2::FormattedString::create(m_xCC); + if (bNextPara) + aNewString = aNewString + OUStringChar('\n'); + xFmtStr->setString(aNewString); + aNewStrings.emplace_back(xFmtStr); - OSL_ENSURE(m_pTextActionUndoGuard, "ChartController::EndTextEdit: no TextUndoGuard!"); - if (m_pTextActionUndoGuard) - m_pTextActionUndoGuard->commit(); + uno::Reference< beans::XPropertySetInfo > xInfo = xFmtStr->getPropertySetInfo(); + uno::Reference< beans::XPropertySet > xSelectionProp(xSelectionCursor, uno::UNO_QUERY); + try + { + for (const beans::Property& rProp : xSelectionProp->getPropertySetInfo()->getProperties()) + { + if (xInfo.is() && xInfo->hasPropertyByName(rProp.Name)) + { + const uno::Any aValue = xSelectionProp->getPropertyValue(rProp.Name); + xFmtStr->setPropertyValue(rProp.Name, aValue); + } + } + } + catch ( const uno::Exception& ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + aNewStrings.clear(); } - m_pTextActionUndoGuard.reset(); + + if (bNextPara) + xSelectionCursor->goRight(1, false); // next paragraph } - return true; + + return comphelper::containerToSequence(aNewStrings); } void ChartController::executeDispatch_InsertSpecialCharacter() @@ -170,54 +239,60 @@ void ChartController::executeDispatch_InsertSpecialCharacter() aSet.Put( SfxBoolItem( FN_PARAM_2, true ) ); //maybe not necessary in future vcl::Font aCurFont = m_pDrawViewWrapper->getOutliner()->GetRefDevice()->GetFont(); - aSet.Put( SvxFontItem( aCurFont.GetFamilyType(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) ); - - ScopedVclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetChartFrame(), aSet, nullptr)); - if( pDlg->Execute() != RET_OK ) - return; - - const SfxItemSet* pSet = pDlg->GetOutputItemSet(); - const SfxPoolItem* pItem=nullptr; - OUString aString; - if (pSet && pSet->GetItemState(SID_CHARMAP, true, &pItem) == SfxItemState::SET) - if (auto pStringItem = dynamic_cast<const SfxStringItem*>(pItem)) - aString = pStringItem->GetValue(); - - OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + aSet.Put( SvxFontItem( aCurFont.GetFamilyTypeMaybeAskConfig(), aCurFont.GetFamilyName(), aCurFont.GetStyleName(), aCurFont.GetPitchMaybeAskConfig(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) ); - if(!pOutliner || !pOutlinerView) - return; - - // insert string to outliner - - // prevent flicker - pOutlinerView->HideCursor(); - pOutliner->SetUpdateMode(false); - - // delete current selection by inserting empty String, so current - // attributes become unique (sel. has to be erased anyway) - pOutlinerView->InsertText(OUString()); - - pOutlinerView->InsertText(aString, true); - - ESelection aSel = pOutlinerView->GetSelection(); - aSel.nStartPara = aSel.nEndPara; - aSel.nStartPos = aSel.nEndPos; - pOutlinerView->SetSelection(aSel); + VclPtr<SfxAbstractDialog> pDlg(pFact->CreateCharMapDialog(GetChartFrame(), aSet, nullptr)); + pDlg->StartExecuteAsync( + [this, pDlg] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + { + const SfxItemSet* pSet = pDlg->GetOutputItemSet(); + OUString aString; + if (pSet) + if (const SfxStringItem* pCharMapItem = pSet->GetItemIfSet(SID_CHARMAP)) + aString = pCharMapItem->GetValue(); + + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + + if(pOutliner && pOutlinerView) + { + // insert string to outliner + + // prevent flicker + pOutlinerView->HideCursor(); + pOutliner->SetUpdateLayout(false); + + // delete current selection by inserting empty String, so current + // attributes become unique (sel. has to be erased anyway) + pOutlinerView->InsertText(OUString()); + + pOutlinerView->InsertText(aString, true); + + ESelection aSel = pOutlinerView->GetSelection(); + aSel.CollapseToEnd(); + pOutlinerView->SetSelection(aSel); + + // show changes + pOutliner->SetUpdateLayout(true); + pOutlinerView->ShowCursor(); + } + } + pDlg->disposeOnce(); + } + ); - // show changes - pOutliner->SetUpdateMode(true); - pOutlinerView->ShowCursor(); } -uno::Reference< css::accessibility::XAccessibleContext > - ChartController::impl_createAccessibleTextContext() +rtl::Reference< ::chart::AccessibleTextHelper > + ChartController::createAccessibleTextContext() { - uno::Reference< css::accessibility::XAccessibleContext > xResult( - new AccessibleTextHelper( m_pDrawViewWrapper.get() )); - - return xResult; +#if !ENABLE_WASM_STRIP_ACCESSIBILITY + return new AccessibleTextHelper( m_pDrawViewWrapper.get() ); +#else + return {}; +#endif } } //namespace chart diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx index 093cbcdaeac8..ef64a1d84b9e 100644 --- a/chart2/source/controller/main/ChartController_Tools.cxx +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -20,9 +20,9 @@ #include <ChartController.hxx> #include <ChartWindow.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include <TitleHelper.hxx> -#include <ThreeDHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include "UndoGuard.hxx" #include <ControllerLockGuard.hxx> @@ -33,24 +33,28 @@ #include <chartview/DrawModelWrapper.hxx> #include "ChartTransferable.hxx" #include <DrawViewWrapper.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> +#include <RegressionCurveModel.hxx> #include <RegressionCurveHelper.hxx> #include "ShapeController.hxx" #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <ObjectNameProvider.hxx> #include <unonames.hxx> +#include <com/sun/star/awt/FontWeight.hpp> +#include <com/sun/star/awt/Gradient.hpp> #include <com/sun/star/chart2/DataPointLabel.hpp> -#include <com/sun/star/beans/XPropertyState.hpp> #include <com/sun/star/graphic/XGraphic.hpp> -#include <com/sun/star/text/XTextRange.hpp> #include <com/sun/star/drawing/TextVerticalAdjust.hpp> #include <com/sun/star/drawing/TextHorizontalAdjust.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> +#include <docmodel/uno/UnoGradientTools.hxx> #include <editeng/editview.hxx> #include <editeng/outliner.hxx> #include <svx/ActionDescriptionProvider.hxx> @@ -69,13 +73,12 @@ #include <svx/svdundo.hxx> #include <svx/unoapi.hxx> #include <svx/unopage.hxx> -#include <svx/xgrad.hxx> -#include <svx/xflgrit.hxx> +#include <svx/unoshape.hxx> #include <PropertyHelper.hxx> #include <LibreOfficeKit/LibreOfficeKitEnums.h> #include <tools/debug.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <tools/UnitConversion.hxx> #include <memory> @@ -92,17 +95,16 @@ namespace { bool lcl_deleteDataSeries( - const OUString & rCID, - const Reference< frame::XModel > & xModel, + std::u16string_view rCID, + const rtl::Reference<::chart::ChartModel> & xModel, const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; - uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); - uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); - if( xSeries.is() && xChartDoc.is()) + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rCID, xModel ); + if( xSeries.is() && xModel.is()) { - uno::Reference< chart2::XChartType > xChartType( - DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); + rtl::Reference< ::chart::ChartType > xChartType = + DataSeriesHelper::getChartTypeOfSeries( xSeries, xModel->getFirstChartDiagram()); if( xChartType.is()) { UndoGuard aUndoGuard( @@ -110,10 +112,10 @@ bool lcl_deleteDataSeries( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_DATASERIES )), xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) ); - uno::Reference< chart2::XAxis > xAxis( DiagramHelper::getAttachedAxis( xSeries, xDiagram ) ); + rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); + rtl::Reference< Axis > xAxis = xDiagram->getAttachedAxis( xSeries ); - DataSeriesHelper::deleteSeries( xSeries, xChartType ); + xChartType->deleteSeries( xSeries ); AxisHelper::hideAxisIfNoDataIsAttached( xAxis, xDiagram ); @@ -125,8 +127,8 @@ bool lcl_deleteDataSeries( } bool lcl_deleteDataCurve( - const OUString & rCID, - const Reference< frame::XModel > & xModel, + std::u16string_view rCID, + const rtl::Reference<::chart::ChartModel> & xModel, const Reference< document::XUndoManager > & xUndoManager ) { bool bResult = false; @@ -158,21 +160,35 @@ bool lcl_deleteDataCurve( return bResult; } +bool lcl_arePropertiesSame(const std::vector<Reference<beans::XPropertySet>>& xProperties, + OUString& aPropName) +{ + if (xProperties.size() == 1) + return true; + if (xProperties.size() < 1) + return false; + + uno::Any aValue = xProperties[0]->getPropertyValue(aPropName); + for (std::size_t i = 1; i < xProperties.size(); i++) + { + if (aValue != xProperties[i]->getPropertyValue(aPropName)) + return false; + } + return true; +} + } // anonymous namespace -std::unique_ptr<ReferenceSizeProvider> ChartController::impl_createReferenceSizeProvider() +ReferenceSizeProvider ChartController::impl_createReferenceSizeProvider() { - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); - return std::make_unique<ReferenceSizeProvider>( - aPageSize, Reference<chart2::XChartDocument>(getModel(), uno::UNO_QUERY)); + return ReferenceSizeProvider(aPageSize, getChartModel()); } void ChartController::impl_adaptDataSeriesAutoResize() { - std::unique_ptr<ReferenceSizeProvider> pRefSizeProvider(impl_createReferenceSizeProvider()); - if (pRefSizeProvider) - pRefSizeProvider->setValuesAtAllDataSeries(); + impl_createReferenceSizeProvider().setValuesAtAllDataSeries(); } void ChartController::executeDispatch_NewArrangement() @@ -182,8 +198,8 @@ void ChartController::executeDispatch_NewArrangement() try { - Reference< frame::XModel > xModel( getModel() ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); + rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); if( xDiagram.is()) { UndoGuard aUndoGuard( @@ -192,21 +208,20 @@ void ChartController::executeDispatch_NewArrangement() ControllerLockGuardUNO aCtlLockGuard( xModel ); // diagram - Reference< beans::XPropertyState > xState( xDiagram, uno::UNO_QUERY_THROW ); - xState->setPropertyToDefault( "RelativeSize"); - xState->setPropertyToDefault( "RelativePosition"); - xState->setPropertyToDefault( "PosSizeExcludeAxes"); + xDiagram->setPropertyToDefault( u"RelativeSize"_ustr); + xDiagram->setPropertyToDefault( u"RelativePosition"_ustr); + xDiagram->setPropertyToDefault( u"PosSizeExcludeAxes"_ustr); // 3d rotation - ThreeDHelper::set3DSettingsToDefault( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ) ); + xDiagram->set3DSettingsToDefault(); // legend - Reference< beans::XPropertyState > xLegendState( xDiagram->getLegend(), uno::UNO_QUERY ); - if( xLegendState.is()) + rtl::Reference< Legend > xLegend = xDiagram->getLegend2(); + if( xLegend.is()) { - xLegendState->setPropertyToDefault( "RelativePosition"); - xLegendState->setPropertyToDefault( "RelativeSize"); - xLegendState->setPropertyToDefault( "AnchorPosition"); + xLegend->setPropertyToDefault( u"RelativePosition"_ustr); + xLegend->setPropertyToDefault( u"RelativeSize"_ustr); + xLegend->setPropertyToDefault( u"AnchorPosition"_ustr); } // titles @@ -214,16 +229,16 @@ void ChartController::executeDispatch_NewArrangement() eType < TitleHelper::NORMAL_TITLE_END; ++eType ) { - Reference< beans::XPropertyState > xTitleState( + rtl::Reference< Title > xTitleState = TitleHelper::getTitle( - static_cast< TitleHelper::eTitleType >( eType ), xModel ), uno::UNO_QUERY ); + static_cast< TitleHelper::eTitleType >( eType ), xModel ); if( xTitleState.is()) - xTitleState->setPropertyToDefault( "RelativePosition"); + xTitleState->setPropertyToDefault( u"RelativePosition"_ustr); } // regression curve equations - std::vector< Reference< chart2::XRegressionCurve > > aRegressionCurves( - RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( xDiagram )); + std::vector< rtl::Reference< RegressionCurveModel > > aRegressionCurves = + xDiagram->getAllRegressionCurvesNotMeanValueLine(); // reset equation position for( const auto& xCurve : aRegressionCurves ) @@ -244,16 +259,241 @@ void ChartController::executeDispatch_ScaleText() UndoGuard aUndoGuard( SchResId( STR_ACTION_SCALE_TEXT ), m_xUndoManager ); - ControllerLockGuardUNO aCtlLockGuard( getModel() ); + ControllerLockGuardUNO aCtlLockGuard( getChartModel() ); - std::unique_ptr<ReferenceSizeProvider> pRefSizeProv(impl_createReferenceSizeProvider()); - OSL_ASSERT(pRefSizeProv); - if (pRefSizeProv) - pRefSizeProv->toggleAutoResizeState(); + impl_createReferenceSizeProvider().toggleAutoResizeState(); aUndoGuard.commit(); } +void ChartController::executeDispatch_FontBold( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + OUString aPropName = u"CharWeight"_ustr; + float nFontWeight = awt::FontWeight::NORMAL; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + xProperties[0]->getPropertyValue(aPropName) >>= nFontWeight; + } + nFontWeight = (nFontWeight == awt::FontWeight::NORMAL) ? awt::FontWeight::BOLD + : awt::FontWeight::NORMAL; + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(aPropName, uno::Any(nFontWeight)); +} + +void ChartController::executeDispatch_FontName( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + // the sent font may have a lot of properties that we could set. + // but now we set only this + awt::FontDescriptor aFont; + rArgs[0].Value >>= aFont; + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(u"CharFontName"_ustr, css::uno::Any(aFont.Name)); +} + +void ChartController::executeDispatch_FontHeight( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(u"CharHeight"_ustr, rArgs[0].Value); +} + +void ChartController::executeDispatch_FontItalic( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + OUString aPropName = u"CharPosture"_ustr; + awt::FontSlant nFontItalic = awt::FontSlant::FontSlant_NONE; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + xProperties[0]->getPropertyValue(aPropName) >>= nFontItalic; + } + nFontItalic = (nFontItalic == awt::FontSlant::FontSlant_NONE ? awt::FontSlant::FontSlant_ITALIC + : awt::FontSlant::FontSlant_NONE); + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontItalic)); +} + +void ChartController::executeDispatch_FontUnderline( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + OUString aPropName = u"CharUnderline"_ustr; + sal_Int16 nFontUnderline = 0; + sal_Int32 nFontUnderline32 = 0; + if (!(rArgs[0].Value >>= nFontUnderline) && (rArgs[0].Value >>= nFontUnderline32)) + { + nFontUnderline = nFontUnderline32; + } + else + { + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + xProperties[0]->getPropertyValue(aPropName) >>= nFontUnderline; + } + nFontUnderline = (nFontUnderline == 0 ? 1 : 0); + } + + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontUnderline)); +} + +void ChartController::executeDispatch_FontStrikeout( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + OUString aPropName = u"CharStrikeout"_ustr; + sal_Int16 nFontStrikeout = 0; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + xProperties[0]->getPropertyValue(aPropName) >>= nFontStrikeout; + } + nFontStrikeout = (nFontStrikeout == 0 ? 1 : 0); + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(aPropName, css::uno::Any(nFontStrikeout)); +} + +void ChartController::executeDispatch_FontShadowed( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + OUString aPropName = u"CharShadowed"_ustr; + bool bFontShadowed = false; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + xProperties[0]->getPropertyValue(aPropName) >>= bFontShadowed; + } + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(u"CharShadowed"_ustr, css::uno::Any(!bFontShadowed)); +} + +void ChartController::executeDispatch_FontColor( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(u"CharColor"_ustr, rArgs[0].Value); +} + +void ChartController::executeDispatch_FontGrow( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + for (std::size_t i = 0; i < xProperties.size(); i++) + { + float nFontHeight = 0; + xProperties[i]->getPropertyValue(u"CharHeight"_ustr) >>= nFontHeight; + if (nFontHeight > 0) + { + nFontHeight = ceil(nFontHeight); //round + nFontHeight += 1; + if (nFontHeight > 999) + nFontHeight = 999; + xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(nFontHeight)); + } + } +} + +void ChartController::executeDispatch_FontShrink( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + for (std::size_t i = 0; i < xProperties.size(); i++) + { + float nFontHeight = 0; + xProperties[i]->getPropertyValue(u"CharHeight"_ustr) >>= nFontHeight; + if (nFontHeight > 0) + { + if (nFontHeight - ceil(nFontHeight) >= 0.4) + nFontHeight = ceil(nFontHeight); //round + else + { + nFontHeight -= 1; + if (nFontHeight < 2) + nFontHeight = 2; + } + xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(nFontHeight)); + } + } +} + +void ChartController::executeDispatch_FontReset( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + for (std::size_t i = 0; i < xProperties.size(); i++) + { + xProperties[i]->setPropertyValue(u"CharFontName"_ustr, + css::uno::Any(OUString("Liberation Sans"))); + xProperties[i]->setPropertyValue(u"CharHeight"_ustr, css::uno::Any(float(13))); + xProperties[i]->setPropertyValue(u"CharWeight"_ustr, uno::Any(float(100))); + xProperties[i]->setPropertyValue(u"CharPosture"_ustr, + css::uno::Any(awt::FontSlant::FontSlant_NONE)); + xProperties[i]->setPropertyValue(u"CharUnderline"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharStrikeout"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharShadowed"_ustr, css::uno::Any(false)); + xProperties[i]->setPropertyValue(u"CharColor"_ustr, css::uno::Any(Color(0))); + + xProperties[i]->setPropertyValue(u"CharKerning"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr, + css::uno::Any(sal_Int8(100))); + } +} + +void ChartController::executeDispatch_FontSpacing( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties, + const css::uno::Sequence<css::beans::PropertyValue>& rArgs) +{ + sal_Int16 nKerning = 0; + rArgs[0].Value >>= nKerning; + for (std::size_t i = 0; i < xProperties.size(); i++) + xProperties[i]->setPropertyValue(u"CharKerning"_ustr, css::uno::Any(nKerning)); +} + +void ChartController::executeDispatch_FontSuperScript( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + sal_Int16 nCharEscapement = 0; + xProperties[0]->getPropertyValue(u"CharEscapement"_ustr) >>= nCharEscapement; + for (std::size_t i = 0; i < xProperties.size(); i++) + { + if (nCharEscapement > 0) + { + xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr, + css::uno::Any(sal_Int8(100))); + } + else + { + xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, + css::uno::Any(sal_Int16(14000))); + xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr, + css::uno::Any(sal_Int8(58))); + } + } +} + +void ChartController::executeDispatch_FontSubScript( + const std::vector<css::uno::Reference<css::beans::XPropertySet>>& xProperties) +{ + sal_Int16 nCharEscapement = 0; + xProperties[0]->getPropertyValue(u"CharEscapement"_ustr) >>= nCharEscapement; + for (std::size_t i = 0; i < xProperties.size(); i++) + { + if (nCharEscapement < 0) + { + xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, css::uno::Any(sal_Int16(0))); + xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr, + css::uno::Any(sal_Int8(100))); + } + else + { + xProperties[i]->setPropertyValue(u"CharEscapement"_ustr, + css::uno::Any(sal_Int16(-14000))); + xProperties[i]->setPropertyValue(u"CharEscapementHeight"_ustr, + css::uno::Any(sal_Int8(58))); + } + } +} + void ChartController::executeDispatch_Paste() { SolarMutexGuard aGuard; @@ -263,7 +503,7 @@ void ChartController::executeDispatch_Paste() Graphic aGraphic; // paste location: center of window - Point aPos = pChartWindow->PixelToLogic( tools::Rectangle( {}, pChartWindow->GetSizePixel()).Center()); + Point aPos = pChartWindow->PixelToLogic( tools::Rectangle(Point{}, pChartWindow->GetSizePixel()).Center()); // handle different formats TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( pChartWindow )); @@ -271,8 +511,7 @@ void ChartController::executeDispatch_Paste() { if ( aDataHelper.HasFormat( SotClipboardFormatId::DRAWING ) ) { - tools::SvRef<SotTempStream> xStm; - if ( aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING, xStm ) ) + if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::DRAWING) ) { xStm->Seek( 0 ); Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm ) ); @@ -289,8 +528,7 @@ void ChartController::executeDispatch_Paste() else if ( aDataHelper.HasFormat( SotClipboardFormatId::SVXB ) ) { // graphic exchange format (graphic manager bitmap format?) - tools::SvRef<SotTempStream> xStm; - if( aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB, xStm )) + if (std::unique_ptr<SvStream> xStm = aDataHelper.GetSotStorageStream( SotClipboardFormatId::SVXB )) { TypeSerializer aSerializer(*xStm); aSerializer.readGraphic(aGraphic); @@ -318,8 +556,8 @@ void ChartController::executeDispatch_Paste() if( m_pDrawViewWrapper ) { OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); - if( pOutlinerView )//in case of edit mode insert into edited string - pOutlinerView->InsertText( aString ); + if (pOutlinerView)//in case of edit mode insert the formatted string + pOutlinerView->PasteSpecial(); else { impl_PasteStringAsTextShape( aString, awt::Point( 0, 0 ) ); @@ -346,43 +584,50 @@ void ChartController::impl_PasteGraphic( DBG_TESTSOLARMUTEX(); // note: the XPropertySet of the model is the old API. Also the property // "AdditionalShapes" that is used there. - uno::Reference< beans::XPropertySet > xModelProp( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xModel = getChartModel(); DrawModelWrapper * pDrawModelWrapper( GetDrawModelWrapper()); - if( ! (xGraphic.is() && xModelProp.is())) - return; - uno::Reference< lang::XMultiServiceFactory > xFact( pDrawModelWrapper->getShapeFactory()); - uno::Reference< drawing::XShape > xGraphicShape( - xFact->createInstance( "com.sun.star.drawing.GraphicObjectShape" ), uno::UNO_QUERY ); - uno::Reference< beans::XPropertySet > xGraphicShapeProp( xGraphicShape, uno::UNO_QUERY ); - if( !(xGraphicShapeProp.is() && xGraphicShape.is())) + if( ! (xGraphic.is() && xModel.is())) return; + rtl::Reference<SvxGraphicObject> xGraphicShape = new SvxGraphicObject(nullptr); + xGraphicShape->setShapeKind(SdrObjKind::Graphic); - uno::Reference< drawing::XShapes > xPage = pDrawModelWrapper->getMainDrawPage(); + rtl::Reference< SvxDrawPage > xPage = pDrawModelWrapper->getMainDrawPage(); if( xPage.is()) { xPage->add( xGraphicShape ); //need to change the model state manually - { - uno::Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); - if( xModifiable.is() ) - xModifiable->setModified( true ); - } + xModel->setModified( true ); //select new shape m_aSelection.setSelection( xGraphicShape ); m_aSelection.applySelection( m_pDrawViewWrapper.get() ); } - xGraphicShapeProp->setPropertyValue( "Graphic", uno::Any( xGraphic )); - uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY ); + xGraphicShape->SvxShape::setPropertyValue( u"Graphic"_ustr, uno::Any( xGraphic )); awt::Size aGraphicSize( 1000, 1000 ); + bool bGotGraphicSize = false; + try + { + bGotGraphicSize = xGraphicShape->SvxShape::getPropertyValue( u"Size100thMM"_ustr) >>= aGraphicSize; + } + catch (css::beans::UnknownPropertyException& ) + {} auto pChartWindow(GetChartWindow()); // first try size in 100th mm, then pixel size - if( ! ( xGraphicProp->getPropertyValue( "Size100thMM") >>= aGraphicSize ) && - ( ( xGraphicProp->getPropertyValue( "SizePixel") >>= aGraphicSize ) && pChartWindow )) + if( !bGotGraphicSize ) { - ::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); - aGraphicSize.Width = aVCLSize.getWidth(); - aGraphicSize.Height = aVCLSize.getHeight(); + bool bGotSizePixel = false; + try + { + bGotSizePixel = xGraphicShape->SvxShape::getPropertyValue( u"SizePixel"_ustr) >>= aGraphicSize; + } + catch (css::beans::UnknownPropertyException& ) + {} + if ( bGotSizePixel && pChartWindow ) + { + ::Size aVCLSize( pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); + aGraphicSize.Width = aVCLSize.getWidth(); + aGraphicSize.Height = aVCLSize.getHeight(); + } } xGraphicShape->setSize( aGraphicSize ); xGraphicShape->setPosition( awt::Point( 0, 0 ) ); @@ -394,7 +639,7 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) if ( !(pDrawModelWrapper && m_pDrawViewWrapper) ) return; - Reference< drawing::XDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() ); + rtl::Reference< SvxDrawPage > xDestPage( pDrawModelWrapper->getMainDrawPage() ); SdrPage* pDestPage = GetSdrPageFromXDrawPage( xDestPage ); if ( !pDestPage ) return; @@ -410,7 +655,9 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) { SdrObject* pObj(aIter.Next()); // Clone to new SdrModel - SdrObject* pNewObj(pObj ? pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()) : nullptr); + rtl::Reference<SdrObject> pNewObj; + if (pObj) + pNewObj = pObj->CloneSdrObject(pDrawModelWrapper->getSdrModel()); if ( pNewObj ) { @@ -421,14 +668,14 @@ void ChartController::impl_PasteShapes( SdrModel* pModel ) xShape->setPosition( awt::Point( 0, 0 ) ); } - pDestPage->InsertObject( pNewObj ); + pDestPage->InsertObject( pNewObj.get() ); m_pDrawViewWrapper->AddUndo( std::make_unique<SdrUndoInsertObj>( *pNewObj ) ); - xSelShape = xShape; + xSelShape = std::move(xShape); } } } - Reference< util::XModifiable > xModifiable( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xModifiable = getChartModel(); if ( xModifiable.is() ) { xModifiable->setModified( true ); @@ -449,32 +696,29 @@ void ChartController::impl_PasteStringAsTextShape( const OUString& rString, cons if ( !(pDrawModelWrapper && m_pDrawViewWrapper) ) return; - const Reference< lang::XMultiServiceFactory >& xShapeFactory( pDrawModelWrapper->getShapeFactory() ); - const Reference< drawing::XDrawPage >& xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - OSL_ASSERT( xShapeFactory.is() && xDrawPage.is() ); + const rtl::Reference< SvxDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); + OSL_ASSERT( xDrawPage.is() ); - if ( !(xShapeFactory.is() && xDrawPage.is()) ) + if ( !xDrawPage ) return; try { - Reference< drawing::XShape > xTextShape( - xShapeFactory->createInstance( "com.sun.star.drawing.TextShape" ), uno::UNO_QUERY_THROW ); + rtl::Reference<SvxShapeText> xTextShape = new SvxShapeText(nullptr); + xTextShape->setShapeKind(SdrObjKind::Text); xDrawPage->add( xTextShape ); - Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW ); - xRange->setString( rString ); + xTextShape->setString( rString ); float fCharHeight = 10.0; - Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW ); - xProperties->setPropertyValue( "TextAutoGrowHeight", uno::Any( true ) ); - xProperties->setPropertyValue( "TextAutoGrowWidth", uno::Any( true ) ); - xProperties->setPropertyValue( "CharHeight", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightAsian", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "CharHeightComplex", uno::Any( fCharHeight ) ); - xProperties->setPropertyValue( "TextVerticalAdjust", uno::Any( drawing::TextVerticalAdjust_CENTER ) ); - xProperties->setPropertyValue( "TextHorizontalAdjust", uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); - xProperties->setPropertyValue( "CharFontName", uno::Any( OUString("Albany") ) ); + xTextShape->SvxShape::setPropertyValue( u"TextAutoGrowHeight"_ustr, uno::Any( true ) ); + xTextShape->SvxShape::setPropertyValue( u"TextAutoGrowWidth"_ustr, uno::Any( true ) ); + xTextShape->SvxShape::setPropertyValue( u"CharHeight"_ustr, uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( u"CharHeightAsian"_ustr, uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( u"CharHeightComplex"_ustr, uno::Any( fCharHeight ) ); + xTextShape->SvxShape::setPropertyValue( u"TextVerticalAdjust"_ustr, uno::Any( drawing::TextVerticalAdjust_CENTER ) ); + xTextShape->SvxShape::setPropertyValue( u"TextHorizontalAdjust"_ustr, uno::Any( drawing::TextHorizontalAdjust_CENTER ) ); + xTextShape->SvxShape::setPropertyValue( u"CharFontName"_ustr, uno::Any( u"Albany"_ustr ) ); xTextShape->setPosition( rPosition ); @@ -577,8 +821,15 @@ bool ChartController::isObjectDeleteable( const uno::Any& rSelection ) bool ChartController::isShapeContext() const { return m_aSelection.isAdditionalShapeSelected() || - ( m_pDrawViewWrapper && m_pDrawViewWrapper->AreObjectsMarked() && - ( m_pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) ); + ( m_pDrawViewWrapper && m_pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0 && + ( m_pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::Text ) ); +} + +bool ChartController::IsTextEdit() const +{ + // only Title objects and additional shapes are editable textshapes in chart + return m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() && + (m_aSelection.isTitleObjectSelected() || m_aSelection.isAdditionalShapeSelected()); } void ChartController::impl_ClearSelection() @@ -602,7 +853,7 @@ bool ChartController::executeDispatch_Delete() return false; //remove chart object - uno::Reference< chart2::XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xChartDoc = getChartModel(); if( !xChartDoc.is() ) return false; @@ -616,24 +867,24 @@ bool ChartController::executeDispatch_Delete() ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_TITLE )), m_xUndoManager ); TitleHelper::removeTitle( - ObjectIdentifier::getTitleTypeForCID( aCID ), getModel() ); + ObjectIdentifier::getTitleTypeForCID( aCID ), getChartModel() ); bReturn = true; aUndoGuard.commit(); break; } case OBJECTTYPE_LEGEND: { - uno::Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram()); + rtl::Reference< Diagram > xDiagram( xChartDoc->getFirstChartDiagram()); if( xDiagram.is()) { - uno::Reference< beans::XPropertySet > xLegendProp( xDiagram->getLegend(), uno::UNO_QUERY ); - if( xLegendProp.is()) + rtl::Reference< Legend > xLegend( xDiagram->getLegend2() ); + if( xLegend.is()) { UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_LEGEND )), m_xUndoManager ); - xLegendProp->setPropertyValue( "Show", uno::Any( false )); + xLegend->setPropertyValue( u"Show"_ustr, uno::Any( false )); bReturn = true; aUndoGuard.commit(); } @@ -642,7 +893,7 @@ bool ChartController::executeDispatch_Delete() } case OBJECTTYPE_DATA_SERIES: - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getChartModel(), m_xUndoManager ); break; case OBJECTTYPE_LEGEND_ENTRY: @@ -651,14 +902,14 @@ bool ChartController::executeDispatch_Delete() ObjectIdentifier::getFullParentParticle( aCID )); if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) { - bReturn = lcl_deleteDataSeries( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataSeries( aCID, getChartModel(), m_xUndoManager ); } else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) { sal_Int32 nEndPos = aCID.lastIndexOf(':'); OUString aParentCID = aCID.copy(0, nEndPos); - bReturn = lcl_deleteDataCurve(aParentCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve(aParentCID, getChartModel(), m_xUndoManager ); } else if( eParentObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) { @@ -672,7 +923,7 @@ bool ChartController::executeDispatch_Delete() { uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( ObjectIdentifier::getObjectPropertySet( - ObjectIdentifier::getFullParentParticle( aCID ), getModel()), uno::UNO_QUERY ); + ObjectIdentifier::getFullParentParticle( aCID ), getChartModel()), uno::UNO_QUERY ); if( xRegCurveCnt.is()) { UndoGuard aUndoGuard( @@ -688,28 +939,28 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_CURVE: { - bReturn = lcl_deleteDataCurve( aCID, getModel(), m_xUndoManager ); + bReturn = lcl_deleteDataCurve( aCID, getChartModel(), m_xUndoManager ); } break; case OBJECTTYPE_DATA_CURVE_EQUATION: { uno::Reference< beans::XPropertySet > xEqProp( - ObjectIdentifier::getObjectPropertySet( aCID, getModel())); + ObjectIdentifier::getObjectPropertySet( aCID, getChartModel())); if( xEqProp.is()) { - uno::Reference< frame::XModel > xModel( getModel() ); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId( STR_OBJECT_CURVE_EQUATION )), m_xUndoManager ); { ControllerLockGuardUNO aCtlLockGuard( xModel ); - xEqProp->setPropertyValue( "ShowEquation", uno::Any( false )); - xEqProp->setPropertyValue( "XName", uno::Any( OUString("x") )); - xEqProp->setPropertyValue( "YName", uno::Any( OUString("f(x)") )); - xEqProp->setPropertyValue( "ShowCorrelationCoefficient", uno::Any( false )); + xEqProp->setPropertyValue( u"ShowEquation"_ustr, uno::Any( false )); + xEqProp->setPropertyValue( u"XName"_ustr, uno::Any( u"x"_ustr )); + xEqProp->setPropertyValue( u"YName"_ustr, uno::Any( u"f(x)"_ustr )); + xEqProp->setPropertyValue( u"ShowCorrelationCoefficient"_ustr, uno::Any( false )); } bReturn = true; aUndoGuard.commit(); @@ -722,10 +973,10 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_ERRORS_Z: { uno::Reference< beans::XPropertySet > xErrorBarProp( - ObjectIdentifier::getObjectPropertySet( aCID, getModel() )); + ObjectIdentifier::getObjectPropertySet( aCID, getChartModel() )); if( xErrorBarProp.is()) { - const char* pId; + TranslateId pId; if ( aObjectType == OBJECTTYPE_DATA_ERRORS_X ) pId = STR_OBJECT_ERROR_BARS_X; @@ -734,7 +985,7 @@ bool ChartController::executeDispatch_Delete() else pId = STR_OBJECT_ERROR_BARS_Z; - uno::Reference< frame::XModel > xModel( getModel() ); + rtl::Reference<::chart::ChartModel> xModel( getChartModel() ); UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::ActionType::Delete, SchResId(pId)), @@ -742,7 +993,7 @@ bool ChartController::executeDispatch_Delete() { ControllerLockGuardUNO aCtlLockGuard( xModel ); xErrorBarProp->setPropertyValue( - "ErrorBarStyle", + u"ErrorBarStyle"_ustr, uno::Any( css::chart::ErrorBarStyle::NONE )); } bReturn = true; @@ -755,7 +1006,7 @@ bool ChartController::executeDispatch_Delete() case OBJECTTYPE_DATA_LABEL: { uno::Reference< beans::XPropertySet > xObjectProperties = - ObjectIdentifier::getObjectPropertySet( aCID, getModel() ); + ObjectIdentifier::getObjectPropertySet( aCID, getChartModel() ); if( xObjectProperties.is() ) { UndoGuard aUndoGuard( @@ -773,9 +1024,9 @@ bool ChartController::executeDispatch_Delete() aLabel.ShowSeriesName = false; if( aObjectType == OBJECTTYPE_DATA_LABELS ) { - uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, getModel() )); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_LABEL, uno::Any(aLabel) ); - DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aCID, getChartModel() ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_LABEL, uno::Any(aLabel) ); + xSeries->setPropertyAlsoToAllAttributedDataPoints( CHART_UNONAME_CUSTOM_LABEL_FIELDS, uno::Any() ); } else { @@ -830,20 +1081,19 @@ bool ChartController::executeDispatch_Delete() void ChartController::executeDispatch_ToggleLegend() { - Reference< frame::XModel > xModel( getModel() ); + rtl::Reference< ChartModel > xModel = getChartModel(); UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_LEGEND ), m_xUndoManager ); - ChartModel& rModel = dynamic_cast<ChartModel&>(*xModel); - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(rModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*xModel); bool bChanged = false; if( xLegendProp.is()) { try { bool bShow = false; - if( xLegendProp->getPropertyValue( "Show") >>= bShow ) + if( xLegendProp->getPropertyValue( u"Show"_ustr) >>= bShow ) { - xLegendProp->setPropertyValue( "Show", uno::Any( ! bShow )); + xLegendProp->setPropertyValue( u"Show"_ustr, uno::Any( ! bShow )); bChanged = true; } } @@ -854,7 +1104,7 @@ void ChartController::executeDispatch_ToggleLegend() } else { - xLegendProp.set( LegendHelper::getLegend(rModel, m_xCC, true), uno::UNO_QUERY ); + xLegendProp = LegendHelper::getLegend(*xModel, m_xCC, true); if( xLegendProp.is()) bChanged = true; } @@ -867,7 +1117,7 @@ void ChartController::executeDispatch_ToggleGridHorizontal() { UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ), m_xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); + rtl::Reference< Diagram > xDiagram( getFirstDiagram() ); if( !xDiagram.is()) return; @@ -900,7 +1150,7 @@ void ChartController::executeDispatch_ToggleGridVertical() { UndoGuard aUndoGuard( SchResId( STR_ACTION_TOGGLE_GRID_VERTICAL ), m_xUndoManager ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( getModel() )); + rtl::Reference< Diagram > xDiagram( getFirstDiagram() ); if( !xDiagram.is()) return; @@ -934,13 +1184,19 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); if( xPointProperties.is() ) - xPointProperties->setPropertyValue( "FillColor", uno::Any( nColor ) ); + xPointProperties->setPropertyValue( u"FillColor"_ustr, uno::Any( nColor ) ); + + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + if (eType == OBJECTTYPE_DATA_SERIES || eType == OBJECTTYPE_DATA_POINT) + { + xChartModel->clearColorPalette(); + } } } catch( const uno::Exception& ) @@ -949,15 +1205,15 @@ void ChartController::executeDispatch_FillColor(sal_uInt32 nColor) } } -void ChartController::executeDispatch_FillGradient(OUString sJSONGradient) +void ChartController::executeDispatch_FillGradient(std::u16string_view sJSONGradient) { - XGradient aXGradient = XGradient::fromJSON(sJSONGradient); - css::awt::Gradient aGradient = aXGradient.toGradientUNO(); + basegfx::BGradient aBGradient = basegfx::BGradient::fromJSON(sJSONGradient); + css::awt::Gradient aGradient = model::gradient::createUnoGradient2(aBGradient); try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { @@ -966,15 +1222,16 @@ void ChartController::executeDispatch_FillGradient(OUString sJSONGradient) if( xPropSet.is() ) { - OUString aPrefferedName = OUString::number(static_cast<sal_Int32>(aXGradient.GetStartColor())) - + OUString::number(static_cast<sal_Int32>(aXGradient.GetEndColor())) - + OUString::number(static_cast<sal_Int32>(aXGradient.GetAngle().get())); + OUString aPrefferedName = + OUString::number(static_cast<sal_Int32>(Color(aBGradient.GetColorStops().front().getStopColor()))) + + OUString::number(static_cast<sal_Int32>(Color(aBGradient.GetColorStops().back().getStopColor()))) + + OUString::number(static_cast<sal_Int32>(aBGradient.GetAngle().get())); OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(css::uno::Any(aGradient), - css::uno::Reference<css::lang::XMultiServiceFactory>(xChartModel, css::uno::UNO_QUERY_THROW), + xChartModel, aPrefferedName); - xPropSet->setPropertyValue("FillGradientName", css::uno::Any(aNewName)); + xPropSet->setPropertyValue(u"FillGradientName"_ustr, css::uno::Any(aNewName)); } } } @@ -989,7 +1246,7 @@ void ChartController::executeDispatch_LineColor(sal_uInt32 nColor) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPropSet( @@ -1005,7 +1262,7 @@ void ChartController::executeDispatch_LineColor(sal_uInt32 nColor) } if( xPropSet.is() ) - xPropSet->setPropertyValue( "LineColor", css::uno::makeAny( Color(ColorTransparency, nColor) ) ); + xPropSet->setPropertyValue( u"LineColor"_ustr, css::uno::Any( Color(ColorTransparency, nColor) ) ); } } catch( const uno::Exception& ) @@ -1019,7 +1276,7 @@ void ChartController::executeDispatch_LineWidth(sal_uInt32 nWidth) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPropSet( @@ -1035,7 +1292,7 @@ void ChartController::executeDispatch_LineWidth(sal_uInt32 nWidth) } if( xPropSet.is() ) - xPropSet->setPropertyValue( "LineWidth", css::uno::makeAny( nWidth ) ); + xPropSet->setPropertyValue( u"LineWidth"_ustr, css::uno::Any( nWidth ) ); } } catch( const uno::Exception& ) @@ -1080,13 +1337,13 @@ void ChartController::executeDispatch_LOKPieSegmentDragging( int nOffset ) try { OUString aCID( m_aSelection.getSelectedCID() ); - const uno::Reference< frame::XModel >& xChartModel = getModel(); + rtl::Reference<::chart::ChartModel> xChartModel = getChartModel(); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( ObjectIdentifier::getObjectPropertySet( aCID, xChartModel ) ); if( xPointProperties.is() ) - xPointProperties->setPropertyValue( "Offset", uno::Any( nOffset / 100.0 ) ); + xPointProperties->setPropertyValue( u"Offset"_ustr, uno::Any( nOffset / 100.0 ) ); } } catch( const uno::Exception & ) @@ -1110,8 +1367,7 @@ void ChartController::impl_switchDiagramPositioningToExcludingPositioning() ActionDescriptionProvider::ActionType::PosSize, ObjectNameProvider::getName( OBJECTTYPE_DIAGRAM)), m_xUndoManager ); - ChartModel& rModel = dynamic_cast<ChartModel&>(*m_aModel->getModel()); - if (DiagramHelper::switchDiagramPositioningToExcludingPositioning(rModel, true, true)) + if (DiagramHelper::switchDiagramPositioningToExcludingPositioning(*getChartModel(), true, true)) aUndoGuard.commit(); } diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx index a63da0791c30..cd57689af263 100644 --- a/chart2/source/controller/main/ChartController_Window.cxx +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -22,13 +22,15 @@ #include <string_view> #include <ChartController.hxx> +#include <ChartView.hxx> #include <PositionAndSizeHelper.hxx> #include <ObjectIdentifier.hxx> #include <ChartWindow.hxx> #include <ResId.hxx> #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> +#include <ChartType.hxx> #include <DiagramHelper.hxx> +#include <Diagram.hxx> #include <TitleHelper.hxx> #include "UndoGuard.hxx" #include <ControllerLockGuard.hxx> @@ -37,12 +39,15 @@ #include "DragMethod_PieSegment.hxx" #include "DragMethod_RotateDiagram.hxx" #include <ObjectHierarchy.hxx> -#include <chartview/ExplicitValueProvider.hxx> #include <RelativePositionHelper.hxx> #include <chartview/DrawModelWrapper.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <StatisticsHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> +#include <DataSeriesProperties.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <LegendHelper.hxx> #include <servicenames_charttypes.hxx> @@ -52,24 +57,17 @@ #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/data/XPivotTableDataProvider.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/awt/PopupMenuDirection.hpp> #include <com/sun/star/frame/DispatchHelper.hpp> #include <com/sun/star/frame/FrameSearchFlag.hpp> #include <com/sun/star/frame/XPopupMenuController.hpp> -#include <com/sun/star/util/XUpdatable.hpp> #include <com/sun/star/awt/Rectangle.hpp> -#include <com/sun/star/qa/XDumper.hpp> #include <comphelper/lok.hxx> #include <comphelper/propertysequence.hxx> #include <comphelper/propertyvalue.hxx> -#include <comphelper/sequence.hxx> - -#include <toolkit/awt/vclxmenu.hxx> #include <sfx2/viewsh.hxx> #include <svx/ActionDescriptionProvider.hxx> @@ -83,8 +81,10 @@ #include <vcl/weld.hxx> #include <vcl/ptrstyle.hxx> #include <svtools/acceleratorexecute.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> +#include <toolkit/awt/vclxmenu.hxx> #include <sal/log.hxx> +#include <o3tl/string_view.hxx> #include <boost/property_tree/json_parser.hpp> #include <sfx2/dispatch.hxx> @@ -94,6 +94,7 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; +using namespace ::chart::DataSeriesProperties; using ::com::sun::star::uno::Reference; namespace chart @@ -143,13 +144,13 @@ void lcl_insertMenuCommand( const uno::Reference< awt::XPopupMenu > & xMenu, sal_Int16 nId, const OUString & rCommand ) { - xMenu->insertItem( nId, "", 0, -1 ); + xMenu->insertItem( nId, u""_ustr, 0, -1 ); xMenu->setCommand( nId, rCommand ); } -OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) +OUString lcl_getFormatCommandForObjectCID( std::u16string_view rCID ) { - OUString aDispatchCommand( ".uno:FormatSelection" ); + OUString aDispatchCommand( u".uno:FormatSelection"_ustr ); ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); @@ -172,6 +173,7 @@ OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) aDispatchCommand = ".uno:FormatTitle"; break; case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_DATA_SERIES: aDispatchCommand = ".uno:FormatDataSeries"; break; case OBJECTTYPE_AXIS: @@ -187,9 +189,6 @@ OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) case OBJECTTYPE_DATA_LABELS: aDispatchCommand = ".uno:FormatDataLabels"; break; - case OBJECTTYPE_DATA_SERIES: - aDispatchCommand = ".uno:FormatDataSeries"; - break; case OBJECTTYPE_DATA_LABEL: aDispatchCommand = ".uno:FormatDataLabel"; break; @@ -240,17 +239,16 @@ void SAL_CALL ChartController::setPosSize( sal_Int16 Flags ) { SolarMutexGuard aGuard; - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; auto pChartWindow(GetChartWindow()); - if(!(xWindow.is() && pChartWindow)) + if(!(m_xViewWindow.is() && pChartWindow)) return; Size aLogicSize = pChartWindow->PixelToLogic( Size( Width, Height ), MapMode( MapUnit::Map100thMM ) ); //todo: for standalone chart: detect whether we are standalone //change map mode to fit new size - awt::Size aModelPageSize = ChartModelHelper::getPageSize( getModel() ); + awt::Size aModelPageSize = getChartModel()->getPageSize(); sal_Int32 nScaleXNumerator = aLogicSize.Width(); sal_Int32 nScaleXDenominator = aModelPageSize.Width; sal_Int32 nScaleYNumerator = aLogicSize.Height(); @@ -264,8 +262,7 @@ void SAL_CALL ChartController::setPosSize( pChartWindow->setPosSizePixel( X, Y, Width, Height, static_cast<PosSizeFlags>(Flags) ); //#i75867# poor quality of ole's alternative view with 3D scenes and zoomfactors besides 100% - uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY ); - if( xProp.is() ) + if( m_xChartView.is() ) { auto aZoomFactors(::comphelper::InitPropertySequence({ { "ScaleXNumerator", uno::Any( nScaleXNumerator ) }, @@ -273,7 +270,7 @@ void SAL_CALL ChartController::setPosSize( { "ScaleYNumerator", uno::Any( nScaleYNumerator ) }, { "ScaleYDenominator", uno::Any( nScaleYDenominator ) } })); - xProp->setPropertyValue( "ZoomFactors", uno::Any( aZoomFactors )); + m_xChartView->setPropertyValue( u"ZoomFactors"_ustr, uno::Any( aZoomFactors )); } //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area @@ -287,161 +284,114 @@ void SAL_CALL ChartController::setPosSize( awt::Rectangle SAL_CALL ChartController::getPosSize() { - //@todo awt::Rectangle aRet(0, 0, 0, 0); - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - if(xWindow.is()) - aRet = xWindow->getPosSize(); + if (m_xViewWindow.is()) + aRet = m_xViewWindow->getPosSize(); return aRet; } void SAL_CALL ChartController::setVisible( sal_Bool Visible ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setVisible( Visible ); + if (m_xViewWindow.is()) + m_xViewWindow->setVisible(Visible); } void SAL_CALL ChartController::setEnable( sal_Bool Enable ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setEnable( Enable ); + if (m_xViewWindow.is()) + m_xViewWindow->setEnable(Enable); } void SAL_CALL ChartController::setFocus() { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->setFocus(); + if (m_xViewWindow.is()) + m_xViewWindow->setFocus(); } void SAL_CALL ChartController::addWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addWindowListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addWindowListener(xListener); } void SAL_CALL ChartController::removeWindowListener( const uno::Reference< awt::XWindowListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeWindowListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeWindowListener(xListener); } void SAL_CALL ChartController::addFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addFocusListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addFocusListener(xListener); } void SAL_CALL ChartController::removeFocusListener( const uno::Reference< awt::XFocusListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeFocusListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeFocusListener(xListener); } void SAL_CALL ChartController::addKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addKeyListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addKeyListener(xListener); } void SAL_CALL ChartController::removeKeyListener( const uno::Reference< awt::XKeyListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeKeyListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeKeyListener(xListener); } void SAL_CALL ChartController::addMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addMouseListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addMouseListener(xListener); } void SAL_CALL ChartController::removeMouseListener( const uno::Reference< awt::XMouseListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeMouseListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeMouseListener(xListener); } void SAL_CALL ChartController::addMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addMouseMotionListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addMouseMotionListener(xListener); } void SAL_CALL ChartController::removeMouseMotionListener( const uno::Reference< awt::XMouseMotionListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removeMouseMotionListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removeMouseMotionListener(xListener); } void SAL_CALL ChartController::addPaintListener( const uno::Reference< awt::XPaintListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->addPaintListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->addPaintListener(xListener); } void SAL_CALL ChartController::removePaintListener( const uno::Reference< awt::XPaintListener >& xListener ) { - //@todo - uno::Reference<awt::XWindow> xWindow = m_xViewWindow; - - if(xWindow.is()) - xWindow->removePaintListener( xListener ); + if (m_xViewWindow.is()) + m_xViewWindow->removePaintListener(xListener); } // impl vcl window controller methods @@ -460,14 +410,13 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to { try { - uno::Reference<frame::XModel> xModel(getModel()); + rtl::Reference<ChartModel> xModel(getChartModel()); //OSL_ENSURE( xModel.is(), "ChartController::execute_Paint: have no model to paint"); if (!xModel.is()) return; //better performance for big data - uno::Reference<beans::XPropertySet> xProp(m_xChartView, uno::UNO_QUERY); - if (xProp.is()) + if (m_xChartView.is()) { awt::Size aResolution(1000, 1000); { @@ -479,12 +428,11 @@ void ChartController::execute_Paint(vcl::RenderContext& rRenderContext, const to aResolution.Height = pChartWindow->GetSizePixel().Height(); } } - xProp->setPropertyValue( "Resolution", uno::Any( aResolution )); + m_xChartView->setPropertyValue( u"Resolution"_ustr, uno::Any( aResolution )); } - uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY ); - if (xUpdatable.is()) - xUpdatable->update(); + if (m_xChartView.is()) + m_xChartView->update(); { SolarMutexGuard aGuard; @@ -637,7 +585,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) } if ( !pDrawViewWrapper->IsAction() ) { - if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CAPTION ) + if ( pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::Caption ) { Size aCaptionSize( 2268, 1134 ); pDrawViewWrapper->BegCreateCaptionObj( aMPos, aCaptionSize ); @@ -666,7 +614,7 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) rMEvt.IsRight(), m_bWaitingForDoubleClick ); - if( !m_aSelection.isRotateableObjectSelected( getModel() ) ) + if( !m_aSelection.isRotateableObjectSelected( getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; pDrawViewWrapper->SetDragMode(m_eDragMode); @@ -699,14 +647,14 @@ void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) else if( eKind==SdrHdlKind::UpperLeft || eKind==SdrHdlKind::UpperRight || eKind==SdrHdlKind::LowerLeft || eKind==SdrHdlKind::LowerRight ) eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z; } - pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel(), eRotationDirection ); + pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel(), eRotationDirection ); } } else { - OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); + std::u16string_view aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); if( aDragMethodServiceName == ObjectIdentifier::getPieSegmentDragMethodServiceName() ) - pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getModel() ); + pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), getChartModel() ); } pDrawViewWrapper->SdrView::BegDragObj(aMPos, nullptr, pHitSelectionHdl, nDrgLog, pDragMethod); } @@ -739,10 +687,11 @@ void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { - ControllerLockGuardUNO aCLGuard( getModel() ); + ControllerLockGuardUNO aCLGuard( getChartModel() ); bool bMouseUpWithoutMouseDown = !m_bWaitingForMouseUp; m_bWaitingForMouseUp = false; bool bNotifySelectionChange = false; + bool bEditText = false; { SolarMutexGuard aGuard; @@ -784,9 +733,9 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) // don't want the positioning Undo action to appear in the UI impl_switchDiagramPositioningToExcludingPositioning(); } - if ( pDrawViewWrapper->AreObjectsMarked() ) + if ( pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0 ) { - if ( pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_TEXT ) + if ( pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::Text ) { executeDispatch_EditText(); } @@ -839,10 +788,10 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) { tools::Rectangle aObjectRect = pObj->GetSnapRect(); tools::Rectangle aOldObjectRect = pObj->GetLastBoundRect(); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); tools::Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); - const E3dObject* pE3dObject(dynamic_cast< const E3dObject*>(pObj)); + const E3dObject* pE3dObject(DynCastE3dObject(pObj)); if(nullptr != pE3dObject) { E3dScene* pScene(pE3dObject->getRootE3dSceneFromE3dObject()); @@ -863,17 +812,15 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) m_xUndoManager ); bool bChanged = false; - css::uno::Reference< css::frame::XModel > xModel = getModel(); - ChartModel* pModel = dynamic_cast<ChartModel*>(xModel.get()); - assert(pModel); + rtl::Reference< ChartModel > xModel = getChartModel(); if ( eObjectType == OBJECTTYPE_LEGEND ) - bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *pModel, false , true ); + bChanged = DiagramHelper::switchDiagramPositioningToExcludingPositioning( *xModel, false , true ); bool bMoved = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() - , getModel() - , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) - , awt::Rectangle(aOldObjectRect.getX(), aOldObjectRect.getY(), 0, 0) - , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) ); + , xModel + , awt::Rectangle(aObjectRect.Left(),aObjectRect.Top(),aObjectRect.getOpenWidth(),aObjectRect.getOpenHeight()) + , awt::Rectangle(aOldObjectRect.Left(), aOldObjectRect.Top(), 0, 0) + , awt::Rectangle(aPageRect.Left(),aPageRect.Top(),aPageRect.getOpenWidth(),aPageRect.getOpenHeight()) ); if( bMoved || bChanged ) { @@ -893,7 +840,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( !bDraggingDone ) //mouse wasn't moved while dragging { bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper ); - bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getModel() ); + bool bIsRotateable = m_aSelection.isRotateableObjectSelected( getChartModel() ); //toggle between move and rotate if( bIsRotateable && bClickedTwiceOnDragableObject && m_eDragMode==SdrDragMode::Move ) @@ -921,7 +868,7 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) if( isDoubleClick(rMEvt) && !bMouseUpWithoutMouseDown /*#i106966#*/ ) { Point aMousePixel = rMEvt.GetPosPixel(); - execute_DoubleClick( &aMousePixel ); + execute_DoubleClick( &aMousePixel, bEditText ); } if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) @@ -930,18 +877,17 @@ void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) impl_SetMousePointer( rMEvt ); - if(bNotifySelectionChange) + if(bNotifySelectionChange || bEditText) impl_notifySelectionChangeListeners(); } -void ChartController::execute_DoubleClick( const Point* pMousePixel ) +void ChartController::execute_DoubleClick( const Point* pMousePixel, bool &bEditText ) { const SfxViewShell* pViewShell = SfxViewShell::Current(); - bool isMobilePhone = pViewShell && pViewShell->isLOKMobilePhone(); - if (isMobilePhone) + bool notAllowed = pViewShell && (pViewShell->isLOKMobilePhone() || pViewShell->IsLokReadOnlyView()); + if (notAllowed) return; - bool bEditText = false; if ( m_aSelection.hasSelection() ) { OUString aCID( m_aSelection.getSelectedCID() ); @@ -957,7 +903,7 @@ void ChartController::execute_DoubleClick( const Point* pMousePixel ) { // #i12587# support for shapes in chart SdrObject* pObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() ); - if ( dynamic_cast< const SdrTextObj* >(pObj) != nullptr ) + if ( DynCastSdrTextObj(pObj) != nullptr ) { bEditText = true; } @@ -986,33 +932,25 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) { SolarMutexGuard aGuard; auto pChartWindow(GetChartWindow()); - bool bIsAction = false; - { - DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper.get(); - if(!pChartWindow || !pDrawViewWrapper) - return; - bIsAction = m_pDrawViewWrapper->IsAction(); - } + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper.get(); + if(!pChartWindow || !pDrawViewWrapper) + return; + bool bIsAction = m_pDrawViewWrapper->IsAction(); // pop-up menu if(rCEvt.GetCommand() == CommandEventId::ContextMenu && !bIsAction) { - { - if(pChartWindow) - pChartWindow->ReleaseMouse(); - } + pChartWindow->ReleaseMouse(); if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) impl_notifySelectionChangeListeners(); - css::uno::Reference< css::awt::XPopupMenu > xPopupMenu( m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), css::uno::UNO_QUERY ); + rtl::Reference< VCLXPopupMenu > xPopupMenu = new VCLXPopupMenu(); Point aPos( rCEvt.GetMousePosPixel() ); if( !rCEvt.IsMouseEvent() ) { - if(pChartWindow) - aPos = pChartWindow->GetPointerState().maPos; + aPos = pChartWindow->GetPointerState().maPos; } OUString aMenuName; @@ -1021,264 +959,260 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) aMenuName = m_pDrawViewWrapper->IsTextEdit() ? std::u16string_view( u"drawtext" ) : std::u16string_view( u"draw" ); else { + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + // todo: the context menu should be specified by an xml file in uiconfig - if( xPopupMenu.is()) + sal_Int16 nUniqueId = 1; + if (eObjectType != OBJECTTYPE_DATA_TABLE) { - sal_Int16 nUniqueId = 1; - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Cut" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Copy" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:Paste" ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Cut"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Copy"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:Paste"_ustr ); xPopupMenu->insertSeparator( -1 ); + } - ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); - Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( getModel() ); + rtl::Reference< Diagram > xDiagram = getFirstDiagram(); - OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); + OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, aFormatCommand ); + if (eObjectType == OBJECTTYPE_TITLE && m_pDrawViewWrapper->IsTextEdit()) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FontDialog"_ustr ); - //some commands for dataseries and points: + //some commands for dataseries and points: - if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + if( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_POINT ) + { + bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getChartModel() ); + rtl::Reference< RegressionCurveModel > xTrendline = RegressionCurveHelper::getFirstCurveNotMeanValueLine( xSeries ); + bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); + rtl::Reference< RegressionCurveModel > xMeanValue = RegressionCurveHelper::getMeanValueLine( xSeries ); + bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); + bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); + bool bHasDataLabelsAtSeries = xSeries->hasDataLabelsAtSeries(); + bool bHasDataLabelsAtPoints = xSeries->hasDataLabelsAtPoints(); + bool bHasDataLabelAtPoint = false; + sal_Int32 nPointIndex = -1; + if( bIsPoint ) { - bool bIsPoint = ( eObjectType == OBJECTTYPE_DATA_POINT ); - uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), getModel() ); - uno::Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); - Reference< chart2::XRegressionCurve > xTrendline( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt ) ); - bool bHasEquation = RegressionCurveHelper::hasEquation( xTrendline ); - Reference< chart2::XRegressionCurve > xMeanValue( RegressionCurveHelper::getMeanValueLine( xCurveCnt ) ); - bool bHasYErrorBars = StatisticsHelper::hasErrorBars( xSeries ); - bool bHasXErrorBars = StatisticsHelper::hasErrorBars( xSeries, false ); - bool bHasDataLabelsAtSeries = DataSeriesHelper::hasDataLabelsAtSeries( xSeries ); - bool bHasDataLabelsAtPoints = DataSeriesHelper::hasDataLabelsAtPoints( xSeries ); - bool bHasDataLabelAtPoint = false; - sal_Int32 nPointIndex = -1; - if( bIsPoint ) - { - nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); - bHasDataLabelAtPoint = DataSeriesHelper::hasDataLabelAtPoint( xSeries, nPointIndex ); - } - bool bSelectedPointIsFormatted = false; - bool bHasFormattedDataPointsOtherThanSelected = false; + nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + bHasDataLabelAtPoint = xSeries->hasDataLabelAtPoint( nPointIndex ); + } + bool bSelectedPointIsFormatted = false; + bool bHasFormattedDataPointsOtherThanSelected = false; - Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); - if( xSeriesProperties.is() ) + if( xSeries.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + // "AttributedDataPoints" + if( xSeries->getFastPropertyValue( PROP_DATASERIES_ATTRIBUTED_DATA_POINTS ) >>= aAttributedDataPointIndexList ) { - uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; - if( xSeriesProperties->getPropertyValue( "AttributedDataPoints" ) >>= aAttributedDataPointIndexList ) + if( aAttributedDataPointIndexList.hasElements() ) { - if( aAttributedDataPointIndexList.hasElements() ) + if( bIsPoint ) { - if( bIsPoint ) - { - auto aIndices( comphelper::sequenceToContainer<std::vector< sal_Int32 >>( aAttributedDataPointIndexList ) ); - std::vector< sal_Int32 >::iterator aIt = std::find( aIndices.begin(), aIndices.end(), nPointIndex ); - if( aIt != aIndices.end()) - bSelectedPointIsFormatted = true; - else - bHasFormattedDataPointsOtherThanSelected = true; - } + auto aIt = std::find( aAttributedDataPointIndexList.begin(), aAttributedDataPointIndexList.end(), nPointIndex ); + if (aIt != aAttributedDataPointIndexList.end()) + bSelectedPointIsFormatted = true; else bHasFormattedDataPointsOtherThanSelected = true; } + else + bHasFormattedDataPointsOtherThanSelected = true; } } + } - if( bIsPoint ) - { - if( bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabel" ); - if( !bHasDataLabelAtPoint ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabel" ); - else - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabel" ); - if( bSelectedPointIsFormatted ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetDataPoint" ); + if( bIsPoint ) + { + if( bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataLabel"_ustr ); + if( !bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertDataLabel"_ustr ); + else + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteDataLabel"_ustr ); + if( bSelectedPointIsFormatted ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:ResetDataPoint"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataSeries" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataSeries"_ustr ); + } - Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); - if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeOfSeries( xSeries ) ); + if( xChartType->getChartType() == CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK ) + { + try { - try - { - Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); - if( xChartTypeProp.is() ) - { - bool bJapaneseStyle = false; - xChartTypeProp->getPropertyValue( "Japanese" ) >>= bJapaneseStyle; - - if( bJapaneseStyle ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - } - } - } - catch( const uno::Exception & ) + bool bJapaneseStyle = false; + xChartType->getPropertyValue( u"Japanese"_ustr ) >>= bJapaneseStyle; + + if( bJapaneseStyle ) { - DBG_UNHANDLED_EXCEPTION("chart2"); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockLoss"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockGain"_ustr ); } } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } + } - if( bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatYErrorBars" ); + if( bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatDataLabels"_ustr ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatTrendlineEquation"_ustr ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMeanValue"_ustr ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatXErrorBars"_ustr ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatYErrorBars"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - if( !bHasDataLabelsAtSeries ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertDataLabels" ); - - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendline" ); - - if( !xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMeanValue" ); - if( !bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertXErrorBars" ); - if( !bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertYErrorBars" ); - if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteDataLabels" ); - if( bHasEquation ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - if( xMeanValue.is() ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMeanValue" ); - if( bHasXErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteXErrorBars" ); - if( bHasYErrorBars ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteYErrorBars" ); - - if( bHasFormattedDataPointsOtherThanSelected ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:ResetAllDataPoints" ); + if( !bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertDataLabels"_ustr ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendline"_ustr ); + + if( !xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMeanValue"_ustr ); + if( !bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertXErrorBars"_ustr ); + if( !bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertYErrorBars"_ustr ); + if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteDataLabels"_ustr ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendlineEquation"_ustr ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMeanValue"_ustr ); + if( bHasXErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteXErrorBars"_ustr ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteYErrorBars"_ustr ); + + if( bHasFormattedDataPointsOtherThanSelected ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:ResetAllDataPoints"_ustr ); - xPopupMenu->insertSeparator( -1 ); + xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId, ".uno:ArrangeRow" ); - uno::Reference< awt::XPopupMenu > xArrangePopupMenu( - m_xCC->getServiceManager()->createInstanceWithContext( - "com.sun.star.awt.PopupMenu", m_xCC ), uno::UNO_QUERY ); - if( xArrangePopupMenu.is() ) - { - sal_Int16 nSubId = nUniqueId + 1; - lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, ".uno:Forward" ); - lcl_insertMenuCommand( xArrangePopupMenu, nSubId, ".uno:Backward" ); - xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); - nUniqueId = nSubId; - } - ++nUniqueId; - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendline" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTrendlineEquationAndR2" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteTrendlineEquation" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } - else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) - { - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertR2Value" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteR2Value" ); - } + lcl_insertMenuCommand( xPopupMenu, nUniqueId, u".uno:ArrangeRow"_ustr ); + rtl::Reference< VCLXPopupMenu > xArrangePopupMenu = new VCLXPopupMenu(); + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, nSubId++, u".uno:Forward"_ustr ); + lcl_insertMenuCommand( xArrangePopupMenu, nSubId, u".uno:Backward"_ustr ); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + ++nUniqueId; + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendline"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTrendlineEquationAndR2"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertR2Value"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteTrendlineEquation"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteR2Value"_ustr ); + } + else if( eObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertR2Value"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteR2Value"_ustr ); + } - //some commands for axes: and grids + //some commands for axes: and grids - else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + else if( eObjectType == OBJECTTYPE_AXIS || eObjectType == OBJECTTYPE_GRID || eObjectType == OBJECTTYPE_SUBGRID ) + { + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getChartModel() ); + if( xAxis.is() && xDiagram.is() ) { - Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), getModel() ); - if( xAxis.is() && xDiagram.is() ) - { - sal_Int32 nDimensionIndex = -1; - sal_Int32 nCooSysIndex = -1; - sal_Int32 nAxisIndex = -1; - AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); - bool bIsSecondaryAxis = nAxisIndex!=0; - bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); - bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); - bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); - bool bHasTitle = false; - uno::Reference< XTitled > xTitled( xAxis, uno::UNO_QUERY ); - if( xTitled.is()) - bHasTitle = !TitleHelper::getCompleteString( xTitled->getTitleObject() ).isEmpty(); - - if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatAxis" ); - if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatMinorGrid" ); - - xPopupMenu->insertSeparator( -1 ); - - if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxis" ); - if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMajorGrid" ); - if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertMinorGrid" ); - if( !bHasTitle ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertAxisTitle" ); - - if( bIsAxisVisible ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteAxis" ); - if( bIsMajorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMajorGrid" ); - if( bIsMinorGridVisible && !bIsSecondaryAxis ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteMinorGrid" ); - } - } - - if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockGain" ); - else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:FormatStockLoss" ); + sal_Int32 nDimensionIndex = -1; + sal_Int32 nCooSysIndex = -1; + sal_Int32 nAxisIndex = -1; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + bool bIsSecondaryAxis = nAxisIndex!=0; + bool bIsAxisVisible = AxisHelper::isAxisVisible( xAxis ); + bool bIsMajorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, true /*bMainGrid*/, xDiagram ); + bool bIsMinorGridVisible = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, false /*bMainGrid*/, xDiagram ); + bool bHasTitle = !TitleHelper::getCompleteString( xAxis->getTitleObject2() ).isEmpty(); + + if( eObjectType != OBJECTTYPE_AXIS && bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatAxis"_ustr ); + if( eObjectType != OBJECTTYPE_GRID && bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMajorGrid"_ustr ); + if( eObjectType != OBJECTTYPE_SUBGRID && bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatMinorGrid"_ustr ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:TransformDialog" ); + xPopupMenu->insertSeparator( -1 ); - if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM - || eObjectType == OBJECTTYPE_DIAGRAM_WALL - || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR - || eObjectType == OBJECTTYPE_UNKNOWN ) - { - if( eObjectType != OBJECTTYPE_UNKNOWN ) - xPopupMenu->insertSeparator( -1 ); - bool bHasLegend = LegendHelper::hasLegend( xDiagram ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertTitles" ); - if( !bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertLegend" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:InsertRemoveAxes" ); - if( bHasLegend ) - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DeleteLegend" ); + if( eObjectType != OBJECTTYPE_AXIS && !bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertAxis"_ustr ); + if( eObjectType != OBJECTTYPE_GRID && !bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMajorGrid"_ustr ); + if( eObjectType != OBJECTTYPE_SUBGRID && !bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertMinorGrid"_ustr ); + if( !bHasTitle ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertAxisTitle"_ustr ); + + if( bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteAxis"_ustr ); + if( bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMajorGrid"_ustr ); + if( bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteMinorGrid"_ustr ); + if (bIsAxisVisible) + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, u".uno:InsertDataTable"_ustr); } + } + else if (eObjectType == OBJECTTYPE_DATA_TABLE) + { + lcl_insertMenuCommand(xPopupMenu, nUniqueId++, u".uno:DeleteDataTable"_ustr); + } - xPopupMenu->insertSeparator( -1 ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramType" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DataRanges" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:DiagramData" ); - lcl_insertMenuCommand( xPopupMenu, nUniqueId++, ".uno:View3D" ); + if( eObjectType == OBJECTTYPE_DATA_STOCK_LOSS ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockGain"_ustr ); + else if( eObjectType == OBJECTTYPE_DATA_STOCK_GAIN ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:FormatStockLoss"_ustr ); + + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:TransformDialog"_ustr ); + + if( eObjectType == OBJECTTYPE_PAGE || eObjectType == OBJECTTYPE_DIAGRAM + || eObjectType == OBJECTTYPE_DIAGRAM_WALL + || eObjectType == OBJECTTYPE_DIAGRAM_FLOOR + || eObjectType == OBJECTTYPE_UNKNOWN ) + { + if( eObjectType != OBJECTTYPE_UNKNOWN ) + xPopupMenu->insertSeparator( -1 ); + bool bHasLegend = LegendHelper::hasLegend( xDiagram ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertTitles"_ustr ); + if( !bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertLegend"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:InsertRemoveAxes"_ustr ); + if( bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DeleteLegend"_ustr ); } + + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DiagramType"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DataRanges"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:DiagramData"_ustr ); + lcl_insertMenuCommand( xPopupMenu, nUniqueId++, u".uno:View3D"_ustr ); } - css::uno::Sequence< css::uno::Any > aArgs( 3 ); - aArgs[0] <<= comphelper::makePropertyValue( "IsContextMenu", true ); - aArgs[1] <<= comphelper::makePropertyValue( "Frame", m_xFrame ); - aArgs[2] <<= comphelper::makePropertyValue( "Value", aMenuName ); + css::uno::Sequence< css::uno::Any > aArgs{ + css::uno::Any(comphelper::makePropertyValue( u"IsContextMenu"_ustr, true )), + css::uno::Any(comphelper::makePropertyValue( u"Frame"_ustr, m_xFrame )), + css::uno::Any(comphelper::makePropertyValue( u"Value"_ustr, aMenuName )) + }; css::uno::Reference< css::frame::XPopupMenuController > xPopupController( m_xCC->getServiceManager()->createInstanceWithArgumentsAndContext( - "com.sun.star.comp.framework.ResourceMenuController", aArgs, m_xCC ), css::uno::UNO_QUERY ); + u"com.sun.star.comp.framework.ResourceMenuController"_ustr, aArgs, m_xCC ), css::uno::UNO_QUERY ); if ( !xPopupController.is() || !xPopupMenu.is() ) return; @@ -1301,14 +1235,13 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) } } - Menu* pPopupMenu = comphelper::getUnoTunnelImplementation<VCLXMenu>(xPopupMenu)->GetMenu(); - boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(pPopupMenu); + boost::property_tree::ptree aMenu = SfxDispatcher::fillPopupMenu(xPopupMenu); boost::property_tree::ptree aRoot; aRoot.add_child("menu", aMenu); std::stringstream aStream; boost::property_tree::write_json(aStream, aRoot, true); - pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, aStream.str().c_str()); + pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_CONTEXT_MENU, OString(aStream.str())); } } else @@ -1328,8 +1261,7 @@ void ChartController::execute_Command( const CommandEvent& rCEvt ) ( rCEvt.GetCommand() == CommandEventId::InputContextChange ) ) { //#i84417# enable editing with IME - if( m_pDrawViewWrapper ) - m_pDrawViewWrapper->Command( rCEvt, pChartWindow ); + m_pDrawViewWrapper->Command( rCEvt, pChartWindow ); } } @@ -1381,8 +1313,8 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if( ! bReturn ) { // Navigation (Tab/F3/Home/End) - uno::Reference< XChartDocument > xChartDoc( getModel(), uno::UNO_QUERY ); - ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); + rtl::Reference<::chart::ChartModel> xChartDoc( getChartModel() ); + ObjectKeyNavigation aObjNav( m_aSelection.getSelectedOID(), xChartDoc, m_xChartView.get() ); awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode )); bReturn = aObjNav.handleKeyEvent( aKeyEvent ); if( bReturn ) @@ -1393,7 +1325,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { aNewSelection = aNewOID.getAny(); } - if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getModel() ) ) + if ( m_eDragMode == SdrDragMode::Rotate && !SelectionHelper::isRotateableObject( aNewOID.getObjectCID(), getChartModel() ) ) { m_eDragMode = SdrDragMode::Move; } @@ -1425,7 +1357,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) nCode == KEY_DOWN ) { bDrag = true; - OUString aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() )); + std::u16string_view aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() )); sal_Int32 nOffsetPercentDummy( 0 ); awt::Point aMinimumPosition( 0, 0 ); awt::Point aMaximumPosition( 0, 0 ); @@ -1521,17 +1453,17 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) if (pObj) { tools::Rectangle aRect = pObj->GetSnapRect(); - awt::Size aPageSize(ChartModelHelper::getPageSize(getModel())); - if ((fShiftAmountX > 0.0 && (aRect.getX() + fShiftAmountX + aRect.getWidth() > aPageSize.Width)) || - (fShiftAmountX < 0.0 && (aRect.getX() + fShiftAmountX < 0)) || - (fShiftAmountY > 0.0 && (aRect.getY() + fShiftAmountY + aRect.getHeight() > aPageSize.Height)) || - (fShiftAmountY < 0.0 && (aRect.getY() + fShiftAmountY < 0))) + awt::Size aPageSize(getChartModel()->getPageSize()); + if ((fShiftAmountX > 0.0 && (aRect.Right() + fShiftAmountX > aPageSize.Width)) || + (fShiftAmountX < 0.0 && (aRect.Left() + fShiftAmountX < 0)) || + (fShiftAmountY > 0.0 && (aRect.Bottom() + fShiftAmountY > aPageSize.Height)) || + (fShiftAmountY < 0.0 && (aRect.Top() + fShiftAmountY < 0))) bReturn = false; else bReturn = PositionAndSizeHelper::moveObject( - m_aSelection.getSelectedCID(), getModel(), - awt::Rectangle(aRect.getX() + fShiftAmountX, aRect.getY() + fShiftAmountY, aRect.getWidth(), aRect.getHeight()), - awt::Rectangle(aRect.getX(), aRect.getY(), 0, 0), + m_aSelection.getSelectedCID(), getChartModel(), + awt::Rectangle(aRect.Left() + fShiftAmountX, aRect.Top() + fShiftAmountY, aRect.getOpenWidth(), aRect.getOpenHeight()), + awt::Rectangle(aRect.Left(), aRect.Top(), 0, 0), awt::Rectangle(0, 0, aPageSize.Width, aPageSize.Height)); } } @@ -1547,7 +1479,7 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) { awt::Point aPos( xShape->getPosition() ); awt::Size aSize( xShape->getSize() ); - awt::Size aPageSize( ChartModelHelper::getPageSize( getModel() ) ); + awt::Size aPageSize( getChartModel()->getPageSize() ); aPos.X = static_cast< tools::Long >( static_cast< double >( aPos.X ) + fShiftAmountX ); aPos.Y = static_cast< tools::Long >( static_cast< double >( aPos.Y ) + fShiftAmountY ); if( aPos.X + aSize.Width > aPageSize.Width ) @@ -1570,10 +1502,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) // dumping the shape if( !bReturn && bCtrl && nCode == KEY_F12) { - uno::Reference< qa::XDumper > xChartModel( getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xChartModel = getChartModel(); if(xChartModel.is()) { - OUString aDump = xChartModel->dump(); + OUString aDump = xChartModel->dump(u"shapes"_ustr); SAL_WARN("chart2", aDump); } } @@ -1598,8 +1530,8 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) uno::Sequence< beans::PropertyValue > aArgs; xDispatchHelper->executeDispatch( uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), - ".uno:TerminateInplaceActivation", - "_parent", + u".uno:TerminateInplaceActivation"_ustr, + u"_parent"_ustr, frame::FrameSearchFlag::PARENT, aArgs ); bReturn = true; @@ -1611,10 +1543,10 @@ bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) bReturn = executeDispatch_Delete(); if( ! bReturn ) { - std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(), + std::shared_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(pChartWindow->GetFrameWeld(), VclMessageType::Info, VclButtonsType::Ok, SchResId(STR_ACTION_NOTPOSSIBLE))); - xInfoBox->run(); + xInfoBox->runAsync(xInfoBox, [] (int) {}); } } @@ -1627,9 +1559,9 @@ bool ChartController::requestQuickHelp( OUString & rOutQuickHelpText, awt::Rectangle & rOutEqualRect ) { - uno::Reference< frame::XModel > xChartModel; + rtl::Reference<::chart::ChartModel> xChartModel; if( m_aModel.is()) - xChartModel.set( getModel() ); + xChartModel = getChartModel(); if( !xChartModel.is()) return false; @@ -1648,10 +1580,8 @@ bool ChartController::requestQuickHelp( rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ ); // set rectangle - ExplicitValueProvider * pValueProvider( - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); - if( pValueProvider ) - rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true ); + if( m_xChartView ) + rOutEqualRect = m_xChartView->getRectangleOfObject( aCID, true ); } return bResult; @@ -1664,8 +1594,7 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) if ( rSelection.hasValue() ) { - const uno::Type& rType = rSelection.getValueType(); - if ( rType == cppu::UnoType< OUString >::get() ) + if (rSelection.getValueType() == cppu::UnoType<OUString>::get()) { OUString aNewCID; if ( ( rSelection >>= aNewCID ) && m_aSelection.setSelection( aNewCID ) ) @@ -1673,10 +1602,9 @@ sal_Bool SAL_CALL ChartController::select( const uno::Any& rSelection ) bSuccess = true; } } - else if ( rType == cppu::UnoType<drawing::XShape>::get() ) + else if (uno::Reference<drawing::XShape> xShape; rSelection >>= xShape) { - uno::Reference< drawing::XShape > xShape; - if ( ( rSelection >>= xShape ) && m_aSelection.setSelection( xShape ) ) + if (m_aSelection.setSelection(xShape)) { bSuccess = true; } @@ -1736,7 +1664,8 @@ void SAL_CALL ChartController::addSelectionChangeListener( const uno::Reference< return; //behave passive if already disposed or suspended //--add listener - m_aLifeTimeManager.m_aListenerContainer.addInterface( cppu::UnoType<view::XSelectionChangeListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aSelectionChangeListeners.addInterface( aGuard2, xListener ); } void SAL_CALL ChartController::removeSelectionChangeListener( const uno::Reference<view::XSelectionChangeListener> & xListener ) @@ -1746,24 +1675,18 @@ void SAL_CALL ChartController::removeSelectionChangeListener( const uno::Referen return; //behave passive if already disposed or suspended //--remove listener - m_aLifeTimeManager.m_aListenerContainer.removeInterface( cppu::UnoType<view::XSelectionChangeListener>::get(), xListener ); + std::unique_lock aGuard2(m_aLifeTimeManager.m_aAccessMutex); + m_aLifeTimeManager.m_aSelectionChangeListeners.removeInterface( aGuard2, xListener ); } void ChartController::impl_notifySelectionChangeListeners() { - ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer - .getContainer( cppu::UnoType<view::XSelectionChangeListener>::get() ); - if( pIC ) + std::unique_lock aGuard(m_aLifeTimeManager.m_aAccessMutex); + if( m_aLifeTimeManager.m_aSelectionChangeListeners.getLength(aGuard) ) { uno::Reference< view::XSelectionSupplier > xSelectionSupplier(this); lang::EventObject aEvent( xSelectionSupplier ); - ::cppu::OInterfaceIteratorHelper aIt( *pIC ); - while( aIt.hasMoreElements() ) - { - uno::Reference< view::XSelectionChangeListener > xListener( aIt.next(), uno::UNO_QUERY ); - if( xListener.is() ) - xListener->selectionChanged( aEvent ); - } + m_aLifeTimeManager.m_aSelectionChangeListeners.notifyEach(aGuard, &view::XSelectionChangeListener::selectionChanged, aEvent); } } @@ -1790,23 +1713,22 @@ bool ChartController::impl_moveOrResizeObject( bool bResult = false; bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT ); - uno::Reference< frame::XModel > xChartModel( getModel() ); + rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() ); uno::Reference< beans::XPropertySet > xObjProp( ObjectIdentifier::getObjectPropertySet( rCID, xChartModel )); if( xObjProp.is()) { - awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel ); + awt::Size aRefSize = xChartModel->getPageSize(); chart2::RelativePosition aRelPos; chart2::RelativeSize aRelSize; - bool bDeterminePos = !(xObjProp->getPropertyValue( "RelativePosition") >>= aRelPos); - bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( "RelativeSize") >>= aRelSize); + bool bDeterminePos = !(xObjProp->getPropertyValue( u"RelativePosition"_ustr) >>= aRelPos); + bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( u"RelativeSize"_ustr) >>= aRelSize); if( ( bDeterminePos || bDetermineSize ) && ( aRefSize.Width > 0 && aRefSize.Height > 0 ) ) { - ExplicitValueProvider * pValueProvider( - comphelper::getUnoTunnelImplementation<ExplicitValueProvider>( m_xChartView )); + ChartView * pValueProvider( m_xChartView.get() ); if( pValueProvider ) { awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID )); @@ -1853,9 +1775,9 @@ bool ChartController::impl_moveOrResizeObject( eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager ); { ControllerLockGuardUNO aCLGuard( xChartModel ); - xObjProp->setPropertyValue( "RelativePosition", uno::Any( aRelPos )); + xObjProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any( aRelPos )); if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicit size at the diagram when an explicit position is set - xObjProp->setPropertyValue( "RelativeSize", uno::Any( aRelSize )); + xObjProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any( aRelSize )); } aUndoGuard.commit(); } @@ -1863,15 +1785,15 @@ bool ChartController::impl_moveOrResizeObject( return bResult; } -bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditionalOffset ) +bool ChartController::impl_DragDataPoint( std::u16string_view rCID, double fAdditionalOffset ) { bool bResult = false; if( fAdditionalOffset < -1.0 || fAdditionalOffset > 1.0 || fAdditionalOffset == 0.0 ) return bResult; sal_Int32 nDataPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rCID ); - uno::Reference< chart2::XDataSeries > xSeries( - ObjectIdentifier::getDataSeriesForCID( rCID, getModel() )); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID( rCID, getChartModel() ); if( xSeries.is()) { try @@ -1879,7 +1801,7 @@ bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditio uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex( nDataPointIndex )); double fOffset = 0.0; if( xPointProp.is() && - (xPointProp->getPropertyValue( "Offset" ) >>= fOffset ) && + (xPointProp->getPropertyValue( u"Offset"_ustr ) >>= fOffset ) && (( fAdditionalOffset > 0.0 && fOffset < 1.0 ) || (fOffset > 0.0)) ) { fOffset += fAdditionalOffset; @@ -1887,7 +1809,7 @@ bool ChartController::impl_DragDataPoint( const OUString & rCID, double fAdditio fOffset = 1.0; else if( fOffset < 0.0 ) fOffset = 0.0; - xPointProp->setPropertyValue( "Offset", uno::Any( fOffset )); + xPointProp->setPropertyValue( u"Offset"_ustr, uno::Any( fOffset )); bResult = true; } } @@ -1989,33 +1911,33 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) SdrObjKind eKind = m_pDrawViewWrapper->GetCurrentObjIdentifier(); switch ( eKind ) { - case OBJ_LINE: + case SdrObjKind::Line: { ePointerStyle = PointerStyle::DrawLine; } break; - case OBJ_RECT: - case OBJ_CUSTOMSHAPE: + case SdrObjKind::Rectangle: + case SdrObjKind::CustomShape: { ePointerStyle = PointerStyle::DrawRect; } break; - case OBJ_CIRC: + case SdrObjKind::CircleOrEllipse: { ePointerStyle = PointerStyle::DrawEllipse; } break; - case OBJ_FREELINE: + case SdrObjKind::FreehandLine: { ePointerStyle = PointerStyle::DrawPolygon; } break; - case OBJ_TEXT: + case SdrObjKind::Text: { ePointerStyle = PointerStyle::DrawText; } break; - case OBJ_CAPTION: + case SdrObjKind::Caption: { ePointerStyle = PointerStyle::DrawCaption; } @@ -2052,7 +1974,7 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) { if( (m_eDragMode == SdrDragMode::Rotate) && SelectionHelper::isRotateableObject( aHitObjectCID - , getModel() ) ) + , getChartModel() ) ) pChartWindow->SetPointer( PointerStyle::Rotate ); else { @@ -2073,14 +1995,9 @@ void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) pChartWindow->SetPointer( PointerStyle::Arrow ); } -css::uno::Reference<css::uno::XInterface> const & ChartController::getChartView() const -{ - return m_xChartView; -} - -void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle aRectangle) +void ChartController::sendPopupRequest(std::u16string_view rCID, tools::Rectangle aRectangle) { - ChartModel* pChartModel = dynamic_cast<ChartModel*>(m_aModel->getModel().get()); + ChartModel* pChartModel = m_aModel->getModel().get(); if (!pChartModel) return; @@ -2097,11 +2014,11 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a return; // Get dimension index from CID - sal_Int32 nStartPos = rCID.lastIndexOf('.'); - nStartPos++; - sal_Int32 nEndPos = rCID.getLength(); - OUString sDimensionIndex = rCID.copy(nStartPos, nEndPos - nStartPos); - sal_Int32 nDimensionIndex = sDimensionIndex.toInt32(); + size_t nStartPos = rCID.rfind('.'); + nStartPos = (nStartPos == std::u16string_view::npos) ? 0 : (nStartPos + 1); + sal_Int32 nEndPos = rCID.size(); + std::u16string_view sDimensionIndex = rCID.substr(nStartPos, nEndPos - nStartPos); + sal_Int32 nDimensionIndex = o3tl::toInt32(sDimensionIndex); awt::Rectangle xRectangle { sal_Int32(aRectangle.Left()), @@ -2112,12 +2029,12 @@ void ChartController::sendPopupRequest(OUString const & rCID, tools::Rectangle a uno::Sequence<beans::PropertyValue> aCallbackData = comphelper::InitPropertySequence( { - {"Rectangle", uno::makeAny<awt::Rectangle>(xRectangle)}, - {"DimensionIndex", uno::makeAny<sal_Int32>(nDimensionIndex)}, - {"PivotTableName", uno::makeAny<OUString>(sPivotTableName)}, + {"Rectangle", uno::Any(xRectangle)}, + {"DimensionIndex", uno::Any(sal_Int32(nDimensionIndex))}, + {"PivotTableName", uno::Any(sPivotTableName)}, }); - pPopupRequest->getCallback()->notify(uno::makeAny(aCallbackData)); + pPopupRequest->getCallback()->notify(uno::Any(aCallbackData)); } } //namespace chart diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx index 15272dfc5963..f03596e96475 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.cxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -18,13 +18,15 @@ */ #include "ChartDropTargetHelper.hxx" +#include <DataSource.hxx> #include <DataSourceHelper.hxx> +#include <ChartModel.hxx> +#include <Diagram.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/data/XDataProvider.hpp> -#include <com/sun/star/container/XChild.hpp> #include <sot/formats.hxx> +#include <utility> #include <vector> using namespace ::com::sun::star; @@ -60,9 +62,9 @@ namespace chart ChartDropTargetHelper::ChartDropTargetHelper( const Reference< datatransfer::dnd::XDropTarget >& rxDropTarget, - const Reference< chart2::XChartDocument > & xChartDocument ) : + rtl::Reference<::chart::ChartModel> xChartDocument ) : DropTargetHelper( rxDropTarget ), - m_xChartDocument( xChartDocument ) + m_xChartDocument(std::move( xChartDocument )) {} ChartDropTargetHelper::~ChartDropTargetHelper() @@ -108,26 +110,25 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) std::vector< OUString > aStrings( lcl_getStringsFromByteSequence( aBytes )); if( aStrings.size() >= 3 && aStrings[0] == "soffice" ) { - OUString aRangeString( aStrings[2] ); - Reference< container::XChild > xChild( m_xChartDocument, uno::UNO_QUERY ); - if( xChild.is()) + const OUString& aRangeString( aStrings[2] ); + if( m_xChartDocument.is()) { - Reference< frame::XModel > xParentModel( xChild->getParent(), uno::UNO_QUERY ); + Reference< frame::XModel > xParentModel( m_xChartDocument->getParent(), uno::UNO_QUERY ); if( xParentModel.is() && m_xChartDocument.is()) { // @todo: get the title somehow and compare it to // aDocName if successful (the document is the // parent) - Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram() ); + rtl::Reference< Diagram > xDiagram = m_xChartDocument->getFirstChartDiagram(); Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); if( xDataProvider.is() && xDiagram.is() && DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument )) { - Reference< chart2::data::XDataSource > xDataSource( - DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); + rtl::Reference< DataSource > xDataSource1 = + DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument ); Sequence< beans::PropertyValue > aArguments( - xDataProvider->detectArguments( xDataSource )); + xDataProvider->detectArguments( xDataSource1 )); OUString aOldRange; beans::PropertyValue * pCellRange = nullptr; @@ -155,8 +156,9 @@ sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) pCellRange->Value <<= aRangeString; } - xDataSource.set( xDataProvider->createDataSource( aArguments )); - xDiagram->setDiagramData( xDataSource, aArguments ); + Reference< chart2::data::XDataSource > xDataSource2 = + xDataProvider->createDataSource( aArguments ); + xDiagram->setDiagramData( xDataSource2, aArguments ); // always return copy state to avoid deletion of the dragged range nResult = DND_ACTION_COPY; diff --git a/chart2/source/controller/main/ChartDropTargetHelper.hxx b/chart2/source/controller/main/ChartDropTargetHelper.hxx index 84c8dfe98f45..6a5383825836 100644 --- a/chart2/source/controller/main/ChartDropTargetHelper.hxx +++ b/chart2/source/controller/main/ChartDropTargetHelper.hxx @@ -19,15 +19,11 @@ #pragma once #include <vcl/transfer.hxx> - -namespace com::sun::star { - namespace chart2 { - class XChartDocument; - } -} +#include <rtl/ref.hxx> namespace chart { +class ChartModel; class ChartDropTargetHelper : public DropTargetHelper { @@ -35,7 +31,7 @@ public: ChartDropTargetHelper() = delete; explicit ChartDropTargetHelper( const css::uno::Reference< css::datatransfer::dnd::XDropTarget >& rxDropTarget, - const css::uno::Reference< css::chart2::XChartDocument > & xChartDocument ); + rtl::Reference<::chart::ChartModel> xChartDocument ); virtual ~ChartDropTargetHelper() override; protected: @@ -46,7 +42,7 @@ protected: private: bool satisfiesPrerequisites() const; - css::uno::Reference< css::chart2::XChartDocument > m_xChartDocument; + rtl::Reference<::chart::ChartModel> m_xChartDocument; }; } // namespace chart diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx index c03a3f6b619e..cbaec55db9e0 100644 --- a/chart2/source/controller/main/ChartFrameloader.cxx +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -20,11 +20,14 @@ #include "ChartFrameloader.hxx" #include <servicenames.hxx> #include <MediaDescriptorHelper.hxx> +#include <ChartController.hxx> +#include <ChartModel.hxx> +#include <unotools/fcm.hxx> #include <unotools/mediadescriptor.hxx> #include <cppuhelper/supportsservice.hxx> #include <com/sun/star/frame/XLoadable.hpp> #include <com/sun/star/uno/XComponentContext.hpp> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -57,7 +60,7 @@ bool ChartFrameLoader::impl_checkCancel() OUString SAL_CALL ChartFrameLoader::getImplementationName() { - return CHART_FRAMELOADER_SERVICE_IMPLEMENTATION_NAME; + return u"com.sun.star.comp.chart2.ChartFrameLoader"_ustr; } sal_Bool SAL_CALL ChartFrameLoader::supportsService( const OUString& rServiceName ) @@ -67,7 +70,7 @@ sal_Bool SAL_CALL ChartFrameLoader::supportsService( const OUString& rServiceNam css::uno::Sequence< OUString > SAL_CALL ChartFrameLoader::getSupportedServiceNames() { - return { CHART_FRAMELOADER_SERVICE_NAME }; + return { u"com.sun.star.frame.SynchronousFrameLoader"_ustr }; } // frame::XFrameLoader @@ -81,7 +84,7 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa utl::MediaDescriptor aMediaDescriptor(rMediaDescriptor); { - utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_MODEL())); + utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_MODEL)); if( aIt != aMediaDescriptor.end()) { xModel.set( (*aIt).second.get< uno::Reference< frame::XModel > >()); @@ -93,90 +96,71 @@ sal_Bool SAL_CALL ChartFrameLoader::load( const uno::Sequence< beans::PropertyVa if( ! xModel.is()) { //@todo?? load mechanism to cancel during loading of document - xModel.set( - m_xCC->getServiceManager()->createInstanceWithContext( - CHART_MODEL_SERVICE_IMPLEMENTATION_NAME, m_xCC ) - , uno::UNO_QUERY ); + xModel = new ChartModel(m_xCC); if( impl_checkCancel() ) return false; } //create the controller(+XWindow) - uno::Reference< frame::XController > xController; - uno::Reference< awt::XWindow > xComponentWindow; - { - xController.set( - m_xCC->getServiceManager()->createInstanceWithContext( - CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME,m_xCC ) - , uno::UNO_QUERY ); - - //!!!it is a special characteristic of the example application - //that the controller simultaneously provides the XWindow controller functionality - xComponentWindow = - uno::Reference< awt::XWindow >( xController, uno::UNO_QUERY ); + rtl::Reference< ChartController > xController = new ChartController(m_xCC); - if( impl_checkCancel() ) - return false; - } + if( impl_checkCancel() ) + return false; //connect frame, controller and model one to each other: - if(xController.is()&&xModel.is()) + if(xModel.is()) { - xModel->connectController(xController); - xModel->setCurrentController(xController); - xController->attachModel(xModel); - if(xFrame.is()) - xFrame->setComponent(xComponentWindow,xController); - //creates the view and menu - //for correct menu creation the initialized component must be already set into the frame - xController->attachFrame(xFrame); + utl::ConnectFrameControllerModel(xFrame, xController, xModel); } // call initNew() or load() at XLoadable - if(!bHaveLoadedModel) - try + if(bHaveLoadedModel) + return true; + + try + { + utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL)); + if( aIt != aMediaDescriptor.end()) { - utl::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( utl::MediaDescriptor::PROP_URL())); - if( aIt != aMediaDescriptor.end()) + OUString aURL( (*aIt).second.get< OUString >()); + if( aURL.startsWith( "private:factory/schart" ) ) + { + // create new file + uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); + xLoadable->initNew(); + } + else { - OUString aURL( (*aIt).second.get< OUString >()); - if( aURL.startsWith( "private:factory/schart" ) ) + // use the URL as BaseURL, similar to what SfxBaseModel effectively does + if (!aURL.isEmpty()) { - // create new file - uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); - xLoadable->initNew(); + aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL] <<= aURL; } - else + aMediaDescriptor.addInputStream(); + uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; + aMediaDescriptor >> aCompleteMediaDescriptor; + apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor ); + + // load file + // @todo: replace: aMediaDescriptorHelper.getReducedForModel() + uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); + xLoadable->load( aCompleteMediaDescriptor ); + + //resize standalone files to get correct size: + if( aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) { - // use the URL as BaseURL, similar to what SfxBaseModel effectively does - if (!aURL.isEmpty()) - { - aMediaDescriptor[utl::MediaDescriptor::PROP_DOCUMENTBASEURL()] <<= aURL; - } - aMediaDescriptor.addInputStream(); - uno::Sequence< beans::PropertyValue > aCompleteMediaDescriptor; - aMediaDescriptor >> aCompleteMediaDescriptor; - apphelper::MediaDescriptorHelper aMDHelper( aCompleteMediaDescriptor ); - - // load file - // @todo: replace: aMediaDescriptorHelper.getReducedForModel() - uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); - xLoadable->load( aCompleteMediaDescriptor ); - - //resize standalone files to get correct size: - if( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName == "StarChart 5.0" ) - { - awt::Rectangle aRect( xComponentWindow->getPosSize() ); - xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 ); - } + uno::Reference<awt::XWindow> xComponentWindow = xController->getComponentWindow(); + awt::Rectangle aRect( xComponentWindow->getPosSize() ); + xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, 0 ); } } } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } + } + catch( const uno::Exception & ) + { + DBG_UNHANDLED_EXCEPTION("chart2"); + } return true; } diff --git a/chart2/source/controller/main/ChartModelClone.cxx b/chart2/source/controller/main/ChartModelClone.cxx index 6348aee6e6f9..153a37d7f982 100644 --- a/chart2/source/controller/main/ChartModelClone.cxx +++ b/chart2/source/controller/main/ChartModelClone.cxx @@ -19,8 +19,8 @@ #include "ChartModelClone.hxx" #include <ChartModel.hxx> -#include <ChartModelHelper.hxx> #include <ControllerLockGuard.hxx> +#include <DataSource.hxx> #include <DataSourceHelper.hxx> #include <com/sun/star/chart2/XAnyDescriptionAccess.hpp> @@ -28,14 +28,10 @@ #include <com/sun/star/util/XCloneable.hpp> #include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/lang/XComponent.hpp> -#include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/util/XModifiable.hpp> -#include <com/sun/star/chart2/data/XDataSource.hpp> #include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> #include <comphelper/property.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -51,45 +47,38 @@ namespace chart using ::com::sun::star::chart2::XInternalDataProvider; using ::com::sun::star::chart2::XAnyDescriptionAccess; using ::com::sun::star::view::XSelectionSupplier; - using ::com::sun::star::lang::XComponent; - using ::com::sun::star::chart2::XTitled; - using ::com::sun::star::util::XModifiable; - using ::com::sun::star::chart2::data::XDataSource; using ::com::sun::star::chart2::data::XLabeledDataSequence; // = helper namespace { - Reference< XModel > lcl_cloneModel( const Reference< XModel > & xModel ) + rtl::Reference<::chart::ChartModel> lcl_cloneModel( const rtl::Reference<::chart::ChartModel> & xModel ) { - Reference< XModel > xResult; try { - const Reference< XCloneable > xCloneable( xModel, UNO_QUERY_THROW ); - xResult.set( xCloneable->createClone(), UNO_QUERY_THROW ); + return new ChartModel(*xModel); } catch( const Exception& ) { DBG_UNHANDLED_EXCEPTION("chart2"); } - return xResult; + return nullptr; } } // = ChartModelClone - ChartModelClone::ChartModelClone( const Reference< XModel >& i_model, const ModelFacet i_facet ) + ChartModelClone::ChartModelClone( const rtl::Reference<::chart::ChartModel>& i_model, const ModelFacet i_facet ) { - m_xModelClone.set( lcl_cloneModel( i_model ) ); + m_xModelClone = lcl_cloneModel( i_model ); try { if ( i_facet == E_MODEL_WITH_DATA ) { - const Reference< XChartDocument > xChartDoc( m_xModelClone, UNO_QUERY_THROW ); - ENSURE_OR_THROW( xChartDoc->hasInternalDataProvider(), "invalid chart model" ); + ENSURE_OR_THROW( m_xModelClone && m_xModelClone->hasInternalDataProvider(), "invalid chart model" ); - const Reference< XCloneable > xCloneable( xChartDoc->getDataProvider(), UNO_QUERY_THROW ); + const Reference< XCloneable > xCloneable( m_xModelClone->getDataProvider(), UNO_QUERY_THROW ); m_xDataClone.set( xCloneable->createClone(), UNO_QUERY_THROW ); } @@ -116,15 +105,6 @@ namespace chart if ( impl_isDisposed() ) return; - try - { - Reference< XComponent > xComp( m_xModelClone, UNO_QUERY_THROW ); - xComp->dispose(); - } - catch( const Exception& ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } m_xModelClone.clear(); m_xDataClone.clear(); m_aSelection.clear(); @@ -139,7 +119,7 @@ namespace chart return E_MODEL; } - void ChartModelClone::applyToModel( const Reference< XModel >& i_model ) const + void ChartModelClone::applyToModel( const rtl::Reference<::chart::ChartModel>& i_model ) const { applyModelContentToModel( i_model, m_xModelClone, m_xDataClone ); @@ -179,8 +159,9 @@ namespace chart } } - void ChartModelClone::applyModelContentToModel( const Reference< XModel >& i_model, - const Reference< XModel >& i_modelToCopyFrom, const Reference< XInternalDataProvider >& i_data ) + void ChartModelClone::applyModelContentToModel( const rtl::Reference<::chart::ChartModel>& i_model, + const rtl::Reference<::chart::ChartModel>& i_modelToCopyFrom, + const Reference< XInternalDataProvider >& i_data ) { ENSURE_OR_RETURN_VOID( i_model.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); ENSURE_OR_RETURN_VOID( i_modelToCopyFrom.is(), "ChartModelElement::applyModelContentToModel: invalid source model!" ); @@ -188,25 +169,20 @@ namespace chart { // locked controllers of destination ControllerLockGuardUNO aLockedControllers( i_model ); - Reference< XChartDocument > xSource( i_modelToCopyFrom, UNO_QUERY_THROW ); - Reference< XChartDocument > xDestination( i_model, UNO_QUERY_THROW ); // propagate the correct flag for plotting of hidden values to the data provider and all used sequences - ChartModel& rModel = dynamic_cast<ChartModel&>(*i_model); - ChartModelHelper::setIncludeHiddenCells(ChartModelHelper::isIncludeHiddenCells( i_modelToCopyFrom ), rModel); + i_model->setIncludeHiddenCells(i_modelToCopyFrom->isIncludeHiddenCells()); // diagram - xDestination->setFirstDiagram( xSource->getFirstDiagram() ); + i_model->setFirstDiagram( i_modelToCopyFrom->getFirstDiagram() ); // main title - Reference< XTitled > xDestinationTitled( xDestination, UNO_QUERY_THROW ); - Reference< XTitled > xSourceTitled( xSource, UNO_QUERY_THROW ); - xDestinationTitled->setTitleObject( xSourceTitled->getTitleObject() ); + i_model->setTitleObject( i_modelToCopyFrom->getTitleObject() ); // page background ::comphelper::copyProperties( - xSource->getPageBackground(), - xDestination->getPageBackground() ); + i_modelToCopyFrom->getPageBackground(), + i_model->getPageBackground() ); // apply data (not applied in standard Undo) if ( i_data.is() ) @@ -214,10 +190,10 @@ namespace chart // register all sequences at the internal data provider to get adapted // indexes when columns are added/removed - if ( xDestination->hasInternalDataProvider() ) + if ( i_model->hasInternalDataProvider() ) { - Reference< XInternalDataProvider > xNewDataProvider( xDestination->getDataProvider(), UNO_QUERY ); - Reference< XDataSource > xUsedData( DataSourceHelper::getUsedData( i_model ) ); + Reference< XInternalDataProvider > xNewDataProvider( i_model->getDataProvider(), UNO_QUERY ); + rtl::Reference< DataSource > xUsedData = DataSourceHelper::getUsedData( *i_model ); if ( xUsedData.is() && xNewDataProvider.is() ) { const Sequence< Reference< XLabeledDataSequence > > aData( xUsedData->getDataSequences() ); @@ -230,11 +206,9 @@ namespace chart } // restore modify status - Reference< XModifiable > xSourceMod( xSource, UNO_QUERY ); - Reference< XModifiable > xDestMod( xDestination, UNO_QUERY ); - if ( xSourceMod.is() && xDestMod.is() && !xSourceMod->isModified() ) + if ( !i_modelToCopyFrom->isModified() ) { - xDestMod->setModified( false ); + i_model->setModified( false ); } // \-- locked controllers of destination } diff --git a/chart2/source/controller/main/ChartModelClone.hxx b/chart2/source/controller/main/ChartModelClone.hxx index e5f052eb7046..4f70132486b1 100644 --- a/chart2/source/controller/main/ChartModelClone.hxx +++ b/chart2/source/controller/main/ChartModelClone.hxx @@ -21,12 +21,13 @@ #include <com/sun/star/uno/Any.hxx> #include <com/sun/star/uno/Reference.h> +#include <rtl/ref.hxx> namespace com::sun::star::chart2 { class XInternalDataProvider; } -namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; enum ModelFacet { @@ -39,7 +40,7 @@ namespace chart { public: ChartModelClone( - const css::uno::Reference< css::frame::XModel >& i_model, + const rtl::Reference<::chart::ChartModel>& i_model, const ModelFacet i_facet ); @@ -50,11 +51,11 @@ namespace chart ModelFacet getFacet() const; - void applyToModel( const css::uno::Reference< css::frame::XModel >& i_model ) const; + void applyToModel( const rtl::Reference<::chart::ChartModel>& i_model ) const; static void applyModelContentToModel( - const css::uno::Reference< css::frame::XModel > & i_model, - const css::uno::Reference< css::frame::XModel > & i_modelToCopyFrom, + const rtl::Reference<::chart::ChartModel> & i_model, + const rtl::Reference<::chart::ChartModel> & i_modelToCopyFrom, const css::uno::Reference< css::chart2::XInternalDataProvider > & i_data ); void dispose(); @@ -63,7 +64,7 @@ namespace chart bool impl_isDisposed() const { return !m_xModelClone.is(); } private: - css::uno::Reference< css::frame::XModel > m_xModelClone; + rtl::Reference<::chart::ChartModel> m_xModelClone; css::uno::Reference< css::chart2::XInternalDataProvider > m_xDataClone; css::uno::Any m_aSelection; }; diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx index 322e73be3aa8..7c8eb12041f6 100644 --- a/chart2/source/controller/main/ChartTransferable.cxx +++ b/chart2/source/controller/main/ChartTransferable.cxx @@ -49,20 +49,19 @@ ChartTransferable::ChartTransferable( SdrModel& rSdrModel, SdrObject* pSelectedObj, bool bDrawing) -: m_pMarkedObjModel( nullptr ) - ,m_bDrawing( bDrawing ) + : m_bDrawing(bDrawing) { - std::unique_ptr<SdrExchangeView> pExchgView(std::make_unique<SdrView>( rSdrModel )); - SdrPageView* pPv = pExchgView->ShowSdrPage( rSdrModel.GetPage( 0 )); + SdrView aExchgView( rSdrModel ); + SdrPageView* pPv = aExchgView.ShowSdrPage( rSdrModel.GetPage( 0 )); if( pSelectedObj ) - pExchgView->MarkObj( pSelectedObj, pPv ); + aExchgView.MarkObj( pSelectedObj, pPv ); else - pExchgView->MarkAllObj( pPv ); - Graphic aGraphic( pExchgView->GetMarkedObjMetaFile(true)); + aExchgView.MarkAllObj( pPv ); + Graphic aGraphic( aExchgView.GetMarkedObjMetaFile(true)); m_xMetaFileGraphic.set( aGraphic.GetXGraphic()); if ( m_bDrawing ) { - m_pMarkedObjModel = pExchgView->CreateMarkedObjModel().release(); + m_xMarkedObjModel = aExchgView.CreateMarkedObjModel(); } } @@ -89,7 +88,7 @@ bool ChartTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, c { if ( nFormat == SotClipboardFormatId::DRAWING ) { - bResult = SetObject( m_pMarkedObjModel, CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor ); + bResult = SetObject(m_xMarkedObjModel.get(), CHARTTRANSFER_OBJECTTYPE_DRAWMODEL, rFlavor); } else if ( nFormat == SotClipboardFormatId::GDIMETAFILE ) { @@ -106,7 +105,7 @@ bool ChartTransferable::GetData( const css::datatransfer::DataFlavor& rFlavor, c return bResult; } -bool ChartTransferable::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, +bool ChartTransferable::WriteObject( SvStream& rOStm, void* pUserObject, sal_uInt32 nUserObjectId, const datatransfer::DataFlavor& /* rFlavor */ ) { // called from SetObject, put data into stream @@ -119,12 +118,12 @@ bool ChartTransferable::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* SdrModel* pMarkedObjModel = static_cast< SdrModel* >( pUserObject ); if ( pMarkedObjModel ) { - rxOStm->SetBufferSize( 0xff00 ); + rOStm.SetBufferSize( 0xff00 ); // for the changed pool defaults from drawing layer pool set those // attributes as hard attributes to preserve them for saving const SfxItemPool& rItemPool = pMarkedObjModel->GetItemPool(); - const SvxFontHeightItem& rDefaultFontHeight = rItemPool.GetDefaultItem( EE_CHAR_FONTHEIGHT ); + const SvxFontHeightItem& rDefaultFontHeight = rItemPool.GetUserOrPoolDefaultItem( EE_CHAR_FONTHEIGHT ); sal_uInt16 nCount = pMarkedObjModel->GetPageCount(); for ( sal_uInt16 i = 0; i < nCount; ++i ) { @@ -141,10 +140,10 @@ bool ChartTransferable::WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* } } - Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( *rxOStm ) ); + Reference< io::XOutputStream > xDocOut( new utl::OOutputStreamWrapper( rOStm ) ); SvxDrawingLayerExport( pMarkedObjModel, xDocOut ); - bRet = ( rxOStm->GetError() == ERRCODE_NONE ); + bRet = ( rOStm.GetError() == ERRCODE_NONE ); } } break; diff --git a/chart2/source/controller/main/ChartTransferable.hxx b/chart2/source/controller/main/ChartTransferable.hxx index 34567dceb6a9..486fdb48c5a9 100644 --- a/chart2/source/controller/main/ChartTransferable.hxx +++ b/chart2/source/controller/main/ChartTransferable.hxx @@ -46,12 +46,12 @@ protected: // implementation of TransferableHelper methods virtual void AddSupportedFormats() override; virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override; - virtual bool WriteObject( tools::SvRef<SotTempStream>& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, + virtual bool WriteObject( SvStream& rOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override; private: css::uno::Reference< css::graphic::XGraphic > m_xMetaFileGraphic; - SdrModel* m_pMarkedObjModel; + std::unique_ptr<SdrModel> m_xMarkedObjModel; bool m_bDrawing; }; diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx index 73e642446be1..ee8b70aab9a8 100644 --- a/chart2/source/controller/main/ChartWindow.cxx +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -17,6 +17,7 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <config_wasm_strip.h> #include <ChartWindow.hxx> #include <ChartController.hxx> #include <helpids.h> @@ -30,17 +31,13 @@ #include <sfx2/lokhelper.hxx> #include <comphelper/lok.hxx> -#define TWIPS_PER_PIXEL 15 - using namespace ::com::sun::star; namespace { ::tools::Rectangle lcl_AWTRectToVCLRect( const css::awt::Rectangle & rAWTRect ) { - ::tools::Rectangle aResult; - aResult.setX( rAWTRect.X ); - aResult.setY( rAWTRect.Y ); + ::tools::Rectangle aResult(rAWTRect.X, rAWTRect.Y); aResult.setWidth( rAWTRect.Width ); aResult.setHeight( rAWTRect.Height ); return aResult; @@ -56,7 +53,7 @@ ChartWindow::ChartWindow( ChartController* pController, vcl::Window* pParent, Wi , m_bInPaint(false) , m_pViewShellWindow( nullptr ) { - set_id("chart_window"); + set_id(u"chart_window"_ustr); SetHelpId( HID_SCH_WIN_DOCUMENT ); SetMapMode( MapMode(MapUnit::Map100thMM) ); adjustHighContrastMode(); @@ -75,7 +72,7 @@ ChartWindow::~ChartWindow() void ChartWindow::dispose() { m_pWindowController = nullptr; - m_pViewShellWindow.clear(); + m_pViewShellWindow.reset(); vcl::Window::dispose(); } @@ -185,10 +182,14 @@ void ChartWindow::KeyInput( const KeyEvent& rKEvt ) uno::Reference< css::accessibility::XAccessible > ChartWindow::CreateAccessible() { +#if !ENABLE_WASM_STRIP_ACCESSIBILITY if( m_pWindowController ) return m_pWindowController->CreateAccessible(); else return Window::CreateAccessible(); +#else + return uno::Reference< css::accessibility::XAccessible >(); +#endif } void ChartWindow::DataChanged( const DataChangedEvent& rDCEvt ) @@ -208,7 +209,6 @@ void ChartWindow::RequestHelp( const HelpEvent& rHEvt ) if( ( rHEvt.GetMode() & HelpEventMode::QUICK ) && m_pWindowController ) { -// Point aLogicHitPos = PixelToLogic( rHEvt.GetMousePosPixel()); // old chart: GetPointerPosPixel() Point aLogicHitPos = PixelToLogic( GetPointerPosPixel()); OUString aQuickHelpText; awt::Rectangle aHelpRect; @@ -217,12 +217,14 @@ void ChartWindow::RequestHelp( const HelpEvent& rHEvt ) if( bHelpHandled ) { + tools::Rectangle aPixelRect(LogicToPixel(lcl_AWTRectToVCLRect(aHelpRect))); + tools::Rectangle aScreenRect(OutputToScreenPixel(aPixelRect.TopLeft()), + OutputToScreenPixel(aPixelRect.BottomRight())); + if( bIsBalloonHelp ) - Help::ShowBalloon( - this, rHEvt.GetMousePosPixel(), lcl_AWTRectToVCLRect( aHelpRect ), aQuickHelpText ); + Help::ShowBalloon(this, rHEvt.GetMousePosPixel(), aScreenRect, aQuickHelpText); else - Help::ShowQuickHelp( - this, lcl_AWTRectToVCLRect( aHelpRect ), aQuickHelpText ); + Help::ShowQuickHelp(this, aScreenRect, aQuickHelpText); } } @@ -230,21 +232,6 @@ void ChartWindow::RequestHelp( const HelpEvent& rHEvt ) vcl::Window::RequestHelp( rHEvt ); } -void ChartWindow::LogicMouseButtonDown(const MouseEvent& rEvent) -{ - MouseButtonDown(rEvent); -} - -void ChartWindow::LogicMouseButtonUp(const MouseEvent& rEvent) -{ - MouseButtonUp(rEvent); -} - -void ChartWindow::LogicMouseMove(const MouseEvent& rEvent) -{ - MouseMove(rEvent); -} - void ChartWindow::adjustHighContrastMode() { static const DrawModeFlags nContrastMode = @@ -259,23 +246,11 @@ void ChartWindow::ForceInvalidate() { vcl::Window::Invalidate(); } -void ChartWindow::Invalidate( InvalidateFlags nFlags ) +void ChartWindow::ImplInvalidate( const vcl::Region* rRegion, InvalidateFlags nFlags ) { if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" return; - vcl::Window::Invalidate( nFlags ); -} -void ChartWindow::Invalidate( const tools::Rectangle& rRect, InvalidateFlags nFlags ) -{ - if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" - return; - vcl::Window::Invalidate( rRect, nFlags ); -} -void ChartWindow::Invalidate( const vcl::Region& rRegion, InvalidateFlags nFlags ) -{ - if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" - return; - vcl::Window::Invalidate( rRegion, nFlags ); + vcl::Window::ImplInvalidate( rRegion, nFlags ); } void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle) @@ -283,11 +258,11 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle) SfxViewShell* pCurrentShell = SfxViewShell::Current(); if ( nullptr == pCurrentShell ) return; - OString sRectangle; + tools::Rectangle aResultRectangle; if (!pRectangle) { // we have to invalidate the whole chart area not the whole document - sRectangle = GetBoundingBox().toString(); + aResultRectangle = GetBoundingBox(); } else { @@ -296,7 +271,9 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle) if (IsMapModeEnabled()) { if (GetMapMode().GetMapUnit() == MapUnit::Map100thMM) - aRectangle = OutputDevice::LogicToLogic(aRectangle, MapMode(MapUnit::Map100thMM), MapMode(MapUnit::MapTwip)); + { + aRectangle = o3tl::convert(aRectangle, o3tl::Length::mm100, o3tl::Length::twip); + } } else { @@ -307,27 +284,28 @@ void ChartWindow::LogicInvalidate(const tools::Rectangle* pRectangle) if (pEditWin) { MapMode aCWMapMode = GetMapMode(); - double fXScale( aCWMapMode.GetScaleX() ); - double fYScale( aCWMapMode.GetScaleY() ); + constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip); + const auto& scaleX = aCWMapMode.GetScaleX(); + const auto& scaleY = aCWMapMode.GetScaleY(); + const auto nXNum = p.first * scaleX.GetDenominator(); + const auto nXDen = p.second * scaleX.GetNumerator(); + const auto nYNum = p.first * scaleY.GetDenominator(); + const auto nYDen = p.second * scaleY.GetNumerator(); if (!IsMapModeEnabled()) { - aRectangle.SetLeft( aRectangle.Left() / fXScale ); - aRectangle.SetRight( aRectangle.Right() / fXScale ); - aRectangle.SetTop( aRectangle.Top() / fYScale ); - aRectangle.SetBottom( aRectangle.Bottom() / fYScale ); + aRectangle = aRectangle.scale(scaleX.GetDenominator(), scaleX.GetNumerator(), + scaleY.GetDenominator(), scaleY.GetNumerator()); } - Point aOffset = this->GetOffsetPixelFrom(*pEditWin); - aOffset.setX( aOffset.X() * (TWIPS_PER_PIXEL / fXScale) ); - aOffset.setY( aOffset.Y() * (TWIPS_PER_PIXEL / fYScale) ); + Point aOffset = this->GetOffsetPixelFrom(*pEditWin).scale(nXNum, nXDen, nYNum, nYDen); aRectangle = tools::Rectangle(aRectangle.TopLeft() + aOffset, aRectangle.GetSize()); } - sRectangle = aRectangle.toString(); + aResultRectangle = aRectangle; } - SfxLokHelper::notifyInvalidation(pCurrentShell, sRectangle); + SfxLokHelper::notifyInvalidation(pCurrentShell, &aResultRectangle); } FactoryFunction ChartWindow::GetUITestFactory() const @@ -374,14 +352,20 @@ tools::Rectangle ChartWindow::GetBoundingBox() // In all cases, the following code fragment // returns the chart bounding box in twips. MapMode aCWMapMode = GetMapMode(); - double fXScale( aCWMapMode.GetScaleX() ); - double fYScale( aCWMapMode.GetScaleY() ); + constexpr auto p = o3tl::getConversionMulDiv(o3tl::Length::px, o3tl::Length::twip); + const auto& scaleX = aCWMapMode.GetScaleX(); + const auto& scaleY = aCWMapMode.GetScaleY(); + const auto nXNum = p.first * scaleX.GetDenominator(); + const auto nXDen = p.second * scaleX.GetNumerator(); + const auto nYNum = p.first * scaleY.GetDenominator(); + const auto nYDen = p.second * scaleY.GetNumerator(); + Point aOffset = GetOffsetPixelFrom(*pRootWin); - aOffset.setX( aOffset.X() * (TWIPS_PER_PIXEL / fXScale) ); - aOffset.setY( aOffset.Y() * (TWIPS_PER_PIXEL / fYScale) ); + aOffset.setX( o3tl::convert(aOffset.X(), nXNum, nXDen) ); + aOffset.setY( o3tl::convert(aOffset.Y(), nYNum, nYDen) ); Size aSize = GetSizePixel(); - aSize.setWidth( aSize.Width() * (TWIPS_PER_PIXEL / fXScale) ); - aSize.setHeight( aSize.Height() * (TWIPS_PER_PIXEL / fYScale) ); + aSize.setWidth( o3tl::convert(aSize.Width(), nXNum, nXDen) ); + aSize.setHeight( o3tl::convert(aSize.Height(), nYNum, nYDen) ); aBBox = tools::Rectangle(aOffset, aSize); } return aBBox; diff --git a/chart2/source/controller/main/CommandDispatch.cxx b/chart2/source/controller/main/CommandDispatch.cxx index ed6370a5228b..2cb25f68d5bf 100644 --- a/chart2/source/controller/main/CommandDispatch.cxx +++ b/chart2/source/controller/main/CommandDispatch.cxx @@ -19,7 +19,6 @@ #include "CommandDispatch.hxx" #include <com/sun/star/util/URLTransformer.hpp> -#include <tools/diagnose_ex.h> using namespace ::com::sun::star; @@ -31,7 +30,6 @@ namespace chart CommandDispatch::CommandDispatch( const Reference< uno::XComponentContext > & xContext ) : - impl::CommandDispatch_Base( m_aMutex ), m_xContext( xContext ) { } @@ -44,17 +42,11 @@ void CommandDispatch::initialize() // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed -void SAL_CALL CommandDispatch::disposing() +void CommandDispatch::disposing(std::unique_lock<std::mutex>& rGuard) { Reference< uno::XInterface > xEventSource(static_cast< cppu::OWeakObject* >( this )); for( auto& rElement : m_aListeners ) - { - if( rElement.second ) - { - rElement.second->disposeAndClear( xEventSource ); - rElement.second.reset(); - } - } + rElement.second.disposeAndClear( rGuard, xEventSource ); m_aListeners.clear(); } @@ -64,24 +56,29 @@ void SAL_CALL CommandDispatch::dispatch( const util::URL& /* URL */, const Seque void SAL_CALL CommandDispatch::addStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) { - tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); - if( aIt == m_aListeners.end()) { - aIt = m_aListeners.insert( - m_aListeners.begin(), - tListenerMap::value_type( URL.Complete, new ::comphelper::OInterfaceContainerHelper2( m_aMutex ))); - } - OSL_ASSERT( aIt != m_aListeners.end()); + std::unique_lock g(m_aMutex); + tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); + if( aIt == m_aListeners.end()) + { + aIt = m_aListeners.emplace( + std::piecewise_construct, + std::forward_as_tuple(URL.Complete), + std::forward_as_tuple()).first; + } + assert( aIt != m_aListeners.end()); - aIt->second->addInterface( Control ); + aIt->second.addInterface( g, Control ); + } fireStatusEvent( URL.Complete, Control ); } void SAL_CALL CommandDispatch::removeStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) { + std::unique_lock g(m_aMutex); tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); if( aIt != m_aListeners.end()) - (*aIt).second->removeInterface( Control ); + (*aIt).second.removeInterface( g, Control ); } // ____ XModifyListener ____ @@ -132,24 +129,8 @@ void CommandDispatch::fireStatusEventForURL( tListenerMap::iterator aIt( m_aListeners.find( aURL.Complete )); if( aIt != m_aListeners.end()) { - if( aIt->second ) - { - ::comphelper::OInterfaceIteratorHelper2 aIntfIt( *((*aIt).second) ); - - while( aIntfIt.hasMoreElements()) - { - Reference< frame::XStatusListener > xListener( aIntfIt.next(), uno::UNO_QUERY ); - try - { - if( xListener.is()) - xListener->statusChanged( aEventToSend ); - } - catch( const uno::Exception & ) - { - DBG_UNHANDLED_EXCEPTION("chart2"); - } - } - } + std::unique_lock g(m_aMutex); + aIt->second.notifyEach(g, &css::frame::XStatusListener::statusChanged, aEventToSend); } } } diff --git a/chart2/source/controller/main/CommandDispatch.hxx b/chart2/source/controller/main/CommandDispatch.hxx index 37de7c59c119..feb1c2183af5 100644 --- a/chart2/source/controller/main/CommandDispatch.hxx +++ b/chart2/source/controller/main/CommandDispatch.hxx @@ -18,14 +18,12 @@ */ #pragma once -#include <MutexContainer.hxx> -#include <cppuhelper/compbase.hxx> -#include <comphelper/interfacecontainer2.hxx> +#include <comphelper/compbase.hxx> +#include <comphelper/interfacecontainer4.hxx> #include <com/sun/star/frame/XDispatch.hpp> #include <com/sun/star/util/XModifyListener.hpp> #include <map> -#include <memory> namespace com::sun::star::uno { class XComponentContext; } namespace com::sun::star::util { class XURLTransformer; } @@ -35,7 +33,7 @@ namespace chart namespace impl { -typedef ::cppu::WeakComponentImplHelper< +typedef ::comphelper::WeakComponentImplHelper< css::frame::XDispatch, css::util::XModifyListener > CommandDispatch_Base; @@ -43,9 +41,7 @@ typedef ::cppu::WeakComponentImplHelper< /** This is the base class for an XDispatch. */ -class CommandDispatch : - public MutexContainer, - public impl::CommandDispatch_Base +class CommandDispatch : public impl::CommandDispatch_Base { public: explicit CommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext ); @@ -107,7 +103,7 @@ protected: // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // ____ XModifyListener ____ virtual void SAL_CALL modified( @@ -121,7 +117,7 @@ private: css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer; - typedef std::map< OUString, std::unique_ptr<::comphelper::OInterfaceContainerHelper2> > + typedef std::map< OUString, ::comphelper::OInterfaceContainerHelper4<css::frame::XStatusListener> > tListenerMap; tListenerMap m_aListeners; diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx index dee4c961358e..7304c8e48e4e 100644 --- a/chart2/source/controller/main/CommandDispatchContainer.cxx +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -23,10 +23,11 @@ #include <DisposeHelper.hxx> #include "DrawCommandDispatch.hxx" #include "ShapeController.hxx" +#include <ChartModel.hxx> #include <com/sun/star/frame/XDispatchProvider.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> +#include <osl/diagnose.h> #include <rtl/ref.hxx> #include <o3tl/sorted_vector.hxx> @@ -48,18 +49,18 @@ CommandDispatchContainer::CommandDispatchContainer( } void CommandDispatchContainer::setModel( - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { // remove all existing dispatcher that base on the old model m_aCachedDispatches.clear(); DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); m_aToBeDisposedDispatches.clear(); - m_xModel = xModel; + m_xModel = xModel.get(); } void CommandDispatchContainer::setChartDispatch( const Reference< frame::XDispatch >& rChartDispatch, - const o3tl::sorted_vector< OUString > & rChartCommands ) + const o3tl::sorted_vector< std::u16string_view > & rChartCommands ) { OSL_ENSURE(rChartDispatch.is(),"Invalid fall back dispatcher!"); m_xChartDispatcher.set( rChartDispatch ); @@ -70,10 +71,10 @@ void CommandDispatchContainer::setChartDispatch( Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( const util::URL & rURL ) { - static const o3tl::sorted_vector< OUString > s_aContainerDocumentCommands { - "AddDirect", "NewDoc", "Open", - "Save", "SaveAs", "SendMail", - "EditDoc", "ExportDirectToPDF", "PrintDefault"}; + static const o3tl::sorted_vector< std::u16string_view > s_aContainerDocumentCommands { + u"AddDirect", u"NewDoc", u"Open", + u"Save", u"SaveAs", u"SendMail", + u"EditDoc", u"ExportDirectToPDF", u"PrintDefault"}; Reference< frame::XDispatch > xResult; tDispatchMap::const_iterator aIt( m_aCachedDispatches.find( rURL.Complete )); @@ -81,59 +82,56 @@ Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( { xResult.set( (*aIt).second ); } - else + else if (rtl::Reference<::chart::ChartModel> xModel{ m_xModel }) { - uno::Reference< frame::XModel > xModel( m_xModel ); - - if( xModel.is() && ( rURL.Path == "Undo" || rURL.Path == "Redo" || - rURL.Path == "GetUndoStrings" || rURL.Path == "GetRedoStrings" ) ) + if (rURL.Path == "Undo" || rURL.Path == "Redo" || + rURL.Path == "GetUndoStrings" || rURL.Path == "GetRedoStrings") { rtl::Reference<CommandDispatch> pDispatch = new UndoCommandDispatch( m_xContext, xModel ); xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ ".uno:Undo" ].set( xResult ); - m_aCachedDispatches[ ".uno:Redo" ].set( xResult ); - m_aCachedDispatches[ ".uno:GetUndoStrings" ].set( xResult ); - m_aCachedDispatches[ ".uno:GetRedoStrings" ].set( xResult ); + m_aCachedDispatches[ u".uno:Undo"_ustr ].set( xResult ); + m_aCachedDispatches[ u".uno:Redo"_ustr ].set( xResult ); + m_aCachedDispatches[ u".uno:GetUndoStrings"_ustr ].set( xResult ); + m_aCachedDispatches[ u".uno:GetRedoStrings"_ustr ].set( xResult ); m_aToBeDisposedDispatches.push_back( xResult ); } - else if( xModel.is() && ( rURL.Path == "Context" || rURL.Path == "ModifiedStatus" ) ) + else if (rURL.Path == "Context" || rURL.Path == "ModifiedStatus") { Reference< view::XSelectionSupplier > xSelSupp( xModel->getCurrentController(), uno::UNO_QUERY ); rtl::Reference<CommandDispatch> pDispatch = new StatusBarCommandDispatch( m_xContext, xModel, xSelSupp ); xResult.set( pDispatch ); pDispatch->initialize(); - m_aCachedDispatches[ ".uno:Context" ].set( xResult ); - m_aCachedDispatches[ ".uno:ModifiedStatus" ].set( xResult ); + m_aCachedDispatches[ u".uno:Context"_ustr ].set( xResult ); + m_aCachedDispatches[ u".uno:ModifiedStatus"_ustr ].set( xResult ); m_aToBeDisposedDispatches.push_back( xResult ); } - else if( xModel.is() && - (s_aContainerDocumentCommands.find( rURL.Path ) != s_aContainerDocumentCommands.end()) ) + else if (s_aContainerDocumentCommands.find( std::u16string_view(rURL.Path) ) != s_aContainerDocumentCommands.end()) { xResult.set( getContainerDispatchForURL( xModel->getCurrentController(), rURL )); // ToDo: can those dispatches be cached? m_aCachedDispatches[ rURL.Complete ].set( xResult ); } - else if( m_xChartDispatcher.is() && - (m_aChartCommands.find( rURL.Path ) != m_aChartCommands.end()) ) - { - xResult.set( m_xChartDispatcher ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } - // #i12587# support for shapes in chart - // Note, that the chart dispatcher must be queried first, because - // the chart dispatcher is the default dispatcher for all context - // sensitive commands. - else if ( m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported( rURL.Complete ) ) - { - xResult.set( m_pDrawCommandDispatch ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } - else if ( m_pShapeController && m_pShapeController->isFeatureSupported( rURL.Complete ) ) - { - xResult.set( m_pShapeController ); - m_aCachedDispatches[ rURL.Complete ].set( xResult ); - } + } + else if (m_xChartDispatcher.is() + && (m_aChartCommands.find(rURL.Path) != m_aChartCommands.end())) + { + xResult.set( m_xChartDispatcher ); + m_aCachedDispatches[ rURL.Complete ].set( xResult ); + } + // #i12587# support for shapes in chart + // Note, that the chart dispatcher must be queried first, because + // the chart dispatcher is the default dispatcher for all context + // sensitive commands. + else if ( m_pDrawCommandDispatch && m_pDrawCommandDispatch->isFeatureSupported( rURL.Complete ) ) + { + xResult.set( m_pDrawCommandDispatch ); + m_aCachedDispatches[ rURL.Complete ].set( xResult ); + } + else if ( m_pShapeController && m_pShapeController->isFeatureSupported( rURL.Complete ) ) + { + xResult.set( m_pShapeController ); + m_aCachedDispatches[ rURL.Complete ].set( xResult ); } return xResult; @@ -144,11 +142,12 @@ Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatche { sal_Int32 nCount = aDescriptors.getLength(); uno::Sequence< uno::Reference< frame::XDispatch > > aRet( nCount ); + auto aRetRange = asNonConstRange(aRet); for( sal_Int32 nPos = 0; nPos < nCount; ++nPos ) { if ( aDescriptors[ nPos ].FrameName == "_self" ) - aRet[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); + aRetRange[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); } return aRet; } @@ -176,7 +175,7 @@ Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForU { Reference< frame::XDispatchProvider > xDispProv( xFrame->getCreator(), uno::UNO_QUERY ); if( xDispProv.is()) - xResult.set( xDispProv->queryDispatch( rURL, "_self", 0 )); + xResult.set( xDispProv->queryDispatch( rURL, u"_self"_ustr, 0 )); } } return xResult; diff --git a/chart2/source/controller/main/ConfigurationAccess.cxx b/chart2/source/controller/main/ConfigurationAccess.cxx deleted file mode 100644 index 4040c8db1b8d..000000000000 --- a/chart2/source/controller/main/ConfigurationAccess.cxx +++ /dev/null @@ -1,98 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ - -#include <ConfigurationAccess.hxx> - -#include <unotools/syslocale.hxx> -#include <unotools/configitem.hxx> -#include <unotools/localedatawrapper.hxx> -#include <rtl/instance.hxx> - -namespace chart -{ -using namespace ::com::sun::star; - -namespace -{ -bool lcl_IsMetric() -{ - SvtSysLocale aSysLocale; - MeasurementSystem eSys = aSysLocale.GetLocaleData().getMeasurementSystemEnum(); - - return ( eSys == MeasurementSystem::Metric ); -} - -class CalcConfigItem : public ::utl::ConfigItem -{ -private: - virtual void ImplCommit() override; - -public: - CalcConfigItem(); - - FieldUnit getFieldUnit(); - virtual void Notify( const uno::Sequence<OUString>& aPropertyNames) override; -}; - -}//end anonymous namespace - -CalcConfigItem::CalcConfigItem() - : ConfigItem( "Office.Calc/Layout" ) -{ -} - -void CalcConfigItem::ImplCommit() {} -void CalcConfigItem::Notify( const uno::Sequence<OUString>& ) {} - -FieldUnit CalcConfigItem::getFieldUnit() -{ - FieldUnit eResult( FieldUnit::CM ); - - uno::Sequence< OUString > aNames( 1 ); - if( lcl_IsMetric() ) - aNames[ 0 ] = "Other/MeasureUnit/Metric"; - else - aNames[ 0 ] = "Other/MeasureUnit/NonMetric"; - - uno::Sequence< uno::Any > aResult( GetProperties( aNames )); - sal_Int32 nValue = 0; - if( aResult[ 0 ] >>= nValue ) - eResult = static_cast< FieldUnit >( nValue ); - - return eResult; -} - -namespace -{ - //a CalcConfigItem Singleton - struct theCalcConfigItem : public rtl::Static< CalcConfigItem, theCalcConfigItem > {}; -} - -namespace ConfigurationAccess -{ - FieldUnit getFieldUnit() - { - FieldUnit aUnit( theCalcConfigItem::get().getFieldUnit() ); - return aUnit; - } -} //namespace ConfigurationAccess - -} //namespace chart - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx index 2f0e13f56155..e6abe080a655 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.cxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -18,34 +18,35 @@ */ #include "ControllerCommandDispatch.hxx" -#include <ChartModelHelper.hxx> #include <ChartModel.hxx> -#include <DiagramHelper.hxx> +#include <Diagram.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> #include <TitleHelper.hxx> #include <LegendHelper.hxx> #include <ObjectIdentifier.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <ChartController.hxx> #include <RegressionCurveHelper.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> #include <StatisticsHelper.hxx> #include <ReferenceSizeProvider.hxx> +#include <RegressionCurveModel.hxx> #include "ShapeController.hxx" +#include <CharacterProperties.hxx> #include <vcl/svapp.hxx> #include <sal/log.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <comphelper/lok.hxx> #include <sfx2/viewsh.hxx> #include <sfx2/objsh.hxx> -#include <com/sun/star/util/XModifyBroadcaster.hpp> -#include <com/sun/star/frame/XStorable.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/chart2/XRegressionCurve.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart2/XDataProviderAccess.hpp> +#include <com/sun/star/frame/status/FontHeight.hpp> // only needed until #i68864# is fixed #include <com/sun/star/frame/XLayoutManager.hpp> @@ -68,14 +69,34 @@ bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController if( xPropSet.is() ) { uno::Reference< css::frame::XLayoutManager > xLayoutManager; - xPropSet->getPropertyValue( "LayoutManager" ) >>= xLayoutManager; + xPropSet->getPropertyValue( u"LayoutManager"_ustr ) >>= xLayoutManager; if ( xLayoutManager.is() ) - bIsStatusBarVisible = xLayoutManager->isElementVisible( "private:resource/statusbar/statusbar" ); + bIsStatusBarVisible = xLayoutManager->isElementVisible( u"private:resource/statusbar/statusbar"_ustr ); } } return bIsStatusBarVisible; } +bool lcl_arePropertiesSame(std::vector<Reference<beans::XPropertySet>>& xProperties, + const OUString& aPropName) +{ + if (xProperties.size() == 1) + return true; + if (xProperties.size() < 1) + return false; + + if (!xProperties[0]) + return false; + + uno::Any aValue = xProperties[0]->getPropertyValue(aPropName); + for (std::size_t i = 1; i < xProperties.size(); i++) + { + if (xProperties[i] && aValue != xProperties[i]->getPropertyValue(aPropName)) + return false; + } + return true; +} + } // anonymous namespace namespace chart @@ -106,7 +127,7 @@ struct ControllerState ControllerState(); void update( const Reference< frame::XController > & xController, - const Reference< frame::XModel > & xModel ); + const rtl::Reference<::chart::ChartModel> & xModel ); // -- State variables ------- bool bHasSelectedObject; @@ -173,7 +194,7 @@ ControllerState::ControllerState() : void ControllerState::update( const Reference< frame::XController > & xController, - const Reference< frame::XModel > & xModel ) + const rtl::Reference<::chart::ChartModel> & xModel ) { Reference< view::XSelectionSupplier > xSelectionSupplier( xController, uno::UNO_QUERY ); @@ -184,7 +205,7 @@ void ControllerState::update( uno::Any aSelObj( xSelectionSupplier->getSelection() ); ObjectIdentifier aSelOID( aSelObj ); - OUString aSelObjCID( aSelOID.getObjectCID() ); + const OUString& aSelObjCID( aSelOID.getObjectCID() ); bHasSelectedObject = aSelOID.isValid(); @@ -193,24 +214,22 @@ void ControllerState::update( bIsPositionableObject = (aObjectType != OBJECTTYPE_DATA_POINT) && aSelOID.isDragableObject(); bIsTextObject = aObjectType == OBJECTTYPE_TITLE; - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); bIsFormateableObjectSelected = bHasSelectedObject && aSelOID.isAutoGeneratedObject(); if( aObjectType==OBJECTTYPE_DIAGRAM || aObjectType==OBJECTTYPE_DIAGRAM_WALL || aObjectType==OBJECTTYPE_DIAGRAM_FLOOR ) - bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + bIsFormateableObjectSelected = xDiagram->isSupportingFloorAndWall(); - uno::Reference< chart2::XDataSeries > xGivenDataSeries( + rtl::Reference< DataSeries > xGivenDataSeries = ObjectIdentifier::getDataSeriesForCID( - aSelObjCID, xModel ) ); + aSelObjCID, xModel ); bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); - bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), + bMayMoveSeriesForward = (aObjectType!=OBJECTTYPE_DATA_POINT) && xDiagram && xDiagram->isSeriesMoveable( xGivenDataSeries, MOVE_SERIES_FORWARD ); - bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && DiagramHelper::isSeriesMoveable( - ChartModelHelper::findDiagram( xModel ), + bMayMoveSeriesBackward = (aObjectType!=OBJECTTYPE_DATA_POINT) && xDiagram && xDiagram->isSeriesMoveable( xGivenDataSeries, MOVE_SERIES_BACKWARD ); @@ -238,29 +257,25 @@ void ControllerState::update( if( xGivenDataSeries.is()) { bMayAddMenuTrendline = true; - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xFirstChartType( + sal_Int32 nDimensionCount = xDiagram->getDimension(); + rtl::Reference< ::chart::ChartType > xFirstChartType( DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); // trend lines/mean value line if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) - && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) + && xFirstChartType.is() ? xFirstChartType->isSupportingRegressionProperties(nDimensionCount) : true) { - uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xGivenDataSeries, uno::UNO_QUERY ); - if( xRegCurveCnt.is()) - { - // Trendline - bMayAddTrendline = true; + // Trendline + bMayAddTrendline = true; - // Mean Value - bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); - bMayAddMeanValue = ! bMayDeleteMeanValue; - } + // Mean Value + bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xGivenDataSeries ); + bMayAddMeanValue = ! bMayDeleteMeanValue; } // error bars if( (aObjectType == OBJECTTYPE_DATA_SERIES || aObjectType == OBJECTTYPE_DATA_POINT) - && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount )) + && xFirstChartType.is() ? xFirstChartType->isSupportingStatisticProperties(nDimensionCount) : true) { bMayFormatXErrorBars = bMayDeleteXErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries, false ); bMayAddXErrorBars = ! bMayDeleteXErrorBars; @@ -283,29 +298,34 @@ void ControllerState::update( { bMayFormatTrendline = true; bMayDeleteTrendline = true; - uno::Reference< chart2::XRegressionCurve > xRegCurve( - ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); + rtl::Reference< RegressionCurveModel > xRegCurve( + dynamic_cast<RegressionCurveModel*>(ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ).get()) ); // Trendline Equation bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; + bMayAddR2Value = RegressionCurveHelper::MayHaveCorrelationCoefficient( xRegCurve ) && bMayAddTrendlineEquation; } else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) { bMayFormatTrendlineEquation = true; bool bHasR2Value = false; + bool bMayHaveR2 = true; try { uno::Reference< beans::XPropertySet > xEquationProperties = ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ); if( xEquationProperties.is() ) - xEquationProperties->getPropertyValue( "ShowCorrelationCoefficient" ) >>= bHasR2Value; + { + xEquationProperties->getPropertyValue( u"ShowCorrelationCoefficient"_ustr ) >>= bHasR2Value; + xEquationProperties->getPropertyValue( u"MayHaveCorrelationCoefficient"_ustr ) >>= bMayHaveR2; + } } catch(const uno::RuntimeException&) { TOOLS_WARN_EXCEPTION("chart2", "" ); } - bMayAddR2Value = !bHasR2Value; + bMayAddR2Value = !bHasR2Value && bMayHaveR2; bMayDeleteR2Value = bHasR2Value; } } @@ -325,7 +345,7 @@ struct ModelState { ModelState(); - void update( const Reference< frame::XModel > & xModel ); + void update( const rtl::Reference<::chart::ChartModel> & xModel ); bool HasAnyAxis() const; bool HasAnyGrid() const; @@ -364,6 +384,8 @@ struct ModelState bool bSupportsStatistics; bool bSupportsAxes; + + bool bDataTable = false; }; ModelState::ModelState() : @@ -397,28 +419,27 @@ ModelState::ModelState() : bSupportsAxes(false) {} -void ModelState::update( const Reference< frame::XModel > & xModel ) +void ModelState::update( const rtl::Reference<::chart::ChartModel> & xModel ) { - Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); - Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + rtl::Reference< Diagram > xDiagram = xModel->getFirstChartDiagram(); - bIsReadOnly = true; - Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY ); - if( xStorable.is()) - bIsReadOnly = xStorable->isReadonly(); + bIsReadOnly = xModel->isReadonly(); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + sal_Int32 nDimensionCount = 0; + if (xDiagram) + nDimensionCount = xDiagram->getDimension(); - uno::Reference< chart2::XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); - bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ); - bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 ); + rtl::Reference<ChartType> xFirstChartType; + if (xDiagram) + xFirstChartType = xDiagram->getChartTypeByIndex( 0 ); + bSupportsStatistics = xFirstChartType.is() ? xFirstChartType->isSupportingStatisticProperties(nDimensionCount) : true; + bSupportsAxes = xFirstChartType.is() ? xFirstChartType->isSupportingMainAxis(nDimensionCount, 0) : true; bIsThreeD = (nDimensionCount == 3); - if (xChartDoc.is()) + if (xModel.is()) { - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); - bHasOwnData = rModel.hasInternalDataProvider(); - bHasDataFromPivotTable = !bHasOwnData && rModel.isDataFromPivotTable(); + bHasOwnData = xModel->hasInternalDataProvider(); + bHasDataFromPivotTable = !bHasOwnData && xModel->isDataFromPivotTable(); } bHasMainTitle = TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is(); @@ -443,12 +464,14 @@ void ModelState::update( const Reference< frame::XModel > & xModel ) bHasHelpZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, false, xDiagram ); bHasAutoScaledText = - (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) == + (ReferenceSizeProvider::getAutoResizeState( xModel ) == ReferenceSizeProvider::AUTO_RESIZE_YES); bHasLegend = LegendHelper::hasLegend( xDiagram ); - bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + bHasWall = xDiagram && xDiagram->isSupportingFloorAndWall(); bHasFloor = bHasWall && bIsThreeD; + + bDataTable = xDiagram.is() && xDiagram->getDataTable().is(); } bool ModelState::HasAnyAxis() const @@ -491,11 +514,10 @@ void ControllerCommandDispatch::initialize() if( !m_xChartController.is()) return; - Reference< frame::XModel > xModel( m_xChartController->getModel()); - Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); - OSL_ASSERT( xModifyBroadcaster.is()); - if( xModifyBroadcaster.is()) - xModifyBroadcaster->addModifyListener( this ); + rtl::Reference<::chart::ChartModel> xModel( m_xChartController->getChartModel()); + OSL_ASSERT( xModel.is()); + if( xModel.is()) + xModel->addModifyListener( this ); // Listen selection modifications (Arrangement feature - issue 63017). if( m_xSelectionSupplier.is() ) @@ -532,6 +554,7 @@ void ControllerCommandDispatch::updateCommandAvailability() // read-only bool bIsWritable = bModelStateIsValid && (! m_apModelState->bIsReadOnly); bool bShapeContext = m_xChartController.is() && m_xChartController->isShapeContext(); + bool bIsTextEdit = m_xChartController.is() && m_xChartController->IsTextEdit(); bool bEnableDataTableDialog = false; bool bCanCreateDataProvider = false; @@ -543,7 +566,7 @@ void ControllerCommandDispatch::updateCommandAvailability() { try { - xProps->getPropertyValue("EnableDataTableDialog") >>= bEnableDataTableDialog; + xProps->getPropertyValue(u"EnableDataTableDialog"_ustr) >>= bEnableDataTableDialog; } catch( const uno::Exception& ) { @@ -551,160 +574,338 @@ void ControllerCommandDispatch::updateCommandAvailability() } } - Reference< chart2::XChartDocument > xChartDoc(m_xChartController->getModel(), uno::UNO_QUERY); - OSL_ENSURE(xChartDoc.is(), "Invalid XChartDocument"); - if ( xChartDoc.is() ) + rtl::Reference< ChartModel > xChartModel = m_xChartController->getChartModel(); + OSL_ENSURE(xChartModel.is(), "Invalid XChartDocument"); + if ( xChartModel.is() ) { - ChartModel& rModel = dynamic_cast<ChartModel&>(*xChartDoc); - css::uno::Reference< com::sun::star::chart2::XDataProviderAccess > xCreatorDoc(rModel.getParent(), uno::UNO_QUERY); + css::uno::Reference< css::chart2::XDataProviderAccess > xCreatorDoc(xChartModel->getParent(), uno::UNO_QUERY); bCanCreateDataProvider = xCreatorDoc.is(); } } // edit commands - m_aCommandAvailability[ ".uno:Cut" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; - m_aCommandAvailability[ ".uno:Copy" ] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; - m_aCommandAvailability[ ".uno:Paste" ] = bIsWritable; + m_aCommandAvailability[ u".uno:Cut"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; + m_aCommandAvailability[ u".uno:Copy"_ustr ] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; + m_aCommandAvailability[ u".uno:Paste"_ustr ] = bIsWritable; // toolbar commands - m_aCommandAvailability[ ".uno:ToggleGridHorizontal" ] = bIsWritable; - m_aCommandArguments[ ".uno:ToggleGridHorizontal" ] <<= m_apModelState->bHasMainYGrid; - m_aCommandAvailability[ ".uno:ToggleGridVertical" ] = bIsWritable; - m_aCommandArguments[ ".uno:ToggleGridVertical" ] <<= m_apModelState->bHasMainXGrid; - - m_aCommandAvailability[ ".uno:ToggleLegend" ] = bIsWritable; - m_aCommandArguments[ ".uno:ToggleLegend" ] <<= m_apModelState->bHasLegend; - - m_aCommandAvailability[ ".uno:NewArrangement" ] = bIsWritable; - m_aCommandAvailability[ ".uno:Update" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DefaultColors" ] = bIsWritable; - m_aCommandAvailability[ ".uno:BarWidth" ] = bIsWritable; - m_aCommandAvailability[ ".uno:NumberOfLines" ] = bIsWritable; - m_aCommandAvailability[ ".uno:ArrangeRow" ] = + m_aCommandAvailability[ u".uno:ToggleGridHorizontal"_ustr ] = bIsWritable; + m_aCommandArguments[ u".uno:ToggleGridHorizontal"_ustr ] <<= bModelStateIsValid && m_apModelState->bHasMainYGrid; + m_aCommandAvailability[ u".uno:ToggleGridVertical"_ustr ] = bIsWritable; + m_aCommandArguments[ u".uno:ToggleGridVertical"_ustr ] <<= bModelStateIsValid && m_apModelState->bHasMainXGrid; + + m_aCommandAvailability[ u".uno:ToggleLegend"_ustr ] = bIsWritable; + m_aCommandArguments[ u".uno:ToggleLegend"_ustr ] <<= bModelStateIsValid && m_apModelState->bHasLegend; + + m_aCommandAvailability[ u".uno:NewArrangement"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:Update"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DefaultColors"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:BarWidth"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:NumberOfLines"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:ArrangeRow"_ustr ] = bShapeContext || ( bIsWritable && bControllerStateIsValid && ( m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward ) ); // insert objects - m_aCommandAvailability[ ".uno:InsertTitles" ] = m_aCommandAvailability[ ".uno:InsertMenuTitles" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertLegend" ] = m_aCommandAvailability[ ".uno:InsertMenuLegend" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteLegend" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertMenuDataLabels" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertRemoveAxes" ] = m_aCommandAvailability[ ".uno:InsertMenuAxes" ] = bIsWritable && m_apModelState->bSupportsAxes; - m_aCommandAvailability[ ".uno:InsertMenuGrids" ] = bIsWritable && m_apModelState->bSupportsAxes; - m_aCommandAvailability[ ".uno:InsertMenuTrendlines" ] = bIsWritable && m_apModelState->bSupportsStatistics && m_apControllerState->bMayAddMenuTrendline; - m_aCommandAvailability[ ".uno:InsertMenuMeanValues" ] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ ".uno:InsertMenuXErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ ".uno:InsertMenuYErrorBars" ] = bIsWritable && m_apModelState->bSupportsStatistics; - m_aCommandAvailability[ ".uno:InsertSymbol" ] = bIsWritable && m_apControllerState->bIsTextObject; + m_aCommandAvailability[ u".uno:InsertTitles"_ustr ] = m_aCommandAvailability[ u".uno:InsertMenuTitles"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertLegend"_ustr ] = m_aCommandAvailability[ u".uno:InsertMenuLegend"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteLegend"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertMenuDataLabels"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertRemoveAxes"_ustr ] = m_aCommandAvailability[ u".uno:InsertMenuAxes"_ustr ] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ u".uno:InsertMenuGrids"_ustr ] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ u".uno:InsertMenuTrendlines"_ustr ] = bIsWritable && m_apModelState->bSupportsStatistics && bControllerStateIsValid && m_apControllerState->bMayAddMenuTrendline; + m_aCommandAvailability[ u".uno:InsertMenuMeanValues"_ustr ] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ u".uno:InsertMenuXErrorBars"_ustr ] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ u".uno:InsertMenuYErrorBars"_ustr ] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ u".uno:InsertSymbol"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsTextObject; + m_aCommandAvailability[ u".uno:InsertMenuDataTable"_ustr ] = bIsWritable; // format objects bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected; - m_aCommandAvailability[ ".uno:FormatSelection" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatAxis" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatTitle" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatDataSeries" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatDataPoint" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatDataLabels" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatDataLabel" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatXErrorBars; - m_aCommandAvailability[ ".uno:FormatYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars; - m_aCommandAvailability[ ".uno:FormatMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue; - m_aCommandAvailability[ ".uno:FormatTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline; - m_aCommandAvailability[ ".uno:FormatTrendlineEquation" ] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation; - m_aCommandAvailability[ ".uno:FormatStockLoss" ] = bFormatObjectAvailable; - m_aCommandAvailability[ ".uno:FormatStockGain" ] = bFormatObjectAvailable; - - m_aCommandAvailability[ ".uno:DiagramType" ] = bIsWritable; - m_aCommandAvailability[ ".uno:Legend" ] = bIsWritable && m_apModelState->bHasLegend; - m_aCommandAvailability[ ".uno:DiagramWall" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall; - m_aCommandAvailability[ ".uno:DiagramArea" ] = bIsWritable; - - m_aCommandAvailability[ ".uno:TransformDialog" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject; + m_aCommandAvailability[ u".uno:FormatSelection"_ustr ] = bFormatObjectAvailable && !bIsTextEdit; + m_aCommandAvailability[ u".uno:FontDialog"_ustr ] = (bShapeContext ? isShapeControllerCommandAvailable(u".uno:FontDialog"_ustr) : + bFormatObjectAvailable) && bIsTextEdit; + m_aCommandAvailability[ u".uno:FormatAxis"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatTitle"_ustr ] = bFormatObjectAvailable && !bIsTextEdit; + m_aCommandAvailability[ u".uno:FormatDataSeries"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatDataPoint"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatDataLabels"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatDataLabel"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatXErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatXErrorBars; + m_aCommandAvailability[ u".uno:FormatYErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars; + m_aCommandAvailability[ u".uno:FormatMeanValue"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue; + m_aCommandAvailability[ u".uno:FormatTrendline"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline; + m_aCommandAvailability[ u".uno:FormatTrendlineEquation"_ustr ] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation; + m_aCommandAvailability[ u".uno:FormatStockLoss"_ustr ] = bFormatObjectAvailable; + m_aCommandAvailability[ u".uno:FormatStockGain"_ustr ] = bFormatObjectAvailable; + + m_aCommandAvailability[ u".uno:DiagramType"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:Legend"_ustr ] = bIsWritable && m_apModelState->bHasLegend; + m_aCommandAvailability[ u".uno:DiagramWall"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall; + m_aCommandAvailability[ u".uno:DiagramArea"_ustr ] = bIsWritable; + + m_aCommandAvailability[ u".uno:TransformDialog"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject; // 3d commands - m_aCommandAvailability[ ".uno:View3D" ] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD; - m_aCommandAvailability[ ".uno:DiagramFloor" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor; + m_aCommandAvailability[ u".uno:View3D"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD; + m_aCommandAvailability[ u".uno:DiagramFloor"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor; //some more format commands with different ui text - m_aCommandAvailability[ ".uno:FormatWall" ] = m_aCommandAvailability[ ".uno:DiagramWall" ]; - m_aCommandAvailability[ ".uno:FormatFloor" ] = m_aCommandAvailability[ ".uno:DiagramFloor" ]; - m_aCommandAvailability[ ".uno:FormatChartArea" ] = m_aCommandAvailability[ ".uno:DiagramArea" ]; - m_aCommandAvailability[ ".uno:FormatLegend" ] = m_aCommandAvailability[ ".uno:Legend" ]; + m_aCommandAvailability[ u".uno:FormatWall"_ustr ] = m_aCommandAvailability[ u".uno:DiagramWall"_ustr ]; + m_aCommandAvailability[ u".uno:FormatFloor"_ustr ] = m_aCommandAvailability[ u".uno:DiagramFloor"_ustr ]; + m_aCommandAvailability[ u".uno:FormatChartArea"_ustr ] = m_aCommandAvailability[ u".uno:DiagramArea"_ustr ]; + m_aCommandAvailability[ u".uno:FormatLegend"_ustr ] = m_aCommandAvailability[ u".uno:Legend"_ustr ]; // depending on own data and ability to create new data provider - m_aCommandAvailability[".uno:DataRanges"] = bIsWritable && bModelStateIsValid && !m_apModelState->bHasDataFromPivotTable + m_aCommandAvailability[u".uno:DataRanges"_ustr] = bIsWritable && bModelStateIsValid && !m_apModelState->bHasDataFromPivotTable && ((m_apModelState->bHasOwnData && bCanCreateDataProvider) || !m_apModelState->bHasOwnData); - m_aCommandAvailability[ ".uno:DiagramData" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData && bEnableDataTableDialog; + m_aCommandAvailability[ u".uno:DiagramData"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData && bEnableDataTableDialog; // titles - m_aCommandAvailability[ ".uno:MainTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; - m_aCommandAvailability[ ".uno:SubTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle; - m_aCommandAvailability[ ".uno:XTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle; - m_aCommandAvailability[ ".uno:YTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle; - m_aCommandAvailability[ ".uno:ZTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle; - m_aCommandAvailability[ ".uno:SecondaryXTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryXAxisTitle; - m_aCommandAvailability[ ".uno:SecondaryYTitle" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryYAxisTitle; - m_aCommandAvailability[ ".uno:AllTitles" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle(); + m_aCommandAvailability[ u".uno:MainTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; + m_aCommandAvailability[ u".uno:SubTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle; + m_aCommandAvailability[ u".uno:XTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle; + m_aCommandAvailability[ u".uno:YTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle; + m_aCommandAvailability[ u".uno:ZTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle; + m_aCommandAvailability[ u".uno:SecondaryXTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryXAxisTitle; + m_aCommandAvailability[ u".uno:SecondaryYTitle"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryYAxisTitle; + m_aCommandAvailability[ u".uno:AllTitles"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle(); // text - m_aCommandAvailability[ ".uno:ScaleText" ] = bIsWritable && bModelStateIsValid ; - m_aCommandArguments[ ".uno:ScaleText" ] <<= m_apModelState->bHasAutoScaledText; + m_aCommandAvailability[ u".uno:ScaleText"_ustr ] = bIsWritable && bModelStateIsValid ; + m_aCommandArguments[ u".uno:ScaleText"_ustr ] <<= bModelStateIsValid && m_apModelState->bHasAutoScaledText; + + bool bTitleIsInEditMode = false; + try + { + OUString aObjectCID2 = m_xChartController->getSelectionMember().getSelectedCID(); + if (!aObjectCID2.isEmpty()) + if (ObjectIdentifier::getObjectType(aObjectCID2) == OBJECTTYPE_TITLE) + if (m_xChartController->GetDrawViewWrapper()) + if (m_xChartController->GetDrawViewWrapper()->GetTextEditOutlinerView()) + bTitleIsInEditMode = true; + } + catch (const uno::Exception&) { TOOLS_WARN_EXCEPTION("chart2", ""); } + + bool bEnableUnoCommands = bIsWritable && bModelStateIsValid && !bTitleIsInEditMode; + m_aCommandAvailability[u".uno:Bold"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Strikeout"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:CharFontName"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:FontHeight"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Italic"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Underline"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Shadowed"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Color"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:FontColor"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Grow"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Shrink"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:SuperScript"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:SubScript"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:Spacing"_ustr] = bEnableUnoCommands; + m_aCommandAvailability[u".uno:ResetAttributes"_ustr] = bEnableUnoCommands; + + if (!bTitleIsInEditMode) + { + // at default they are not filled in the sidebar + m_aCommandArguments[u".uno:CharFontName"_ustr] <<= false; + m_aCommandArguments[u".uno:FontHeight"_ustr] <<= false; + m_aCommandArguments[u".uno:Bold"_ustr] <<= false; + m_aCommandArguments[u".uno:Strikeout"_ustr] <<= false; + m_aCommandArguments[u".uno:Italic"_ustr] <<= false; + m_aCommandArguments[u".uno:Underline"_ustr] <<= false; + m_aCommandArguments[u".uno:Shadowed"_ustr] <<= false; + m_aCommandArguments[u".uno:Color"_ustr] <<= false; + m_aCommandArguments[u".uno:FontColor"_ustr] <<= false; + m_aCommandArguments[u".uno:SuperScript"_ustr] <<= false; + m_aCommandArguments[u".uno:SubScript"_ustr] <<= false; + m_aCommandArguments[u".uno:Spacing"_ustr] <<= false; + m_aCommandArguments[u".uno:ResetAttributes"_ustr] <<= false; + } + + // They are filled based on the text properties.. if there are only 1 + // but only those properties that are true for the whole text + try + { + // if title is selected, and in edit mode, then the font panel should be disabled + // enable the uno commands only if the title is not in edit mode + // Todo: enable font panel here if the panel will be able to handle edited title. + OUString aObjectCID = m_xChartController->getSelectionMember().getSelectedCID(); + if (!aObjectCID.isEmpty() && !bTitleIsInEditMode) + { + // If the selected is not title, then we should check the text properties.. + // or the selected text properties? + std::vector<Reference<beans::XPropertySet>> xProperties; + xProperties.emplace(xProperties.end(), + ObjectIdentifier::getObjectPropertySet( + aObjectCID, m_xChartController->getChartModel())); + + if (ObjectIdentifier::getObjectType(aObjectCID) == OBJECTTYPE_TITLE) + { + Reference<chart2::XTitle> xTitle(xProperties[0], uno::UNO_QUERY); + if (xTitle.is()) + { + const Sequence<Reference<chart2::XFormattedString>> aStrings(xTitle->getText()); + xProperties.pop_back(); + for (int i = 0; i < aStrings.getLength(); i++) + { + Reference<beans::XPropertySet> xTitlePropSet(aStrings[i], uno::UNO_QUERY); + xProperties.push_back(xTitlePropSet); + } + } + } + + Reference<beans::XMultiPropertySet> aMObjProps(xProperties[0], uno::UNO_QUERY); + if (aMObjProps) + { + awt::FontDescriptor aFont + = CharacterProperties::createFontDescriptorFromPropertySet(aMObjProps); + + if (!aFont.Name.isEmpty()) + { + OUString aPropName = u"CharFontName"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + m_aCommandArguments[u".uno:CharFontName"_ustr] <<= aFont; + } + } + } + OUString aPropName = u"CharHeight"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + uno::Any aAny = xProperties[0]->getPropertyValue(aPropName); + frame::status::FontHeight aFontHeight; + aAny >>= aFontHeight.Height; + // another type is needed here, so + m_aCommandArguments[u".uno:FontHeight"_ustr] <<= aFontHeight; + } + + aPropName = u"CharWeight"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + float nFontWeight(0.0); + xProperties[0]->getPropertyValue(aPropName) >>= nFontWeight; + bool bFontWeight = (nFontWeight > 100.0); + m_aCommandArguments[u".uno:Bold"_ustr] <<= bFontWeight; + } + + aPropName = u"CharPosture"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + awt::FontSlant nFontItalic; + xProperties[0]->getPropertyValue(aPropName) >>= nFontItalic; + bool bItalic = (nFontItalic == awt::FontSlant_ITALIC); + m_aCommandArguments[u".uno:Italic"_ustr] <<= bItalic; + } + + aPropName = u"CharStrikeout"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + sal_Int16 nFontStrikeout(0); + xProperties[0]->getPropertyValue(aPropName) >>= nFontStrikeout; + bool bFontStrikeout = (nFontStrikeout > 0); + m_aCommandArguments[u".uno:Strikeout"_ustr] <<= bFontStrikeout; + } + + aPropName = u"CharUnderline"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + sal_Int16 nFontUnderline(0); + xProperties[0]->getPropertyValue(aPropName) >>= nFontUnderline; + bool bFontUnderline = (nFontUnderline > 0); + m_aCommandArguments[u".uno:Underline"_ustr] <<= bFontUnderline; + } + + aPropName = u"CharShadowed"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + bool bShadowed = false; + xProperties[0]->getPropertyValue(aPropName) >>= bShadowed; + m_aCommandArguments[u".uno:Shadowed"_ustr] <<= bShadowed; + } + + // Font color is not set in panel... it is just enabled to use + m_aCommandArguments[u".uno:Color"_ustr] <<= false; + m_aCommandArguments[u".uno:FontColor"_ustr] <<= false; + + aPropName = u"CharEscapement"_ustr; + if (lcl_arePropertiesSame(xProperties, aPropName)) + { + sal_Int32 nCharEscapement = 0; + xProperties[0]->getPropertyValue(aPropName) >>= nCharEscapement; + m_aCommandArguments[u".uno:SuperScript"_ustr] <<= (nCharEscapement > 0); + m_aCommandArguments[u".uno:SubScript"_ustr] <<= (nCharEscapement < 0); + } + + // Font Spacing is not set in panel... it is just enabled to use + m_aCommandArguments[u".uno:Spacing"_ustr] <<= false; + } + } + catch (const uno::Exception&) + { + TOOLS_WARN_EXCEPTION("chart2", ""); + } // axes - m_aCommandAvailability[ ".uno:DiagramAxisX" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis; - m_aCommandAvailability[ ".uno:DiagramAxisY" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis; - m_aCommandAvailability[ ".uno:DiagramAxisZ" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis; - m_aCommandAvailability[ ".uno:DiagramAxisA" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis; - m_aCommandAvailability[ ".uno:DiagramAxisB" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis; - m_aCommandAvailability[ ".uno:DiagramAxisAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis(); + m_aCommandAvailability[ u".uno:DiagramAxisX"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis; + m_aCommandAvailability[ u".uno:DiagramAxisY"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis; + m_aCommandAvailability[ u".uno:DiagramAxisZ"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis; + m_aCommandAvailability[ u".uno:DiagramAxisA"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis; + m_aCommandAvailability[ u".uno:DiagramAxisB"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis; + m_aCommandAvailability[ u".uno:DiagramAxisAll"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis(); // grids // note: x and y are swapped in the commands! - m_aCommandAvailability[ ".uno:DiagramGridYMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid; - m_aCommandAvailability[ ".uno:DiagramGridXMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid; - m_aCommandAvailability[ ".uno:DiagramGridZMain" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid; - m_aCommandAvailability[ ".uno:DiagramGridYHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid; - m_aCommandAvailability[ ".uno:DiagramGridXHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid; - m_aCommandAvailability[ ".uno:DiagramGridZHelp" ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid; - m_aCommandAvailability[ ".uno:DiagramGridAll" ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid(); + m_aCommandAvailability[ u".uno:DiagramGridYMain"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid; + m_aCommandAvailability[ u".uno:DiagramGridXMain"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid; + m_aCommandAvailability[ u".uno:DiagramGridZMain"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid; + m_aCommandAvailability[ u".uno:DiagramGridYHelp"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid; + m_aCommandAvailability[ u".uno:DiagramGridXHelp"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid; + m_aCommandAvailability[ u".uno:DiagramGridZHelp"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid; + m_aCommandAvailability[ u".uno:DiagramGridAll"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid(); // series arrangement - m_aCommandAvailability[ ".uno:Forward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Forward" ) : + m_aCommandAvailability[ u".uno:Forward"_ustr ] = ( bShapeContext ? isShapeControllerCommandAvailable( u".uno:Forward"_ustr ) : ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward && bEnableDataTableDialog ) ); - m_aCommandAvailability[ ".uno:Backward" ] = ( bShapeContext ? isShapeControllerCommandAvailable( ".uno:Backward" ) : + m_aCommandAvailability[ u".uno:Backward"_ustr ] = ( bShapeContext ? isShapeControllerCommandAvailable( u".uno:Backward"_ustr ) : ( bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward && bEnableDataTableDialog ) ); - m_aCommandAvailability[ ".uno:InsertDataLabels" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertDataLabel" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue; - m_aCommandAvailability[ ".uno:InsertTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline; - m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation; - m_aCommandAvailability[ ".uno:InsertTrendlineEquationAndR2" ] = m_aCommandAvailability[ ".uno:InsertTrendlineEquation" ]; - m_aCommandAvailability[ ".uno:InsertR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value; - m_aCommandAvailability[ ".uno:DeleteR2Value" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value; - - m_aCommandAvailability[ ".uno:InsertXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddXErrorBars; - m_aCommandAvailability[ ".uno:InsertYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars; - - m_aCommandAvailability[ ".uno:DeleteDataLabels" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteDataLabel" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteTrendline" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline; - m_aCommandAvailability[ ".uno:DeleteTrendlineEquation" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation; - m_aCommandAvailability[ ".uno:DeleteMeanValue" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue; - m_aCommandAvailability[ ".uno:DeleteXErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteXErrorBars; - m_aCommandAvailability[ ".uno:DeleteYErrorBars" ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars; - - m_aCommandAvailability[ ".uno:ResetDataPoint" ] = bIsWritable; - m_aCommandAvailability[ ".uno:ResetAllDataPoints" ] = bIsWritable; - - m_aCommandAvailability[ ".uno:InsertAxis" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteAxis" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertAxisTitle" ] = bIsWritable; - m_aCommandAvailability[ ".uno:FormatMajorGrid" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertMajorGrid" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteMajorGrid" ] = bIsWritable; - m_aCommandAvailability[ ".uno:FormatMinorGrid" ] = bIsWritable; - m_aCommandAvailability[ ".uno:InsertMinorGrid" ] = bIsWritable; - m_aCommandAvailability[ ".uno:DeleteMinorGrid" ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertDataLabels"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertDataLabel"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertMeanValue"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue; + m_aCommandAvailability[ u".uno:InsertTrendline"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline; + const bool bInsertTrendlineEquation = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation; + m_aCommandAvailability[ u".uno:InsertTrendlineEquation"_ustr ] = bInsertTrendlineEquation; + m_aCommandAvailability[ u".uno:InsertTrendlineEquationAndR2"_ustr ] = bInsertTrendlineEquation && m_apControllerState->bMayAddR2Value; + m_aCommandAvailability[ u".uno:InsertR2Value"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value + && !m_apControllerState->bMayAddTrendlineEquation; + m_aCommandAvailability[ u".uno:DeleteR2Value"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value; + + m_aCommandAvailability[ u".uno:InsertXErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddXErrorBars; + m_aCommandAvailability[ u".uno:InsertYErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars; + + m_aCommandAvailability[ u".uno:DeleteDataLabels"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteDataLabel"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteTrendline"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline; + m_aCommandAvailability[ u".uno:DeleteTrendlineEquation"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation; + m_aCommandAvailability[ u".uno:DeleteMeanValue"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue; + m_aCommandAvailability[ u".uno:DeleteXErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteXErrorBars; + m_aCommandAvailability[ u".uno:DeleteYErrorBars"_ustr ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars; + + m_aCommandAvailability[ u".uno:ResetDataPoint"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:ResetAllDataPoints"_ustr ] = bIsWritable; + + m_aCommandAvailability[ u".uno:InsertAxis"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteAxis"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertAxisTitle"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:FormatMajorGrid"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertMajorGrid"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteMajorGrid"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:FormatMinorGrid"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:InsertMinorGrid"_ustr ] = bIsWritable; + m_aCommandAvailability[ u".uno:DeleteMinorGrid"_ustr ] = bIsWritable; + + // data table + m_aCommandAvailability[ u".uno:InsertDataTable"_ustr ] = bIsWritable && bModelStateIsValid && !m_apModelState->bDataTable; + m_aCommandAvailability[ u".uno:DeleteDataTable"_ustr ] = bIsWritable && bModelStateIsValid && m_apModelState->bDataTable; } bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand ) @@ -741,7 +942,7 @@ void ControllerCommandDispatch::fireStatusEvent( { uno::Any aArg; aArg <<= Reference< frame::XController >(m_xChartController); - fireStatusEventForURL( ".uno:ChartElementSelector", aArg, true, xSingleListener ); + fireStatusEventForURL( u".uno:ChartElementSelector"_ustr, aArg, true, xSingleListener ); } if( rURL.isEmpty() ) @@ -757,7 +958,7 @@ void ControllerCommandDispatch::fireStatusEvent( if( rURL.isEmpty() || rURL == ".uno:StatusBarVisible" ) { bool bIsStatusBarVisible( lcl_isStatusBarVisible( m_xChartController )); - fireStatusEventForURL( ".uno:StatusBarVisible", uno::Any( bIsStatusBarVisible ), true, xSingleListener ); + fireStatusEventForURL( u".uno:StatusBarVisible"_ustr, uno::Any( bIsStatusBarVisible ), true, xSingleListener ); } } @@ -772,7 +973,7 @@ void SAL_CALL ControllerCommandDispatch::dispatch( // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed -void SAL_CALL ControllerCommandDispatch::disposing() +void ControllerCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { m_xChartController.clear(); m_xDispatch.clear(); @@ -795,14 +996,14 @@ void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEve // Update the "ModelState" Struct. if( m_apModelState && m_xChartController.is()) { - m_apModelState->update( m_xChartController->getModel()); + m_apModelState->update( m_xChartController->getChartModel()); bUpdateCommandAvailability = true; } // Update the "ControllerState" Struct. if( m_apControllerState && m_xChartController.is()) { - m_apControllerState->update( m_xChartController, m_xChartController->getModel()); + m_apControllerState->update( m_xChartController, m_xChartController->getChartModel()); bUpdateCommandAvailability = true; } @@ -825,7 +1026,7 @@ void SAL_CALL ControllerCommandDispatch::selectionChanged( const lang::EventObje // Update the "ControllerState" Struct. if( m_apControllerState && m_xChartController.is()) { - m_apControllerState->update( m_xChartController, m_xChartController->getModel()); + m_apControllerState->update( m_xChartController, m_xChartController->getChartModel()); updateCommandAvailability(); } diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx b/chart2/source/controller/main/ControllerCommandDispatch.hxx index 38b00c48d8f0..6a5e441e8e3c 100644 --- a/chart2/source/controller/main/ControllerCommandDispatch.hxx +++ b/chart2/source/controller/main/ControllerCommandDispatch.hxx @@ -74,7 +74,7 @@ protected: // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // ____ XEventListener (base of XModifyListener) ____ virtual void SAL_CALL disposing( diff --git a/chart2/source/controller/main/DragMethod_Base.cxx b/chart2/source/controller/main/DragMethod_Base.cxx index 9e01d5c3bd7b..5e46dc327b19 100644 --- a/chart2/source/controller/main/DragMethod_Base.cxx +++ b/chart2/source/controller/main/DragMethod_Base.cxx @@ -19,30 +19,28 @@ #include "DragMethod_Base.hxx" #include <DrawViewWrapper.hxx> - +#include <ChartModel.hxx> #include <ObjectNameProvider.hxx> #include <ObjectIdentifier.hxx> #include <svx/ActionDescriptionProvider.hxx> -#include <com/sun/star/frame/XModel.hpp> +#include <utility> #include <vcl/ptrstyle.hxx> namespace chart { using namespace ::com::sun::star; -using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::WeakReference; DragMethod_Base::DragMethod_Base( DrawViewWrapper& rDrawViewWrapper - , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel + , OUString aObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel , ActionDescriptionProvider::ActionType eActionType ) : SdrDragMethod( rDrawViewWrapper ) , m_rDrawViewWrapper(rDrawViewWrapper) - , m_aObjectCID(rObjectCID) + , m_aObjectCID(std::move(aObjectCID)) , m_eActionType( eActionType ) - , m_xChartModel( WeakReference< frame::XModel >(xChartModel) ) + , m_xChartModel( xChartModel.get() ) { setMoveOnly(true); } @@ -50,9 +48,9 @@ DragMethod_Base::~DragMethod_Base() { } -Reference< frame::XModel > DragMethod_Base::getChartModel() const +rtl::Reference<::chart::ChartModel> DragMethod_Base::getChartModel() const { - return Reference< frame::XModel >( m_xChartModel ); + return m_xChartModel.get(); } OUString DragMethod_Base::getUndoDescription() const diff --git a/chart2/source/controller/main/DragMethod_Base.hxx b/chart2/source/controller/main/DragMethod_Base.hxx index b036da0e9fdf..df124406894c 100644 --- a/chart2/source/controller/main/DragMethod_Base.hxx +++ b/chart2/source/controller/main/DragMethod_Base.hxx @@ -20,19 +20,19 @@ #include <svx/ActionDescriptionProvider.hxx> #include <svx/svddrgmt.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace chart { class DrawViewWrapper; } -namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; class DragMethod_Base : public SdrDragMethod { public: - DragMethod_Base( DrawViewWrapper& rDrawViewWrapper, const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel + DragMethod_Base( DrawViewWrapper& rDrawViewWrapper, OUString aObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel , ActionDescriptionProvider::ActionType eActionType = ActionDescriptionProvider::ActionType::Move ); virtual ~DragMethod_Base() override; @@ -42,7 +42,7 @@ public: virtual PointerStyle GetSdrDragPointer() const override; protected: - css::uno::Reference< css::frame::XModel > getChartModel() const; + rtl::Reference<::chart::ChartModel> getChartModel() const; protected: DrawViewWrapper& m_rDrawViewWrapper; @@ -50,7 +50,7 @@ protected: ActionDescriptionProvider::ActionType m_eActionType; private: - css::uno::WeakReference< css::frame::XModel > m_xChartModel; + unotools::WeakReference<::chart::ChartModel> m_xChartModel; }; } // namespace chart diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx b/chart2/source/controller/main/DragMethod_PieSegment.cxx index 100846ba9357..f5145d276c99 100644 --- a/chart2/source/controller/main/DragMethod_PieSegment.cxx +++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx @@ -19,15 +19,14 @@ #include "DragMethod_PieSegment.hxx" #include <DrawViewWrapper.hxx> - +#include <ChartModel.hxx> #include <strings.hrc> #include <ResId.hxx> #include <ObjectIdentifier.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Point.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <basegfx/matrix/b2dhommatrix.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> namespace chart { @@ -38,7 +37,7 @@ using ::basegfx::B2DVector; DragMethod_PieSegment::DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel ) + , const rtl::Reference<::chart::ChartModel>& xChartModel ) : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel ) , m_aStartVector(100.0,100.0) , m_fInitialOffset(0.0) @@ -46,7 +45,7 @@ DragMethod_PieSegment::DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper , m_aDragDirection(1000.0,1000.0) , m_fDragRange( 1.0 ) { - OUString aParameter( ObjectIdentifier::getDragParameterString( m_aObjectCID ) ); + std::u16string_view aParameter( ObjectIdentifier::getDragParameterString( m_aObjectCID ) ); sal_Int32 nOffsetPercent(0); awt::Point aMinimumPosition(0,0); @@ -112,13 +111,13 @@ bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/) try { - Reference< frame::XModel > xChartModel( getChartModel() ); + rtl::Reference<::chart::ChartModel> xChartModel( getChartModel() ); if( xChartModel.is() ) { Reference< beans::XPropertySet > xPointProperties( ObjectIdentifier::getObjectPropertySet( m_aObjectCID, xChartModel ) ); if( xPointProperties.is() ) - xPointProperties->setPropertyValue( "Offset", uno::Any( m_fAdditionalOffset+m_fInitialOffset )); + xPointProperties->setPropertyValue( u"Offset"_ustr, uno::Any( m_fAdditionalOffset+m_fInitialOffset )); } } catch( const uno::Exception & ) @@ -128,7 +127,7 @@ bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/) return true; } -basegfx::B2DHomMatrix DragMethod_PieSegment::getCurrentTransformation() +basegfx::B2DHomMatrix DragMethod_PieSegment::getCurrentTransformation() const { basegfx::B2DHomMatrix aRetval; @@ -143,8 +142,8 @@ void DragMethod_PieSegment::createSdrDragEntries() if( pObj && pPV ) { - const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly()); - addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(aNewPolyPolygon))); + basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly()); + addSdrDragEntry(std::unique_ptr<SdrDragEntry>(new SdrDragEntryPolyPolygon(std::move(aNewPolyPolygon)))); } } } //namespace chart diff --git a/chart2/source/controller/main/DragMethod_PieSegment.hxx b/chart2/source/controller/main/DragMethod_PieSegment.hxx index 14090203272f..8cb498373f33 100644 --- a/chart2/source/controller/main/DragMethod_PieSegment.hxx +++ b/chart2/source/controller/main/DragMethod_PieSegment.hxx @@ -28,7 +28,7 @@ class DragMethod_PieSegment : public DragMethod_Base { public: DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper, const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel ); + , const rtl::Reference<::chart::ChartModel>& xChartModel ); virtual ~DragMethod_PieSegment() override; virtual OUString GetSdrDragComment() const override; @@ -36,7 +36,7 @@ public: virtual void MoveSdrDrag(const Point& rPnt) override; virtual bool EndSdrDrag(bool bCopy) override; - virtual basegfx::B2DHomMatrix getCurrentTransformation() override; + virtual basegfx::B2DHomMatrix getCurrentTransformation() const override; protected: virtual void createSdrDragEntries() override; diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx index 7501f0bf7204..68698f195bae 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -21,8 +21,9 @@ #include <DrawViewWrapper.hxx> #include <SelectionHelper.hxx> -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <ChartModel.hxx> +#include <Diagram.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> #include <ThreeDHelper.hxx> #include <defines.hxx> @@ -30,8 +31,6 @@ #include <svx/scene3d.hxx> #include <basegfx/matrix/b3dhommatrix.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <basegfx/polygon/b2dpolypolygontools.hxx> #include <svx/sdr/contact/viewcontactofe3dscene.hxx> #include <drawinglayer/geometry/viewinformation3d.hxx> @@ -40,17 +39,15 @@ namespace chart { using namespace ::com::sun::star; -using ::com::sun::star::uno::Reference; DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const Reference< frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , RotationDirection eRotationDirection ) : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel, ActionDescriptionProvider::ActionType::Rotate ) , m_pScene(nullptr) , m_aReferenceRect(100,100,100,100) , m_aStartPos(0,0) - , m_aWireframePolyPolygon() , m_fInitialXAngleRad(0.0) , m_fInitialYAngleRad(0.0) , m_fInitialZAngleRad(0.0) @@ -73,20 +70,19 @@ DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWr m_aWireframePolyPolygon = m_pScene->CreateWireframe(); - uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(getChartModel()) ); - uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); - if( !xDiagramProperties.is() ) + rtl::Reference< Diagram > xDiagram = getChartModel()->getFirstChartDiagram(); + if( !xDiagram.is() ) return; - ThreeDHelper::getRotationFromDiagram( xDiagramProperties - , m_nInitialHorizontalAngleDegree, m_nInitialVerticalAngleDegree ); + xDiagram->getRotation( + m_nInitialHorizontalAngleDegree, m_nInitialVerticalAngleDegree ); - ThreeDHelper::getRotationAngleFromDiagram( xDiagramProperties - , m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad ); + xDiagram->getRotationAngle( + m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad ); - if( ChartTypeHelper::isSupportingRightAngledAxes( - DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) - xDiagramProperties->getPropertyValue("RightAngledAxes") >>= m_bRightAngledAxes; + auto xChartType = xDiagram->getChartTypeByIndex(0); + if (xChartType.is() ? xChartType->isSupportingRightAngledAxes() : true) + xDiagram->getPropertyValue(u"RightAngledAxes"_ustr) >>= m_bRightAngledAxes; if(m_bRightAngledAxes) { if( m_eRotationDirection==ROTATIONDIRECTION_Z ) @@ -115,9 +111,9 @@ void DragMethod_RotateDiagram::MoveSdrDrag(const Point& rPnt) Hide(); //calculate new angle - double fX = F_PI2 * static_cast<double>(rPnt.Y() - m_aStartPos.Y()) + double fX = M_PI_2 * static_cast<double>(rPnt.Y() - m_aStartPos.Y()) / (m_aReferenceRect.GetHeight() > 0 ? static_cast<double>(m_aReferenceRect.GetHeight()) : 1.0); - double fY = F_PI * static_cast<double>(rPnt.X() - m_aStartPos.X()) + double fY = M_PI * static_cast<double>(rPnt.X() - m_aStartPos.X()) / (m_aReferenceRect.GetWidth() > 0 ? static_cast<double>(m_aReferenceRect.GetWidth()) : 1.0); if( m_eRotationDirection != ROTATIONDIRECTION_Y ) @@ -161,20 +157,23 @@ bool DragMethod_RotateDiagram::EndSdrDrag(bool /*bCopy*/) if(m_bRightAngledAxes) ThreeDHelper::adaptRadAnglesForRightAngledAxes( fResultX, fResultY ); - ThreeDHelper::setRotationAngleToDiagram( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( getChartModel() ), uno::UNO_QUERY ) - , fResultX, fResultY, fResultZ ); + rtl::Reference<Diagram> xDiagram = getChartModel()->getFirstChartDiagram(); + if (xDiagram) + xDiagram->setRotationAngle( fResultX, fResultY, fResultZ ); } else { - ThreeDHelper::setRotationToDiagram( ( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( getChartModel() ), uno::UNO_QUERY ) ) - , m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree ); + rtl::Reference<Diagram> xDiagram = getChartModel()->getFirstChartDiagram(); + if (xDiagram) + xDiagram->setRotation( + m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree ); } return true; } void DragMethod_RotateDiagram::CreateOverlayGeometry( sdr::overlay::OverlayManager& rOverlayManager, - const sdr::contact::ObjectContact& rObjectContact) + const sdr::contact::ObjectContact& rObjectContact, bool /* bIsGeometrySizeValid */) { ::basegfx::B3DHomMatrix aCurrentTransform; aCurrentTransform.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, @@ -217,7 +216,7 @@ void DragMethod_RotateDiagram::CreateOverlayGeometry( std::unique_ptr<sdr::overlay::OverlayPolyPolygonStripedAndFilled> pNew( new sdr::overlay::OverlayPolyPolygonStripedAndFilled( - aPolyPolygon)); + std::move(aPolyPolygon))); insertNewlyCreatedOverlayObjectForSdrDragMethod( std::move(pNew), diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.hxx b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx index c4fe814b0e11..d50fb42354ea 100644 --- a/chart2/source/controller/main/DragMethod_RotateDiagram.hxx +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx @@ -41,7 +41,7 @@ public: DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper , const OUString& rObjectCID - , const css::uno::Reference< css::frame::XModel >& xChartModel + , const rtl::Reference<::chart::ChartModel>& xChartModel , RotationDirection eRotationDirection ); virtual ~DragMethod_RotateDiagram() override; @@ -54,7 +54,7 @@ public: virtual void CreateOverlayGeometry( sdr::overlay::OverlayManager& rOverlayManager, - const sdr::contact::ObjectContact& rObjectContact) override; + const sdr::contact::ObjectContact& rObjectContact, bool bIsGeometrySizeValid=true) override; private: E3dScene* m_pScene; diff --git a/chart2/source/controller/main/DrawCommandDispatch.cxx b/chart2/source/controller/main/DrawCommandDispatch.cxx index f2011022595f..2065e123ebcd 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.cxx +++ b/chart2/source/controller/main/DrawCommandDispatch.cxx @@ -18,15 +18,14 @@ */ #include "DrawCommandDispatch.hxx" -#include "DrawCommandDispatch.h" #include <ChartController.hxx> #include <DrawViewWrapper.hxx> #include <chartview/DrawModelWrapper.hxx> #include <com/sun/star/frame/CommandGroup.hpp> #include <o3tl/unsafe_downcast.hxx> +#include <o3tl/string_view.hxx> #include <vcl/svapp.hxx> -#include <svl/itempool.hxx> #include <editeng/eeitem.hxx> #include <svx/strings.hrc> #include <svx/dialmgr.hxx> @@ -67,13 +66,13 @@ DrawCommandDispatch::~DrawCommandDispatch() bool DrawCommandDispatch::isFeatureSupported( const OUString& rCommandURL ) { - sal_uInt16 nFeatureId = 0; + ChartCommandID nFeatureId = ChartCommandID::NONE; OUString aBaseCommand; OUString aCustomShapeType; return parseCommandURL( rCommandURL, &nFeatureId, &aBaseCommand, &aCustomShapeType ); } -static ::basegfx::B2DPolyPolygon getPolygon(const char* pResId, const SdrModel& rModel) +static ::basegfx::B2DPolyPolygon getPolygon(TranslateId pResId, const SdrModel& rModel) { ::basegfx::B2DPolyPolygon aReturn; XLineEndListRef pLineEndList = rModel.GetLineEndList(); @@ -101,7 +100,7 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( !(pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == OBJ_CUSTOMSHAPE) ) + if ( !(pDrawModelWrapper && pDrawViewWrapper && pDrawViewWrapper->GetCurrentObjIdentifier() == SdrObjKind::CustomShape) ) return; bool bAttributesAppliedFromGallery = false; @@ -115,8 +114,6 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) if ( aObjList[ i ].equalsIgnoreAsciiCase( m_aCustomShapeType ) ) { FmFormModel aModel; - SfxItemPool& rPool(aModel.GetItemPool()); - rPool.FreezeIdRanges(); if ( GalleryExplorer::GetSdrObj( GALLERY_THEME_POWERPOINT, i, &aModel ) ) { @@ -124,22 +121,19 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) if ( pSourceObj ) { const SfxItemSet& rSource = pSourceObj->GetMergedItemSet(); + // Create a dynamic SfxItemSet SfxItemSet aDest( - pObj->getSdrModelFromSdrObject().GetItemPool(), - svl::Items< + SfxItemSet::makeFixedSfxItemSet< // Ranges from SdrAttrObj: - SDRATTR_START, SDRATTR_SHADOW_LAST, - SDRATTR_MISC_FIRST, - SDRATTR_MISC_LAST, - SDRATTR_TEXTDIRECTION, - SDRATTR_TEXTDIRECTION, + SDRATTR_START, SDRATTR_SHADOW_LAST, SDRATTR_MISC_FIRST, + SDRATTR_MISC_LAST, SDRATTR_TEXTDIRECTION, SDRATTR_TEXTDIRECTION, // Graphic attributes, 3D // properties, CustomShape // properties: - SDRATTR_GRAF_FIRST, - SDRATTR_CUSTOMSHAPE_LAST, + SDRATTR_GRAF_FIRST, SDRATTR_CUSTOMSHAPE_LAST, // Range from SdrTextObj: - EE_ITEMS_START, EE_ITEMS_END>{}); + EE_ITEMS_START, EE_ITEMS_END>( + pObj->getSdrModelFromSdrObject().GetItemPool())); aDest.Set( rSource ); pObj->SetMergedItemSet( aDest ); Degree100 nAngle = pSourceObj->GetRotateAngle(); @@ -165,7 +159,7 @@ void DrawCommandDispatch::setAttributes( SdrObject* pObj ) void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr ) { - if ( !(m_nFeatureId == COMMAND_ID_LINE_ARROW_END && m_pChartController) ) + if ( !(m_nFeatureId == ChartCommandID::DrawLineArrowEnd && m_pChartController) ) return; DrawModelWrapper* pDrawModelWrapper = m_pChartController->GetDrawModelWrapper(); @@ -184,11 +178,11 @@ void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr ) aArrow.append( aNewArrow ); } - SfxItemSet aSet( pDrawViewWrapper->GetModel()->GetItemPool() ); + SfxItemSet aSet(pDrawViewWrapper->GetModel().GetItemPool()); pDrawViewWrapper->GetAttributes( aSet ); tools::Long nWidth = 300; // (1/100th mm) - if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::DONTCARE ) + if ( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::INVALID ) { tools::Long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); if ( nValue > 0 ) @@ -197,12 +191,12 @@ void DrawCommandDispatch::setLineEnds( SfxItemSet& rAttr ) } } - rAttr.Put( XLineEndItem( SvxResId( RID_SVXSTR_ARROW ), aArrow ) ); + rAttr.Put( XLineEndItem( SvxResId( RID_SVXSTR_ARROW ), std::move(aArrow) ) ); rAttr.Put( XLineEndWidthItem( nWidth ) ); } // WeakComponentImplHelperBase -void DrawCommandDispatch::disposing() +void DrawCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { } @@ -217,27 +211,27 @@ FeatureState DrawCommandDispatch::getState( const OUString& rCommand ) aReturn.bEnabled = false; aReturn.aState <<= false; - sal_uInt16 nFeatureId = 0; + ChartCommandID nFeatureId = ChartCommandID::NONE; OUString aBaseCommand; OUString aCustomShapeType; if ( parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) ) { switch ( nFeatureId ) { - case COMMAND_ID_OBJECT_SELECT: - case COMMAND_ID_DRAW_LINE: - case COMMAND_ID_LINE_ARROW_END: - case COMMAND_ID_DRAW_RECT: - case COMMAND_ID_DRAW_ELLIPSE: - case COMMAND_ID_DRAW_FREELINE_NOFILL: - case COMMAND_ID_DRAW_TEXT: - case COMMAND_ID_DRAW_CAPTION: - case COMMAND_ID_DRAWTBX_CS_BASIC: - case COMMAND_ID_DRAWTBX_CS_SYMBOL: - case COMMAND_ID_DRAWTBX_CS_ARROW: - case COMMAND_ID_DRAWTBX_CS_FLOWCHART: - case COMMAND_ID_DRAWTBX_CS_CALLOUT: - case COMMAND_ID_DRAWTBX_CS_STAR: + case ChartCommandID::DrawObjectSelect: + case ChartCommandID::DrawLine: + case ChartCommandID::DrawLineArrowEnd: + case ChartCommandID::DrawRect: + case ChartCommandID::DrawEllipse: + case ChartCommandID::DrawFreelineNoFill: + case ChartCommandID::DrawText: + case ChartCommandID::DrawCaption: + case ChartCommandID::DrawToolboxCsBasic: + case ChartCommandID::DrawToolboxCsSymbol: + case ChartCommandID::DrawToolboxCsArrow: + case ChartCommandID::DrawToolboxCsFlowchart: + case ChartCommandID::DrawToolboxCsCallout: + case ChartCommandID::DrawToolboxCsStar: { aReturn.bEnabled = true; aReturn.aState <<= false; @@ -258,9 +252,9 @@ FeatureState DrawCommandDispatch::getState( const OUString& rCommand ) void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< beans::PropertyValue>& rArgs ) { ChartDrawMode eDrawMode = CHARTDRAW_SELECT; - SdrObjKind eKind = OBJ_NONE; + SdrObjKind eKind = SdrObjKind::NONE; - sal_uInt16 nFeatureId = 0; + ChartCommandID nFeatureId = ChartCommandID::NONE; OUString aBaseCommand; OUString aCustomShapeType; if ( !parseCommandURL( rCommand, &nFeatureId, &aBaseCommand, &aCustomShapeType ) ) @@ -272,65 +266,65 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea switch ( nFeatureId ) { - case COMMAND_ID_OBJECT_SELECT: + case ChartCommandID::DrawObjectSelect: { eDrawMode = CHARTDRAW_SELECT; - eKind = OBJ_NONE; + eKind = SdrObjKind::NONE; } break; - case COMMAND_ID_DRAW_LINE: - case COMMAND_ID_LINE_ARROW_END: + case ChartCommandID::DrawLine: + case ChartCommandID::DrawLineArrowEnd: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_LINE; + eKind = SdrObjKind::Line; } break; - case COMMAND_ID_DRAW_RECT: + case ChartCommandID::DrawRect: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_RECT; + eKind = SdrObjKind::Rectangle; } break; - case COMMAND_ID_DRAW_ELLIPSE: + case ChartCommandID::DrawEllipse: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CIRC; + eKind = SdrObjKind::CircleOrEllipse; } break; - case COMMAND_ID_DRAW_FREELINE_NOFILL: + case ChartCommandID::DrawFreelineNoFill: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_FREELINE; + eKind = SdrObjKind::FreehandLine; } break; - case COMMAND_ID_DRAW_TEXT: + case ChartCommandID::DrawText: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_TEXT; + eKind = SdrObjKind::Text; bCreate = true; } break; - case COMMAND_ID_DRAW_CAPTION: + case ChartCommandID::DrawCaption: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CAPTION; + eKind = SdrObjKind::Caption; } break; - case COMMAND_ID_DRAWTBX_CS_BASIC: - case COMMAND_ID_DRAWTBX_CS_SYMBOL: - case COMMAND_ID_DRAWTBX_CS_ARROW: - case COMMAND_ID_DRAWTBX_CS_FLOWCHART: - case COMMAND_ID_DRAWTBX_CS_CALLOUT: - case COMMAND_ID_DRAWTBX_CS_STAR: + case ChartCommandID::DrawToolboxCsBasic: + case ChartCommandID::DrawToolboxCsSymbol: + case ChartCommandID::DrawToolboxCsArrow: + case ChartCommandID::DrawToolboxCsFlowchart: + case ChartCommandID::DrawToolboxCsCallout: + case ChartCommandID::DrawToolboxCsStar: { eDrawMode = CHARTDRAW_INSERT; - eKind = OBJ_CUSTOMSHAPE; + eKind = SdrObjKind::CustomShape; } break; default: { eDrawMode = CHARTDRAW_SELECT; - eKind = OBJ_NONE; + eKind = SdrObjKind::NONE; } break; } @@ -350,25 +344,23 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea pDrawViewWrapper->SetCreateMode(); } - const beans::PropertyValue* pIter = rArgs.getConstArray(); - const beans::PropertyValue* pEnd = pIter + rArgs.getLength(); - const beans::PropertyValue* pKeyModifier = std::find_if(pIter, pEnd, + const beans::PropertyValue* pKeyModifier = std::find_if(rArgs.begin(), rArgs.end(), [](const beans::PropertyValue& lhs) {return lhs.Name == "KeyModifier";} ); sal_Int16 nKeyModifier = 0; - if ( !(pKeyModifier != pEnd && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1) ) + if ( !(pKeyModifier != rArgs.end() && ( pKeyModifier->Value >>= nKeyModifier ) && nKeyModifier == KEY_MOD1) ) return; if ( eDrawMode != CHARTDRAW_INSERT ) return; - SdrObject* pObj = createDefaultObject( nFeatureId ); + rtl::Reference<SdrObject> pObj = createDefaultObject( nFeatureId ); if ( pObj ) { SdrPageView* pPageView = pDrawViewWrapper->GetSdrPageView(); - if (pDrawViewWrapper->InsertObjectAtView(pObj, *pPageView)) + if (pDrawViewWrapper->InsertObjectAtView(pObj.get(), *pPageView)) m_pChartController->SetAndApplySelection(Reference<drawing::XShape>(pObj->getUnoShape(), uno::UNO_QUERY)); - if ( nFeatureId == COMMAND_ID_DRAW_TEXT ) + if ( nFeatureId == ChartCommandID::DrawText ) { m_pChartController->StartTextEdit(); } @@ -377,20 +369,20 @@ void DrawCommandDispatch::execute( const OUString& rCommand, const Sequence< bea void DrawCommandDispatch::describeSupportedFeatures() { - implDescribeSupportedFeature( ".uno:SelectObject", COMMAND_ID_OBJECT_SELECT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:Line", COMMAND_ID_DRAW_LINE, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:LineArrowEnd", COMMAND_ID_LINE_ARROW_END, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:Rect", COMMAND_ID_DRAW_RECT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:Ellipse", COMMAND_ID_DRAW_ELLIPSE, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:Freeline_Unfilled", COMMAND_ID_DRAW_FREELINE_NOFILL, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DrawText", COMMAND_ID_DRAW_TEXT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:DrawCaption", COMMAND_ID_DRAW_CAPTION, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:BasicShapes", COMMAND_ID_DRAWTBX_CS_BASIC, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:SymbolShapes", COMMAND_ID_DRAWTBX_CS_SYMBOL, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:ArrowShapes", COMMAND_ID_DRAWTBX_CS_ARROW, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:FlowChartShapes", COMMAND_ID_DRAWTBX_CS_FLOWCHART, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:CalloutShapes", COMMAND_ID_DRAWTBX_CS_CALLOUT, CommandGroup::INSERT ); - implDescribeSupportedFeature( ".uno:StarShapes", COMMAND_ID_DRAWTBX_CS_STAR, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SelectObject", ChartCommandID::DrawObjectSelect, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Line", ChartCommandID::DrawLine, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:LineArrowEnd", ChartCommandID::DrawLineArrowEnd, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Rect", ChartCommandID::DrawRect, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Ellipse", ChartCommandID::DrawEllipse, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:Freeline_Unfilled", ChartCommandID::DrawFreelineNoFill, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:DrawText", ChartCommandID::DrawText, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:DrawCaption", ChartCommandID::DrawCaption, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:BasicShapes", ChartCommandID::DrawToolboxCsBasic, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:SymbolShapes", ChartCommandID::DrawToolboxCsSymbol, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:ArrowShapes", ChartCommandID::DrawToolboxCsArrow, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:FlowChartShapes", ChartCommandID::DrawToolboxCsFlowchart, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:CalloutShapes", ChartCommandID::DrawToolboxCsCallout, CommandGroup::INSERT ); + implDescribeSupportedFeature( ".uno:StarShapes", ChartCommandID::DrawToolboxCsStar, CommandGroup::INSERT ); } void DrawCommandDispatch::setInsertObj(SdrObjKind eObj) @@ -402,15 +394,15 @@ void DrawCommandDispatch::setInsertObj(SdrObjKind eObj) } } -SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) +rtl::Reference<SdrObject> DrawCommandDispatch::createDefaultObject( const ChartCommandID nID ) { - SdrObject* pObj = nullptr; + rtl::Reference<SdrObject> pObj; DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr ); DrawModelWrapper* pDrawModelWrapper = ( m_pChartController ? m_pChartController->GetDrawModelWrapper() : nullptr ); if ( pDrawViewWrapper && pDrawModelWrapper ) { - Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); + rtl::Reference< SvxDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); SdrPage* pPage = GetSdrPageFromXDrawPage( xDrawPage ); if ( pPage ) { @@ -432,10 +424,10 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) switch ( nID ) { - case COMMAND_ID_DRAW_LINE: - case COMMAND_ID_LINE_ARROW_END: + case ChartCommandID::DrawLine: + case ChartCommandID::DrawLineArrowEnd: { - if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj) ) + if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) ) { Point aStart = aRect.TopLeft(); Point aEnd = aRect.BottomRight(); @@ -450,9 +442,9 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) } } break; - case COMMAND_ID_DRAW_FREELINE_NOFILL: + case ChartCommandID::DrawFreelineNoFill: { - if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj) ) + if ( auto const pathObj = dynamic_cast<SdrPathObj*>( pObj.get()) ) { basegfx::B2DPolygon aInnerPoly; aInnerPoly.append( basegfx::B2DPoint( aRect.Left(), aRect.Bottom() ) ); @@ -470,13 +462,13 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) } } break; - case COMMAND_ID_DRAW_TEXT: - case COMMAND_ID_DRAW_TEXT_VERTICAL: + case ChartCommandID::DrawText: + case ChartCommandID::DrawTextVertical: { - if ( SdrTextObj* pTextObj = dynamic_cast<SdrTextObj*>( pObj) ) + if ( SdrTextObj* pTextObj = DynCastSdrTextObj( pObj.get()) ) { pTextObj->SetLogicRect( aRect ); - bool bVertical = ( nID == COMMAND_ID_DRAW_TEXT_VERTICAL ); + bool bVertical = ( nID == ChartCommandID::DrawTextVertical ); pTextObj->SetVerticalWriting( bVertical ); if ( bVertical ) { @@ -490,12 +482,12 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) } } break; - case COMMAND_ID_DRAW_CAPTION: - case COMMAND_ID_DRAW_CAPTION_VERTICAL: + case ChartCommandID::DrawCaption: + case ChartCommandID::DrawCaptionVertical: { - if ( SdrCaptionObj* pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj) ) + if ( SdrCaptionObj* pCaptionObj = dynamic_cast<SdrCaptionObj*>( pObj.get()) ) { - bool bIsVertical( nID == COMMAND_ID_DRAW_CAPTION_VERTICAL ); + bool bIsVertical( nID == ChartCommandID::DrawCaptionVertical ); pCaptionObj->SetVerticalWriting( bIsVertical ); if ( bIsVertical ) { @@ -514,7 +506,7 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) { pObj->SetLogicRect( aRect ); SfxItemSet aSet( pDrawModelWrapper->GetItemPool() ); - setAttributes( pObj ); + setAttributes( pObj.get() ); pObj->SetMergedItemSet( aSet ); } break; @@ -526,17 +518,17 @@ SdrObject* DrawCommandDispatch::createDefaultObject( const sal_uInt16 nID ) return pObj; } -bool DrawCommandDispatch::parseCommandURL( const OUString& rCommandURL, sal_uInt16* pnFeatureId, +bool DrawCommandDispatch::parseCommandURL( const OUString& rCommandURL, ChartCommandID* pnFeatureId, OUString* pBaseCommand, OUString* pCustomShapeType ) { bool bFound = true; - sal_uInt16 nFeatureId = 0; + ChartCommandID nFeatureId = ChartCommandID::NONE; OUString aBaseCommand; OUString aType; - sal_Int32 nIndex = 1; - OUString aToken = rCommandURL.getToken( 0, '.', nIndex ); - if ( nIndex == -1 || aToken.isEmpty() ) + sal_Int32 nIndex = std::min(sal_Int32(1), rCommandURL.getLength()); + std::u16string_view aToken = o3tl::getToken(rCommandURL, 0, '.', nIndex ); + if ( nIndex == -1 || aToken.empty() ) { aBaseCommand = rCommandURL; SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( aBaseCommand ); @@ -546,32 +538,32 @@ bool DrawCommandDispatch::parseCommandURL( const OUString& rCommandURL, sal_uInt switch ( nFeatureId ) { - case COMMAND_ID_DRAWTBX_CS_BASIC: + case ChartCommandID::DrawToolboxCsBasic: { aType = "diamond"; } break; - case COMMAND_ID_DRAWTBX_CS_SYMBOL: + case ChartCommandID::DrawToolboxCsSymbol: { aType = "smiley"; } break; - case COMMAND_ID_DRAWTBX_CS_ARROW: + case ChartCommandID::DrawToolboxCsArrow: { aType = "left-right-arrow"; } break; - case COMMAND_ID_DRAWTBX_CS_FLOWCHART: + case ChartCommandID::DrawToolboxCsFlowchart: { aType = "flowchart-internal-storage"; } break; - case COMMAND_ID_DRAWTBX_CS_CALLOUT: + case ChartCommandID::DrawToolboxCsCallout: { aType = "round-rectangular-callout"; } break; - case COMMAND_ID_DRAWTBX_CS_STAR: + case ChartCommandID::DrawToolboxCsStar: { aType = "star5"; } diff --git a/chart2/source/controller/main/DrawCommandDispatch.h b/chart2/source/controller/main/DrawCommandDispatch.h deleted file mode 100644 index faf70bde1047..000000000000 --- a/chart2/source/controller/main/DrawCommandDispatch.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* - * This file is part of the LibreOffice project. - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. - * - * This file incorporates work covered by the following license notice: - * - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed - * with this work for additional information regarding copyright - * ownership. The ASF licenses this file to you under the Apache - * License, Version 2.0 (the "License"); you may not use this file - * except in compliance with the License. You may obtain a copy of - * the License at http://www.apache.org/licenses/LICENSE-2.0 . - */ -#ifndef CHART_DRAWCOMMANDDISPATCH_HRC -#define CHART_DRAWCOMMANDDISPATCH_HRC - -//Command Ids: -#define COMMAND_ID_OBJECT_SELECT 1 -#define COMMAND_ID_DRAW_LINE 2 -#define COMMAND_ID_LINE_ARROW_END 3 -#define COMMAND_ID_DRAW_RECT 4 -#define COMMAND_ID_DRAW_ELLIPSE 5 -#define COMMAND_ID_DRAW_FREELINE_NOFILL 6 -#define COMMAND_ID_DRAW_TEXT 7 -#define COMMAND_ID_DRAW_TEXT_VERTICAL 8 -#define COMMAND_ID_DRAW_CAPTION 9 -#define COMMAND_ID_DRAW_CAPTION_VERTICAL 10 -#define COMMAND_ID_DRAWTBX_CS_BASIC 11 -#define COMMAND_ID_DRAWTBX_CS_SYMBOL 12 -#define COMMAND_ID_DRAWTBX_CS_ARROW 13 -#define COMMAND_ID_DRAWTBX_CS_FLOWCHART 14 -#define COMMAND_ID_DRAWTBX_CS_CALLOUT 15 -#define COMMAND_ID_DRAWTBX_CS_STAR 16 - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/DrawCommandDispatch.hxx b/chart2/source/controller/main/DrawCommandDispatch.hxx index febfa8338d40..65200cca6323 100644 --- a/chart2/source/controller/main/DrawCommandDispatch.hxx +++ b/chart2/source/controller/main/DrawCommandDispatch.hxx @@ -20,6 +20,7 @@ #include <svx/svdobjkind.hxx> #include "FeatureCommandDispatchBase.hxx" +#include <rtl/ref.hxx> class SfxItemSet; class SdrObject; @@ -44,7 +45,7 @@ public: protected: // WeakComponentImplHelperBase - virtual void SAL_CALL disposing() override; + virtual void disposing( std::unique_lock<std::mutex>& rGuard ) override; // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; @@ -60,9 +61,9 @@ protected: private: void setInsertObj(SdrObjKind eObj); - SdrObject* createDefaultObject( const sal_uInt16 nID ); + rtl::Reference<SdrObject> createDefaultObject( const ChartCommandID nID ); - bool parseCommandURL( const OUString& rCommandURL, sal_uInt16* pnFeatureId, OUString* pBaseCommand, OUString* pCustomShapeType ); + bool parseCommandURL( const OUString& rCommandURL, ChartCommandID* pnFeatureId, OUString* pBaseCommand, OUString* pCustomShapeType ); ChartController* m_pChartController; OUString m_aCustomShapeType; diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx index 8e448fa355fe..36ea5dabfc18 100644 --- a/chart2/source/controller/main/ElementSelector.cxx +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -25,16 +25,15 @@ #include <ResId.hxx> #include <strings.hrc> #include <ObjectIdentifier.hxx> +#include <ChartController.hxx> +#include <ChartModel.hxx> +#include <ChartView.hxx> #include <cppuhelper/supportsservice.hxx> #include <o3tl/safeint.hxx> #include <toolkit/helper/vclunohelper.hxx> #include <vcl/svapp.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/lang/XMultiServiceFactory.hpp> - namespace chart { class ExplicitValueProvider; } namespace chart @@ -53,8 +52,8 @@ constexpr OUStringLiteral lcl_aServiceName } SelectorListBox::SelectorListBox(vcl::Window* pParent) - : InterimItemWindow(pParent, "modules/schart/ui/combobox.ui", "ComboBox") - , m_xWidget(m_xBuilder->weld_combo_box("combobox")) + : InterimItemWindow(pParent, u"modules/schart/ui/combobox.ui"_ustr, u"ComboBox"_ustr) + , m_xWidget(m_xBuilder->weld_combo_box(u"combobox"_ustr)) , m_bReleaseFocus(true) { InitControlBase(m_xWidget.get()); @@ -81,7 +80,7 @@ SelectorListBox::~SelectorListBox() } static void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectIdentifier & rParent, std::vector< ListBoxEntryData >& rEntries - , const sal_Int32 nHierarchyDepth, const Reference< chart2::XChartDocument >& xChartDoc ) + , const sal_Int32 nHierarchyDepth, const rtl::Reference<::chart::ChartModel>& xChartDoc ) { ObjectHierarchy::tChildContainer aChildren( rHierarchy.getChildren(rParent) ); for (auto const& child : aChildren) @@ -95,9 +94,9 @@ static void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const Obje } } -void SelectorListBox::SetChartController( const Reference< frame::XController >& xChartController ) +void SelectorListBox::SetChartController( const rtl::Reference< ::chart::ChartController >& xChartController ) { - m_xChartController = xChartController; + m_xChartController = xChartController.get(); } void SelectorListBox::UpdateChartElementsListAndSelection() @@ -105,29 +104,23 @@ void SelectorListBox::UpdateChartElementsListAndSelection() m_xWidget->clear(); m_aEntries.clear(); - Reference< frame::XController > xChartController( m_xChartController ); + rtl::Reference< ::chart::ChartController > xChartController = m_xChartController.get(); if( xChartController.is() ) { - Reference< view::XSelectionSupplier > xSelectionSupplier( xChartController, uno::UNO_QUERY); - ObjectIdentifier aSelectedOID; - OUString aSelectedCID; - if( xSelectionSupplier.is() ) - { - aSelectedOID = ObjectIdentifier( xSelectionSupplier->getSelection() ); - aSelectedCID = aSelectedOID.getObjectCID(); - } + ObjectIdentifier aSelectedOID( xChartController->getSelection() ); + const OUString& aSelectedCID = aSelectedOID.getObjectCID(); - Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY ); + rtl::Reference<::chart::ChartModel> xChartDoc = xChartController->getChartModel(); ObjectType eType( aSelectedOID.getObjectType() ); bool bAddSelectionToList = false; if ( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL || eType == OBJECTTYPE_SHAPE ) bAddSelectionToList = true; - Reference< uno::XInterface > xChartView; - Reference< lang::XMultiServiceFactory > xFact( xChartController->getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartView > xChartView; + rtl::Reference< ChartModel > xFact = xChartController->getChartModel(); if( xFact.is() ) - xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); - ExplicitValueProvider* pExplicitValueProvider = nullptr; //ExplicitValueProvider::getExplicitValueProvider(xChartView); this creates all visible data points, that's too much + xChartView = xFact->createChartView(); + ChartView* pExplicitValueProvider = nullptr; //ExplicitValueProvider::getExplicitValueProvider(xChartView); this creates all visible data points, that's too much ObjectHierarchy aHierarchy( xChartDoc, pExplicitValueProvider, true /*bFlattenDiagram*/, true /*bOrderingForElementSelector*/ ); lcl_addObjectsToList( aHierarchy, ::chart::ObjectHierarchy::getRootNodeOID(), m_aEntries, 0, xChartDoc ); @@ -166,7 +159,8 @@ void SelectorListBox::UpdateChartElementsListAndSelection() sal_uInt16 nN=0; for (auto const& entry : m_aEntries) { - m_xWidget->append_text(entry.UIName); + // tdf#152087 strip any newlines from the entry + m_xWidget->append_text(entry.UIName.replaceAll("\n", " ")); if ( !bSelectionFound && aSelectedOID == entry.OID ) { nEntryPosToSelect = nN; @@ -190,7 +184,7 @@ void SelectorListBox::ReleaseFocus_Impl() return; } - Reference< frame::XController > xController( m_xChartController ); + rtl::Reference< ::chart::ChartController > xController = m_xChartController.get(); Reference< frame::XFrame > xFrame( xController->getFrame() ); if ( xFrame.is() && xFrame->getContainerWindow().is() ) xFrame->getContainerWindow()->setFocus(); @@ -204,9 +198,9 @@ IMPL_LINK(SelectorListBox, SelectHdl, weld::ComboBox&, rComboBox, void) if (o3tl::make_unsigned(nPos) < m_aEntries.size()) { ObjectIdentifier aOID = m_aEntries[nPos].OID; - Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY ); - if( xSelectionSupplier.is() ) - xSelectionSupplier->select( aOID.getAny() ); + rtl::Reference< ::chart::ChartController > xController = m_xChartController.get(); + if( xController.is() ) + xController->select( aOID.getAny() ); } ReleaseFocus_Impl(); } @@ -258,7 +252,7 @@ sal_Bool SAL_CALL ElementSelectorToolbarController::supportsService( const OUStr css::uno::Sequence< OUString > SAL_CALL ElementSelectorToolbarController::getSupportedServiceNames() { - return { "com.sun.star.frame.ToolbarController" }; + return { u"com.sun.star.frame.ToolbarController"_ustr }; } ElementSelectorToolbarController::ElementSelectorToolbarController() { @@ -291,7 +285,9 @@ void SAL_CALL ElementSelectorToolbarController::statusChanged( const frame::Feat { Reference< frame::XController > xChartController; rEvent.State >>= xChartController; - m_apSelectorListBox->SetChartController( xChartController ); + ::chart::ChartController* pController = dynamic_cast<::chart::ChartController*>(xChartController.get()); + assert(!xChartController || pController); + m_apSelectorListBox->SetChartController( pController ); m_apSelectorListBox->UpdateChartElementsListAndSelection(); } } diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx index 67305fcf8266..fb1e4e0527ff 100644 --- a/chart2/source/controller/main/ElementSelector.hxx +++ b/chart2/source/controller/main/ElementSelector.hxx @@ -20,15 +20,15 @@ #include <ObjectIdentifier.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> -#include <com/sun/star/frame/XController.hpp> #include <cppuhelper/implbase1.hxx> #include <svtools/toolboxcontroller.hxx> #include <vcl/InterimItemWindow.hxx> -#include <cppuhelper/weakref.hxx> +#include <unotools/weakref.hxx> namespace chart { +class ChartController; struct ListBoxEntryData { @@ -50,11 +50,11 @@ public: void ReleaseFocus_Impl(); - void SetChartController( const css::uno::Reference< css::frame::XController >& xChartController ); + void SetChartController( const rtl::Reference< ::chart::ChartController >& xChartController ); void UpdateChartElementsListAndSelection(); private: - css::uno::WeakReference<css::frame::XController> m_xChartController; + unotools::WeakReference<::chart::ChartController> m_xChartController; std::unique_ptr<weld::ComboBox> m_xWidget; std::vector<ListBoxEntryData> m_aEntries; diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx index 90dcf77b2482..b1c5f72d1d5b 100644 --- a/chart2/source/controller/main/FeatureCommandDispatchBase.cxx +++ b/chart2/source/controller/main/FeatureCommandDispatchBase.cxx @@ -29,7 +29,7 @@ namespace chart FeatureCommandDispatchBase::FeatureCommandDispatchBase( const Reference< uno::XComponentContext >& rxContext ) :CommandDispatch( rxContext ) - ,m_nFeatureId( 0 ) + ,m_nFeatureId( ChartCommandID::NONE ) { } @@ -79,7 +79,7 @@ void FeatureCommandDispatchBase::dispatch( const util::URL& URL, } void FeatureCommandDispatchBase::implDescribeSupportedFeature( const char* pAsciiCommandURL, - sal_uInt16 nId, sal_Int16 nGroup ) + ChartCommandID nId, sal_Int16 nGroup ) { ControllerFeature aFeature; aFeature.Command = OUString::createFromAscii( pAsciiCommandURL ); diff --git a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx index 0c291a684d79..3ceb35ad1268 100644 --- a/chart2/source/controller/main/FeatureCommandDispatchBase.hxx +++ b/chart2/source/controller/main/FeatureCommandDispatchBase.hxx @@ -22,12 +22,50 @@ #include <com/sun/star/frame/DispatchInformation.hpp> +enum class ChartCommandID +{ + NONE = 0, + + //Draw Command Ids: + DrawObjectSelect = 1, + DrawLine = 2, + DrawLineArrowEnd = 3, + DrawRect = 4, + DrawEllipse = 5, + DrawFreelineNoFill = 6, + DrawText = 7, + DrawTextVertical = 8, + DrawCaption = 9, + DrawCaptionVertical = 10, + DrawToolboxCsBasic = 11, + DrawToolboxCsSymbol = 12, + DrawToolboxCsArrow = 13, + DrawToolboxCsFlowchart = 14, + DrawToolboxCsCallout = 15, + DrawToolboxCsStar = 16, + + //Shape Controller Command Ids: + ShapeFormatLine = 21, + ShapeFormatArea = 22, + ShapeTextAttributes = 23, + ShapeTransformDialog = 24, + ShapeObjectTitleDescription = 25, + ShapeRenameObject = 26, + ShapeBringToFront = 28, + ShapeForward = 29, + ShapeBackward = 30, + ShapeSendToBack = 31, + ShapeFontDialog = 35, + ShapeParagraphDialog = 36 +}; + + namespace chart { struct ControllerFeature: public css::frame::DispatchInformation { - sal_uInt16 nFeatureId; + ChartCommandID nFeatureId; }; typedef std::map< OUString, @@ -84,12 +122,12 @@ protected: the command group of the feature. This is important for configuring the controller UI by the user, see also <type scope="css::frame">CommandGroup</type>. */ - void implDescribeSupportedFeature( const char* pAsciiCommandURL, sal_uInt16 nId, + void implDescribeSupportedFeature( const char* pAsciiCommandURL, ChartCommandID nId, sal_Int16 nGroup ); mutable SupportedFeatures m_aSupportedFeatures; - sal_uInt16 m_nFeatureId; + ChartCommandID m_nFeatureId; }; } // namespace chart diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx index ff4d63fc16ea..c82d1c15bacb 100644 --- a/chart2/source/controller/main/ObjectHierarchy.cxx +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -19,62 +19,44 @@ #include <ObjectHierarchy.hxx> #include <ObjectIdentifier.hxx> -#include <ChartModelHelper.hxx> -#include <DiagramHelper.hxx> +#include <ChartView.hxx> +#include <Diagram.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> +#include <Axis.hxx> #include <AxisHelper.hxx> -#include <chartview/ExplicitValueProvider.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> +#include <ChartModel.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> +#include <GridProperties.hxx> #include <LegendHelper.hxx> #include <chartview/DrawModelWrapper.hxx> #include <unonames.hxx> +#include <BaseCoordinateSystem.hxx> #include <map> #include <algorithm> -#include <iterator> +#include <cstddef> -#include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XShapes.hpp> -#include <com/sun/star/chart2/XTitled.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XDataSeriesContainer.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> #include <com/sun/star/chart/ErrorBarStyle.hpp> #include <com/sun/star/container/XIndexAccess.hpp> #include <com/sun/star/awt/Key.hpp> -#include <com/sun/star/awt/KeyEvent.hpp> #include <com/sun/star/awt/KeyModifier.hpp> -#include <com/sun/star/frame/XModel.hpp> -#include <tools/diagnose_ex.h> +#include <utility> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::chart2; using ::com::sun::star::uno::Reference; -using ::com::sun::star::uno::Sequence; namespace { -struct lcl_ObjectToOID -{ - explicit lcl_ObjectToOID( const Reference< chart2::XChartDocument > & xChartDoc ) : - m_xModel( xChartDoc ) - {} - - ::chart::ObjectIdentifier operator() ( const Reference< uno::XInterface > & xObj ) - { - return ::chart::ObjectIdentifier( ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xObj, m_xModel ) ); - } - -private: - Reference< frame::XModel > m_xModel; -}; - void lcl_getChildOIDs( ::chart::ObjectHierarchy::tChildContainer& rOutChildren, const Reference< container::XIndexAccess >& xShapes ) @@ -91,8 +73,8 @@ void lcl_getChildOIDs( Reference< beans::XPropertySetInfo > xInfo( xShapeProp->getPropertySetInfo()); OUString aName; if( xInfo.is() && - xInfo->hasPropertyByName( "Name") && - (xShapeProp->getPropertyValue( "Name") >>= aName ) && + xInfo->hasPropertyByName( u"Name"_ustr) && + (xShapeProp->getPropertyValue( u"Name"_ustr) >>= aName ) && !aName.isEmpty() && ::chart::ObjectIdentifier::isCID( aName )) { @@ -105,12 +87,11 @@ void lcl_getChildOIDs( } } -void lcl_addAxisTitle( const Reference< XAxis >& xAxis, ::chart::ObjectHierarchy::tChildContainer& rContainer, const Reference< frame::XModel >& xChartModel ) +void lcl_addAxisTitle( const rtl::Reference< ::chart::Axis >& xAxis, ::chart::ObjectHierarchy::tChildContainer& rContainer, const rtl::Reference<::chart::ChartModel>& xChartModel ) { - Reference< XTitled > xAxisTitled( xAxis, uno::UNO_QUERY ); - if( xAxisTitled.is()) + if( xAxis.is()) { - Reference< XTitle > xAxisTitle( xAxisTitled->getTitleObject()); + Reference< XTitle > xAxisTitle( xAxis->getTitleObject()); if( xAxisTitle.is()) rContainer.emplace_back( ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xChartModel ) ); } @@ -121,85 +102,19 @@ void lcl_addAxisTitle( const Reference< XAxis >& xAxis, ::chart::ObjectHierarchy namespace chart { -namespace impl -{ - -class ImplObjectHierarchy -{ -public: - explicit ImplObjectHierarchy( - const Reference< XChartDocument >& xChartDocument, - ExplicitValueProvider* pExplicitValueProvider, - bool bFlattenDiagram, bool bOrderingForElementSelector ); - - bool hasChildren( const ObjectIdentifier& rParent ); - ObjectHierarchy::tChildContainer getChildren( const ObjectIdentifier& rParent ); - ObjectHierarchy::tChildContainer getSiblings( const ObjectIdentifier& rNode ); - - ObjectIdentifier getParent( const ObjectIdentifier& rOID ); - -private: - void createTree( const Reference< XChartDocument > & xChartDocument ); - void createAxesTree( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ); - void createDiagramTree( - ObjectHierarchy::tChildContainer& rContainer, - const Reference< XChartDocument >& xChartDoc, - const Reference< XDiagram >& xDiagram ); - void createDataSeriesTree( - ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, - const Reference< XDiagram > & xDiagram ); - static void createWallAndFloor( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XDiagram > & xDiagram ); - void createLegendTree( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ); - void createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer ); - - ObjectIdentifier getParentImpl( - const ObjectIdentifier& rParentOID, - const ObjectIdentifier& rOID ); - - typedef std::map< ObjectIdentifier, ObjectHierarchy::tChildContainer > - tChildMap; - tChildMap m_aChildMap; - ExplicitValueProvider* m_pExplicitValueProvider; - bool m_bFlattenDiagram; - bool m_bOrderingForElementSelector; -}; - -ImplObjectHierarchy::ImplObjectHierarchy( - const Reference< XChartDocument >& xChartDocument, - ExplicitValueProvider* pExplicitValueProvider, - bool bFlattenDiagram, - bool bOrderingForElementSelector ) : - m_pExplicitValueProvider( pExplicitValueProvider ), - m_bFlattenDiagram( bFlattenDiagram ), - m_bOrderingForElementSelector( bOrderingForElementSelector ) -{ - createTree( xChartDocument ); - // don't remember this helper to avoid access after lifetime - m_pExplicitValueProvider = nullptr; -} - -void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartDocument ) +void ObjectHierarchy::createTree( const rtl::Reference<::chart::ChartModel>& xChartDocument ) { - m_aChildMap = tChildMap();//clear tree + m_aChildMap.clear(); if( !xChartDocument.is() ) return; //@todo: change ObjectIdentifier to take an XChartDocument rather than XModel - Reference< frame::XModel > xModel = xChartDocument; - Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDocument ) ); + rtl::Reference< Diagram > xDiagram = xChartDocument->getFirstChartDiagram(); ObjectIdentifier aDiaOID; if( xDiagram.is() ) - aDiaOID = ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel ) ); - ObjectHierarchy::tChildContainer aTopLevelContainer; + aDiaOID = ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForObject( static_cast<cppu::OWeakObject*>(xDiagram.get()), xChartDocument ) ); + tChildContainer aTopLevelContainer; // First Level @@ -216,31 +131,23 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartD } // Main Title - Reference< XTitled > xDocTitled( xChartDocument, uno::UNO_QUERY ); - if( xDocTitled.is()) - { - Reference< XTitle > xMainTitle( xDocTitled->getTitleObject()); - if( xMainTitle.is()) - aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel ) ); - } + Reference< XTitle > xMainTitle( xChartDocument->getTitleObject()); + if( xMainTitle.is()) + aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xChartDocument ) ); if( xDiagram.is()) { // Sub Title. Note: This is interpreted of being top level - Reference< XTitled > xDiaTitled( xDiagram, uno::UNO_QUERY ); - if( xDiaTitled.is()) - { - Reference< XTitle > xSubTitle( xDiaTitled->getTitleObject()); - if( xSubTitle.is()) - aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel ) ); - } + Reference< XTitle > xSubTitle( xDiagram->getTitleObject()); + if( xSubTitle.is()) + aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xChartDocument ) ); if( !m_bOrderingForElementSelector ) { // Axis Titles. Note: These are interpreted of being top level - const Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); - for( Reference< XAxis > const & axis : aAxes ) - lcl_addAxisTitle( axis, aTopLevelContainer, xModel ); + const std::vector< rtl::Reference< Axis > > aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram ); + for( rtl::Reference< Axis > const & axis : aAxes ) + lcl_addAxisTitle( axis, aTopLevelContainer, xChartDocument ); // Diagram aTopLevelContainer.push_back( aDiaOID ); @@ -250,10 +157,10 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartD createDiagramTree( aTopLevelContainer, xChartDocument, xDiagram ); else { - ObjectHierarchy::tChildContainer aSubContainer; + tChildContainer aSubContainer; createDiagramTree( aSubContainer, xChartDocument, xDiagram ); if( !aSubContainer.empty() ) - m_aChildMap[ aDiaOID ] = aSubContainer; + m_aChildMap[ aDiaOID ] = std::move(aSubContainer); } if( !m_bOrderingForElementSelector ) @@ -271,13 +178,13 @@ void ImplObjectHierarchy::createTree( const Reference< XChartDocument >& xChartD aTopLevelContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, u"" ) ); if( ! aTopLevelContainer.empty()) - m_aChildMap[ ObjectHierarchy::getRootNodeOID() ] = aTopLevelContainer; + m_aChildMap[ObjectHierarchy::getRootNodeOID()] = std::move(aTopLevelContainer); } -void ImplObjectHierarchy::createLegendTree( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ) +void ObjectHierarchy::createLegendTree( + tChildContainer & rContainer, + const rtl::Reference<::chart::ChartModel> & xChartDoc, + const rtl::Reference< Diagram > & xDiagram ) { if( !(xDiagram.is() && LegendHelper::hasLegend( xDiagram )) ) return; @@ -288,38 +195,49 @@ void ImplObjectHierarchy::createLegendTree( // iterate over child shapes of legend and search for matching CIDs if( m_pExplicitValueProvider ) { - Reference< container::XIndexAccess > xLegendShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ), uno::UNO_QUERY ); - ObjectHierarchy::tChildContainer aLegendEntryOIDs; + rtl::Reference< SvxShapeGroupAnyD > xLegendShapeContainer = + dynamic_cast<SvxShapeGroupAnyD*>( + m_pExplicitValueProvider->getShapeForCID( aLegendOID.getObjectCID() ).get() ); + tChildContainer aLegendEntryOIDs; lcl_getChildOIDs( aLegendEntryOIDs, xLegendShapeContainer ); - m_aChildMap[ aLegendOID ] = aLegendEntryOIDs; + m_aChildMap[aLegendOID] = std::move(aLegendEntryOIDs); } } -void ImplObjectHierarchy::createAxesTree( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ) +void ObjectHierarchy::createAxesTree( + tChildContainer & rContainer, + const rtl::Reference<::chart::ChartModel> & xChartDoc, + const rtl::Reference< Diagram > & xDiagram ) { - Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - uno::Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); - bool bSupportsAxesGrids = ChartTypeHelper::isSupportingMainAxis( xChartType, nDimensionCount, 0 ); - if( !bSupportsAxesGrids ) + sal_Int32 nDimensionCount = xDiagram->getDimension(); + rtl::Reference< ChartType > xChartType( xDiagram->getChartTypeByIndex( 0 ) ); + bool bSupportsAxesGrids = true; + if (xChartType.is()) + bSupportsAxesGrids = xChartType->isSupportingMainAxis(nDimensionCount, 0); + + if (!bSupportsAxesGrids) return; - Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); + // Data Table + uno::Reference<chart2::XDataTable> xDataTable = xDiagram->getDataTable(); + if (xDataTable.is()) + { + rContainer.push_back(ObjectIdentifier::createClassifiedIdentifierForObject(xDataTable, xChartDoc)); + } + + // Axes + std::vector< rtl::Reference< Axis > > aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ); if( !m_bOrderingForElementSelector ) - std::transform( aAxes.begin(), aAxes.end(), - std::back_inserter( rContainer ), - lcl_ObjectToOID( xChartDoc )); + { + for (const auto& rAxis : aAxes) + rContainer.push_back( ObjectIdentifier::createClassifiedIdentifierForObject( rAxis, xChartDoc ) ); + } // get all axes, also invisible ones aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram ); // Grids - Reference< frame::XModel > xChartModel = xChartDoc; - for( Reference< XAxis > const & xAxis : std::as_const(aAxes) ) + for( rtl::Reference< Axis > const & xAxis : aAxes ) { if(!xAxis.is()) continue; @@ -328,47 +246,45 @@ void ImplObjectHierarchy::createAxesTree( sal_Int32 nDimensionIndex = 0; sal_Int32 nAxisIndex = 0; AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); - if( nAxisIndex>0 && !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount ) ) + if (nAxisIndex > 0 && !(xChartType.is() ? xChartType->isSupportingSecondaryAxis(nDimensionCount) : true)) continue; if( m_bOrderingForElementSelector ) { // axis if( AxisHelper::isAxisVisible( xAxis ) ) - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartDoc ) ); // axis title - lcl_addAxisTitle( xAxis, rContainer, xChartModel ); + lcl_addAxisTitle( xAxis, rContainer, xChartDoc ); } - Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); + rtl::Reference< ::chart::GridProperties > xGridProperties( xAxis->getGridProperties2() ); if( AxisHelper::isGridVisible( xGridProperties ) ) { //main grid - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) ); + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDoc ) ); } - Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); - sal_Int32 nSubGrid = 0; - for( nSubGrid = 0; nSubGrid < aSubGrids.getLength(); ++nSubGrid ) + std::vector< rtl::Reference< ::chart::GridProperties > > aSubGrids( xAxis->getSubGridProperties2() ); + for( size_t nSubGrid = 0; nSubGrid < aSubGrids.size(); ++nSubGrid ) { - Reference< beans::XPropertySet > xSubGridProperties( aSubGrids[nSubGrid] ); - if( AxisHelper::isGridVisible( xSubGridProperties ) ) + if( AxisHelper::isGridVisible( aSubGrids[nSubGrid] ) ) { //sub grid - rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) ); + rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartDoc, nSubGrid ) ); } } } } -void ImplObjectHierarchy::createWallAndFloor( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XDiagram > & xDiagram ) +void ObjectHierarchy::createWallAndFloor( + tChildContainer & rContainer, + const rtl::Reference< Diagram > & xDiagram ) { - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + sal_Int32 nDimensionCount = xDiagram->getDimension(); bool bIsThreeD = ( nDimensionCount == 3 ); - bool bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + bool bHasWall = xDiagram->isSupportingFloorAndWall(); if( bHasWall && bIsThreeD ) { rContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, u"" ) ); @@ -380,10 +296,10 @@ void ImplObjectHierarchy::createWallAndFloor( } -void ImplObjectHierarchy::createDiagramTree( - ObjectHierarchy::tChildContainer & rContainer, - const Reference< XChartDocument > & xChartDoc, - const Reference< XDiagram > & xDiagram ) +void ObjectHierarchy::createDiagramTree( + tChildContainer & rContainer, + const rtl::Reference<::chart::ChartModel> & xChartDoc, + const rtl::Reference< Diagram > & xDiagram ) { if( !m_bOrderingForElementSelector ) { @@ -398,28 +314,24 @@ void ImplObjectHierarchy::createDiagramTree( } } -void ImplObjectHierarchy::createDataSeriesTree( - ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, - const Reference< XDiagram > & xDiagram ) +void ObjectHierarchy::createDataSeriesTree( + tChildContainer & rOutDiagramSubContainer, + const rtl::Reference< Diagram > & xDiagram ) { - Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); - try { - sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); - Sequence< Reference< XCoordinateSystem > > aCooSysSeq( - xCooSysCnt->getCoordinateSystems()); - for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + sal_Int32 nDimensionCount = xDiagram->getDimension(); + std::vector< rtl::Reference< BaseCoordinateSystem > > aCooSysSeq( + xDiagram->getBaseCoordinateSystems()); + for( std::size_t nCooSysIdx=0; nCooSysIdx<aCooSysSeq.size(); ++nCooSysIdx ) { - Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); - Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); - for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypeSeq.getLength(); ++nCTIdx ) + std::vector< rtl::Reference< ChartType > > aChartTypeSeq( aCooSysSeq[nCooSysIdx]->getChartTypes2()); + for( std::size_t nCTIdx=0; nCTIdx<aChartTypeSeq.size(); ++nCTIdx ) { - Reference< XChartType > xChartType( aChartTypeSeq[nCTIdx] ); - Reference< XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY_THROW ); - Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); + const rtl::Reference< ChartType >& xChartType( aChartTypeSeq[nCTIdx] ); + std::vector< rtl::Reference< DataSeries > > aSeriesSeq( xChartType->getDataSeries2() ); const sal_Int32 nNumberOfSeries = - ChartTypeHelper::getNumberOfDisplayedSeries( xChartType, aSeriesSeq.getLength()); + ChartTypeHelper::getNumberOfDisplayedSeries( xChartType, aSeriesSeq.size()); for( sal_Int32 nSeriesIdx=0; nSeriesIdx<nNumberOfSeries; ++nSeriesIdx ) { @@ -430,59 +342,52 @@ void ImplObjectHierarchy::createDataSeriesTree( ObjectIdentifier( ObjectIdentifier::createClassifiedIdentifierForParticle( aSeriesParticle ) ) ); rOutDiagramSubContainer.push_back( aSeriesOID ); - ObjectHierarchy::tChildContainer aSeriesSubContainer; + tChildContainer aSeriesSubContainer; - Reference< chart2::XDataSeries > const & xSeries = aSeriesSeq[nSeriesIdx]; + rtl::Reference< DataSeries > const & xSeries = aSeriesSeq[nSeriesIdx]; // data labels - if( DataSeriesHelper::hasDataLabelsAtSeries( xSeries ) ) + if( xSeries->hasDataLabelsAtSeries() ) { OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) + "=" ); aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ) ); } // Statistics - if( ChartTypeHelper::isSupportingStatisticProperties( xChartType, nDimensionCount ) ) + if (xChartType.is() ? xChartType->isSupportingStatisticProperties(nDimensionCount) : true) { - Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); - if( xCurveCnt.is()) + const std::vector< rtl::Reference< RegressionCurveModel > > & rCurves( xSeries->getRegressionCurves2()); + for( size_t nCurveIdx=0; nCurveIdx<rCurves.size(); ++nCurveIdx ) { - Sequence< Reference< chart2::XRegressionCurve > > aCurves( xCurveCnt->getRegressionCurves()); - for( sal_Int32 nCurveIdx=0; nCurveIdx<aCurves.getLength(); ++nCurveIdx ) + bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( rCurves[nCurveIdx] ); + aSeriesSubContainer.emplace_back( ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine ) ); + if( RegressionCurveHelper::hasEquation( rCurves[nCurveIdx] ) ) { - bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[nCurveIdx] ); - aSeriesSubContainer.emplace_back( ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine ) ); - if( RegressionCurveHelper::hasEquation( aCurves[nCurveIdx] ) ) - { - aSeriesSubContainer.emplace_back( ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx ) ); - } + aSeriesSubContainer.emplace_back( ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx ) ); } - Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); - Reference< beans::XPropertySet > xErrorBarProp; - if( xSeriesProp.is() && - (xSeriesProp->getPropertyValue( CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarProp) && - xErrorBarProp.is()) + } + Reference< beans::XPropertySet > xErrorBarProp; + if( (xSeries->getPropertyValue( CHART_UNONAME_ERRORBAR_Y) >>= xErrorBarProp) && + xErrorBarProp.is()) + { + sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; + if( ( xErrorBarProp->getPropertyValue( u"ErrorBarStyle"_ustr) >>= nStyle ) && + ( nStyle != css::chart::ErrorBarStyle::NONE ) ) { - sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; - if( ( xErrorBarProp->getPropertyValue( "ErrorBarStyle") >>= nStyle ) && - ( nStyle != css::chart::ErrorBarStyle::NONE ) ) - { - aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierWithParent( - OBJECTTYPE_DATA_ERRORS_Y, u"", aSeriesParticle ) ); - } + aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS_Y, u"", aSeriesParticle ) ); } + } - if( xSeriesProp.is() && - (xSeriesProp->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarProp) && - xErrorBarProp.is()) + if( (xSeries->getPropertyValue(CHART_UNONAME_ERRORBAR_X) >>= xErrorBarProp) && + xErrorBarProp.is()) + { + sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; + if( ( xErrorBarProp->getPropertyValue( u"ErrorBarStyle"_ustr) >>= nStyle ) && + ( nStyle != css::chart::ErrorBarStyle::NONE ) ) { - sal_Int32 nStyle = css::chart::ErrorBarStyle::NONE; - if( ( xErrorBarProp->getPropertyValue( "ErrorBarStyle") >>= nStyle ) && - ( nStyle != css::chart::ErrorBarStyle::NONE ) ) - { - aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierWithParent( - OBJECTTYPE_DATA_ERRORS_X, u"", aSeriesParticle ) ); - } + aSeriesSubContainer.emplace_back( ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS_X, u"", aSeriesParticle ) ); } } } @@ -491,13 +396,14 @@ void ImplObjectHierarchy::createDataSeriesTree( // iterate over child shapes of legend and search for matching CIDs if( m_pExplicitValueProvider ) { - Reference< container::XIndexAccess > xSeriesShapeContainer( - m_pExplicitValueProvider->getShapeForCID( aSeriesOID.getObjectCID() ), uno::UNO_QUERY ); + rtl::Reference< SvxShapeGroupAnyD > xSeriesShapeContainer = + dynamic_cast<SvxShapeGroupAnyD*>( + m_pExplicitValueProvider->getShapeForCID( aSeriesOID.getObjectCID() ).get() ); lcl_getChildOIDs( aSeriesSubContainer, xSeriesShapeContainer ); } if( ! aSeriesSubContainer.empty()) - m_aChildMap[ aSeriesOID ] = aSeriesSubContainer; + m_aChildMap[ aSeriesOID ] = std::move(aSeriesSubContainer); } } } @@ -508,20 +414,19 @@ void ImplObjectHierarchy::createDataSeriesTree( } } -void ImplObjectHierarchy::createAdditionalShapesTree( ObjectHierarchy::tChildContainer& rContainer ) +void ObjectHierarchy::createAdditionalShapesTree(tChildContainer& rContainer) { try { if ( m_pExplicitValueProvider ) { - Reference< drawing::XDrawPage > xDrawPage( m_pExplicitValueProvider->getDrawModelWrapper()->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( m_pExplicitValueProvider->getDrawModelWrapper()->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { @@ -537,7 +442,7 @@ void ImplObjectHierarchy::createAdditionalShapesTree( ObjectHierarchy::tChildCon } } -bool ImplObjectHierarchy::hasChildren( const ObjectIdentifier& rParent ) +bool ObjectHierarchy::hasChildren( const ObjectIdentifier& rParent ) const { if ( rParent.isValid() ) { @@ -548,7 +453,7 @@ bool ImplObjectHierarchy::hasChildren( const ObjectIdentifier& rParent ) return false; } -ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const ObjectIdentifier& rParent ) +const ObjectHierarchy::tChildContainer & ObjectHierarchy::getChildren( const ObjectIdentifier& rParent ) const { if ( rParent.isValid() ) { @@ -556,31 +461,33 @@ ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const ObjectI if( aIt != m_aChildMap.end()) return aIt->second; } - return ObjectHierarchy::tChildContainer(); + static const tChildContainer EMPTY; + return EMPTY; } -ObjectHierarchy::tChildContainer ImplObjectHierarchy::getSiblings( const ObjectIdentifier& rNode ) +const ObjectHierarchy::tChildContainer & ObjectHierarchy::getSiblings( const ObjectIdentifier& rNode ) const { if ( rNode.isValid() && !ObjectHierarchy::isRootNode( rNode ) ) { for (auto const& child : m_aChildMap) { - ObjectHierarchy::tChildContainer::const_iterator aElemIt( + tChildContainer::const_iterator aElemIt( std::find( child.second.begin(), child.second.end(), rNode )); if( aElemIt != child.second.end()) return child.second; } } - return ObjectHierarchy::tChildContainer(); + static const tChildContainer EMPTY; + return EMPTY; } -ObjectIdentifier ImplObjectHierarchy::getParentImpl( +ObjectIdentifier ObjectHierarchy::getParentImpl( const ObjectIdentifier & rParentOID, - const ObjectIdentifier & rOID ) + const ObjectIdentifier & rOID ) const { // search children - ObjectHierarchy::tChildContainer aChildren( getChildren( rParentOID )); - ObjectHierarchy::tChildContainer::const_iterator aIt( + tChildContainer aChildren( getChildren( rParentOID )); + tChildContainer::const_iterator aIt( std::find( aChildren.begin(), aChildren.end(), rOID )); // recursion end if( aIt != aChildren.end()) @@ -601,28 +508,32 @@ ObjectIdentifier ImplObjectHierarchy::getParentImpl( return ObjectIdentifier(); } -ObjectIdentifier ImplObjectHierarchy::getParent( - const ObjectIdentifier & rOID ) +ObjectIdentifier ObjectHierarchy::getParent( + const ObjectIdentifier & rOID ) const { return getParentImpl( ObjectHierarchy::getRootNodeOID(), rOID ); } -} // namespace impl - ObjectHierarchy::ObjectHierarchy( - const Reference< XChartDocument > & xChartDocument, - ExplicitValueProvider * pExplicitValueProvider /* = 0 */, + const rtl::Reference<::chart::ChartModel> & xChartDocument, + ChartView * pExplicitValueProvider /* = 0 */, bool bFlattenDiagram /* = false */, bool bOrderingForElementSelector /* = false */) : - m_apImpl( new impl::ImplObjectHierarchy( xChartDocument, pExplicitValueProvider, bFlattenDiagram, bOrderingForElementSelector )) -{} + m_pExplicitValueProvider( pExplicitValueProvider ), + m_bFlattenDiagram( bFlattenDiagram ), + m_bOrderingForElementSelector( bOrderingForElementSelector ) +{ + createTree( xChartDocument ); + // don't remember this helper to avoid access after lifetime + m_pExplicitValueProvider = nullptr; +} ObjectHierarchy::~ObjectHierarchy() {} ObjectIdentifier ObjectHierarchy::getRootNodeOID() { - return ObjectIdentifier( "ROOT" ); + return ObjectIdentifier( u"ROOT"_ustr ); } bool ObjectHierarchy::isRootNode( const ObjectIdentifier& rOID ) @@ -630,45 +541,16 @@ bool ObjectHierarchy::isRootNode( const ObjectIdentifier& rOID ) return ( rOID == ObjectHierarchy::getRootNodeOID() ); } -ObjectHierarchy::tChildContainer ObjectHierarchy::getTopLevelChildren() const -{ - return m_apImpl->getChildren( ObjectHierarchy::getRootNodeOID()); -} - -bool ObjectHierarchy::hasChildren( const ObjectIdentifier& rParent ) const +const ObjectHierarchy::tChildContainer & ObjectHierarchy::getTopLevelChildren() const { - return m_apImpl->hasChildren( rParent ); -} - -ObjectHierarchy::tChildContainer ObjectHierarchy::getChildren( - const ObjectIdentifier& rParent ) const -{ - if ( rParent.isValid() ) - return m_apImpl->getChildren( rParent ); - - return ObjectHierarchy::tChildContainer(); -} - -ObjectHierarchy::tChildContainer ObjectHierarchy::getSiblings( - const ObjectIdentifier& rNode ) const -{ - if ( rNode.isValid() && !isRootNode( rNode ) ) - return m_apImpl->getSiblings( rNode ); - - return ObjectHierarchy::tChildContainer(); -} - -ObjectIdentifier ObjectHierarchy::getParent( - const ObjectIdentifier& rNode ) const -{ - return m_apImpl->getParent( rNode ); + return getChildren( ObjectHierarchy::getRootNodeOID()); } sal_Int32 ObjectHierarchy::getIndexInParent( const ObjectIdentifier& rNode ) const { - ObjectIdentifier aParentOID( m_apImpl->getParent( rNode )); - tChildContainer aChildren( m_apImpl->getChildren( aParentOID ) ); + ObjectIdentifier aParentOID( getParent( rNode )); + const tChildContainer & aChildren( getChildren( aParentOID ) ); sal_Int32 nIndex = 0; for (auto const& child : aChildren) { @@ -680,11 +562,11 @@ sal_Int32 ObjectHierarchy::getIndexInParent( } ObjectKeyNavigation::ObjectKeyNavigation( - const ObjectIdentifier & rCurrentOID, - const Reference< chart2::XChartDocument > & xChartDocument, - ExplicitValueProvider * pExplicitValueProvider /* = 0 */ ) : - m_aCurrentOID( rCurrentOID ), - m_xChartDocument( xChartDocument ), + ObjectIdentifier aCurrentOID, + rtl::Reference<::chart::ChartModel> xChartDocument, + ChartView * pExplicitValueProvider /* = 0 */ ) : + m_aCurrentOID(std::move( aCurrentOID )), + m_xChartDocument(std::move( xChartDocument )), m_pExplicitValueProvider( pExplicitValueProvider ) { if ( !m_aCurrentOID.isValid() ) @@ -737,7 +619,7 @@ void ObjectKeyNavigation::setCurrentSelection( const ObjectIdentifier& rOID ) bool ObjectKeyNavigation::first() { ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider ); - ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) ); + const ObjectHierarchy::tChildContainer& aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) ); bool bResult = !aSiblings.empty(); if( bResult ) setCurrentSelection( aSiblings.front()); @@ -749,7 +631,7 @@ bool ObjectKeyNavigation::first() bool ObjectKeyNavigation::last() { ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider ); - ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) ); + const ObjectHierarchy::tChildContainer& aSiblings( aHierarchy.getSiblings( getCurrentSelection() ) ); bool bResult = !aSiblings.empty(); if( bResult ) setCurrentSelection( aSiblings.back()); @@ -813,7 +695,7 @@ bool ObjectKeyNavigation::down() bool bResult = aHierarchy.hasChildren( getCurrentSelection()); if( bResult ) { - ObjectHierarchy::tChildContainer aChildren = aHierarchy.getChildren( getCurrentSelection()); + const ObjectHierarchy::tChildContainer& aChildren = aHierarchy.getChildren( getCurrentSelection()); OSL_ASSERT( !aChildren.empty()); setCurrentSelection( aChildren.front()); } @@ -823,7 +705,7 @@ bool ObjectKeyNavigation::down() bool ObjectKeyNavigation::veryFirst() { ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider ); - ObjectHierarchy::tChildContainer aChildren( aHierarchy.getTopLevelChildren()); + const ObjectHierarchy::tChildContainer& aChildren( aHierarchy.getTopLevelChildren()); bool bResult = !aChildren.empty(); if( bResult ) setCurrentSelection( aChildren.front()); @@ -833,7 +715,7 @@ bool ObjectKeyNavigation::veryFirst() bool ObjectKeyNavigation::veryLast() { ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider ); - ObjectHierarchy::tChildContainer aChildren( aHierarchy.getTopLevelChildren()); + const ObjectHierarchy::tChildContainer& aChildren( aHierarchy.getTopLevelChildren()); bool bResult = !aChildren.empty(); if( bResult ) setCurrentSelection( aChildren.back()); diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx index 63ddb818fd0d..dbb5368686ae 100644 --- a/chart2/source/controller/main/PositionAndSizeHelper.cxx +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -20,13 +20,12 @@ #include <PositionAndSizeHelper.hxx> #include <ControllerLockGuard.hxx> #include <com/sun/star/chart/ChartLegendExpansion.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> #include <com/sun/star/chart2/RelativePosition.hpp> #include <com/sun/star/chart2/RelativeSize.hpp> -#include <com/sun/star/frame/XModel.hpp> #include <tools/gen.hxx> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/awt/Rectangle.hpp> +#include <ChartModel.hxx> +#include <Diagram.hxx> namespace chart { @@ -46,7 +45,7 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType tools::Rectangle aPageRect( Point(rPageRectangle.X,rPageRectangle.Y), Size(rPageRectangle.Width,rPageRectangle.Height) ); // every following branch divides by width and height - if (aPageRect.getWidth() == 0 || aPageRect.getHeight() == 0) + if (aPageRect.getOpenWidth() == 0 || aPageRect.getOpenHeight() == 0) return false; if( eObjectType==OBJECTTYPE_TITLE ) @@ -56,18 +55,18 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType aRelativePosition.Anchor = drawing::Alignment_CENTER; //the anchor point at the title object is top/middle Point aPos = aObjectRect.TopLeft(); - aRelativePosition.Primary = (double(aPos.X())+double(aObjectRect.getWidth())/2.0)/double(aPageRect.getWidth()); - aRelativePosition.Secondary = (double(aPos.Y())+double(aObjectRect.getHeight())/2.0)/double(aPageRect.getHeight()); - xObjectProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + aRelativePosition.Primary = (double(aPos.X())+double(aObjectRect.getOpenWidth())/2.0)/double(aPageRect.getOpenWidth()); + aRelativePosition.Secondary = (double(aPos.Y())+double(aObjectRect.getOpenHeight())/2.0)/double(aPageRect.getOpenHeight()); + xObjectProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); } else if( eObjectType == OBJECTTYPE_DATA_LABEL ) { RelativePosition aAbsolutePosition; RelativePosition aCustomLabelPosition; - aAbsolutePosition.Primary = double(rOldPositionAndSize.X) / double(aPageRect.getWidth()); - aAbsolutePosition.Secondary = double(rOldPositionAndSize.Y) / double(aPageRect.getHeight()); + aAbsolutePosition.Primary = double(rOldPositionAndSize.X) / double(aPageRect.getOpenWidth()); + aAbsolutePosition.Secondary = double(rOldPositionAndSize.Y) / double(aPageRect.getOpenHeight()); - if( xObjectProp->getPropertyValue("CustomLabelPosition") >>= aCustomLabelPosition ) + if( xObjectProp->getPropertyValue(u"CustomLabelPosition"_ustr) >>= aCustomLabelPosition ) { aAbsolutePosition.Primary -= aCustomLabelPosition.Primary; aAbsolutePosition.Secondary -= aCustomLabelPosition.Secondary; @@ -76,15 +75,15 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType //the anchor point at the data label object is top/left Point aPos = aObjectRect.TopLeft(); double fRotation = 0.0; - xObjectProp->getPropertyValue("TextRotation") >>= fRotation; + xObjectProp->getPropertyValue(u"TextRotation"_ustr) >>= fRotation; if( fRotation == 90.0 ) aPos = aObjectRect.BottomLeft(); else if( fRotation == 270.0 ) aPos = aObjectRect.TopRight(); - aCustomLabelPosition.Primary = double(aPos.X()) / double(aPageRect.getWidth()) - aAbsolutePosition.Primary; - aCustomLabelPosition.Secondary = double(aPos.Y()) / double(aPageRect.getHeight()) - aAbsolutePosition.Secondary; - xObjectProp->setPropertyValue("CustomLabelPosition", uno::Any(aCustomLabelPosition)); + aCustomLabelPosition.Primary = double(aPos.X()) / double(aPageRect.getOpenWidth()) - aAbsolutePosition.Primary; + aCustomLabelPosition.Secondary = double(aPos.Y()) / double(aPageRect.getOpenHeight()) - aAbsolutePosition.Secondary; + xObjectProp->setPropertyValue(u"CustomLabelPosition"_ustr, uno::Any(aCustomLabelPosition)); } else if( eObjectType==OBJECTTYPE_DATA_CURVE_EQUATION ) { @@ -93,38 +92,38 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; //the anchor point at the title object is top/middle Point aPos = aObjectRect.TopLeft(); - aRelativePosition.Primary = double(aPos.X())/double(aPageRect.getWidth()); - aRelativePosition.Secondary = double(aPos.Y())/double(aPageRect.getHeight()); - xObjectProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + aRelativePosition.Primary = double(aPos.X())/double(aPageRect.getOpenWidth()); + aRelativePosition.Secondary = double(aPos.Y())/double(aPageRect.getOpenHeight()); + xObjectProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); } else if(eObjectType==OBJECTTYPE_LEGEND) { - xObjectProp->setPropertyValue( "Expansion", uno::Any(css::chart::ChartLegendExpansion_CUSTOM)); + xObjectProp->setPropertyValue( u"Expansion"_ustr, uno::Any(css::chart::ChartLegendExpansion_CUSTOM)); chart2::RelativePosition aRelativePosition; chart2::RelativeSize aRelativeSize; Point aAnchor = aObjectRect.TopLeft(); aRelativePosition.Primary = static_cast< double >( aAnchor.X()) / - static_cast< double >( aPageRect.getWidth() ); + static_cast< double >( aPageRect.getOpenWidth() ); aRelativePosition.Secondary = static_cast< double >( aAnchor.Y()) / - static_cast< double >( aPageRect.getHeight()); + static_cast< double >( aPageRect.getOpenHeight()); - xObjectProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + xObjectProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); aRelativeSize.Primary = - static_cast< double >( aObjectRect.getWidth()) / - static_cast< double >( aPageRect.getWidth() ); + static_cast< double >( aObjectRect.getOpenWidth()) / + static_cast< double >( aPageRect.getOpenWidth() ); if (aRelativeSize.Primary > 1.0) aRelativeSize.Primary = 1.0; aRelativeSize.Secondary = - static_cast< double >( aObjectRect.getHeight()) / - static_cast< double >( aPageRect.getHeight()); + static_cast< double >( aObjectRect.getOpenHeight()) / + static_cast< double >( aPageRect.getOpenHeight()); if (aRelativeSize.Secondary > 1.0) aRelativeSize.Secondary = 1.0; - xObjectProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) ); + xObjectProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any(aRelativeSize) ); } else if(eObjectType==OBJECTTYPE_DIAGRAM || eObjectType==OBJECTTYPE_DIAGRAM_WALL || eObjectType==OBJECTTYPE_DIAGRAM_FLOOR) { @@ -135,25 +134,25 @@ bool PositionAndSizeHelper::moveObject( ObjectType eObjectType aRelativePosition.Anchor = drawing::Alignment_CENTER; Point aPos = aObjectRect.Center(); - aRelativePosition.Primary = double(aPos.X())/double(aPageRect.getWidth()); - aRelativePosition.Secondary = double(aPos.Y())/double(aPageRect.getHeight()); - xObjectProp->setPropertyValue( "RelativePosition", uno::Any(aRelativePosition) ); + aRelativePosition.Primary = double(aPos.X())/double(aPageRect.getOpenWidth()); + aRelativePosition.Secondary = double(aPos.Y())/double(aPageRect.getOpenHeight()); + xObjectProp->setPropertyValue( u"RelativePosition"_ustr, uno::Any(aRelativePosition) ); //set size: RelativeSize aRelativeSize; //the anchor points for the diagram are in the middle of the diagram //and in the middle of the page - aRelativeSize.Primary = double(aObjectRect.getWidth())/double(aPageRect.getWidth()); - aRelativeSize.Secondary = double(aObjectRect.getHeight())/double(aPageRect.getHeight()); - xObjectProp->setPropertyValue( "RelativeSize", uno::Any(aRelativeSize) ); + aRelativeSize.Primary = double(aObjectRect.getOpenWidth())/double(aPageRect.getOpenWidth()); + aRelativeSize.Secondary = double(aObjectRect.getOpenHeight())/double(aPageRect.getOpenHeight()); + xObjectProp->setPropertyValue( u"RelativeSize"_ustr, uno::Any(aRelativeSize) ); } else return false; return true; } -bool PositionAndSizeHelper::moveObject( const OUString& rObjectCID - , const uno::Reference< frame::XModel >& xChartModel +bool PositionAndSizeHelper::moveObject( std::u16string_view rObjectCID + , const rtl::Reference<::chart::ChartModel>& xChartModel , const awt::Rectangle& rNewPositionAndSize , const awt::Rectangle& rOldPositionAndSize , const awt::Rectangle& rPageRectangle @@ -167,7 +166,7 @@ bool PositionAndSizeHelper::moveObject( const OUString& rObjectCID ObjectType eObjectType( ObjectIdentifier::getObjectType( rObjectCID ) ); if(eObjectType==OBJECTTYPE_DIAGRAM || eObjectType==OBJECTTYPE_DIAGRAM_WALL || eObjectType==OBJECTTYPE_DIAGRAM_FLOOR) { - xObjectProp.set( ObjectIdentifier::getDiagramForCID( rObjectCID, xChartModel ), uno::UNO_QUERY ); + xObjectProp = ObjectIdentifier::getDiagramForCID( rObjectCID, xChartModel ); if(!xObjectProp.is()) return false; } diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx index 51ec5ab91da5..8a6305c6f6c2 100644 --- a/chart2/source/controller/main/SelectionHelper.cxx +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -19,10 +19,9 @@ #include <SelectionHelper.hxx> #include <ObjectIdentifier.hxx> -#include <DiagramHelper.hxx> -#include <ChartModelHelper.hxx> +#include <Diagram.hxx> +#include <ChartModel.hxx> -#include <com/sun/star/frame/XModel.hpp> #include <svx/svdpage.hxx> #include <svx/svditer.hxx> #include <svx/obj3d.hxx> @@ -218,10 +217,10 @@ void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper { if( bAllowMultiClickSelectionChange ) { - m_aSelectedOID = aLastChild; + m_aSelectedOID = std::move(aLastChild); } else - m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = aLastChild; + m_aSelectedOID_selectOnlyIfNoDoubleClickIsFollowing = std::move(aLastChild); break; } } @@ -303,7 +302,7 @@ bool Selection::isResizeableObjectSelected() const } } -bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel ) const +bool Selection::isRotateableObjectSelected( const rtl::Reference<::chart::ChartModel>& xChartModel ) const { return SelectionHelper::isRotateableObject( m_aSelectedOID.getObjectCID(), xChartModel ); } @@ -313,6 +312,11 @@ bool Selection::isDragableObjectSelected() const return m_aSelectedOID.isDragableObject(); } +bool Selection::isTitleObjectSelected() const +{ + return m_aSelectedOID.getObjectType() == OBJECTTYPE_TITLE; +} + bool Selection::isAdditionalShapeSelected() const { return m_aSelectedOID.isAdditionalShape(); @@ -431,8 +435,7 @@ OUString SelectionHelper::getHitObjectCID( if( aRet == aWallCID ) { - OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ); - aRet = aDiagramCID; + aRet = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, OUString::number( 0 ) ); } } } @@ -441,13 +444,13 @@ OUString SelectionHelper::getHitObjectCID( // \\- solar mutex } -bool SelectionHelper::isRotateableObject( const OUString& rCID - , const uno::Reference< frame::XModel >& xChartModel ) +bool SelectionHelper::isRotateableObject( std::u16string_view rCID + , const rtl::Reference<::chart::ChartModel>& xChartModel ) { if( !ObjectIdentifier::isRotateableObject( rCID ) ) return false; - sal_Int32 nDimensionCount = DiagramHelper::getDimension( ChartModelHelper::findDiagram( xChartModel ) ); + sal_Int32 nDimensionCount = xChartModel->getFirstChartDiagram()->getDimension(); return nDimensionCount == 3; } @@ -464,7 +467,7 @@ SelectionHelper::~SelectionHelper() bool SelectionHelper::getFrameDragSingles() { //true == green == surrounding handles - return dynamic_cast<const E3dObject*>( m_pSelectedObj) == nullptr; + return DynCastE3dObject( m_pSelectedObj) == nullptr; } SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj ) @@ -531,7 +534,7 @@ E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj ) if(pObj) { - pRotateable = dynamic_cast<E3dObject*>(pObj); + pRotateable = DynCastE3dObject(pObj); if( !pRotateable ) { SolarMutexGuard aSolarGuard; @@ -541,8 +544,7 @@ E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj ) SdrObjListIter aIterator(pSubList, SdrIterMode::DeepWithGroups); while( aIterator.IsMore() && !pRotateable ) { - SdrObject* pSubObj = aIterator.Next(); - pRotateable = dynamic_cast<E3dObject*>(pSubObj); + pRotateable = DynCastE3dObject(aIterator.Next()); } } } @@ -596,7 +598,7 @@ bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList ) for( sal_uInt32 nM = 0; nM < aPolygon.count(); nM++) { const ::basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nM)); - rHdlList.AddHdl(std::make_unique<SdrHdl>(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), SdrHdlKind::Poly)); + rHdlList.AddHdl(std::make_unique<SdrHdl>(Point(basegfx::fround<tools::Long>(aPoint.getX()), basegfx::fround<tools::Long>(aPoint.getY())), SdrHdlKind::Poly)); } } return true; diff --git a/chart2/source/controller/main/ShapeController.cxx b/chart2/source/controller/main/ShapeController.cxx index 8161717fe339..f9d262c6e3f3 100644 --- a/chart2/source/controller/main/ShapeController.cxx +++ b/chart2/source/controller/main/ShapeController.cxx @@ -18,16 +18,14 @@ */ #include "ShapeController.hxx" -#include <ShapeController.h> #include <ChartController.hxx> #include <ViewElementListProvider.hxx> #include <dlg_ShapeFont.hxx> #include <dlg_ShapeParagraph.hxx> +#include <ChartModel.hxx> #include <chartview/DrawModelWrapper.hxx> -#include <com/sun/star/drawing/XDrawPage.hpp> #include <com/sun/star/drawing/XShapes.hpp> #include <com/sun/star/frame/CommandGroup.hpp> -#include <com/sun/star/frame/XStorable.hpp> #include <vcl/svapp.hxx> #include <editeng/formatbreakitem.hxx> @@ -38,7 +36,7 @@ #include <editeng/spltitem.hxx> #include <svx/svxdlg.hxx> #include <editeng/widwitem.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; using namespace ::com::sun::star::frame; @@ -61,7 +59,7 @@ ShapeController::~ShapeController() } // WeakComponentImplHelperBase -void ShapeController::disposing() +void ShapeController::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { } @@ -79,7 +77,7 @@ FeatureState ShapeController::getState( const OUString& rCommand ) bool bWritable = false; if ( m_pChartController ) { - Reference< frame::XStorable > xStorable( m_pChartController->getModel(), uno::UNO_QUERY ); + rtl::Reference< ChartModel > xStorable = m_pChartController->getChartModel(); if ( xStorable.is() ) { bWritable = !xStorable->isReadonly(); @@ -89,42 +87,37 @@ FeatureState ShapeController::getState( const OUString& rCommand ) SupportedFeatures::const_iterator aIter = m_aSupportedFeatures.find( rCommand ); if ( aIter != m_aSupportedFeatures.end() ) { - sal_uInt16 nFeatureId = aIter->second.nFeatureId; + ChartCommandID nFeatureId = aIter->second.nFeatureId; switch ( nFeatureId ) { - case COMMAND_ID_FORMAT_LINE: - case COMMAND_ID_FORMAT_AREA: - case COMMAND_ID_TEXT_ATTRIBUTES: - case COMMAND_ID_TRANSFORM_DIALOG: - case COMMAND_ID_OBJECT_TITLE_DESCRIPTION: - case COMMAND_ID_RENAME_OBJECT: + case ChartCommandID::ShapeFormatLine: + case ChartCommandID::ShapeFormatArea: + case ChartCommandID::ShapeTextAttributes: + case ChartCommandID::ShapeTransformDialog: + case ChartCommandID::ShapeObjectTitleDescription: + case ChartCommandID::ShapeRenameObject: + case ChartCommandID::ShapeFontDialog: + case ChartCommandID::ShapeParagraphDialog: { aReturn.bEnabled = bWritable; aReturn.aState <<= false; } break; - case COMMAND_ID_BRING_TO_FRONT: - case COMMAND_ID_FORWARD: + case ChartCommandID::ShapeBringToFront: + case ChartCommandID::ShapeForward: { aReturn.bEnabled = ( bWritable && isForwardPossible() ); aReturn.aState <<= false; } break; - case COMMAND_ID_BACKWARD: - case COMMAND_ID_SEND_TO_BACK: + case ChartCommandID::ShapeBackward: + case ChartCommandID::ShapeSendToBack: { aReturn.bEnabled = ( bWritable && isBackwardPossible() ); aReturn.aState <<= false; } break; - case COMMAND_ID_FONT_DIALOG: - case COMMAND_ID_PARAGRAPH_DIALOG: - { - aReturn.bEnabled = bWritable; - aReturn.aState <<= false; - } - break; default: { aReturn.bEnabled = false; @@ -143,53 +136,53 @@ void ShapeController::execute( const OUString& rCommand, const Sequence< beans:: if ( aIter == m_aSupportedFeatures.end() ) return; - sal_uInt16 nFeatureId = aIter->second.nFeatureId; + ChartCommandID nFeatureId = aIter->second.nFeatureId; switch ( nFeatureId ) { - case COMMAND_ID_FORMAT_LINE: + case ChartCommandID::ShapeFormatLine: { executeDispatch_FormatLine(); } break; - case COMMAND_ID_FORMAT_AREA: + case ChartCommandID::ShapeFormatArea: { executeDispatch_FormatArea(); } break; - case COMMAND_ID_TEXT_ATTRIBUTES: + case ChartCommandID::ShapeTextAttributes: { executeDispatch_TextAttributes(); } break; - case COMMAND_ID_TRANSFORM_DIALOG: + case ChartCommandID::ShapeTransformDialog: { executeDispatch_TransformDialog(); } break; - case COMMAND_ID_OBJECT_TITLE_DESCRIPTION: + case ChartCommandID::ShapeObjectTitleDescription: { executeDispatch_ObjectTitleDescription(); } break; - case COMMAND_ID_RENAME_OBJECT: + case ChartCommandID::ShapeRenameObject: { executeDispatch_RenameObject(); } break; - case COMMAND_ID_BRING_TO_FRONT: - case COMMAND_ID_FORWARD: - case COMMAND_ID_BACKWARD: - case COMMAND_ID_SEND_TO_BACK: + case ChartCommandID::ShapeBringToFront: + case ChartCommandID::ShapeForward: + case ChartCommandID::ShapeBackward: + case ChartCommandID::ShapeSendToBack: { executeDispatch_ChangeZOrder( nFeatureId ); } break; - case COMMAND_ID_FONT_DIALOG: + case ChartCommandID::ShapeFontDialog: { executeDispatch_FontDialog(); } break; - case COMMAND_ID_PARAGRAPH_DIALOG: + case ChartCommandID::ShapeParagraphDialog: { executeDispatch_ParagraphDialog(); } @@ -203,24 +196,23 @@ void ShapeController::execute( const OUString& rCommand, const Sequence< beans:: void ShapeController::describeSupportedFeatures() { - implDescribeSupportedFeature( ".uno:FormatLine", COMMAND_ID_FORMAT_LINE, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:FormatArea", COMMAND_ID_FORMAT_AREA, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:TextAttributes", COMMAND_ID_TEXT_ATTRIBUTES, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:TransformDialog", COMMAND_ID_TRANSFORM_DIALOG, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:ObjectTitleDescription", COMMAND_ID_OBJECT_TITLE_DESCRIPTION, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:RenameObject", COMMAND_ID_RENAME_OBJECT, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:BringToFront", COMMAND_ID_BRING_TO_FRONT, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:Forward", COMMAND_ID_FORWARD, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:Backward", COMMAND_ID_BACKWARD, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:SendToBack", COMMAND_ID_SEND_TO_BACK, CommandGroup::FORMAT ); - implDescribeSupportedFeature( ".uno:FontDialog", COMMAND_ID_FONT_DIALOG, CommandGroup::EDIT ); - implDescribeSupportedFeature( ".uno:ParagraphDialog", COMMAND_ID_PARAGRAPH_DIALOG, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:FormatLine", ChartCommandID::ShapeFormatLine, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:FormatArea", ChartCommandID::ShapeFormatArea, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:TextAttributes", ChartCommandID::ShapeTextAttributes, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:TransformDialog", ChartCommandID::ShapeTransformDialog, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:ObjectTitleDescription", ChartCommandID::ShapeObjectTitleDescription, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:RenameObject", ChartCommandID::ShapeRenameObject, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:BringToFront", ChartCommandID::ShapeBringToFront, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Forward", ChartCommandID::ShapeForward, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:Backward", ChartCommandID::ShapeBackward, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:SendToBack", ChartCommandID::ShapeSendToBack, CommandGroup::FORMAT ); + implDescribeSupportedFeature( ".uno:FontDialog", ChartCommandID::ShapeFontDialog, CommandGroup::EDIT ); + implDescribeSupportedFeature( ".uno:ParagraphDialog", ChartCommandID::ShapeParagraphDialog, CommandGroup::EDIT ); } IMPL_LINK( ShapeController, CheckNameHdl, AbstractSvxObjectNameDialog&, rDialog, bool ) { - OUString aName; - rDialog.GetName( aName ); + OUString aName = rDialog.GetName(); if ( !aName.isEmpty() ) { @@ -247,7 +239,7 @@ void ShapeController::executeDispatch_FormatLine() SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; if ( bHasMarked ) { pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); @@ -283,14 +275,14 @@ void ShapeController::executeDispatch_FormatArea() return; SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; if ( bHasMarked ) { pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr< AbstractSvxAreaTabDialog > pDlg( - pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true)); + pFact->CreateSvxAreaTabDialog(pChartWindow, &aAttr, &pDrawModelWrapper->getSdrModel(), true, false)); if ( pDlg->Execute() == RET_OK ) { const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); @@ -317,26 +309,32 @@ void ShapeController::executeDispatch_TextAttributes() return; SfxItemSet aAttr( pDrawViewWrapper->GetDefaultAttr() ); - bool bHasMarked = pDrawViewWrapper->AreObjectsMarked(); + bool bHasMarked = pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() != 0; if ( bHasMarked ) { pDrawViewWrapper->MergeAttrFromMarked( aAttr, false ); } SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); - ScopedVclPtr< SfxAbstractTabDialog > pDlg( + VclPtr< SfxAbstractTabDialog > pDlg( pFact->CreateTextTabDialog(pChartWindow, &aAttr, pDrawViewWrapper)); - if ( pDlg->Execute() == RET_OK ) - { - const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); - if ( bHasMarked ) - { - pDrawViewWrapper->SetAttributes( *pOutAttr ); - } - else + pDlg->StartExecuteAsync( + [pDlg, bHasMarked, pDrawViewWrapper] (sal_Int32 nResult)->void { - pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); + if ( RET_OK == nResult ) + { + const SfxItemSet* pOutAttr = pDlg->GetOutputItemSet(); + if ( bHasMarked ) + { + pDrawViewWrapper->SetAttributes( *pOutAttr ); + } + else + { + pDrawViewWrapper->SetDefaultAttr( *pOutAttr, false ); + } + } + pDlg->disposeOnce(); } - } + ); } void ShapeController::executeDispatch_TransformDialog() @@ -351,18 +349,18 @@ void ShapeController::executeDispatch_TransformDialog() return; SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); - if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == OBJ_CAPTION ) + if ( pSelectedObj && pSelectedObj->GetObjIdentifier() == SdrObjKind::Caption ) { // item set for caption - SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); + SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool()); pDrawViewWrapper->GetAttributes( aAttr ); // item set for position and size SfxItemSet aGeoAttr( pDrawViewWrapper->GetGeoAttrFromMarked() ); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); ScopedVclPtr< SfxAbstractTabDialog > pDlg( pFact->CreateCaptionDialog(pChartWindow, pDrawViewWrapper)); - const sal_uInt16* pRange = pDlg->GetInputRanges( *aAttr.GetPool() ); - SfxItemSet aCombAttr( *aAttr.GetPool(), pRange ); + const WhichRangesContainer aRange = pDlg->GetInputRanges( *aAttr.GetPool() ); + SfxItemSet aCombAttr( *aAttr.GetPool(), aRange ); aCombAttr.Put( aAttr ); aCombAttr.Put( aGeoAttr ); pDlg->SetInputSet( &aCombAttr ); @@ -394,7 +392,7 @@ void ShapeController::executeDispatch_ObjectTitleDescription() return; DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1) ) + if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) ) return; SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); @@ -403,17 +401,23 @@ void ShapeController::executeDispatch_ObjectTitleDescription() OUString aTitle( pSelectedObj->GetTitle() ); OUString aDescription( pSelectedObj->GetDescription() ); + bool isDecorative(pSelectedObj->IsDecorative()); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - ScopedVclPtr< AbstractSvxObjectTitleDescDialog > pDlg( - pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription)); - if ( pDlg->Execute() == RET_OK ) - { - pDlg->GetTitle( aTitle ); - pDlg->GetDescription( aDescription ); - pSelectedObj->SetTitle( aTitle ); - pSelectedObj->SetDescription( aDescription ); - } + VclPtr< AbstractSvxObjectTitleDescDialog > pDlg( + pFact->CreateSvxObjectTitleDescDialog(pChartWindow, aTitle, aDescription, isDecorative)); + pDlg->StartExecuteAsync( + [pDlg, pSelectedObj] (sal_Int32 nResult)->void + { + if (nResult == RET_OK) + { + pSelectedObj->SetTitle( pDlg->GetTitle() ); + pSelectedObj->SetDescription( pDlg->GetDescription() ); + pSelectedObj->SetDecorative(pDlg->IsDecorative()); + } + pDlg->disposeOnce(); + } + ); } void ShapeController::executeDispatch_RenameObject() @@ -423,30 +427,35 @@ void ShapeController::executeDispatch_RenameObject() return; DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); - if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectCount() == 1) ) + if ( !(pDrawViewWrapper && pDrawViewWrapper->GetMarkedObjectList().GetMarkCount() == 1) ) return; SdrObject* pSelectedObj = pDrawViewWrapper->getSelectedObject(); if ( !pSelectedObj ) return; - OUString aName = pSelectedObj->GetName(); SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); weld::Window* pChartWindow(m_pChartController->GetChartFrame()); - ScopedVclPtr< AbstractSvxObjectNameDialog > pDlg( - pFact->CreateSvxObjectNameDialog(pChartWindow, aName)); + VclPtr< AbstractSvxObjectNameDialog > pDlg( + pFact->CreateSvxObjectNameDialog(pChartWindow, pSelectedObj->GetName())); pDlg->SetCheckNameHdl( LINK( this, ShapeController, CheckNameHdl ) ); - if ( pDlg->Execute() == RET_OK ) - { - pDlg->GetName(aName); - if (pSelectedObj->GetName() == aName) + pDlg->StartExecuteAsync( + [pDlg, pSelectedObj] (sal_Int32 nResult)->void { - pSelectedObj->SetName( aName ); + if (nResult == RET_OK) + { + OUString aName = pDlg->GetName(); + if (pSelectedObj->GetName() != aName) + { + pSelectedObj->SetName( aName ); + } + } + pDlg->disposeOnce(); } - } + ); } -void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) +void ShapeController::executeDispatch_ChangeZOrder( ChartCommandID nId ) { SolarMutexGuard aGuard; DrawViewWrapper* pDrawViewWrapper = ( m_pChartController ? m_pChartController->GetDrawViewWrapper() : nullptr ); @@ -455,7 +464,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) switch ( nId ) { - case COMMAND_ID_BRING_TO_FRONT: + case ChartCommandID::ShapeBringToFront: { if ( isForwardPossible() ) { @@ -463,7 +472,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) } } break; - case COMMAND_ID_FORWARD: + case ChartCommandID::ShapeForward: { if ( isForwardPossible() ) { @@ -471,7 +480,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) } } break; - case COMMAND_ID_BACKWARD: + case ChartCommandID::ShapeBackward: { if ( isBackwardPossible() ) { @@ -479,7 +488,7 @@ void ShapeController::executeDispatch_ChangeZOrder( sal_uInt16 nId ) } } break; - case COMMAND_ID_SEND_TO_BACK: + case ChartCommandID::ShapeSendToBack: { if ( isBackwardPossible() ) { @@ -506,7 +515,7 @@ void ShapeController::executeDispatch_FontDialog() DrawViewWrapper* pDrawViewWrapper = m_pChartController->GetDrawViewWrapper(); if ( pChartWindow && pDrawModelWrapper && pDrawViewWrapper ) { - SfxItemSet aAttr( pDrawViewWrapper->GetModel()->GetItemPool() ); + SfxItemSet aAttr(pDrawViewWrapper->GetModel().GetItemPool()); pDrawViewWrapper->GetAttributes( aAttr ); ViewElementListProvider aViewElementListProvider( pDrawModelWrapper ); ShapeFontDialog aDlg(pChartWindow, &aAttr, &aViewElementListProvider); @@ -529,15 +538,13 @@ void ShapeController::executeDispatch_ParagraphDialog() if ( !(pChartWindow && pDrawViewWrapper) ) return; - SfxItemPool& rPool = pDrawViewWrapper->GetModel()->GetItemPool(); + SfxItemPool& rPool = pDrawViewWrapper->GetModel().GetItemPool(); SfxItemSet aAttr( rPool ); pDrawViewWrapper->GetAttributes( aAttr ); - SfxItemSet aNewAttr( - rPool, - svl::Items< + SfxItemSetFixed< EE_ITEMS_START, EE_ITEMS_END, - SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS>{}); + SID_ATTR_PARA_PAGEBREAK, SID_ATTR_PARA_WIDOWS> aNewAttr(rPool); aNewAttr.Put( aAttr ); aNewAttr.Put( SvxHyphenZoneItem( false, SID_ATTR_PARA_HYPHENZONE ) ); aNewAttr.Put( SvxFormatBreakItem( SvxBreak::NONE, SID_ATTR_PARA_PAGEBREAK ) ); @@ -563,18 +570,17 @@ SdrObject* ShapeController::getFirstAdditionalShape() if ( pDrawModelWrapper ) { Reference< drawing::XShape > xFirstShape; - Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = 0; i < nCount; ++i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { - xFirstShape = xShape; + xFirstShape = std::move(xShape); break; } } @@ -603,18 +609,17 @@ SdrObject* ShapeController::getLastAdditionalShape() if ( pDrawModelWrapper ) { Reference< drawing::XShape > xLastShape; - Reference< drawing::XDrawPage > xDrawPage( pDrawModelWrapper->getMainDrawPage() ); - Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY_THROW ); + rtl::Reference<SvxDrawPage> xDrawPage( pDrawModelWrapper->getMainDrawPage() ); Reference< drawing::XShapes > xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); - sal_Int32 nCount = xDrawPageShapes->getCount(); + sal_Int32 nCount = xDrawPage->getCount(); for ( sal_Int32 i = nCount - 1; i >= 0; --i ) { Reference< drawing::XShape > xShape; - if ( xDrawPageShapes->getByIndex( i ) >>= xShape ) + if ( xDrawPage->getByIndex( i ) >>= xShape ) { if ( xShape.is() && xShape != xChartRoot ) { - xLastShape = xShape; + xLastShape = std::move(xShape); break; } } diff --git a/chart2/source/controller/main/ShapeController.hxx b/chart2/source/controller/main/ShapeController.hxx index 3d65c49e504c..cdd8002ce2d8 100644 --- a/chart2/source/controller/main/ShapeController.hxx +++ b/chart2/source/controller/main/ShapeController.hxx @@ -41,7 +41,7 @@ public: protected: // WeakComponentImplHelperBase - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // XEventListener virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override; @@ -64,7 +64,7 @@ private: void executeDispatch_TransformDialog(); void executeDispatch_ObjectTitleDescription(); void executeDispatch_RenameObject(); - void executeDispatch_ChangeZOrder( sal_uInt16 nId ); + void executeDispatch_ChangeZOrder( ChartCommandID nId ); void executeDispatch_FontDialog(); void executeDispatch_ParagraphDialog(); diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.cxx b/chart2/source/controller/main/StatusBarCommandDispatch.cxx index 1e6c06c35b6f..863436c3bab0 100644 --- a/chart2/source/controller/main/StatusBarCommandDispatch.cxx +++ b/chart2/source/controller/main/StatusBarCommandDispatch.cxx @@ -19,9 +19,9 @@ #include "StatusBarCommandDispatch.hxx" #include <ObjectNameProvider.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/util/XModifiable.hpp> +#include <ChartModel.hxx> +#include <utility> using namespace ::com::sun::star; @@ -33,10 +33,10 @@ namespace chart StatusBarCommandDispatch::StatusBarCommandDispatch( const Reference< uno::XComponentContext > & xContext, - const Reference< frame::XModel > & xModel, + rtl::Reference<::chart::ChartModel> xModel, const Reference< view::XSelectionSupplier > & xSelSupp ) : impl::StatusBarCommandDispatch_Base( xContext ), - m_xModifiable( xModel, uno::UNO_QUERY ), + m_xChartModel(std::move( xModel )), m_xSelectionSupplier( xSelSupp ), m_bIsModified( false ) {} @@ -46,9 +46,9 @@ StatusBarCommandDispatch::~StatusBarCommandDispatch() void StatusBarCommandDispatch::initialize() { - if( m_xModifiable.is()) + if( m_xChartModel.is()) { - m_xModifiable->addModifyListener( this ); + m_xChartModel->addModifyListener( this ); } if( m_xSelectionSupplier.is()) @@ -65,19 +65,18 @@ void StatusBarCommandDispatch::fireStatusEvent( bool bFireContext( bFireAll || rURL == ".uno:Context" ); bool bFireModified( bFireAll || rURL == ".uno:ModifiedStatus" ); - if( bFireContext ) + if( bFireContext && m_xChartModel.is()) { uno::Any aArg; - Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY ); - aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), xDoc ); - fireStatusEventForURL( ".uno:Context", aArg, true, xSingleListener ); + aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedOID.getObjectCID(), m_xChartModel ); + fireStatusEventForURL( u".uno:Context"_ustr, aArg, true, xSingleListener ); } if( bFireModified ) { uno::Any aArg; if( m_bIsModified ) - aArg <<= OUString("*"); - fireStatusEventForURL( ".uno:ModifiedStatus", aArg, true, xSingleListener ); + aArg <<= u"*"_ustr; + fireStatusEventForURL( u".uno:ModifiedStatus"_ustr, aArg, true, xSingleListener ); } } @@ -91,24 +90,24 @@ void SAL_CALL StatusBarCommandDispatch::dispatch( // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed -void SAL_CALL StatusBarCommandDispatch::disposing() +void StatusBarCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { - m_xModifiable.clear(); + m_xChartModel.clear(); m_xSelectionSupplier.clear(); } // ____ XEventListener (base of XModifyListener) ____ void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ ) { - m_xModifiable.clear(); + m_xChartModel.clear(); m_xSelectionSupplier.clear(); } // ____ XModifyListener ____ void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent ) { - if( m_xModifiable.is()) - m_bIsModified = m_xModifiable->isModified(); + if( m_xChartModel.is()) + m_bIsModified = m_xChartModel->isModified(); CommandDispatch::modified( aEvent ); } diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.hxx b/chart2/source/controller/main/StatusBarCommandDispatch.hxx index 4551eb5a0c57..438952631206 100644 --- a/chart2/source/controller/main/StatusBarCommandDispatch.hxx +++ b/chart2/source/controller/main/StatusBarCommandDispatch.hxx @@ -22,9 +22,8 @@ #include <ObjectIdentifier.hxx> #include <cppuhelper/implbase.hxx> #include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <rtl/ref.hxx> -namespace com::sun::star::frame { class XModel; } -namespace com::sun::star::util { class XModifiable; } namespace com::sun::star::view { class XSelectionSupplier; } namespace chart @@ -48,7 +47,7 @@ class StatusBarCommandDispatch : public impl::StatusBarCommandDispatch_Base public: explicit StatusBarCommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext, - const css::uno::Reference< css::frame::XModel > & xModel, + rtl::Reference<::chart::ChartModel> xModel, const css::uno::Reference< css::view::XSelectionSupplier > & xSelSupp ); virtual ~StatusBarCommandDispatch() override; @@ -63,7 +62,7 @@ protected: // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // ____ XModifyListener (override from CommandDispatch) ____ virtual void SAL_CALL modified( @@ -82,7 +81,7 @@ protected: const css::lang::EventObject& aEvent ) override; private: - css::uno::Reference< css::util::XModifiable > m_xModifiable; + rtl::Reference<::chart::ChartModel> m_xChartModel; css::uno::Reference< css::view::XSelectionSupplier > m_xSelectionSupplier; bool m_bIsModified; ObjectIdentifier m_aSelectedOID; diff --git a/chart2/source/controller/main/ToolbarController.cxx b/chart2/source/controller/main/ToolbarController.cxx index b985558a3a0b..de04e4c91b4d 100644 --- a/chart2/source/controller/main/ToolbarController.cxx +++ b/chart2/source/controller/main/ToolbarController.cxx @@ -19,21 +19,18 @@ namespace com::sun::star::uno { class XComponentContext; } namespace chart { -ChartToolbarController::ChartToolbarController(const css::uno::Sequence<css::uno::Any>& rProperties): - ChartToolbarControllerBase(m_aMutex) +ChartToolbarController::ChartToolbarController(const css::uno::Sequence<css::uno::Any>& rProperties) { - css::uno::Reference<css::frame::XFrame> xFrame; - sal_Int32 nLength = rProperties.getLength(); - for (sal_Int32 i = 0; i < nLength; ++i) + for (const auto& rProperty : rProperties) { css::beans::PropertyValue aPropValue; - rProperties[i] >>= aPropValue; + rProperty >>= aPropValue; if (aPropValue.Name == "Frame") - aPropValue.Value >>= xFrame; + { + mxFramesSupplier.set(aPropValue.Value, css::uno::UNO_QUERY); + break; + } } - - css::uno::Reference<css::frame::XFramesSupplier> xFramesSupplier(xFrame, css::uno::UNO_QUERY); - mxFramesSupplier = xFramesSupplier; } ChartToolbarController::~ChartToolbarController() @@ -100,7 +97,7 @@ void ChartToolbarController::update() OUString ChartToolbarController::getImplementationName() { - return "org.libreoffice.chart2.Chart2ToolboxController"; + return u"org.libreoffice.chart2.Chart2ToolboxController"_ustr; } sal_Bool ChartToolbarController::supportsService(OUString const & ServiceName) @@ -110,7 +107,7 @@ sal_Bool ChartToolbarController::supportsService(OUString const & ServiceName) css::uno::Sequence<OUString> ChartToolbarController::getSupportedServiceNames() { - return { "com.sun.star.frame.ToolbarController" }; + return { u"com.sun.star.frame.ToolbarController"_ustr }; } } diff --git a/chart2/source/controller/main/UndoActions.cxx b/chart2/source/controller/main/UndoActions.cxx index 78bc1f6b0ef4..a3c899253295 100644 --- a/chart2/source/controller/main/UndoActions.cxx +++ b/chart2/source/controller/main/UndoActions.cxx @@ -19,27 +19,25 @@ #include "UndoActions.hxx" #include "ChartModelClone.hxx" +#include <ChartModel.hxx> #include <com/sun/star/lang/DisposedException.hpp> #include <svx/svdundo.hxx> #include <memory> +#include <utility> using namespace ::com::sun::star; namespace chart::impl { - using ::com::sun::star::uno::Reference; - using ::com::sun::star::frame::XModel; using ::com::sun::star::lang::DisposedException; -UndoElement::UndoElement( const OUString& i_actionString, const Reference< XModel >& i_documentModel, const std::shared_ptr< ChartModelClone >& i_modelClone ) - :UndoElement_MBase() - ,UndoElement_TBase( m_aMutex ) - ,m_sActionString( i_actionString ) - ,m_xDocumentModel( i_documentModel ) - ,m_pModelClone( i_modelClone ) +UndoElement::UndoElement( OUString i_actionString, rtl::Reference<::chart::ChartModel> i_documentModel, std::shared_ptr< ChartModelClone > i_modelClone ) + :m_sActionString(std::move( i_actionString )) + ,m_xDocumentModel(std::move( i_documentModel )) + ,m_pModelClone(std::move( i_modelClone )) { } @@ -47,7 +45,7 @@ UndoElement::~UndoElement() { } -void SAL_CALL UndoElement::disposing() +void UndoElement::disposing(std::unique_lock<std::mutex>&) { if ( m_pModelClone ) m_pModelClone->dispose(); @@ -67,7 +65,7 @@ void UndoElement::impl_toggleModelState() // apply the previous snapshot to our model m_pModelClone->applyToModel( m_xDocumentModel ); // remember the new snapshot, for the next toggle - m_pModelClone = pNewClone; + m_pModelClone = std::move(pNewClone); } void SAL_CALL UndoElement::undo( ) @@ -83,9 +81,7 @@ void SAL_CALL UndoElement::redo( ) // = ShapeUndoElement ShapeUndoElement::ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction ) - :ShapeUndoElement_MBase() - ,ShapeUndoElement_TBase( m_aMutex ) - ,m_xAction( std::move(xSdrUndoAction) ) + :m_xAction( std::move(xSdrUndoAction) ) { } @@ -114,10 +110,6 @@ void SAL_CALL ShapeUndoElement::redo( ) m_xAction->Redo(); } -void SAL_CALL ShapeUndoElement::disposing() -{ -} - } // namespace chart::impl /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/main/UndoActions.hxx b/chart2/source/controller/main/UndoActions.hxx index 81b4121047a9..10fc0aeb5817 100644 --- a/chart2/source/controller/main/UndoActions.hxx +++ b/chart2/source/controller/main/UndoActions.hxx @@ -20,28 +20,25 @@ #include <com/sun/star/document/XUndoAction.hpp> +#include <rtl/ref.hxx> #include <rtl/ustring.hxx> -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <memory> -namespace com::sun::star::frame { class XModel; } - class SdrUndoAction; namespace chart { +class ChartModel; class ChartModelClone; namespace impl { -typedef ::cppu::BaseMutex UndoElement_MBase; -typedef ::cppu::WeakComponentImplHelper< css::document::XUndoAction > UndoElement_TBase; +typedef comphelper::WeakComponentImplHelper< css::document::XUndoAction > UndoElement_TBase; -class UndoElement :public UndoElement_MBase - ,public UndoElement_TBase +class UndoElement final : public UndoElement_TBase { public: /** creates a new undo action @@ -54,10 +51,11 @@ public: is the cloned model from before the changes, which the Undo action represents, have been applied. Upon <member>invoking</member>, the clone model is applied to the document model. */ - UndoElement( const OUString & i_actionString, - const css::uno::Reference< css::frame::XModel >& i_documentModel, - const std::shared_ptr< ChartModelClone >& i_modelClone + UndoElement( OUString i_actionString, + rtl::Reference<::chart::ChartModel> i_documentModel, + std::shared_ptr< ChartModelClone > i_modelClone ); + virtual ~UndoElement() override; UndoElement(const UndoElement&) = delete; const UndoElement& operator=(const UndoElement&) = delete; @@ -67,40 +65,30 @@ public: virtual void SAL_CALL undo( ) override; virtual void SAL_CALL redo( ) override; - // OComponentHelper - virtual void SAL_CALL disposing() override; - -protected: - virtual ~UndoElement() override; + // WeakComponentImplHelper + virtual void disposing(std::unique_lock<std::mutex>&) override; private: void impl_toggleModelState(); private: OUString m_sActionString; - css::uno::Reference< css::frame::XModel > m_xDocumentModel; + rtl::Reference<::chart::ChartModel> m_xDocumentModel; std::shared_ptr< ChartModelClone > m_pModelClone; }; -typedef ::cppu::BaseMutex ShapeUndoElement_MBase; -typedef ::cppu::WeakComponentImplHelper< css::document::XUndoAction > ShapeUndoElement_TBase; -class ShapeUndoElement :public ShapeUndoElement_MBase - ,public ShapeUndoElement_TBase +typedef comphelper::WeakComponentImplHelper< css::document::XUndoAction > ShapeUndoElement_TBase; +class ShapeUndoElement final : public ShapeUndoElement_TBase { public: explicit ShapeUndoElement( std::unique_ptr<SdrUndoAction> xSdrUndoAction ); + virtual ~ShapeUndoElement() override; // XUndoAction virtual OUString SAL_CALL getTitle() override; virtual void SAL_CALL undo( ) override; virtual void SAL_CALL redo( ) override; - // OComponentHelper - virtual void SAL_CALL disposing() override; - -protected: - virtual ~ShapeUndoElement() override; - private: std::unique_ptr<SdrUndoAction> m_xAction; }; diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx index e4bd85a3be34..1c5c760f93f5 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.cxx +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -18,14 +18,14 @@ */ #include "UndoCommandDispatch.hxx" +#include <ChartModel.hxx> -#include <com/sun/star/frame/XModel.hpp> #include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/document/UndoFailedException.hpp> -#include <com/sun/star/document/XUndoManagerSupplier.hpp> +#include <utility> #include <vcl/svapp.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> #include <svtools/strings.hrc> #include <svtools/svtresid.hxx> @@ -40,12 +40,11 @@ namespace chart UndoCommandDispatch::UndoCommandDispatch( const Reference< uno::XComponentContext > & xContext, - const Reference< frame::XModel > & xModel ) : + rtl::Reference<::chart::ChartModel> xModel ) : CommandDispatch( xContext ), - m_xModel( xModel ) + m_xModel(std::move( xModel )) { - uno::Reference< document::XUndoManagerSupplier > xSuppUndo( m_xModel, uno::UNO_QUERY_THROW ); - m_xUndoManager.set( xSuppUndo->getUndoManager(), uno::UNO_SET_THROW ); + m_xUndoManager.set( m_xModel->getUndoManager(), uno::UNO_SET_THROW ); } UndoCommandDispatch::~UndoCommandDispatch() @@ -76,13 +75,13 @@ void UndoCommandDispatch::fireStatusEvent( aRedoStrings <<= m_xUndoManager->getAllRedoActionTitles(); if( bFireAll || rURL == ".uno:Undo" ) - fireStatusEventForURL( ".uno:Undo", aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); + fireStatusEventForURL( u".uno:Undo"_ustr, aUndoState, m_xUndoManager->isUndoPossible(), xSingleListener ); if( bFireAll || rURL == ".uno:Redo" ) - fireStatusEventForURL( ".uno:Redo", aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); + fireStatusEventForURL( u".uno:Redo"_ustr, aRedoState, m_xUndoManager->isRedoPossible(), xSingleListener ); if( bFireAll || rURL == ".uno:GetUndoStrings" ) - fireStatusEventForURL( ".uno:GetUndoStrings", aUndoStrings, true, xSingleListener ); + fireStatusEventForURL( u".uno:GetUndoStrings"_ustr, aUndoStrings, true, xSingleListener ); if( bFireAll || rURL == ".uno:GetRedoStrings" ) - fireStatusEventForURL( ".uno:GetRedoStrings", aRedoStrings, true, xSingleListener ); + fireStatusEventForURL( u".uno:GetRedoStrings"_ustr, aRedoStrings, true, xSingleListener ); } // ____ XDispatch ____ @@ -122,7 +121,7 @@ void SAL_CALL UndoCommandDispatch::dispatch( // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed -void SAL_CALL UndoCommandDispatch::disposing() +void UndoCommandDispatch::disposing(std::unique_lock<std::mutex>& /*rGuard*/) { Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); OSL_ENSURE( xBroadcaster.is(), "UndoCommandDispatch::initialize: missing modification broadcaster interface!" ); diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx index cfb0e11078df..f09554103844 100644 --- a/chart2/source/controller/main/UndoCommandDispatch.hxx +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -19,12 +19,13 @@ #pragma once #include "CommandDispatch.hxx" +#include <rtl/ref.hxx> namespace com::sun::star::document { class XUndoManager; } -namespace com::sun::star::frame { class XModel; } namespace chart { +class ChartModel; /** This is a CommandDispatch implementation for Undo and Redo. */ @@ -33,7 +34,7 @@ class UndoCommandDispatch : public CommandDispatch public: explicit UndoCommandDispatch( const css::uno::Reference< css::uno::XComponentContext > & xContext, - const css::uno::Reference< css::frame::XModel > & xModel ); + rtl::Reference<::chart::ChartModel> xModel ); virtual ~UndoCommandDispatch() override; // late initialisation, especially for adding as listener @@ -47,7 +48,7 @@ protected: // ____ WeakComponentImplHelperBase ____ /// is called when this is disposed - virtual void SAL_CALL disposing() override; + virtual void disposing(std::unique_lock<std::mutex>& rGuard) override; // ____ XEventListener (base of XModifyListener) ____ virtual void SAL_CALL disposing( @@ -58,7 +59,7 @@ protected: const css::uno::Reference< css::frame::XStatusListener > & xSingleListener ) override; private: - css::uno::Reference< css::frame::XModel > m_xModel; + rtl::Reference<::chart::ChartModel> m_xModel; css::uno::Reference< css::document::XUndoManager > m_xUndoManager; }; diff --git a/chart2/source/controller/main/UndoGuard.cxx b/chart2/source/controller/main/UndoGuard.cxx index 91687aebd28f..4e870c36d07d 100644 --- a/chart2/source/controller/main/UndoGuard.cxx +++ b/chart2/source/controller/main/UndoGuard.cxx @@ -20,11 +20,12 @@ #include "UndoGuard.hxx" #include "ChartModelClone.hxx" #include "UndoActions.hxx" +#include <ChartModel.hxx> #include <com/sun/star/document/XUndoManager.hpp> -#include <com/sun/star/frame/XModel.hpp> +#include <utility> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace ::com::sun::star; @@ -33,14 +34,14 @@ using ::com::sun::star::uno::Reference; namespace chart { -UndoGuard::UndoGuard( const OUString& i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager, +UndoGuard::UndoGuard( OUString i_undoString, const uno::Reference< document::XUndoManager > & i_undoManager, const ModelFacet i_facet ) - :m_xChartModel( i_undoManager->getParent(), uno::UNO_QUERY_THROW ) - ,m_xUndoManager( i_undoManager ) - ,m_pDocumentSnapshot() - ,m_aUndoString( i_undoString ) + :m_xUndoManager( i_undoManager ) + ,m_aUndoString(std::move( i_undoString )) ,m_bActionPosted( false ) { + m_xChartModel = dynamic_cast<::chart::ChartModel*>(i_undoManager->getParent().get()); + assert(m_xChartModel); m_pDocumentSnapshot = std::make_shared<ChartModelClone>( m_xChartModel, i_facet ); } diff --git a/chart2/source/controller/main/UndoGuard.hxx b/chart2/source/controller/main/UndoGuard.hxx index c983854e2fcd..83938e86370a 100644 --- a/chart2/source/controller/main/UndoGuard.hxx +++ b/chart2/source/controller/main/UndoGuard.hxx @@ -25,7 +25,6 @@ #include <memory> namespace com::sun::star::document { class XUndoManager; } -namespace com::sun::star::frame { class XModel; } namespace chart { @@ -37,7 +36,7 @@ class UndoGuard { public: explicit UndoGuard( - const OUString& i_undoMessage, + OUString i_undoMessage, const css::uno::Reference< css::document::XUndoManager > & i_undoManager, const ModelFacet i_facet = E_MODEL ); @@ -53,7 +52,7 @@ private: void discardSnapshot(); private: - const css::uno::Reference< css::frame::XModel > m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; const css::uno::Reference< css::document::XUndoManager > m_xUndoManager; std::shared_ptr< ChartModelClone > m_pDocumentSnapshot; diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx index b5bde521d031..9274dc2e346c 100644 --- a/chart2/source/controller/sidebar/Chart2PanelFactory.cxx +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.cxx @@ -34,13 +34,13 @@ #include "ChartErrorBarPanel.hxx" #include "ChartAreaPanel.hxx" #include "ChartLinePanel.hxx" +#include "ChartColorsPanel.hxx" using namespace css::uno; namespace chart::sidebar { ChartPanelFactory::ChartPanelFactory() - : PanelFactoryInterfaceBase(m_aMutex) { } @@ -57,9 +57,9 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( try { const ::comphelper::NamedValueCollection aArguments (rArguments); - Reference<css::frame::XFrame> xFrame (aArguments.getOrDefault("Frame", Reference<css::frame::XFrame>())); - Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault("ParentWindow", Reference<css::awt::XWindow>())); - Reference<css::frame::XController> xController (aArguments.getOrDefault("Controller", Reference<css::frame::XController>())); + Reference<css::frame::XFrame> xFrame(sfx2::sidebar::GetFrame(aArguments)); + Reference<css::awt::XWindow> xParentWindow (aArguments.getOrDefault(u"ParentWindow"_ustr, Reference<css::awt::XWindow>())); + Reference<css::frame::XController> xController (aArguments.getOrDefault(u"Controller"_ustr, Reference<css::frame::XController>())); weld::Widget* pParent(nullptr); if (weld::TransportAsXWindow* pTunnel = dynamic_cast<weld::TransportAsXWindow*>(xParentWindow.get())) @@ -67,21 +67,21 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( if (!pParent) throw RuntimeException( - "PanelFactory::createUIElement called without ParentWindow", + u"PanelFactory::createUIElement called without ParentWindow"_ustr, nullptr); if ( ! xFrame.is()) throw RuntimeException( - "PanelFactory::createUIElement called without Frame", + u"PanelFactory::createUIElement called without Frame"_ustr, nullptr); if (!xController.is()) throw RuntimeException( - "ChartPanelFactory::createUIElement called without Controller", + u"ChartPanelFactory::createUIElement called without Controller"_ustr, nullptr); ChartController* pController = dynamic_cast<ChartController*>(xController.get()); if (!pController) throw RuntimeException( - "ChartPanelFactory::createUIElement called without valid ChartController", + u"ChartPanelFactory::createUIElement called without valid ChartController"_ustr, nullptr); std::unique_ptr<PanelLayout> xPanel; @@ -99,6 +99,8 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( xPanel = ChartAreaPanel::Create(pParent, xFrame, pController); else if (rsResourceURL.endsWith("/LinePanel")) xPanel = ChartLinePanel::Create(pParent, xFrame, pController); + else if (rsResourceURL.endsWith("/ColorsPanel")) + xPanel = ChartColorsPanel::Create(pParent, xFrame, pController); if (xPanel) xElement = sfx2::sidebar::SidebarPanelBase::Create( @@ -115,7 +117,7 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( { css::uno::Any anyEx = cppu::getCaughtException(); throw css::lang::WrappedTargetRuntimeException( - "ChartPanelFactory::createUIElement exception", + u"ChartPanelFactory::createUIElement exception"_ustr, nullptr, anyEx ); } @@ -124,7 +126,7 @@ Reference<css::ui::XUIElement> SAL_CALL ChartPanelFactory::createUIElement ( OUString ChartPanelFactory::getImplementationName() { - return "org.libreoffice.comp.chart2.sidebar.ChartPanelFactory"; + return u"org.libreoffice.comp.chart2.sidebar.ChartPanelFactory"_ustr; } sal_Bool ChartPanelFactory::supportsService(OUString const & ServiceName) @@ -134,7 +136,7 @@ sal_Bool ChartPanelFactory::supportsService(OUString const & ServiceName) css::uno::Sequence<OUString> ChartPanelFactory::getSupportedServiceNames() { - return { "com.sun.star.ui.UIElementFactory" }; + return { u"com.sun.star.ui.UIElementFactory"_ustr }; } } // end of namespace chart::sidebar diff --git a/chart2/source/controller/sidebar/Chart2PanelFactory.hxx b/chart2/source/controller/sidebar/Chart2PanelFactory.hxx index b218f4e41ebc..87619f647d70 100644 --- a/chart2/source/controller/sidebar/Chart2PanelFactory.hxx +++ b/chart2/source/controller/sidebar/Chart2PanelFactory.hxx @@ -18,21 +18,19 @@ */ #pragma once -#include <cppuhelper/compbase.hxx> -#include <cppuhelper/basemutex.hxx> +#include <comphelper/compbase.hxx> #include <com/sun/star/lang/XServiceInfo.hpp> #include <com/sun/star/ui/XUIElementFactory.hpp> namespace chart::sidebar { -typedef ::cppu::WeakComponentImplHelper < +typedef comphelper::WeakComponentImplHelper < css::ui::XUIElementFactory, css::lang::XServiceInfo > PanelFactoryInterfaceBase; -class ChartPanelFactory - : private ::cppu::BaseMutex, - public PanelFactoryInterfaceBase +class ChartPanelFactory final + : public PanelFactoryInterfaceBase { public: ChartPanelFactory(); diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index 0378f7bbda6f..87a49974eb8c 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -14,11 +14,11 @@ #include "ChartAreaPanel.hxx" #include <ChartController.hxx> +#include <ChartModel.hxx> #include <ViewElementListProvider.hxx> #include <PropertyHelper.hxx> #include <chartview/DrawModelWrapper.hxx> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/chart2/XDiagram.hpp> #include <sfx2/weldutils.hxx> @@ -36,12 +36,12 @@ namespace { SvxColorToolBoxControl* getColorToolBoxControl(const ToolbarUnoDispatcher& rColorDispatch) { - css::uno::Reference<css::frame::XToolbarController> xController = rColorDispatch.GetControllerForCommand(".uno:FillColor"); + css::uno::Reference<css::frame::XToolbarController> xController = rColorDispatch.GetControllerForCommand(u".uno:FillColor"_ustr); SvxColorToolBoxControl* pToolBoxColorControl = dynamic_cast<SvxColorToolBoxControl*>(xController.get()); return pToolBoxColorControl; } -OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) +OUString getCID(const rtl::Reference<::chart::ChartModel>& xModel) { css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController()); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); @@ -72,7 +72,7 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) } css::uno::Reference<css::beans::XPropertySet> getPropSet( - const css::uno::Reference<css::frame::XModel>& xModel) + const rtl::Reference<::chart::ChartModel>& xModel) { OUString aCID = getCID(xModel); css::uno::Reference<css::beans::XPropertySet> xPropSet = @@ -123,7 +123,7 @@ XFillGradientItem getXGradientForName(const css::uno::Reference<css::frame::XMod { css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY); css::uno::Reference<css::container::XNameAccess> xNameAccess( - xFact->createInstance("com.sun.star.drawing.GradientTable"), css::uno::UNO_QUERY); + xFact->createInstance(u"com.sun.star.drawing.GradientTable"_ustr), css::uno::UNO_QUERY); if (!xNameAccess.is()) return XFillGradientItem(); @@ -145,7 +145,7 @@ XFillFloatTransparenceItem getXTransparencyGradientForName(const css::uno::Refer { css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY); css::uno::Reference<css::container::XNameAccess> xNameAccess( - xFact->createInstance("com.sun.star.drawing.TransparencyGradientTable"), css::uno::UNO_QUERY); + xFact->createInstance(u"com.sun.star.drawing.TransparencyGradientTable"_ustr), css::uno::UNO_QUERY); if (!xNameAccess.is()) return XFillFloatTransparenceItem(); @@ -262,9 +262,9 @@ std::unique_ptr<PanelLayout> ChartAreaPanel::Create( ChartController* pController) { if (pParent == nullptr) - throw css::lang::IllegalArgumentException("no parent Window given to ChartAxisPanel::Create", nullptr, 0); + throw css::lang::IllegalArgumentException(u"no parent Window given to ChartAxisPanel::Create"_ustr, nullptr, 0); if (!rxFrame.is()) - throw css::lang::IllegalArgumentException("no XFrame given to ChartAxisPanel::Create", nullptr, 1); + throw css::lang::IllegalArgumentException(u"no XFrame given to ChartAxisPanel::Create"_ustr, nullptr, 1); return std::make_unique<ChartAreaPanel>(pParent, rxFrame, pController); } @@ -273,17 +273,17 @@ ChartAreaPanel::ChartAreaPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, ChartController* pController): svx::sidebar::AreaPropertyPanelBase(pParent, rxFrame), - mxModel(pController->getModel()), + mxModel(pController->getChartModel()), mxListener(new ChartSidebarModifyListener(this)), mxSelectionListener(new ChartSidebarSelectionListener(this)), mbUpdate(true), mbModelValid(true), - maFillColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), "FillColor") + maFillColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), u"FillColor"_ustr) { std::vector<ObjectType> aAcceptedTypes { OBJECTTYPE_PAGE, OBJECTTYPE_DIAGRAM, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_DATA_POINT, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND}; - mxSelectionListener->setAcceptedTypes(aAcceptedTypes); + mxSelectionListener->setAcceptedTypes(std::move(aAcceptedTypes)); Initialize(); } @@ -294,8 +294,7 @@ ChartAreaPanel::~ChartAreaPanel() void ChartAreaPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -307,6 +306,13 @@ void ChartAreaPanel::Initialize() updateData(); } +bool ChartAreaPanel::selectionIsDataSeries() const +{ + OUString aCID = getCID(mxModel); + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + return eType == ObjectType::OBJECTTYPE_DATA_SERIES || eType == ObjectType::OBJECTTYPE_DATA_POINT; +} + void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem) { PreventUpdate aProtector(mbUpdate); @@ -314,7 +320,7 @@ void ChartAreaPanel::setFillTransparence(const XFillTransparenceItem& rItem) if (!xPropSet.is()) return; - xPropSet->setPropertyValue("FillTransparence", css::uno::Any(rItem.GetValue())); + xPropSet->setPropertyValue(u"FillTransparence"_ustr, css::uno::Any(rItem.GetValue())); } void ChartAreaPanel::setFillFloatTransparence( @@ -327,15 +333,15 @@ void ChartAreaPanel::setFillFloatTransparence( if (!rItem.IsEnabled()) { - xPropSet->setPropertyValue("FillTransparenceGradientName", css::uno::Any(OUString())); + xPropSet->setPropertyValue(u"FillTransparenceGradientName"_ustr, css::uno::Any(OUString())); return; } const OUString& aName = rItem.GetName(); css::uno::Any aGradientVal; rItem.QueryValue(aGradientVal, MID_FILLGRADIENT); - OUString aNewName = PropertyHelper::addTransparencyGradientUniqueNameToTable(aGradientVal, css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY_THROW), aName); - xPropSet->setPropertyValue("FillTransparenceGradientName", css::uno::Any(aNewName)); + OUString aNewName = PropertyHelper::addTransparencyGradientUniqueNameToTable(aGradientVal, mxModel, aName); + xPropSet->setPropertyValue(u"FillTransparenceGradientName"_ustr, css::uno::Any(aNewName)); } void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem) @@ -345,7 +351,7 @@ void ChartAreaPanel::setFillStyle(const XFillStyleItem& rItem) if (!xPropSet.is()) return; - xPropSet->setPropertyValue("FillStyle", css::uno::Any(rItem.GetValue())); + xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(rItem.GetValue())); } void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem, @@ -356,8 +362,12 @@ void ChartAreaPanel::setFillStyleAndColor(const XFillStyleItem* pStyleItem, return; if (pStyleItem) - xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue())); - xPropSet->setPropertyValue("FillColor", css::uno::Any(rColorItem.GetValue())); + xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue())); + xPropSet->setPropertyValue(u"FillColor"_ustr, css::uno::Any(rColorItem.GetValue())); + if (selectionIsDataSeries()) + { + mxModel->clearColorPalette(); + } } void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem, @@ -369,13 +379,13 @@ void ChartAreaPanel::setFillStyleAndGradient(const XFillStyleItem* pStyleItem, return; if (pStyleItem) - xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue())); + xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue())); const OUString& aName = rGradientItem.GetName(); css::uno::Any aGradientVal; rGradientItem.QueryValue(aGradientVal, MID_FILLGRADIENT); - OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(aGradientVal, css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY_THROW), aName); - xPropSet->setPropertyValue("FillGradientName", css::uno::Any(aNewName)); + OUString aNewName = PropertyHelper::addGradientUniqueNameToTable(aGradientVal, mxModel, aName); + xPropSet->setPropertyValue(u"FillGradientName"_ustr, css::uno::Any(aNewName)); } void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem, @@ -387,8 +397,8 @@ void ChartAreaPanel::setFillStyleAndHatch(const XFillStyleItem* pStyleItem, return; if (pStyleItem) - xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue())); - xPropSet->setPropertyValue("FillHatchName", css::uno::Any(rHatchItem.GetValue())); + xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue())); + xPropSet->setPropertyValue(u"FillHatchName"_ustr, css::uno::Any(rHatchItem.GetValue())); } void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, @@ -400,13 +410,19 @@ void ChartAreaPanel::setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, return; if (pStyleItem) - xPropSet->setPropertyValue("FillStyle", css::uno::Any(pStyleItem->GetValue())); + xPropSet->setPropertyValue(u"FillStyle"_ustr, css::uno::Any(pStyleItem->GetValue())); css::uno::Any aBitmap; rBitmapItem.QueryValue(aBitmap, MID_BITMAP); const OUString& aPreferredName = rBitmapItem.GetName(); - aBitmap <<= PropertyHelper::addBitmapUniqueNameToTable(aBitmap, css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY_THROW), aPreferredName); - xPropSet->setPropertyValue("FillBitmapName", aBitmap); + aBitmap <<= PropertyHelper::addBitmapUniqueNameToTable(aBitmap, mxModel, aPreferredName); + xPropSet->setPropertyValue(u"FillBitmapName"_ustr, aBitmap); +} + +void ChartAreaPanel::setFillUseBackground(const XFillStyleItem* pStyleItem, + const XFillUseSlideBackgroundItem& /*rItem*/) +{ + setFillStyle(*pStyleItem); } void ChartAreaPanel::updateData() @@ -423,43 +439,43 @@ void ChartAreaPanel::updateData() return; SolarMutexGuard aGuard; - if (xInfo->hasPropertyByName("FillStyle")) + if (xInfo->hasPropertyByName(u"FillStyle"_ustr)) { css::drawing::FillStyle eFillStyle = css::drawing::FillStyle_SOLID; - xPropSet->getPropertyValue("FillStyle") >>= eFillStyle; + xPropSet->getPropertyValue(u"FillStyle"_ustr) >>= eFillStyle; XFillStyleItem aFillStyleItem(eFillStyle); updateFillStyle(false, true, &aFillStyleItem); } - if (xInfo->hasPropertyByName("FillTransparence")) + if (xInfo->hasPropertyByName(u"FillTransparence"_ustr)) { sal_uInt16 nFillTransparence = 0; - xPropSet->getPropertyValue("FillTransparence") >>= nFillTransparence; + xPropSet->getPropertyValue(u"FillTransparence"_ustr) >>= nFillTransparence; SfxUInt16Item aTransparenceItem(0, nFillTransparence); updateFillTransparence(false, true, &aTransparenceItem); } - if (xInfo->hasPropertyByName("FillGradientName")) + if (xInfo->hasPropertyByName(u"FillGradientName"_ustr)) { OUString aGradientName; - xPropSet->getPropertyValue("FillGradientName") >>= aGradientName; + xPropSet->getPropertyValue(u"FillGradientName"_ustr) >>= aGradientName; XFillGradientItem aGradientItem = getXGradientForName(mxModel, aGradientName); updateFillGradient(false, true, &aGradientItem); } - if (xInfo->hasPropertyByName("FillHatchName")) + if (xInfo->hasPropertyByName(u"FillHatchName"_ustr)) { OUString aHatchName; - xPropSet->getPropertyValue("FillHatchName") >>= aHatchName; + xPropSet->getPropertyValue(u"FillHatchName"_ustr) >>= aHatchName; XHatch aHatch = getXHatchFromName(mxModel, aHatchName); XFillHatchItem aHatchItem(aHatchName, aHatch); updateFillHatch(false, true, &aHatchItem); } - if (xInfo->hasPropertyByName("FillBitmapName")) + if (xInfo->hasPropertyByName(u"FillBitmapName"_ustr)) { OUString aBitmapName; - xPropSet->getPropertyValue("FillBitmapName") >>= aBitmapName; + xPropSet->getPropertyValue(u"FillBitmapName"_ustr) >>= aBitmapName; GraphicObject aBitmap = getXBitmapFromName(mxModel, aBitmapName); XFillBitmapItem aBitmapItem(aBitmapName, aBitmap); std::unique_ptr<XFillBitmapItem> pBitmapItem; @@ -468,7 +484,7 @@ void ChartAreaPanel::updateData() DrawModelWrapper* pModelWrapper = getDrawModelWrapper(mxModel); if (pModelWrapper) { - pBitmapItem = aBitmapItem.checkForUniqueItem(&pModelWrapper->getSdrModel()); + pBitmapItem = aBitmapItem.checkForUniqueItem(pModelWrapper->getSdrModel()); } } catch (...) @@ -477,21 +493,21 @@ void ChartAreaPanel::updateData() updateFillBitmap(false, true, pBitmapItem ? pBitmapItem.get() : &aBitmapItem); } - if (xInfo->hasPropertyByName("FillTransparenceGradientName")) + if (xInfo->hasPropertyByName(u"FillTransparenceGradientName"_ustr)) { OUString aFillFloatTransparenceName; - xPropSet->getPropertyValue("FillTransparenceGradientName") >>= aFillFloatTransparenceName; + xPropSet->getPropertyValue(u"FillTransparenceGradientName"_ustr) >>= aFillFloatTransparenceName; XFillFloatTransparenceItem aFillFloatTransparenceItem = getXTransparencyGradientForName(mxModel, aFillFloatTransparenceName); updateFillFloatTransparence(false, true, &aFillFloatTransparenceItem); maFillColorWrapper.updateData(); } - if (xInfo->hasPropertyByName("FillColor")) + if (xInfo->hasPropertyByName(u"FillColor"_ustr)) { sal_uInt32 nFillColor = 0; - xPropSet->getPropertyValue("FillColor") >>= nFillColor; - XFillColorItem aFillColorItem("", Color(ColorTransparency, nFillColor)); + xPropSet->getPropertyValue(u"FillColor"_ustr) >>= nFillColor; + XFillColorItem aFillColorItem(u""_ustr, Color(ColorTransparency, nFillColor)); updateFillColor(true, &aFillColorItem); } } @@ -507,12 +523,11 @@ void ChartAreaPanel::selectionChanged(bool bCorrectType) updateData(); } -void ChartAreaPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartAreaPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + mxModel->removeModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier( mxModel->getCurrentController(), css::uno::UNO_QUERY); @@ -527,8 +542,7 @@ void ChartAreaPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -537,7 +551,9 @@ void ChartAreaPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode void ChartAreaPanel::updateModel( css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.hxx b/chart2/source/controller/sidebar/ChartAreaPanel.hxx index 110132ca4356..24f0d85912b1 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.hxx @@ -57,6 +57,7 @@ public: virtual void setFillStyleAndGradient(const XFillStyleItem* pStyleItem, const XFillGradientItem& rGradientItem) override; virtual void setFillStyleAndHatch(const XFillStyleItem* pStyleItem, const XFillHatchItem& rHatchItem) override; virtual void setFillStyleAndBitmap(const XFillStyleItem* pStyleItem, const XFillBitmapItem& rBitmapItem) override; + virtual void setFillUseBackground(const XFillStyleItem* pStyleItem, const XFillUseSlideBackgroundItem& rItem) override; virtual void updateData() override; virtual void modelInvalid() override; @@ -67,12 +68,13 @@ public: private: - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; rtl::Reference<ChartSidebarSelectionListener> mxSelectionListener; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); + bool selectionIsDataSeries() const; bool mbUpdate; bool mbModelValid; diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.cxx b/chart2/source/controller/sidebar/ChartAxisPanel.cxx index c5e4d91c54e2..7554d164f11f 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.cxx @@ -17,17 +17,16 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart/ChartAxisLabelPosition.hpp> #include <com/sun/star/chart2/AxisOrientation.hpp> -#include <com/sun/star/chart2/XAxis.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <vcl/svapp.hxx> #include <sal/log.hxx> #include "ChartAxisPanel.hxx" #include <ChartController.hxx> +#include <ChartModel.hxx> +#include <Axis.hxx> using namespace css; using namespace css::uno; @@ -36,16 +35,15 @@ namespace chart::sidebar { namespace { -bool isLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool isLabelShown(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return false; - uno::Any aAny = xAxis->getPropertyValue("DisplayLabels"); + uno::Any aAny = xAxis->getPropertyValue(u"DisplayLabels"_ustr); if (!aAny.hasValue()) return false; @@ -54,16 +52,15 @@ bool isLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, return bVisible; } -void setLabelShown(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bVisible) +void setLabelShown(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bVisible) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; - xAxis->setPropertyValue("DisplayLabels", css::uno::Any(bVisible)); + xAxis->setPropertyValue(u"DisplayLabels"_ustr, css::uno::Any(bVisible)); } struct AxisLabelPosMap @@ -79,16 +76,15 @@ AxisLabelPosMap const aLabelPosMap[] = { { 3, css::chart::ChartAxisLabelPosition_OUTSIDE_END } }; -sal_Int32 getLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +sal_Int32 getLabelPosition(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return 0; - uno::Any aAny = xAxis->getPropertyValue("LabelPosition"); + uno::Any aAny = xAxis->getPropertyValue(u"LabelPosition"_ustr); if (!aAny.hasValue()) return 0; @@ -103,11 +99,10 @@ sal_Int32 getLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel return 0; } -void setLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, sal_Int32 nPos) +void setLabelPosition(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, sal_Int32 nPos) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; @@ -119,13 +114,13 @@ void setLabelPosition(const css::uno::Reference<css::frame::XModel>& xModel, ePos = i.ePos; } - xAxis->setPropertyValue("LabelPosition", css::uno::Any(ePos)); + xAxis->setPropertyValue(u"LabelPosition"_ustr, css::uno::Any(ePos)); } -bool isReverse(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool isReverse(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::chart2::XAxis > xAxis = + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) @@ -136,10 +131,10 @@ bool isReverse(const css::uno::Reference<css::frame::XModel>& xModel, return aData.Orientation == css::chart2::AxisOrientation_REVERSE; } -void setReverse(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bReverse) +void setReverse(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bReverse) { - css::uno::Reference< css::chart2::XAxis > xAxis = + rtl::Reference< Axis > xAxis = ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) @@ -174,28 +169,28 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) return aCID; } -void setAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, double nVal) +void setAxisRotation(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, double nVal) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = + ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return; - xAxis->setPropertyValue("TextRotation", css::uno::Any(nVal)); + xAxis->setPropertyValue(u"TextRotation"_ustr, css::uno::Any(nVal)); } -double getAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +double getAxisRotation(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xAxis( - ObjectIdentifier::getAxisForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< ::chart::Axis > xAxis = + ObjectIdentifier::getAxisForCID(rCID, xModel); if (!xAxis.is()) return 0; - css::uno::Any aAny = xAxis->getPropertyValue("TextRotation"); + css::uno::Any aAny = xAxis->getPropertyValue(u"TextRotation"_ustr); double nVal = 0; aAny >>= nVal; return nVal; @@ -206,13 +201,13 @@ double getAxisRotation(const css::uno::Reference<css::frame::XModel>& xModel, ChartAxisPanel::ChartAxisPanel( weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartAxisPanel", "modules/schart/ui/sidebaraxis.ui") - , mxCBShowLabel(m_xBuilder->weld_check_button("checkbutton_show_label")) - , mxCBReverse(m_xBuilder->weld_check_button("checkbutton_reverse")) - , mxLBLabelPos(m_xBuilder->weld_combo_box("comboboxtext_label_position")) - , mxGridLabel(m_xBuilder->weld_widget("label_props")) - , mxNFRotation(m_xBuilder->weld_metric_spin_button("spinbutton1", FieldUnit::DEGREE)) - , mxModel(pController->getModel()) + : PanelLayout(pParent, u"ChartAxisPanel"_ustr, u"modules/schart/ui/sidebaraxis.ui"_ustr) + , mxCBShowLabel(m_xBuilder->weld_check_button(u"checkbutton_show_label"_ustr)) + , mxCBReverse(m_xBuilder->weld_check_button(u"checkbutton_reverse"_ustr)) + , mxLBLabelPos(m_xBuilder->weld_combo_box(u"comboboxtext_label_position"_ustr)) + , mxGridLabel(m_xBuilder->weld_widget(u"label_props"_ustr)) + , mxNFRotation(m_xBuilder->weld_metric_spin_button(u"spinbutton1"_ustr, FieldUnit::DEGREE)) + , mxModel(pController->getChartModel()) , mxModifyListener(new ChartSidebarModifyListener(this)) , mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_AXIS)) , mbModelValid(true) @@ -235,8 +230,7 @@ ChartAxisPanel::~ChartAxisPanel() void ChartAxisPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxModifyListener); + mxModel->addModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -278,7 +272,7 @@ std::unique_ptr<PanelLayout> ChartAxisPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartAxisPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartAxisPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartAxisPanel>(pParent, pController); } @@ -306,12 +300,11 @@ void ChartAxisPanel::modelInvalid() mbModelValid = false; } -void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartAxisPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxModifyListener); + mxModel->removeModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier( mxModel->getCurrentController(), css::uno::UNO_QUERY); @@ -326,8 +319,7 @@ void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxModifyListener); + mxModel->addModifyListener(mxModifyListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -336,7 +328,9 @@ void ChartAxisPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode void ChartAxisPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } void ChartAxisPanel::selectionChanged(bool bCorrectType) diff --git a/chart2/source/controller/sidebar/ChartAxisPanel.hxx b/chart2/source/controller/sidebar/ChartAxisPanel.hxx index 0185f4b9431f..e5ed4b5ebcc6 100644 --- a/chart2/source/controller/sidebar/ChartAxisPanel.hxx +++ b/chart2/source/controller/sidebar/ChartAxisPanel.hxx @@ -74,14 +74,14 @@ private: std::unique_ptr<weld::Widget> mxGridLabel; std::unique_ptr<weld::MetricSpinButton> mxNFRotation; - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxModifyListener; css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener; bool mbModelValid; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); DECL_LINK(CheckBoxHdl, weld::Toggleable&, void); DECL_LINK(ListBoxHdl, weld::ComboBox&, void); diff --git a/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx new file mode 100644 index 000000000000..74a6c13d3f7b --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorPaletteControl.cxx @@ -0,0 +1,353 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <com/sun/star/drawing/FillStyle.hpp> + +#include <memory> +#include <utility> +#include <vcl/svapp.hxx> +#include <vcl/toolbox.hxx> +#include <vcl/virdev.hxx> + +#include <ChartColorPaletteHelper.hxx> +#include "ChartColorPaletteControl.hxx" + +#include <vcl/gdimtf.hxx> +#include <vcl/graph.hxx> + +using namespace css; + +namespace chart::sidebar +{ +constexpr tools::Long BORDER = ChartColorPaletteLayout::ItemBorder; +constexpr tools::Long SIZE = ChartColorPaletteLayout::ItemSize; +constexpr tools::Long constElementNumber = ChartColorPaletteSize; + +ChartColorPaletteControl::ChartColorPaletteControl( + const uno::Reference<uno::XComponentContext>& rContext) + : PopupWindowController(rContext, nullptr, OUString()) + , meColorPaletteType(ChartColorPaletteType::Unknown) + , mnColorPaletteIndex(0) +{ +} + +ChartColorPaletteControl::~ChartColorPaletteControl() = default; + +void ChartColorPaletteControl::initialize(const uno::Sequence<uno::Any>& rArguments) +{ + svt::PopupWindowController::initialize(rArguments); + + if (m_pToolbar) + { + mxPopoverContainer = std::make_unique<ToolbarPopupContainer>(m_pToolbar); + m_pToolbar->set_item_popover(m_aCommandURL, mxPopoverContainer->getTopLevel()); + m_pToolbar->set_item_sensitive(m_aCommandURL, true); + } + + ToolBox* pToolBox = nullptr; + ToolBoxItemId nId; + if (getToolboxId(nId, &pToolBox)) + { + pToolBox->SetItemBits(nId, pToolBox->GetItemBits(nId) | ToolBoxItemBits::DROPDOWNONLY); + pToolBox->EnableItem(nId, true); + } +} + +void ChartColorPaletteControl::execute(sal_Int16 /*nKeyModifier*/) +{ + if (m_pToolbar) + { + // Toggle the popup also when toolbutton is activated + m_pToolbar->set_menu_item_active(m_aCommandURL, + !m_pToolbar->get_menu_item_active(m_aCommandURL)); + } + else + { + // Open the popup also when Enter key is pressed. + createPopupWindow(); + } +} + +void ChartColorPaletteControl::statusChanged(const frame::FeatureStateEvent& rEvent) +{ + ToolBox* pToolBox = nullptr; + ToolBoxItemId nId; + if (!getToolboxId(nId, &pToolBox) && !m_pToolbar) + return; + + if (rEvent.FeatureURL.Complete == m_aCommandURL) + { + updateStatus(); + } +} + +void ChartColorPaletteControl::updateStatus(bool bForce) +{ + if (!mpHandler) + return; + + if (bForce || meColorPaletteType != getColorPaletteType() + || mnColorPaletteIndex != getColorPaletteIndex()) + { + meColorPaletteType = getColorPaletteType(); + mnColorPaletteIndex = getColorPaletteIndex(); + + ToolBox* pToolBox = nullptr; + ToolBoxItemId nId; + if (!getToolboxId(nId, &pToolBox) && !m_pToolbar) + return; + + auto pDev = VclPtr<VirtualDevice>::Create(); + renderSelectedColorPalette(pDev); + auto aSelItemImg(pDev->GetBitmapEx(Point(), pDev->GetOutputSizePixel())); + if (m_pToolbar) + { + m_pToolbar->set_item_image(m_aCommandURL, Graphic(aSelItemImg).GetXGraphic()); + } + else + { + pToolBox->SetItemImage(nId, Image(aSelItemImg)); + } + } +} + +void ChartColorPaletteControl::renderSelectedColorPalette(const VclPtr<VirtualDevice>& pDev) const +{ + if (!pDev) + return; + + const auto pHelper = getColorPaletteHelper(); + if (!pHelper) + return; + + static constexpr Point aPosition(0, 0); + static constexpr Size aSize + = { BORDER * 6 + SIZE * constElementNumber / 2, BORDER * 5 + SIZE * 2 }; + static constexpr tools::Rectangle aDrawArea(aPosition, aSize); + + pDev->SetOutputSizePixel(aSize, /*bErase*/ true, /*bAlphaMaskTransparent*/ true); + + if (getColorPaletteType() == ChartColorPaletteType::Unknown) + { + ChartColorPaletteHelper::renderNoPalette(pDev, aDrawArea); + return; + } + + const ChartColorPalette aColorPalette + = pHelper->getColorPalette(getColorPaletteType(), getColorPaletteIndex()); + ChartColorPaletteHelper::renderColorPalette(pDev, aDrawArea, aColorPalette, true); +} + +void ChartColorPaletteControl::setColorPaletteHandler( + const std::shared_ptr<IColorPaletteHandler>& rColorPaletteHandler) +{ + if (!mpHandler) + { + mpHandler = rColorPaletteHandler; + updateStatus(true); + } +} + +std::shared_ptr<ChartColorPaletteHelper> ChartColorPaletteControl::getColorPaletteHelper() const +{ + if (mpHandler) + return mpHandler->getHelper(); + return nullptr; +} + +ChartColorPaletteType ChartColorPaletteControl::getColorPaletteType() const +{ + if (mpHandler) + return mpHandler->getType(); + return ChartColorPaletteType::Unknown; +} + +sal_uInt32 ChartColorPaletteControl::getColorPaletteIndex() const +{ + if (mpHandler) + return mpHandler->getIndex(); + return 0; +} + +void ChartColorPaletteControl::dispatchColorPaletteCommand(const ChartColorPaletteType eType, + const sal_uInt32 nIndex) const +{ + if (mpHandler) + mpHandler->select(eType, nIndex); +} + +void ChartColorPaletteControl::applyColorPalette(const ChartColorPalette* pColorPalette) const +{ + if (mpHandler) + mpHandler->apply(pColorPalette); +} + +std::unique_ptr<WeldToolbarPopup> ChartColorPaletteControl::weldPopupWindow() +{ + return std::make_unique<ChartColorPalettePopup>(this, m_pToolbar); +} + +VclPtr<vcl::Window> ChartColorPaletteControl::createVclPopupWindow(vcl::Window* pParent) +{ + mxInterimPopover = VclPtr<InterimToolbarPopup>::Create( + getFrameInterface(), pParent, + std::make_unique<ChartColorPalettePopup>(this, pParent->GetFrameWeld())); + + mxInterimPopover->Show(); + + return mxInterimPopover; +} + +OUString ChartColorPaletteControl::getImplementationName() +{ + return "com.sun.star.comp.chart2.ChartColorPaletteControl"; +} + +uno::Sequence<OUString> ChartColorPaletteControl::getSupportedServiceNames() +{ + return { "com.sun.star.frame.ToolbarController" }; +} + +extern "C" SAL_DLLPUBLIC_EXPORT uno::XInterface* +com_sun_star_comp_chart2_ChartColorPaletteControl_get_implementation( + uno::XComponentContext* rContext, uno::Sequence<uno::Any> const&) +{ + return cppu::acquire(new ChartColorPaletteControl(rContext)); +} + +ChartColorPalettePopup::ChartColorPalettePopup(ChartColorPaletteControl* pControl, + weld::Widget* pParent) + : WeldToolbarPopup(pControl->getFrameInterface(), pParent, + "modules/schart/ui/chartcolorpalettepopup.ui", "ColorPaletteWindow") + , mxControl(pControl) + , mxColorfulValueSet(new ChartColorPalettes) + , mxColorfulValueSetWin( + new weld::CustomWeld(*m_xBuilder, "colorful_palettes", *mxColorfulValueSet)) + , mxMonoValueSet(new ChartColorPalettes) + , mxMonoValueSetWin( + new weld::CustomWeld(*m_xBuilder, "monochromatic_palettes", *mxMonoValueSet)) +{ + mxColorfulValueSet->SetColCount(2); + mxColorfulValueSet->SetLineCount(2); + mxColorfulValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + mxMonoValueSet->SetColCount(2); + mxMonoValueSet->SetLineCount(3); + mxMonoValueSet->SetColor(Application::GetSettings().GetStyleSettings().GetFaceColor()); + + initColorPalettes(); + + mxColorfulValueSet->SetOptimalSize(); + mxColorfulValueSet->SetSelectHdl(LINK(this, ChartColorPalettePopup, SelectColorfulValueSetHdl)); + + mxMonoValueSet->SetOptimalSize(); + mxMonoValueSet->SetSelectHdl(LINK(this, ChartColorPalettePopup, SelectMonoValueSetHdl)); + + selectItem(mxControl->getColorPaletteType(), mxControl->getColorPaletteIndex() + 1); +} + +ChartColorPalettePopup::~ChartColorPalettePopup() {} + +void ChartColorPalettePopup::selectItem(const ChartColorPaletteType eType, + const sal_uInt32 nIndex) const +{ + switch (eType) + { + default: + case ChartColorPaletteType::Unknown: + mxColorfulValueSet->SetNoSelection(); + mxMonoValueSet->SetNoSelection(); + break; + case ChartColorPaletteType::Colorful: + mxColorfulValueSet->SelectItem(nIndex); + break; + case ChartColorPaletteType::Monochromatic: + mxMonoValueSet->SelectItem(nIndex); + break; + } +} + +void ChartColorPalettePopup::initColorPalettes() const +{ + const auto pColorPaletteHelper = mxControl->getColorPaletteHelper(); + if (!pColorPaletteHelper) + return; + // colorful palettes + for (size_t i = 0; i < ChartColorPaletteHelper::ColorfulPaletteSize; ++i) + mxColorfulValueSet->insert( + pColorPaletteHelper->getColorPalette(ChartColorPaletteType::Colorful, i)); + // monotonic palettes + for (size_t i = 0; i < ChartColorPaletteHelper::MonotonicPaletteSize; ++i) + mxMonoValueSet->insert( + pColorPaletteHelper->getColorPalette(ChartColorPaletteType::Monochromatic, i)); +} + +void ChartColorPalettePopup::GrabFocus() +{ + if (mxMonoValueSet->IsNoSelection()) + mxColorfulValueSet->GrabFocus(); + else + mxMonoValueSet->GrabFocus(); +} + +IMPL_LINK_NOARG(ChartColorPalettePopup, SelectColorfulValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxColorfulValueSet); + if (nIndex != static_cast<sal_uInt32>(-1)) + { + mxControl->dispatchColorPaletteCommand(ChartColorPaletteType::Colorful, nIndex); + mxMonoValueSet->SetNoSelection(); + mxControl->updateStatus(); + } + mxControl->EndPopupMode(); +} + +IMPL_LINK_NOARG(ChartColorPalettePopup, SelectMonoValueSetHdl, ValueSet*, void) +{ + sal_uInt32 nIndex = SelectValueSetHdl(mxMonoValueSet); + if (nIndex != static_cast<sal_uInt32>(-1)) + { + mxControl->dispatchColorPaletteCommand(ChartColorPaletteType::Monochromatic, nIndex); + mxColorfulValueSet->SetNoSelection(); + mxControl->updateStatus(); + } + mxControl->EndPopupMode(); +} + +sal_uInt32 ChartColorPalettePopup::SelectValueSetHdl( + const std::unique_ptr<ChartColorPalettes>& xValueSet) const +{ + const sal_uInt32 nItemId = xValueSet->GetSelectedItemId(); + + if (!nItemId) + return static_cast<sal_uInt32>(-1); + + const sal_uInt32 nIndex = nItemId - 1; + + if (const ChartColorPalette* pPalette = xValueSet->getPalette(nIndex)) + { + mxControl->applyColorPalette(pPalette); + return nIndex; + } + return static_cast<sal_uInt32>(-1); +} + +} // end namespace chart::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartColorPaletteControl.hxx b/chart2/source/controller/sidebar/ChartColorPaletteControl.hxx new file mode 100644 index 000000000000..3ba66a1e72ec --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorPaletteControl.hxx @@ -0,0 +1,94 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <svtools/popupwindowcontroller.hxx> +#include <svtools/toolbarmenu.hxx> +#include <ChartColorPalettes.hxx> + +namespace chart +{ +class ChartColorPaletteHelper; + +namespace sidebar +{ +struct IColorPaletteHandler +{ + virtual ~IColorPaletteHandler() = default; + virtual void select(ChartColorPaletteType eType, sal_uInt32 nIndex) = 0; + virtual void apply(const ChartColorPalette* pColorPalette) = 0; + [[nodiscard]] virtual std::shared_ptr<ChartColorPaletteHelper> getHelper() const = 0; + [[nodiscard]] virtual ChartColorPaletteType getType() const = 0; + [[nodiscard]] virtual sal_uInt32 getIndex() const = 0; +}; + +class ChartColorPaletteControl final : public svt::PopupWindowController +{ + std::shared_ptr<IColorPaletteHandler> mpHandler; + ChartColorPaletteType meColorPaletteType; + sal_uInt32 mnColorPaletteIndex; + +public: + explicit ChartColorPaletteControl( + const css::uno::Reference<css::uno::XComponentContext>& rContext); + + // XInitialization + void SAL_CALL initialize(const css::uno::Sequence<css::uno::Any>& rArguments) override; + + // XServiceInfo + OUString SAL_CALL getImplementationName() override; + css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override; + + void SAL_CALL execute(sal_Int16 nKeyModifier) override; + void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& rEvent) override; + + ~ChartColorPaletteControl() override; + + void setColorPaletteHandler(const std::shared_ptr<IColorPaletteHandler>& rColorPaletteHandler); + std::shared_ptr<ChartColorPaletteHelper> getColorPaletteHelper() const; + ChartColorPaletteType getColorPaletteType() const; + sal_uInt32 getColorPaletteIndex() const; + void dispatchColorPaletteCommand(ChartColorPaletteType eType, sal_uInt32 nIndex) const; + void applyColorPalette(const ChartColorPalette* pColorPalette) const; + void updateStatus(bool bForce = false); + +private: + std::unique_ptr<WeldToolbarPopup> weldPopupWindow() override; + VclPtr<vcl::Window> createVclPopupWindow(vcl::Window* pParent) override; + + void renderSelectedColorPalette(const VclPtr<VirtualDevice>& pDev) const; +}; + +class ChartColorPalettePopup final : public WeldToolbarPopup +{ + rtl::Reference<ChartColorPaletteControl> mxControl; + std::unique_ptr<ChartColorPalettes> mxColorfulValueSet; + std::unique_ptr<weld::CustomWeld> mxColorfulValueSetWin; + std::unique_ptr<ChartColorPalettes> mxMonoValueSet; + std::unique_ptr<weld::CustomWeld> mxMonoValueSetWin; + + DECL_LINK(SelectColorfulValueSetHdl, ValueSet*, void); + DECL_LINK(SelectMonoValueSetHdl, ValueSet*, void); + sal_uInt32 SelectValueSetHdl(const std::unique_ptr<ChartColorPalettes>& xValueSet) const; + + void GrabFocus() override; + + void selectItem(ChartColorPaletteType eType, sal_uInt32 nIndex) const; + void initColorPalettes() const; + +public: + ChartColorPalettePopup(ChartColorPaletteControl* pControl, weld::Widget* pParent); + ~ChartColorPalettePopup() override; +}; +} // end namespace sidebar +} // end namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.cxx b/chart2/source/controller/sidebar/ChartColorWrapper.cxx index 613407a827e7..f706f763e737 100644 --- a/chart2/source/controller/sidebar/ChartColorWrapper.cxx +++ b/chart2/source/controller/sidebar/ChartColorWrapper.cxx @@ -12,6 +12,7 @@ #include <string_view> #include "ChartColorWrapper.hxx" +#include <ChartModel.hxx> #include <ObjectIdentifier.hxx> #include <PropertyHelper.hxx> @@ -27,7 +28,9 @@ #include <svx/unomid.hxx> #include <comphelper/lok.hxx> +#include <sal/log.hxx> #include <sfx2/viewsh.hxx> +#include <utility> #include <LibreOfficeKit/LibreOfficeKitEnums.h> namespace chart::sidebar { @@ -36,6 +39,9 @@ namespace { OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) { + if (!xModel.is()) + return OUString(); + css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController()); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); if (!xSelectionSupplier.is()) @@ -52,7 +58,7 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) } css::uno::Reference<css::beans::XPropertySet> getPropSet( - const css::uno::Reference<css::frame::XModel>& xModel) + const rtl::Reference<::chart::ChartModel>& xModel) { OUString aCID = getCID(xModel); css::uno::Reference<css::beans::XPropertySet> xPropSet = @@ -75,12 +81,12 @@ css::uno::Reference<css::beans::XPropertySet> getPropSet( } ChartColorWrapper::ChartColorWrapper( - css::uno::Reference<css::frame::XModel> const & xModel, + rtl::Reference<::chart::ChartModel> xModel, SvxColorToolBoxControl* pControl, - const OUString& rName): - mxModel(xModel), + OUString aName): + mxModel(std::move(xModel)), mpControl(pControl), - maPropertyName(rName) + maPropertyName(std::move(aName)) { } @@ -94,17 +100,22 @@ void ChartColorWrapper::operator()([[maybe_unused]] const OUString& , const Name return; } - xPropSet->setPropertyValue(maPropertyName, css::uno::makeAny(rColor.first)); + xPropSet->setPropertyValue(maPropertyName, css::uno::Any(rColor.m_aColor)); + + OUString aCID = getCID(mxModel); + ObjectType eType = ObjectIdentifier::getObjectType(aCID); + if (eType == OBJECTTYPE_DATA_SERIES || eType == OBJECTTYPE_DATA_POINT) + mxModel->clearColorPalette(); } -void ChartColorWrapper::updateModel(const css::uno::Reference<css::frame::XModel>& xModel) +void ChartColorWrapper::updateModel(const rtl::Reference<::chart::ChartModel>& xModel) { mxModel = xModel; } void ChartColorWrapper::updateData() { - static constexpr OUStringLiteral aLineColor = u"LineColor"; + static constexpr OUString aLineColor = u"LineColor"_ustr; static const std::u16string_view aCommands[2] = {u".uno:XLineColor", u".uno:FillColor"}; css::uno::Reference<css::beans::XPropertySet> xPropSet = getPropSet(mxModel); @@ -123,23 +134,23 @@ void ChartColorWrapper::updateData() SfxViewShell* pViewShell = SfxViewShell::Current(); if (comphelper::LibreOfficeKit::isActive() && pViewShell && (maPropertyName == aLineColor)) { - std::string sCommand = OUStringToOString(aUrl.Complete, RTL_TEXTENCODING_ASCII_US).getStr(); + OString sCommand = OUStringToOString(aUrl.Complete, RTL_TEXTENCODING_ASCII_US); sal_Int32 nColor = -1; aEvent.State >>= nColor; pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, - (sCommand + "=" + std::to_string(nColor)).c_str()); + sCommand + "=" + OString::number(nColor)); } } ChartLineStyleWrapper::ChartLineStyleWrapper( - css::uno::Reference<css::frame::XModel> const & xModel, + rtl::Reference<::chart::ChartModel> xModel, SvxLineStyleToolBoxControl* pControl) - : mxModel(xModel) + : mxModel(std::move(xModel)) , mpControl(pControl) { } -void ChartLineStyleWrapper::updateModel(const css::uno::Reference<css::frame::XModel>& xModel) +void ChartLineStyleWrapper::updateModel(const rtl::Reference<::chart::ChartModel>& xModel) { mxModel = xModel; } @@ -151,7 +162,7 @@ namespace { css::uno::Reference<css::lang::XMultiServiceFactory> xFact(xModel, css::uno::UNO_QUERY); css::uno::Reference<css::container::XNameAccess> xNameAccess( - xFact->createInstance("com.sun.star.drawing.DashTable"), + xFact->createInstance(u"com.sun.star.drawing.DashTable"_ustr), css::uno::UNO_QUERY ); if(xNameAccess.is()) { @@ -178,19 +189,19 @@ void ChartLineStyleWrapper::updateData() aEvent.IsEnabled = true; aEvent.FeatureURL = aUrl; - aEvent.State = xPropSet->getPropertyValue("LineStyle"); + aEvent.State = xPropSet->getPropertyValue(u"LineStyle"_ustr); mpControl->statusChanged(aEvent); aUrl.Complete = ".uno:LineDash"; - auto aLineDashName = xPropSet->getPropertyValue("LineDashName"); + auto aLineDashName = xPropSet->getPropertyValue(u"LineDashName"_ustr); OUString aDashName; aLineDashName >>= aDashName; css::uno::Any aLineDash = getLineDash(mxModel, aDashName); XLineDashItem aDashItem; aDashItem.PutValue(aLineDash, MID_LINEDASH); - aEvent.FeatureURL = aUrl; + aEvent.FeatureURL = std::move(aUrl); aDashItem.QueryValue(aEvent.State); mpControl->statusChanged(aEvent); } @@ -207,7 +218,7 @@ bool ChartLineStyleWrapper::operator()(std::u16string_view rCommand, const css:: if (rCommand == u".uno:XLineStyle") { - xPropSet->setPropertyValue("LineStyle", rValue); + xPropSet->setPropertyValue(u"LineStyle"_ustr, rValue); return true; } else if (rCommand == u".uno:LineDash") @@ -217,10 +228,10 @@ bool ChartLineStyleWrapper::operator()(std::u16string_view rCommand, const css:: css::uno::Any aAny; aDashItem.QueryValue(aAny, MID_LINEDASH); OUString aDashName = PropertyHelper::addLineDashUniqueNameToTable(aAny, - css::uno::Reference<css::lang::XMultiServiceFactory>(mxModel, css::uno::UNO_QUERY), - ""); - xPropSet->setPropertyValue("LineDash", aAny); - xPropSet->setPropertyValue("LineDashName", css::uno::Any(aDashName)); + mxModel, + u""_ustr); + xPropSet->setPropertyValue(u"LineDash"_ustr, aAny); + xPropSet->setPropertyValue(u"LineDashName"_ustr, css::uno::Any(aDashName)); return true; } return false; diff --git a/chart2/source/controller/sidebar/ChartColorWrapper.hxx b/chart2/source/controller/sidebar/ChartColorWrapper.hxx index 66c880ae3ca2..6405e694b475 100644 --- a/chart2/source/controller/sidebar/ChartColorWrapper.hxx +++ b/chart2/source/controller/sidebar/ChartColorWrapper.hxx @@ -9,10 +9,10 @@ #pragma once -#include <com/sun/star/uno/Reference.hxx> -#include <svx/Palette.hxx> +#include <ChartModel.hxx> -namespace com::sun::star::frame { class XModel; } +#include <sfx2/namedcolor.hxx> +#include <rtl/ref.hxx> class SvxColorToolBoxControl; class SvxLineStyleToolBoxControl; @@ -22,20 +22,20 @@ namespace chart::sidebar { class ChartColorWrapper { public: - ChartColorWrapper(css::uno::Reference<css::frame::XModel> const & xModel, + ChartColorWrapper(rtl::Reference<::chart::ChartModel> xModel, SvxColorToolBoxControl* pControl, - const OUString& rPropertyName); + OUString rPropertyName); void operator()(const OUString& rCommand, const NamedColor& rColor); // ColorSelectFunction signature - void updateModel(const css::uno::Reference<css::frame::XModel>& xModel); + void updateModel(const rtl::Reference<::chart::ChartModel>& xModel); void updateData(); private: - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; SvxColorToolBoxControl* mpControl; @@ -45,18 +45,18 @@ private: class ChartLineStyleWrapper { public: - ChartLineStyleWrapper(css::uno::Reference<css::frame::XModel> const & xModel, + ChartLineStyleWrapper(rtl::Reference<::chart::ChartModel> xModel, SvxLineStyleToolBoxControl* pControl); bool operator()(std::u16string_view rCommand, const css::uno::Any& rValue); - void updateModel(const css::uno::Reference<css::frame::XModel>& xModel); + void updateModel(const rtl::Reference<::chart::ChartModel>& xModel); void updateData(); private: - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; SvxLineStyleToolBoxControl* mpControl; }; diff --git a/chart2/source/controller/sidebar/ChartColorsPanel.cxx b/chart2/source/controller/sidebar/ChartColorsPanel.cxx new file mode 100644 index 000000000000..259365a28adb --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorsPanel.cxx @@ -0,0 +1,310 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include <sal/log.hxx> +#include <vcl/svapp.hxx> + +#include "ChartColorsPanel.hxx" +#include "ChartColorPaletteControl.hxx" + +#include <ChartColorPaletteHelper.hxx> +#include <ChartController.hxx> +#include <ChartModel.hxx> +#include <DataSeries.hxx> + +#include <com/sun/star/drawing/FillStyle.hpp> + +#include <sfx2/weldutils.hxx> +#include <svtools/toolbarmenu.hxx> + +#include <algorithm> + +using namespace css; + +namespace chart::sidebar +{ +namespace +{ +OUString getCID(const uno::Reference<frame::XModel>& xModel) +{ + const uno::Reference<frame::XController> xController(xModel->getCurrentController()); + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(xController, uno::UNO_QUERY); + if (!xSelectionSupplier.is()) + return {}; + + uno::Any aAny = xSelectionSupplier->getSelection(); + if (!aAny.hasValue()) + { + // if no selection, default to diagram wall so sidebar can show some editable properties + if (auto* pController = dynamic_cast<ChartController*>(xController.get())) + { + pController->select( + uno::Any(ObjectIdentifier::createClassifiedIdentifier(OBJECTTYPE_PAGE, u""))); + xSelectionSupplier + = uno::Reference<css::view::XSelectionSupplier>(xController, uno::UNO_QUERY); + if (xSelectionSupplier.is()) + aAny = xSelectionSupplier->getSelection(); + } + + if (!aAny.hasValue()) + return {}; + } + + OUString aCID; + aAny >>= aCID; + return aCID; +} + +ChartColorPaletteControl* getChartColorPaletteControl(const ToolbarUnoDispatcher& rToolBoxColor) +{ + const uno::Reference<frame::XToolbarController> xController + = rToolBoxColor.GetControllerForCommand(sUnoChartColorPalette); + const auto pToolBoxLineStyleControl + = dynamic_cast<ChartColorPaletteControl*>(xController.get()); + return pToolBoxLineStyleControl; +} +} // end unnamed namespace + +class ColorPaletteWrapper final : public IColorPaletteHandler +{ +public: + ColorPaletteWrapper(rtl::Reference<ChartModel> mxModel, ChartColorPaletteControl* pControl); + + void updateModel(const rtl::Reference<ChartModel>& xModel); + void updateData() const; + + void select(ChartColorPaletteType eType, sal_uInt32 nIndex) override; + void apply(const ChartColorPalette* pColorPalette) override; + [[nodiscard]] std::shared_ptr<ChartColorPaletteHelper> getHelper() const override; + [[nodiscard]] ChartColorPaletteType getType() const override; + [[nodiscard]] sal_uInt32 getIndex() const override; + +private: + rtl::Reference<ChartModel> mxModel; + ChartColorPaletteControl* mpControl; +}; + +ColorPaletteWrapper::ColorPaletteWrapper(rtl::Reference<ChartModel> xModel, + ChartColorPaletteControl* pControl) + : mxModel(std::move(xModel)) + , mpControl(pControl) +{ +} + +void ColorPaletteWrapper::updateModel(const rtl::Reference<ChartModel>& xModel) +{ + mxModel = xModel; +} + +void ColorPaletteWrapper::updateData() const +{ + frame::FeatureStateEvent aEvent; + aEvent.FeatureURL.Complete = sUnoChartColorPalette; + aEvent.IsEnabled = true; + + if (mpControl) + mpControl->statusChanged(aEvent); +} + +void ColorPaletteWrapper::select(ChartColorPaletteType eType, const sal_uInt32 nIndex) +{ + mxModel->setColorPalette(eType, nIndex); +} + +void ColorPaletteWrapper::apply(const ChartColorPalette* pColorPalette) +{ + if (pColorPalette) + mxModel->applyColorPaletteToDataSeries(*pColorPalette); +} + +std::shared_ptr<ChartColorPaletteHelper> ColorPaletteWrapper::getHelper() const +{ + const std::shared_ptr<model::Theme> pTheme = mxModel->getDocumentTheme(); + return std::make_shared<ChartColorPaletteHelper>(pTheme); +} + +ChartColorPaletteType ColorPaletteWrapper::getType() const +{ + return mxModel->getColorPaletteType(); +} + +sal_uInt32 ColorPaletteWrapper::getIndex() const { return mxModel->getColorPaletteIndex(); } + +const std::vector<ObjectType> ChartColorsPanel::maAcceptedTypes{ + OBJECTTYPE_PAGE, OBJECTTYPE_LEGEND, OBJECTTYPE_DIAGRAM, + OBJECTTYPE_DIAGRAM_WALL, OBJECTTYPE_DIAGRAM_FLOOR, OBJECTTYPE_DATA_SERIES, + OBJECTTYPE_DATA_POINT, +}; + +ChartColorsPanel::ChartColorsPanel(weld::Widget* pParent, + const uno::Reference<frame::XFrame>& rxFrame, + ChartController* pController) + : PanelLayout(pParent, "ChartColorsPanel", "modules/schart/ui/sidebarcolors.ui") + , mxModel(pController->getChartModel()) + , mxModifyListener(new ChartSidebarModifyListener(this)) + , mxSelectionListener(new ChartSidebarSelectionListener(this)) + , mbModelValid(true) + , mxColorPaletteTB(m_xBuilder->weld_toolbar("colorpalettetype")) + , mxColorPaletteDispatch(new ToolbarUnoDispatcher(*mxColorPaletteTB, *m_xBuilder, rxFrame)) +{ + auto aAcceptedTypes(maAcceptedTypes); + mxSelectionListener->setAcceptedTypes(std::move(aAcceptedTypes)); + Initialize(); +} + +ChartColorsPanel::~ChartColorsPanel() +{ + doUpdateModel(nullptr); + mxColorPaletteDispatch.reset(); + mxColorPaletteTB.reset(); +} + +void ChartColorsPanel::Initialize() +{ + mxModel->addModifyListener(mxModifyListener); + + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), + uno::UNO_QUERY); + if (xSelectionSupplier.is()) + xSelectionSupplier->addSelectionChangeListener(mxSelectionListener); + + ChartColorPaletteControl* pColorPaletteControl + = getChartColorPaletteControl(*mxColorPaletteDispatch); + assert(pColorPaletteControl); + mxColorPaletteWrapper = std::make_shared<ColorPaletteWrapper>(mxModel, pColorPaletteControl); + pColorPaletteControl->setColorPaletteHandler(mxColorPaletteWrapper); + + updateData(); +} + +void ChartColorsPanel::updateData() +{ + if (!mbModelValid) + return; + + const OUString aCID = getCID(mxModel); + if (aCID.isEmpty()) + return; + const ObjectType eType = ObjectIdentifier::getObjectType(aCID); + + if (std::find(maAcceptedTypes.begin(), maAcceptedTypes.end(), eType) == maAcceptedTypes.end()) + return; + + // if fill style is not solid clear palette selection + if (eType == OBJECTTYPE_DATA_SERIES || eType == OBJECTTYPE_DATA_POINT) + { + const uno::Reference<beans::XPropertySet> xPropSet + = ObjectIdentifier::getObjectPropertySet(aCID, mxModel); + if (!xPropSet.is()) + return; + + uno::Reference<beans::XPropertySetInfo> xInfo(xPropSet->getPropertySetInfo()); + if (!xInfo.is()) + return; + + SolarMutexGuard aGuard; + if (xInfo->hasPropertyByName("FillStyle")) + { + drawing::FillStyle eFillStyle = drawing::FillStyle_SOLID; + xPropSet->getPropertyValue("FillStyle") >>= eFillStyle; + if (eFillStyle != drawing::FillStyle_SOLID) + { + mxModel->clearColorPalette(); + } + } + } + + mxColorPaletteWrapper->updateData(); +} + +std::unique_ptr<PanelLayout> ChartColorsPanel::Create(weld::Widget* pParent, + const uno::Reference<frame::XFrame>& rxFrame, + ChartController* pController) +{ + if (pParent == nullptr) + throw lang::IllegalArgumentException("no parent Window given to ChartColorsPanel::Create", + nullptr, 0); + if (!rxFrame.is()) + throw lang::IllegalArgumentException("no XFrame given to ChartColorsPanel::Create", nullptr, + 1); + + return std::make_unique<ChartColorsPanel>(pParent, rxFrame, pController); +} + +void ChartColorsPanel::DataChanged(const DataChangedEvent& rEvent) +{ + PanelLayout::DataChanged(rEvent); + updateData(); +} + +void ChartColorsPanel::HandleContextChange(const vcl::EnumContext&) { updateData(); } + +void ChartColorsPanel::NotifyItemUpdate(sal_uInt16 /*nSID*/, SfxItemState /*eState*/, + const SfxPoolItem* /*pState*/) +{ +} + +void ChartColorsPanel::modelInvalid() { mbModelValid = false; } + +void ChartColorsPanel::doUpdateModel(const rtl::Reference<ChartModel>& xModel) +{ + if (mbModelValid) + { + mxModel->removeModifyListener(mxModifyListener); + + const uno::Reference<view::XSelectionSupplier> oldSelectionSupplier( + mxModel->getCurrentController(), uno::UNO_QUERY); + if (oldSelectionSupplier.is()) + { + oldSelectionSupplier->removeSelectionChangeListener(mxSelectionListener); + } + } + + mxModel = xModel; + mbModelValid = mxModel.is(); + + if (!mbModelValid) + return; + + mxColorPaletteWrapper->updateModel(mxModel); + + mxModel->addModifyListener(mxModifyListener); + + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), + uno::UNO_QUERY); + if (xSelectionSupplier.is()) + xSelectionSupplier->addSelectionChangeListener(mxSelectionListener); +} + +void ChartColorsPanel::updateModel(const uno::Reference<frame::XModel> xModel) +{ + const auto pModel = dynamic_cast<ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); +} + +void ChartColorsPanel::selectionChanged(const bool bCorrectType) +{ + if (bCorrectType) + updateData(); +} + +} // end of namespace ::chart::sidebar + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartColorsPanel.hxx b/chart2/source/controller/sidebar/ChartColorsPanel.hxx new file mode 100644 index 000000000000..3180f7660f58 --- /dev/null +++ b/chart2/source/controller/sidebar/ChartColorsPanel.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + */ + +#pragma once + +#include <com/sun/star/frame/XFrame.hpp> + +#include <sfx2/sidebar/ControllerItem.hxx> +#include <sfx2/sidebar/IContextChangeReceiver.hxx> +#include <sfx2/sidebar/SidebarModelUpdate.hxx> +#include <sfx2/sidebar/PanelLayout.hxx> +#include "ChartSidebarModifyListener.hxx" +#include "ChartSidebarSelectionListener.hxx" +#include <ChartColorPalettes.hxx> + +class ToolbarUnoDispatcher; + +namespace chart +{ +class ChartController; + +namespace sidebar +{ +class ColorPaletteWrapper; + +class ChartColorsPanel final : public PanelLayout, + public sfx2::sidebar::IContextChangeReceiver, + public sfx2::sidebar::ControllerItem::ItemUpdateReceiverInterface, + public sfx2::sidebar::SidebarModelUpdate, + public ChartSidebarModifyListenerParent, + public ChartSidebarSelectionListenerParent +{ +public: + static const std::vector<ObjectType> maAcceptedTypes; + + static std::unique_ptr<PanelLayout> + Create(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, + ChartController* pController); + + void DataChanged(const DataChangedEvent& rEvent) override; + + void HandleContextChange(const vcl::EnumContext& rContext) override; + + void NotifyItemUpdate(sal_uInt16 nSId, SfxItemState eState, const SfxPoolItem* pState) override; + + void GetControlState(const sal_uInt16 /*nSId*/, + boost::property_tree::ptree& /*rState*/) override + { + } + + // constructor/destructor + ChartColorsPanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, + ChartController* pController); + ~ChartColorsPanel() override; + + void updateData() override; + void modelInvalid() override; + + void selectionChanged(bool bCorrectType) override; + + void updateModel(css::uno::Reference<css::frame::XModel> xModel) override; + +private: + rtl::Reference<ChartModel> mxModel; + css::uno::Reference<css::util::XModifyListener> mxModifyListener; + rtl::Reference<ChartSidebarSelectionListener> mxSelectionListener; + + bool mbModelValid; + + std::unique_ptr<weld::Toolbar> mxColorPaletteTB; + std::unique_ptr<ToolbarUnoDispatcher> mxColorPaletteDispatch; + std::shared_ptr<ColorPaletteWrapper> mxColorPaletteWrapper; + + void Initialize(); + void doUpdateModel(const rtl::Reference<ChartModel>& xModel); +}; +} // end of namespace sidebar +} // end of namespace chart + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.cxx b/chart2/source/controller/sidebar/ChartElementsPanel.cxx index 7bf6663243f7..89dd339f9a48 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.cxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.cxx @@ -19,8 +19,6 @@ #include <com/sun/star/chart2/LegendPosition.hpp> #include <com/sun/star/chart/ChartLegendExpansion.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> #include <vcl/svapp.hxx> @@ -28,13 +26,14 @@ #include <ChartController.hxx> #include <comphelper/processfactory.hxx> +#include <Legend.hxx> #include <LegendHelper.hxx> -#include <ChartModelHelper.hxx> #include <AxisHelper.hxx> -#include <DiagramHelper.hxx> +#include <Diagram.hxx> +#include <ChartType.hxx> #include <ChartTypeHelper.hxx> - #include <ChartModel.hxx> +#include <BaseCoordinateSystem.hxx> using namespace css; @@ -74,13 +73,13 @@ bool isLegendVisible(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return false; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if( xLegendProp.is()) { try { bool bShow = false; - if( xLegendProp->getPropertyValue( "Show") >>= bShow ) + if( xLegendProp->getPropertyValue( u"Show"_ustr) >>= bShow ) { return bShow; } @@ -111,13 +110,13 @@ bool isLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return false; - Reference< beans::XPropertySet > xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if( xLegendProp.is()) { try { bool bOverlay = false; - if(xLegendProp->getPropertyValue("Overlay") >>= bOverlay) + if(xLegendProp->getPropertyValue(u"Overlay"_ustr) >>= bOverlay) { return bOverlay; } @@ -136,28 +135,27 @@ void setLegendOverlay(const css::uno::Reference<css::frame::XModel>& xModel, boo if (!pModel) return; - Reference<beans::XPropertySet> xLegendProp(LegendHelper::getLegend(*pModel), uno::UNO_QUERY); + rtl::Reference<Legend> xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return; - xLegendProp->setPropertyValue("Overlay", css::uno::Any(bOverlay)); + xLegendProp->setPropertyValue(u"Overlay"_ustr, css::uno::Any(bOverlay)); } -bool isTitleVisible(const css::uno::Reference<css::frame::XModel>& xModel, TitleHelper::eTitleType eTitle) +bool isTitleVisible(const rtl::Reference<::chart::ChartModel>& xModel, TitleHelper::eTitleType eTitle) { - css::uno::Reference<css::uno::XInterface> xTitle = TitleHelper::getTitle(eTitle, xModel); + rtl::Reference<Title> xTitle = TitleHelper::getTitle(eTitle, xModel); if (!xTitle.is()) return false; - css::uno::Reference<css::beans::XPropertySet> xPropSet(xTitle, css::uno::UNO_QUERY_THROW); - css::uno::Any aAny = xPropSet->getPropertyValue("Visible"); + css::uno::Any aAny = xTitle->getPropertyValue(u"Visible"_ustr); bool bVisible = aAny.get<bool>(); return bVisible; } -bool isGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType) +bool isGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType eType) { - Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(xDiagram.is()) { sal_Int32 nDimensionIndex = 0; @@ -172,9 +170,9 @@ bool isGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridTy return false; } -void setGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridType eType, bool bVisible) +void setGridVisible(const rtl::Reference<::chart::ChartModel>& xModel, GridType eType, bool bVisible) { - Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(!xDiagram.is()) return; @@ -192,9 +190,9 @@ void setGridVisible(const css::uno::Reference<css::frame::XModel>& xModel, GridT AxisHelper::hideGrid(nDimensionIndex, nCooSysIndex, bMajor, xDiagram); } -bool isAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType) +bool isAxisVisible(const rtl::Reference<::chart::ChartModel>& xModel, AxisType eType) { - Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(xDiagram.is()) { sal_Int32 nDimensionIndex = 0; @@ -211,9 +209,9 @@ bool isAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisTy return false; } -void setAxisVisible(const css::uno::Reference<css::frame::XModel>& xModel, AxisType eType, bool bVisible) +void setAxisVisible(const rtl::Reference<::chart::ChartModel>& xModel, AxisType eType, bool bVisible) { - Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(xModel)); + rtl::Reference< Diagram > xDiagram(xModel->getFirstChartDiagram()); if(!xDiagram.is()) return; @@ -237,12 +235,12 @@ sal_Int32 getLegendPos(const css::uno::Reference<css::frame::XModel>& xModel) if (!pModel) return -1; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return -1; chart2::LegendPosition eLegendPos = chart2::LegendPosition_LINE_END; - xLegendProp->getPropertyValue("AnchorPosition") >>= eLegendPos; + xLegendProp->getPropertyValue(u"AnchorPosition"_ustr) >>= eLegendPos; switch(eLegendPos) { case chart2::LegendPosition_LINE_START: @@ -264,7 +262,7 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int if (!pModel) return; - Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend(*pModel), uno::UNO_QUERY ); + rtl::Reference< Legend > xLegendProp = LegendHelper::getLegend(*pModel); if (!xLegendProp.is()) return; @@ -290,44 +288,43 @@ void setLegendPos(const css::uno::Reference<css::frame::XModel>& xModel, sal_Int assert(false); } - xLegendProp->setPropertyValue("AnchorPosition", css::uno::Any(eLegendPos)); - xLegendProp->setPropertyValue("Expansion", css::uno::Any(eExpansion)); - xLegendProp->setPropertyValue("RelativePosition", uno::Any()); + xLegendProp->setPropertyValue(u"AnchorPosition"_ustr, css::uno::Any(eLegendPos)); + xLegendProp->setPropertyValue(u"Expansion"_ustr, css::uno::Any(eExpansion)); + xLegendProp->setPropertyValue(u"RelativePosition"_ustr, uno::Any()); } } ChartElementsPanel::ChartElementsPanel( weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartElementsPanel", "modules/schart/ui/sidebarelements.ui") - , mxCBTitle(m_xBuilder->weld_check_button("checkbutton_title")) - , mxEditTitle(m_xBuilder->weld_entry("edit_title")) - , mxCBSubtitle(m_xBuilder->weld_check_button("checkbutton_subtitle")) - , mxEditSubtitle(m_xBuilder->weld_entry("edit_subtitle")) - , mxCBXAxis(m_xBuilder->weld_check_button("checkbutton_x_axis")) - , mxCBXAxisTitle(m_xBuilder->weld_check_button("checkbutton_x_axis_title")) - , mxCBYAxis(m_xBuilder->weld_check_button("checkbutton_y_axis")) - , mxCBYAxisTitle(m_xBuilder->weld_check_button("checkbutton_y_axis_title")) - , mxCBZAxis(m_xBuilder->weld_check_button("checkbutton_z_axis")) - , mxCBZAxisTitle(m_xBuilder->weld_check_button("checkbutton_z_axis_title")) - , mxCB2ndXAxis(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis")) - , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_x_axis_title")) - , mxCB2ndYAxis(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis")) - , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button("checkbutton_2nd_y_axis_title")) - , mxCBLegend(m_xBuilder->weld_check_button("checkbutton_legend")) - , mxCBLegendNoOverlay(m_xBuilder->weld_check_button("checkbutton_no_overlay")) - , mxCBGridVerticalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_major")) - , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_major")) - , mxCBGridVerticalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_vertical_minor")) - , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button("checkbutton_gridline_horizontal_minor")) - , mxTextTitle(m_xBuilder->weld_label("text_title")) - , mxTextSubTitle(m_xBuilder->weld_label("text_subtitle")) - , mxLBAxis(m_xBuilder->weld_label("label_axes")) - , mxLBGrid(m_xBuilder->weld_label("label_gri")) - , mxLBLegendPosition(m_xBuilder->weld_combo_box("comboboxtext_legend")) - , mxBoxLegend(m_xBuilder->weld_widget("box_legend")) - , maContext() - , mxModel(pController->getModel()) + : PanelLayout(pParent, u"ChartElementsPanel"_ustr, u"modules/schart/ui/sidebarelements.ui"_ustr) + , mxCBTitle(m_xBuilder->weld_check_button(u"checkbutton_title"_ustr)) + , mxEditTitle(m_xBuilder->weld_entry(u"edit_title"_ustr)) + , mxCBSubtitle(m_xBuilder->weld_check_button(u"checkbutton_subtitle"_ustr)) + , mxEditSubtitle(m_xBuilder->weld_entry(u"edit_subtitle"_ustr)) + , mxCBXAxis(m_xBuilder->weld_check_button(u"checkbutton_x_axis"_ustr)) + , mxCBXAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_x_axis_title"_ustr)) + , mxCBYAxis(m_xBuilder->weld_check_button(u"checkbutton_y_axis"_ustr)) + , mxCBYAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_y_axis_title"_ustr)) + , mxCBZAxis(m_xBuilder->weld_check_button(u"checkbutton_z_axis"_ustr)) + , mxCBZAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_z_axis_title"_ustr)) + , mxCB2ndXAxis(m_xBuilder->weld_check_button(u"checkbutton_2nd_x_axis"_ustr)) + , mxCB2ndXAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_2nd_x_axis_title"_ustr)) + , mxCB2ndYAxis(m_xBuilder->weld_check_button(u"checkbutton_2nd_y_axis"_ustr)) + , mxCB2ndYAxisTitle(m_xBuilder->weld_check_button(u"checkbutton_2nd_y_axis_title"_ustr)) + , mxCBLegend(m_xBuilder->weld_check_button(u"checkbutton_legend"_ustr)) + , mxCBLegendNoOverlay(m_xBuilder->weld_check_button(u"checkbutton_no_overlay"_ustr)) + , mxCBGridVerticalMajor(m_xBuilder->weld_check_button(u"checkbutton_gridline_vertical_major"_ustr)) + , mxCBGridHorizontalMajor(m_xBuilder->weld_check_button(u"checkbutton_gridline_horizontal_major"_ustr)) + , mxCBGridVerticalMinor(m_xBuilder->weld_check_button(u"checkbutton_gridline_vertical_minor"_ustr)) + , mxCBGridHorizontalMinor(m_xBuilder->weld_check_button(u"checkbutton_gridline_horizontal_minor"_ustr)) + , mxTextTitle(m_xBuilder->weld_label(u"text_title"_ustr)) + , mxTextSubTitle(m_xBuilder->weld_label(u"text_subtitle"_ustr)) + , mxLBAxis(m_xBuilder->weld_label(u"label_axes"_ustr)) + , mxLBGrid(m_xBuilder->weld_label(u"label_gri"_ustr)) + , mxLBLegendPosition(m_xBuilder->weld_combo_box(u"comboboxtext_legend"_ustr)) + , mxBoxLegend(m_xBuilder->weld_widget(u"box_legend"_ustr)) + , mxModel(pController->getChartModel()) , mxListener(new ChartSidebarModifyListener(this)) , mbModelValid(true) { @@ -374,8 +371,7 @@ ChartElementsPanel::~ChartElementsPanel() void ChartElementsPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); updateData(); Link<weld::Toggleable&,void> aLink = LINK(this, ChartElementsPanel, CheckBoxHdl); @@ -407,27 +403,21 @@ void ChartElementsPanel::Initialize() namespace { -css::uno::Reference<css::chart2::XChartType> getChartType(const css::uno::Reference<css::frame::XModel>& xModel) +rtl::Reference<ChartType> getChartType(const rtl::Reference<ChartModel>& xModel) { - css::uno::Reference<css::chart2::XChartDocument> xChartDoc(xModel, css::uno::UNO_QUERY_THROW); - css::uno::Reference<chart2::XDiagram > xDiagram = xChartDoc->getFirstDiagram(); - if (!xDiagram.is()) { - return css::uno::Reference<css::chart2::XChartType>(); - } - - css::uno::Reference<css::chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, css::uno::UNO_QUERY_THROW ); + rtl::Reference<Diagram > xDiagram = xModel->getFirstChartDiagram(); + if (!xDiagram.is()) + return nullptr; - css::uno::Sequence<css::uno::Reference<css::chart2::XCoordinateSystem>> xCooSysSequence(xCooSysContainer->getCoordinateSystems()); + const std::vector<rtl::Reference<BaseCoordinateSystem>> xCooSysSequence(xDiagram->getBaseCoordinateSystems()); - if (!xCooSysSequence.hasElements()) - return css::uno::Reference<css::chart2::XChartType>(); + if (xCooSysSequence.empty()) + return nullptr; - css::uno::Reference<css::chart2::XChartTypeContainer> xChartTypeContainer(xCooSysSequence[0], css::uno::UNO_QUERY_THROW); + const std::vector<rtl::Reference<ChartType>> & xChartTypeSequence(xCooSysSequence[0]->getChartTypes2()); - css::uno::Sequence<css::uno::Reference<css::chart2::XChartType>> xChartTypeSequence(xChartTypeContainer->getChartTypes()); - - if (!xChartTypeSequence.hasElements()) - return css::uno::Reference<css::chart2::XChartType>(); + if (xChartTypeSequence.empty()) + return nullptr; return xChartTypeSequence[0]; } @@ -439,8 +429,10 @@ void ChartElementsPanel::updateData() if (!mbModelValid) return; - Reference< chart2::XDiagram > xDiagram(ChartModelHelper::findDiagram(mxModel)); - sal_Int32 nDimension = DiagramHelper::getDimension(xDiagram); + rtl::Reference< Diagram > xDiagram(mxModel->getFirstChartDiagram()); + sal_Int32 nDimension = 0; + if (xDiagram) + nDimension = xDiagram->getDimension(); SolarMutexGuard aGuard; mxCBLegend->set_active(isLegendVisible(mxModel)); @@ -483,8 +475,8 @@ void ChartElementsPanel::updateData() mxCB2ndXAxis->set_active(isAxisVisible(mxModel, AxisType::X_SECOND)); mxCB2ndYAxis->set_active(isAxisVisible(mxModel, AxisType::Y_SECOND)); - bool bSupportsMainAxis = ChartTypeHelper::isSupportingMainAxis( - getChartType(mxModel), 0, 0); + auto xChartType = getChartType(mxModel); + bool bSupportsMainAxis = xChartType.is() ? xChartType->isSupportingMainAxis(0, 0) : true; if (bSupportsMainAxis) { mxCBXAxis->show(); @@ -535,7 +527,7 @@ std::unique_ptr<PanelLayout> ChartElementsPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartElementsPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartElementsPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartElementsPanel>(pParent, pController); } @@ -563,12 +555,11 @@ void ChartElementsPanel::modelInvalid() mbModelValid = false; } -void ChartElementsPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartElementsPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + mxModel->removeModifyListener(mxListener); } mxModel = xModel; @@ -577,13 +568,14 @@ void ChartElementsPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> x if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); } void ChartElementsPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } IMPL_LINK(ChartElementsPanel, CheckBoxHdl, weld::Toggleable&, rCheckBox, void) @@ -629,6 +621,8 @@ IMPL_LINK(ChartElementsPanel, CheckBoxHdl, weld::Toggleable&, rCheckBox, void) setGridVisible(mxModel, GridType::VERT_MINOR, bChecked); else if (&rCheckBox == mxCBGridHorizontalMinor.get()) setGridVisible(mxModel, GridType::HOR_MINOR, bChecked); + + updateData(); } IMPL_LINK(ChartElementsPanel, EditHdl, weld::Entry&, rEdit, void) @@ -640,7 +634,8 @@ IMPL_LINK(ChartElementsPanel, EditHdl, weld::Entry&, rEdit, void) // set it OUString aText(rEdit.get_text()); - TitleHelper::setCompleteString(aText, TitleHelper::getTitle(aTitleType, mxModel), comphelper::getProcessComponentContext()); + TitleHelper::setCompleteString(aText, TitleHelper::getTitle(aTitleType, mxModel), + comphelper::getProcessComponentContext(), nullptr, true); } IMPL_LINK_NOARG(ChartElementsPanel, LegendPosHdl, weld::ComboBox&, void) diff --git a/chart2/source/controller/sidebar/ChartElementsPanel.hxx b/chart2/source/controller/sidebar/ChartElementsPanel.hxx index ff8516e3e4c8..2e0dee28b68f 100644 --- a/chart2/source/controller/sidebar/ChartElementsPanel.hxx +++ b/chart2/source/controller/sidebar/ChartElementsPanel.hxx @@ -93,7 +93,7 @@ private: vcl::EnumContext maContext; - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; bool mbModelValid; @@ -102,7 +102,7 @@ private: OUString maTextSubTitle; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); void setTitleVisible(TitleHelper::eTitleType eTitle, bool bVisible); diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx index 0cb228bc1222..87be2b47d185 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.cxx @@ -18,11 +18,11 @@ */ #include <com/sun/star/chart/ErrorBarStyle.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/beans/XPropertySet.hpp> #include "ChartErrorBarPanel.hxx" #include <ChartController.hxx> +#include <ChartModel.hxx> #include <vcl/svapp.hxx> #include <sal/log.hxx> @@ -41,13 +41,13 @@ enum class ErrorBarDirection }; css::uno::Reference<css::beans::XPropertySet> getErrorBarPropSet( - const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rCID) + const rtl::Reference<::chart::ChartModel>& xModel, std::u16string_view rCID) { return ObjectIdentifier::getObjectPropertySet(rCID, xModel); } -bool showPositiveError(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool showPositiveError(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -55,7 +55,7 @@ bool showPositiveError(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return false; - css::uno::Any aAny = xPropSet->getPropertyValue("ShowPositiveError"); + css::uno::Any aAny = xPropSet->getPropertyValue(u"ShowPositiveError"_ustr); if (!aAny.hasValue()) return false; @@ -65,8 +65,8 @@ bool showPositiveError(const css::uno::Reference<css::frame::XModel>& xModel, return bShow; } -bool showNegativeError(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool showNegativeError(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -74,7 +74,7 @@ bool showNegativeError(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return false; - css::uno::Any aAny = xPropSet->getPropertyValue("ShowNegativeError"); + css::uno::Any aAny = xPropSet->getPropertyValue(u"ShowNegativeError"_ustr); if (!aAny.hasValue()) return false; @@ -84,8 +84,8 @@ bool showNegativeError(const css::uno::Reference<css::frame::XModel>& xModel, return bShow; } -void setShowPositiveError(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bShow) +void setShowPositiveError(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bShow) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -93,11 +93,11 @@ void setShowPositiveError(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return; - xPropSet->setPropertyValue("ShowPositiveError", css::uno::Any(bShow)); + xPropSet->setPropertyValue(u"ShowPositiveError"_ustr, css::uno::Any(bShow)); } -void setShowNegativeError(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bShow) +void setShowNegativeError(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bShow) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -105,7 +105,7 @@ void setShowNegativeError(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return; - xPropSet->setPropertyValue("ShowNegativeError", css::uno::Any(bShow)); + xPropSet->setPropertyValue(u"ShowNegativeError"_ustr, css::uno::Any(bShow)); } struct ErrorBarTypeMap @@ -124,8 +124,8 @@ ErrorBarTypeMap const aErrorBarType[] = { { 6, css::chart::ErrorBarStyle::ERROR_MARGIN }, }; -sal_Int32 getTypePos(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +sal_Int32 getTypePos(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -133,7 +133,7 @@ sal_Int32 getTypePos(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return 0; - css::uno::Any aAny = xPropSet->getPropertyValue("ErrorBarStyle"); + css::uno::Any aAny = xPropSet->getPropertyValue(u"ErrorBarStyle"_ustr); if (!aAny.hasValue()) return 0; @@ -150,8 +150,8 @@ sal_Int32 getTypePos(const css::uno::Reference<css::frame::XModel>& xModel, return 0; } -void setTypePos(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, sal_Int32 nPos) +void setTypePos(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, sal_Int32 nPos) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -166,11 +166,11 @@ void setTypePos(const css::uno::Reference<css::frame::XModel>& xModel, nApi = i.nApi; } - xPropSet->setPropertyValue("ErrorBarStyle", css::uno::Any(nApi)); + xPropSet->setPropertyValue(u"ErrorBarStyle"_ustr, css::uno::Any(nApi)); } -double getValue(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, ErrorBarDirection eDir) +double getValue(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, ErrorBarDirection eDir) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -178,7 +178,7 @@ double getValue(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return 0; - OUString aName = "PositiveError"; + OUString aName = u"PositiveError"_ustr; if (eDir == ErrorBarDirection::NEGATIVE) aName = "NegativeError"; @@ -193,8 +193,8 @@ double getValue(const css::uno::Reference<css::frame::XModel>& xModel, return nVal; } -void setValue(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, double nVal, ErrorBarDirection eDir) +void setValue(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, double nVal, ErrorBarDirection eDir) { css::uno::Reference<css::beans::XPropertySet> xPropSet = getErrorBarPropSet(xModel, rCID); @@ -202,14 +202,14 @@ void setValue(const css::uno::Reference<css::frame::XModel>& xModel, if (!xPropSet.is()) return; - OUString aName = "PositiveError"; + OUString aName = u"PositiveError"_ustr; if (eDir == ErrorBarDirection::NEGATIVE) aName = "NegativeError"; xPropSet->setPropertyValue(aName, css::uno::Any(nVal)); } -OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) +OUString getCID(const rtl::Reference<::chart::ChartModel>& xModel) { css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController()); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); @@ -235,14 +235,14 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) } ChartErrorBarPanel::ChartErrorBarPanel(weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartErrorBarPanel", "modules/schart/ui/sidebarerrorbar.ui") - , mxRBPosAndNeg(m_xBuilder->weld_radio_button("radiobutton_positive_negative")) - , mxRBPos(m_xBuilder->weld_radio_button("radiobutton_positive")) - , mxRBNeg(m_xBuilder->weld_radio_button("radiobutton_negative")) - , mxLBType(m_xBuilder->weld_combo_box("comboboxtext_type")) - , mxMFPos(m_xBuilder->weld_spin_button("spinbutton_pos")) - , mxMFNeg(m_xBuilder->weld_spin_button("spinbutton_neg")) - , mxModel(pController->getModel()) + : PanelLayout(pParent, u"ChartErrorBarPanel"_ustr, u"modules/schart/ui/sidebarerrorbar.ui"_ustr) + , mxRBPosAndNeg(m_xBuilder->weld_radio_button(u"radiobutton_positive_negative"_ustr)) + , mxRBPos(m_xBuilder->weld_radio_button(u"radiobutton_positive"_ustr)) + , mxRBNeg(m_xBuilder->weld_radio_button(u"radiobutton_negative"_ustr)) + , mxLBType(m_xBuilder->weld_combo_box(u"comboboxtext_type"_ustr)) + , mxMFPos(m_xBuilder->weld_spin_button(u"spinbutton_pos"_ustr)) + , mxMFNeg(m_xBuilder->weld_spin_button(u"spinbutton_neg"_ustr)) + , mxModel(pController->getChartModel()) , mxListener(new ChartSidebarModifyListener(this)) , mbModelValid(true) { @@ -265,8 +265,7 @@ ChartErrorBarPanel::~ChartErrorBarPanel() void ChartErrorBarPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); mxRBNeg->set_active(false); mxRBPos->set_active(false); mxRBPosAndNeg->set_active(false); @@ -342,7 +341,7 @@ std::unique_ptr<PanelLayout> ChartErrorBarPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartErrorBarPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartErrorBarPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartErrorBarPanel>(pParent, pController); } @@ -370,12 +369,11 @@ void ChartErrorBarPanel::modelInvalid() mbModelValid = false; } -void ChartErrorBarPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartErrorBarPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + mxModel->removeModifyListener(mxListener); } mxModel = xModel; @@ -384,13 +382,14 @@ void ChartErrorBarPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> x if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); } void ChartErrorBarPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } IMPL_LINK_NOARG(ChartErrorBarPanel, RadioBtnHdl, weld::Toggleable&, void) diff --git a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx index c1bb6b4f8b94..92f7afb0ad53 100644 --- a/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx +++ b/chart2/source/controller/sidebar/ChartErrorBarPanel.hxx @@ -21,6 +21,7 @@ namespace com::sun::star::util { class XModifyListener; } namespace chart { class ChartController; +class ChartModel; namespace sidebar { @@ -72,13 +73,13 @@ private: std::unique_ptr<weld::SpinButton> mxMFPos; std::unique_ptr<weld::SpinButton> mxMFNeg; - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; bool mbModelValid; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); DECL_LINK(RadioBtnHdl, weld::Toggleable&, void); DECL_LINK(ListBoxHdl, weld::ComboBox&, void); diff --git a/chart2/source/controller/sidebar/ChartLinePanel.cxx b/chart2/source/controller/sidebar/ChartLinePanel.cxx index 1de557ec5aba..daa9f0645cfc 100644 --- a/chart2/source/controller/sidebar/ChartLinePanel.cxx +++ b/chart2/source/controller/sidebar/ChartLinePanel.cxx @@ -10,9 +10,9 @@ #include "ChartLinePanel.hxx" #include <ChartController.hxx> +#include <ChartModel.hxx> #include <svx/xlnwtit.hxx> -#include <svx/xlinjoit.hxx> #include <svx/xlntrit.hxx> #include <svx/linectrl.hxx> @@ -21,7 +21,6 @@ #include <vcl/svapp.hxx> #include <com/sun/star/view/XSelectionSupplier.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <com/sun/star/chart2/XDiagram.hpp> #include <comphelper/lok.hxx> @@ -34,19 +33,19 @@ namespace { SvxLineStyleToolBoxControl* getLineStyleToolBoxControl(const ToolbarUnoDispatcher& rToolBoxColor) { - css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxColor.GetControllerForCommand(".uno:XLineStyle"); + css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxColor.GetControllerForCommand(u".uno:XLineStyle"_ustr); SvxLineStyleToolBoxControl* pToolBoxLineStyleControl = dynamic_cast<SvxLineStyleToolBoxControl*>(xController.get()); return pToolBoxLineStyleControl; } SvxColorToolBoxControl* getColorToolBoxControl(const ToolbarUnoDispatcher& rToolBoxLineStyle) { - css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxLineStyle.GetControllerForCommand(".uno:XLineColor"); + css::uno::Reference<css::frame::XToolbarController> xController = rToolBoxLineStyle.GetControllerForCommand(u".uno:XLineColor"_ustr); SvxColorToolBoxControl* pToolBoxColorControl = dynamic_cast<SvxColorToolBoxControl*>(xController.get()); return pToolBoxColorControl; } -OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) +OUString getCID(const rtl::Reference<::chart::ChartModel>& xModel) { css::uno::Reference<css::frame::XController> xController(xModel->getCurrentController()); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(xController, css::uno::UNO_QUERY); @@ -55,10 +54,7 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) css::uno::Any aAny = xSelectionSupplier->getSelection(); if (!aAny.hasValue()) - { - xSelectionSupplier->select(css::uno::makeAny(OUString("CID/Page="))); - aAny = xSelectionSupplier->getSelection(); - } + return OUString(); OUString aCID; aAny >>= aCID; @@ -67,7 +63,7 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) } css::uno::Reference<css::beans::XPropertySet> getPropSet( - const css::uno::Reference<css::frame::XModel>& xModel) + const rtl::Reference<::chart::ChartModel>& xModel) { OUString aCID = getCID(xModel); css::uno::Reference<css::beans::XPropertySet> xPropSet = @@ -113,9 +109,9 @@ std::unique_ptr<PanelLayout> ChartLinePanel::Create( ChartController* pController) { if (pParent == nullptr) - throw css::lang::IllegalArgumentException("no parent Window given to ChartAxisPanel::Create", nullptr, 0); + throw css::lang::IllegalArgumentException(u"no parent Window given to ChartAxisPanel::Create"_ustr, nullptr, 0); if (!rxFrame.is()) - throw css::lang::IllegalArgumentException("no XFrame given to ChartAxisPanel::Create", nullptr, 1); + throw css::lang::IllegalArgumentException(u"no XFrame given to ChartAxisPanel::Create"_ustr, nullptr, 1); return std::make_unique<ChartLinePanel>(pParent, rxFrame, pController); } @@ -124,12 +120,12 @@ ChartLinePanel::ChartLinePanel(weld::Widget* pParent, const css::uno::Reference<css::frame::XFrame>& rxFrame, ChartController* pController): svx::sidebar::LinePropertyPanelBase(pParent, rxFrame), - mxModel(pController->getModel()), + mxModel(pController->getChartModel()), mxListener(new ChartSidebarModifyListener(this)), mxSelectionListener(new ChartSidebarSelectionListener(this)), mbUpdate(true), mbModelValid(true), - maLineColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), "LineColor"), + maLineColorWrapper(mxModel, getColorToolBoxControl(*mxColorDispatch), u"LineColor"_ustr), maLineStyleWrapper(mxModel, getLineStyleToolBoxControl(*mxLineStyleDispatch)) { disableArrowHead(); @@ -137,7 +133,7 @@ ChartLinePanel::ChartLinePanel(weld::Widget* pParent, OBJECTTYPE_DATA_SERIES, OBJECTTYPE_DATA_POINT, OBJECTTYPE_TITLE, OBJECTTYPE_LEGEND, OBJECTTYPE_DATA_CURVE, OBJECTTYPE_DATA_AVERAGE_LINE, OBJECTTYPE_AXIS}; - mxSelectionListener->setAcceptedTypes(aAcceptedTypes); + mxSelectionListener->setAcceptedTypes(std::move(aAcceptedTypes)); Initialize(); } @@ -148,8 +144,7 @@ ChartLinePanel::~ChartLinePanel() void ChartLinePanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -176,12 +171,12 @@ void ChartLinePanel::updateData() return; sal_uInt16 nLineTransparence = 0; - xPropSet->getPropertyValue("LineTransparence") >>= nLineTransparence; + xPropSet->getPropertyValue(u"LineTransparence"_ustr) >>= nLineTransparence; XLineTransparenceItem aLineTransparenceItem(nLineTransparence); updateLineTransparence(false, true, &aLineTransparenceItem); sal_uInt32 nWidth = 0; - xPropSet->getPropertyValue("LineWidth") >>= nWidth; + xPropSet->getPropertyValue(u"LineWidth"_ustr) >>= nWidth; XLineWidthItem aWidthItem(nWidth); updateLineWidth(false, true, &aWidthItem); @@ -200,12 +195,11 @@ void ChartLinePanel::selectionChanged(bool bCorrectType) updateData(); } -void ChartLinePanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartLinePanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + mxModel->removeModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier( mxModel->getCurrentController(), css::uno::UNO_QUERY); @@ -223,8 +217,7 @@ void ChartLinePanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode maLineStyleWrapper.updateModel(mxModel); maLineColorWrapper.updateModel(mxModel); - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -233,24 +226,9 @@ void ChartLinePanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMode void ChartLinePanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); -} - -void ChartLinePanel::setLineJoint(const XLineJointItem* pItem) -{ - css::uno::Reference<css::beans::XPropertySet> xPropSet = - getPropSet(mxModel); - - if (!xPropSet.is()) - return; - - PreventUpdate aPreventUpdate(mbUpdate); - if (pItem) - xPropSet->setPropertyValue("LineJoint", css::uno::Any(pItem->GetValue())); -} - -void ChartLinePanel::setLineCap(const XLineCapItem* /*pItem*/) -{ + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } void ChartLinePanel::setLineTransparency(const XLineTransparenceItem& rItem) @@ -262,7 +240,7 @@ void ChartLinePanel::setLineTransparency(const XLineTransparenceItem& rItem) return; PreventUpdate aPreventUpdate(mbUpdate); - xPropSet->setPropertyValue("LineTransparence", css::uno::Any(rItem.GetValue())); + xPropSet->setPropertyValue(u"LineTransparence"_ustr, css::uno::Any(rItem.GetValue())); } void ChartLinePanel::setLineWidth(const XLineWidthItem& rItem) @@ -274,7 +252,7 @@ void ChartLinePanel::setLineWidth(const XLineWidthItem& rItem) return; PreventUpdate aPreventUpdate(mbUpdate); - xPropSet->setPropertyValue("LineWidth", css::uno::Any(rItem.GetValue())); + xPropSet->setPropertyValue(u"LineWidth"_ustr, css::uno::Any(rItem.GetValue())); } void ChartLinePanel::updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem) @@ -285,7 +263,7 @@ void ChartLinePanel::updateLineWidth(bool bDisabled, bool bSetOrDefault, const S if (comphelper::LibreOfficeKit::isActive() && pViewShell) { pViewShell->libreOfficeKitViewCallback(LOK_CALLBACK_STATE_CHANGED, - (".uno:LineWidth=" + std::to_string(mnWidthCoreValue)).c_str()); + ".uno:LineWidth=" + OString::number(mnWidthCoreValue)); } } diff --git a/chart2/source/controller/sidebar/ChartLinePanel.hxx b/chart2/source/controller/sidebar/ChartLinePanel.hxx index c1348c7ac481..4449f3678fb6 100644 --- a/chart2/source/controller/sidebar/ChartLinePanel.hxx +++ b/chart2/source/controller/sidebar/ChartLinePanel.hxx @@ -16,12 +16,6 @@ #include "ChartSidebarSelectionListener.hxx" #include "ChartColorWrapper.hxx" -class XLineCapItem; -class XLineDashItem; -class XLineEndItem; -class XLineJointItem; -class XLineStartItem; -class XLineStyleItem; class XLineTransparenceItem; class XLineWidthItem; @@ -62,19 +56,17 @@ public: protected: virtual void setLineTransparency(const XLineTransparenceItem& rItem) override; - virtual void setLineJoint(const XLineJointItem* pItem) override; - virtual void setLineCap(const XLineCapItem* pItem) override; virtual void updateLineWidth(bool bDisabled, bool bSetOrDefault, const SfxPoolItem* pItem) override; private: - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; rtl::Reference<ChartSidebarSelectionListener> mxSelectionListener; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); bool mbUpdate; bool mbModelValid; diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx index 0550463e4d3c..8795e691fbd7 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.cxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.cxx @@ -18,24 +18,24 @@ */ #include <com/sun/star/chart/ErrorBarStyle.hpp> -#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/chart/DataLabelPlacement.hpp> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XDataSeries.hpp> -#include <com/sun/star/chart2/XChartTypeContainer.hpp> -#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> -#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> #include <vcl/svapp.hxx> #include <sal/log.hxx> #include "ChartSeriesPanel.hxx" #include <ChartController.hxx> - +#include <ChartModel.hxx> +#include <ChartType.hxx> +#include <DataSeries.hxx> #include <DataSeriesHelper.hxx> +#include <Diagram.hxx> #include <RegressionCurveHelper.hxx> +#include <RegressionCurveModel.hxx> #include <StatisticsHelper.hxx> +#include <BaseCoordinateSystem.hxx> + +#include <comphelper/processfactory.hxx> using namespace css; using namespace css::uno; @@ -44,29 +44,29 @@ namespace chart::sidebar { namespace { -bool isDataLabelVisible(const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rCID) +bool isDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, std::u16string_view rCID) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return false; - return DataSeriesHelper::hasDataLabelsAtSeries(xSeries); + return xSeries->hasDataLabelsAtSeries(); } -void setDataLabelVisible(const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rCID, bool bVisible) +void setDataLabelVisible(const rtl::Reference<::chart::ChartModel>& xModel, std::u16string_view rCID, bool bVisible) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return; if (bVisible) - DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints(xSeries); + xSeries->insertDataLabelsToSeriesAndAllPoints(); else - DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints(xSeries); + xSeries->deleteDataLabelsFromSeriesAndAllPoints(); } struct LabelPlacementMap @@ -84,16 +84,16 @@ LabelPlacementMap const aLabelPlacementMap[] = { { 5, css::chart::DataLabelPlacement::NEAR_ORIGIN } }; -sal_Int32 getDataLabelPlacement(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +sal_Int32 getDataLabelPlacement(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::beans::XPropertySet > xSeries( - ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return 0; - css::uno::Any aAny = xSeries->getPropertyValue("LabelPlacement"); + css::uno::Any aAny = xSeries->getPropertyValue(u"LabelPlacement"_ustr); if (!aAny.hasValue()) return 0; @@ -109,11 +109,11 @@ sal_Int32 getDataLabelPlacement(const css::uno::Reference<css::frame::XModel>& x return 0; } -void setDataLabelPlacement(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, sal_Int32 nPos) +void setDataLabelPlacement(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, sal_Int32 nPos) { - css::uno::Reference< css::beans::XPropertySet > xSeries( - ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xSeries = + ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return; @@ -128,26 +128,26 @@ void setDataLabelPlacement(const css::uno::Reference<css::frame::XModel>& xModel } } - xSeries->setPropertyValue("LabelPlacement", css::uno::Any(nApi)); + xSeries->setPropertyValue(u"LabelPlacement"_ustr, css::uno::Any(nApi)); } -bool isTrendlineVisible(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID) +bool isTrendlineVisible(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID) { - css::uno::Reference< css::chart2::XRegressionCurveContainer > xRegressionCurveContainer( - ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegressionCurveContainer = + ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xRegressionCurveContainer.is()) return false; - return xRegressionCurveContainer->getRegressionCurves().hasElements(); + return !xRegressionCurveContainer->getRegressionCurves2().empty(); } -void setTrendlineVisible(const css::uno::Reference<css::frame::XModel>& - xModel, const OUString& rCID, bool bVisible) +void setTrendlineVisible(const rtl::Reference<::chart::ChartModel>& + xModel, std::u16string_view rCID, bool bVisible) { - css::uno::Reference< css::chart2::XRegressionCurveContainer > xRegressionCurveContainer( - ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + rtl::Reference< DataSeries > xRegressionCurveContainer = + ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xRegressionCurveContainer.is()) return; @@ -164,10 +164,10 @@ void setTrendlineVisible(const css::uno::Reference<css::frame::XModel>& } -bool isErrorBarVisible(const css::uno::Reference<css::frame::XModel>& xModel, - const OUString& rCID, bool bYError) +bool isErrorBarVisible(const rtl::Reference<::chart::ChartModel>& xModel, + std::u16string_view rCID, bool bYError) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) @@ -176,10 +176,10 @@ bool isErrorBarVisible(const css::uno::Reference<css::frame::XModel>& xModel, return StatisticsHelper::hasErrorBars(xSeries, bYError); } -void setErrorBarVisible(const css::uno::Reference<css::frame::XModel>& - xModel, const OUString& rCID, bool bYError, bool bVisible) +void setErrorBarVisible(const rtl::Reference<::chart::ChartModel>& + xModel, std::u16string_view rCID, bool bYError, bool bVisible) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) @@ -197,53 +197,48 @@ void setErrorBarVisible(const css::uno::Reference<css::frame::XModel>& } } -bool isPrimaryAxis(const css::uno::Reference<css::frame::XModel>& - xModel, const OUString& rCID) +bool isPrimaryAxis(const rtl::Reference<::chart::ChartModel>& + xModel, std::u16string_view rCID) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return true; - return DataSeriesHelper::getAttachedAxisIndex(xSeries) == 0; + return xSeries->getAttachedAxisIndex() == 0; } -void setAttachedAxisType(const css::uno::Reference<css::frame::XModel>& - xModel, const OUString& rCID, bool bPrimary) +void setAttachedAxisType(const rtl::Reference<::chart::ChartModel>& + xModel, std::u16string_view rCID, bool bPrimary) { - css::uno::Reference< css::beans::XPropertySet > xSeries( - ObjectIdentifier::getDataSeriesForCID(rCID, xModel), uno::UNO_QUERY ); + const rtl::Reference<DataSeries> xDataSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); - if (!xSeries.is()) + if (!xDataSeries.is()) return; - sal_Int32 nIndex = bPrimary ? 0 : 1; - xSeries->setPropertyValue("AttachedAxisIndex", css::uno::Any(nIndex)); + rtl::Reference<Diagram> xDiagram = xModel->getFirstChartDiagram(); + xDiagram->attachSeriesToAxis(bPrimary, xDataSeries, comphelper::getProcessComponentContext()); } -css::uno::Reference<css::chart2::XChartType> getChartType( - const css::uno::Reference<css::frame::XModel>& xModel) +rtl::Reference<ChartType> getChartType( + const rtl::Reference<::chart::ChartModel>& xModel) { - css::uno::Reference<css::chart2::XChartDocument> xChartDoc (xModel, css::uno::UNO_QUERY); - css::uno::Reference<css::chart2::XDiagram> xDiagram = xChartDoc->getFirstDiagram(); - css::uno::Reference< css::chart2::XCoordinateSystemContainer > xCooSysContainer( xDiagram, UNO_QUERY_THROW ); - css::uno::Sequence< css::uno::Reference< css::chart2::XCoordinateSystem > > xCooSysSequence( xCooSysContainer->getCoordinateSystems()); - css::uno::Reference< css::chart2::XChartTypeContainer > xChartTypeContainer( xCooSysSequence[0], UNO_QUERY_THROW ); - css::uno::Sequence< css::uno::Reference< css::chart2::XChartType > > xChartTypeSequence( xChartTypeContainer->getChartTypes() ); - return xChartTypeSequence[0]; + rtl::Reference<Diagram> xDiagram = xModel->getFirstChartDiagram(); + const std::vector< rtl::Reference< BaseCoordinateSystem > > xCooSysSequence( xDiagram->getBaseCoordinateSystems()); + return xCooSysSequence[0]->getChartTypes2()[0]; } -OUString getSeriesLabel(const css::uno::Reference<css::frame::XModel>& xModel, const OUString& rCID) +OUString getSeriesLabel(const rtl::Reference<::chart::ChartModel>& xModel, std::u16string_view rCID) { - css::uno::Reference< css::chart2::XDataSeries > xSeries = + rtl::Reference< DataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID(rCID, xModel); if (!xSeries.is()) return OUString(); - css::uno::Reference<css::chart2::XChartType> xChartType = getChartType(xModel); - return DataSeriesHelper::getDataSeriesLabel(xSeries, xChartType->getRoleOfSequenceForSeriesLabel()); + rtl::Reference<ChartType> xChartType = getChartType(xModel); + return xSeries->getLabelForRole(xChartType->getRoleOfSequenceForSeriesLabel()); } OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) @@ -279,18 +274,18 @@ OUString getCID(const css::uno::Reference<css::frame::XModel>& xModel) ChartSeriesPanel::ChartSeriesPanel( weld::Widget* pParent, ChartController* pController) - : PanelLayout(pParent, "ChartSeriesPanel", "modules/schart/ui/sidebarseries.ui") - , mxCBLabel(m_xBuilder->weld_check_button("checkbutton_label")) - , mxCBTrendline(m_xBuilder->weld_check_button("checkbutton_trendline")) - , mxCBXError(m_xBuilder->weld_check_button("checkbutton_x_error")) - , mxCBYError(m_xBuilder->weld_check_button("checkbutton_y_error")) - , mxRBPrimaryAxis(m_xBuilder->weld_radio_button("radiobutton_primary_axis")) - , mxRBSecondaryAxis(m_xBuilder->weld_radio_button("radiobutton_secondary_axis")) - , mxBoxLabelPlacement(m_xBuilder->weld_widget("datalabel_box")) - , mxLBLabelPlacement(m_xBuilder->weld_combo_box("comboboxtext_label")) - , mxFTSeriesName(m_xBuilder->weld_label("label_series_name")) - , mxFTSeriesTemplate(m_xBuilder->weld_label("label_series_tmpl")) - , mxModel(pController->getModel()) + : PanelLayout(pParent, u"ChartSeriesPanel"_ustr, u"modules/schart/ui/sidebarseries.ui"_ustr) + , mxCBLabel(m_xBuilder->weld_check_button(u"checkbutton_label"_ustr)) + , mxCBTrendline(m_xBuilder->weld_check_button(u"checkbutton_trendline"_ustr)) + , mxCBXError(m_xBuilder->weld_check_button(u"checkbutton_x_error"_ustr)) + , mxCBYError(m_xBuilder->weld_check_button(u"checkbutton_y_error"_ustr)) + , mxRBPrimaryAxis(m_xBuilder->weld_radio_button(u"radiobutton_primary_axis"_ustr)) + , mxRBSecondaryAxis(m_xBuilder->weld_radio_button(u"radiobutton_secondary_axis"_ustr)) + , mxBoxLabelPlacement(m_xBuilder->weld_widget(u"datalabel_box"_ustr)) + , mxLBLabelPlacement(m_xBuilder->weld_combo_box(u"comboboxtext_label"_ustr)) + , mxFTSeriesName(m_xBuilder->weld_label(u"label_series_name"_ustr)) + , mxFTSeriesTemplate(m_xBuilder->weld_label(u"label_series_tmpl"_ustr)) + , mxModel(pController->getChartModel()) , mxListener(new ChartSidebarModifyListener(this)) , mxSelectionListener(new ChartSidebarSelectionListener(this, OBJECTTYPE_DATA_SERIES)) , mbModelValid(true) @@ -319,8 +314,7 @@ ChartSeriesPanel::~ChartSeriesPanel() void ChartSeriesPanel::Initialize() { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) xSelectionSupplier->addSelectionChangeListener(mxSelectionListener); @@ -376,7 +370,7 @@ std::unique_ptr<PanelLayout> ChartSeriesPanel::Create ( ChartController* pController) { if (pParent == nullptr) - throw lang::IllegalArgumentException("no parent Window given to ChartSeriesPanel::Create", nullptr, 0); + throw lang::IllegalArgumentException(u"no parent Window given to ChartSeriesPanel::Create"_ustr, nullptr, 0); return std::make_unique<ChartSeriesPanel>(pParent, pController); } @@ -405,12 +399,11 @@ void ChartSeriesPanel::modelInvalid() mbModelValid = false; } -void ChartSeriesPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartSeriesPanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + mxModel->removeModifyListener(mxListener); } css::uno::Reference<css::view::XSelectionSupplier> oldSelectionSupplier( @@ -425,8 +418,7 @@ void ChartSeriesPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMo if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + mxModel->addModifyListener(mxListener); css::uno::Reference<css::view::XSelectionSupplier> xSelectionSupplier(mxModel->getCurrentController(), css::uno::UNO_QUERY); if (xSelectionSupplier.is()) @@ -435,7 +427,9 @@ void ChartSeriesPanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xMo void ChartSeriesPanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } void ChartSeriesPanel::selectionChanged(bool bCorrectType) diff --git a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx index 3c573d91464c..5b69cc3b959f 100644 --- a/chart2/source/controller/sidebar/ChartSeriesPanel.hxx +++ b/chart2/source/controller/sidebar/ChartSeriesPanel.hxx @@ -91,14 +91,14 @@ private: std::unique_ptr<weld::Label> mxFTSeriesName; std::unique_ptr<weld::Label> mxFTSeriesTemplate; - css::uno::Reference<css::frame::XModel> mxModel; + rtl::Reference<::chart::ChartModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; css::uno::Reference<css::view::XSelectionChangeListener> mxSelectionListener; bool mbModelValid; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); DECL_LINK(CheckBoxHdl, weld::Toggleable&, void); DECL_LINK(RadioBtnHdl, weld::Toggleable&, void); diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx index 0c8018eb09c3..c3757a3b877a 100644 --- a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx +++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.cxx @@ -74,9 +74,9 @@ void ChartSidebarSelectionListener::disposing(const css::lang::EventObject& /*rE mpParent = nullptr; } -void ChartSidebarSelectionListener::setAcceptedTypes(const std::vector<ObjectType>& aTypes) +void ChartSidebarSelectionListener::setAcceptedTypes(std::vector<ObjectType>&& aTypes) { - maTypes = aTypes; + maTypes = std::move(aTypes); } } diff --git a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx index 44bae13651e1..e8cea5003fa0 100644 --- a/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx +++ b/chart2/source/controller/sidebar/ChartSidebarSelectionListener.hxx @@ -40,7 +40,7 @@ public: virtual void SAL_CALL disposing(const css::lang::EventObject& rEvent) override; - void setAcceptedTypes(const std::vector<ObjectType>& aTypes); + void setAcceptedTypes(std::vector<ObjectType>&& aTypes); private: ChartSidebarSelectionListenerParent* mpParent; diff --git a/chart2/source/controller/sidebar/ChartTypePanel.cxx b/chart2/source/controller/sidebar/ChartTypePanel.cxx index 2fca2443807f..fa85ded6d4a6 100644 --- a/chart2/source/controller/sidebar/ChartTypePanel.cxx +++ b/chart2/source/controller/sidebar/ChartTypePanel.cxx @@ -21,18 +21,16 @@ #include <TimerTriggeredControllerLock.hxx> #include <ChartController.hxx> -#include <ChartModelHelper.hxx> +#include <ChartModel.hxx> #include <ChartResourceGroups.hxx> #include <ChartTypeDialogController.hxx> -#include <DiagramHelper.hxx> +#include <ChartTypeManager.hxx> +#include <ChartTypeTemplate.hxx> +#include <Diagram.hxx> #include <unonames.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> -#include <com/sun/star/chart2/XDiagram.hpp> -#include <com/sun/star/util/XModifyBroadcaster.hpp> - #include <svtools/valueset.hxx> -#include <tools/diagnose_ex.h> +#include <comphelper/diagnose_ex.hxx> using namespace css; using namespace css::uno; @@ -40,9 +38,7 @@ using namespace css::uno; namespace chart::sidebar { ChartTypePanel::ChartTypePanel(weld::Widget* pParent, ::chart::ChartController* pController) - : PanelLayout(pParent, "ChartTypePanel", "modules/schart/ui/sidebartype.ui") - , maContext() - , mxModel(pController->getModel()) + : PanelLayout(pParent, u"ChartTypePanel"_ustr, u"modules/schart/ui/sidebartype.ui"_ustr) , mxListener(new ChartSidebarModifyListener(this)) , mbModelValid(true) , m_pDim3DLookResourceGroup(new Dim3DLookResourceGroup(m_xBuilder.get())) @@ -51,14 +47,14 @@ ChartTypePanel::ChartTypePanel(weld::Widget* pParent, ::chart::ChartController* new SplineResourceGroup(m_xBuilder.get(), pController->GetChartFrame())) , m_pGeometryResourceGroup(new GeometryResourceGroup(m_xBuilder.get())) , m_pSortByXValuesResourceGroup(new SortByXValuesResourceGroup(m_xBuilder.get())) - , m_xChartModel(mxModel, css::uno::UNO_QUERY_THROW) + , m_xChartModel(pController->getChartModel()) , m_aChartTypeDialogControllerList(0) , m_pCurrentMainType(nullptr) , m_nChangingCalls(0) , m_aTimerTriggeredControllerLock(m_xChartModel) - , m_xMainTypeList(m_xBuilder->weld_combo_box("cmb_chartType")) - , m_xSubTypeList(new ValueSet(m_xBuilder->weld_scrolled_window("subtypewin", true))) - , m_xSubTypeListWin(new weld::CustomWeld(*m_xBuilder, "subtype", *m_xSubTypeList)) + , m_xMainTypeList(m_xBuilder->weld_combo_box(u"cmb_chartType"_ustr)) + , m_xSubTypeList(new ValueSet(m_xBuilder->weld_scrolled_window(u"subtypewin"_ustr, true))) + , m_xSubTypeListWin(new weld::CustomWeld(*m_xBuilder, u"subtype"_ustr, *m_xSubTypeList)) { Size aSize(m_xSubTypeList->GetDrawingArea()->get_ref_device().LogicToPixel( Size(120, 40), MapMode(MapUnit::MapAppFont))); @@ -73,12 +69,13 @@ ChartTypePanel::ChartTypePanel(weld::Widget* pParent, ::chart::ChartController* m_xSubTypeList->SetLineCount(1); bool bEnableComplexChartTypes = true; - uno::Reference<beans::XPropertySet> xProps(m_xChartModel, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xProps(static_cast<cppu::OWeakObject*>(m_xChartModel.get()), + uno::UNO_QUERY); if (xProps.is()) { try { - xProps->getPropertyValue("EnableComplexChartTypes") >>= bEnableComplexChartTypes; + xProps->getPropertyValue(u"EnableComplexChartTypes"_ustr) >>= bEnableComplexChartTypes; } catch (const uno::Exception&) { @@ -88,7 +85,9 @@ ChartTypePanel::ChartTypePanel(weld::Widget* pParent, ::chart::ChartController* m_aChartTypeDialogControllerList.push_back(std::make_unique<ColumnChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<BarChartDialogController>()); + m_aChartTypeDialogControllerList.push_back(std::make_unique<HistogramChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<PieChartDialogController>()); + m_aChartTypeDialogControllerList.push_back(std::make_unique<OfPieChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<AreaChartDialogController>()); m_aChartTypeDialogControllerList.push_back(std::make_unique<LineChartDialogController>()); if (bEnableComplexChartTypes) @@ -106,7 +105,7 @@ ChartTypePanel::ChartTypePanel(weld::Widget* pParent, ::chart::ChartController* for (auto const& elem : m_aChartTypeDialogControllerList) { - m_xMainTypeList->append("", elem->getName(), elem->getImage()); + m_xMainTypeList->append(u""_ustr, elem->getName(), elem->getImage()); elem->setChangeListener(this); } @@ -157,12 +156,12 @@ void ChartTypePanel::Initialize() { if (!m_xChartModel.is()) return; - uno::Reference<lang::XMultiServiceFactory> xTemplateManager( - m_xChartModel->getChartTypeManager(), uno::UNO_QUERY); - uno::Reference<css::chart2::XDiagram> xDiagram(ChartModelHelper::findDiagram(m_xChartModel)); - DiagramHelper::tTemplateWithServiceName aTemplate - = DiagramHelper::getTemplateForDiagram(xDiagram, xTemplateManager); - OUString aServiceName(aTemplate.second); + rtl::Reference<::chart::ChartTypeManager> xChartTypeManager = m_xChartModel->getTypeManager(); + rtl::Reference<Diagram> xDiagram = m_xChartModel->getFirstChartDiagram(); + Diagram::tTemplateWithServiceName aTemplate; + if (xDiagram) + aTemplate = xDiagram->getTemplate(xChartTypeManager); + OUString aServiceName(aTemplate.sServiceName); bool bFound = false; @@ -175,21 +174,22 @@ void ChartTypePanel::Initialize() m_xMainTypeList->set_active(nM); showAllControls(*elem); - uno::Reference<beans::XPropertySet> xTemplateProps(aTemplate.first, uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTemplateProps( + static_cast<cppu::OWeakObject*>(aTemplate.xChartTypeTemplate.get()), + uno::UNO_QUERY); ChartTypeParameter aParameter = elem->getChartTypeParameterForService(aServiceName, xTemplateProps); m_pCurrentMainType = getSelectedMainType(); //set ThreeDLookScheme - aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme(xDiagram); + aParameter.eThreeDLookScheme = xDiagram->detectScheme(); if (!aParameter.b3DLook && aParameter.eThreeDLookScheme != ThreeDLookScheme::ThreeDLookScheme_Realistic) aParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic; try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch (const uno::Exception&) @@ -221,15 +221,14 @@ void ChartTypePanel::updateData() // Chart Type related if (!m_xChartModel.is()) return; - uno::Reference<lang::XMultiServiceFactory> xTemplateManager( - m_xChartModel->getChartTypeManager(), uno::UNO_QUERY); - uno::Reference<frame::XModel> xModel(m_xChartModel); - uno::Reference<css::chart2::XDiagram> xDiagram(ChartModelHelper::findDiagram(xModel)); - DiagramHelper::tTemplateWithServiceName aTemplate - = DiagramHelper::getTemplateForDiagram(xDiagram, xTemplateManager); - OUString aServiceName(aTemplate.second); - - sal_uInt16 nM = 0; + rtl::Reference<::chart::ChartTypeManager> xChartTypeManager = m_xChartModel->getTypeManager(); + rtl::Reference<Diagram> xDiagram = m_xChartModel->getFirstChartDiagram(); + Diagram::tTemplateWithServiceName aTemplate; + if (xDiagram) + aTemplate = xDiagram->getTemplate(xChartTypeManager); + OUString aServiceName(aTemplate.sServiceName); + + //sal_uInt16 nM = 0; for (auto const& elem : m_aChartTypeDialogControllerList) { if (elem->isSubType(aServiceName)) @@ -238,7 +237,7 @@ void ChartTypePanel::updateData() //m_pMainTypeList->select_entry_region(nM, nM); break; } - ++nM; + //++nM; } } @@ -262,40 +261,38 @@ void ChartTypePanel::HandleContextChange(const vcl::EnumContext& rContext) void ChartTypePanel::modelInvalid() { mbModelValid = false; } -void ChartTypePanel::doUpdateModel(css::uno::Reference<css::frame::XModel> xModel) +void ChartTypePanel::doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel) { if (mbModelValid) { - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcaster(mxModel, - css::uno::UNO_QUERY_THROW); - xBroadcaster->removeModifyListener(mxListener); + m_xChartModel->removeModifyListener(mxListener); } - mxModel = xModel; - mbModelValid = mxModel.is(); + m_xChartModel = xModel; + mbModelValid = m_xChartModel.is(); if (!mbModelValid) return; - css::uno::Reference<css::util::XModifyBroadcaster> xBroadcasterNew(mxModel, - css::uno::UNO_QUERY_THROW); - xBroadcasterNew->addModifyListener(mxListener); + m_xChartModel->addModifyListener(mxListener); } void ChartTypePanel::updateModel(css::uno::Reference<css::frame::XModel> xModel) { - doUpdateModel(xModel); + ::chart::ChartModel* pModel = dynamic_cast<::chart::ChartModel*>(xModel.get()); + assert(!xModel || pModel); + doUpdateModel(pModel); } -uno::Reference<css::chart2::XChartTypeTemplate> ChartTypePanel::getCurrentTemplate() const +rtl::Reference<::chart::ChartTypeTemplate> ChartTypePanel::getCurrentTemplate() const { if (m_pCurrentMainType && m_xChartModel.is()) { ChartTypeParameter aParameter(getCurrentParameter()); m_pCurrentMainType->adjustParameterToSubType(aParameter); - uno::Reference<lang::XMultiServiceFactory> xTemplateManager( - m_xChartModel->getChartTypeManager(), uno::UNO_QUERY); - return m_pCurrentMainType->getCurrentTemplate(aParameter, xTemplateManager); + rtl::Reference<::chart::ChartTypeManager> xChartTypeManager + = m_xChartModel->getTypeManager(); + return m_pCurrentMainType->getCurrentTemplate(aParameter, xChartTypeManager); } return nullptr; } @@ -372,12 +369,11 @@ void ChartTypePanel::stateChanged() commitToModel(aParameter); //detect the new ThreeDLookScheme - uno::Reference<css::chart2::XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); - aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme(xDiagram); + rtl::Reference<Diagram> xDiagram = m_xChartModel->getFirstChartDiagram(); + aParameter.eThreeDLookScheme = xDiagram->detectScheme(); try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch (const uno::Exception&) { @@ -395,7 +391,9 @@ void ChartTypePanel::commitToModel(const ChartTypeParameter& rParameter) return; m_aTimerTriggeredControllerLock.startTimer(); - m_pCurrentMainType->commitToModel(rParameter, m_xChartModel); + uno::Reference<beans::XPropertySet> xTemplateProps( + static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY); + m_pCurrentMainType->commitToModel(rParameter, m_xChartModel, xTemplateProps); } void ChartTypePanel::selectMainType() @@ -417,17 +415,15 @@ void ChartTypePanel::selectMainType() m_pCurrentMainType->adjustParameterToMainType(aParameter); commitToModel(aParameter); //detect the new ThreeDLookScheme - aParameter.eThreeDLookScheme - = ThreeDHelper::detectScheme(ChartModelHelper::findDiagram(m_xChartModel)); + aParameter.eThreeDLookScheme = m_xChartModel->getFirstChartDiagram()->detectScheme(); if (!aParameter.b3DLook && aParameter.eThreeDLookScheme != ThreeDLookScheme::ThreeDLookScheme_Realistic) aParameter.eThreeDLookScheme = ThreeDLookScheme::ThreeDLookScheme_Realistic; - uno::Reference<css::chart2::XDiagram> xDiagram = ChartModelHelper::findDiagram(m_xChartModel); + rtl::Reference<Diagram> xDiagram = m_xChartModel->getFirstChartDiagram(); try { - uno::Reference<beans::XPropertySet> xPropSet(xDiagram, uno::UNO_QUERY_THROW); - xPropSet->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; + xDiagram->getPropertyValue(CHART_UNONAME_SORT_BY_XVALUES) >>= aParameter.bSortByXValues; } catch (const uno::Exception&) { @@ -435,7 +431,8 @@ void ChartTypePanel::selectMainType() } fillAllControls(aParameter); - uno::Reference<beans::XPropertySet> xTemplateProps(getCurrentTemplate(), uno::UNO_QUERY); + uno::Reference<beans::XPropertySet> xTemplateProps( + static_cast<cppu::OWeakObject*>(getCurrentTemplate().get()), uno::UNO_QUERY); m_pCurrentMainType->fillExtraControls(m_xChartModel, xTemplateProps); } } // end of namespace ::chart::sidebar diff --git a/chart2/source/controller/sidebar/ChartTypePanel.hxx b/chart2/source/controller/sidebar/ChartTypePanel.hxx index 9610ce3520e9..8df0020431db 100644 --- a/chart2/source/controller/sidebar/ChartTypePanel.hxx +++ b/chart2/source/controller/sidebar/ChartTypePanel.hxx @@ -71,8 +71,7 @@ public: virtual void updateModel(css::uno::Reference<css::frame::XModel> xModel) override; - virtual css::uno::Reference<css::chart2::XChartTypeTemplate> - getCurrentTemplate() const override; + virtual rtl::Reference<::chart::ChartTypeTemplate> getCurrentTemplate() const override; private: ChartTypeDialogController* getSelectedMainType(); @@ -90,13 +89,12 @@ private: vcl::EnumContext maContext; - css::uno::Reference<css::frame::XModel> mxModel; css::uno::Reference<css::util::XModifyListener> mxListener; bool mbModelValid; void Initialize(); - void doUpdateModel(css::uno::Reference<css::frame::XModel> xModel); + void doUpdateModel(const rtl::Reference<::chart::ChartModel>& xModel); std::unique_ptr<Dim3DLookResourceGroup> m_pDim3DLookResourceGroup; std::unique_ptr<StackingResourceGroup> m_pStackingResourceGroup; @@ -104,7 +102,7 @@ private: std::unique_ptr<GeometryResourceGroup> m_pGeometryResourceGroup; std::unique_ptr<SortByXValuesResourceGroup> m_pSortByXValuesResourceGroup; - css::uno::Reference<css::chart2::XChartDocument> m_xChartModel; + rtl::Reference<::chart::ChartModel> m_xChartModel; std::vector<std::unique_ptr<ChartTypeDialogController>> m_aChartTypeDialogControllerList; ChartTypeDialogController* m_pCurrentMainType; diff --git a/chart2/source/controller/uitest/uiobject.cxx b/chart2/source/controller/uitest/uiobject.cxx index 651c407565d7..edc93d370f0a 100644 --- a/chart2/source/controller/uitest/uiobject.cxx +++ b/chart2/source/controller/uitest/uiobject.cxx @@ -11,21 +11,20 @@ #include <uiobject.hxx> #include <ChartWindow.hxx> +#include <ChartView.hxx> #include <ChartController.hxx> +#include <ChartModel.hxx> #include <ObjectHierarchy.hxx> -#include <chartview/ExplicitValueProvider.hxx> -#include <com/sun/star/chart2/XChartDocument.hpp> - -#include <comphelper/servicehelper.hxx> +#include <utility> #include <vcl/svapp.hxx> #include <algorithm> #include <iterator> ChartUIObject::ChartUIObject(const VclPtr<chart::ChartWindow>& xChartWindow, - const OUString& rCID): - maCID(rCID), + OUString aCID): + maCID(std::move(aCID)), mxChartWindow(xChartWindow) { } @@ -33,7 +32,7 @@ ChartUIObject::ChartUIObject(const VclPtr<chart::ChartWindow>& xChartWindow, StringMap ChartUIObject::get_state() { StringMap aMap; - aMap["CID"] = maCID; + aMap[u"CID"_ustr] = maCID; return aMap; } @@ -46,7 +45,7 @@ void ChartUIObject::execute(const OUString& rAction, std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); StringMap aParams; - aParams["NAME"] = maCID; + aParams[u"NAME"_ustr] = maCID; pWindow->execute(rAction, aParams); } else if (rAction == "COMMAND") @@ -55,12 +54,12 @@ void ChartUIObject::execute(const OUString& rAction, std::unique_ptr<UIObject> pWindow = mxChartWindow->GetUITestFactory()(mxChartWindow.get()); StringMap aParams; - aParams["NAME"] = maCID; - pWindow->execute("SELECT", aParams); + aParams[u"NAME"_ustr] = maCID; + pWindow->execute(u"SELECT"_ustr, aParams); - auto itr = rParameters.find("COMMAND"); + auto itr = rParameters.find(u"COMMAND"_ustr); if (itr == rParameters.end()) - throw css::uno::RuntimeException("missing COMMAND parameter"); + throw css::uno::RuntimeException(u"missing COMMAND parameter"_ustr); maCommands.emplace_back(new OUString(itr->second)); OUString* pCommand = maCommands.rbegin()->get(); @@ -92,7 +91,15 @@ std::set<OUString> ChartUIObject::get_children() const OUString ChartUIObject::get_type() const { - return "ChartUIObject for type: "; + return u"ChartUIObject for type: "_ustr; +} + +bool ChartUIObject::equals(const UIObject& rOther) const +{ + const ChartUIObject* pOther = dynamic_cast<const ChartUIObject*>(&rOther); + if (!pOther) + return false; + return mxChartWindow.get() == pOther->mxChartWindow.get(); } ChartWindowUIObject::ChartWindowUIObject(const VclPtr<chart::ChartWindow>& xChartWindow): @@ -111,7 +118,7 @@ StringMap ChartWindowUIObject::get_state() css::uno::Any aAny = pController->getSelection(); OUString aSelectedObject; aAny >>= aSelectedObject; - aMap["SelectedObject"] = aSelectedObject; + aMap[u"SelectedObject"_ustr] = aSelectedObject; } return aMap; @@ -122,9 +129,9 @@ void ChartWindowUIObject::execute(const OUString& rAction, { if (rAction == "SELECT") { - auto itr = rParameters.find("NAME"); + auto itr = rParameters.find(u"NAME"_ustr); if (itr == rParameters.end()) - throw css::uno::RuntimeException("Missing Parameter 'NAME' for action 'SELECT'"); + throw css::uno::RuntimeException(u"Missing Parameter 'NAME' for action 'SELECT'"_ustr); const OUString& rName = itr->second; @@ -143,7 +150,7 @@ std::unique_ptr<UIObject> ChartWindowUIObject::get_child(const OUString& rID) if (chart::ObjectIdentifier::isCID(rID)) return std::unique_ptr<UIObject>(new ChartUIObject(mxChartWindow, rID)); - throw css::uno::RuntimeException("unknown child"); + throw css::uno::RuntimeException(u"unknown child"_ustr); } namespace { @@ -172,10 +179,9 @@ std::set<OUString> ChartWindowUIObject::get_children() const if (!pController) return aChildren; - css::uno::Reference< css::chart2::XChartDocument > xChartDoc( pController->getModel(), css::uno::UNO_QUERY ); - - css::uno::Reference<css::uno::XInterface> xChartView = pController->getChartView(); - chart::ExplicitValueProvider* pValueProvider = comphelper::getUnoTunnelImplementation<chart::ExplicitValueProvider>( xChartView ); + rtl::Reference<::chart::ChartModel> xChartDoc = pController->getChartModel(); + rtl::Reference<::chart::ChartView> xChartView = pController->getChartView(); + chart::ChartView* pValueProvider = xChartView.get(); chart::ObjectHierarchy aHierarchy(xChartDoc, pValueProvider); chart::ObjectIdentifier aIdentifier = chart::ObjectHierarchy::getRootNodeOID(); aChildren.insert(aIdentifier.getObjectCID()); @@ -195,7 +201,7 @@ std::unique_ptr<UIObject> ChartWindowUIObject::create(vcl::Window* pWindow) OUString ChartWindowUIObject::get_name() const { - return "ChartWindowUIObject"; + return u"ChartWindowUIObject"_ustr; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |