diff options
Diffstat (limited to 'chart2/source/controller')
352 files changed, 76089 insertions, 0 deletions
diff --git a/chart2/source/controller/accessibility/AccStatisticsObject.cxx b/chart2/source/controller/accessibility/AccStatisticsObject.cxx new file mode 100644 index 000000000000..f9ea135242d3 --- /dev/null +++ b/chart2/source/controller/accessibility/AccStatisticsObject.cxx @@ -0,0 +1,84 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccStatisticsObject.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AccStatisticsObject.hxx" +#include <vcl/svapp.hxx> +#include <svx/svditer.hxx> + +using ::rtl::OUString; + +namespace chart +{ + +AccStatisticsObject::AccStatisticsObject( const AccessibleElementInfo& rAccInfo ) + : AccessibleChartElement( rAccInfo, false/*NoChildren*/, true/*AlwaysTransparent*/ ) + //, m_eType( eType ) + //, m_nSeriesIndex( nSeriesIndex ) +{ +// ChartModel * pModel = GetChartModel(); +// OSL_ASSERT( pModel ); + + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); +/* switch( eType ) + { + case MEAN_VAL_LINE: + SetItemSet( pModel->GetAverageAttr( m_nSeriesIndex )); + break; + case ERROR_BARS: + SetItemSet( pModel->GetErrorAttr( m_nSeriesIndex )); + break; + case REGRESSION: + SetItemSet( pModel->GetRegressAttr( m_nSeriesIndex )); + break; + }*/ + // \-- solar +} + +AccStatisticsObject::~AccStatisticsObject() +{ +} + +OUString SAL_CALL AccStatisticsObject::getAccessibleName() + throw (::com::sun::star::uno::RuntimeException) +{ + return getToolTipText(); +} + +OUString SAL_CALL AccStatisticsObject::getImplementationName() + throw (::com::sun::star::uno::RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "StatisticsObject" )); +} + +} // namespace chart diff --git a/chart2/source/controller/accessibility/AccStatisticsObject.hxx b/chart2/source/controller/accessibility/AccStatisticsObject.hxx new file mode 100644 index 000000000000..4306da3e7576 --- /dev/null +++ b/chart2/source/controller/accessibility/AccStatisticsObject.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccStatisticsObject.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_ACCSTATISTICSOBJECT_HXX +#define _CHART2_ACCSTATISTICSOBJECT_HXX + +#ifndef _CHART2_ACCESSIBLE_CHART_ELEMENT_HXX_ +#include "AccessibleChartElement.hxx" +#endif + +#include "ObjectIdentifier.hxx" + +namespace chart +{ + +class AccStatisticsObject : public AccessibleChartElement +{ +public: + /* + enum StatisticsObjectType + { + MEAN_VAL_LINE = OBJECTTYPE_AVERAGEVALUE, + ERROR_BARS = OBJECTTYPE_ERROR, + REGRESSION = OBJECTTYPE_REGRESSION + }; + */ + + AccStatisticsObject( const AccessibleElementInfo& rAccInfo ); + + virtual ~AccStatisticsObject(); + + // ________ XAccessibleContext ________ + virtual ::rtl::OUString SAL_CALL getAccessibleName() throw (::com::sun::star::uno::RuntimeException); + + // ________ XServiceInfo ________ + virtual ::rtl::OUString SAL_CALL getImplementationName() throw (::com::sun::star::uno::RuntimeException); + +private: + //const StatisticsObjectType m_eType; + //const sal_uInt16 m_nSeriesIndex; +}; + +} // accessibility + +#endif diff --git a/chart2/source/controller/accessibility/AccessibleBase.cxx b/chart2/source/controller/accessibility/AccessibleBase.cxx new file mode 100644 index 000000000000..df3cab9e39b4 --- /dev/null +++ b/chart2/source/controller/accessibility/AccessibleBase.cxx @@ -0,0 +1,1002 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleBase.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AccessibleBase.hxx" +#include "ObjectHierarchy.hxx" +#include "ObjectIdentifier.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "macros.hxx" + +#include <com/sun/star/awt/XDevice.hpp> +#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 <rtl/ustrbuf.hxx> +// for SolarMutex +#include <vcl/svapp.hxx> +#include <rtl/uuid.h> +#include <cppuhelper/queryinterface.hxx> +#include <svtools/itemset.hxx> +#include <svx/unofdesc.hxx> +#include <svx/outliner.hxx> +#include <svx/svdoutl.hxx> +#include <svx/svdetc.hxx> +#include <svx/unoshape.hxx> +#include <svx/unoprov.hxx> +#include <vcl/unohelp.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.hxx> + +#include <algorithm> + +#include "ChartElementFactory.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; + +using ::com::sun::star::uno::UNO_QUERY; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::uno::Reference; +using ::osl::MutexGuard; +using ::osl::ClearableMutexGuard; +using ::osl::ResettableMutexGuard; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Any; + +namespace chart +{ + +/** @param bMayHaveChildren is false per default + */ +AccessibleBase::AccessibleBase( + const AccessibleElementInfo & rAccInfo, + bool bMayHaveChildren, + bool bAlwaysTransparent /* default: false */ ) : + impl::AccessibleBase_Base( m_aMutex ), + m_bIsDisposed( false ), + m_bMayHaveChildren( bMayHaveChildren ), + m_bChildrenInitialized( false ), + m_nEventNotifierId(0), + m_pStateSetHelper( new ::utl::AccessibleStateSetHelper() ), + m_aStateSet( m_pStateSetHelper ), + m_aAccInfo( rAccInfo ), + m_bAlwaysTransparent( bAlwaysTransparent ), + m_bStateSetInitialized( false ) +{ + // initialize some states + OSL_ASSERT( m_pStateSetHelper ); + m_pStateSetHelper->AddState( AccessibleStateType::ENABLED ); + m_pStateSetHelper->AddState( AccessibleStateType::SHOWING ); + m_pStateSetHelper->AddState( AccessibleStateType::VISIBLE ); + m_pStateSetHelper->AddState( AccessibleStateType::SELECTABLE ); + m_pStateSetHelper->AddState( AccessibleStateType::FOCUSABLE ); +} + +AccessibleBase::~AccessibleBase() +{ + OSL_ASSERT( m_bIsDisposed ); +} + +// ________ public ________ + +bool AccessibleBase::CheckDisposeState( bool bThrowException /* default: true */ ) const + throw (lang::DisposedException) +{ + if( bThrowException && + m_bIsDisposed ) + { + throw lang::DisposedException( + C2U("component has state DEFUNC" ), + static_cast< uno::XWeak * >( const_cast< AccessibleBase * >( this ))); + } + return m_bIsDisposed; +} + +bool AccessibleBase::NotifyEvent( EventType eEventType, const AccessibleUniqueId & rId ) +{ + if( GetId() == rId ) + { + // event is addressed to this object + + ::com::sun::star::uno::Any aEmpty; + ::com::sun::star::uno::Any aSelected; + aSelected <<= AccessibleStateType::SELECTED; + switch( eEventType ) + { + case OBJECT_CHANGE: + { + BroadcastAccEvent( AccessibleEventId::VISIBLE_DATA_CHANGED, aEmpty, aEmpty ); +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( + ::rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "Visible data event sent by: " )) + + getAccessibleName(), + RTL_TEXTENCODING_ASCII_US ).getStr() ); +#endif + } + break; + + case GOT_SELECTION: + { + AddState( AccessibleStateType::SELECTED ); + BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty ); + + AddState( AccessibleStateType::FOCUSED ); + aSelected <<= AccessibleStateType::FOCUSED; + BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aSelected, aEmpty, true ); +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( + ::rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "Selection acquired by: " )) + + getAccessibleName(), + RTL_TEXTENCODING_ASCII_US ).getStr() ); +#endif + } + break; + + case LOST_SELECTION: + { + RemoveState( AccessibleStateType::SELECTED ); + BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected ); + + AddState( AccessibleStateType::FOCUSED ); + aSelected <<= AccessibleStateType::FOCUSED; + BroadcastAccEvent( AccessibleEventId::STATE_CHANGED, aEmpty, aSelected, true ); +#if OSL_DEBUG_LEVEL > 1 + OSL_TRACE( + ::rtl::OUStringToOString( + OUString( RTL_CONSTASCII_USTRINGPARAM( + "Selection lost by: " )) + + getAccessibleName(), + RTL_TEXTENCODING_ASCII_US ).getStr() ); +#endif + } + break; + + case PROPERTY_CHANGE: + { + //not implemented --> rebuild all + } + break; + } + return true; + } + else if( m_bMayHaveChildren ) + { + bool bStop = false; + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + // make local copy for notification + ChildListVectorType aLocalChildList( m_aChildList ); + aGuard.clear(); + // \-- + + ChildListVectorType::iterator aEndIter = aLocalChildList.end(); + for( ChildListVectorType::iterator aIter = aLocalChildList.begin() ; + ( aIter != aEndIter ) && ( ! bStop ) ; + ++aIter ) + { + // Note: at this place we must be sure to have an AccessibleBase + // object in the UNO reference to XAccessible ! + bStop = (*static_cast< AccessibleBase * > + ( (*aIter).get() )).NotifyEvent( eEventType, rId ); + } + return bStop; + } + + return false; +} + +void AccessibleBase::AddState( sal_Int16 aState ) + throw (RuntimeException) +{ + CheckDisposeState(); + OSL_ASSERT( m_pStateSetHelper ); + m_pStateSetHelper->AddState( aState ); +} + +void AccessibleBase::RemoveState( sal_Int16 aState ) + throw (RuntimeException) +{ + CheckDisposeState(); + OSL_ASSERT( m_pStateSetHelper ); + m_pStateSetHelper->RemoveState( aState ); +} + +// ________ protected ________ + +bool AccessibleBase::UpdateChildren() +{ + bool bMustUpdateChildren = false; + { + // /-- + MutexGuard aGuard( GetMutex() ); + if( ! m_bMayHaveChildren || + m_bIsDisposed ) + return false; + + bMustUpdateChildren = ( m_bMayHaveChildren && + ! m_bChildrenInitialized ); + // \-- + } + + // update unguarded + if( bMustUpdateChildren ) + m_bChildrenInitialized = ImplUpdateChildren(); + + return m_bChildrenInitialized; +} + +bool AccessibleBase::ImplUpdateChildren() +{ + bool bResult = false; + + if( m_aAccInfo.m_spObjectHierarchy ) + { + ObjectHierarchy::tChildContainer aModelChildren( + m_aAccInfo.m_spObjectHierarchy->getChildren( GetId() )); + ::std::vector< ChildCIDMap::key_type > aAccChildren; + aAccChildren.reserve( aModelChildren.size()); + ::std::transform( m_aChildCIDMap.begin(), m_aChildCIDMap.end(), + ::std::back_inserter( aAccChildren ), + ::std::select1st< ChildCIDMap::value_type >()); + + ::std::sort( aModelChildren.begin(), aModelChildren.end()); + + ::std::vector< OUString > aChildrenToRemove, aChildrenToAdd; + ::std::set_difference( aModelChildren.begin(), aModelChildren.end(), + aAccChildren.begin(), aAccChildren.end(), + ::std::back_inserter( aChildrenToAdd )); + ::std::set_difference( aAccChildren.begin(), aAccChildren.end(), + aModelChildren.begin(), aModelChildren.end(), + ::std::back_inserter( aChildrenToRemove )); + + ::std::vector< OUString >::const_iterator aIt( aChildrenToRemove.begin()); + for( ; aIt != aChildrenToRemove.end(); ++aIt ) + { + RemoveChildById( *aIt ); + } + + AccessibleElementInfo aAccInfo( GetInfo()); + aAccInfo.m_pParent = this; + + for( aIt = aChildrenToAdd.begin(); aIt != aChildrenToAdd.end(); ++aIt ) + { + aAccInfo.m_aCID = *aIt; + AddChild( ChartElementFactory::CreateChartElement( aAccInfo )); + } + bResult = true; + } + + return bResult; +} + +void AccessibleBase::AddChild( AccessibleBase * pChild ) +{ + OSL_ENSURE( pChild != NULL, "Invalid Child" ); + if( pChild ) + { + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + + Reference< XAccessible > xChild( pChild ); + m_aChildList.push_back( xChild ); + + m_aChildCIDMap[ pChild->GetId() ] = xChild; + + // inform listeners of new child + if( m_bChildrenInitialized ) + { + Any aEmpty, aNew; + aNew <<= xChild; + + aGuard.clear(); + // \-- (1st) + BroadcastAccEvent( AccessibleEventId::CHILD, aNew, aEmpty ); + } + // \-- (2nd) + } +} + +/** in this method we imply that the Reference< XAccessible > elements in the + vector are AccessibleBase objects ! + */ +void AccessibleBase::RemoveChildById( const ::rtl::OUString & rId ) +{ + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + + ChildCIDMap::iterator aIt( m_aChildCIDMap.find( rId )); + if( aIt != m_aChildCIDMap.end()) + { + Reference< XAccessible > xChild( aIt->second ); + + // remove from map + m_aChildCIDMap.erase( aIt ); + + // search child in vector + ChildListVectorType::iterator aVecIter = + ::std::find( m_aChildList.begin(), m_aChildList.end(), xChild ); + + OSL_ENSURE( aVecIter != m_aChildList.end(), + "Inconsistent ChildMap" ); + + // remove child from vector + m_aChildList.erase( aVecIter ); + bool bInitialized = m_bChildrenInitialized; + + // call listeners unguarded + aGuard.clear(); + // \-- (1st) + + // inform listeners of removed child + if( bInitialized ) + { + Any aEmpty, aOld; + aOld <<= xChild; + + BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); + } + + // dispose the child + Reference< lang::XComponent > xComp( xChild, UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); + } +} + +awt::Point AccessibleBase::GetUpperLeftOnScreen() const +{ + awt::Point aResult; + if( m_aAccInfo.m_pParent ) + { + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + AccessibleBase * pParent = m_aAccInfo.m_pParent; + aGuard.clear(); + // \-- + + if( pParent ) + { + aResult = pParent->GetUpperLeftOnScreen(); + } + else + OSL_ENSURE( false, "Default position used is probably incorrect." ); + } + + return aResult; +} + +void AccessibleBase::BroadcastAccEvent( + sal_Int16 nId, + const Any & rNew, + const Any & rOld, + bool bSendGlobally ) const +{ + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + + 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( GetMutex() ); + + // make local copy for notification + ChildListVectorType aLocalChildList( m_aChildList ); + + // remove all children + m_aChildList.clear(); + m_aChildCIDMap.clear(); + + aGuard.clear(); + // \-- + + // call dispose for all children + // and notify listeners + Reference< lang::XComponent > xComp; + Any aEmpty, aOld; + ChildListVectorType::const_iterator aEndIter = aLocalChildList.end(); + for( ChildListVectorType::const_iterator aIter = aLocalChildList.begin(); + aIter != aEndIter; ++aIter ) + { + aOld <<= (*aIter); + BroadcastAccEvent( AccessibleEventId::CHILD, aEmpty, aOld ); + + xComp.set( *aIter, UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); + } + m_bChildrenInitialized = false; +} + +AccessibleElementInfo AccessibleBase::GetInfo() const +{ + return m_aAccInfo; +} + +void AccessibleBase::SetInfo( const AccessibleElementInfo & rNewInfo ) +{ + m_aAccInfo = rNewInfo; + if( m_bMayHaveChildren ) + { + KillAllChildren(); + } + BroadcastAccEvent( AccessibleEventId::INVALIDATE_ALL_CHILDREN, uno::Any(), uno::Any(), + true /* global notification */ ); +} + +AccessibleUniqueId AccessibleBase::GetId() const +{ + return m_aAccInfo.m_aCID; +} + +// ____________________________________ +// ____________________________________ +// +// Interfaces +// ____________________________________ +// ____________________________________ + +// ________ (XComponent::dispose) ________ +void SAL_CALL AccessibleBase::disposing() +{ + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + OSL_ENSURE( ! m_bIsDisposed, "dispose() called twice" ); + + // notify disposing to all AccessibleEvent listeners asynchron + if ( m_nEventNotifierId ) + { + ::comphelper::AccessibleEventNotifier::revokeClientNotifyDisposing( m_nEventNotifierId, *this ); + m_nEventNotifierId = 0; + } + + // reset pointers + m_aAccInfo.m_pParent = NULL; + + // invalidate implementation for helper, but keep UNO reference to still + // allow a tool to query the DEFUNC state. + // Note: The object will be deleted when the last reference is released + m_pStateSetHelper = NULL; + + // attach new empty state set helper to member reference + ::utl::AccessibleStateSetHelper * pHelper = new ::utl::AccessibleStateSetHelper(); + pHelper->AddState( AccessibleStateType::DEFUNC ); + // release old helper and attach new one + m_aStateSet.set( pHelper ); + + m_bIsDisposed = true; + + // call listeners unguarded + aGuard.clear(); + // \-- + + if( m_bMayHaveChildren ) + { + KillAllChildren(); + } + else + OSL_ENSURE( m_aChildList.empty(), "Child list should be empty" ); +} + +// ________ XAccessible ________ +Reference< XAccessibleContext > SAL_CALL AccessibleBase::getAccessibleContext() + throw (RuntimeException) +{ + return this; +} + +// ________ AccessibleBase::XAccessibleContext ________ +sal_Int32 SAL_CALL AccessibleBase::getAccessibleChildCount() + throw (RuntimeException) +{ + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + if( ! m_bMayHaveChildren || + m_bIsDisposed ) + return 0; + + bool bMustUpdateChildren = ( m_bMayHaveChildren && + ! m_bChildrenInitialized ); + + aGuard.clear(); + // \-- + + // update unguarded + if( bMustUpdateChildren ) + UpdateChildren(); + + return ImplGetAccessibleChildCount(); +} + +sal_Int32 AccessibleBase::ImplGetAccessibleChildCount() const + throw (RuntimeException) +{ + return m_aChildList.size(); +} + +Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleChild( sal_Int32 i ) + throw (lang::IndexOutOfBoundsException, RuntimeException) +{ + CheckDisposeState(); + Reference< XAccessible > xResult; + + // /-- + ResettableMutexGuard aGuard( GetMutex() ); + bool bMustUpdateChildren = ( m_bMayHaveChildren && + ! m_bChildrenInitialized ); + + aGuard.clear(); + // \-- + + if( bMustUpdateChildren ) + UpdateChildren(); + + xResult.set( ImplGetAccessibleChildById( i )); + + return xResult; + // \-- +} + +Reference< XAccessible > AccessibleBase::ImplGetAccessibleChildById( sal_Int32 i ) const + throw (lang::IndexOutOfBoundsException, RuntimeException) +{ + Reference< XAccessible > xResult; + // /-- + MutexGuard aGuard( GetMutex()); + if( ! m_bMayHaveChildren || + i < 0 || + static_cast< ChildListVectorType::size_type >( i ) >= m_aChildList.size() ) + { + OUStringBuffer aBuf; + aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( "Index " )); + aBuf.append( i ); + aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " is invalid for range [ 0, " )); + aBuf.append( static_cast< sal_Int32 >( m_aChildList.size() - 1 ) ); + aBuf.appendAscii( RTL_CONSTASCII_STRINGPARAM( " ]" ) ); + lang::IndexOutOfBoundsException aEx( aBuf.makeStringAndClear(), + const_cast< ::cppu::OWeakObject * >( + static_cast< const ::cppu::OWeakObject * >( this ))); + throw aEx; + } + else + xResult.set( m_aChildList[ i ] ); + + return xResult; +} + +Reference< XAccessible > SAL_CALL AccessibleBase::getAccessibleParent() + throw (RuntimeException) +{ + CheckDisposeState(); + Reference< XAccessible > aResult; + if( m_aAccInfo.m_pParent ) + aResult.set( m_aAccInfo.m_pParent ); + + return aResult; +} + +sal_Int32 SAL_CALL AccessibleBase::getAccessibleIndexInParent() + throw (RuntimeException) +{ + CheckDisposeState(); + + if( m_aAccInfo.m_spObjectHierarchy ) + return m_aAccInfo.m_spObjectHierarchy->getIndexInParent( GetId() ); + return -1; +} + +sal_Int16 SAL_CALL AccessibleBase::getAccessibleRole() + throw (RuntimeException) +{ + return AccessibleRole::LIST_ITEM; // #i73747# role SHAPE seems more appropriate, but is not read +} + +Reference< XAccessibleRelationSet > SAL_CALL AccessibleBase::getAccessibleRelationSet() + throw (RuntimeException) +{ + Reference< XAccessibleRelationSet > aResult; + return aResult; +} + +Reference< XAccessibleStateSet > SAL_CALL AccessibleBase::getAccessibleStateSet() + throw (RuntimeException) +{ + if( ! m_bStateSetInitialized ) + { + OUString aSelCID; + Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); + if( xSelSupp.is() && + ( xSelSupp->getSelection() >>= aSelCID ) && + GetId().equals( aSelCID ) ) + { + AddState( AccessibleStateType::SELECTED ); + AddState( AccessibleStateType::FOCUSED ); + } + m_bStateSetInitialized = true; + } + + return m_aStateSet; +} + + +lang::Locale SAL_CALL AccessibleBase::getLocale() + throw (IllegalAccessibleComponentStateException, RuntimeException) +{ + CheckDisposeState(); + + return Application::GetSettings().GetLocale(); +} + +// ________ AccessibleBase::XAccessibleComponent ________ +sal_Bool SAL_CALL AccessibleBase::containsPoint( const awt::Point& aPoint ) + throw (RuntimeException) +{ + 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 ) + throw (RuntimeException) +{ + CheckDisposeState(); + Reference< XAccessible > aResult; + awt::Rectangle aRect( getBounds()); + + // children are positioned relative to this object, so translate bound rect + aRect.X = 0; + aRect.Y = 0; + + // children must be inside the own bound rect + if( ( aRect.X <= aPoint.X && aPoint.X <= (aRect.X + aRect.Width) ) && + ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) + { + // /-- + ClearableMutexGuard aGuard( GetMutex() ); + ChildListVectorType aLocalChildList( m_aChildList ); + aGuard.clear(); + // \-- + + Reference< XAccessibleComponent > aComp; + for( ChildListVectorType::const_iterator aIter = aLocalChildList.begin(); + aIter != aLocalChildList.end(); ++aIter ) + { + aComp.set( *aIter, UNO_QUERY ); + if( aComp.is()) + { + aRect = aComp->getBounds(); + if( ( aRect.X <= aPoint.X && aPoint.X <= (aRect.X + aRect.Width) ) && + ( aRect.Y <= aPoint.Y && aPoint.Y <= (aRect.Y + aRect.Height))) + { + aResult = (*aIter); + break; + } + } + } + } + + return aResult; +} + +awt::Rectangle SAL_CALL AccessibleBase::getBounds() + throw (RuntimeException) +{ + ExplicitValueProvider *pExplicitValueProvider( + ExplicitValueProvider::getExplicitValueProvider( m_aAccInfo.m_xView )); + if( pExplicitValueProvider ) + { + Window* pWindow( VCLUnoHelper::GetWindow( m_aAccInfo.m_xWindow )); + awt::Rectangle aLogicRect( pExplicitValueProvider->getRectangleOfObject( m_aAccInfo.m_aCID )); + if( pWindow ) + { + Rectangle aRect( aLogicRect.X, aLogicRect.Y, + aLogicRect.X + aLogicRect.Width, + aLogicRect.Y + aLogicRect.Height ); + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + aRect = pWindow->LogicToPixel( aRect ); + + // aLogicRect ist relative to the page, but we need a value relative + // to the parent object + awt::Point aParentLocOnScreen; + uno::Reference< XAccessibleComponent > xParent( getAccessibleParent(), uno::UNO_QUERY ); + if( xParent.is() ) + aParentLocOnScreen = xParent->getLocationOnScreen(); + + // aOffset = aParentLocOnScreen - GetUpperLeftOnScreen() + awt::Point aULOnScreen = GetUpperLeftOnScreen(); + 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()); + // \-- solar + } + } + + return awt::Rectangle(); +} + +awt::Point SAL_CALL AccessibleBase::getLocation() + throw (RuntimeException) +{ + CheckDisposeState(); + awt::Rectangle aBBox( getBounds() ); + return awt::Point( aBBox.X, aBBox.Y ); +} + +awt::Point SAL_CALL AccessibleBase::getLocationOnScreen() + throw (RuntimeException) +{ + CheckDisposeState(); + + if( m_aAccInfo.m_pParent != NULL ) + { + AccessibleBase * pParent = m_aAccInfo.m_pParent; + awt::Point aLocThisRel( getLocation()); + awt::Point aUpperLeft; + + if( pParent != NULL ) + aUpperLeft = pParent->getLocationOnScreen(); + + return awt::Point( aUpperLeft.X + aLocThisRel.X, + aUpperLeft.Y + aLocThisRel.Y ); + } + else + return getLocation(); +} + +awt::Size SAL_CALL AccessibleBase::getSize() + throw (RuntimeException) +{ + CheckDisposeState(); + awt::Rectangle aBBox( getBounds() ); + return awt::Size( aBBox.Width, aBBox.Height ); +} + +void SAL_CALL AccessibleBase::grabFocus() + throw (RuntimeException) +{ + CheckDisposeState(); + + OUString aSelCID; + Reference< view::XSelectionSupplier > xSelSupp( GetInfo().m_xSelectionSupplier ); + if( xSelSupp.is()) + xSelSupp->select( uno::makeAny( GetId())); +} + +sal_Int32 SAL_CALL AccessibleBase::getForeground() + throw (RuntimeException) +{ + return getColor( ACC_BASE_FOREGROUND ); +} + +sal_Int32 SAL_CALL AccessibleBase::getBackground() + throw (RuntimeException) +{ + return getColor( ACC_BASE_BACKGROUND ); +} + +sal_Int32 AccessibleBase::getColor( eColorType eColType ) +{ + sal_Int32 nResult = static_cast< sal_Int32 >( Color( COL_TRANSPARENT ).GetColor()); + if( m_bAlwaysTransparent ) + return nResult; + + ObjectType eType( ObjectIdentifier::getObjectType( m_aAccInfo.m_aCID )); + Reference< beans::XPropertySet > xObjProp; + OUString aObjectCID = m_aAccInfo.m_aCID; + if( eType == OBJECTTYPE_LEGEND_ENTRY ) + { + // for colors get the data series/point properties + OUString aParentParticle( ObjectIdentifier::getFullParentParticle( aObjectCID )); + aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); + } + + xObjProp.set( + ObjectIdentifier::getObjectPropertySet( + aObjectCID, Reference< chart2::XChartDocument >( m_aAccInfo.m_xChartDocument )), uno::UNO_QUERY ); + if( xObjProp.is()) + { + try + { + OUString aPropName; + OUString aStylePropName; + + switch( eType ) + { + case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_DATA_SERIES: + case OBJECTTYPE_DATA_POINT: + if( eColType == ACC_BASE_FOREGROUND ) + { + aPropName = C2U("BorderColor"); + aStylePropName = C2U("BorderTransparency"); + } + else + { + aPropName = C2U("Color"); + aStylePropName = C2U("Transparency"); + } + break; + default: + if( eColType == ACC_BASE_FOREGROUND ) + { + aPropName = C2U("LineColor"); + aStylePropName = C2U("LineTransparence"); + } + else + { + aPropName = C2U("FillColor"); + aStylePropName = C2U("FillTransparence"); + } + break; + } + + bool bTransparent = m_bAlwaysTransparent; + Reference< beans::XPropertySetInfo > xInfo( xObjProp->getPropertySetInfo(), uno::UNO_QUERY ); + if( xInfo.is() && + xInfo->hasPropertyByName( aStylePropName )) + { + if( eColType == ACC_BASE_FOREGROUND ) + { + drawing::LineStyle aLStyle; + if( xObjProp->getPropertyValue( aStylePropName ) >>= aLStyle ) + bTransparent = (aLStyle == drawing::LineStyle_NONE); + } + else + { + drawing::FillStyle aFStyle; + if( xObjProp->getPropertyValue( aStylePropName ) >>= aFStyle ) + bTransparent = (aFStyle == drawing::FillStyle_NONE); + } + } + + if( !bTransparent && + xInfo.is() && + xInfo->hasPropertyByName( aPropName )) + { + xObjProp->getPropertyValue( aPropName ) >>= nResult; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + return nResult; +} + +// ________ AccessibleBase::XServiceInfo ________ +OUString SAL_CALL AccessibleBase::getImplementationName() + throw (RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleBase" )); +} + +sal_Bool SAL_CALL AccessibleBase::supportsService( const OUString& ServiceName ) + throw (RuntimeException) +{ + return SvxServiceInfoHelper::supportsService( ServiceName, getSupportedServiceNames() ); +} + +uno::Sequence< OUString > SAL_CALL AccessibleBase::getSupportedServiceNames() + throw (RuntimeException) +{ + uno::Sequence< ::rtl::OUString > aSeq( 2 ); + ::rtl::OUString* pStr = aSeq.getArray(); + pStr[ 0 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.Accessible" )); + pStr[ 1 ] = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.accessibility.AccessibleContext" )); + + return aSeq; +} + +// ________ AccessibleBase::XEventListener ________ +void SAL_CALL AccessibleBase::disposing( const lang::EventObject& /*Source*/ ) + throw (RuntimeException) +{ +} + +// ________ XAccessibleEventBroadcasters ________ +void SAL_CALL AccessibleBase::addEventListener( const Reference< XAccessibleEventListener >& xListener ) + throw (RuntimeException) +{ + MutexGuard aGuard( GetMutex() ); + + if ( xListener.is() ) + { + if ( !m_nEventNotifierId ) + m_nEventNotifierId = ::comphelper::AccessibleEventNotifier::registerClient(); + + ::comphelper::AccessibleEventNotifier::addEventListener( m_nEventNotifierId, xListener ); + } +} + +void SAL_CALL AccessibleBase::removeEventListener( const Reference< XAccessibleEventListener >& xListener ) + throw (RuntimeException) +{ + MutexGuard aGuard( GetMutex() ); + + if ( xListener.is() ) + { + sal_Int32 nListenerCount = ::comphelper::AccessibleEventNotifier::removeEventListener( m_nEventNotifierId, xListener ); + if ( !nListenerCount ) + { + // no listeners anymore + ::comphelper::AccessibleEventNotifier::revokeClient( m_nEventNotifierId ); + m_nEventNotifierId = 0; + } + } +} + +} // namespace chart diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.cxx b/chart2/source/controller/accessibility/AccessibleChartElement.cxx new file mode 100644 index 000000000000..2e1a4e074ce3 --- /dev/null +++ b/chart2/source/controller/accessibility/AccessibleChartElement.cxx @@ -0,0 +1,335 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleChartElement.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AccessibleChartElement.hxx" +#include "CharacterProperties.hxx" +#include "ObjectIdentifier.hxx" +#include "ObjectNameProvider.hxx" +#include "servicenames.hxx" +#include "macros.hxx" + +#include <com/sun/star/awt/XDevice.hpp> +#include <com/sun/star/chart2/XTitle.hpp> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/lang/XInitialization.hpp> + +// for SolarMutex +#include <vcl/svapp.hxx> +#include <rtl/ustrbuf.hxx> + +// #ifndef _RTL_UUID_H_ +// #include <rtl/uuid.h> +// #endif +// #ifndef _CPPUHELPER_QUERYINTERFACE_HXX_ +// #include <cppuhelper/queryinterface.hxx> +// #endif +// #ifndef _TOOLKIT_HELPER_VCLUNOHELPER_HXX_ +// #include <toolkit/helper/vclunohelper.hxx> +// #endif +// #ifndef _SV_WINDOW_HXX +// #include <vcl/window.hxx> +// #endif + +// #ifndef _SVX_ACCESSILE_TEXT_HELPER_HXX_ +// #include <svx/AccessibleTextHelper.hxx> +// #endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; + +using ::com::sun::star::uno::UNO_QUERY; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::osl::MutexGuard; +using ::osl::ClearableMutexGuard; +using ::osl::ResettableMutexGuard; +using ::com::sun::star::uno::RuntimeException; +using ::com::sun::star::uno::Any; + +namespace chart +{ + +AccessibleChartElement::AccessibleChartElement( + const AccessibleElementInfo & rAccInfo, + bool bMayHaveChildren, + bool bAlwaysTransparent /* default: false */ ) : + impl::AccessibleChartElement_Base( rAccInfo, bMayHaveChildren, bAlwaysTransparent ), + m_bHasText( false ) +{ + AddState( AccessibleStateType::TRANSIENT ); +} + +AccessibleChartElement::~AccessibleChartElement() +{ + OSL_ASSERT( CheckDisposeState( false /* don't throw exceptions */ ) ); +} + +// ________ protected ________ + +bool AccessibleChartElement::ImplUpdateChildren() +{ + bool bResult = false; + Reference< chart2::XTitle > xTitle( + ObjectIdentifier::getObjectPropertySet( + GetInfo().m_aCID, Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )), + uno::UNO_QUERY ); + m_bHasText = xTitle.is(); + + if( m_bHasText ) + { + InitTextEdit(); + bResult = true; + } + else + bResult = AccessibleBase::ImplUpdateChildren(); + + return bResult; +} + +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 ); + } + } + + if( m_xTextHelper.is()) + try + { + Reference< lang::XInitialization > xInit( m_xTextHelper, uno::UNO_QUERY_THROW ); + Sequence< uno::Any > aArgs( 3 ); + aArgs[0] <<= GetInfo().m_aCID; + aArgs[1] <<= Reference< XAccessible >( this ); + aArgs[2] <<= Reference< awt::XWindow >( GetInfo().m_xWindow ); + xInit->initialize( aArgs ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} +// OSL_ASSERT( m_pTextHelper == 0 ); + +// // /-- solar +// ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); +// Window* pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow )); +// if( pWindow ) +// { +// // we need ChartController::m_pDrawViewWrapper here +// SdrView * pView = 0; +// if( pView ) +// { +// SdrObject * pTextObj = m_pDrawViewWrapper->getTextEditObject(); +// if( pTextObj ) +// { +// SvxEditSource * pEditSource = new SvxEditSource( pTextObj, pView, pWindow ); +// m_pTextHelper = new ::accessibility::AccessibleTextHelper( +// ::std::auto_ptr< SvxEditSource >( pEditSource )); +// if( m_pTextHelper ) +// m_pTextHelper->SetEventSource( this ); +// } +// } +// } +// // \-- solar +// } + +// ____________________________________ +// ____________________________________ +// +// Interfaces +// ____________________________________ +// ____________________________________ + +// ________ AccessibleBase::XAccessibleContext ________ +Reference< XAccessible > AccessibleChartElement::ImplGetAccessibleChildById( sal_Int32 i ) const + throw (lang::IndexOutOfBoundsException, RuntimeException) +{ + Reference< XAccessible > xResult; + + if( m_bHasText ) + { + xResult.set( m_xTextHelper->getAccessibleChild( i )); + // /-- solar +// ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); +// if( m_pTextHelper ) +// xResult.set( m_pTextHelper->GetChild( i ) ); + // \-- solar + } + else + xResult.set( AccessibleBase::ImplGetAccessibleChildById( i )); + + return xResult; +} + +sal_Int32 AccessibleChartElement::ImplGetAccessibleChildCount() const + throw (RuntimeException) +{ + if( m_bHasText ) + { + if( m_xTextHelper.is()) + return m_xTextHelper->getAccessibleChildCount(); + return 0; + } + + return AccessibleBase::ImplGetAccessibleChildCount(); +} + +// ________ XServiceInfo ________ +OUString SAL_CALL AccessibleChartElement::getImplementationName() + throw (RuntimeException) +{ + return OUString( RTL_CONSTASCII_USTRINGPARAM( "AccessibleChartElement" )); +} + +// ________ AccessibleChartElement::XAccessibleContext (overloaded) ________ +OUString SAL_CALL AccessibleChartElement::getAccessibleName() + throw (::com::sun::star::uno::RuntimeException) +{ + return ObjectNameProvider::getNameForCID( + GetInfo().m_aCID, GetInfo().m_xChartDocument ); +} + +// ________ AccessibleChartElement::XAccessibleContext (overloaded) ________ +OUString SAL_CALL AccessibleChartElement::getAccessibleDescription() + throw (::com::sun::star::uno::RuntimeException) +{ + return getToolTipText(); +} + +// ________ AccessibleChartElement::XAccessibleExtendedComponent ________ +Reference< awt::XFont > SAL_CALL AccessibleChartElement::getFont() + throw (uno::RuntimeException) +{ + CheckDisposeState(); + + Reference< awt::XFont > xFont; + // using assignment for broken gcc 3.3 + Reference< awt::XDevice > xDevice = Reference< awt::XDevice >( + Reference< awt::XWindow >( GetInfo().m_xWindow ), uno::UNO_QUERY ); + + if( xDevice.is()) + { + Reference< beans::XMultiPropertySet > xObjProp( + ObjectIdentifier::getObjectPropertySet( + GetInfo().m_aCID, 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() + throw (uno::RuntimeException) +{ + return OUString(); +} + +OUString SAL_CALL AccessibleChartElement::getToolTipText() + throw (::com::sun::star::uno::RuntimeException) +{ + CheckDisposeState(); + + return ObjectNameProvider::getHelpText( + GetInfo().m_aCID, Reference< chart2::XChartDocument >( GetInfo().m_xChartDocument )); +} + +// ________ XAccessibleComponent ________ +sal_Bool SAL_CALL AccessibleChartElement::containsPoint( const awt::Point& aPoint ) + throw (uno::RuntimeException) +{ + return AccessibleBase::containsPoint( aPoint ); +} + +Reference< accessibility::XAccessible > SAL_CALL AccessibleChartElement::getAccessibleAtPoint( const awt::Point& aPoint ) + throw (uno::RuntimeException) +{ + return AccessibleBase::getAccessibleAtPoint( aPoint ); +} + +awt::Rectangle SAL_CALL AccessibleChartElement::getBounds() + throw (uno::RuntimeException) +{ + return AccessibleBase::getBounds(); +} + +awt::Point SAL_CALL AccessibleChartElement::getLocation() + throw (uno::RuntimeException) +{ + return AccessibleBase::getLocation(); +} + +awt::Point SAL_CALL AccessibleChartElement::getLocationOnScreen() + throw (uno::RuntimeException) +{ + return AccessibleBase::getLocationOnScreen(); +} + +awt::Size SAL_CALL AccessibleChartElement::getSize() + throw (uno::RuntimeException) +{ + return AccessibleBase::getSize(); +} + +void SAL_CALL AccessibleChartElement::grabFocus() + throw (uno::RuntimeException) +{ + return AccessibleBase::grabFocus(); +} + +sal_Int32 SAL_CALL AccessibleChartElement::getForeground() + throw (uno::RuntimeException) +{ + return AccessibleBase::getForeground(); +} + +sal_Int32 SAL_CALL AccessibleChartElement::getBackground() + throw (uno::RuntimeException) +{ + return AccessibleBase::getBackground(); +} + + +} // namespace chart diff --git a/chart2/source/controller/accessibility/AccessibleChartElement.hxx b/chart2/source/controller/accessibility/AccessibleChartElement.hxx new file mode 100644 index 000000000000..c8052be29556 --- /dev/null +++ b/chart2/source/controller/accessibility/AccessibleChartElement.hxx @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleChartElement.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_ACCESSIBLECHARTELEMENT_HXX_ +#define _CHART2_ACCESSIBLECHARTELEMENT_HXX_ + +#include "AccessibleBase.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#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/document/XEventListener.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/accessibility/XAccessibleExtendedComponent.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <cppuhelper/implbase1.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <unotools/accessiblestatesethelper.hxx> + +#include <vector> +#include <map> +#include <boost/shared_ptr.hpp> + +class SfxItemSet; +class SdrObject; + +namespace chart +{ + +/** Base class for all Chart Accessibility objects except the root node (see AccessibleChartView) + + This class contains a reference to the ChartModel, thus, components can easily access all core functionality. + + Usage Instructions: + + <ul> + <li>define the getAccessibleName() method of XAccessibleContext</li> + <li>set the ChartModel using SetChartModel() for the first node before + creating any children</li> + <li>overload UpdateChildren()</li> + </ul> + */ + +namespace impl +{ +typedef ::cppu::ImplInheritanceHelper1< + AccessibleBase, + ::com::sun::star::accessibility::XAccessibleExtendedComponent + > AccessibleChartElement_Base; +} + +class AccessibleChartElement : + public impl::AccessibleChartElement_Base +{ +public: + AccessibleChartElement( const AccessibleElementInfo & rAccInfo, + bool bMayHaveChildren, + bool bAlwaysTransparent = false ); + virtual ~AccessibleChartElement(); + + // ________ AccessibleBase ________ + virtual bool ImplUpdateChildren(); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + ImplGetAccessibleChildById( sal_Int32 i ) const + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual sal_Int32 ImplGetAccessibleChildCount() const + throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleContext ________ + virtual ::rtl::OUString SAL_CALL getAccessibleName() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleDescription() + throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleExtendedComponent ________ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XFont > SAL_CALL getFont() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getTitledBorderText() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getToolTipText() + throw (::com::sun::star::uno::RuntimeException); + + // the following interface is implemented in AccessibleBase, however it is + // also a (non-virtual) base class of XAccessibleExtendedComponent Thus + // these methods have to be overloaded and forward to AccessibleBase + + // ________ XAccessibleComponent ________ + virtual sal_Bool SAL_CALL containsPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL getLocation() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grabFocus() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeground() throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackground() throw (::com::sun::star::uno::RuntimeException); + + // ________ XServiceInfo ________ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + +private: + bool m_bHasText; + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleContext > + m_xTextHelper; + + void InitTextEdit(); +}; + +} // namespace chart + +#endif diff --git a/chart2/source/controller/accessibility/AccessibleChartView.cxx b/chart2/source/controller/accessibility/AccessibleChartView.cxx new file mode 100644 index 000000000000..8e9c53b78639 --- /dev/null +++ b/chart2/source/controller/accessibility/AccessibleChartView.cxx @@ -0,0 +1,421 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleChartView.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AccessibleChartView.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "servicenames.hxx" +#include "macros.hxx" +#include "ObjectHierarchy.hxx" +#include "ObjectIdentifier.hxx" +#include "ResId.hxx" +#include "Strings.hrc" + +#include <com/sun/star/accessibility/AccessibleEventId.hpp> +#include <com/sun/star/accessibility/AccessibleStateType.hpp> +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +#include <tools/string.hxx> +#include <vcl/window.hxx> +#include <toolkit/helper/vclunohelper.hxx> +// for SolarMutex +#include <vcl/svapp.hxx> + +// header for typedef MutexGuard +#include <osl/mutex.hxx> + +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 ::rtl::OUString; +using osl::MutexGuard; + +//............................................................................. +namespace chart +{ +//............................................................................. + +AccessibleChartView::AccessibleChartView( + const Reference<uno::XComponentContext> & xContext ) : + impl::AccessibleChartView_Base( + AccessibleElementInfo(), // empty for now + true, // has children + true // always transparent + ), + m_xContext( xContext ) +{ + AddState( AccessibleStateType::OPAQUE ); +} + +AccessibleChartView::~AccessibleChartView() +{ +} + + +awt::Rectangle AccessibleChartView::GetWindowPosSize() const +{ + Reference< awt::XWindow > xWindow( GetInfo().m_xWindow ); + if( ! xWindow.is()) + return awt::Rectangle(); + + // this should do, but it doesn't => HACK +// return xWindow->getPosSize(); + + awt::Rectangle aBBox( xWindow->getPosSize() ); + + Window* pWindow( VCLUnoHelper::GetWindow( GetInfo().m_xWindow )); + if( pWindow ) + { + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + Point aVCLPoint( pWindow->OutputToAbsoluteScreenPixel( Point( 0, 0 ) )); + aBBox.X = aVCLPoint.getX(); + aBBox.Y = aVCLPoint.getY(); + // \-- solar + } + + return aBBox; +} + +awt::Point AccessibleChartView::GetUpperLeftOnScreen() const +{ + awt::Point aParentPosition; + + awt::Rectangle aBBox( GetWindowPosSize() ); + aParentPosition.X = aBBox.X; + aParentPosition.Y = aBBox.Y; + + return aParentPosition; +} + +// ________ XAccessibleContext ________ +OUString SAL_CALL AccessibleChartView::getAccessibleName() + throw (uno::RuntimeException) +{ + return OUString( String( SchResId( STR_OBJECT_DIAGRAM ))); +} + +OUString SAL_CALL AccessibleChartView::getAccessibleDescription() + throw (uno::RuntimeException) +{ + return getAccessibleName(); +} + +Reference< XAccessible > SAL_CALL AccessibleChartView::getAccessibleParent() + throw (uno::RuntimeException) +{ + return Reference< XAccessible >( m_xParent ); +} + +sal_Int32 SAL_CALL AccessibleChartView::getAccessibleIndexInParent() + throw (uno::RuntimeException) +{ + // the document is always the only child of the window + return 0; +} + +sal_Int16 SAL_CALL AccessibleChartView::getAccessibleRole() + throw (uno::RuntimeException) +{ + return AccessibleRole::DOCUMENT; +} + +// ________ XAccessibleComponent ________ +awt::Rectangle SAL_CALL AccessibleChartView::getBounds() + throw (uno::RuntimeException) +{ + awt::Rectangle aResult( GetWindowPosSize()); + Reference< XAccessible > xParent( m_xParent ); + if( xParent.is()) + { + Reference< XAccessibleComponent > xContext( xParent->getAccessibleContext(), uno::UNO_QUERY ); + if( xContext.is()) + { + awt::Point aParentPosition = xContext->getLocationOnScreen(); + aResult.X -= aParentPosition.X; + aResult.Y -= aParentPosition.Y; + } + } + return aResult; +} + +awt::Point SAL_CALL AccessibleChartView::getLocationOnScreen() + throw (uno::RuntimeException) +{ + 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; +} + +//----------------------------------------------------------------- +// lang::XServiceInfo +//----------------------------------------------------------------- + +APPHELPER_XSERVICEINFO_IMPL( AccessibleChartView, CHART2_ACCESSIBLE_SERVICE_IMPLEMENTATION_NAME ) + +uno::Sequence< rtl::OUString > AccessibleChartView::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 2 ); + aSNS.getArray()[ 0 ] = C2U("com.sun.star.accessibility.Accessible"); + aSNS.getArray()[ 1 ] = CHART2_ACCESSIBLE_SERVICE_NAME; + return aSNS; +} + +//----------------------------------------------------------------- +// lang::XInitialization +//----------------------------------------------------------------- + +void SAL_CALL AccessibleChartView::initialize( const Sequence< Any >& rArguments ) + throw (uno::Exception, uno::RuntimeException) +{ + //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; + bool bNewInvalid = false; + + Reference< view::XSelectionSupplier > xSelectionSupplier; + Reference< frame::XModel > xChartModel; + Reference< uno::XInterface > xChartView; + Reference< XAccessible > xParent; + Reference< awt::XWindow > xWindow; + { + MutexGuard aGuard( GetMutex()); + xSelectionSupplier.set( m_xSelectionSupplier ); + xChartModel.set( m_xChartModel ); + xChartView.set( m_xChartView ); + xParent.set( m_xParent ); + xWindow.set( m_xWindow ); + } + + if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + { + bOldInvalid = true; + } + + if( rArguments.getLength() > 1 ) + { + Reference< frame::XModel > xNewChartModel; + rArguments[1] >>= xNewChartModel; + if( xNewChartModel != xChartModel ) + { + xChartModel = xNewChartModel; + bChanged = true; + } + } + else if( xChartModel.is() ) + { + bChanged = true; + xChartModel = 0; + } + + if( rArguments.getLength() > 2 ) + { + Reference< uno::XInterface > xNewChartView; + rArguments[2] >>= xNewChartView; + if( xNewChartView != xChartView ) + { + xChartView = xNewChartView; + bChanged = true; + } + } + else if( xChartView.is() ) + { + bChanged = true; + xChartView = 0; + } + + if( rArguments.getLength() > 3 ) + { + Reference< XAccessible > xNewParent; + rArguments[3] >>= xNewParent; + if( xNewParent != xParent ) + { + xParent = xNewParent; + bChanged = true; + } + } + + if( rArguments.getLength() > 4 ) + { + Reference< awt::XWindow > xNewWindow; + rArguments[4] >>= xNewWindow; + if( xNewWindow != xWindow ) + { + xWindow.set( xNewWindow ); + bChanged = true; + } + } + + if( rArguments.getLength() > 0 && 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; + } + } + else if( xSelectionSupplier.is() ) + { + bChanged = true; + xSelectionSupplier->removeSelectionChangeListener(this); + xSelectionSupplier = 0; + } + + if( !xSelectionSupplier.is() || !xChartModel.is() || !xChartView.is() ) + { + if(xSelectionSupplier.is()) + xSelectionSupplier->removeSelectionChangeListener(this); + xSelectionSupplier = 0; + xChartModel.clear(); + xChartView.clear(); + xParent.clear(); + xWindow.clear(); + + bNewInvalid = true; + } + + { + MutexGuard aGuard( GetMutex()); + 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); + } + + if( bOldInvalid && bNewInvalid ) + bChanged = false; + + if( bChanged ) + { + { + //before notification we prepare for creation of new context + //the old context will be deleted after notification than + MutexGuard aGuard( GetMutex()); + Reference< chart2::XChartDocument > xChartDoc( xChartModel, uno::UNO_QUERY ); + if( xChartDoc.is()) + m_spObjectHierarchy.reset( new ObjectHierarchy( xChartDoc, getExplicitValueProvider() )); + else + m_spObjectHierarchy.reset(); + } + + { + AccessibleElementInfo aAccInfo; + aAccInfo.m_aCID = C2U("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_xView = m_xChartView; + aAccInfo.m_xWindow = m_xWindow; + aAccInfo.m_pParent = 0; + aAccInfo.m_spObjectHierarchy = m_spObjectHierarchy; + // broadcasts an INVALIDATE_ALL_CHILDREN event globally + SetInfo( aAccInfo ); + } + } +} + +ExplicitValueProvider* AccessibleChartView::getExplicitValueProvider() +{ + return ExplicitValueProvider::getExplicitValueProvider(m_xChartView); +} + +//------------------------------------------------------------------------- +// view::XSelectionChangeListener +//------------------------------------------------------------------------- + +void SAL_CALL AccessibleChartView::selectionChanged( const lang::EventObject& /*rEvent*/ ) + throw (uno::RuntimeException) +{ + Reference< view::XSelectionSupplier > xSelectionSupplier; + { + MutexGuard aGuard( GetMutex()); + xSelectionSupplier = Reference< view::XSelectionSupplier >(m_xSelectionSupplier); + } + + if( xSelectionSupplier.is() ) + { + rtl::OUString aSelectedObjectCID; + Any aSelection = xSelectionSupplier->getSelection(); + if(aSelection>>=aSelectedObjectCID) + { + if( m_aCurrentSelectionCID.getLength()) + NotifyEvent( LOST_SELECTION, m_aCurrentSelectionCID ); + if( aSelectedObjectCID.getLength()) + NotifyEvent( GOT_SELECTION, aSelectedObjectCID ); + m_aCurrentSelectionCID = aSelectedObjectCID; + } + } +} + +//------------------------------------------------------------------------- +// lang::XComponent::dispose() +//------------------------------------------------------------------------- +void SAL_CALL AccessibleChartView::disposing() +{ + AccessibleBase::disposing(); +} + +//------------------------------------------------------------------------- +// XEventListener +//------------------------------------------------------------------------- +void SAL_CALL AccessibleChartView::disposing( const lang::EventObject& /*Source*/ ) + throw (uno::RuntimeException) +{ +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/accessibility/AccessibleTextHelper.cxx b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx new file mode 100644 index 000000000000..f6af68da51d0 --- /dev/null +++ b/chart2/source/controller/accessibility/AccessibleTextHelper.cxx @@ -0,0 +1,206 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleTextHelper.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AccessibleTextHelper.hxx" +#include "DrawViewWrapper.hxx" + +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +#include <svx/AccessibleTextHelper.hxx> +#include <svx/unoshtxt.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/window.hxx> + +#include <com/sun/star/accessibility/AccessibleRole.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::accessibility; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +AccessibleTextHelper::AccessibleTextHelper( + DrawViewWrapper * pDrawViewWrapper ) : + impl::AccessibleTextHelper_Base( m_aMutex ), + m_pTextHelper( 0 ), + m_pDrawViewWrapper( pDrawViewWrapper ) +{} + +AccessibleTextHelper::~AccessibleTextHelper() +{ + if( m_pTextHelper ) + delete m_pTextHelper; +} + +// ____ XInitialization ____ +void SAL_CALL AccessibleTextHelper::initialize( const Sequence< uno::Any >& aArguments ) + throw (uno::Exception, + uno::RuntimeException) +{ + 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.getLength() > 0, "Empty CID" ); + OSL_ENSURE( xEventSource.is(), "Empty Event Source" ); + OSL_ENSURE( xWindow.is(), "Empty Window" ); + if( !xEventSource.is() || aCID.getLength() == 0 ) + return; + + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + + if( m_pTextHelper ) + delete m_pTextHelper; + + Window* pWindow( VCLUnoHelper::GetWindow( xWindow )); + if( pWindow ) + { + SdrView * pView = m_pDrawViewWrapper; + if( pView ) + { + SdrObject * pTextObj = m_pDrawViewWrapper->getNamedSdrObject( aCID ); + if( pTextObj ) + { + SvxEditSource * pEditSource = new SvxTextEditSource( *pTextObj, 0, *pView, *pWindow ); + m_pTextHelper = new ::accessibility::AccessibleTextHelper( + ::std::auto_ptr< SvxEditSource >( pEditSource )); + if( m_pTextHelper ) + m_pTextHelper->SetEventSource( xEventSource ); + } + } + } + + OSL_ENSURE( m_pTextHelper, "Couldn't create text helper" ); + // \-- solar +} + +// ____ XAccessibleContext ____ +::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleChildCount() + throw (uno::RuntimeException) +{ + if( m_pTextHelper ) + { + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + return m_pTextHelper->GetChildCount(); + // \-- solar + } + return 0; +} + +Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleChild( ::sal_Int32 i ) + throw (lang::IndexOutOfBoundsException, + uno::RuntimeException) +{ + if( m_pTextHelper ) + { + // /-- solar + ::vos::OGuard aSolarGuard( Application::GetSolarMutex() ); + return m_pTextHelper->GetChild( i ); + // \-- solar + } + return Reference< XAccessible >(); +} + +Reference< XAccessible > SAL_CALL AccessibleTextHelper::getAccessibleParent() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return Reference< XAccessible >(); +} + +::sal_Int32 SAL_CALL AccessibleTextHelper::getAccessibleIndexInParent() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return -1; +} + +::sal_Int16 SAL_CALL AccessibleTextHelper::getAccessibleRole() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return AccessibleRole::UNKNOWN; +} + +OUString SAL_CALL AccessibleTextHelper::getAccessibleDescription() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return OUString(); +} + +OUString SAL_CALL AccessibleTextHelper::getAccessibleName() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return OUString(); +} + +Reference< XAccessibleRelationSet > SAL_CALL AccessibleTextHelper::getAccessibleRelationSet() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return Reference< XAccessibleRelationSet >(); +} + +Reference< XAccessibleStateSet > SAL_CALL AccessibleTextHelper::getAccessibleStateSet() + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return Reference< XAccessibleStateSet >(); +} + +lang::Locale SAL_CALL AccessibleTextHelper::getLocale() + throw (IllegalAccessibleComponentStateException, + uno::RuntimeException) +{ + OSL_ENSURE( false, "Not implemented in this helper" ); + return lang::Locale(); +} + + + +} // namespace chart diff --git a/chart2/source/controller/accessibility/ChartElementFactory.cxx b/chart2/source/controller/accessibility/ChartElementFactory.cxx new file mode 100644 index 000000000000..0e0786f1031e --- /dev/null +++ b/chart2/source/controller/accessibility/ChartElementFactory.cxx @@ -0,0 +1,147 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartElementFactory.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartElementFactory.hxx" +#include "ObjectIdentifier.hxx" + +#include "AccessibleChartElement.hxx" + +namespace chart +{ + +AccessibleBase* ChartElementFactory::CreateChartElement( const AccessibleElementInfo& rAccInfo ) +{ + ObjectType eType( + ObjectIdentifier::getObjectType( rAccInfo.m_aCID )); + + switch( eType ) + { + case OBJECTTYPE_DATA_POINT: + case OBJECTTYPE_LEGEND_ENTRY: + return new AccessibleChartElement( rAccInfo, false, false ); + case OBJECTTYPE_PAGE: + case OBJECTTYPE_TITLE: + case OBJECTTYPE_LEGEND: + case OBJECTTYPE_DIAGRAM: + case OBJECTTYPE_DIAGRAM_WALL: + case OBJECTTYPE_DIAGRAM_FLOOR: + case OBJECTTYPE_AXIS: + case OBJECTTYPE_AXIS_UNITLABEL: + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: + case OBJECTTYPE_DATA_SERIES: + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + case OBJECTTYPE_DATA_CURVE: // e.g. a statistical method printed as line + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_STOCK_RANGE: + case OBJECTTYPE_DATA_STOCK_LOSS: + case OBJECTTYPE_DATA_STOCK_GAIN: + case OBJECTTYPE_DATA_CURVE_EQUATION: + return new AccessibleChartElement( rAccInfo, true, false ); + case OBJECTTYPE_UNKNOWN: + break; + } + + return 0; + + /* + sal_uInt16 nObjId = rId.GetObjectId(); + switch( nObjId ) + { + case CHOBJID_LEGEND: + return new AccLegend( pParent ); + case AccLegendEntry::ObjectId: + return new AccLegendEntry( pParent, rId.GetIndex1() ); + + case CHOBJID_TITLE_MAIN: + return new AccTitle( pParent, Title::MAIN ); + case CHOBJID_TITLE_SUB: + return new AccTitle( pParent, Title::SUB ); + case CHOBJID_DIAGRAM_TITLE_X_AXIS: + return new AccTitle( pParent, Title::X_AXIS ); + case CHOBJID_DIAGRAM_TITLE_Y_AXIS: + return new AccTitle( pParent, Title::Y_AXIS ); + case CHOBJID_DIAGRAM_TITLE_Z_AXIS: + return new AccTitle( pParent, Title::Z_AXIS ); + + case CHOBJID_DIAGRAM: + return new AccDiagram( pParent ); + + // series + case CHOBJID_DIAGRAM_ROWGROUP: + return new AccDataSeries( pParent, rId.GetIndex1() ); + + // data points + case CHOBJID_DIAGRAM_DATA: + return new AccDataPoint( pParent, rId.GetIndex1(), rId.GetIndex2() ); + + case Axis::X_AXIS: + case Axis::Y_AXIS: + case Axis::Z_AXIS: + case Axis::SEC_X_AXIS: + case Axis::SEC_Y_AXIS: + return new AccAxis( pParent, static_cast< Axis::AxisType >( nObjId ) ); + + case Grid::X_MAJOR: + case Grid::Y_MAJOR: + case Grid::Z_MAJOR: + case Grid::X_MINOR: + case Grid::Y_MINOR: + case Grid::Z_MINOR: + return new AccGrid( pParent, static_cast< AccGrid::GridType >( nObjId ) ); + + case AccStatisticsObject::MEAN_VAL_LINE: + case AccStatisticsObject::ERROR_BARS: + case AccStatisticsObject::REGRESSION: + return new AccStatisticsObject( pParent, + static_cast< AccStatisticsObject::StatisticsObjectType >( nObjId ), + rId.GetIndex1() ); + + case CHOBJID_DIAGRAM_WALL: + return new AccWall( pParent ); + + case CHOBJID_DIAGRAM_FLOOR: + return new AccFloor( pParent ); + + case CHOBJID_DIAGRAM_AREA: + return new AccArea( pParent ); + } + */ +} + +} // namespace chart diff --git a/chart2/source/controller/accessibility/ChartElementFactory.hxx b/chart2/source/controller/accessibility/ChartElementFactory.hxx new file mode 100644 index 000000000000..d86e8cf297c5 --- /dev/null +++ b/chart2/source/controller/accessibility/ChartElementFactory.hxx @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartElementFactory.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_ACC_ELEMENTFACTORY_HXX_ +#define _CHART2_ACC_ELEMENTFACTORY_HXX_ + +#include "AccessibleBase.hxx" + +namespace chart +{ + +class AccessibleBase; + +class ChartElementFactory +{ +public: + /** @return a newly created object (using the new operator) that corresponds + to the given unique id + */ + static AccessibleBase* CreateChartElement( const AccessibleElementInfo& rAccInfo ); +}; + +} // namespace chart + +#endif diff --git a/chart2/source/controller/accessibility/makefile.mk b/chart2/source/controller/accessibility/makefile.mk new file mode 100644 index 000000000000..0d17ab8140e6 --- /dev/null +++ b/chart2/source/controller/accessibility/makefile.mk @@ -0,0 +1,56 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcaccessibility + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES= $(SLO)$/AccessibleChartView.obj \ + $(SLO)$/ChartElementFactory.obj \ + $(SLO)$/AccessibleBase.obj \ + $(SLO)$/AccessibleChartElement.obj \ + $(SLO)$/AccessibleTextHelper.obj + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk + diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx new file mode 100644 index 000000000000..de6a2ed33838 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.cxx @@ -0,0 +1,210 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AreaWrapper.cxx,v $ + * $Revision: 1.5.16.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "AreaWrapper.hxx" +#include "macros.hxx" +#include "ContainerHelper.hxx" +#include "Chart2ModelContact.hxx" +#include "WrappedDirectStateProperty.hxx" +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/drawing/FillStyle.hpp> + +#include "LineProperties.hxx" +#include "FillProperties.hxx" +#include "UserDefinedProperties.hxx" + +#include <algorithm> + +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; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Area" )); + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} +} // anonymous namespace + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +AreaWrapper::AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ) +{ +} + +AreaWrapper::~AreaWrapper() +{} + +// ____ XShape ____ +awt::Point SAL_CALL AreaWrapper::getPosition() + throw (uno::RuntimeException) +{ + return awt::Point(0,0); +} + +void SAL_CALL AreaWrapper::setPosition( const awt::Point& /*aPosition*/ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "trying to set position of chart area" ); +} + +awt::Size SAL_CALL AreaWrapper::getSize() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetPageSize(); +} + +void SAL_CALL AreaWrapper::setSize( const awt::Size& /*aSize*/ ) + throw (beans::PropertyVetoException, + uno::RuntimeException) +{ + OSL_ENSURE( false, "trying to set size of chart area" ); +} + +// ____ XShapeDescriptor (base of XShape) ____ +::rtl::OUString SAL_CALL AreaWrapper::getShapeType() + throw (uno::RuntimeException) +{ + return C2U( "com.sun.star.chart.ChartArea" ); +} + +// ____ XComponent ____ +void SAL_CALL AreaWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + clearWrappedPropertySet(); + // \-- +} + +void SAL_CALL AreaWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL AreaWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +// WrappedPropertySet +Reference< beans::XPropertySet > AreaWrapper::getInnerPropertySet() +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( xChartDoc.is() ) + return xChartDoc->getPageBackground(); + OSL_ENSURE(false,"AreaWrapper::getInnerPropertySet() is NULL"); + return 0; +} + +const Sequence< beans::Property >& AreaWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > AreaWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("LineStyle"), C2U("LineStyle") ) ); + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< ::rtl::OUString > AreaWrapper::getSupportedServiceNames_Static() +{ + Sequence< ::rtl::OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 1 ] = C2U( "com.sun.star.beans.PropertySet" ); + aServices[ 2 ] = C2U( "com.sun.star.drawing.FillProperties" ); + aServices[ 3 ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( AreaWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx new file mode 100644 index 000000000000..58ddba960cfe --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/AreaWrapper.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AreaWrapper.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_AREAWRAPPER_HXX +#define CHART_AREAWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase3.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#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/chart2/XChartDocument.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class AreaWrapper : public ::cppu::ImplInheritanceHelper3< + WrappedPropertySet + , com::sun::star::drawing::XShape + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + > +{ +public: + AreaWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~AreaWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XShape ____ + virtual ::com::sun::star::awt::Point SAL_CALL getPosition() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShapeDescriptor (base of XShape) ____ + virtual ::rtl::OUString SAL_CALL getShapeType() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_AREAWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx new file mode 100644 index 000000000000..7fd921e761dc --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.cxx @@ -0,0 +1,599 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AxisWrapper.cxx,v $ + * $Revision: 1.11.8.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "AxisWrapper.hxx" +#include "AxisHelper.hxx" +#include "Chart2ModelContact.hxx" +#include "ContainerHelper.hxx" +#include "macros.hxx" +#include "WrappedDirectStateProperty.hxx" +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart/ChartAxisArrangeOrderType.hpp> +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> + +#include "CharacterProperties.hxx" +#include "LineProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedCharacterHeightProperty.hxx" +#include "WrappedTextRotationProperty.hxx" +#include "WrappedGapwidthProperty.hxx" +#include "WrappedScaleProperty.hxx" +#include "WrappedDefaultProperty.hxx" +#include "WrappedNumberFormatProperty.hxx" +#include "WrappedScaleTextProperties.hxx" + +#include <algorithm> +#include <rtl/ustrbuf.hxx> +#include <rtl/math.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::chart::ContainerHelper; + +using ::com::sun::star::beans::Property; +using ::osl::MutexGuard; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Axis" )); + +enum +{ + PROP_AXIS_MAX, + PROP_AXIS_MIN, + PROP_AXIS_STEPMAIN, + PROP_AXIS_STEPHELP, //deprecated property use 'StepHelpCount' instead + PROP_AXIS_STEPHELP_COUNT, + PROP_AXIS_AUTO_MAX, + PROP_AXIS_AUTO_MIN, + PROP_AXIS_AUTO_STEPMAIN, + PROP_AXIS_AUTO_STEPHELP, + PROP_AXIS_LOGARITHMIC, + PROP_AXIS_REVERSEDIRECTION, + PROP_AXIS_VISIBLE, + PROP_AXIS_CROSSOVER_POSITION, + PROP_AXIS_CROSSOVER_VALUE, + PROP_AXIS_ORIGIN, + PROP_AXIS_AUTO_ORIGIN, + PROP_AXIS_MARKS, + PROP_AXIS_HELPMARKS, + PROP_AXIS_MARK_POSITION, + PROP_AXIS_DISPLAY_LABELS, + PROP_AXIS_NUMBERFORMAT, + PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, + PROP_AXIS_LABEL_POSITION, + PROP_AXIS_TEXT_ROTATION, + PROP_AXIS_ARRANGE_ORDER, + PROP_AXIS_TEXTBREAK, + PROP_AXIS_CAN_OVERLAP, + PROP_AXIS_STACKEDTEXT, + PROP_AXIS_OVERLAP, + PROP_AXIS_GAP_WIDTH +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + //Properties for scaling: + rOutProperties.push_back( + Property( C2U( "Max" ), + PROP_AXIS_MAX, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "Min" ), + PROP_AXIS_MIN, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "StepMain" ), + PROP_AXIS_STEPMAIN, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "StepHelpCount" ), + PROP_AXIS_STEPHELP_COUNT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + //deprecated property use 'StepHelpCount' instead + rOutProperties.push_back( + Property( C2U( "StepHelp" ), + PROP_AXIS_STEPHELP, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "AutoMax" ), + PROP_AXIS_AUTO_MAX, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "AutoMin" ), + PROP_AXIS_AUTO_MIN, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "AutoStepMain" ), + PROP_AXIS_AUTO_STEPMAIN, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "AutoStepHelp" ), + PROP_AXIS_AUTO_STEPHELP, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "Logarithmic" ), + PROP_AXIS_LOGARITHMIC, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "ReverseDirection" ), + PROP_AXIS_REVERSEDIRECTION, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //todo: this property is missing in the API + rOutProperties.push_back( + Property( C2U( "Visible" ), + PROP_AXIS_VISIBLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "CrossoverPosition" ), + PROP_AXIS_CROSSOVER_POSITION, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisPosition * >(0)), + beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "CrossoverValue" ), + PROP_AXIS_CROSSOVER_VALUE, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::MAYBEVOID )); + + + rOutProperties.push_back( + Property( C2U( "Origin" ), + PROP_AXIS_ORIGIN, + ::getCppuType( reinterpret_cast< const double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "AutoOrigin" ), + PROP_AXIS_AUTO_ORIGIN, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //Properties for interval marks: + rOutProperties.push_back( + Property( C2U( "Marks" ), + PROP_AXIS_MARKS, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "HelpMarks" ), + PROP_AXIS_HELPMARKS, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "MarkPosition" ), + PROP_AXIS_MARK_POSITION, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisMarkPosition * >(0)), + beans::PropertyAttribute::MAYBEDEFAULT )); + + + //Properties for labels: + rOutProperties.push_back( + Property( C2U( "DisplayLabels" ), + PROP_AXIS_DISPLAY_LABELS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "NumberFormat" ), + PROP_AXIS_NUMBERFORMAT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "LinkNumberFormatToSource" ), + PROP_AXIS_LINK_NUMBERFORMAT_TO_SOURCE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "LabelPosition" ), + PROP_AXIS_LABEL_POSITION, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisLabelPosition * >(0)), + beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TextRotation" ), + PROP_AXIS_TEXT_ROTATION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "ArrangeOrder" ), + PROP_AXIS_ARRANGE_ORDER, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartAxisArrangeOrderType * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TextBreak" ), + PROP_AXIS_TEXTBREAK, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "TextCanOverlap" ), + PROP_AXIS_CAN_OVERLAP, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "StackedText" ), + PROP_AXIS_STACKEDTEXT, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // Properties related to bar charts: + rOutProperties.push_back( + Property( C2U( "Overlap" ), + PROP_AXIS_OVERLAP, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "GapWidth" ), + PROP_AXIS_GAP_WIDTH, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +AxisWrapper::AxisWrapper( + tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ), + m_eType( eType ) +{ +} + +AxisWrapper::~AxisWrapper() +{ +} + +// ____ XShape ____ +awt::Point SAL_CALL AxisWrapper::getPosition() + throw (uno::RuntimeException) +{ + awt::Point aResult( m_spChart2ModelContact->GetAxisPosition( this->getAxis() ) ); + return aResult; +} + +void SAL_CALL AxisWrapper::setPosition( const awt::Point& /*aPosition*/ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE( false, "trying to set position of Axis" ); +} + +awt::Size SAL_CALL AxisWrapper::getSize() + throw (uno::RuntimeException) +{ + awt::Size aSize( m_spChart2ModelContact->GetAxisSize( this->getAxis() ) ); + return aSize; +} + +void SAL_CALL AxisWrapper::setSize( const awt::Size& /*aSize*/ ) + throw (beans::PropertyVetoException, + uno::RuntimeException) +{ + OSL_ENSURE( false, "trying to set size of Axis" ); +} + +// ____ XShapeDescriptor (base of XShape) ____ +OUString SAL_CALL AxisWrapper::getShapeType() + throw (uno::RuntimeException) +{ + return C2U( "com.sun.star.chart.ChartAxis" ); +} + +// ____ XNumberFormatsSupplier ____ +uno::Reference< beans::XPropertySet > SAL_CALL AxisWrapper::getNumberFormatSettings() + throw (uno::RuntimeException) +{ + Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY ); + if( xNumSuppl.is() ) + return xNumSuppl->getNumberFormatSettings(); + + return uno::Reference< beans::XPropertySet >(); +} + +uno::Reference< util::XNumberFormats > SAL_CALL AxisWrapper::getNumberFormats() + throw (uno::RuntimeException) +{ + Reference< util::XNumberFormatsSupplier > xNumSuppl( m_spChart2ModelContact->getChartModel(), uno::UNO_QUERY ); + if( xNumSuppl.is() ) + return xNumSuppl->getNumberFormats(); + + return uno::Reference< util::XNumberFormats >(); +} + +// static +void AxisWrapper::getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis ) +{ + switch( eType ) + { + case X_AXIS: + rnDimensionIndex = 0; rbMainAxis = sal_True; break; + case Y_AXIS: + rnDimensionIndex = 1; rbMainAxis = sal_True; break; + case Z_AXIS: + rnDimensionIndex = 2; rbMainAxis = sal_True; break; + case SECOND_X_AXIS: + rnDimensionIndex = 0; rbMainAxis = sal_False; break; + case SECOND_Y_AXIS: + rnDimensionIndex = 1; rbMainAxis = sal_False; break; + } +} + +// ____ XComponent ____ +void SAL_CALL AxisWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + clearWrappedPropertySet(); +} + +void SAL_CALL AxisWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL AxisWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +//ReferenceSizePropertyProvider +void AxisWrapper::updateReferenceSize() +{ + Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY ); + if( xProp.is() ) + { + if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) + xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( + m_spChart2ModelContact->GetPageSize() )); + } +} +Any AxisWrapper::getReferenceSize() +{ + Any aRet; + Reference< beans::XPropertySet > xProp( this->getAxis(), uno::UNO_QUERY ); + if( xProp.is() ) + aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); + return aRet; +} +awt::Size AxisWrapper::getCurrentSizeForReference() +{ + return m_spChart2ModelContact->GetPageSize(); +} + +// ================================================================================ + +Reference< chart2::XAxis > AxisWrapper::getAxis() +{ + Reference< chart2::XAxis > xAxis; + try + { + sal_Int32 nDimensionIndex = 0; + sal_Bool bMainAxis = sal_True; + AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); + + Reference< XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + 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( C2U( "Show" ), uno::makeAny( sal_False ) ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return xAxis; +} + +// WrappedPropertySet +Reference< beans::XPropertySet > AxisWrapper::getInnerPropertySet() +{ + return Reference< beans::XPropertySet >( this->getAxis(), uno::UNO_QUERY ); +} + +const Sequence< beans::Property >& AxisWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > AxisWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + aWrappedProperties.push_back( new WrappedTextRotationProperty() ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "Marks" ), C2U( "MajorTickmarks" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "HelpMarks" ), C2U( "MinorTickmarks" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "TextCanOverlap" ), C2U( "TextOverlap" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "ArrangeOrder" ), C2U( "ArrangeOrder" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "Visible" ), C2U( "Show" ) ) ); + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "DisplayLabels" ), C2U( "DisplayLabels" ) ) ); + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "TextBreak" ), C2U( "TextBreak" ) ) ); + WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact ); + aWrappedProperties.push_back( pWrappedNumberFormatProperty ); + aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) ) ); + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U( "CrossoverPosition" ), C2U( "CrossoverPosition" ) ) ); + { + WrappedGapwidthProperty* pWrappedGapwidthProperty( new WrappedGapwidthProperty( m_spChart2ModelContact ) ); + WrappedBarOverlapProperty* pWrappedBarOverlapProperty( new WrappedBarOverlapProperty( m_spChart2ModelContact ) ); + sal_Int32 nDimensionIndex = 0; + sal_Bool bMainAxis = sal_True; + sal_Int32 nAxisIndex = 0; + AxisWrapper::getDimensionAndMainAxisBool( m_eType, nDimensionIndex, bMainAxis ); + if( !bMainAxis ) + nAxisIndex = 1; + pWrappedGapwidthProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex ); + pWrappedBarOverlapProperty->setDimensionAndAxisIndex( nDimensionIndex, nAxisIndex ); + aWrappedProperties.push_back( pWrappedGapwidthProperty ); + aWrappedProperties.push_back( pWrappedBarOverlapProperty ); + } + + WrappedScaleProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + + WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); + WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< OUString > AxisWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 3 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartAxis" ); + aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 2 ] = C2U( "com.sun.star.style.CharacterProperties" ); +// aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); +// aServices[ 4 ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( AxisWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx new file mode 100644 index 000000000000..b7708dcf2ac2 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/AxisWrapper.hxx @@ -0,0 +1,143 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AxisWrapper.hxx,v $ + * $Revision: 1.6.8.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_AXISWRAPPER_HXX +#define CHART_AXISWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ReferenceSizePropertyProvider.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase4.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/frame/XModel.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/uno/XComponentContext.hpp> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class AxisWrapper : public ::cppu::ImplInheritanceHelper4< + WrappedPropertySet + , com::sun::star::drawing::XShape + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + , com::sun::star::util::XNumberFormatsSupplier + > + , public ReferenceSizePropertyProvider +{ +public: + enum tAxisType + { + X_AXIS, + Y_AXIS, + Z_AXIS, + SECOND_X_AXIS, + SECOND_Y_AXIS + }; + + AxisWrapper( tAxisType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~AxisWrapper(); + + static void getDimensionAndMainAxisBool( tAxisType eType, sal_Int32& rnDimensionIndex, sal_Bool& rbMainAxis ); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + //ReferenceSizePropertyProvider + virtual void updateReferenceSize(); + virtual ::com::sun::star::uno::Any getReferenceSize(); + virtual ::com::sun::star::awt::Size getCurrentSizeForReference(); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XShape ____ + virtual ::com::sun::star::awt::Point SAL_CALL getPosition() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShapeDescriptor (base of XShape) ____ + virtual ::rtl::OUString SAL_CALL getShapeType() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XNumberFormatsSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getNumberFormatSettings() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::util::XNumberFormats > SAL_CALL getNumberFormats() + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: //methods + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis > getAxis(); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + tAxisType m_eType; + ::com::sun::star::uno::Any m_aTemporaryHelpStepValue; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_AXISWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx new file mode 100644 index 000000000000..3d930f72f0af --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.cxx @@ -0,0 +1,303 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Chart2ModelContact.cxx,v $ + * $Revision: 1.4.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "Chart2ModelContact.hxx" +#include "ChartModelHelper.hxx" +#include "LegendHelper.hxx" +#include "CommonConverters.hxx" +#include "macros.hxx" +#include "servicenames.hxx" +#include "ObjectIdentifier.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "AxisHelper.hxx" + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ +namespace wrapper +{ + +namespace +{ + +rtl::OUString lcl_getCIDForDiagram( const Reference< frame::XModel >& xChartModel ) +{ + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xChartModel ); +} + +} //anonymous namespace + +Chart2ModelContact::Chart2ModelContact( + const Reference< uno::XComponentContext > & xContext ) : + m_xContext( xContext ), + m_xChartModel( 0 ), + m_xChartView(0) +{ +} + +Chart2ModelContact::~Chart2ModelContact() +{ + this->clear(); +} + +void Chart2ModelContact::setModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ) +{ + this->clear(); + m_xChartModel = xChartModel; + uno::Reference< lang::XMultiServiceFactory > xTableFactory( xChartModel, uno::UNO_QUERY ); + if( xTableFactory.is() ) + { + uno::Reference< container::XNameContainer > xDashTable( xTableFactory->createInstance( C2U( "com.sun.star.drawing.DashTable" ) ), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xGradientTable( xTableFactory->createInstance( C2U( "com.sun.star.drawing.GradientTable" ) ), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xHatchTable( xTableFactory->createInstance( C2U( "com.sun.star.drawing.HatchTable" ) ), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xBitmapTable( xTableFactory->createInstance( C2U( "com.sun.star.drawing.BitmapTable" ) ), uno::UNO_QUERY ); + uno::Reference< container::XNameContainer > xTransparencyGradientTable( xTableFactory->createInstance( C2U( "com.sun.star.drawing.TransparencyGradientTable" ) ), uno::UNO_QUERY ); + //C2U( "com.sun.star.drawing.MarkerTable" ) + m_aTableMap[ C2U( "LineDashName" ) ] = xDashTable; + m_aTableMap[ C2U( "FillGradientName" ) ] = xGradientTable; + m_aTableMap[ C2U( "FillHatchName" ) ] = xHatchTable; + m_aTableMap[ C2U( "FillBitmapName" ) ] = xBitmapTable; + m_aTableMap[ C2U( "FillTransparenceGradientName" ) ] = xTransparencyGradientTable; + } +} + +void Chart2ModelContact::clear() +{ + m_xChartModel = uno::WeakReference< frame::XModel >(0); + m_xChartView.clear(); +} + +Reference< frame::XModel > Chart2ModelContact::getChartModel() const +{ + return Reference< frame::XModel >( m_xChartModel.get(), uno::UNO_QUERY ); +} + +Reference< chart2::XChartDocument > Chart2ModelContact::getChart2Document() const +{ + return Reference< chart2::XChartDocument >( m_xChartModel.get(), uno::UNO_QUERY ); +} + +Reference< chart2::XDiagram > Chart2ModelContact::getChart2Diagram() const +{ + return ChartModelHelper::findDiagram( this->getChartModel() ); +} + +ExplicitValueProvider* Chart2ModelContact::getExplicitValueProvider() 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 = Reference< lang::XUnoTunnel >( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + } + + if(!m_xChartView.is()) + return 0; + + //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() +{ + uno::Reference< drawing::XDrawPage > xResult; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + { + xResult.set( pProvider->getDrawModelWrapper()->getMainDrawPage() ); + } + return xResult; +} + +sal_Bool Chart2ModelContact::getExplicitValuesForAxis( + const Reference< XAxis > & xAxis, + ExplicitScaleData & rOutExplicitScale, + ExplicitIncrementData & rOutExplicitIncrement ) +{ + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + { + return pProvider->getExplicitValuesForAxis( + xAxis, rOutExplicitScale, rOutExplicitIncrement ); + } + return sal_False; +} + +sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForAxis( + const Reference< chart2::XAxis >& xAxis ) +{ + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( + xAxis, ChartModelHelper::findDiagram( m_xChartModel ) ) ); + + return ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( xAxis, xCooSys + , Reference< util::XNumberFormatsSupplier >( m_xChartModel.get(), uno::UNO_QUERY ) ); +} + +sal_Int32 Chart2ModelContact::getExplicitNumberFormatKeyForSeries( + const Reference< chart2::XDataSeries >& xSeries ) +{ + return ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( + uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ), + xSeries, + -1 /*-1 for whole series*/, + ChartModelHelper::findDiagram( m_xChartModel ) + ); +} + +//----------------------------------------------------------------------------- + +awt::Size Chart2ModelContact::GetPageSize() const +{ + return ChartModelHelper::getPageSize(m_xChartModel); +} + +awt::Rectangle Chart2ModelContact::GetDiagramRectangleInclusive() const +{ + awt::Rectangle aRect; + + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + { + aRect = pProvider->getRectangleOfObject( lcl_getCIDForDiagram( m_xChartModel ) ); + } + //add axis title sizes to the diagram size + aRect = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle( + m_xChartModel, m_xChartView, aRect ); + + return aRect; +} + +awt::Size Chart2ModelContact::GetDiagramSizeInclusive() const +{ + return ToSize( this->GetDiagramRectangleInclusive() ); +} + +awt::Point Chart2ModelContact::GetDiagramPositionInclusive() const +{ + return ToPoint( this->GetDiagramRectangleInclusive() ); +} + +awt::Size Chart2ModelContact::GetLegendSize() const +{ + awt::Size aSize; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + { + uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_xChartModel ) ); + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + } + return aSize; +} + +awt::Point Chart2ModelContact::GetLegendPosition() const +{ + awt::Point aPoint; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider ) + { + uno::Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_xChartModel ) ); + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xLegend, m_xChartModel ) ); + aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + } + return aPoint; +} + +awt::Size Chart2ModelContact::GetTitleSize( const uno::Reference< + ::com::sun::star::chart2::XTitle > & xTitle ) const +{ + awt::Size aSize; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider && xTitle.is() ) + { + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) ); + aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + } + return aSize; +} + +awt::Point Chart2ModelContact::GetTitlePosition( const uno::Reference< + ::com::sun::star::chart2::XTitle > & xTitle ) const +{ + awt::Point aPoint; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider && xTitle.is() ) + { + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_xChartModel ) ); + aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + } + return aPoint; +} + +awt::Size Chart2ModelContact::GetAxisSize( const uno::Reference< + ::com::sun::star::chart2::XAxis > & xAxis ) const +{ + awt::Size aSize; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider && xAxis.is() ) + { + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) ); + aSize = ToSize( pProvider->getRectangleOfObject( aCID ) ); + } + return aSize; +} + +awt::Point Chart2ModelContact::GetAxisPosition( const uno::Reference< + ::com::sun::star::chart2::XAxis > & xAxis ) const +{ + awt::Point aPoint; + ExplicitValueProvider* pProvider( getExplicitValueProvider() ); + if( pProvider && xAxis.is() ) + { + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, m_xChartModel ) ); + aPoint = ToPoint( pProvider->getRectangleOfObject( aCID ) ); + } + return aPoint; +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx new file mode 100644 index 000000000000..0cc8a16bafff --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/Chart2ModelContact.hxx @@ -0,0 +1,162 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Chart2ModelContact.hxx,v $ + * $Revision: 1.3.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_CHART2MODELCONTACT_HXX +#define CHART_CHART2MODELCONTACT_HXX + +#include <com/sun/star/chart2/ExplicitScaleData.hpp> +#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/XTitle.hpp> +#include <cppuhelper/weakref.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/container/XNameContainer.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <map> + +namespace chart +{ +class ExplicitValueProvider; + +namespace wrapper +{ + +class Chart2ModelContact +{ +public: + Chart2ModelContact( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~Chart2ModelContact(); + +public: + void setModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + void clear(); + + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > getChartModel() const; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > getChart2Document() const; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > getChart2Diagram() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage > getDrawPage(); + + /** get the current values calculated for an axis in the current view in + case properties are 'auto'. + */ + sal_Bool getExplicitValuesForAxis( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XAxis > & xAxis, + ::com::sun::star::chart2::ExplicitScaleData & rOutExplicitScale, + ::com::sun::star::chart2::ExplicitIncrementData & rOutExplicitIncrement ); + + sal_Int32 getExplicitNumberFormatKeyForAxis( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XAxis >& xAxis ); + + sal_Int32 getExplicitNumberFormatKeyForSeries( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries >& xSeries ); + + /** Returns the size of the page in logic coordinates. This value is used + for setting an appropriate "ReferencePageSize" for FontHeights. + */ + ::com::sun::star::awt::Size GetPageSize() const; + + /** Returns the size of the diagram object in logic coordinates inclusive + the space reserved for axis titles. + */ + ::com::sun::star::awt::Size GetDiagramSizeInclusive() const; + + /** Returns the position of the diagram in logic coordinates inclusive + the space reserved for axis titles. + */ + ::com::sun::star::awt::Point GetDiagramPositionInclusive() const; + + /** Returns the size of the object in logic coordinates. + */ + ::com::sun::star::awt::Size GetLegendSize() const; + + /** Returns the position of the object in logic coordinates. + */ + ::com::sun::star::awt::Point GetLegendPosition() const; + + /** Returns the size of the object in logic coordinates. + */ + ::com::sun::star::awt::Size GetTitleSize( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XTitle > & xTitle ) const; + + /** Returns the position of the object in logic coordinates. + */ + ::com::sun::star::awt::Point GetTitlePosition( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XTitle > & xTitle ) const; + + + /** Returns the size of the object in logic coordinates. + */ + ::com::sun::star::awt::Size GetAxisSize( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XAxis > & xAxis ) const; + + /** Returns the position of the object in logic coordinates. + */ + ::com::sun::star::awt::Point GetAxisPosition( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XAxis > & xAxis ) const; + +private: //methods + ExplicitValueProvider* getExplicitValueProvider() const; + ::com::sun::star::awt::Rectangle GetDiagramRectangleInclusive() const; + +public: //member + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > + m_xContext; + +private: //member + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XModel > m_xChartModel; + + mutable ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XUnoTunnel > m_xChartView; + + typedef std::map< ::rtl::OUString, ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer > > tTableMap;//GradientTable, HatchTable etc. + tTableMap m_aTableMap; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_CHART2MODELCONTACT_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx new file mode 100644 index 000000000000..8cbb0c5af80c --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.cxx @@ -0,0 +1,667 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDataWrapper.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartDataWrapper.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include "DataSourceHelper.hxx" +#include "servicenames_charttypes.hxx" +#include "ContainerHelper.hxx" +#include "CommonFunctors.hxx" +#include "ChartModelHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "Chart2ModelContact.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart2/data/XNumericalDataSequence.hpp> +#include <com/sun/star/chart2/data/XTextualDataSequence.hpp> +#include <com/sun/star/chart2/data/XDataSource.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> + +#include "CharacterProperties.hxx" +#include "LineProperties.hxx" +#include "FillProperties.hxx" + +#include <map> +#include <algorithm> +#include <rtl/math.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::osl::MutexGuard; + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartData" )); + +struct lcl_DataSequenceToDoubleSeq : public ::std::unary_function< + uno::Reference< chart2::data::XDataSequence >, + uno::Sequence< double > > +{ + uno::Sequence< double > operator() ( const uno::Reference< chart2::data::XDataSequence > & xSeq ) + { + uno::Reference< chart2::data::XNumericalDataSequence > xNumSeq( xSeq, uno::UNO_QUERY ); + if( xNumSeq.is()) + { + return xNumSeq->getNumericalData(); + } + else if( xSeq.is()) + { + uno::Sequence< uno::Any > aValues = xSeq->getData(); + uno::Sequence< double > aResult( aValues.getLength()); + const sal_Int32 nLength = aValues.getLength(); + for( sal_Int32 i = 0; i < nLength; ++i ) + { + if( ! ( aValues[ i ] >>= aResult[ i ]) ) + { + aResult[ i ] = DBL_MIN; + } + double& rValue = aResult[ i ]; + if( ::rtl::math::isNan( rValue ) ) + rValue = DBL_MIN; + } + return aResult; + } + return uno::Sequence< double >(); + } +}; + +void lcl_AddSequences( uno::Reference< chart2::data::XLabeledDataSequence > xLSeq, + ::std::vector< uno::Reference< chart2::data::XDataSequence > > & rOutSeqVector, + ::std::vector< ::rtl::OUString > & rOutLabelVector ) +{ + if( xLSeq.is() ) + { + uno::Reference< chart2::data::XDataSequence > xSeq( xLSeq->getValues() ); + rOutSeqVector.push_back( xSeq ); + + ::rtl::OUString aLabel( ::chart::DataSeriesHelper::getLabelForLabeledDataSequence( xLSeq ) ); + rOutLabelVector.push_back( aLabel ); + } +} + +uno::Sequence< uno::Sequence< double > > lcl_getNANInsteadDBL_MIN( const uno::Sequence< uno::Sequence< double > >& rData ) +{ + uno::Sequence< uno::Sequence< double > > aRet; + const sal_Int32 nOuterSize = rData.getLength(); + aRet.realloc( nOuterSize ); + for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) + { + sal_Int32 nInnerSize = rData[nOuter].getLength(); + aRet[nOuter].realloc( nInnerSize ); + for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) + { + aRet[nOuter][nInner] = rData[nOuter][nInner]; + double& rValue = aRet[nOuter][nInner]; + if( rValue == DBL_MIN ) + ::rtl::math::setNan( &rValue ); + } + } + return aRet; +} + +uno::Sequence< uno::Sequence< double > > lcl_getDBL_MINInsteadNAN( const uno::Sequence< uno::Sequence< double > >& rData ) +{ + uno::Sequence< uno::Sequence< double > > aRet; + const sal_Int32 nOuterSize = rData.getLength(); + aRet.realloc( nOuterSize ); + for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) + { + sal_Int32 nInnerSize = rData[nOuter].getLength(); + aRet[nOuter].realloc( nInnerSize ); + for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) + { + aRet[nOuter][nInner] = rData[nOuter][nInner]; + double& rValue = aRet[nOuter][nInner]; + if( ::rtl::math::isNan( rValue ) ) + rValue = DBL_MIN; + } + } + return aRet; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +ChartDataWrapper::ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ) +{ + refreshData(); +} + +ChartDataWrapper::~ChartDataWrapper() +{ + // @todo: implement XComponent and call this in dispose(). In the DTOR the + // ref-count is 0, thus creating a stack reference to this calls the DTOR at + // the end of the block recursively +// uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); +// m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); +} + +// ____ XChartDataArray ____ +uno::Sequence< uno::Sequence< double > > SAL_CALL ChartDataWrapper::getData() + throw (uno::RuntimeException) +{ + // until we have a data change notification mechanism we always have to + // update the data here + refreshData(); + // /-- + MutexGuard aGuard( GetMutex()); + return m_aData; + // \-- +} + +void SAL_CALL ChartDataWrapper::setData( + const uno::Sequence< uno::Sequence< double > >& aData ) + throw (uno::RuntimeException) +{ + refreshData(); + { + // /-- + MutexGuard aGuard( GetMutex()); + m_aData = aData; + // \-- + } + applyData( true, false, false ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ChartDataWrapper::getRowDescriptions() + throw (uno::RuntimeException) +{ + // until we have a data change notification mechanism we always have to + // update the data here + refreshData(); + + // /-- + MutexGuard aGuard( GetMutex()); + return m_aRowDescriptions; + // \-- +} + +void SAL_CALL ChartDataWrapper::setRowDescriptions( + const uno::Sequence< ::rtl::OUString >& aRowDescriptions ) + throw (uno::RuntimeException) +{ + refreshData(); + { + // /-- + MutexGuard aGuard( GetMutex()); + m_aRowDescriptions = aRowDescriptions; + // \-- + } + applyData( false, true, false ); +} + +uno::Sequence< + ::rtl::OUString > SAL_CALL ChartDataWrapper::getColumnDescriptions() + throw (uno::RuntimeException) +{ + // until we have a data change notification mechanism we always have to + // update the data here + refreshData(); + // /-- + MutexGuard aGuard( GetMutex()); + return m_aColumnDescriptions; + // \-- +} + +void SAL_CALL ChartDataWrapper::setColumnDescriptions( + const uno::Sequence< ::rtl::OUString >& aColumnDescriptions ) + throw (uno::RuntimeException) +{ + refreshData(); + { + // /-- + MutexGuard aGuard( GetMutex()); + m_aColumnDescriptions = aColumnDescriptions; + // \-- + } + applyData( false, false, true ); +} + + +// ____ XChartData (base of XChartDataArray) ____ +void SAL_CALL ChartDataWrapper::addChartDataChangeEventListener( + const uno::Reference< + ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( aListener ); +} + +void SAL_CALL ChartDataWrapper::removeChartDataChangeEventListener( + const uno::Reference< + ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +double SAL_CALL ChartDataWrapper::getNotANumber() + throw (uno::RuntimeException) +{ + return DBL_MIN; +} + +sal_Bool SAL_CALL ChartDataWrapper::isNotANumber( double nNumber ) + throw (uno::RuntimeException) +{ + return DBL_MIN == nNumber + || ::rtl::math::isNan( nNumber ) + || ::rtl::math::isInf( nNumber ); +} + +// ____ XComponent ____ +void SAL_CALL ChartDataWrapper::dispose() + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); + + // /-- + MutexGuard aGuard( GetMutex()); + m_aData.realloc( 0 ); + m_aColumnDescriptions.realloc( 0 ); + m_aRowDescriptions.realloc( 0 ); + // \-- +} + +void SAL_CALL ChartDataWrapper::addEventListener( + const uno::Reference< lang::XEventListener > & xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL ChartDataWrapper::removeEventListener( + const uno::Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ____ XEventListener ____ +void SAL_CALL ChartDataWrapper::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{ +} + +// ::com::sun::star::chart::ChartDataChangeEvent aEvent; +// aEvent.Type = chart::ChartDataChangeType_ALL; +// aEvent.StartColumn = 0; +// aEvent.EndColumn = 0; +// aEvent.StartRow = 0; +// aEvent.EndRow = 0; +void ChartDataWrapper::fireChartDataChangeEvent( + ::com::sun::star::chart::ChartDataChangeEvent& aEvent ) +{ + if( ! m_aEventListenerContainer.getLength() ) + return; + + uno::Reference< uno::XInterface > xSrc( static_cast< cppu::OWeakObject* >( this )); + OSL_ASSERT( xSrc.is()); + if( xSrc.is() ) + aEvent.Source = xSrc; + + ::cppu::OInterfaceIteratorHelper aIter( m_aEventListenerContainer ); + + while( aIter.hasMoreElements() ) + { + uno::Reference< + ::com::sun::star::chart::XChartDataChangeEventListener > xListener( + aIter.next(), uno::UNO_QUERY ); + xListener->chartDataChanged( aEvent ); + } +} + +void ChartDataWrapper::refreshData() +{ + //todo mutex... + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( !xChartDoc.is() ) + return; + if( xChartDoc->hasInternalDataProvider()) + { + try { + uno::Reference< ::com::sun::star::chart::XChartDataArray > xInternalData( xChartDoc->getDataProvider(), uno::UNO_QUERY_THROW ); + m_aColumnDescriptions = xInternalData->getColumnDescriptions(); + m_aRowDescriptions = xInternalData->getRowDescriptions(); + m_aData = lcl_getDBL_MINInsteadNAN( xInternalData->getData() ); + } + catch( const uno::Exception & ex ) { + ASSERT_EXCEPTION( ex ); + } + } + else + { + uno::Reference< chart2::XDiagram > xDia( + xChartDoc->getFirstDiagram() ); + if( ! xDia.is()) + return; + + // get information about the segmentation of the assumed "rectangular" data + // range + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + DataSourceHelper::detectRangeSegmentation( + uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ), + aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ); + + + // get data values from data series + // -------------------------------- + uno::Sequence< uno::Reference< chart2::data::XLabeledDataSequence > > aLabeledSequences; + uno::Reference< chart2::data::XDataSource > xRectangularDataSource( + DataSourceHelper::pressUsedDataIntoRectangularFormat( xChartDoc, false /*bWithCategories*/ ) ); + if( xRectangularDataSource.is() ) + { + aLabeledSequences = xRectangularDataSource->getDataSequences(); + } + + ::std::vector< uno::Reference< chart2::data::XDataSequence > > aSequenceVector; + ::std::vector< ::rtl::OUString > aLabelVector; + for( sal_Int32 nN=0; nN<aLabeledSequences.getLength(); nN++ ) + lcl_AddSequences( aLabeledSequences[nN], aSequenceVector, aLabelVector ); + + if( aSequenceMapping.getLength() ) + { + //aSequenceVector and aLabelVector contain changed positions; resort them to the original position + ::std::vector< uno::Reference< chart2::data::XDataSequence > > aBackSortedSequences; + ::std::vector< ::rtl::OUString > aBackSortedLabels; + + std::map< sal_Int32, sal_Int32 > aReverseMap; + { + sal_Int32 nNewIndex, nOldIndex; + for( sal_Int32 nS=0; nS <aSequenceMapping.getLength(); nS++ ) + { + nOldIndex = aSequenceMapping[nS]; + nNewIndex = nS; + if( bHasCategories ) + nNewIndex--; + if( nOldIndex >= 0 && nNewIndex >= 0 ) + aReverseMap[nOldIndex] = nNewIndex; + } + } + + std::map< sal_Int32, sal_Int32 >::iterator aMapIt = aReverseMap.begin(); + std::map< sal_Int32, sal_Int32 >::const_iterator aMapEnd = aReverseMap.end(); + + for( ; aMapIt != aMapEnd; ++aMapIt ) + { + size_t nNewIndex = static_cast< size_t >( aMapIt->second ); + if( nNewIndex < aSequenceVector.size() ) + aBackSortedSequences.push_back( aSequenceVector[nNewIndex] ); + if( nNewIndex < aLabelVector.size() ) + aBackSortedLabels.push_back( aLabelVector[nNewIndex] ); + } + + // note: assign( beg, end ) doesn't work on solaris + aSequenceVector.clear(); + aSequenceVector.insert( + aSequenceVector.begin(), aBackSortedSequences.begin(), aBackSortedSequences.end() ); + aLabelVector.clear(); + aLabelVector.insert( + aLabelVector.begin(), aBackSortedLabels.begin(), aBackSortedLabels.end() ); + } + + if( bUseColumns ) + { + const sal_Int32 nInnerSize = aSequenceVector.size(); + if( nInnerSize > 0 && aSequenceVector[0].is() ) + { + // take the length of the first data series also as length for all + // other series + const sal_Int32 nOuterSize = aSequenceVector[0]->getData().getLength(); + + m_aData.realloc( nOuterSize ); + for( sal_Int32 nOuter=0; nOuter<nOuterSize; ++nOuter ) + m_aData[nOuter].realloc( nInnerSize ); + + for( sal_Int32 nInner=0; nInner<nInnerSize; ++nInner ) + { + uno::Sequence< double > aValues = uno::Sequence< double > ( + lcl_DataSequenceToDoubleSeq() (aSequenceVector[nInner] )); + sal_Int32 nMax = ::std::min( nOuterSize, aValues.getLength()); + for( sal_Int32 nOuter=0; nOuter<nMax; ++nOuter ) + m_aData[nOuter][nInner] = aValues[nOuter]; + } + } + } + else + { + m_aData.realloc( static_cast< sal_Int32 >( aSequenceVector.size())); + ::std::transform( aSequenceVector.begin(), aSequenceVector.end(), + m_aData.getArray(), + lcl_DataSequenceToDoubleSeq() ); + } + + // labels (values already filled during parsing of data values) + if( bUseColumns ) + m_aColumnDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector ); + else + m_aRowDescriptions = ::chart::ContainerHelper::ContainerToSequence( aLabelVector ); + + // get row-/column descriptions + // ---------------------------- + // categories + uno::Sequence< ::rtl::OUString > & rSequence = + bUseColumns ? m_aRowDescriptions : m_aColumnDescriptions; + rSequence = DiagramHelper::generateAutomaticCategories( xChartDoc ); + } +} + +void ChartDataWrapper::applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions ) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( !xChartDoc.is() ) + return; + + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + // should do nothing if we already have an internal data provider + xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ ); + + uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider()); + uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY ); + + // remember some diagram properties to reset later + sal_Bool bStacked = sal_False; + sal_Bool bPercent = sal_False; + sal_Bool bDeep = sal_False; + uno::Reference< ::com::sun::star::chart::XChartDocument > xOldDoc( xChartDoc, uno::UNO_QUERY ); + OSL_ASSERT( xOldDoc.is()); + uno::Reference< beans::XPropertySet > xDiaProp( xOldDoc->getDiagram(), uno::UNO_QUERY ); + if( xDiaProp.is()) + { + xDiaProp->getPropertyValue( C2U("Stacked")) >>= bStacked; + xDiaProp->getPropertyValue( C2U("Percent")) >>= bPercent; + xDiaProp->getPropertyValue( C2U("Deep")) >>= bDeep; + } + + //detect arguments for the new data source + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + DataSourceHelper::detectRangeSegmentation( + uno::Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ), + aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ); + + if( !bFirstCellAsLabel ) + { + if( bSetRowDescriptions && !bUseColumns ) + bFirstCellAsLabel = true; + else if( bSetColumnDescriptions && bUseColumns ) + bFirstCellAsLabel = true; + } + if( !bHasCategories ) + { + if( bSetColumnDescriptions && bUseColumns ) + bHasCategories = true; + else if( bSetRowDescriptions && !bUseColumns ) + bHasCategories = true; + } + + aRangeString = C2U("all"); + uno::Sequence< beans::PropertyValue > aArguments( DataSourceHelper::createArguments( + aRangeString, aSequenceMapping, bUseColumns, bFirstCellAsLabel, bHasCategories ) ); + + // create and attach new data source + uno::Reference< chart2::data::XDataSource > xSource; + if( xDocDataArray.is() ) + { + // we have an internal data provider that supports the XChartDataArray + // interface + if( bSetValues ) + xDocDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) ); + if( bSetRowDescriptions ) + xDocDataArray->setRowDescriptions( m_aRowDescriptions ); + if( bSetColumnDescriptions ) + xDocDataArray->setColumnDescriptions( m_aColumnDescriptions ); + + xSource.set( xDataProvider->createDataSource( aArguments )); + } + else + { + uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY ); + OSL_ASSERT( xChartDoc.is()); + OSL_ASSERT( xReceiver.is()); + if( ! (xChartDoc.is() && xReceiver.is())) + return; + + // create a data provider containing the new data + uno::Reference< chart2::data::XDataProvider > xTempDataProvider( + ChartModelHelper::createInternalDataProvider() ); + if( ! xTempDataProvider.is()) + throw uno::RuntimeException( C2U("Couldn't create temporary data provider"), + static_cast< ::cppu::OWeakObject * >( this )); + + uno::Reference< ::com::sun::star::chart::XChartDataArray > xDataArray( xTempDataProvider, uno::UNO_QUERY ); + OSL_ASSERT( xDataArray.is()); + if( xDataArray.is()) + { + if( bSetValues ) + xDataArray->setData( lcl_getNANInsteadDBL_MIN( m_aData ) ); + if( bSetRowDescriptions ) + xDataArray->setRowDescriptions( m_aRowDescriptions ); + if( bSetColumnDescriptions ) + xDataArray->setColumnDescriptions( m_aColumnDescriptions ); + + // removes existing data provider and attaches the new one + xReceiver->attachDataProvider( xTempDataProvider ); + xSource.set( xTempDataProvider->createDataSource( aArguments)); + } + } + + // determine a template + uno::Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram()); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDia, xFact ); + ::rtl::OUString aServiceName( aTemplateAndService.second ); + uno::Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first; + + // (fall-back) + if( ! xTemplate.is()) + { + if( aServiceName.getLength() == 0 ) + aServiceName = C2U("com.sun.star.chart2.template.Column"); + xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY ); + } + OSL_ASSERT( xTemplate.is()); + + if( xTemplate.is() && xSource.is()) + { + // argument detection works with internal knowledge of the + // ArrayDataProvider + OSL_ASSERT( xDia.is()); + xTemplate->changeDiagramData( + xDia, xSource, aArguments ); + } + + //correct stacking mode + if( bStacked || bPercent || bDeep ) + { + StackMode eStackMode = StackMode_Y_STACKED; + if( bDeep ) + eStackMode = StackMode_Z_STACKED; + else if( bPercent ) + eStackMode = StackMode_Y_STACKED_PERCENT; + DiagramHelper::setStackMode( xDia, eStackMode ); + } + + // notify listeners + ::com::sun::star::chart::ChartDataChangeEvent aEvent( + static_cast< ::cppu::OWeakObject* >( this ), + ::com::sun::star::chart::ChartDataChangeType_ALL, 0, 0, 0, 0 ); + fireChartDataChangeEvent( aEvent ); + // \-- locked controllers +} + +// -------------------------------------------------------------------------------- + +uno::Sequence< ::rtl::OUString > ChartDataWrapper::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 2 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDataArray" ); + aServices[ 1 ] = C2U( "com.sun.star.chart.ChartData" ); + + return aServices; +} + +// ================================================================================ + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ChartDataWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx new file mode 100644 index 000000000000..e63b64397f58 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/ChartDataWrapper.hxx @@ -0,0 +1,138 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDataWrapper.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_CHARTDATAWRAPPER_HXX +#define CHART_CHARTDATAWRAPPER_HXX + +#include "ServiceMacros.hxx" +#include "MutexContainer.hxx" +#include <cppuhelper/implbase4.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/chart/XChartDataArray.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ +namespace wrapper +{ + +class Chart2ModelContact; + +class ChartDataWrapper : public MutexContainer, public + ::cppu::WeakImplHelper4< + com::sun::star::chart::XChartDataArray, + com::sun::star::lang::XServiceInfo, + com::sun::star::lang::XEventListener, + com::sun::star::lang::XComponent > +{ +public: + ChartDataWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~ChartDataWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + +protected: + // ____ XChartDataArray ____ + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + double > > SAL_CALL getData() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setData( const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< + double > >& aData ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::rtl::OUString > SAL_CALL getRowDescriptions() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setRowDescriptions( const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& aRowDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::rtl::OUString > SAL_CALL getColumnDescriptions() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setColumnDescriptions( const ::com::sun::star::uno::Sequence< + ::rtl::OUString >& aColumnDescriptions ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XChartData (base of XChartDataArray) ____ + virtual void SAL_CALL addChartDataChangeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeChartDataChangeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XChartDataChangeEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual double SAL_CALL getNotANumber() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL isNotANumber( double nNumber ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XEventListener ____ + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + + void fireChartDataChangeEvent( ::com::sun::star::chart::ChartDataChangeEvent& aEvent ); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Sequence< double > > m_aData; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aColumnDescriptions; + ::com::sun::star::uno::Sequence< ::rtl::OUString > m_aRowDescriptions; + + /// re-reads the data from the model + void refreshData(); + + /// applies changed data to model + void applyData( bool bSetValues, bool bSetRowDescriptions, bool bSetColumnDescriptions ); +}; + +} // namespace wrapper +} // namespace chart + +// CHART_CHARTDATAWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx new file mode 100644 index 000000000000..397527f3ea9d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/ChartDocumentWrapper.cxx @@ -0,0 +1,1686 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDocumentWrapper.cxx,v $ + * $Revision: 1.10 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartDocumentWrapper.hxx" +#include "macros.hxx" +#include "servicenames.hxx" +#include "PropertyHelper.hxx" +#include "TitleHelper.hxx" +#include "LegendHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "ModifyListenerHelper.hxx" +#include "DisposeHelper.hxx" +#include "DataSeriesPointWrapper.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "Chart2ModelContact.hxx" + +#include "DiagramHelper.hxx" +#include "DataSourceHelper.hxx" +#include "ChartModelHelper.hxx" +#include "ContainerHelper.hxx" + +#include "TitleWrapper.hxx" +#include "ChartDataWrapper.hxx" +#include "DiagramWrapper.hxx" +#include "LegendWrapper.hxx" +#include "AreaWrapper.hxx" +#include "WrappedAddInProperty.hxx" +#include "WrappedIgnoreProperty.hxx" +#include "ChartRenderer.hxx" +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/chart/ChartDataRowSource.hpp> +#include <com/sun/star/chart/XChartDataArray.hpp> +#include <comphelper/InlineContainer.hxx> +// header for function SvxShapeCollection_NewInstance +#include <svx/unoshcol.hxx> +// header for define DBG_ASSERT +#include <tools/debug.hxx> +#include <com/sun/star/drawing/XDrawPagesSupplier.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/util/DateTime.hpp> + +#include <vector> +#include <algorithm> +#include <functional> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart; + +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::osl::MutexGuard; +using ::rtl::OUString; + +namespace +{ +enum eServiceType +{ + SERVICE_NAME_AREA_DIAGRAM = 0, + SERVICE_NAME_BAR_DIAGRAM, + SERVICE_NAME_DONUT_DIAGRAM, + SERVICE_NAME_LINE_DIAGRAM, + SERVICE_NAME_NET_DIAGRAM, + SERVICE_NAME_FILLED_NET_DIAGRAM, + SERVICE_NAME_PIE_DIAGRAM, + SERVICE_NAME_STOCK_DIAGRAM, + SERVICE_NAME_XY_DIAGRAM, + SERVICE_NAME_BUBBLE_DIAGRAM, + + SERVICE_NAME_DASH_TABLE, + SERVICE_NAME_GARDIENT_TABLE, + SERVICE_NAME_HATCH_TABLE, + SERVICE_NAME_BITMAP_TABLE, + SERVICE_NAME_TRANSP_GRADIENT_TABLE, + SERVICE_NAME_MARKER_TABLE, + + SERVICE_NAME_NAMESPACE_MAP, + SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER, + SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER +}; + +typedef ::std::map< ::rtl::OUString, enum eServiceType > tServiceNameMap; +typedef ::comphelper::MakeMap< ::rtl::OUString, enum eServiceType > tMakeServiceNameMap; + +tServiceNameMap & lcl_getStaticServiceNameMap() +{ + static tServiceNameMap aServiceNameMap( + tMakeServiceNameMap + ( C2U( "com.sun.star.chart.AreaDiagram" ), SERVICE_NAME_AREA_DIAGRAM ) + ( C2U( "com.sun.star.chart.BarDiagram" ), SERVICE_NAME_BAR_DIAGRAM ) + ( C2U( "com.sun.star.chart.DonutDiagram" ), SERVICE_NAME_DONUT_DIAGRAM ) + ( C2U( "com.sun.star.chart.LineDiagram" ), SERVICE_NAME_LINE_DIAGRAM ) + ( C2U( "com.sun.star.chart.NetDiagram" ), SERVICE_NAME_NET_DIAGRAM ) + ( C2U( "com.sun.star.chart.FilledNetDiagram" ), SERVICE_NAME_FILLED_NET_DIAGRAM ) + ( C2U( "com.sun.star.chart.PieDiagram" ), SERVICE_NAME_PIE_DIAGRAM ) + ( C2U( "com.sun.star.chart.StockDiagram" ), SERVICE_NAME_STOCK_DIAGRAM ) + ( C2U( "com.sun.star.chart.XYDiagram" ), SERVICE_NAME_XY_DIAGRAM ) + ( C2U( "com.sun.star.chart.BubbleDiagram" ), SERVICE_NAME_BUBBLE_DIAGRAM ) + + ( C2U( "com.sun.star.drawing.DashTable" ), SERVICE_NAME_DASH_TABLE ) + ( C2U( "com.sun.star.drawing.GradientTable" ), SERVICE_NAME_GARDIENT_TABLE ) + ( C2U( "com.sun.star.drawing.HatchTable" ), SERVICE_NAME_HATCH_TABLE ) + ( C2U( "com.sun.star.drawing.BitmapTable" ), SERVICE_NAME_BITMAP_TABLE ) + ( C2U( "com.sun.star.drawing.TransparencyGradientTable" ), SERVICE_NAME_TRANSP_GRADIENT_TABLE ) + ( C2U( "com.sun.star.drawing.MarkerTable" ), SERVICE_NAME_MARKER_TABLE ) + + ( C2U( "com.sun.star.xml.NamespaceMap" ), SERVICE_NAME_NAMESPACE_MAP ) + ( C2U( "com.sun.star.document.ExportGraphicObjectResolver" ), SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER ) + ( C2U( "com.sun.star.document.ImportGraphicObjectResolver" ), SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER ) + ); + + return aServiceNameMap; +} + +enum +{ + PROP_DOCUMENT_HAS_MAIN_TITLE, + PROP_DOCUMENT_HAS_SUB_TITLE, + PROP_DOCUMENT_HAS_LEGEND, + PROP_DOCUMENT_LABELS_IN_FIRST_ROW, + PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN, + PROP_DOCUMENT_ADDIN, + PROP_DOCUMENT_BASEDIAGRAM, + PROP_DOCUMENT_ADDITIONAL_SHAPES, + PROP_DOCUMENT_UPDATE_ADDIN, + PROP_DOCUMENT_NULL_DATE +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "HasMainTitle" ), + PROP_DOCUMENT_HAS_MAIN_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasSubTitle" ), + PROP_DOCUMENT_HAS_SUB_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasLegend" ), + PROP_DOCUMENT_HAS_LEGEND, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // really needed? + rOutProperties.push_back( + Property( C2U( "DataSourceLabelsInFirstRow" ), + PROP_DOCUMENT_LABELS_IN_FIRST_ROW, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "DataSourceLabelsInFirstColumn" ), + PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //add-in + rOutProperties.push_back( + Property( C2U( "AddIn" ), + PROP_DOCUMENT_ADDIN, + ::getCppuType( reinterpret_cast< Reference< util::XRefreshable > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "BaseDiagram" ), + PROP_DOCUMENT_BASEDIAGRAM, + ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "AdditionalShapes" ), + PROP_DOCUMENT_ADDITIONAL_SHAPES, + ::getCppuType( reinterpret_cast< Reference< drawing::XShapes > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::READONLY )); + rOutProperties.push_back( + Property( C2U( "RefreshAddInAllowed" ), + PROP_DOCUMENT_UPDATE_ADDIN, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND )); + + // table:null-date // i99104 + rOutProperties.push_back( + Property( C2U( "NullDate" ), + PROP_DOCUMENT_NULL_DATE, + ::getCppuType( static_cast< const ::com::sun::star::util::DateTime * >(0)), + beans::PropertyAttribute::MAYBEVOID )); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DOCUMENT_LABELS_IN_FIRST_ROW +class WrappedDataSourceLabelsInFirstRowProperty : public WrappedProperty +{ +public: + WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedDataSourceLabelsInFirstRowProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedDataSourceLabelsInFirstRowProperty::WrappedDataSourceLabelsInFirstRowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("DataSourceLabelsInFirstRow"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( 0 ); +} + +WrappedDataSourceLabelsInFirstRowProperty::~WrappedDataSourceLabelsInFirstRowProperty() +{ +} + +void WrappedDataSourceLabelsInFirstRowProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bLabelsInFirstRow = sal_True; + if( ! (rOuterValue >>= bLabelsInFirstRow) ) + throw lang::IllegalArgumentException( C2U("Property DataSourceLabelsInFirstRow requires value of type boolean"), 0, 0 ); + + m_aOuterValue = rOuterValue; + bool bNewValue = bLabelsInFirstRow; + + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + if( bUseColumns && bNewValue != bFirstCellAsLabel ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns ,bNewValue, bHasCategories ); + } + else if( !bUseColumns && bNewValue != bHasCategories ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bFirstCellAsLabel, bNewValue ); + } + } +} + +Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + sal_Bool bLabelsInFirstRow = sal_True; + if( bUseColumns ) + bLabelsInFirstRow = bFirstCellAsLabel; + else + bLabelsInFirstRow = bHasCategories; + + m_aOuterValue <<= bLabelsInFirstRow; + } + return m_aOuterValue; +} + +Any WrappedDataSourceLabelsInFirstRowProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_True; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DOCUMENT_LABELS_IN_FIRST_COLUMN +class WrappedDataSourceLabelsInFirstColumnProperty : public WrappedProperty +{ +public: + WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedDataSourceLabelsInFirstColumnProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedDataSourceLabelsInFirstColumnProperty::WrappedDataSourceLabelsInFirstColumnProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("DataSourceLabelsInFirstColumn"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( 0 ); +} + +WrappedDataSourceLabelsInFirstColumnProperty::~WrappedDataSourceLabelsInFirstColumnProperty() +{ +} + +void WrappedDataSourceLabelsInFirstColumnProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bLabelsInFirstRow = sal_True; + if( ! (rOuterValue >>= bLabelsInFirstRow) ) + throw lang::IllegalArgumentException( C2U("Property DataSourceLabelsInFirstRow requires value of type boolean"), 0, 0 ); + + m_aOuterValue = rOuterValue; + bool bNewValue = bLabelsInFirstRow; + + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + if( bUseColumns && bNewValue != bHasCategories ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns, bFirstCellAsLabel, bNewValue ); + } + else if( !bUseColumns && bNewValue != bFirstCellAsLabel ) + { + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bUseColumns , bNewValue, bHasCategories ); + } + } +} + +Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + sal_Bool bLabelsInFirstColumn = sal_True; + if( bUseColumns ) + bLabelsInFirstColumn = bHasCategories; + else + bLabelsInFirstColumn = bFirstCellAsLabel; + + m_aOuterValue <<= bLabelsInFirstColumn; + } + return m_aOuterValue; +} + +Any WrappedDataSourceLabelsInFirstColumnProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_True; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DOCUMENT_HAS_LEGEND +class WrappedHasLegendProperty : public WrappedProperty +{ +public: + WrappedHasLegendProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedHasLegendProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedHasLegendProperty::WrappedHasLegendProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("HasLegend"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedHasLegendProperty::~WrappedHasLegendProperty() +{ +} + +void WrappedHasLegendProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = sal_True; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property HasLegend requires value of type boolean"), 0, 0 ); + + try + { + Reference< chart2::XLegend > xLegend( LegendHelper::getLegend( m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext,bNewValue )); + if(xLegend.is()) + { + Reference< beans::XPropertySet > xLegendProp( xLegend, uno::UNO_QUERY_THROW ); + sal_Bool bOldValue = sal_True; + Any aAOld = xLegendProp->getPropertyValue( C2U("Show") ); + aAOld >>= bOldValue; + if( bOldValue != bNewValue ) + xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( bNewValue )); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +Any WrappedHasLegendProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + try + { + Reference< beans::XPropertySet > xLegendProp( + LegendHelper::getLegend( m_spChart2ModelContact->getChartModel() ), uno::UNO_QUERY ); + if( xLegendProp.is()) + aRet = xLegendProp->getPropertyValue( C2U("Show")); + else + aRet <<= sal_False; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aRet; +} + +Any WrappedHasLegendProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_False; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DOCUMENT_HAS_MAIN_TITLE +class WrappedHasMainTitleProperty : public WrappedProperty +{ +public: + WrappedHasMainTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedHasMainTitleProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedHasMainTitleProperty::WrappedHasMainTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("HasMainTitle"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedHasMainTitleProperty::~WrappedHasMainTitleProperty() +{ +} + +void WrappedHasMainTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = sal_True; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property HasMainTitle requires value of type boolean"), 0, 0 ); + + try + { + if( bNewValue ) + TitleHelper::createTitle( TitleHelper::MAIN_TITLE, C2U("main-title"), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + else + TitleHelper::removeTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +Any WrappedHasMainTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + try + { + aRet <<= sal_Bool( TitleHelper::getTitle( TitleHelper::MAIN_TITLE, m_spChart2ModelContact->getChartModel() ).is() ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aRet; +} + +Any WrappedHasMainTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_False; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DOCUMENT_HAS_SUB_TITLE +class WrappedHasSubTitleProperty : public WrappedProperty +{ +public: + WrappedHasSubTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedHasSubTitleProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedHasSubTitleProperty::WrappedHasSubTitleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("HasSubTitle"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedHasSubTitleProperty::~WrappedHasSubTitleProperty() +{ +} + +void WrappedHasSubTitleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = sal_True; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property HasSubTitle requires value of type boolean"), 0, 0 ); + + + try + { + if( bNewValue ) + TitleHelper::createTitle( TitleHelper::SUB_TITLE, C2U("sub-title"), m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + else + TitleHelper::removeTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +Any WrappedHasSubTitleProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + try + { + aRet <<= sal_Bool( TitleHelper::getTitle( TitleHelper::SUB_TITLE, m_spChart2ModelContact->getChartModel() ).is() ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aRet; +} + +Any WrappedHasSubTitleProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_False; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +ChartDocumentWrapper::ChartDocumentWrapper( + const Reference< uno::XComponentContext > & xContext ) : + m_spChart2ModelContact( new Chart2ModelContact( xContext ) ), + m_bUpdateAddIn( sal_True ), + m_bIsDisposed( false ) +{ +} + +ChartDocumentWrapper::~ChartDocumentWrapper() +{ + stopAllComponentListening(); +} + +// ____ XInterface (for new interfaces) ____ +uno::Any SAL_CALL ChartDocumentWrapper::queryInterface( const uno::Type& aType ) + throw (uno::RuntimeException) +{ + if( m_xDelegator.is()) + // calls queryAggregation if the delegator doesn't know aType + return m_xDelegator->queryInterface( aType ); + else + return queryAggregation( aType ); +} + +// ____ chart::XChartDocument (old API wrapper) ____ +Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getTitle() + throw (uno::RuntimeException) +{ + if( !m_xTitle.is() ) + { + m_xTitle = new TitleWrapper( TitleHelper::MAIN_TITLE, m_spChart2ModelContact ); + } + return m_xTitle; +} + +Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getSubTitle() + throw (uno::RuntimeException) +{ + if( !m_xSubTitle.is() ) + { + m_xSubTitle = new TitleWrapper( TitleHelper::SUB_TITLE, m_spChart2ModelContact ); + } + return m_xSubTitle; +} + +Reference< drawing::XShape > SAL_CALL ChartDocumentWrapper::getLegend() + throw (uno::RuntimeException) +{ + if( ! m_xLegend.is()) + { + m_xLegend = new LegendWrapper( m_spChart2ModelContact ); + Reference< lang::XComponent > xComp( m_xLegend, uno::UNO_QUERY ); + } + + return m_xLegend; +} + +Reference< beans::XPropertySet > SAL_CALL ChartDocumentWrapper::getArea() + throw (uno::RuntimeException) +{ + if( ! m_xArea.is()) + { + m_xArea.set( new AreaWrapper( m_spChart2ModelContact ) ); + Reference< lang::XComponent > xComp( m_xArea, uno::UNO_QUERY ); + } + + return m_xArea; +} + +Reference< XDiagram > SAL_CALL ChartDocumentWrapper::getDiagram() + throw (uno::RuntimeException) +{ + if( !m_xDiagram.is() ) + { + try + { + m_xDiagram = new DiagramWrapper( m_spChart2ModelContact ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + return m_xDiagram; +} + +void SAL_CALL ChartDocumentWrapper::setDiagram( const Reference< XDiagram >& xDiagram ) + throw (uno::RuntimeException) +{ + uno::Reference< util::XRefreshable > xAddIn( xDiagram, uno::UNO_QUERY ); + if( xAddIn.is() ) + { + setAddIn( xAddIn ); + } + else if( xDiagram.is() && 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()); + + try + { + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( xChartDoc.is() ) + { + // set the new diagram + xChartDoc->setFirstDiagram( xNewDia ); + m_xDiagram = xDiagram; + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +Reference< XChartData > SAL_CALL ChartDocumentWrapper::getData() + throw (uno::RuntimeException) +{ + if( ! m_xChartData.is()) + { + m_xChartData.set( new ChartDataWrapper( m_spChart2ModelContact ) ); + } + //@todo: check hasInternalDataProvider also in else? + + return m_xChartData; +} + +void SAL_CALL ChartDocumentWrapper::attachData( const Reference< XChartData >& xData ) + throw (uno::RuntimeException) +{ + if( !xData.is()) + return; + + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( !xChartDoc.is() ) + return; + + uno::Reference< chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider()); + uno::Reference< XChartDataArray > xDocDataArray( xDataProvider, uno::UNO_QUERY ); + uno::Reference< XChartDataArray > xDataArray( xData, uno::UNO_QUERY ); + OSL_ASSERT( xDataArray.is()); + if( ! xDataArray.is() || + xDocDataArray == xDataArray ) + return; + + // remember some diagram properties to reset later + ChartDataRowSource eSeriesSource = ChartDataRowSource_ROWS; + sal_Bool bStacked = sal_False; + sal_Bool bPercent = sal_False; + sal_Bool bDeep = sal_False; + Reference< beans::XPropertySet > xDiaProp( getDiagram(), uno::UNO_QUERY ); + if( xDiaProp.is()) + { + xDiaProp->getPropertyValue( C2U("DataRowSource")) >>= eSeriesSource; + xDiaProp->getPropertyValue( C2U("Stacked")) >>= bStacked; + xDiaProp->getPropertyValue( C2U("Percent")) >>= bPercent; + xDiaProp->getPropertyValue( C2U("Deep")) >>= bDeep; + } + + // create and attach new data source + uno::Reference< chart2::data::XDataSource > xSource; + Sequence< beans::PropertyValue > aArguments( 4 ); + aArguments[0] = beans::PropertyValue( + C2U("CellRangeRepresentation"), -1, uno::makeAny( C2U("all") ), + beans::PropertyState_DIRECT_VALUE ); + aArguments[1] = beans::PropertyValue( + C2U("DataRowSource"), -1, uno::makeAny( eSeriesSource ), + beans::PropertyState_DIRECT_VALUE ); + aArguments[2] = beans::PropertyValue( + C2U("FirstCellAsLabel"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + aArguments[3] = beans::PropertyValue( + C2U("HasCategories"), -1, uno::makeAny( true ), beans::PropertyState_DIRECT_VALUE ); + + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + if( xDocDataArray.is()) + { + // we have an internal data provider that supports the XChartDataArray + // interface + xDocDataArray->setData( xDataArray->getData()); + xDocDataArray->setRowDescriptions( xDataArray->getRowDescriptions()); + xDocDataArray->setColumnDescriptions( xDataArray->getColumnDescriptions()); + + xSource.set( xDataProvider->createDataSource( aArguments )); + } + else + { + uno::Reference< chart2::data::XDataReceiver > xReceiver( xChartDoc, uno::UNO_QUERY ); + OSL_ASSERT( xChartDoc.is()); + OSL_ASSERT( xReceiver.is()); + OSL_ASSERT( xDataArray.is()); + if( ! (xChartDoc.is() && + xReceiver.is())) + return; + + // create a data provider containing the new data + Reference< chart2::data::XDataProvider > xTempDataProvider( + ChartModelHelper::createInternalDataProvider( xDataArray )); + + if( ! xTempDataProvider.is()) + throw uno::RuntimeException( C2U("Couldn't create temporary data provider"), + static_cast< ::cppu::OWeakObject * >( this )); + + // removes existing data provider and attaches the new one + xReceiver->attachDataProvider( xTempDataProvider ); + xSource.set( xTempDataProvider->createDataSource( aArguments)); + } + + // determine a template + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram()); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDia, xFact ); + OUString aServiceName( aTemplateAndService.second ); + Reference< chart2::XChartTypeTemplate > xTemplate = aTemplateAndService.first; + + // (fall-back) + if( ! xTemplate.is()) + { + if( aServiceName.getLength() == 0 ) + aServiceName = C2U("com.sun.star.chart2.template.Column"); + xTemplate.set( xFact->createInstance( aServiceName ), uno::UNO_QUERY ); + } + OSL_ASSERT( xTemplate.is()); + + if( xTemplate.is() && xSource.is()) + { + // argument detection works with internal knowledge of the + // ArrayDataProvider + OSL_ASSERT( xDia.is()); + xTemplate->changeDiagramData( + xDia, xSource, aArguments ); + } + + // should do nothing if we already have an internal data provider + xChartDoc->createInternalDataProvider( sal_True /* bCloneExistingData */ ); + + //correct stacking mode + if( bStacked || bPercent || bDeep ) + { + StackMode eStackMode = StackMode_Y_STACKED; + if( bDeep ) + eStackMode = StackMode_Z_STACKED; + else if( bPercent ) + eStackMode = StackMode_Y_STACKED_PERCENT; + DiagramHelper::setStackMode( xDia, eStackMode ); + } + + m_xChartData = xData; + // \-- locked controllers +} + +// ____ XModel ____ +sal_Bool SAL_CALL ChartDocumentWrapper::attachResource( + const ::rtl::OUString& URL, + const Sequence< beans::PropertyValue >& Arguments ) + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->attachResource( URL, Arguments ); + return sal_False; +} + +::rtl::OUString SAL_CALL ChartDocumentWrapper::getURL() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->getURL(); + return ::rtl::OUString(); +} + +Sequence< beans::PropertyValue > SAL_CALL ChartDocumentWrapper::getArgs() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->getArgs(); + return Sequence< beans::PropertyValue >(); +} + +void SAL_CALL ChartDocumentWrapper::connectController( const Reference< frame::XController >& Controller ) + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->connectController( Controller ); +} + +void SAL_CALL ChartDocumentWrapper::disconnectController( + const Reference< frame::XController >& Controller ) + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->disconnectController( Controller ); +} + +void SAL_CALL ChartDocumentWrapper::lockControllers() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->lockControllers(); +} + +void SAL_CALL ChartDocumentWrapper::unlockControllers() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->unlockControllers(); +} + +sal_Bool SAL_CALL ChartDocumentWrapper::hasControllersLocked() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->hasControllersLocked(); + return sal_False; +} + +Reference< frame::XController > SAL_CALL ChartDocumentWrapper::getCurrentController() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->getCurrentController(); + return 0; +} + +void SAL_CALL ChartDocumentWrapper::setCurrentController( + const Reference< frame::XController >& Controller ) + throw (container::NoSuchElementException, + uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->setCurrentController( Controller ); +} + +Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::getCurrentSelection() + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + return xModel->getCurrentSelection(); + return 0; +} + + +// ____ XComponent ____ +void SAL_CALL ChartDocumentWrapper::dispose() + throw (uno::RuntimeException) +{ + if( m_bIsDisposed ) + throw lang::DisposedException( + C2U("ChartDocumentWrapper is disposed" ), + static_cast< ::cppu::OWeakObject* >( this )); + + m_bIsDisposed = true; + + try + { + Reference< lang::XComponent > xFormerDelegator( m_xDelegator, uno::UNO_QUERY ); + DisposeHelper::DisposeAndClear( m_xTitle ); + DisposeHelper::DisposeAndClear( m_xSubTitle ); + DisposeHelper::DisposeAndClear( m_xLegend ); + DisposeHelper::DisposeAndClear( m_xChartData ); + DisposeHelper::DisposeAndClear( m_xDiagram ); + DisposeHelper::DisposeAndClear( m_xArea ); + m_xChartView.set( 0 ); + m_xShapeFactory.set( 0 ); + m_xDelegator.set( 0 ); + + clearWrappedPropertySet(); + m_spChart2ModelContact->clear(); + impl_resetAddIn(); + + stopAllComponentListening(); + + try + { + if( xFormerDelegator.is()) + xFormerDelegator->dispose(); + } + catch( lang::DisposedException ) + { + // this is ok, don't panic + } + } + catch( uno::Exception &ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void ChartDocumentWrapper::impl_resetAddIn() +{ + Reference< util::XRefreshable > xAddIn( m_xAddIn ); + m_xAddIn.set( 0 ); + + if( xAddIn.is() ) + { + try + { + //make sure that the add-in does not hold a refernce to us anymore: + Reference< lang::XComponent > xComp( xAddIn, uno::UNO_QUERY ); + if( xComp.is()) + xComp->dispose(); + else + { + uno::Reference< lang::XInitialization > xInit( xAddIn, uno::UNO_QUERY ); + if( xInit.is() ) + { + uno::Any aParam; + uno::Reference< com::sun::star::chart::XChartDocument > xDoc( 0 ); + aParam <<= xDoc; + uno::Sequence< uno::Any > aSeq( &aParam, 1 ); + xInit->initialize( aSeq ); + } + } + } + catch( const uno::RuntimeException& ex ) + { + ASSERT_EXCEPTION( ex ); + } + catch( const uno::Exception& ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +void ChartDocumentWrapper::setBaseDiagram( const rtl::OUString& rBaseDiagram ) +{ + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + m_aBaseDiagram = rBaseDiagram; + + uno::Reference< XDiagram > xDiagram( ChartDocumentWrapper::createInstance( rBaseDiagram ), uno::UNO_QUERY ); + if( xDiagram.is() ) + this->setDiagram( xDiagram ); +} + +rtl::OUString ChartDocumentWrapper::getBaseDiagram() const +{ + return m_aBaseDiagram; +} + +Reference< util::XRefreshable > ChartDocumentWrapper::getAddIn() const +{ + return m_xAddIn; +} + +void ChartDocumentWrapper::setAddIn( const Reference< util::XRefreshable >& xAddIn ) +{ + if( m_xAddIn == xAddIn ) + return; + + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + impl_resetAddIn(); + m_xAddIn = xAddIn; + // initialize AddIn with this as chart document + uno::Reference< lang::XInitialization > xInit( m_xAddIn, uno::UNO_QUERY ); + if( xInit.is() ) + { + uno::Any aParam; + uno::Reference< XChartDocument > xDoc( (XChartDocument*)this, uno::UNO_QUERY ); + aParam <<= xDoc; + uno::Sequence< uno::Any > aSeq( &aParam, 1 ); + xInit->initialize( aSeq ); + } +} + +void ChartDocumentWrapper::setUpdateAddIn( sal_Bool bUpdateAddIn ) +{ + m_bUpdateAddIn = bUpdateAddIn; +} +sal_Bool ChartDocumentWrapper::getUpdateAddIn() const +{ + return m_bUpdateAddIn; +} + +Reference< drawing::XShapes > ChartDocumentWrapper::getAdditionalShapes() const +{ + // get additional non-chart shapes for XML export + uno::Reference< drawing::XShapes > xFoundShapes; + uno::Reference< drawing::XDrawPage > xDrawPage( this->impl_getDrawPage() ); + + uno::Reference< drawing::XShapes > xDrawPageShapes( xDrawPage, uno::UNO_QUERY ); + if( !xDrawPageShapes.is() ) + return xFoundShapes; + + uno::Reference<drawing::XShapes> xChartRoot( DrawModelWrapper::getChartRootShape( xDrawPage ) ); + + // iterate 'flat' over all top-level objects + // and determine all that are no chart objects + ::std::vector< uno::Reference< drawing::XShape > > aShapeVector; + sal_Int32 nSubCount = xDrawPageShapes->getCount(); + uno::Reference< drawing::XShape > xShape; + for( sal_Int32 nS = 0; nS < nSubCount; nS++ ) + { + if( xDrawPageShapes->getByIndex( nS ) >>= xShape ) + { + if( xShape.is() && xChartRoot!=xShape ) + aShapeVector.push_back( xShape ); + } + } + + if( !aShapeVector.empty() ) + { + // create a shape collection + xFoundShapes = uno::Reference< drawing::XShapes >( SvxShapeCollection_NewInstance(), uno::UNO_QUERY ); + + DBG_ASSERT( xFoundShapes.is(), "Couldn't create a shape collection!" ); + if( xFoundShapes.is()) + { + ::std::vector< uno::Reference< drawing::XShape > >::iterator aIter; + for( aIter = aShapeVector.begin(); aIter != aShapeVector.end(); ++aIter ) + xFoundShapes->add( *aIter ); + } + } + + return xFoundShapes; +} + +void SAL_CALL ChartDocumentWrapper::addEventListener( const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->addEventListener( xListener ); +} + +void SAL_CALL ChartDocumentWrapper::removeEventListener( const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + Reference< frame::XModel > xModel( m_spChart2ModelContact->getChartModel() ); + if( xModel.is() ) + xModel->removeEventListener( aListener ); +} + +// ____ XDrawPageSupplier ____ +uno::Reference< drawing::XDrawPage > SAL_CALL ChartDocumentWrapper::getDrawPage() + throw (uno::RuntimeException) +{ + return this->impl_getDrawPage(); +} + +uno::Reference< drawing::XDrawPage > ChartDocumentWrapper::impl_getDrawPage() const + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->getDrawPage(); +} + +// ____ XMultiServiceFactory ____ +uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstance( + const ::rtl::OUString& aServiceSpecifier ) + throw (uno::Exception, + uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xResult; + + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( !xChartDoc.is() ) + return xResult; + + bool bServiceFound = false; + tServiceNameMap & rMap = lcl_getStaticServiceNameMap(); + + tServiceNameMap::const_iterator aIt( rMap.find( aServiceSpecifier )); + if( aIt != rMap.end()) + { + bool bCreateDiagram = false; + uno::Reference< lang::XMultiServiceFactory > xManagerFact( + xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + uno::Reference< chart2::XChartTypeTemplate > xTemplate; + + switch( (*aIt).second ) + { + case SERVICE_NAME_AREA_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Area" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_BAR_DIAGRAM: + if( xManagerFact.is()) + { + // this is for bar and column (the latter is the default if + // no "Vertical=false" property was set) + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Column" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_DONUT_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Donut" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_LINE_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Line" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_NET_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Net" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_FILLED_NET_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.FilledNet" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + case SERVICE_NAME_PIE_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Pie" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_STOCK_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.StockLowHighClose" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + case SERVICE_NAME_XY_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.ScatterLineSymbol" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + + case SERVICE_NAME_BUBBLE_DIAGRAM: + if( xManagerFact.is()) + { + xTemplate.set( + xManagerFact->createInstance( + C2U( "com.sun.star.chart2.template.Bubble" )), uno::UNO_QUERY ); + bCreateDiagram = true; + } + break; + + case SERVICE_NAME_DASH_TABLE: + case SERVICE_NAME_GARDIENT_TABLE: + case SERVICE_NAME_HATCH_TABLE: + 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 ); + DBG_ASSERT( 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 ); + } + break; + + case SERVICE_NAME_NAMESPACE_MAP: +// xResult = svx::NamespaceMap_createInstance( aWhichIds, &m_pModel->GetPool() ); + break; + case SERVICE_NAME_EXPORT_GRAPHIC_RESOLVER: +// xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_WRITE )); + break; + case SERVICE_NAME_IMPORT_GRAPHIC_RESOLVER: +// xResult = static_cast< ::cppu::OWeakObject * >( new SvXMLGraphicHelper( GRAPHICHELPER_MODE_READ )); + break; + } + + if( bCreateDiagram && xTemplate.is() ) + { + try + { + uno::Reference< chart2::XDiagram > xDia( xChartDoc->getFirstDiagram()); + if( xDia.is()) + { + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + xTemplate->changeDiagram( xDia ); + // \-- locked controllers + } + else + { + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY )); + xDia.set( xTemplate->createDiagramByDataSource( + uno::Reference< chart2::data::XDataSource >(), + uno::Sequence< beans::PropertyValue >())); + xChartDoc->setFirstDiagram( xDia ); + // \-- locked controllers + } + + xResult = static_cast< ::cppu::OWeakObject* >( new DiagramWrapper( m_spChart2ModelContact )); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + bServiceFound = true; + } + else if( aServiceSpecifier.equals( CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME ) ) + { + Reference< lang::XUnoTunnel > xChartRenderer( new ChartRenderer( m_spChart2ModelContact->getChartModel() ) ); + xResult.set( xChartRenderer ); + bServiceFound = true; + } + else if( aServiceSpecifier.equals( C2U("com.sun.star.comp.chart2.DataSeriesWrapper") ) ) + { + Reference< beans::XPropertySet > xDataSeries( new DataSeriesPointWrapper( m_spChart2ModelContact ) ); + xResult.set( xDataSeries ); + bServiceFound = true; + } + else if( aServiceSpecifier.equals( CHART_VIEW_SERVICE_NAME ) ) + { + if( !m_xChartView.is() ) + { + Reference< lang::XMultiServiceFactory > xFact( + m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); + if( xFact.is() ) + { + Reference< lang::XInitialization > xViewInit( xFact->createInstance( + CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + if(xViewInit.is()) + { + try + { + m_xChartView = xViewInit; + + Sequence< Any > aArguments(2); + Reference<frame::XModel> xModel(this); + aArguments[0]=uno::makeAny(xModel); + sal_Bool bRefreshAddIn = sal_True; + aArguments[1]=uno::makeAny(bRefreshAddIn); + xViewInit->initialize(aArguments); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + xResult.set( m_xChartView ); + bServiceFound = true; + } + else + { + // try to create a shape + try + { + if( !m_xShapeFactory.is() && m_xChartView.is() ) + { + Reference< lang::XUnoTunnel> xUnoTunnel(m_xChartView,uno::UNO_QUERY); + if(xUnoTunnel.is()) + { + ExplicitValueProvider* pProvider = reinterpret_cast<ExplicitValueProvider*>(xUnoTunnel->getSomething( + ExplicitValueProvider::getUnoTunnelId() )); + if( pProvider ) + m_xShapeFactory.set( pProvider->getDrawModelWrapper()->getShapeFactory() ); + } + } + if( m_xShapeFactory.is() ) + { + xResult = m_xShapeFactory->createInstance( aServiceSpecifier ); + bServiceFound = true; + } + } + catch( const uno::Exception ) + { + // couldn't create shape + } + } + + // finally, try to create an addin + if( !bServiceFound ) + { + try + { + Reference< lang::XMultiServiceFactory > xFact( + m_spChart2ModelContact->m_xContext->getServiceManager(), uno::UNO_QUERY_THROW ); + if( xFact.is() ) + { + uno::Reference< util::XRefreshable > xAddIn( + xFact->createInstance( aServiceSpecifier ), uno::UNO_QUERY ); + if( xAddIn.is() ) + { + xResult = xAddIn; + bServiceFound = true; + } + } + } + catch( const uno::Exception& ex ) + { + (void)ex; + // couldn't create service + } + } + + return xResult; +} + +uno::Reference< uno::XInterface > SAL_CALL ChartDocumentWrapper::createInstanceWithArguments( + const ::rtl::OUString& ServiceSpecifier, + const uno::Sequence< uno::Any >& Arguments ) + throw (uno::Exception, + uno::RuntimeException) +{ + OSL_ENSURE( Arguments.getLength(), "createInstanceWithArguments: Warning: Arguments are ignored" ); + (void)(Arguments); + + return createInstance( ServiceSpecifier ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL ChartDocumentWrapper::getAvailableServiceNames() + throw (uno::RuntimeException) +{ + tServiceNameMap & rMap = lcl_getStaticServiceNameMap(); + uno::Sequence< ::rtl::OUString > aResult( rMap.size()); + + ::std::transform( rMap.begin(), rMap.end(), + aResult.getArray(), + ::std::select1st< tServiceNameMap::value_type >() ); + + return aResult; + +// // shapes +// // uno::Sequence< OUString > aDrawServices( SvxUnoDrawMSFactory::getAvailableServiceNames() ); +// // const OUString * pArr = aDrawServices.getConstArray(); +// // aServices.insert( aServices.end(), pArr, pArr + aDrawServices.getLength() ); +// } + + + // add-ins + // uno::Sequence< OUString > aAddIns( GetAddInCollection().GetAddInNames() ); +// pArr = aAddIns.getConstArray(); +// aServices.insert( aServices.end(), pArr, pArr + aAddIns.getLength() ); + +// return ContainerToSequence( aServices ); +} + +// ____ XAggregation ____ +void SAL_CALL ChartDocumentWrapper::setDelegator( + const uno::Reference< uno::XInterface >& rDelegator ) + throw (uno::RuntimeException) +{ + if( rDelegator.is()) + { + m_xDelegator = rDelegator; + m_spChart2ModelContact->setModel( uno::Reference< frame::XModel >(m_xDelegator, uno::UNO_QUERY) ); + } + else + { + // this is a sort of dispose() from the new model,so release ressources here + try + { + this->dispose(); + } + catch( uno::Exception &ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +uno::Any SAL_CALL ChartDocumentWrapper::queryAggregation( const uno::Type& rType ) + throw (uno::RuntimeException) +{ + return ChartDocumentWrapper_Base::queryInterface( rType ); +} + +// ____ ::utl::OEventListenerAdapter ____ +void ChartDocumentWrapper::_disposing( const lang::EventObject& rSource ) +{ + if( rSource.Source == m_xTitle ) + m_xTitle.set( 0 ); + else if( rSource.Source == m_xSubTitle ) + m_xSubTitle.set( 0 ); + else if( rSource.Source == m_xLegend ) + m_xLegend.set( 0 ); + else if( rSource.Source == m_xChartData ) + m_xChartData.set( 0 ); + else if( rSource.Source == m_xDiagram ) + m_xDiagram.set( 0 ); + else if( rSource.Source == m_xArea ) + m_xArea.set( 0 ); + else if( rSource.Source == m_xAddIn ) + m_xAddIn.set( 0 ); + else if( rSource.Source == m_xChartView ) + m_xChartView.set( 0 ); +} + +// ================================================================================ + +// WrappedPropertySet +Reference< beans::XPropertySet > ChartDocumentWrapper::getInnerPropertySet() +{ + return 0; +} +const Sequence< beans::Property >& ChartDocumentWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > ChartDocumentWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstRowProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedDataSourceLabelsInFirstColumnProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedHasLegendProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedHasMainTitleProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedHasSubTitleProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedAddInProperty( *this ) ); + aWrappedProperties.push_back( new WrappedBaseDiagramProperty( *this ) ); + aWrappedProperties.push_back( new WrappedAdditionalShapesProperty( *this ) ); + aWrappedProperties.push_back( new WrappedRefreshAddInAllowedProperty( *this ) ); + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U("NullDate"),Any() ) ); // i99104 + + return aWrappedProperties; +} + +// ================================================================================ + +uno::Sequence< ::rtl::OUString > ChartDocumentWrapper::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDocument" ); + aServices[ 1 ] = CHART_CHARTAPIWRAPPER_SERVICE_NAME; + aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ChartDocumentWrapper, CHART_CHARTAPIWRAPPER_IMPLEMENTATION_NAME ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx new file mode 100644 index 000000000000..ce417155dc4f --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.cxx @@ -0,0 +1,890 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataSeriesPointWrapper.cxx,v $ + * $Revision: 1.15.44.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DataSeriesPointWrapper.hxx" +#include "macros.hxx" +#include "RegressionCurveHelper.hxx" +#include "Chart2ModelContact.hxx" +#include "ChartTypeHelper.hxx" +#include "DiagramHelper.hxx" +#include "ContainerHelper.hxx" +#include "ChartModelHelper.hxx" +#include "LineProperties.hxx" +#include "FillProperties.hxx" +#include "CharacterProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedCharacterHeightProperty.hxx" +#include "WrappedProperty.hxx" +#include "WrappedIgnoreProperty.hxx" +#include "WrappedStatisticProperties.hxx" +#include "WrappedSymbolProperties.hxx" +#include "WrappedDataCaptionProperties.hxx" +#include "WrappedSeriesAreaOrLineProperty.hxx" +#include "WrappedScaleTextProperties.hxx" +#include "WrappedNumberFormatProperty.hxx" +#include "WrappedTextRotationProperty.hxx" +#include <rtl/ustrbuf.hxx> +#include <rtl/math.hxx> +// header for define DBG_ASSERT +#include <tools/debug.hxx> + +#include <algorithm> +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart/ChartAxisAssign.hpp> +#include <com/sun/star/chart/ChartErrorCategory.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> + +using namespace ::com::sun::star; +using namespace ::chart::wrapper; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::com::sun::star::uno::Any; +using ::osl::MutexGuard; + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.DataSeries" )); + +enum +{ + //data point properties + PROP_SERIES_DATAPOINT_SOLIDTYPE, + PROP_SERIES_DATAPOINT_SEGMENT_OFFSET, + PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL, + PROP_SERIES_DATAPOINT_LABEL_SEPARATOR, + PROP_SERIES_NUMBERFORMAT, + PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE, + PROP_SERIES_PERCENTAGE_NUMBERFORMAT, + PROP_SERIES_DATAPOINT_LABEL_PLACEMENT, + //other series properties + PROP_SERIES_ATTACHED_AXIS, + PROP_SERIES_DATAPOINT_TEXT_ROTATION +}; + +void lcl_AddPropertiesToVector_PointProperties( + ::std::vector< Property > & rOutProperties ) +{ + //service chart::Chart3DBarProperties + rOutProperties.push_back( + Property( C2U( "SolidType" ), + PROP_SERIES_DATAPOINT_SOLIDTYPE, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "SegmentOffset" ), + PROP_SERIES_DATAPOINT_SEGMENT_OFFSET, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "D3DPercentDiagonal" ), + PROP_SERIES_DATAPOINT_PERCENT_DIAGONAL, + ::getCppuType( reinterpret_cast< sal_Int16 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "LabelSeparator" ), + PROP_SERIES_DATAPOINT_LABEL_SEPARATOR, + ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "NumberFormat" ), + PROP_SERIES_NUMBERFORMAT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "PercentageNumberFormat" ), + PROP_SERIES_PERCENTAGE_NUMBERFORMAT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "LabelPlacement" ), + PROP_SERIES_DATAPOINT_LABEL_PLACEMENT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "TextRotation" ), + PROP_SERIES_DATAPOINT_TEXT_ROTATION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +void lcl_AddPropertiesToVector_SeriesOnly( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Axis" ), + PROP_SERIES_ATTACHED_AXIS, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "LinkNumberFormatToSource" ), + PROP_SERIES_LINK_NUMBERFORMAT_TO_SOURCE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence( DataSeriesPointWrapper::eType _eType ) +{ + static uno::Sequence< Property > aSeriesPropSeq; + static uno::Sequence< Property > aPointPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + uno::Sequence< Property >& rPropSeq = + (_eType == DataSeriesPointWrapper::DATA_SERIES) ? aSeriesPropSeq : aPointPropSeq; + if( 0 == rPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + + lcl_AddPropertiesToVector_PointProperties( aProperties ); + if( _eType == DataSeriesPointWrapper::DATA_SERIES ) + { + lcl_AddPropertiesToVector_SeriesOnly( aProperties ); + WrappedStatisticProperties::addProperties( aProperties ); + } + WrappedSymbolProperties::addProperties( aProperties ); //for series and points + WrappedDataCaptionProperties::addProperties( aProperties ); //for series and points + + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + rPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return rPropSeq; +} + +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- + +//PROP_SERIES_ATTACHED_AXIS +class WrappedAttachedAxisProperty : public ::chart::WrappedProperty +{ +public: + WrappedAttachedAxisProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedAttachedAxisProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +protected: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedAttachedAxisProperty::WrappedAttachedAxisProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("Axis"),rtl::OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedAttachedAxisProperty::~WrappedAttachedAxisProperty() +{ +} + +Any WrappedAttachedAxisProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y; + return aRet; +} + +Any WrappedAttachedAxisProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + + uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + bool bAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + if( bAttachedToMainAxis ) + aRet <<= ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y; + else + aRet <<= ::com::sun::star::chart::ChartAxisAssign::SECONDARY_Y; + return aRet; +} + +void WrappedAttachedAxisProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Reference< chart2::XDataSeries > xDataSeries( xInnerPropertySet, uno::UNO_QUERY ); + + sal_Int32 nChartAxisAssign = ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y; + if( ! (rOuterValue >>= nChartAxisAssign) ) + throw lang::IllegalArgumentException( C2U("Property Axis requires value of type sal_Int32"), 0, 0 ); + + bool bNewAttachedToMainAxis = nChartAxisAssign == ::com::sun::star::chart::ChartAxisAssign::PRIMARY_Y; + bool bOldAttachedToMainAxis = ::chart::DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + + if( bNewAttachedToMainAxis != bOldAttachedToMainAxis) + { + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + ::chart::DiagramHelper::attachSeriesToAxis( bNewAttachedToMainAxis, xDataSeries, xDiagram, m_spChart2ModelContact->m_xContext ); + } +} + +//---------------------------------------------------------------------------------------------------------------------- + +class WrappedSegmentOffsetProperty : public ::chart::WrappedProperty +{ +public: + WrappedSegmentOffsetProperty(); + virtual ~WrappedSegmentOffsetProperty(); + +protected: + virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const; + virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const; +}; + +WrappedSegmentOffsetProperty::WrappedSegmentOffsetProperty() : + WrappedProperty( C2U( "SegmentOffset" ), C2U( "Offset" ) ) +{} + +WrappedSegmentOffsetProperty::~WrappedSegmentOffsetProperty() +{} + +Any WrappedSegmentOffsetProperty::convertInnerToOuterValue( const Any& rInnerValue ) const +{ + // convert new double offset to former integer segment-offset + double fOffset = 0; + Any aResult( rInnerValue ); + + if( rInnerValue >>= fOffset ) + aResult <<= static_cast< sal_Int32 >( ::rtl::math::round( fOffset * 100.0 )); + + return aResult; +} + +Any WrappedSegmentOffsetProperty::convertOuterToInnerValue( const Any& rOuterValue ) const +{ + // convert former integer segment-offset to new double offset + sal_Int32 nOffset = 0; + Any aResult( rOuterValue ); + + if( rOuterValue >>= nOffset ) + aResult <<= (static_cast< double >( nOffset ) / 100.0); + + return aResult; +} + +//---------------------------------------------------------------------------------------------------------------------- + +class WrappedLineColorProperty : public WrappedSeriesAreaOrLineProperty +{ +public: + WrappedLineColorProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper ); + virtual ~WrappedLineColorProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +protected: + DataSeriesPointWrapper* m_pDataSeriesPointWrapper; + mutable Any m_aDefaultValue; + mutable Any m_aOuterValue; +}; + +WrappedLineColorProperty::WrappedLineColorProperty( + DataSeriesPointWrapper* pDataSeriesPointWrapper ) + : WrappedSeriesAreaOrLineProperty(C2U( "LineColor" ), C2U( "BorderColor" ), C2U( "Color" ), pDataSeriesPointWrapper ) + , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) + , m_aDefaultValue(uno::makeAny(sal_Int32( 0x0099ccff ))) // blue 8 + , m_aOuterValue(m_aDefaultValue) +{ +} + +WrappedLineColorProperty::~WrappedLineColorProperty() +{ +} + +void WrappedLineColorProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() ) + m_aOuterValue = rOuterValue; + else + WrappedSeriesAreaOrLineProperty::setPropertyValue( rOuterValue, xInnerPropertySet ); +} + +void WrappedLineColorProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() ) + m_aOuterValue = m_aDefaultValue; + else + WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState ); +} + +Any WrappedLineColorProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( m_pDataSeriesPointWrapper && !m_pDataSeriesPointWrapper->isSupportingAreaProperties() ) + return m_aDefaultValue; + else + return WrappedSeriesAreaOrLineProperty::getPropertyDefault( xInnerPropertyState ); +} + +//---------------------------------------------------------------------------------------------------------------------- + +class WrappedLineStyleProperty : public WrappedSeriesAreaOrLineProperty +{ +public: + WrappedLineStyleProperty( DataSeriesPointWrapper* pDataSeriesPointWrapper ); + virtual ~WrappedLineStyleProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void setPropertyToDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + +protected: + DataSeriesPointWrapper* m_pDataSeriesPointWrapper; + mutable Any m_aDefaultValue; + mutable Any m_aOuterValue; +}; + +WrappedLineStyleProperty::WrappedLineStyleProperty( + DataSeriesPointWrapper* pDataSeriesPointWrapper ) + : WrappedSeriesAreaOrLineProperty(C2U( "LineStyle" ), C2U( "BorderStyle" ), C2U( "LineStyle" ), pDataSeriesPointWrapper ) + , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) + , m_aDefaultValue(uno::makeAny(drawing::LineStyle_SOLID)) + , m_aOuterValue(m_aDefaultValue) +{ +} + +WrappedLineStyleProperty::~WrappedLineStyleProperty() +{ +} + +void WrappedLineStyleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aNewValue(rOuterValue); + if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() ) + { + m_aOuterValue = rOuterValue; + aNewValue = uno::makeAny(drawing::LineStyle_NONE); + } + WrappedSeriesAreaOrLineProperty::setPropertyValue( aNewValue, xInnerPropertySet ); +} + +void WrappedLineStyleProperty::setPropertyToDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException) +{ + if( m_pDataSeriesPointWrapper && m_pDataSeriesPointWrapper->isLinesForbidden() ) + m_aOuterValue = m_aDefaultValue; + else + WrappedSeriesAreaOrLineProperty::setPropertyToDefault( xInnerPropertyState ); +} + +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +DataSeriesPointWrapper::DataSeriesPointWrapper( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : m_spChart2ModelContact( spChart2ModelContact ) + , m_aEventListenerContainer( m_aMutex ) + , m_eType( DATA_SERIES ) + , m_nSeriesIndexInNewAPI( -1 ) + , m_nPointIndex( -1 ) + , m_bLinesAllowed(sal_True) + , m_xDataSeries(0) +{ + //need initialize call afterwards +} + +void SAL_CALL DataSeriesPointWrapper::initialize( const uno::Sequence< uno::Any >& aArguments ) + throw ( uno::Exception, uno::RuntimeException) +{ + DBG_ASSERT(aArguments.getLength() >= 1,"need at least 1 argument to initialize the DataSeriesPointWrapper: series reference + optional datapoint index"); + + m_nSeriesIndexInNewAPI = -1;//ignored in this case + m_nPointIndex = -1; + if( aArguments.getLength() >= 1 ) + { + aArguments[0] >>= m_xDataSeries; + if( aArguments.getLength() >= 2 ) + aArguments[1] >>= m_nPointIndex; + } + + if( !m_xDataSeries.is() ) + throw uno::Exception( + C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this )); + + //todo: check upper border of point index + + if( m_nPointIndex >= 0 ) + m_eType = DATA_POINT; + else + m_eType = DATA_SERIES; +} + +DataSeriesPointWrapper::DataSeriesPointWrapper( eType _eType + , sal_Int32 nSeriesIndexInNewAPI + , sal_Int32 nPointIndex //ignored for series + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : m_spChart2ModelContact( spChart2ModelContact ) + , m_aEventListenerContainer( m_aMutex ) + , m_eType( _eType ) + , m_nSeriesIndexInNewAPI( nSeriesIndexInNewAPI ) + , m_nPointIndex( (_eType == DATA_POINT) ? nPointIndex : -1 ) + , m_xDataSeries(0) +{ +} + +DataSeriesPointWrapper::~DataSeriesPointWrapper() +{ +} + +// ____ XComponent ____ +void SAL_CALL DataSeriesPointWrapper::dispose() + throw (uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + m_xDataSeries.clear(); + clearWrappedPropertySet(); +} + +void SAL_CALL DataSeriesPointWrapper::addEventListener( + const uno::Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL DataSeriesPointWrapper::removeEventListener( + const uno::Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ____ XEventListener ____ +void SAL_CALL DataSeriesPointWrapper::disposing( const lang::EventObject& /*Source*/ ) + throw (uno::RuntimeException) +{ +} + +// ================================================================================ + +bool DataSeriesPointWrapper::isSupportingAreaProperties() +{ + Reference< chart2::XDataSeries > xSeries( this->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 ); +} + +bool DataSeriesPointWrapper::isLinesForbidden() +{ + return !m_bLinesAllowed; +} + +Reference< chart2::XDataSeries > DataSeriesPointWrapper::getDataSeries() +{ + Reference< chart2::XDataSeries > xSeries( m_xDataSeries ); + if( !xSeries.is() ) + { + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( + ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + + if( m_nSeriesIndexInNewAPI >= 0 && m_nSeriesIndexInNewAPI < static_cast<sal_Int32>(aSeriesList.size()) ) + xSeries = aSeriesList[m_nSeriesIndexInNewAPI]; + } + + return xSeries; +} + +Reference< beans::XPropertySet > DataSeriesPointWrapper::getDataPointProperties() +{ + Reference< beans::XPropertySet > xPointProp; + + Reference< chart2::XDataSeries > xSeries( this->getDataSeries() ); + + // may throw an IllegalArgumentException + if( xSeries.is() ) + xPointProp = xSeries->getDataPointByIndex( m_nPointIndex ); + + return xPointProp; +} + +// ================================================================================ + +//ReferenceSizePropertyProvider +void DataSeriesPointWrapper::updateReferenceSize() +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); + if( xProp.is() ) + { + if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) + xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( + m_spChart2ModelContact->GetPageSize() )); + } +} +Any DataSeriesPointWrapper::getReferenceSize() +{ + Any aRet; + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); + if( xProp.is() ) + aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); + return aRet; +} +awt::Size DataSeriesPointWrapper::getCurrentSizeForReference() +{ + return m_spChart2ModelContact->GetPageSize(); +} + +// ================================================================================ + +// WrappedPropertySet + +//XPropertyState +beans::PropertyState SAL_CALL DataSeriesPointWrapper::getPropertyState( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); + + if( m_eType == DATA_SERIES ) + aState = WrappedPropertySet::getPropertyState( rPropertyName ); + else + { + if( rPropertyName.equals(C2U("FillColor")) ) + { + Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + sal_Bool bVaryColorsByPoint = sal_False; + if( xSeriesProp.is() && (xSeriesProp->getPropertyValue( C2U("VaryColorsByPoint") ) >>= bVaryColorsByPoint) + && bVaryColorsByPoint ) + return beans::PropertyState_DIRECT_VALUE; + } + else if( rPropertyName.equals(C2U("Lines")) + || rPropertyName.equals(C2U("SymbolType")) + || rPropertyName.equals(C2U("SymbolSize")) ) + return WrappedPropertySet::getPropertyState( rPropertyName ); + + uno::Any aDefault( getPropertyDefault( rPropertyName ) ); + uno::Any aValue( getPropertyValue( rPropertyName ) ); + if( aDefault==aValue ) + aState = beans::PropertyState_DEFAULT_VALUE; + } + return aState; +} + +void SAL_CALL DataSeriesPointWrapper::setPropertyToDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + if( m_eType == DATA_SERIES ) + WrappedPropertySet::setPropertyToDefault( rPropertyName ); + else + { + //for data points the default is given by the series + setPropertyValue( rPropertyName, getPropertyDefault( rPropertyName ) ); + } +} +Any SAL_CALL DataSeriesPointWrapper::getPropertyDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + try + { + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( nHandle > 0 ) + { + //always take the series current value as default for points + Reference< beans::XPropertySet > xInnerPropertySet( getDataSeries(), uno::UNO_QUERY ); + if( xInnerPropertySet.is() ) + { + const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); + if( pWrappedProperty ) + aRet = pWrappedProperty->getPropertyValue(xInnerPropertySet); + else + aRet = xInnerPropertySet->getPropertyValue( rPropertyName ); + } + } + } + catch( beans::UnknownPropertyException& ex ) + { + (void)(ex); + aRet = WrappedPropertySet::getPropertyDefault( rPropertyName ); + } + return aRet; +} + +Reference< beans::XPropertySet > DataSeriesPointWrapper::getInnerPropertySet() +{ + if( m_eType == DATA_SERIES ) + return Reference< beans::XPropertySet >( getDataSeries(), uno::UNO_QUERY ); + return getDataPointProperties(); +} + +const Sequence< beans::Property >& DataSeriesPointWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence( m_eType ); +} + +const std::vector< WrappedProperty* > DataSeriesPointWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); + + if( m_eType == DATA_SERIES ) + { + WrappedStatisticProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact ); + aWrappedProperties.push_back( new WrappedAttachedAxisProperty( m_spChart2ModelContact ) ); + + WrappedNumberFormatProperty* pWrappedNumberFormatProperty = new WrappedNumberFormatProperty( m_spChart2ModelContact ); + aWrappedProperties.push_back( pWrappedNumberFormatProperty ); + aWrappedProperties.push_back( new WrappedLinkNumberFormatProperty(pWrappedNumberFormatProperty) ); + } + + WrappedSymbolProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact ); + WrappedDataCaptionProperties::addWrappedPropertiesForSeries( aWrappedProperties, m_spChart2ModelContact ); + WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + + //add unnamed fill properties (different inner names here) +// aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillGradient" ), C2U( "GradientName" ) ) ); +// aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillHatch" ), C2U( "HatchName" ) ) ); +// aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "FillTransparenceGradient" ), C2U( "TransparencyGradientName" ) ) ); + + //add unnamed line properties (different inner names here) +// aWrappedProperties.push_back( new WrappedUnnamedProperty( C2U( "LineDash" ), C2U( "LineDashName" ) ) ); + + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillColor" ), C2U( "Color" ) ) ); + aWrappedProperties.push_back( new WrappedLineStyleProperty( this ) ); + aWrappedProperties.push_back( new WrappedLineColorProperty( this ) ); + aWrappedProperties.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineDashName" ), C2U( "BorderDashName" ), C2U( "LineDashName" ), this ) ); + aWrappedProperties.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineTransparence" ), C2U( "BorderTransparency" ), C2U( "Transparency" ), this ) ); + aWrappedProperties.push_back( new WrappedSeriesAreaOrLineProperty( C2U( "LineWidth" ), C2U( "BorderWidth" ), C2U( "LineWidth" ), this ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillStyle" ), C2U( "FillStyle" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillTransparence" ), C2U( "Transparency" ) ) ); + + aWrappedProperties.push_back( new WrappedIgnoreProperty( C2U( "LineJoint" ), uno::makeAny( drawing::LineJoint_NONE ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillTransparenceGradientName" ), C2U( "TransparencyGradientName" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillGradientName" ), C2U( "GradientName" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillGradientStepCount" ), C2U( "GradientStepCount" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillHatchName" ), C2U( "HatchName" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapName" ), C2U( "FillBitmapName" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBackground" ), C2U( "FillBackground" ) ) ); + + //bitmap properties + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapMode" ), C2U( "FillBitmapMode" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapSizeX" ), C2U( "FillBitmapSizeX" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapSizeY" ), C2U( "FillBitmapSizeY" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapLogicalSize" ), C2U( "FillBitmapLogicalSize" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapOffsetX" ), C2U( "FillBitmapOffsetX" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapOffsetY" ), C2U( "FillBitmapOffsetY" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapRectanglePoint" ), C2U( "FillBitmapRectanglePoint" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapPositionOffsetX" ), C2U( "FillBitmapPositionOffsetX" ) ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "FillBitmapPositionOffsetY" ), C2U( "FillBitmapPositionOffsetY" ) ) ); + + aWrappedProperties.push_back( new WrappedProperty( C2U( "SolidType" ), C2U( "Geometry3D" ) ) ); + aWrappedProperties.push_back( new WrappedSegmentOffsetProperty() ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "D3DPercentDiagonal" ), C2U( "PercentDiagonal" ) ) ); + + aWrappedProperties.push_back( new WrappedTextRotationProperty() ); + + return aWrappedProperties; +} + +void SAL_CALL DataSeriesPointWrapper::setPropertyValue( const ::rtl::OUString& rPropertyName, const Any& rValue ) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if(rPropertyName.equals(C2U("Lines"))) + { + if( ! (rValue >>= m_bLinesAllowed) ) + throw lang::IllegalArgumentException( C2U("Property Lines requires value of type sal_Bool"), 0, 0 ); + } + + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + static const sal_Int32 nErrorCategoryHandle = getInfoHelper().getHandleByName( C2U("ErrorCategory") ); + if( nErrorCategoryHandle == nHandle ) + { + ::com::sun::star::chart::ChartErrorCategory aNewValue = ::com::sun::star::chart::ChartErrorCategory_NONE; + rValue >>= aNewValue; + Any aLow, aHigh; + bool bSetHighAndLowValues = false; + switch(aNewValue) + { + case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE: + aHigh = this->getPropertyValue(C2U("ConstantErrorHigh")); + aLow = this->getPropertyValue(C2U("ConstantErrorLow")); + bSetHighAndLowValues = true; + break; + case ::com::sun::star::chart::ChartErrorCategory_PERCENT: + aHigh = aLow = this->getPropertyValue(C2U("PercentageError")); + bSetHighAndLowValues = true; + break; + case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN: + aHigh = aLow = this->getPropertyValue(C2U("ErrorMargin")); + bSetHighAndLowValues = true; + break; + default: + break; + } + + WrappedPropertySet::setPropertyValue( rPropertyName, rValue ); + + if(bSetHighAndLowValues) + { + switch(aNewValue) + { + case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE: + this->setPropertyValue(C2U("ConstantErrorHigh"),aHigh); + this->setPropertyValue(C2U("ConstantErrorLow"),aLow); + break; + case ::com::sun::star::chart::ChartErrorCategory_PERCENT: + this->setPropertyValue(C2U("PercentageError"),aHigh); + break; + case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN: + this->setPropertyValue(C2U("ErrorMargin"),aHigh); + break; + default: + break; + } + } + } + else + WrappedPropertySet::setPropertyValue( rPropertyName, rValue ); +} + +Any SAL_CALL DataSeriesPointWrapper::getPropertyValue( const rtl::OUString& rPropertyName ) + throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( m_eType == DATA_POINT ) + { + if( rPropertyName.equals(C2U("FillColor")) ) + { + Reference< beans::XPropertySet > xSeriesProp( getDataSeries(), uno::UNO_QUERY ); + sal_Bool bVaryColorsByPoint = sal_False; + if( xSeriesProp.is() && (xSeriesProp->getPropertyValue( C2U("VaryColorsByPoint") ) >>= bVaryColorsByPoint) + && bVaryColorsByPoint ) + { + uno::Reference< beans::XPropertyState > xPointState( DataSeriesPointWrapper::getDataPointProperties(), uno::UNO_QUERY ); + if( xPointState.is() && xPointState->getPropertyState( C2U("Color")) == beans::PropertyState_DEFAULT_VALUE ) + { + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + Reference< chart2::XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() ); + if( xColorScheme.is() ) + return uno::makeAny( xColorScheme->getColorByIndex( m_nPointIndex ) ); + } + } + } + } + } + return WrappedPropertySet::getPropertyValue( rPropertyName ); +} + +// ================================================================================ + +uno::Sequence< ::rtl::OUString > DataSeriesPointWrapper::getSupportedServiceNames_Static() +{ + uno::Sequence< ::rtl::OUString > aServices( 7 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartDataRowProperties" ); + aServices[ 1 ] = C2U( "com.sun.star.chart.ChartDataPointProperties" ); + aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); + aServices[ 4 ] = C2U( "com.sun.star.drawing.FillProperties" ); + aServices[ 5 ] = C2U( "com.sun.star.drawing.LineProperties" ); + aServices[ 6 ] = C2U( "com.sun.star.style.CharacterProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( DataSeriesPointWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx new file mode 100644 index 000000000000..0e3b87605b77 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/DataSeriesPointWrapper.hxx @@ -0,0 +1,163 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataSeriesPointWrapper.hxx,v $ + * $Revision: 1.7.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_DATASERIESPOINTWRAPPER_HXX +#define CHART_DATASERIESPOINTWRAPPER_HXX + +#include "ServiceMacros.hxx" +#include "WrappedPropertySet.hxx" +#include "ReferenceSizePropertyProvider.hxx" +#include <cppuhelper/implbase4.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/frame/XModel.hpp> +#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 <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class DataSeriesPointWrapper : public ::cppu::ImplInheritanceHelper4< + WrappedPropertySet + , com::sun::star::lang::XServiceInfo + , com::sun::star::lang::XInitialization + , com::sun::star::lang::XComponent + , com::sun::star::lang::XEventListener + > + , public ReferenceSizePropertyProvider + +{ +public: + enum eType + { + DATA_SERIES, + DATA_POINT + }; + + //this constructor needs an initialize call afterwards + DataSeriesPointWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + + DataSeriesPointWrapper( eType eType + , sal_Int32 nSeriesIndexInNewAPI + , sal_Int32 nPointIndex //ignored for series + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + + virtual ~DataSeriesPointWrapper(); + + bool isSupportingAreaProperties(); + bool isLinesForbidden(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ___lang::XInitialization___ + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + //ReferenceSizePropertyProvider + virtual void updateReferenceSize(); + virtual ::com::sun::star::uno::Any getReferenceSize(); + virtual ::com::sun::star::awt::Size getCurrentSizeForReference(); + +protected: + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XEventListener ____ + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //own methods + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > getDataSeries(); + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getDataPointProperties(); + +private: + + void SAL_CALL getStatisticsPropertyValue + ( ::com::sun::star::uno::Any& rValue, + sal_Int32 nHandle ) const; + + void SAL_CALL setStatisticsPropertyValue_NoBroadcast( + sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + + // ---------------------------------------- + + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + eType m_eType; + sal_Int32 m_nSeriesIndexInNewAPI; + sal_Int32 m_nPointIndex; + + sal_Bool m_bLinesAllowed; + + //this should only be used, if the DataSeriesPointWrapper is initialized via the XInitialize interface + //because a big change in the chartmodel may leed to an dataseriespointer thats not connected to the model anymore + //with the indizes instead we are can aleays get the new dataseries + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > m_xDataSeries; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_DATASERIESPOINTWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx new file mode 100644 index 000000000000..4a02d9aa99e5 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.cxx @@ -0,0 +1,2116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DiagramWrapper.cxx,v $ + * $Revision: 1.17.32.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DiagramWrapper.hxx" +#include "macros.hxx" +#include "servicenames_charttypes.hxx" +#include "TitleWrapper.hxx" +#include "DataSeriesPointWrapper.hxx" +#include "AxisWrapper.hxx" +#include "AxisHelper.hxx" +#include "Chart2ModelContact.hxx" +#include "PositionAndSizeHelper.hxx" +#include "TitleHelper.hxx" +#include "GridWrapper.hxx" +#include "WallFloorWrapper.hxx" +#include "MinMaxLineWrapper.hxx" +#include "UpDownBarWrapper.hxx" +#include "DiagramHelper.hxx" +#include "DataSourceHelper.hxx" +#include "ChartModelHelper.hxx" +#include "WrappedIgnoreProperty.hxx" +#include "WrappedAxisAndGridExistenceProperties.hxx" +#include "WrappedStatisticProperties.hxx" +#include "WrappedSymbolProperties.hxx" +#include "WrappedDataCaptionProperties.hxx" +#include "WrappedSplineProperties.hxx" +#include "WrappedStockProperties.hxx" +#include "WrappedSceneProperty.hxx" +#include "RelativePositionHelper.hxx" +#include "ContainerHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "ModifyListenerHelper.hxx" +#include "DisposeHelper.hxx" +#include <comphelper/InlineContainer.hxx> +#include "WrappedAutomaticPositionProperties.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart2/XTitled.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/chart/ChartSolidType.hpp> + +#include "LineProperties.hxx" +#include "FillProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "SceneProperties.hxx" + +#include <map> +#include <algorithm> +#include <rtl/ustrbuf.hxx> +// header for define DBG_ERROR +#include <tools/debug.hxx> +#include <com/sun/star/lang/XServiceName.hpp> +#include <com/sun/star/util/XRefreshable.hpp> + +using namespace ::com::sun::star; +using namespace ::chart::wrapper; + +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 ::osl::MutexGuard; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Diagram" )); + +enum +{ + PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, + PROP_DIAGRAM_PERCENT_STACKED, + PROP_DIAGRAM_STACKED, + PROP_DIAGRAM_THREE_D, + PROP_DIAGRAM_SOLIDTYPE, + PROP_DIAGRAM_DEEP, + PROP_DIAGRAM_VERTICAL, + PROP_DIAGRAM_NUMBER_OF_LINES, + PROP_DIAGRAM_STACKED_BARS_CONNECTED, + PROP_DIAGRAM_DATAROW_SOURCE, + + PROP_DIAGRAM_GROUP_BARS_PER_AXIS, + PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, + + PROP_DIAGRAM_SORT_BY_X_VALUES, + + PROP_DIAGRAM_STARTING_ANGLE, + + PROP_DIAGRAM_RIGHT_ANGLED_AXES, + PROP_DIAGRAM_PERSPECTIVE, + PROP_DIAGRAM_ROTATION_HORIZONTAL, + PROP_DIAGRAM_ROTATION_VERTICAL, + + PROP_DIAGRAM_MISSING_VALUE_TREATMENT, + + PROP_DIAGRAM_HAS_X_AXIS, + PROP_DIAGRAM_HAS_X_AXIS_DESCR, + PROP_DIAGRAM_HAS_X_AXIS_TITLE, + PROP_DIAGRAM_HAS_X_AXIS_GRID, + PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, + + PROP_DIAGRAM_HAS_Y_AXIS, + PROP_DIAGRAM_HAS_Y_AXIS_DESCR, + PROP_DIAGRAM_HAS_Y_AXIS_TITLE, + PROP_DIAGRAM_HAS_Y_AXIS_GRID, + PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, + + PROP_DIAGRAM_HAS_Z_AXIS, + PROP_DIAGRAM_HAS_Z_AXIS_DESCR, + PROP_DIAGRAM_HAS_Z_AXIS_TITLE, + PROP_DIAGRAM_HAS_Z_AXIS_GRID, + PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, + + PROP_DIAGRAM_HAS_SECOND_X_AXIS, + PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, + + PROP_DIAGRAM_HAS_SECOND_Y_AXIS, + PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, + + PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, + PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, + + PROP_DIAGRAM_AUTOMATIC_SIZE +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "AttributedDataPoints" ), + PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS, + ::getCppuType( reinterpret_cast< const uno::Sequence< uno::Sequence< sal_Int32 > > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + // see com.sun.star.chart.StackableDiagram + rOutProperties.push_back( + Property( C2U( "Percent" ), + PROP_DIAGRAM_PERCENT_STACKED, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "Stacked" ), + PROP_DIAGRAM_STACKED, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "Dim3D" ), + PROP_DIAGRAM_THREE_D, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // see com.sun.star.chart.Chart3DBarProperties + rOutProperties.push_back( + Property( C2U( "SolidType" ), + PROP_DIAGRAM_SOLIDTYPE, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // see com.sun.star.chart.BarDiagram + rOutProperties.push_back( + Property( C2U( "Deep" ), + PROP_DIAGRAM_DEEP, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "Vertical" ), + PROP_DIAGRAM_VERTICAL, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "NumberOfLines" ), + PROP_DIAGRAM_NUMBER_OF_LINES, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "StackedBarsConnected" ), + PROP_DIAGRAM_STACKED_BARS_CONNECTED, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "DataRowSource" ), + PROP_DIAGRAM_DATAROW_SOURCE, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartDataRowSource * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "GroupBarsPerAxis" ), + PROP_DIAGRAM_GROUP_BARS_PER_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "IncludeHiddenCells" ), + PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //new for XY charts + rOutProperties.push_back( + Property( C2U( "SortByXValues" ), + PROP_DIAGRAM_SORT_BY_X_VALUES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //for pie and donut charts + rOutProperties.push_back( + Property( C2U( "StartingAngle" ), + PROP_DIAGRAM_STARTING_ANGLE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0) ), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + //new for 3D charts + rOutProperties.push_back( + Property( C2U("RightAngledAxes"), + PROP_DIAGRAM_RIGHT_ANGLED_AXES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U("Perspective"), + PROP_DIAGRAM_PERSPECTIVE, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U("RotationHorizontal"), + PROP_DIAGRAM_ROTATION_HORIZONTAL, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U("RotationVertical"), + PROP_DIAGRAM_ROTATION_VERTICAL, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::MAYBEVOID )); + + // XAxisXSupplier + rOutProperties.push_back( + Property( C2U( "HasXAxis" ), + PROP_DIAGRAM_HAS_X_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasXAxisDescription" ), + PROP_DIAGRAM_HAS_X_AXIS_DESCR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasXAxisTitle" ), + PROP_DIAGRAM_HAS_X_AXIS_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasXAxisGrid" ), + PROP_DIAGRAM_HAS_X_AXIS_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasXAxisHelpGrid" ), + PROP_DIAGRAM_HAS_X_AXIS_HELP_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // XAxisYSupplier + rOutProperties.push_back( + Property( C2U( "HasYAxis" ), + PROP_DIAGRAM_HAS_Y_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasYAxisDescription" ), + PROP_DIAGRAM_HAS_Y_AXIS_DESCR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasYAxisTitle" ), + PROP_DIAGRAM_HAS_Y_AXIS_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasYAxisGrid" ), + PROP_DIAGRAM_HAS_Y_AXIS_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasYAxisHelpGrid" ), + PROP_DIAGRAM_HAS_Y_AXIS_HELP_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // XAxisZSupplier + rOutProperties.push_back( + Property( C2U( "HasZAxis" ), + PROP_DIAGRAM_HAS_Z_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasZAxisDescription" ), + PROP_DIAGRAM_HAS_Z_AXIS_DESCR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasZAxisTitle" ), + PROP_DIAGRAM_HAS_Z_AXIS_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasZAxisGrid" ), + PROP_DIAGRAM_HAS_Z_AXIS_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasZAxisHelpGrid" ), + PROP_DIAGRAM_HAS_Z_AXIS_HELP_GRID, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // XTwoAxisXSupplier + rOutProperties.push_back( + Property( C2U( "HasSecondaryXAxis" ), + PROP_DIAGRAM_HAS_SECOND_X_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasSecondaryXAxisDescription" ), + PROP_DIAGRAM_HAS_SECOND_X_AXIS_DESCR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // XTwoAxisYSupplier + rOutProperties.push_back( + Property( C2U( "HasSecondaryYAxis" ), + PROP_DIAGRAM_HAS_SECOND_Y_AXIS, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasSecondaryYAxisDescription" ), + PROP_DIAGRAM_HAS_SECOND_Y_AXIS_DESCR, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + // XSecondAxisTitleSupplier + rOutProperties.push_back( + Property( C2U( "HasSecondaryXAxisTitle" ), + PROP_DIAGRAM_HAS_SECOND_X_AXIS_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "HasSecondaryYAxisTitle" ), + PROP_DIAGRAM_HAS_SECOND_Y_AXIS_TITLE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "MissingValueTreatment" ), + PROP_DIAGRAM_MISSING_VALUE_TREATMENT, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "AutomaticSize" ), + PROP_DIAGRAM_AUTOMATIC_SIZE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +const uno::Sequence< Property > & lcl_GetPropertySequence() +{ + static uno::Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::LineProperties::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 ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +bool lcl_isXYChart( const Reference< chart2::XDiagram > xDiagram ) +{ + bool bRet = false; + Reference< chart2::XChartType > xChartType( ::chart::DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + if( xChartType.is() ) + { + rtl::OUString aChartType( xChartType->getChartType() ); + if( aChartType.equalsIgnoreAsciiCase(CHART2_SERVICE_NAME_CHARTTYPE_SCATTER) ) + bRet = true; + } + return bRet; +} + +sal_Int32 lcl_getNewAPIIndexForOldAPIIndex( + sal_Int32 nOldAPIIndex + , Reference< chart2::XDiagram > xDiagram ) +{ + sal_Int32 nNewAPIIndex = nOldAPIIndex; + + if( lcl_isXYChart( xDiagram ) ) + { + if( nNewAPIIndex >= 1 ) + nNewAPIIndex -= 1; + } + + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( + ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + if( nNewAPIIndex >= static_cast<sal_Int32>(aSeriesList.size()) ) + nNewAPIIndex = -1; + + return nNewAPIIndex; +} + +typedef ::std::map< OUString, OUString > tChartTypeMap; + +OUString lcl_getDiagramType( const OUString & rTemplateServiceName ) +{ + const OUString aPrefix( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.chart2.template.")); + + if( rTemplateServiceName.match( aPrefix )) + { + const OUString aName( rTemplateServiceName.copy( aPrefix.getLength())); + + // "Area" "StackedArea" "PercentStackedArea" "ThreeDArea" + // "StackedThreeDArea" "PercentStackedThreeDArea" + if( aName.indexOf( C2U("Area") ) != -1 ) + return C2U( "com.sun.star.chart.AreaDiagram" ); + + // "Pie" "PieAllExploded" "ThreeDPie" "ThreeDPieAllExploded" + if( aName.indexOf( C2U("Pie") ) != -1 ) + return C2U( "com.sun.star.chart.PieDiagram" ); + + // "Column" "StackedColumn" "PercentStackedColumn" "ThreeDColumnDeep" + // "ThreeDColumnFlat" "StackedThreeDColumnFlat" + // "PercentStackedThreeDColumnFlat" "Bar" "StackedBar" + // "PercentStackedBar" "ThreeDBarDeep" "ThreeDBarFlat" + // "StackedThreeDBarFlat" "PercentStackedThreeDBarFlat" "ColumnWithLine" + // "StackedColumnWithLine" + if( aName.indexOf( C2U("Column") ) != -1 || aName.indexOf( C2U("Bar") ) != -1 ) + return C2U( "com.sun.star.chart.BarDiagram" ); + + // "Donut" "DonutAllExploded" "ThreeDDonut" "ThreeDDonutAllExploded" + if( aName.indexOf( C2U("Donut") ) != -1 ) + return C2U( "com.sun.star.chart.DonutDiagram" ); + + // "ScatterLineSymbol" "ScatterLine" "ScatterSymbol" "ThreeDScatter" + if( aName.indexOf( C2U("Scatter") ) != -1 ) + return C2U( "com.sun.star.chart.XYDiagram" ); + + // "FilledNet" "StackedFilledNet" "PercentStackedFilledNet" + if( aName.indexOf( C2U("FilledNet") ) != -1 ) + return C2U( "com.sun.star.chart.FilledNetDiagram" ); + + // "Net" "NetSymbol" "NetLine" "StackedNet" "StackedNetSymbol" + // "StackedNetLine" "PercentStackedNet" "PercentStackedNetSymbol" + // "PercentStackedNetLine" + if( aName.indexOf( C2U("Net") ) != -1 ) + return C2U( "com.sun.star.chart.NetDiagram" ); + + // "StockLowHighClose" "StockOpenLowHighClose" "StockVolumeLowHighClose" + // "StockVolumeOpenLowHighClose" + if( aName.indexOf( C2U("Stock") ) != -1 ) + return C2U( "com.sun.star.chart.StockDiagram" ); + + if( aName.indexOf( C2U("Bubble") ) != -1 ) + return C2U( "com.sun.star.chart.BubbleDiagram" ); + + // Note: this must be checked after Bar, Net and Scatter + + // "Symbol" "StackedSymbol" "PercentStackedSymbol" "Line" "StackedLine" + // "PercentStackedLine" "LineSymbol" "StackedLineSymbol" + // "PercentStackedLineSymbol" "ThreeDLine" "StackedThreeDLine" + // "PercentStackedThreeDLine" "ThreeDLineDeep" + if( aName.indexOf( C2U("Line") ) != -1 || aName.indexOf( C2U("Symbol") ) != -1 ) + return C2U( "com.sun.star.chart.LineDiagram" ); + + OSL_ENSURE( false, "unknown template" ); + } + + return OUString(); +} + +typedef ::comphelper::MakeMap< ::rtl::OUString, ::rtl::OUString > tMakeStringStringMap; +//static +const tMakeStringStringMap& lcl_getChartTypeNameMap() +{ + static tMakeStringStringMap g_aChartTypeNameMap = + tMakeStringStringMap + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.LineChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.LineDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.AreaChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.AreaDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.ColumnChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.BarDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.PieChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.PieDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.DonutChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.DonutDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.ScatterChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.XYDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.FilledNetChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.FilledNetDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.NetChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.NetDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.CandleStickChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.StockDiagram" ) ) + + ( ::rtl::OUString::createFromAscii( "com.sun.star.chart2.BubbleChartType" ) + , ::rtl::OUString::createFromAscii( "com.sun.star.chart.BubbleDiagram" ) ) + + ; + return g_aChartTypeNameMap; +} + + +OUString lcl_getOldChartTypeName( const OUString & rNewChartTypeName ) +{ + OUString aOld(rNewChartTypeName); + + const tMakeStringStringMap& rMap = lcl_getChartTypeNameMap(); + tMakeStringStringMap::const_iterator aIt( rMap.find( rNewChartTypeName )); + if( aIt != rMap.end()) + { + aOld = aIt->second; + } + return aOld; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +DiagramWrapper::DiagramWrapper( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ) +{ +} + +DiagramWrapper::~DiagramWrapper() +{} + +// ____ XDiagram ____ +OUString SAL_CALL DiagramWrapper::getDiagramType() + throw (uno::RuntimeException) +{ + OUString aRet; + + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xChartDoc.is() && xDiagram.is() ) + { + Reference< beans::XPropertySet > xChartDocProp( xChartDoc, uno::UNO_QUERY ); + if( xChartDocProp.is() ) + { + uno::Reference< util::XRefreshable > xAddIn; + if( xChartDocProp->getPropertyValue( C2U( "AddIn" ) ) >>= xAddIn ) + { + uno::Reference< lang::XServiceName > xServiceName( xAddIn, uno::UNO_QUERY ); + if( xServiceName.is()) + return xServiceName->getServiceName(); + } + } + + Reference< lang::XMultiServiceFactory > xChartTypeManager( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xChartTypeManager ); + + aRet = lcl_getDiagramType( aTemplateAndService.second ); + } + + if( !aRet.getLength()) + { + // none of the standard templates matched + // use first chart type + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + if( xChartType.is() ) + { + aRet = xChartType->getChartType(); + if( aRet.getLength() ) + aRet = lcl_getOldChartTypeName( aRet ); + } + if( !aRet.getLength()) + aRet = C2U( "com.sun.star.chart.BarDiagram" ); + } + + return aRet; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getDataRowProperties( sal_Int32 nRow ) + throw (lang::IndexOutOfBoundsException, + uno::RuntimeException) +{ + if( nRow < 0 ) + throw lang::IndexOutOfBoundsException( + C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this )); + + Reference< chart2::XDataSeries > xSeries; + + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + if( nNewAPIIndex < 0 ) + throw lang::IndexOutOfBoundsException( + C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this )); + + Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( + DataSeriesPointWrapper::DATA_SERIES, nNewAPIIndex, 0, m_spChart2ModelContact ) ); + return xRet; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) + throw (lang::IndexOutOfBoundsException, + uno::RuntimeException) +{ + if( nCol < 0 || nRow < 0 ) + throw lang::IndexOutOfBoundsException( + C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this )); + + Reference< chart2::XDataSeries > xSeries; + + sal_Int32 nNewAPIIndex = lcl_getNewAPIIndexForOldAPIIndex( nRow, m_spChart2ModelContact->getChart2Diagram() ); + if( nNewAPIIndex < 0 ) + throw lang::IndexOutOfBoundsException( + C2U( "DataSeries index invalid" ), static_cast< ::cppu::OWeakObject * >( this )); + + //todo: check borders of point index + + Reference< beans::XPropertySet > xRet( new DataSeriesPointWrapper( + DataSeriesPointWrapper::DATA_POINT, nNewAPIIndex, nCol, m_spChart2ModelContact ) ); + + return xRet; +} + +// ____ XShape (base of XDiagram) ____ +awt::Point SAL_CALL DiagramWrapper::getPosition() + throw (uno::RuntimeException) +{ + awt::Point aPosition; + + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + bool bSet = false; + chart2::RelativePosition aRelativePosition; + uno::Any aAPosition( xProp->getPropertyValue( C2U( "RelativePosition" ) ) ); + if( aAPosition >>= aRelativePosition ) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + aPosition.X = static_cast<sal_Int32>(aRelativePosition.Primary*aPageSize.Width); + aPosition.Y = static_cast<sal_Int32>(aRelativePosition.Secondary*aPageSize.Height); + + aPosition = RelativePositionHelper::getUpperLeftCornerOfAnchoredObject( + aPosition, DiagramWrapper::getSize(), aRelativePosition.Anchor ); + + bSet = true; + } + if(!bSet) + aPosition = m_spChart2ModelContact->GetDiagramPositionInclusive(); + } + + return aPosition; +} + +void SAL_CALL DiagramWrapper::setPosition( const awt::Point& aPosition ) + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + if( aPosition.X < 0 || aPosition.Y < 0 ) + { + if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() && + !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() ) + { + DBG_ERROR("DiagramWrapper::setPosition called with negative position -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativePosition" ), aEmpty ); + return; + } + //else: The saved didagram size does include the axis title sizes thus the position and size could be negative + } + + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + + chart2::RelativePosition aRelativePosition; + aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; + aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); + aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } +} + +awt::Size SAL_CALL DiagramWrapper::getSize() + throw (uno::RuntimeException) +{ + awt::Size aSize; + + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + bool bSet = false; + chart2::RelativeSize aRelativeSize; + uno::Any aASize( xProp->getPropertyValue( C2U( "RelativeSize" ) ) ); + if(aASize>>=aRelativeSize) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + aSize.Width = static_cast<sal_Int32>(aRelativeSize.Primary*aPageSize.Width); + aSize.Height = static_cast<sal_Int32>(aRelativeSize.Secondary*aPageSize.Height); + bSet = true; + } + if(!bSet) + aSize = m_spChart2ModelContact->GetDiagramSizeInclusive(); + } + + return aSize; +} + +void SAL_CALL DiagramWrapper::setSize( const awt::Size& aSize ) + throw (beans::PropertyVetoException, + uno::RuntimeException) +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + + chart2::RelativeSize aRelativeSize; + aRelativeSize.Primary = double(aSize.Width)/double(aPageSize.Width); + aRelativeSize.Secondary = double(aSize.Height)/double(aPageSize.Height); + + if( aRelativeSize.Primary > 1 || aRelativeSize.Secondary > 1 ) + { + if( !TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() && + !TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact->getChartModel() ).is() ) + { + DBG_ERROR("DiagramWrapper::setSize called with sizes bigger than page -> automatic values are taken instead" ); + uno::Any aEmpty; + xProp->setPropertyValue( C2U( "RelativeSize" ), aEmpty ); + return; + } + //else: The saved didagram size does include the axis title sizes thus the position and size could be out of range + } + + xProp->setPropertyValue( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) ); + } +} + +// ____ XShapeDescriptor (base of XShape) ____ +OUString SAL_CALL DiagramWrapper::getShapeType() + throw (uno::RuntimeException) +{ + return C2U( "com.sun.star.chart.Diagram" ); +} + +// ____ XAxisZSupplier ____ +Reference< + drawing::XShape > SAL_CALL DiagramWrapper::getZAxisTitle() + throw (uno::RuntimeException) +{ + if( !m_xZAxisTitle.is() ) + { + m_xZAxisTitle = new TitleWrapper( TitleHelper::Z_AXIS_TITLE, m_spChart2ModelContact ); + } + return m_xZAxisTitle; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getZMainGrid() + throw (uno::RuntimeException) +{ + if( ! m_xZMainGrid.is()) + { + m_xZMainGrid = new GridWrapper( GridWrapper::Z_MAIN_GRID, m_spChart2ModelContact ); + } + return m_xZMainGrid; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getZHelpGrid() + throw (uno::RuntimeException) +{ + if( !m_xZHelpGrid.is() ) + { + m_xZHelpGrid = new GridWrapper( GridWrapper::Z_SUB_GRID, m_spChart2ModelContact ); + } + return m_xZHelpGrid; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getZAxis() + throw (uno::RuntimeException) +{ + if( ! m_xZAxis.is()) + { + m_xZAxis = new AxisWrapper( AxisWrapper::Z_AXIS, m_spChart2ModelContact ); + } + return m_xZAxis; +} + + +// ____ XTwoAxisXSupplier ____ +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryXAxis() + throw (uno::RuntimeException) +{ + if( ! m_xSecondXAxis.is()) + { + m_xSecondXAxis = new AxisWrapper( AxisWrapper::SECOND_X_AXIS, m_spChart2ModelContact ); + } + return m_xSecondXAxis; +} + + +// ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ +Reference< + drawing::XShape > SAL_CALL DiagramWrapper::getXAxisTitle() + throw (uno::RuntimeException) +{ + + if( !m_xXAxisTitle.is() ) + { + m_xXAxisTitle = new TitleWrapper( TitleHelper::X_AXIS_TITLE, m_spChart2ModelContact ); + } + return m_xXAxisTitle; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getXAxis() + throw (uno::RuntimeException) +{ + if( ! m_xXAxis.is()) + { + m_xXAxis = new AxisWrapper( AxisWrapper::X_AXIS, m_spChart2ModelContact ); + } + + return m_xXAxis; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getXMainGrid() + throw (uno::RuntimeException) +{ + if( ! m_xXMainGrid.is()) + { + m_xXMainGrid = new GridWrapper( GridWrapper::X_MAIN_GRID, m_spChart2ModelContact ); + } + + return m_xXMainGrid; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getXHelpGrid() + throw (uno::RuntimeException) +{ + if( ! m_xXHelpGrid.is()) + { + m_xXHelpGrid = new GridWrapper( GridWrapper::X_SUB_GRID, m_spChart2ModelContact ); + } + return m_xXHelpGrid; +} + + +// ____ XTwoAxisYSupplier ____ +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getSecondaryYAxis() + throw (uno::RuntimeException) +{ + if( ! m_xSecondYAxis.is()) + { + m_xSecondYAxis = new AxisWrapper( AxisWrapper::SECOND_Y_AXIS, m_spChart2ModelContact ); + } + return m_xSecondYAxis; +} + + +// ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ +Reference< + drawing::XShape > SAL_CALL DiagramWrapper::getYAxisTitle() + throw (uno::RuntimeException) +{ + if( !m_xYAxisTitle.is() ) + { + m_xYAxisTitle = new TitleWrapper( TitleHelper::Y_AXIS_TITLE, m_spChart2ModelContact ); + } + return m_xYAxisTitle; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getYAxis() + throw (uno::RuntimeException) +{ + if( ! m_xYAxis.is()) + { + m_xYAxis = new AxisWrapper( AxisWrapper::Y_AXIS, m_spChart2ModelContact ); + } + return m_xYAxis; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getYHelpGrid() + throw (uno::RuntimeException) +{ + if( ! m_xYHelpGrid.is()) + { + m_xYHelpGrid = new GridWrapper( GridWrapper::Y_SUB_GRID, m_spChart2ModelContact ); + } + return m_xYHelpGrid; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getYMainGrid() + throw (uno::RuntimeException) +{ + if( ! m_xYMainGrid.is()) + { + m_xYMainGrid = new GridWrapper( GridWrapper::Y_MAIN_GRID, m_spChart2ModelContact ); + } + return m_xYMainGrid; +} + +// ____ XSecondAxisTitleSupplier ____ +Reference< + drawing::XShape > SAL_CALL DiagramWrapper::getSecondXAxisTitle() + throw (uno::RuntimeException) +{ + if( !m_xSecondXAxisTitle.is() ) + { + m_xSecondXAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_X_AXIS_TITLE, m_spChart2ModelContact ); + } + return m_xSecondXAxisTitle; +} + +Reference< + drawing::XShape > SAL_CALL DiagramWrapper::getSecondYAxisTitle() + throw (uno::RuntimeException) +{ + if( !m_xSecondYAxisTitle.is() ) + { + m_xSecondYAxisTitle = new TitleWrapper( TitleHelper::SECONDARY_Y_AXIS_TITLE, m_spChart2ModelContact ); + } + return m_xSecondYAxisTitle; +} + +// ____ XStatisticDisplay ____ +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getUpBar() + throw (uno::RuntimeException) +{ + if( !m_xUpBarWrapper.is() ) + { + m_xUpBarWrapper = new UpDownBarWrapper( true, m_spChart2ModelContact ); + } + return m_xUpBarWrapper; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getDownBar() + throw (uno::RuntimeException) +{ + if( !m_xDownBarWrapper.is() ) + { + m_xDownBarWrapper = new UpDownBarWrapper( false, m_spChart2ModelContact ); + } + return m_xDownBarWrapper; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getMinMaxLine() + throw (uno::RuntimeException) +{ + if( !m_xMinMaxLineWrapper.is() ) + { + m_xMinMaxLineWrapper = new MinMaxLineWrapper( m_spChart2ModelContact ); + } + return m_xMinMaxLineWrapper; +} + +// ____ X3DDisplay ____ +Reference< beans::XPropertySet > SAL_CALL DiagramWrapper::getWall() + throw (uno::RuntimeException) +{ + if( !m_xWall.is() ) + { + m_xWall = new WallFloorWrapper( true, m_spChart2ModelContact ); + } + return m_xWall; +} + +Reference< + beans::XPropertySet > SAL_CALL DiagramWrapper::getFloor() + throw (uno::RuntimeException) +{ + if( !m_xFloor.is() ) + { + m_xFloor = new WallFloorWrapper( false, m_spChart2ModelContact ); + } + return m_xFloor; +} + +// ____ X3DDefaultSetter ____ +void SAL_CALL DiagramWrapper::set3DSettingsToDefault() + throw (uno::RuntimeException) +{ + Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + if( x3DDefaultSetter.is() ) + x3DDefaultSetter->set3DSettingsToDefault(); +} + +void SAL_CALL DiagramWrapper::setDefaultRotation() + throw (uno::RuntimeException) +{ + Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + if( x3DDefaultSetter.is() ) + x3DDefaultSetter->setDefaultRotation(); +} + +void SAL_CALL DiagramWrapper::setDefaultIllumination() + throw (uno::RuntimeException) +{ + Reference< X3DDefaultSetter > x3DDefaultSetter( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); + if( x3DDefaultSetter.is() ) + x3DDefaultSetter->setDefaultIllumination(); +} + +// ____ XComponent ____ +void SAL_CALL DiagramWrapper::dispose() + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.disposeAndClear( lang::EventObject( static_cast< ::cppu::OWeakObject* >( this ))); + + // /-- + MutexGuard aGuard( GetMutex()); + + DisposeHelper::DisposeAndClear( m_xXAxisTitle ); + DisposeHelper::DisposeAndClear( m_xYAxisTitle ); + DisposeHelper::DisposeAndClear( m_xZAxisTitle ); + DisposeHelper::DisposeAndClear( m_xSecondXAxisTitle ); + DisposeHelper::DisposeAndClear( m_xSecondYAxisTitle ); + DisposeHelper::DisposeAndClear( m_xXAxis ); + DisposeHelper::DisposeAndClear( m_xYAxis ); + DisposeHelper::DisposeAndClear( m_xZAxis ); + DisposeHelper::DisposeAndClear( m_xSecondXAxis ); + DisposeHelper::DisposeAndClear( m_xSecondYAxis ); + DisposeHelper::DisposeAndClear( m_xXMainGrid ); + DisposeHelper::DisposeAndClear( m_xYMainGrid ); + DisposeHelper::DisposeAndClear( m_xZMainGrid ); + DisposeHelper::DisposeAndClear( m_xXHelpGrid ); + DisposeHelper::DisposeAndClear( m_xYHelpGrid ); + DisposeHelper::DisposeAndClear( m_xZHelpGrid ); + DisposeHelper::DisposeAndClear( m_xWall ); + DisposeHelper::DisposeAndClear( m_xFloor ); + DisposeHelper::DisposeAndClear( m_xMinMaxLineWrapper ); + DisposeHelper::DisposeAndClear( m_xUpBarWrapper ); + DisposeHelper::DisposeAndClear( m_xDownBarWrapper ); + + clearWrappedPropertySet(); + // \-- +} + +void SAL_CALL DiagramWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL DiagramWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ____ XEventListener ____ +// void SAL_CALL DiagramWrapper::disposing( const lang::EventObject& Source ) +// throw (uno::RuntimeException) +// { +// } + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_DATAROW_SOURCE +class WrappedDataRowSourceProperty : public WrappedProperty +{ +public: + WrappedDataRowSourceProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedDataRowSourceProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedDataRowSourceProperty::WrappedDataRowSourceProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("DataRowSource"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedDataRowSourceProperty::getPropertyDefault( 0 ); +} + +WrappedDataRowSourceProperty::~WrappedDataRowSourceProperty() +{ +} + +void WrappedDataRowSourceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::com::sun::star::chart::ChartDataRowSource eChartDataRowSource = ::com::sun::star::chart::ChartDataRowSource_ROWS; + if( ! (rOuterValue >>= eChartDataRowSource) ) + throw lang::IllegalArgumentException( C2U("Property DataRowSource requires ::com::sun::star::chart::ChartDataRowSource value"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + bool bNewUseColumns = eChartDataRowSource == ::com::sun::star::chart::ChartDataRowSource_COLUMNS; + + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + if( bUseColumns != bNewUseColumns ) + { + aSequenceMapping.realloc(0); + DataSourceHelper::setRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aSequenceMapping, bNewUseColumns , bHasCategories, bFirstCellAsLabel ); + } + } +} + +Any WrappedDataRowSourceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + ::rtl::OUString aRangeString; + bool bUseColumns = true; + bool bFirstCellAsLabel = true; + bool bHasCategories = true; + uno::Sequence< sal_Int32 > aSequenceMapping; + + if( DataSourceHelper::detectRangeSegmentation( + m_spChart2ModelContact->getChartModel(), aRangeString, aSequenceMapping, bUseColumns + , bFirstCellAsLabel, bHasCategories ) ) + { + ::com::sun::star::chart::ChartDataRowSource eChartDataRowSource = ::com::sun::star::chart::ChartDataRowSource_ROWS; + if(bUseColumns) + eChartDataRowSource = ::com::sun::star::chart::ChartDataRowSource_COLUMNS; + + m_aOuterValue <<= eChartDataRowSource; + } + + return m_aOuterValue; +} + +Any WrappedDataRowSourceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= ::com::sun::star::chart::ChartDataRowSource_COLUMNS; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + + +//PROP_DIAGRAM_STACKED +//PROP_DIAGRAM_DEEP +//PROP_DIAGRAM_PERCENT_STACKED +class WrappedStackingProperty : public WrappedProperty +{ +public: + WrappedStackingProperty( StackMode eStackMode, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedStackingProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +protected: //methods + bool detectInnerValue( StackMode& eInnerStackMode ) const; + +private: //member +::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + const StackMode m_eStackMode; + mutable Any m_aOuterValue; +}; + +WrappedStackingProperty::WrappedStackingProperty( StackMode eStackMode, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(OUString(),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_eStackMode( eStackMode ) + , m_aOuterValue() +{ + switch( m_eStackMode ) + { + case StackMode_Y_STACKED: + m_aOuterName = C2U( "Stacked" ); + break; + case StackMode_Y_STACKED_PERCENT: + m_aOuterName = C2U( "Percent" ); + break; + case StackMode_Z_STACKED: + m_aOuterName = C2U( "Deep" ); + break; + default: + OSL_ENSURE( false, "unexpected stack mode" ); + break; + } +} + +WrappedStackingProperty::~WrappedStackingProperty() +{ +} + +bool WrappedStackingProperty::detectInnerValue( StackMode& eStackMode ) const +{ + bool bHasDetectableInnerValue = false; + bool bIsAmbiguous = false; + eStackMode = DiagramHelper::getStackMode( m_spChart2ModelContact->getChart2Diagram() + , bHasDetectableInnerValue, bIsAmbiguous ); + return bHasDetectableInnerValue; +} + +void WrappedStackingProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Stacking Properties require boolean values"), 0, 0 ); + + StackMode eInnerStackMode; + bool bHasDetectableInnerValue = detectInnerValue( eInnerStackMode ); + + if( !bHasDetectableInnerValue ) + { + m_aOuterValue = rOuterValue; + return; + } + + if( bNewValue && eInnerStackMode == m_eStackMode ) + return; + if( !bNewValue && eInnerStackMode != m_eStackMode ) + return; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + StackMode eNewStackMode = bNewValue ? m_eStackMode : StackMode_NONE; + DiagramHelper::setStackMode( xDiagram, eNewStackMode ); + } +} + +Any WrappedStackingProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + StackMode eInnerStackMode; + if( detectInnerValue( eInnerStackMode ) ) + { + sal_Bool bValue = (eInnerStackMode == m_eStackMode); + Any aAny; + aAny <<= bValue; + return aAny; + } + return m_aOuterValue; +} + +Any WrappedStackingProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Bool( sal_False ); + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_THREE_D +class WrappedDim3DProperty : public WrappedProperty +{ +public: + WrappedDim3DProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedDim3DProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedDim3DProperty::WrappedDim3DProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("Dim3D"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedDim3DProperty::getPropertyDefault( 0 ); +} + +WrappedDim3DProperty::~WrappedDim3DProperty() +{ +} + +void WrappedDim3DProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNew3D = false; + if( ! (rOuterValue >>= bNew3D) ) + throw lang::IllegalArgumentException( C2U("Property Dim3D requires boolean value"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( !xDiagram.is() ) + return; + + sal_Bool bOld3D = DiagramHelper::getDimension( xDiagram ) == 3; + if( bOld3D != bNew3D ) + DiagramHelper::setDimension( xDiagram, bNew3D ? 3 : 2 ); +} + +Any WrappedDim3DProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + sal_Bool b3D = DiagramHelper::getDimension( xDiagram ) == 3; + m_aOuterValue <<= b3D; + } + return m_aOuterValue; +} + +Any WrappedDim3DProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Bool( sal_False ); + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_VERTICAL +class WrappedVerticalProperty : public WrappedProperty +{ +public: + WrappedVerticalProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedVerticalProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedVerticalProperty::WrappedVerticalProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("Vertical"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedVerticalProperty::getPropertyDefault( 0 ); +} + +WrappedVerticalProperty::~WrappedVerticalProperty() +{ +} + +void WrappedVerticalProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewVertical = false; + if( ! (rOuterValue >>= bNewVertical) ) + throw lang::IllegalArgumentException( C2U("Property Vertical requires boolean value"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( !xDiagram.is() ) + return; + + bool bFound = false; + bool bAmbiguous = false; + sal_Bool bOldVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + if( bFound && ( bOldVertical != bNewVertical || bAmbiguous ) ) + DiagramHelper::setVertical( xDiagram, bNewVertical ); +} + +Any WrappedVerticalProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + bool bFound = false; + bool bAmbiguous = false; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + sal_Bool bVertical = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + if( bFound ) + m_aOuterValue <<= bVertical; + } + return m_aOuterValue; +} + +Any WrappedVerticalProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Bool( sal_False ); + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_NUMBER_OF_LINES +class WrappedNumberOfLinesProperty : public WrappedProperty +{ +public: + WrappedNumberOfLinesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedNumberOfLinesProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +protected: //methods + bool detectInnerValue( uno::Any& rInnerValue ) const; + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedNumberOfLinesProperty::WrappedNumberOfLinesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("NumberOfLines"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue( this->getPropertyDefault(0) ) +{ +} + +WrappedNumberOfLinesProperty::~WrappedNumberOfLinesProperty() +{ +} + +bool WrappedNumberOfLinesProperty::detectInnerValue( uno::Any& rInnerValue ) const +{ + sal_Int32 nNumberOfLines = 0; + bool bHasDetectableInnerValue = false; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( xDiagram.is() && xChartDoc.is() ) + { + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( + DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + if( aSeriesVector.size() > 0 ) + { + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + if( aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.ColumnWithLine" ) ) ) + { + try + { + uno::Reference< beans::XPropertySet > xProp( aTemplateAndService.first, uno::UNO_QUERY ); + xProp->getPropertyValue( m_aOuterName ) >>= nNumberOfLines; + bHasDetectableInnerValue = true; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + if(bHasDetectableInnerValue) + rInnerValue = uno::makeAny(nNumberOfLines); + return bHasDetectableInnerValue; +} + +void WrappedNumberOfLinesProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Int32 nNewValue; + if( ! (rOuterValue >>= nNewValue) ) + throw lang::IllegalArgumentException( C2U("property NumberOfLines requires sal_Int32 value"), 0, 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 ) + { + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + + uno::Reference< chart2::XChartTypeTemplate > xTemplate(0); + if( aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.ColumnWithLine" ) ) ) + { + if( nNewValue != 0 ) + { + xTemplate.set( aTemplateAndService.first ); + try + { + sal_Int32 nOldValue = 0; + uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); + xProp->getPropertyValue( m_aOuterName ) >>= nOldValue; + if( nOldValue == nNewValue ) + return; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + else + { + xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.Column" ) ), uno::UNO_QUERY ); + } + } + else if( aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.Column" ) ) ) + { + if( nNewValue == 0 ) + return; + xTemplate.set( xFact->createInstance( C2U( "com.sun.star.chart2.template.ColumnWithLine" ) ), uno::UNO_QUERY ); + } + + if(xTemplate.is()) + { + try + { + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + uno::Reference< beans::XPropertySet > xProp( xTemplate, uno::UNO_QUERY ); + xProp->setPropertyValue( C2U( "NumberOfLines" ), uno::makeAny(nNewValue) ); + xTemplate->changeDiagram( xDiagram ); + // \-- locked controllers + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } +} + +Any WrappedNumberOfLinesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + if( !detectInnerValue( aRet ) ) + aRet = m_aOuterValue; + return aRet; +} + +Any WrappedNumberOfLinesProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Int32( 0 ); + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_ATTRIBUTED_DATA_POINTS +class WrappedAttributedDataPointsProperty : public WrappedProperty +{ +public: + WrappedAttributedDataPointsProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedAttributedDataPointsProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedAttributedDataPointsProperty::WrappedAttributedDataPointsProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("AttributedDataPoints"),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedAttributedDataPointsProperty::getPropertyDefault( 0 ); +} + +WrappedAttributedDataPointsProperty::~WrappedAttributedDataPointsProperty() +{ +} + +void WrappedAttributedDataPointsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Sequence< uno::Sequence< sal_Int32 > > aNewValue; + if( ! (rOuterValue >>= aNewValue) ) + throw lang::IllegalArgumentException( C2U("Property AttributedDataPoints requires value of type uno::Sequence< uno::Sequence< sal_Int32 > >"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + + if( xDiagram.is() && xDiaProp.is()) + { + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( + ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + + uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); + + ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt = + aSeriesVector.begin(); + sal_Int32 i = 0; + for( ; aIt != aSeriesVector.end(); ++aIt, ++i ) + { + Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY ); + if( xProp.is()) + { + uno::Any aVal; + if( i < aNewValue.getLength() ) + aVal <<= aNewValue[i]; + else + { + //set empty sequence + uno::Sequence< sal_Int32 > aSeq; + aVal <<= aSeq; + } + xProp->setPropertyValue( C2U( "AttributedDataPoints" ), aVal ); + } + } + } +} + +Any WrappedAttributedDataPointsProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + + if( xDiagram.is() && xDiaProp.is()) + { + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( + ::chart::DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + + uno::Sequence< uno::Sequence< sal_Int32 > > aResult( aSeriesVector.size() ); + + ::std::vector< Reference< chart2::XDataSeries > >::const_iterator aIt = + aSeriesVector.begin(); + sal_Int32 i = 0; + for( ; aIt != aSeriesVector.end(); ++aIt, ++i ) + { + Reference< beans::XPropertySet > xProp( *aIt, uno::UNO_QUERY ); + if( xProp.is()) + { + uno::Any aVal( + xProp->getPropertyValue( C2U( "AttributedDataPoints" ))); + uno::Sequence< sal_Int32 > aSeq; + if( aVal >>= aSeq ) + aResult[ i ] = aSeq; + } + } + m_aOuterValue <<= aResult; + } + return m_aOuterValue; +} + +Any WrappedAttributedDataPointsProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + uno::Sequence< uno::Sequence< sal_Int32 > > aSeq; + aRet <<= aSeq; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_SOLIDTYPE +class WrappedSolidTypeProperty : public WrappedProperty +{ +public: + WrappedSolidTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedSolidTypeProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable Any m_aOuterValue; +}; + +WrappedSolidTypeProperty::WrappedSolidTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty( C2U( "SolidType" ), OUString() ) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_aOuterValue() +{ + m_aOuterValue = WrappedSolidTypeProperty::getPropertyDefault( 0 ); +} + +WrappedSolidTypeProperty::~WrappedSolidTypeProperty() +{ +} + +void WrappedSolidTypeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Int32 nNewSolidType = ::com::sun::star::chart::ChartSolidType::RECTANGULAR_SOLID; + if( ! (rOuterValue >>= nNewSolidType) ) + throw lang::IllegalArgumentException( C2U("Property SolidType requires integer value"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( !xDiagram.is() ) + return; + + bool bFound = false; + bool bAmbiguous = false; + sal_Int32 nOldSolidType = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + if( bFound && ( nOldSolidType != nNewSolidType || bAmbiguous ) ) + DiagramHelper::setGeometry3D( xDiagram, nNewSolidType ); +} + +Any WrappedSolidTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + bool bFound = false; + bool bAmbiguous = false; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + sal_Int32 nGeometry = DiagramHelper::getGeometry3D( xDiagram, bFound, bAmbiguous ); + if( bFound ) + m_aOuterValue <<= nGeometry; + } + return m_aOuterValue; +} + +Any WrappedSolidTypeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( ::com::sun::star::chart::ChartSolidType::RECTANGULAR_SOLID ); +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedAutomaticSizeProperty : public WrappedProperty +{ +public: + WrappedAutomaticSizeProperty(); + virtual ~WrappedAutomaticSizeProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); +}; + +WrappedAutomaticSizeProperty::WrappedAutomaticSizeProperty() + : WrappedProperty( C2U( "AutomaticSize" ), OUString() ) +{ +} + +WrappedAutomaticSizeProperty::~WrappedAutomaticSizeProperty() +{ +} + +void WrappedAutomaticSizeProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( xInnerPropertySet.is() ) + { + bool bNewValue = true; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property AutomaticSize requires value of type boolean"), 0, 0 ); + + try + { + if( bNewValue ) + { + Any aRelativeSize( xInnerPropertySet->getPropertyValue( C2U( "RelativeSize" ) ) ); + if( aRelativeSize.hasValue() ) + xInnerPropertySet->setPropertyValue( C2U( "RelativeSize" ), Any() ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +Any WrappedAutomaticSizeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); + if( xInnerPropertySet.is() ) + { + Any aRelativeSize( xInnerPropertySet->getPropertyValue( C2U( "RelativeSize" ) ) ); + if( !aRelativeSize.hasValue() ) + aRet <<= true; + } + return aRet; +} + +Any WrappedAutomaticSizeProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= false; + return aRet; +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +//PROP_DIAGRAM_INCLUDE_HIDDEN_CELLS +class WrappedIncludeHiddenCellsProperty : public WrappedProperty +{ +public: + WrappedIncludeHiddenCellsProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedIncludeHiddenCellsProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedIncludeHiddenCellsProperty::WrappedIncludeHiddenCellsProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("IncludeHiddenCells"),C2U("IncludeHiddenCells")) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedIncludeHiddenCellsProperty::~WrappedIncludeHiddenCellsProperty() +{ +} + +void WrappedIncludeHiddenCellsProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property Dim3D requires boolean value"), 0, 0 ); + + ChartModelHelper::setIncludeHiddenCells( bNewValue, m_spChart2ModelContact->getChartModel() ); +} + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +// ____ XDiagramProvider ____ +Reference< chart2::XDiagram > SAL_CALL DiagramWrapper::getDiagram() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->getChart2Diagram(); +} + +void SAL_CALL DiagramWrapper::setDiagram( + const Reference< chart2::XDiagram >& /*xDiagram*/ ) + throw (uno::RuntimeException) +{ + //@todo: remove this method from interface + DBG_ERROR("DiagramWrapper::setDiagram is not implemented, should be removed and not be called" ); +} + +// ================================================================================ + +Reference< beans::XPropertySet > DiagramWrapper::getInnerPropertySet() +{ + return Reference< beans::XPropertySet >( m_spChart2ModelContact->getChart2Diagram(), uno::UNO_QUERY ); +} + +const Sequence< beans::Property >& DiagramWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > DiagramWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + WrappedAxisAndGridExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedAxisTitleExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedAxisLabelExistenceProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedSceneProperty::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedIgnoreProperties::addIgnoreFillProperties( aWrappedProperties ); + WrappedIgnoreProperties::addIgnoreLineProperties( aWrappedProperties ); + WrappedStatisticProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); + WrappedSymbolProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); + WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( aWrappedProperties, m_spChart2ModelContact ); + WrappedSplineProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedStockProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); + + aWrappedProperties.push_back( new WrappedDataRowSourceProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedStackingProperty( StackMode_Y_STACKED,m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedStackingProperty( StackMode_Y_STACKED_PERCENT, m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedStackingProperty( StackMode_Z_STACKED, m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedDim3DProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedVerticalProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedNumberOfLinesProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedAttributedDataPointsProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedProperty( C2U( "StackedBarsConnected" ), C2U( "ConnectBars" ) ) ); + aWrappedProperties.push_back( new WrappedSolidTypeProperty( m_spChart2ModelContact ) ); + aWrappedProperties.push_back( new WrappedAutomaticSizeProperty() ); + aWrappedProperties.push_back( new WrappedIncludeHiddenCellsProperty( m_spChart2ModelContact ) ); + + return aWrappedProperties; +} + +// ================================================================================ + +uno::Sequence< OUString > DiagramWrapper::getSupportedServiceNames_Static() +{ + uno::Sequence< OUString > aServices( 8 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.Diagram" ); + aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 2 ] = C2U( "com.sun.star.chart.StackableDiagram" ); + aServices[ 3 ] = C2U( "com.sun.star.chart.ChartAxisXSupplier" ); + aServices[ 4 ] = C2U( "com.sun.star.chart.ChartAxisYSupplier" ); + aServices[ 5 ] = C2U( "com.sun.star.chart.ChartAxisZSupplier" ); + aServices[ 6 ] = C2U( "com.sun.star.chart.ChartTwoAxisXSupplier" ); + aServices[ 7 ] = C2U( "com.sun.star.chart.ChartTwoAxisYSupplier" ); +// aServices[ x ] = C2U( "com.sun.star.beans.PropertySet" ); +// aServices[ x ] = C2U( "com.sun.star.drawing.FillProperties" ); +// aServices[ x ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( DiagramWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx new file mode 100644 index 000000000000..b69a856a557f --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/DiagramWrapper.hxx @@ -0,0 +1,308 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DiagramWrapper.hxx,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_DIAGRAMWRAPPER_HXX +#define CHART_DIAGRAMWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ServiceMacros.hxx" +#include "DiagramHelper.hxx" +#include <cppuhelper/implbase11.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/chart2/XDiagramProvider.hpp> +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> +#include <com/sun/star/chart2/XChartTypeManager.hpp> +#include <com/sun/star/chart/XDiagram.hpp> +#include <com/sun/star/chart/XAxisZSupplier.hpp> +#include <com/sun/star/chart/XTwoAxisXSupplier.hpp> +#include <com/sun/star/chart/XTwoAxisYSupplier.hpp> +#include <com/sun/star/chart/XStatisticDisplay.hpp> +#include <com/sun/star/chart/X3DDisplay.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/chart/XSecondAxisTitleSupplier.hpp> + +#include <com/sun/star/chart/X3DDefaultSetter.hpp> +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class DiagramWrapper : public ::cppu::ImplInheritanceHelper11< + WrappedPropertySet + , ::com::sun::star::chart::XDiagram + , ::com::sun::star::chart::XAxisZSupplier + , ::com::sun::star::chart::XTwoAxisXSupplier // : XAxisXSupplier + , ::com::sun::star::chart::XTwoAxisYSupplier // : XAxisYSupplier + , ::com::sun::star::chart::XStatisticDisplay + , ::com::sun::star::chart::X3DDisplay + , ::com::sun::star::chart::X3DDefaultSetter + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XComponent +// , ::com::sun::star::lang::XEventListener + , ::com::sun::star::chart2::XDiagramProvider + , ::com::sun::star::chart::XSecondAxisTitleSupplier + > +{ +public: + DiagramWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~DiagramWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XDiagram ____ + virtual ::rtl::OUString SAL_CALL getDiagramType() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getDataRowProperties( sal_Int32 nRow ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getDataPointProperties( sal_Int32 nCol, sal_Int32 nRow ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShape (base of XDiagram) ____ + virtual ::com::sun::star::awt::Point SAL_CALL getPosition() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShapeDescriptor (base of XShape) ____ + virtual ::rtl::OUString SAL_CALL getShapeType() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XAxisZSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getZAxisTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getZMainGrid() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getZHelpGrid() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getZAxis() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XTwoAxisXSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryXAxis() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XAxisXSupplier (base of XTwoAxisXSupplier) ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getXAxisTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getXAxis() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getXMainGrid() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getXHelpGrid() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XTwoAxisYSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getSecondaryYAxis() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XAxisYSupplier (base of XTwoAxisYSupplier) ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getYAxisTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getYAxis() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getYHelpGrid() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getYMainGrid() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XSecondAxisTitleSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getSecondXAxisTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getSecondYAxisTitle() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XStatisticDisplay ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getUpBar() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getDownBar() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getMinMaxLine() + throw (::com::sun::star::uno::RuntimeException); + + // ____ X3DDisplay ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getWall() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getFloor() + throw (::com::sun::star::uno::RuntimeException); + + // ____ X3DDefaultSetter ____ + virtual void SAL_CALL set3DSettingsToDefault() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDefaultRotation() throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDefaultIllumination() throw (::com::sun::star::uno::RuntimeException); + +// // ____ XEventListener ____ +// virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) +// throw (::com::sun::star::uno::RuntimeException); + + // ____ XDiagramProvider ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram > SAL_CALL getDiagram() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDiagram >& xDiagram ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: + void updateFromModel(); + + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > + m_xXAxisTitle; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > + m_xYAxisTitle; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > + m_xZAxisTitle; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > + m_xSecondXAxisTitle; + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > + m_xSecondYAxisTitle; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xXAxis; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xYAxis; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xZAxis; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xSecondXAxis; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xSecondYAxis; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xXMainGrid; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xYMainGrid; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xZMainGrid; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xXHelpGrid; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xYHelpGrid; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xZHelpGrid; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xWall; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xFloor; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xMinMaxLineWrapper; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xUpBarWrapper; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > + m_xDownBarWrapper; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_DIAGRAMWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.cxx b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx new file mode 100644 index 000000000000..7aebd872f870 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: GridWrapper.cxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "GridWrapper.hxx" +#include "macros.hxx" +#include "AxisHelper.hxx" +#include "Chart2ModelContact.hxx" +#include "ContainerHelper.hxx" +#include "AxisIndexDefines.hxx" +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +#include "LineProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedDefaultProperty.hxx" + +#include <algorithm> +#include <rtl/ustrbuf.hxx> +#include <rtl/math.hxx> + +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; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Grid" )); + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + ::chart::LineProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +GridWrapper::GridWrapper( + tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ), + m_eType( eType ) +{ +} + +GridWrapper::~GridWrapper() +{} + +// static +void GridWrapper::getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid ) +{ + rnDimensionIndex = 1; + rbSubGrid = false; + + switch( eType ) + { + case X_MAIN_GRID: + rnDimensionIndex = 0; rbSubGrid = false; break; + case Y_MAIN_GRID: + rnDimensionIndex = 1; rbSubGrid = false; break; + case Z_MAIN_GRID: + rnDimensionIndex = 2; rbSubGrid = false; break; + case X_SUB_GRID: + rnDimensionIndex = 0; rbSubGrid = true; break; + case Y_SUB_GRID: + rnDimensionIndex = 1; rbSubGrid = true; break; + case Z_SUB_GRID: + rnDimensionIndex = 2; rbSubGrid = true; break; + } +} + +// ____ XComponent ____ +void SAL_CALL GridWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + clearWrappedPropertySet(); +} + +void SAL_CALL GridWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL GridWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +// WrappedPropertySet + +Reference< beans::XPropertySet > GridWrapper::getInnerPropertySet() +{ + Reference< beans::XPropertySet > xRet; + try + { + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + uno::Reference< XCoordinateSystem > 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 ) ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return xRet; +} + +const Sequence< beans::Property >& GridWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > GridWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + aWrappedProperties.push_back( new WrappedDefaultProperty( C2U("LineColor"), C2U("LineColor"), uno::makeAny( sal_Int32( 0x000000) ) ) ); // black + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< OUString > GridWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartGrid" ); + aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" ); + aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( GridWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/GridWrapper.hxx b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx new file mode 100644 index 000000000000..6bbe84f052ab --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/GridWrapper.hxx @@ -0,0 +1,106 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: GridWrapper.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_GRIDWRAPPER_HXX +#define CHART_GRIDWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase2.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#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/chart2/XDiagram.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class GridWrapper : public ::cppu::ImplInheritanceHelper2< + WrappedPropertySet + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + > +{ +public: + enum tGridType + { + X_MAIN_GRID, + Y_MAIN_GRID, + Z_MAIN_GRID, + X_SUB_GRID, + Y_SUB_GRID, + Z_SUB_GRID + }; + + GridWrapper( tGridType eType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~GridWrapper(); + + static void getDimensionAndSubGridBool( tGridType eType, sal_Int32& rnDimensionIndex, bool& rbSubGrid ); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + tGridType m_eType; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_GRIDWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx new file mode 100644 index 000000000000..e6b63308b01d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.cxx @@ -0,0 +1,462 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LegendWrapper.cxx,v $ + * $Revision: 1.9.16.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "LegendWrapper.hxx" +#include "macros.hxx" +#include "Chart2ModelContact.hxx" +#include "LegendHelper.hxx" +#include "ContainerHelper.hxx" +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart/ChartLegendPosition.hpp> +#include <com/sun/star/chart2/LegendPosition.hpp> +#include <com/sun/star/chart2/LegendExpansion.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> + +#include "CharacterProperties.hxx" +#include "LineProperties.hxx" +#include "FillProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedCharacterHeightProperty.hxx" +#include "PositionAndSizeHelper.hxx" +#include "WrappedDirectStateProperty.hxx" +#include "WrappedAutomaticPositionProperties.hxx" +#include "WrappedScaleTextProperties.hxx" + +#include <algorithm> +#include <rtl/ustrbuf.hxx> + +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; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace chart +{ +class WrappedLegendAlignmentProperty : public WrappedProperty +{ +public: + WrappedLegendAlignmentProperty(); + virtual ~WrappedLegendAlignmentProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + +protected: + virtual Any convertInnerToOuterValue( const Any& rInnerValue ) const; + virtual Any convertOuterToInnerValue( const Any& rOuterValue ) const; +}; + +WrappedLegendAlignmentProperty::WrappedLegendAlignmentProperty() + : ::chart::WrappedProperty( C2U( "Alignment" ), C2U( "AnchorPosition" ) ) +{ +} +WrappedLegendAlignmentProperty::~WrappedLegendAlignmentProperty() +{ +} + +Any WrappedLegendAlignmentProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + if( xInnerPropertySet.is() ) + { + sal_Bool bShowLegend = sal_True; + xInnerPropertySet->getPropertyValue( C2U( "Show" ) ) >>= bShowLegend; + if(!bShowLegend) + { + aRet = uno::makeAny( ::com::sun::star::chart::ChartLegendPosition_NONE ); + } + else + { + aRet = xInnerPropertySet->getPropertyValue( m_aInnerName ); + aRet = this->convertInnerToOuterValue( aRet ); + } + } + return aRet; +} + +void WrappedLegendAlignmentProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if(xInnerPropertySet.is()) + { + sal_Bool bNewShowLegend = sal_True; + sal_Bool bOldShowLegend = sal_True; + { + ::com::sun::star::chart::ChartLegendPosition eOuterPos(::com::sun::star::chart::ChartLegendPosition_NONE); + if( (rOuterValue >>= eOuterPos) && eOuterPos == ::com::sun::star::chart::ChartLegendPosition_NONE ) + bNewShowLegend = sal_False; + xInnerPropertySet->getPropertyValue( C2U( "Show" ) ) >>= bOldShowLegend; + } + if(bNewShowLegend!=bOldShowLegend) + { + xInnerPropertySet->setPropertyValue( C2U( "Show" ), uno::makeAny(bNewShowLegend) ); + } + if(!bNewShowLegend) + return; + + //set corresponding LegendPosition + Any aInnerValue = this->convertOuterToInnerValue( rOuterValue ); + xInnerPropertySet->setPropertyValue( m_aInnerName, aInnerValue ); + + //correct LegendExpansion + chart2::LegendPosition eNewInnerPos(chart2::LegendPosition_LINE_END); + if( aInnerValue >>= eNewInnerPos ) + { + chart2::LegendExpansion eNewExpansion = + ( eNewInnerPos == chart2::LegendPosition_LINE_END || + eNewInnerPos == chart2::LegendPosition_LINE_START ) + ? chart2::LegendExpansion_HIGH + : chart2::LegendExpansion_WIDE; + + chart2::LegendExpansion eOldExpansion( chart2::LegendExpansion_HIGH ); + bool bExpansionWasSet( + xInnerPropertySet->getPropertyValue( C2U( "Expansion" ) ) >>= eOldExpansion ); + + if( !bExpansionWasSet || (eOldExpansion != eNewExpansion)) + xInnerPropertySet->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eNewExpansion )); + } + + //correct RelativePosition + Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); + if(aRelativePosition.hasValue()) + { + xInnerPropertySet->setPropertyValue( C2U( "RelativePosition" ), Any() ); + } + } +} + +Any WrappedLegendAlignmentProperty::convertInnerToOuterValue( const Any& rInnerValue ) const +{ + ::com::sun::star::chart::ChartLegendPosition ePos = ::com::sun::star::chart::ChartLegendPosition_NONE; + + chart2::LegendPosition eNewPos; + if( rInnerValue >>= eNewPos ) + { + switch( eNewPos ) + { + case chart2::LegendPosition_LINE_START: + ePos = ::com::sun::star::chart::ChartLegendPosition_LEFT; + break; + case chart2::LegendPosition_LINE_END: + ePos = ::com::sun::star::chart::ChartLegendPosition_RIGHT; + break; + case chart2::LegendPosition_PAGE_START: + ePos = ::com::sun::star::chart::ChartLegendPosition_TOP; + break; + case chart2::LegendPosition_PAGE_END: + ePos = ::com::sun::star::chart::ChartLegendPosition_BOTTOM; + break; + + default: + ePos = ::com::sun::star::chart::ChartLegendPosition_NONE; + break; + } + } + return uno::makeAny( ePos ); +} +Any WrappedLegendAlignmentProperty::convertOuterToInnerValue( const Any& rOuterValue ) const +{ + chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END; + + ::com::sun::star::chart::ChartLegendPosition ePos; + if( rOuterValue >>= ePos ) + { + switch( ePos ) + { + case ::com::sun::star::chart::ChartLegendPosition_LEFT: + eNewPos = chart2::LegendPosition_LINE_START; + break; + case ::com::sun::star::chart::ChartLegendPosition_RIGHT: + eNewPos = chart2::LegendPosition_LINE_END; + break; + case ::com::sun::star::chart::ChartLegendPosition_TOP: + eNewPos = chart2::LegendPosition_PAGE_START; + break; + case ::com::sun::star::chart::ChartLegendPosition_BOTTOM: + eNewPos = chart2::LegendPosition_PAGE_END; + break; + default: // NONE + break; + } + } + + return uno::makeAny( eNewPos ); +} +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Legend" )); + +enum +{ + PROP_LEGEND_ALIGNMENT +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Alignment" ), + PROP_LEGEND_ALIGNMENT, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartLegendPosition * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} +} // anonymous namespace + +// -------------------------------------------------------------------------------- +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +LegendWrapper::LegendWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ) +{ +} + +LegendWrapper::~LegendWrapper() +{ +} + +// ____ XShape ____ +awt::Point SAL_CALL LegendWrapper::getPosition() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetLegendPosition(); +} + +void SAL_CALL LegendWrapper::setPosition( const awt::Point& aPosition ) + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + + chart2::RelativePosition aRelativePosition; + aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; + aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); + aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + xProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } +} + +awt::Size SAL_CALL LegendWrapper::getSize() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetLegendSize(); +} + +void SAL_CALL LegendWrapper::setSize( const awt::Size& aSize ) + throw (beans::PropertyVetoException, + uno::RuntimeException) +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet() ); + if( xProp.is() ) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + awt::Rectangle aPageRectangle( 0,0,aPageSize.Width,aPageSize.Height); + + awt::Point aPos( this->getPosition() ); + awt::Rectangle aNewPositionAndSize(aPos.X,aPos.Y,aSize.Width,aSize.Height); + + PositionAndSizeHelper::moveObject( OBJECTTYPE_LEGEND + , xProp, aNewPositionAndSize, aPageRectangle ); + } +} + +// ____ XShapeDescriptor (base of XShape) ____ +::rtl::OUString SAL_CALL LegendWrapper::getShapeType() + throw (uno::RuntimeException) +{ + return C2U( "com.sun.star.chart.ChartLegend" ); +} + +// ____ XComponent ____ +void SAL_CALL LegendWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + clearWrappedPropertySet(); + // \-- +} + +void SAL_CALL LegendWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL LegendWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +//ReferenceSizePropertyProvider +void LegendWrapper::updateReferenceSize() +{ + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); + if( xProp.is() ) + { + if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) + xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( + m_spChart2ModelContact->GetPageSize() )); + } +} +Any LegendWrapper::getReferenceSize() +{ + Any aRet; + Reference< beans::XPropertySet > xProp( this->getInnerPropertySet(), uno::UNO_QUERY ); + if( xProp.is() ) + aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); + + return aRet; +} +awt::Size LegendWrapper::getCurrentSizeForReference() +{ + return m_spChart2ModelContact->GetPageSize(); +} + +// ================================================================================ + +// WrappedPropertySet +Reference< beans::XPropertySet > LegendWrapper::getInnerPropertySet() +{ + Reference< beans::XPropertySet > xRet; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + xRet.set( xDiagram->getLegend(), uno::UNO_QUERY ); + OSL_ENSURE(xRet.is(),"LegendWrapper::getInnerPropertySet() is NULL"); + return xRet; +} + +const Sequence< beans::Property >& LegendWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > LegendWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + aWrappedProperties.push_back( new WrappedLegendAlignmentProperty() ); + WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); + //same problem as for wall: thje defaults ion the old chart are different for different charttypes, so we need to export explicitly + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") ) ); + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") )); + WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); + WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< ::rtl::OUString > LegendWrapper::getSupportedServiceNames_Static() +{ + Sequence< ::rtl::OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartLegend" ); + aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" ); + aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" ); +// aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" ); +// aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" ); +// aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( LegendWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx new file mode 100644 index 000000000000..85483ec6c59c --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/LegendWrapper.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LegendWrapper.hxx,v $ + * $Revision: 1.5.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_LEGENDWRAPPER_HXX +#define CHART_LEGENDWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ReferenceSizePropertyProvider.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase3.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#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/chart2/XChartDocument.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/chart2/XLegend.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class LegendWrapper : public ::cppu::ImplInheritanceHelper3< + WrappedPropertySet + , com::sun::star::drawing::XShape + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + > + , public ReferenceSizePropertyProvider +{ +public: + LegendWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~LegendWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + //ReferenceSizePropertyProvider + virtual void updateReferenceSize(); + virtual ::com::sun::star::uno::Any getReferenceSize(); + virtual ::com::sun::star::awt::Size getCurrentSizeForReference(); + + // ____ XShape ____ + virtual ::com::sun::star::awt::Point SAL_CALL getPosition() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShapeDescriptor (base of XShape) ____ + virtual ::rtl::OUString SAL_CALL getShapeType() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_LEGENDWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx new file mode 100644 index 000000000000..f545e54f872b --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.cxx @@ -0,0 +1,438 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MinMaxLineWrapper.cxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "MinMaxLineWrapper.hxx" +#include "macros.hxx" +#include "Chart2ModelContact.hxx" +#include "DiagramHelper.hxx" +#include "servicenames_charttypes.hxx" +#include "ContainerHelper.hxx" +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/drawing/LineJoint.hpp> + +#include "LineProperties.hxx" +#include "UserDefinedProperties.hxx" + +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; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartLine" )); + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + + ::chart::LineProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedLineProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +MinMaxLineWrapper::MinMaxLineWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : m_spChart2ModelContact( spChart2ModelContact ) + , m_aEventListenerContainer( m_aMutex ) + , m_pPropertyArrayHelper() + , m_aWrappedLineJointProperty( C2U("LineJoint"), uno::makeAny( drawing::LineJoint_NONE )) +{ +} + +MinMaxLineWrapper::~MinMaxLineWrapper() +{ +} + +// ____ XComponent ____ +void SAL_CALL MinMaxLineWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + m_xInfo.clear(); + // \-- +} + +void SAL_CALL MinMaxLineWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL MinMaxLineWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +::cppu::IPropertyArrayHelper& MinMaxLineWrapper::getInfoHelper() +{ + if(!m_pPropertyArrayHelper.get()) + { + // /-- + ::osl::MutexGuard aGuard( GetMutex() ); + if(!m_pPropertyArrayHelper.get()) + { + sal_Bool bSorted = sal_True; + m_pPropertyArrayHelper = ::boost::shared_ptr< ::cppu::OPropertyArrayHelper >( new ::cppu::OPropertyArrayHelper( lcl_GetPropertySequence(), bSorted ) ); + } + // \-- + } + return *m_pPropertyArrayHelper.get(); +} + +//XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL MinMaxLineWrapper::getPropertySetInfo() + throw (uno::RuntimeException) +{ + if( !m_xInfo.is() ) + { + // /-- + ::osl::MutexGuard aGuard( GetMutex() ); + if( !m_xInfo.is() ) + m_xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); + // \-- + } + return m_xInfo; +} +void SAL_CALL MinMaxLineWrapper::setPropertyValue( const ::rtl::OUString& rPropertyName, const uno::Any& rValue ) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< beans::XPropertySet > xPropSet(0); + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + Sequence< Reference< chart2::XChartType > > aTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + { + Reference< chart2::XChartType > xType( aTypes[nN] ); + if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); + if( xSeriesContainer.is() ) + { + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); + if(aSeriesSeq.getLength()) + { + xPropSet = Reference< beans::XPropertySet >(aSeriesSeq[0],uno::UNO_QUERY); + if(xPropSet.is()) + { + if( rPropertyName.equals( C2U("LineColor")) ) + xPropSet->setPropertyValue( C2U("Color"), rValue ); + else if( rPropertyName.equals( C2U("LineTransparence")) ) + xPropSet->setPropertyValue( C2U("Transparency"), rValue ); + else if( rPropertyName.equals( m_aWrappedLineJointProperty.getOuterName() ) ) + m_aWrappedLineJointProperty.setPropertyValue( rValue, xPropSet ); + else + xPropSet->setPropertyValue( rPropertyName, rValue ); + return; + } + } + } + } + } +} +uno::Any SAL_CALL MinMaxLineWrapper::getPropertyValue( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + + Reference< beans::XPropertySet > xPropSet(0); + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + Sequence< Reference< chart2::XChartType > > aTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + { + Reference< chart2::XChartType > xType( aTypes[nN] ); + if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + Reference< chart2::XDataSeriesContainer > xSeriesContainer(xType,uno::UNO_QUERY); + if( xSeriesContainer.is() ) + { + Sequence< Reference< chart2::XDataSeries > > aSeriesSeq( xSeriesContainer->getDataSeries() ); + if(aSeriesSeq.getLength()) + { + xPropSet = Reference< beans::XPropertySet >(aSeriesSeq[0],uno::UNO_QUERY); + break; + } + } + } + } + if(xPropSet.is()) + { + if( rPropertyName.equals( C2U("LineColor")) ) + aRet = xPropSet->getPropertyValue( C2U("Color") ); + else if( rPropertyName.equals( C2U("LineTransparence")) ) + aRet = xPropSet->getPropertyValue( C2U("Transparency") ); + else if( rPropertyName.equals( m_aWrappedLineJointProperty.getOuterName() ) ) + aRet = m_aWrappedLineJointProperty.getPropertyValue( xPropSet ); + else + aRet = xPropSet->getPropertyValue( rPropertyName ); + + } + return aRet; +} + +void SAL_CALL MinMaxLineWrapper::addPropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL MinMaxLineWrapper::removePropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL MinMaxLineWrapper::addVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL MinMaxLineWrapper::removeVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +//XMultiPropertySet +//getPropertySetInfo() already declared in XPropertySet +void SAL_CALL MinMaxLineWrapper::setPropertyValues( const uno::Sequence< ::rtl::OUString >& rNameSeq, const uno::Sequence< uno::Any >& rValueSeq ) + throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + bool bUnknownProperty = false; + sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<nMinCount; nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + try + { + this->setPropertyValue( aPropertyName, rValueSeq[nN] ); + } + catch( beans::UnknownPropertyException& ex ) + { + ASSERT_EXCEPTION( ex ); + bUnknownProperty = true; + } + } + //todo: store unknown properties elsewhere +// if( bUnknownProperty ) +// throw beans::UnknownPropertyException(); +} +uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyValues( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (uno::RuntimeException) +{ + Sequence< Any > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyValue( aPropertyName ); + } + } + return aRetSeq; +} +void SAL_CALL MinMaxLineWrapper::addPropertiesChangeListener( + const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, + const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL MinMaxLineWrapper::removePropertiesChangeListener( + const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL MinMaxLineWrapper::firePropertiesChangeEvent( + const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, + const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +//XPropertyState +beans::PropertyState SAL_CALL MinMaxLineWrapper::getPropertyState( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + if( rPropertyName.equals( m_aWrappedLineJointProperty.getOuterName() ) ) + return beans::PropertyState_DEFAULT_VALUE; + + uno::Any aDefault( this->getPropertyDefault( rPropertyName ) ); + uno::Any aValue( this->getPropertyValue( rPropertyName ) ); + + if( aDefault == aValue ) + return beans::PropertyState_DEFAULT_VALUE; + + return beans::PropertyState_DIRECT_VALUE; +} +uno::Sequence< beans::PropertyState > SAL_CALL MinMaxLineWrapper::getPropertyStates( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + Sequence< beans::PropertyState > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyState( aPropertyName ); + } + } + return aRetSeq; +} +void SAL_CALL MinMaxLineWrapper::setPropertyToDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + this->setPropertyValue( rPropertyName, this->getPropertyDefault(rPropertyName) ); +} +uno::Any SAL_CALL MinMaxLineWrapper::getPropertyDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + static tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + LineProperties::AddDefaultsToMap( aStaticDefaults ); + } + + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + + tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; +} + +//XMultiPropertyStates +//getPropertyStates() already declared in XPropertyState +void SAL_CALL MinMaxLineWrapper::setAllPropertiesToDefault( ) + throw (uno::RuntimeException) +{ + const Sequence< beans::Property >& rPropSeq = lcl_GetPropertySequence(); + for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rPropSeq[nN].Name ); + this->setPropertyToDefault( aPropertyName ); + } +} +void SAL_CALL MinMaxLineWrapper::setPropertiesToDefault( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + this->setPropertyToDefault( aPropertyName ); + } +} +uno::Sequence< uno::Any > SAL_CALL MinMaxLineWrapper::getPropertyDefaults( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Sequence< Any > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyDefault( aPropertyName ); + } + } + return aRetSeq; +} + + +// ================================================================================ + +Sequence< OUString > MinMaxLineWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 3 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartLine" ); + aServices[ 1 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( MinMaxLineWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx new file mode 100644 index 000000000000..411c97e71a5e --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/MinMaxLineWrapper.hxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MinMaxLineWrapper.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_MINMAXLINEWRAPPER_HXX +#define CHART_MINMAXLINEWRAPPER_HXX + +#include "ServiceMacros.hxx" +#include "MutexContainer.hxx" +#include "WrappedIgnoreProperty.hxx" +#include <cppuhelper/interfacecontainer.hxx> + + +#include <com/sun/star/chart2/XDiagram.hpp> + +// header for class OPropertyArrayHelper +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase6.hxx> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class MinMaxLineWrapper : public MutexContainer + , public ::cppu::WeakImplHelper6 + < ::com::sun::star::lang::XComponent + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::beans::XPropertySet + , ::com::sun::star::beans::XMultiPropertySet + , ::com::sun::star::beans::XPropertyState + , ::com::sun::star::beans::XMultiPropertyStates + // , ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface) + // , ::com::sun::star::uno::XInterface // implemented by WeakImplHelper + // , ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper + > +{ +public: + MinMaxLineWrapper( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~MinMaxLineWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + //XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //XMultiPropertySet + //getPropertySetInfo() already declared in XPropertySet + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + //XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //XMultiPropertyStates + //getPropertyStates() already declared in XPropertyState + virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //methods + ::cppu::IPropertyArrayHelper& getInfoHelper(); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > + m_xInfo;//outer PropertySetInfo + + ::boost::shared_ptr< ::cppu::OPropertyArrayHelper > m_pPropertyArrayHelper; + + WrappedIgnoreProperty m_aWrappedLineJointProperty; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_MINMAXLINEWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx b/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx new file mode 100644 index 000000000000..c9199bcadaff --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/ReferenceSizePropertyProvider.hxx @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ReferenceSizePropertyProvider.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX +#define CHART_WRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX + +#include <com/sun/star/awt/Size.hpp> + +namespace chart +{ +namespace wrapper +{ +class ReferenceSizePropertyProvider +{ +public: + virtual void updateReferenceSize() = 0; + virtual ::com::sun::star::uno::Any getReferenceSize() = 0; + virtual ::com::sun::star::awt::Size getCurrentSizeForReference() = 0; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_WRAPPER_REFERENCESIZEPROPERTYPROVIDER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx new file mode 100644 index 000000000000..a84dbc0cfc4d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.cxx @@ -0,0 +1,537 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleWrapper.cxx,v $ + * $Revision: 1.8.44.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "TitleWrapper.hxx" +#include "macros.hxx" +#include "ContainerHelper.hxx" +#include <comphelper/InlineContainer.hxx> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> + +#include "CharacterProperties.hxx" +#include "LineProperties.hxx" +#include "FillProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedCharacterHeightProperty.hxx" +#include "WrappedTextRotationProperty.hxx" +#include "WrappedAutomaticPositionProperties.hxx" +#include "WrappedScaleTextProperties.hxx" + +#include <algorithm> +#include <rtl/ustrbuf.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::beans::Property; +using ::osl::MutexGuard; +using ::rtl::OUString; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + + +namespace chart +{ +class WrappedTitleStringProperty : public WrappedProperty +{ +public: + WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ); + virtual ~WrappedTitleStringProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + +protected: + Reference< uno::XComponentContext > m_xContext; +}; + +WrappedTitleStringProperty::WrappedTitleStringProperty( const Reference< uno::XComponentContext >& xContext ) + : ::chart::WrappedProperty( C2U( "String" ), OUString() ) + , m_xContext( xContext ) +{ +} +WrappedTitleStringProperty::~WrappedTitleStringProperty() +{ +} + +void WrappedTitleStringProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); + if(xTitle.is()) + { + OUString aString; + rOuterValue >>= aString; + TitleHelper::setCompleteString( aString, xTitle, m_xContext ); + } +} +Any WrappedTitleStringProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); + Reference< chart2::XTitle > xTitle(xInnerPropertySet,uno::UNO_QUERY); + if(xTitle.is()) + { + Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + + ::rtl::OUStringBuffer aBuf; + for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + { + aBuf.append( aStrings[ i ]->getString()); + } + aRet <<= aBuf.makeStringAndClear(); + } + return aRet; +} +Any WrappedTitleStringProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( rtl::OUString() );//default title is a empty String +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +class WrappedStackedTextProperty : public WrappedProperty +{ +public: + WrappedStackedTextProperty(); + virtual ~WrappedStackedTextProperty(); +}; + +WrappedStackedTextProperty::WrappedStackedTextProperty() + : ::chart::WrappedProperty( C2U( "StackedText" ), C2U( "StackCharacters" ) ) +{ +} +WrappedStackedTextProperty::~WrappedStackedTextProperty() +{ +} + +}// end namespace chart + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.Title" )); + +enum +{ + PROP_TITLE_STRING, + PROP_TITLE_TEXT_ROTATION, + PROP_TITLE_TEXT_STACKED +}; + +void lcl_AddPropertiesToVector( + ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "String" ), + PROP_TITLE_STRING, + ::getCppuType( reinterpret_cast< const ::rtl::OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEVOID )); + + rOutProperties.push_back( + Property( C2U( "TextRotation" ), + PROP_TITLE_TEXT_ROTATION, + ::getCppuType( reinterpret_cast< const sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "StackedText" ), + PROP_TITLE_TEXT_STACKED, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< beans::Property > aProperties; + lcl_AddPropertiesToVector( aProperties ); + ::chart::CharacterProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + ::chart::wrapper::WrappedAutomaticPositionProperties::addProperties( aProperties ); + ::chart::wrapper::WrappedScaleTextProperties::addProperties( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +TitleWrapper::TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ), + m_eTitleType(eTitleType) +{ +} + +TitleWrapper::~TitleWrapper() +{ +} + +// ____ XShape ____ +awt::Point SAL_CALL TitleWrapper::getPosition() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetTitlePosition( this->getTitleObject() ); +} + +void SAL_CALL TitleWrapper::setPosition( const awt::Point& aPosition ) + throw (uno::RuntimeException) +{ + Reference< beans::XPropertySet > xPropertySet( this->getInnerPropertySet() ); + if(xPropertySet.is()) + { + awt::Size aPageSize( m_spChart2ModelContact->GetPageSize() ); + + chart2::RelativePosition aRelativePosition; + aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; + aRelativePosition.Primary = double(aPosition.X)/double(aPageSize.Width); + aRelativePosition.Secondary = double(aPosition.Y)/double(aPageSize.Height); + xPropertySet->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } +} + +awt::Size SAL_CALL TitleWrapper::getSize() + throw (uno::RuntimeException) +{ + return m_spChart2ModelContact->GetTitleSize( this->getTitleObject() ); +} + +void SAL_CALL TitleWrapper::setSize( const awt::Size& /*aSize*/ ) + throw (beans::PropertyVetoException, + uno::RuntimeException) +{ + OSL_ENSURE( false, "trying to set size of title" ); +} + +// ____ XShapeDescriptor (base of XShape) ____ +OUString SAL_CALL TitleWrapper::getShapeType() + throw (uno::RuntimeException) +{ + return C2U( "com.sun.star.chart.ChartTitle" ); +} + +// ____ XComponent ____ +void SAL_CALL TitleWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + clearWrappedPropertySet(); + // \-- +} + +void SAL_CALL TitleWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL TitleWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +Reference< beans::XPropertySet > TitleWrapper::getFirstCharacterPropertySet() +{ + Reference< beans::XPropertySet > xProp; + + Reference< chart2::XTitle > xTitle( this->getTitleObject() ); + if( xTitle.is()) + { + Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + if( aStrings.getLength() > 0 ) + xProp.set( aStrings[0], uno::UNO_QUERY ); + } + + return xProp; +} + +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(), uno::UNO_QUERY ); + Reference< beans::XFastPropertySet > xFastProp( xProp, uno::UNO_QUERY ); + if(xProp.is()) + { + const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); + if( pWrappedProperty ) + { + rValue = pWrappedProperty->getPropertyValue( xProp ); + } + else if( xFastProp.is() ) + { + rValue = xFastProp->getFastPropertyValue( nHandle ); + } + } + +} + +void TitleWrapper::setFastCharacterPropertyValue( + sal_Int32 nHandle, const Any& rValue ) throw (uno::Exception) +{ + OSL_ASSERT( FAST_PROPERTY_ID_START_CHAR_PROP <= nHandle && + nHandle < CharacterProperties::FAST_PROPERTY_ID_END_CHAR_PROP ); + + Reference< chart2::XTitle > xTitle( this->getTitleObject() ); + if( xTitle.is()) + { + Sequence< Reference< chart2::XFormattedString > > aStrings( xTitle->getText()); + const WrappedProperty* pWrappedProperty = getWrappedProperty( nHandle ); + + for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + { + Reference< beans::XFastPropertySet > xFastPropertySet( aStrings[ i ], uno::UNO_QUERY ); + Reference< beans::XPropertySet > xPropSet( xFastPropertySet, uno::UNO_QUERY ); + + if( pWrappedProperty ) + pWrappedProperty->setPropertyValue( rValue, xPropSet ); + else if( xFastPropertySet.is() ) + xFastPropertySet->setFastPropertyValue( nHandle, rValue ); + } + } +} + +// ================================================================================ +// WrappedPropertySet + +void SAL_CALL TitleWrapper::setPropertyValue( const OUString& rPropertyName, const Any& rValue ) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) + { + setFastCharacterPropertyValue( nHandle, rValue ); + } + else + WrappedPropertySet::setPropertyValue( rPropertyName, rValue ); +} + +Any SAL_CALL TitleWrapper::getPropertyValue( const OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) + getFastCharacterPropertyValue( nHandle, aRet ); + else + aRet = WrappedPropertySet::getPropertyValue( rPropertyName ); + return aRet; +} + +beans::PropertyState SAL_CALL TitleWrapper::getPropertyState( const OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + beans::PropertyState aState( beans::PropertyState_DIRECT_VALUE ); + + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) + { + Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + if( xPropState.is() ) + { + const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); + if( pWrappedProperty ) + aState = pWrappedProperty->getPropertyState( xPropState ); + else + aState = xPropState->getPropertyState( rPropertyName ); + } + } + else + aState = WrappedPropertySet::getPropertyState( rPropertyName ); + + return aState; +} +void SAL_CALL TitleWrapper::setPropertyToDefault( const OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) + { + Any aDefault = getPropertyDefault( rPropertyName ); + setFastCharacterPropertyValue( nHandle, aDefault ); + } + else + WrappedPropertySet::setPropertyToDefault( rPropertyName ); +} +Any SAL_CALL TitleWrapper::getPropertyDefault( const OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + if( CharacterProperties::IsCharacterPropertyHandle( nHandle ) ) + { + Reference< beans::XPropertyState > xPropState( getFirstCharacterPropertySet(), uno::UNO_QUERY ); + if( xPropState.is() ) + { + const WrappedProperty* pWrappedProperty = getWrappedProperty( rPropertyName ); + if( pWrappedProperty ) + aRet = pWrappedProperty->getPropertyDefault(xPropState); + else + aRet = xPropState->getPropertyDefault( rPropertyName ); + } + } + else + aRet = WrappedPropertySet::getPropertyDefault( rPropertyName ); + + return aRet; +} + +// ================================================================================ + +//ReferenceSizePropertyProvider +void TitleWrapper::updateReferenceSize() +{ + Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY ); + if( xProp.is() ) + { + if( xProp->getPropertyValue( C2U("ReferencePageSize") ).hasValue() ) + xProp->setPropertyValue( C2U("ReferencePageSize"), uno::makeAny( + m_spChart2ModelContact->GetPageSize() )); + } +} +Any TitleWrapper::getReferenceSize() +{ + Any aRet; + Reference< beans::XPropertySet > xProp( this->getTitleObject(), uno::UNO_QUERY ); + if( xProp.is() ) + aRet = xProp->getPropertyValue( C2U("ReferencePageSize") ); + + return aRet; +} +awt::Size TitleWrapper::getCurrentSizeForReference() +{ + return m_spChart2ModelContact->GetPageSize(); +} + +// ================================================================================ + +Reference< chart2::XTitle > TitleWrapper::getTitleObject() +{ + return TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ); +} + +// WrappedPropertySet + +Reference< beans::XPropertySet > TitleWrapper::getInnerPropertySet() +{ + return Reference< beans::XPropertySet >( this->getTitleObject(), uno::UNO_QUERY ); +} + +const Sequence< beans::Property >& TitleWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > TitleWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + aWrappedProperties.push_back( new WrappedTitleStringProperty( m_spChart2ModelContact->m_xContext ) ); + aWrappedProperties.push_back( new WrappedTextRotationProperty( m_eTitleType==TitleHelper::Y_AXIS_TITLE || m_eTitleType==TitleHelper::X_AXIS_TITLE ) ); + aWrappedProperties.push_back( new WrappedStackedTextProperty() ); + WrappedCharacterHeightProperty::addWrappedProperties( aWrappedProperties, this ); + WrappedAutomaticPositionProperties::addWrappedProperties( aWrappedProperties ); + WrappedScaleTextProperties::addWrappedProperties( aWrappedProperties, m_spChart2ModelContact ); + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< OUString > TitleWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.chart.ChartTitle" ); + aServices[ 1 ] = C2U( "com.sun.star.drawing.Shape" ); + aServices[ 2 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 3 ] = C2U( "com.sun.star.style.CharacterProperties" ); +// aServices[ 4 ] = C2U( "com.sun.star.beans.PropertySet" ); +// aServices[ 5 ] = C2U( "com.sun.star.drawing.FillProperties" ); +// aServices[ 6 ] = C2U( "com.sun.star.drawing.LineProperties" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( TitleWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx new file mode 100644 index 000000000000..3e0db1ed1e42 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/TitleWrapper.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleWrapper.hxx,v $ + * $Revision: 1.6.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_TITLEWRAPPER_HXX +#define CHART_TITLEWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ReferenceSizePropertyProvider.hxx" +#include "Chart2ModelContact.hxx" +#include "ServiceMacros.hxx" +#include "TitleHelper.hxx" +#include <cppuhelper/implbase3.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#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/chart2/XTitle.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ +namespace wrapper +{ + +class TitleWrapper : public ::cppu::ImplInheritanceHelper3< + WrappedPropertySet + , com::sun::star::drawing::XShape + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + > + , public ReferenceSizePropertyProvider +{ +public: + TitleWrapper( ::chart::TitleHelper::eTitleType eTitleType, + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~TitleWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + //ReferenceSizePropertyProvider + virtual void updateReferenceSize(); + virtual ::com::sun::star::uno::Any getReferenceSize(); + virtual ::com::sun::star::awt::Size getCurrentSizeForReference(); + +protected: + // ____ XShape ____ + virtual ::com::sun::star::awt::Point SAL_CALL getPosition() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPosition( const ::com::sun::star::awt::Point& aPosition ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setSize( const ::com::sun::star::awt::Size& aSize ) + throw (::com::sun::star::beans::PropertyVetoException, + ::com::sun::star::uno::RuntimeException); + + // ____ XShapeDescriptor (base of XShape) ____ + virtual ::rtl::OUString SAL_CALL getShapeType() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // character properties have to be handled differently (via the XFormattedString elements) + void getFastCharacterPropertyValue( sal_Int32 nHandle, ::com::sun::star::uno::Any& rValue ); + void setFastCharacterPropertyValue( sal_Int32 nHandle, const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::Exception); + + // ____ WrappedPropertySet ____ + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getFirstCharacterPropertySet(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XTitle > getTitleObject(); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + ::chart::TitleHelper::eTitleType m_eTitleType; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_TITLEWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx new file mode 100644 index 000000000000..e2a74834d249 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.cxx @@ -0,0 +1,405 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: UpDownBarWrapper.cxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "UpDownBarWrapper.hxx" +#include "macros.hxx" +#include "Chart2ModelContact.hxx" +#include "DiagramHelper.hxx" +#include "servicenames_charttypes.hxx" +#include "ContainerHelper.hxx" +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> + +#include "LineProperties.hxx" +#include "FillProperties.hxx" +// #include "NamedProperties.hxx" +#include "UserDefinedProperties.hxx" + +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; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ChartArea" )); + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + + ::chart::LineProperties::AddPropertiesToVector( aProperties ); + ::chart::FillProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +UpDownBarWrapper::UpDownBarWrapper( + bool bUp, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : m_spChart2ModelContact( spChart2ModelContact ) + , m_aEventListenerContainer( m_aMutex ) + , m_aPropertySetName( bUp ? C2U("WhiteDay") : C2U("BlackDay") ) + , m_xInfo(0) + , m_pPropertyArrayHelper() +{ +} + +UpDownBarWrapper::~UpDownBarWrapper() +{ +} + +// ____ XComponent ____ +void SAL_CALL UpDownBarWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + m_xInfo.clear(); + // \-- +} + +void SAL_CALL UpDownBarWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL UpDownBarWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +::cppu::IPropertyArrayHelper& UpDownBarWrapper::getInfoHelper() +{ + if(!m_pPropertyArrayHelper.get()) + { + // /-- + ::osl::MutexGuard aGuard( GetMutex() ); + if(!m_pPropertyArrayHelper.get()) + { + sal_Bool bSorted = sal_True; + m_pPropertyArrayHelper = ::boost::shared_ptr< ::cppu::OPropertyArrayHelper >( new ::cppu::OPropertyArrayHelper( lcl_GetPropertySequence(), bSorted ) ); + } + // \-- + } + return *m_pPropertyArrayHelper.get(); +} + +//XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL UpDownBarWrapper::getPropertySetInfo() + throw (uno::RuntimeException) +{ + if( !m_xInfo.is() ) + { + // /-- + ::osl::MutexGuard aGuard( GetMutex() ); + if( !m_xInfo.is() ) + m_xInfo = ::cppu::OPropertySetHelper::createPropertySetInfo( getInfoHelper() ); + // \-- + } + return m_xInfo; +} +void SAL_CALL UpDownBarWrapper::setPropertyValue( const ::rtl::OUString& rPropertyName, const uno::Any& rValue ) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< beans::XPropertySet > xPropSet(0); + + Sequence< Reference< chart2::XChartType > > aTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + { + Reference< chart2::XChartType > xType( aTypes[nN] ); + if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY ); + if(xTypeProps.is()) + { + xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; + } + } + } + if(xPropSet.is()) + xPropSet->setPropertyValue( rPropertyName, rValue ); +} +uno::Any SAL_CALL UpDownBarWrapper::getPropertyValue( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + + Reference< beans::XPropertySet > xPropSet(0); + + Sequence< Reference< chart2::XChartType > > aTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + for( sal_Int32 nN = 0; nN < aTypes.getLength(); nN++ ) + { + Reference< chart2::XChartType > xType( aTypes[nN] ); + if( xType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + Reference< beans::XPropertySet > xTypeProps( aTypes[nN], uno::UNO_QUERY ); + if(xTypeProps.is()) + { + xTypeProps->getPropertyValue( m_aPropertySetName ) >>= xPropSet; + } + } + } + if(xPropSet.is()) + aRet = xPropSet->getPropertyValue( rPropertyName ); + return aRet; +} + +void SAL_CALL UpDownBarWrapper::addPropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL UpDownBarWrapper::removePropertyChangeListener( const ::rtl::OUString& /*aPropertyName*/, const uno::Reference< beans::XPropertyChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL UpDownBarWrapper::addVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL UpDownBarWrapper::removeVetoableChangeListener( const ::rtl::OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener >& /*aListener*/ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +//XMultiPropertySet +//getPropertySetInfo() already declared in XPropertySet +void SAL_CALL UpDownBarWrapper::setPropertyValues( const uno::Sequence< ::rtl::OUString >& rNameSeq, const uno::Sequence< uno::Any >& rValueSeq ) + throw (beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + bool bUnknownProperty = false; + sal_Int32 nMinCount = std::min( rValueSeq.getLength(), rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<nMinCount; nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + try + { + this->setPropertyValue( aPropertyName, rValueSeq[nN] ); + } + catch( beans::UnknownPropertyException& ex ) + { + ASSERT_EXCEPTION( ex ); + bUnknownProperty = true; + } + } + //todo: store unknown properties elsewhere +// if( bUnknownProperty ) +// throw beans::UnknownPropertyException(); +} +uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyValues( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (uno::RuntimeException) +{ + Sequence< Any > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyValue( aPropertyName ); + } + } + return aRetSeq; +} +void SAL_CALL UpDownBarWrapper::addPropertiesChangeListener( const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL UpDownBarWrapper::removePropertiesChangeListener( const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL UpDownBarWrapper::firePropertiesChangeEvent( const uno::Sequence< ::rtl::OUString >& /* aPropertyNames */, const uno::Reference< beans::XPropertiesChangeListener >& /* xListener */ ) + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +//XPropertyState +beans::PropertyState SAL_CALL UpDownBarWrapper::getPropertyState( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + uno::Any aDefault( this->getPropertyDefault( rPropertyName ) ); + uno::Any aValue( this->getPropertyValue( rPropertyName ) ); + + if( aDefault == aValue ) + return beans::PropertyState_DEFAULT_VALUE; + + return beans::PropertyState_DIRECT_VALUE; +} +uno::Sequence< beans::PropertyState > SAL_CALL UpDownBarWrapper::getPropertyStates( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + Sequence< beans::PropertyState > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyState( aPropertyName ); + } + } + return aRetSeq; +} +void SAL_CALL UpDownBarWrapper::setPropertyToDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + this->setPropertyValue( rPropertyName, this->getPropertyDefault(rPropertyName) ); +} +uno::Any SAL_CALL UpDownBarWrapper::getPropertyDefault( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + static tPropertyValueMap aStaticDefaults; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aStaticDefaults.size() ) + { + LineProperties::AddDefaultsToMap( aStaticDefaults ); + FillProperties::AddDefaultsToMap( aStaticDefaults ); + } + + sal_Int32 nHandle = getInfoHelper().getHandleByName( rPropertyName ); + + tPropertyValueMap::const_iterator aFound( + aStaticDefaults.find( nHandle )); + + if( aFound == aStaticDefaults.end()) + return uno::Any(); + + return (*aFound).second; +} + +//XMultiPropertyStates +//getPropertyStates() already declared in XPropertyState +void SAL_CALL UpDownBarWrapper::setAllPropertiesToDefault( ) + throw (uno::RuntimeException) +{ + const Sequence< beans::Property >& rPropSeq = lcl_GetPropertySequence(); + for(sal_Int32 nN=0; nN<rPropSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rPropSeq[nN].Name ); + this->setPropertyToDefault( aPropertyName ); + } +} +void SAL_CALL UpDownBarWrapper::setPropertiesToDefault( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + this->setPropertyToDefault( aPropertyName ); + } +} +uno::Sequence< uno::Any > SAL_CALL UpDownBarWrapper::getPropertyDefaults( const uno::Sequence< ::rtl::OUString >& rNameSeq ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Sequence< Any > aRetSeq; + if( rNameSeq.getLength() ) + { + aRetSeq.realloc( rNameSeq.getLength() ); + for(sal_Int32 nN=0; nN<rNameSeq.getLength(); nN++) + { + ::rtl::OUString aPropertyName( rNameSeq[nN] ); + aRetSeq[nN] = this->getPropertyDefault( aPropertyName ); + } + } + return aRetSeq; +} + + +// ================================================================================ + +Sequence< OUString > UpDownBarWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 4 ); + aServices[ 0 ] = ::rtl::OUString::createFromAscii( "com.sun.star.chart.ChartArea" ); + aServices[ 1 ] = ::rtl::OUString::createFromAscii( "com.sun.star.drawing.LineProperties" ); + aServices[ 2 ] = ::rtl::OUString::createFromAscii( "com.sun.star.drawing.FillProperties" ); + aServices[ 3 ] = ::rtl::OUString::createFromAscii( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( UpDownBarWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx new file mode 100644 index 000000000000..ce83ece0a4bf --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/UpDownBarWrapper.hxx @@ -0,0 +1,140 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: UpDownBarWrapper.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_UPDOWNBARWRAPPER_HXX +#define CHART_UPDOWNBARWRAPPER_HXX + +#include "ServiceMacros.hxx" +#include "MutexContainer.hxx" +#include <cppuhelper/interfacecontainer.hxx> + + +#include <com/sun/star/chart2/XDiagram.hpp> + +// header for class OPropertyArrayHelper +#include <cppuhelper/propshlp.hxx> +#include <cppuhelper/implbase6.hxx> +#include <com/sun/star/beans/XMultiPropertySet.hpp> +#include <com/sun/star/beans/XMultiPropertyStates.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class UpDownBarWrapper : public MutexContainer + , public ::cppu::WeakImplHelper6 + < ::com::sun::star::lang::XComponent + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::beans::XPropertySet + , ::com::sun::star::beans::XMultiPropertySet + , ::com::sun::star::beans::XPropertyState + , ::com::sun::star::beans::XMultiPropertyStates + // , ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface) + // , ::com::sun::star::uno::XInterface // implemented by WeakImplHelper + // , ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper + > +{ +public: + UpDownBarWrapper( bool bUp, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~UpDownBarWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + //XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //XMultiPropertySet + //getPropertySetInfo() already declared in XPropertySet + virtual void SAL_CALL setPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aValues ) throw (::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyValues( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertiesChangeListener( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertiesChangeListener( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL firePropertiesChangeEvent( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertiesChangeListener >& xListener ) throw (::com::sun::star::uno::RuntimeException); + + //XPropertyState + virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyState > SAL_CALL getPropertyStates( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + //XMultiPropertyStates + //getPropertyStates() already declared in XPropertyState + virtual void SAL_CALL setAllPropertiesToDefault( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertiesToDefault( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > SAL_CALL getPropertyDefaults( const ::com::sun::star::uno::Sequence< ::rtl::OUString >& aPropertyNames ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //methods + ::cppu::IPropertyArrayHelper& getInfoHelper(); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + rtl::OUString m_aPropertySetName; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > + m_xInfo;//outer PropertySetInfo + ::boost::shared_ptr< ::cppu::OPropertyArrayHelper > m_pPropertyArrayHelper; + +}; + +} // namespace wrapper +} // namespace chart + +// CHART_UPDOWNBARWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx new file mode 100644 index 000000000000..efda626e5fd6 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WallFloorWrapper.cxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WallFloorWrapper.hxx" +#include "macros.hxx" +#include "Chart2ModelContact.hxx" +#include "ContainerHelper.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/drawing/FillStyle.hpp> + +#include "FillProperties.hxx" +#include "LineProperties.hxx" +#include "UserDefinedProperties.hxx" +#include "WrappedDirectStateProperty.hxx" + +#include <algorithm> +#include <rtl/ustrbuf.hxx> +#include <rtl/math.hxx> + +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::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ +static const OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.WallOrFloor" )); + +const Sequence< Property > & lcl_GetPropertySequence() +{ + static Sequence< Property > aPropSeq; + + // /-- + MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( 0 == aPropSeq.getLength() ) + { + // get properties + ::std::vector< ::com::sun::star::beans::Property > aProperties; + ::chart::FillProperties::AddPropertiesToVector( aProperties ); + ::chart::LineProperties::AddPropertiesToVector( aProperties ); +// ::chart::NamedProperties::AddPropertiesToVector( aProperties ); + ::chart::UserDefinedProperties::AddPropertiesToVector( aProperties ); + + // and sort them for access via bsearch + ::std::sort( aProperties.begin(), aProperties.end(), + ::chart::PropertyNameLess() ); + + // transfer result to static Sequence + aPropSeq = ::chart::ContainerHelper::ContainerToSequence( aProperties ); + } + + return aPropSeq; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ +namespace wrapper +{ + +WallFloorWrapper::WallFloorWrapper( bool bWall, + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) : + m_spChart2ModelContact( spChart2ModelContact ), + m_aEventListenerContainer( m_aMutex ), + m_bWall( bWall ) + +{ +} + +WallFloorWrapper::~WallFloorWrapper() +{ +} + +// ____ XComponent ____ +void SAL_CALL WallFloorWrapper::dispose() + throw (uno::RuntimeException) +{ + Reference< uno::XInterface > xSource( static_cast< ::cppu::OWeakObject* >( this ) ); + m_aEventListenerContainer.disposeAndClear( lang::EventObject( xSource ) ); + + // /-- + MutexGuard aGuard( GetMutex()); + clearWrappedPropertySet(); + // \-- +} + +void SAL_CALL WallFloorWrapper::addEventListener( + const Reference< lang::XEventListener >& xListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.addInterface( xListener ); +} + +void SAL_CALL WallFloorWrapper::removeEventListener( + const Reference< lang::XEventListener >& aListener ) + throw (uno::RuntimeException) +{ + m_aEventListenerContainer.removeInterface( aListener ); +} + +// ================================================================================ + +// WrappedPropertySet +Reference< beans::XPropertySet > WallFloorWrapper::getInnerPropertySet() +{ + Reference< beans::XPropertySet > xRet; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + if( m_bWall ) + xRet.set( xDiagram->getWall() ); + else + xRet.set( xDiagram->getFloor() ); + } + + return xRet; +} + +const Sequence< beans::Property >& WallFloorWrapper::getPropertySequence() +{ + return lcl_GetPropertySequence(); +} + +const std::vector< WrappedProperty* > WallFloorWrapper::createWrappedProperties() +{ + ::std::vector< ::chart::WrappedProperty* > aWrappedProperties; + + // use direct state always, so that in XML the value is always + // 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.push_back( new WrappedDirectStateProperty( C2U("FillStyle"), C2U("FillStyle") )); + aWrappedProperties.push_back( new WrappedDirectStateProperty( C2U("FillColor"), C2U("FillColor") )); + + return aWrappedProperties; +} + +// ================================================================================ + +Sequence< OUString > WallFloorWrapper::getSupportedServiceNames_Static() +{ + Sequence< OUString > aServices( 4 ); + aServices[ 0 ] = C2U( "com.sun.star.xml.UserDefinedAttributeSupplier" ); + aServices[ 1 ] = C2U( "com.sun.star.drawing.FillProperties" ); + aServices[ 2 ] = C2U( "com.sun.star.drawing.LineProperties" ); + aServices[ 3 ] = C2U( "com.sun.star.beans.PropertySet" ); + + return aServices; +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( WallFloorWrapper, lcl_aServiceName ); + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx new file mode 100644 index 000000000000..1e975bbb1ab0 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WallFloorWrapper.hxx @@ -0,0 +1,92 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WallFloorWrapper.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WALLFLOORWRAPPER_HXX +#define CHART_WALLFLOORWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase2.hxx> +#include <comphelper/uno3.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <com/sun/star/lang/XComponent.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class WallFloorWrapper : public ::cppu::ImplInheritanceHelper2< + WrappedPropertySet + , com::sun::star::lang::XComponent + , com::sun::star::lang::XServiceInfo + > +{ +public: + WallFloorWrapper( bool bWall, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WallFloorWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + ::cppu::OInterfaceContainerHelper m_aEventListenerContainer; + + bool m_bWall; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_WALLFLOORWRAPPER_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx new file mode 100644 index 000000000000..1f4aa3c96d47 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.cxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAddInProperty.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedAddInProperty.hxx" +#include "macros.hxx" + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. +namespace wrapper +{ + +WrappedAddInProperty::WrappedAddInProperty( ChartDocumentWrapper& rChartDocumentWrapper ) + : ::chart::WrappedProperty( C2U( "AddIn" ), OUString() ) + , m_rChartDocumentWrapper( rChartDocumentWrapper ) +{ +} +WrappedAddInProperty::~WrappedAddInProperty() +{ +} + +void WrappedAddInProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< util::XRefreshable > xAddIn; + if( ! (rOuterValue >>= xAddIn) ) + throw lang::IllegalArgumentException( C2U("AddIn properties require type XRefreshable"), 0, 0 ); + + m_rChartDocumentWrapper.setAddIn( xAddIn ); +} + +Any WrappedAddInProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( m_rChartDocumentWrapper.getAddIn() ); +} + +//............................................................................. +//............................................................................. +//............................................................................. + +WrappedBaseDiagramProperty::WrappedBaseDiagramProperty( ChartDocumentWrapper& rChartDocumentWrapper ) + : ::chart::WrappedProperty( C2U( "BaseDiagram" ), OUString() ) + , m_rChartDocumentWrapper( rChartDocumentWrapper ) +{ +} +WrappedBaseDiagramProperty::~WrappedBaseDiagramProperty() +{ +} + +void WrappedBaseDiagramProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + rtl::OUString aBaseDiagram; + if( ! (rOuterValue >>= aBaseDiagram) ) + throw lang::IllegalArgumentException( C2U("BaseDiagram properties require type OUString"), 0, 0 ); + + m_rChartDocumentWrapper.setBaseDiagram( aBaseDiagram ); +} + +Any WrappedBaseDiagramProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( m_rChartDocumentWrapper.getBaseDiagram() ); +} + +//............................................................................. +//............................................................................. +//............................................................................. + +WrappedAdditionalShapesProperty::WrappedAdditionalShapesProperty( ChartDocumentWrapper& rChartDocumentWrapper ) + : ::chart::WrappedProperty( C2U( "AdditionalShapes" ), OUString() ) + , m_rChartDocumentWrapper( rChartDocumentWrapper ) +{ +} +WrappedAdditionalShapesProperty::~WrappedAdditionalShapesProperty() +{ +} + +void WrappedAdditionalShapesProperty::setPropertyValue( const Any& /*rOuterValue*/, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + throw lang::IllegalArgumentException( C2U("AdditionalShapes is a read only property"), 0, 0 ); +} + +Any WrappedAdditionalShapesProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( m_rChartDocumentWrapper.getAdditionalShapes() ); +} + +//............................................................................. +//............................................................................. +//............................................................................. + +WrappedRefreshAddInAllowedProperty::WrappedRefreshAddInAllowedProperty( ChartDocumentWrapper& rChartDocumentWrapper ) + : ::chart::WrappedProperty( C2U( "RefreshAddInAllowed" ), OUString() ) + , m_rChartDocumentWrapper( rChartDocumentWrapper ) +{ +} +WrappedRefreshAddInAllowedProperty::~WrappedRefreshAddInAllowedProperty() +{ +} + +void WrappedRefreshAddInAllowedProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bUpdateAddIn = sal_True; + if( ! (rOuterValue >>= bUpdateAddIn) ) + throw lang::IllegalArgumentException( C2U("The property RefreshAddInAllowed requires type boolean"), 0, 0 ); + + m_rChartDocumentWrapper.setUpdateAddIn( bUpdateAddIn ); +} + +Any WrappedRefreshAddInAllowedProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( m_rChartDocumentWrapper.getUpdateAddIn() ); +} + +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx new file mode 100644 index 000000000000..01cdd148c136 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAddInProperty.hxx @@ -0,0 +1,114 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAddInProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_ADDIN_PROPERTY_HXX +#define CHART_WRAPPED_ADDIN_PROPERTY_HXX + +#include "WrappedProperty.hxx" +#include "ChartDocumentWrapper.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +namespace wrapper +{ + +class WrappedAddInProperty : public WrappedProperty +{ +public: + WrappedAddInProperty( ChartDocumentWrapper& rChartDocumentWrapper ); + virtual ~WrappedAddInProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + ChartDocumentWrapper& m_rChartDocumentWrapper; +}; + +class WrappedBaseDiagramProperty : public WrappedProperty +{ +public: + WrappedBaseDiagramProperty( ChartDocumentWrapper& rChartDocumentWrapper ); + virtual ~WrappedBaseDiagramProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + ChartDocumentWrapper& m_rChartDocumentWrapper; +}; + +class WrappedAdditionalShapesProperty : public WrappedProperty +{ +public: + WrappedAdditionalShapesProperty( ChartDocumentWrapper& rChartDocumentWrapper ); + virtual ~WrappedAdditionalShapesProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + ChartDocumentWrapper& m_rChartDocumentWrapper; +}; + +class WrappedRefreshAddInAllowedProperty : public WrappedProperty +{ +public: + WrappedRefreshAddInAllowedProperty( ChartDocumentWrapper& rChartDocumentWrapper ); + virtual ~WrappedRefreshAddInAllowedProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + ChartDocumentWrapper& m_rChartDocumentWrapper; +}; + +} + +//............................................................................. +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_ADDIN_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx new file mode 100644 index 000000000000..dfba4f0cf5ab --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAutomaticPositionProperties.cxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" + +#include "WrappedAutomaticPositionProperties.hxx" +#include "FastPropertyIdRanges.hxx" +#include "macros.hxx" +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedAutomaticPositionProperty : public WrappedProperty +{ +public: + WrappedAutomaticPositionProperty(); + virtual ~WrappedAutomaticPositionProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); +}; + +WrappedAutomaticPositionProperty::WrappedAutomaticPositionProperty() + : ::chart::WrappedProperty( C2U( "AutomaticPosition" ), rtl::OUString() ) +{ +} +WrappedAutomaticPositionProperty::~WrappedAutomaticPositionProperty() +{ +} + +void WrappedAutomaticPositionProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( xInnerPropertySet.is() ) + { + bool bNewValue = true; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Property AutomaticPosition requires value of type boolean"), 0, 0 ); + + try + { + if( bNewValue ) + { + Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); + if( aRelativePosition.hasValue() ) + xInnerPropertySet->setPropertyValue( C2U( "RelativePosition" ), Any() ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +Any WrappedAutomaticPositionProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); + if( xInnerPropertySet.is() ) + { + Any aRelativePosition( xInnerPropertySet->getPropertyValue( C2U( "RelativePosition" ) ) ); + if( !aRelativePosition.hasValue() ) + aRet <<= true; + } + return aRet; +} + +Any WrappedAutomaticPositionProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= false; + return aRet; +} + +namespace +{ +enum +{ + PROP_CHART_AUTOMATIC_POSITION = FAST_PROPERTY_ID_START_CHART_AUTOPOSITION_PROP +}; + +void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList ) +{ + rList.push_back( new WrappedAutomaticPositionProperty() ); +} + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedAutomaticPositionProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "AutomaticPosition" ), + PROP_CHART_AUTOMATIC_POSITION, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedAutomaticPositionProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList ) +{ + lcl_addWrappedProperties( rList ); +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx new file mode 100644 index 000000000000..edb9127fcd31 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAutomaticPositionProperties.hxx @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAutomaticPositionProperties.hxx,v $ + * $Revision: 1.1.2.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART_WRAPPED_AUTOMATICPOSITION_PROPERTIES_HXX +#define CHART_WRAPPED_AUTOMATICPOSITION_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedAutomaticPositionProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property >& rOutProperties ); + static void addWrappedProperties( std::vector< WrappedProperty* >& rList ); +}; + +} //namespace wrapper +} //namespace chart +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx new file mode 100644 index 000000000000..9164e42f5eeb --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.cxx @@ -0,0 +1,451 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAxisAndGridExistenceProperties.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedAxisAndGridExistenceProperties.hxx" +#include "AxisHelper.hxx" +#include "ChartModelHelper.hxx" +#include "TitleHelper.hxx" +#include "macros.hxx" + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedAxisAndGridExistenceProperty : public WrappedProperty +{ +public: + WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedAxisAndGridExistenceProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + bool m_bAxis; + bool m_bMain; + sal_Int32 m_nDimensionIndex; +}; + +//static +void WrappedAxisAndGridExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 0, spChart2ModelContact ) );//x axis + rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 0, spChart2ModelContact ) );//x secondary axis + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 0, spChart2ModelContact ) );//x grid + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 0, spChart2ModelContact ) );//x help grid + + rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 1, spChart2ModelContact ) );//y axis + rList.push_back( new WrappedAxisAndGridExistenceProperty( true, false, 1, spChart2ModelContact ) );//y secondary axis + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 1, spChart2ModelContact ) );//y grid + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 1, spChart2ModelContact ) );//y help grid + + rList.push_back( new WrappedAxisAndGridExistenceProperty( true, true, 2, spChart2ModelContact ) );//z axis + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, true, 2, spChart2ModelContact ) );//z grid + rList.push_back( new WrappedAxisAndGridExistenceProperty( false, false, 2, spChart2ModelContact ) );//z help grid +} + +WrappedAxisAndGridExistenceProperty::WrappedAxisAndGridExistenceProperty( bool bAxis, bool bMain, sal_Int32 nDimensionIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(OUString(),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_bAxis( bAxis ) + , m_bMain( bMain ) + , m_nDimensionIndex( nDimensionIndex ) +{ + switch( m_nDimensionIndex ) + { + case 0: + { + if( m_bAxis ) + { + if( m_bMain ) + m_aOuterName = C2U( "HasXAxis" ); + else + m_aOuterName = C2U( "HasSecondaryXAxis" ); + } + else + { + if( m_bMain ) + m_aOuterName = C2U( "HasXAxisGrid" ); + else + m_aOuterName = C2U( "HasXAxisHelpGrid" ); + } + } + break; + case 2: + { + if( m_bAxis ) + { + OSL_ENSURE(m_bMain == true,"there is no secondary z axis at the old api"); + m_bMain = true; + m_aOuterName = C2U( "HasZAxis" ); + } + else + { + if( m_bMain ) + m_aOuterName = C2U( "HasZAxisGrid" ); + else + m_aOuterName = C2U( "HasZAxisHelpGrid" ); + } + } + break; + default: + { + if( m_bAxis ) + { + if( m_bMain ) + m_aOuterName = C2U( "HasYAxis" ); + else + m_aOuterName = C2U( "HasSecondaryYAxis" ); + } + else + { + if( m_bMain ) + m_aOuterName = C2U( "HasYAxisGrid" ); + else + m_aOuterName = C2U( "HasYAxisHelpGrid" ); + } + } + break; + } +} + +WrappedAxisAndGridExistenceProperty::~WrappedAxisAndGridExistenceProperty() +{ +} + +void WrappedAxisAndGridExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 ); + + sal_Bool bOldValue = sal_False; + getPropertyValue( xInnerPropertySet ) >>= bOldValue; + + if( bOldValue == bNewValue ) + return; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( bNewValue ) + { + if( m_bAxis ) + AxisHelper::showAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ); + else + AxisHelper::showGrid( m_nDimensionIndex, 0, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ); + } + else + { + if( m_bAxis ) + AxisHelper::hideAxis( m_nDimensionIndex, m_bMain, xDiagram ); + else + AxisHelper::hideGrid( m_nDimensionIndex, 0, m_bMain, xDiagram ); + } +} + +Any WrappedAxisAndGridExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /* xInnerPropertySet */ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if(m_bAxis) + { + sal_Bool bShown = AxisHelper::isAxisShown( m_nDimensionIndex, m_bMain, xDiagram ); + aRet <<= bShown; + } + else + { + sal_Bool bShown = AxisHelper::isGridShown( m_nDimensionIndex, 0, m_bMain, xDiagram ); + aRet <<= bShown; + } + return aRet; +} + +Any WrappedAxisAndGridExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= false; + return aRet; +} + +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- + +class WrappedAxisTitleExistenceProperty : public WrappedProperty +{ +public: + WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedAxisTitleExistenceProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + TitleHelper::eTitleType m_eTitleType; +}; + +//static +void WrappedAxisTitleExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedAxisTitleExistenceProperty( 0, spChart2ModelContact ) );//x axis title + rList.push_back( new WrappedAxisTitleExistenceProperty( 1, spChart2ModelContact ) );//y axis title + rList.push_back( new WrappedAxisTitleExistenceProperty( 2, spChart2ModelContact ) );//z axis title + rList.push_back( new WrappedAxisTitleExistenceProperty( 3, spChart2ModelContact ) );//secondary x axis title + rList.push_back( new WrappedAxisTitleExistenceProperty( 4, spChart2ModelContact ) );//secondary y axis title +} + +WrappedAxisTitleExistenceProperty::WrappedAxisTitleExistenceProperty( sal_Int32 nTitleIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(OUString(),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_eTitleType( TitleHelper::Y_AXIS_TITLE ) +{ + switch( nTitleIndex ) + { + case 0: + m_aOuterName = C2U( "HasXAxisTitle" ); + m_eTitleType = TitleHelper::X_AXIS_TITLE; + break; + case 2: + m_aOuterName = C2U( "HasZAxisTitle" ); + m_eTitleType = TitleHelper::Z_AXIS_TITLE; + break; + case 3: + m_aOuterName = C2U( "HasSecondaryXAxisTitle" ); + m_eTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; + break; + case 4: + m_aOuterName = C2U( "HasSecondaryYAxisTitle" ); + m_eTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; + break; + default: + m_aOuterName = C2U( "HasYAxisTitle" ); + m_eTitleType = TitleHelper::Y_AXIS_TITLE; + break; + } +} + +WrappedAxisTitleExistenceProperty::~WrappedAxisTitleExistenceProperty() +{ +} + +void WrappedAxisTitleExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 ); + + sal_Bool bOldValue = sal_False; + getPropertyValue( xInnerPropertySet ) >>= bOldValue; + + if( bOldValue == bNewValue ) + return; + + if( bNewValue ) + { + rtl::OUString aTitleText; + TitleHelper::createTitle( m_eTitleType, aTitleText + , m_spChart2ModelContact->getChartModel(), m_spChart2ModelContact->m_xContext ); + } + else + { + TitleHelper::removeTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ); + } +} + +Any WrappedAxisTitleExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bHasTitle = sal_False; + + Reference< chart2::XTitle > xTitle( TitleHelper::getTitle( m_eTitleType, m_spChart2ModelContact->getChartModel() ) ); + if( xTitle.is() && (TitleHelper::getCompleteString( xTitle ).getLength() != 0) ) + bHasTitle = sal_True; + + Any aRet; + aRet <<= bHasTitle; + return aRet; + +} + +Any WrappedAxisTitleExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Bool( sal_False ); + return aRet; +} + +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- + +class WrappedAxisLabelExistenceProperty : public WrappedProperty +{ +public: + WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedAxisLabelExistenceProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + bool m_bMain; + sal_Int32 m_nDimensionIndex; +}; + +//static +void WrappedAxisLabelExistenceProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedAxisLabelExistenceProperty( true, 0, spChart2ModelContact ) );//x axis + rList.push_back( new WrappedAxisLabelExistenceProperty( true, 1, spChart2ModelContact ) );//y axis + rList.push_back( new WrappedAxisLabelExistenceProperty( true, 2, spChart2ModelContact ) );//z axis + rList.push_back( new WrappedAxisLabelExistenceProperty( false, 0, spChart2ModelContact ) );//secondary x axis + rList.push_back( new WrappedAxisLabelExistenceProperty( false, 1, spChart2ModelContact ) );//secondary y axis +} + +WrappedAxisLabelExistenceProperty::WrappedAxisLabelExistenceProperty( bool bMain, sal_Int32 nDimensionIndex + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(OUString(),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_bMain( bMain ) + , m_nDimensionIndex( nDimensionIndex ) +{ + switch( m_nDimensionIndex ) + { + case 0: + m_aOuterName = m_bMain ? C2U( "HasXAxisDescription" ) : C2U( "HasSecondaryXAxisDescription" ); + break; + case 2: + OSL_ENSURE(m_bMain,"there is no description available for a secondary z axis"); + m_aOuterName = C2U( "HasZAxisDescription" ); + break; + default: + m_aOuterName = m_bMain ? C2U( "HasYAxisDescription" ) : C2U( "HasSecondaryYAxisDescription" ); + break; + } +} + +WrappedAxisLabelExistenceProperty::~WrappedAxisLabelExistenceProperty() +{ +} + +void WrappedAxisLabelExistenceProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("Has axis or grid properties require boolean values"), 0, 0 ); + + sal_Bool bOldValue = sal_False; + getPropertyValue( xInnerPropertySet ) >>= bOldValue; + + 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 ); + if( !xProp.is() && bNewValue ) + { + //create axis if needed + xProp.set( AxisHelper::createAxis( m_nDimensionIndex, m_bMain, xDiagram, m_spChart2ModelContact->m_xContext ), uno::UNO_QUERY ); + if( xProp.is() ) + xProp->setPropertyValue( C2U( "Show" ), uno::makeAny( sal_False ) ); + } + if( xProp.is() ) + xProp->setPropertyValue( C2U( "DisplayLabels" ), rOuterValue ); +} + +Any WrappedAxisLabelExistenceProperty::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + Reference< beans::XPropertySet > xProp( AxisHelper::getAxis( m_nDimensionIndex, m_bMain, xDiagram ), uno::UNO_QUERY ); + if( xProp.is() ) + aRet = xProp->getPropertyValue( C2U( "DisplayLabels" )); + else + aRet <<= sal_False; + return aRet; +} + +Any WrappedAxisLabelExistenceProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= sal_Bool( sal_True ); + return aRet; +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx new file mode 100644 index 000000000000..0c094a3de39c --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedAxisAndGridExistenceProperties.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedAxisAndGridExistenceProperties.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_AXISANDGRIDEXISTENCE_PROPERTIES_HXX +#define CHART_WRAPPED_AXISANDGRIDEXISTENCE_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedAxisAndGridExistenceProperties +{ +public: + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- + +class WrappedAxisTitleExistenceProperties +{ +public: + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- +//--------------------------------------------------------------------------------------------------------------- + +class WrappedAxisLabelExistenceProperties +{ +public: + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SCALE_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx new file mode 100644 index 000000000000..94f1c58fe27a --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.cxx @@ -0,0 +1,175 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedCharacterHeightProperty.cxx,v $ + * $Revision: 1.5.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedCharacterHeightProperty.hxx" +#include "macros.hxx" +#include "RelativeSizeHelper.hxx" +#include "ReferenceSizePropertyProvider.hxx" + +// header for define DBG_ASSERT +#include <tools/debug.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + +//............................................................................. +//............................................................................. + +//............................................................................. +//............................................................................. + +namespace chart +{ +namespace wrapper +{ +WrappedCharacterHeightProperty_Base::WrappedCharacterHeightProperty_Base( + const OUString& rOuterEqualsInnerName + , ReferenceSizePropertyProvider* pRefSizePropProvider ) + : WrappedProperty( rOuterEqualsInnerName, rOuterEqualsInnerName ) + , m_pRefSizePropProvider( pRefSizePropProvider ) +{ +} +WrappedCharacterHeightProperty_Base::~WrappedCharacterHeightProperty_Base() +{ +} + +//static +void WrappedCharacterHeightProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ReferenceSizePropertyProvider* pRefSizePropProvider ) +{ + rList.push_back( new WrappedCharacterHeightProperty( pRefSizePropProvider ) ); + rList.push_back( new WrappedAsianCharacterHeightProperty( pRefSizePropProvider ) ); + rList.push_back( new WrappedComplexCharacterHeightProperty( pRefSizePropProvider ) ); +} + +void WrappedCharacterHeightProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if(xInnerPropertySet.is()) + { + if( m_pRefSizePropProvider ) + m_pRefSizePropProvider->updateReferenceSize(); + xInnerPropertySet->setPropertyValue( m_aInnerName, rOuterValue ); + } +} + +Any WrappedCharacterHeightProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + if( xInnerPropertySet.is() ) + { + aRet = xInnerPropertySet->getPropertyValue( m_aInnerName ); + float fHeight = 0; + if( aRet >>= fHeight ) + { + if( m_pRefSizePropProvider ) + { + awt::Size aReferenceSize; + if( m_pRefSizePropProvider->getReferenceSize() >>= aReferenceSize ) + { + awt::Size aCurrentSize = m_pRefSizePropProvider->getCurrentSizeForReference(); + aRet <<= static_cast< float >( + RelativeSizeHelper::calculate( fHeight, aReferenceSize, aCurrentSize )); + } + } + } + } + return aRet; +} + +Any WrappedCharacterHeightProperty_Base::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + if( xInnerPropertyState.is() ) + { + aRet = xInnerPropertyState->getPropertyDefault( m_aInnerName ); + } + return aRet; +} + +beans::PropertyState WrappedCharacterHeightProperty_Base::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + return beans::PropertyState_DIRECT_VALUE; +} + +Any WrappedCharacterHeightProperty_Base::convertInnerToOuterValue( const Any& rInnerValue ) const +{ + OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertInnerToOuterValue - check if you miss data"); + return rInnerValue; +} +Any WrappedCharacterHeightProperty_Base::convertOuterToInnerValue( const Any& rOuterValue ) const +{ + OSL_ASSERT("should not be used: WrappedCharacterHeightProperty_Base::convertOuterToInnerValue - check if you miss data"); + return rOuterValue; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedCharacterHeightProperty::WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( C2U( "CharHeight" ), pRefSizePropProvider ) +{ +} +WrappedCharacterHeightProperty::~WrappedCharacterHeightProperty() +{ +} + +//----------------------------------------------------------------------------- + +WrappedAsianCharacterHeightProperty::WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( C2U( "CharHeightAsian" ), pRefSizePropProvider ) +{ +} +WrappedAsianCharacterHeightProperty::~WrappedAsianCharacterHeightProperty() +{ +} + +//----------------------------------------------------------------------------- + +WrappedComplexCharacterHeightProperty::WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ) + : WrappedCharacterHeightProperty_Base( C2U( "CharHeightComplex" ), pRefSizePropProvider ) +{ +} +WrappedComplexCharacterHeightProperty::~WrappedComplexCharacterHeightProperty() +{ +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx new file mode 100644 index 000000000000..4ee8e0bf89e7 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedCharacterHeightProperty.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedCharacterHeightProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_CHARACTERHEIGHT_PROPERTY_HXX +#define CHART_WRAPPED_CHARACTERHEIGHT_PROPERTY_HXX + +#include "WrappedProperty.hxx" + +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class ReferenceSizePropertyProvider; + +class WrappedCharacterHeightProperty_Base : public WrappedProperty +{ +public: + WrappedCharacterHeightProperty_Base( const ::rtl::OUString& rOuterEqualsInnerName, ReferenceSizePropertyProvider* pRefSizePropProvider ); + virtual ~WrappedCharacterHeightProperty_Base(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::beans::PropertyState getPropertyState( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + +protected: + virtual ::com::sun::star::uno::Any convertInnerToOuterValue( const ::com::sun::star::uno::Any& rInnerValue ) const; + virtual ::com::sun::star::uno::Any convertOuterToInnerValue( const ::com::sun::star::uno::Any& rOuterValue ) const; + +protected: + ReferenceSizePropertyProvider* m_pRefSizePropProvider; +}; + +//----------------------------------------------------------------------------- + +class WrappedCharacterHeightProperty : public WrappedCharacterHeightProperty_Base +{ +public: + WrappedCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ); + virtual ~WrappedCharacterHeightProperty(); + + static void addWrappedProperties( std::vector< WrappedProperty* >& rList, ReferenceSizePropertyProvider* pRefSizePropProvider ); +}; + +//----------------------------------------------------------------------------- + +class WrappedAsianCharacterHeightProperty : public WrappedCharacterHeightProperty_Base +{ +public: + WrappedAsianCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ); + virtual ~WrappedAsianCharacterHeightProperty(); +}; + +//----------------------------------------------------------------------------- + +class WrappedComplexCharacterHeightProperty : public WrappedCharacterHeightProperty_Base +{ +public: + WrappedComplexCharacterHeightProperty( ReferenceSizePropertyProvider* pRefSizePropProvider ); + virtual ~WrappedComplexCharacterHeightProperty(); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_CHARACTERHEIGHT_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx new file mode 100644 index 000000000000..5b48f320db39 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.cxx @@ -0,0 +1,196 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedDataCaptionProperties.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedDataCaptionProperties.hxx" +#include "WrappedSeriesOrDiagramProperty.hxx" +#include "macros.hxx" +#include "FastPropertyIdRanges.hxx" +#include <com/sun/star/chart2/DataPointLabel.hpp> +#include <com/sun/star/chart/ChartDataCaption.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +class WrappedDataCaptionProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 > +{ +public: + virtual sal_Int32 getValueFromSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet, sal_Int32 aNewValue ) const; + + explicit WrappedDataCaptionProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedDataCaptionProperty(); +}; + +namespace +{ +enum +{ + //data caption properties + PROP_CHART_DATAPOINT_DATA_CAPTION = FAST_PROPERTY_ID_START_CHART_DATACAPTION_PROP +}; + +sal_Int32 lcl_LabelToCaption( const chart2::DataPointLabel& rLabel ) +{ + sal_Int32 nCaption=0; + + if( rLabel.ShowNumber ) + nCaption |= ::com::sun::star::chart::ChartDataCaption::VALUE; + if( rLabel.ShowNumberInPercent ) + nCaption |= ::com::sun::star::chart::ChartDataCaption::PERCENT; + if( rLabel.ShowCategoryName ) + nCaption |= ::com::sun::star::chart::ChartDataCaption::TEXT; + if( rLabel.ShowLegendSymbol ) + nCaption |= ::com::sun::star::chart::ChartDataCaption::SYMBOL; + + return nCaption; +} + +chart2::DataPointLabel lcl_CaptionToLabel( sal_Int32 nCaption ) +{ + chart2::DataPointLabel aLabel(false,false,false,false); + + if( nCaption & ::com::sun::star::chart::ChartDataCaption::VALUE ) + aLabel.ShowNumber = true; + if( nCaption & ::com::sun::star::chart::ChartDataCaption::PERCENT ) + aLabel.ShowNumberInPercent = true; + if( nCaption & ::com::sun::star::chart::ChartDataCaption::TEXT ) + aLabel.ShowCategoryName = true; + if( nCaption & ::com::sun::star::chart::ChartDataCaption::SYMBOL ) + aLabel.ShowLegendSymbol = true; + + return aLabel; +} + +void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) +{ + //if !spChart2ModelContact.get() is then the created properties do belong to a single series or single datapoint + //otherwise they do belong to the whole diagram + + rList.push_back( new WrappedDataCaptionProperty( spChart2ModelContact, ePropertyType ) ); +} + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedDataCaptionProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "DataCaption" ), + PROP_CHART_DATAPOINT_DATA_CAPTION, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedDataCaptionProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedDataCaptionProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedDataCaptionProperty::WrappedDataCaptionProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< sal_Int32 >( C2U("DataCaption") + , uno::makeAny( sal_Int32(0) ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedDataCaptionProperty::~WrappedDataCaptionProperty() +{ +} + +sal_Int32 WrappedDataCaptionProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + sal_Int32 aRet = 0; + m_aDefaultValue >>= aRet; + chart2::DataPointLabel aLabel; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Label")) >>= aLabel ) ) + aRet = lcl_LabelToCaption( aLabel ); + return aRet; +} + +void WrappedDataCaptionProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nCaption ) const +{ + if(!xSeriesPropertySet.is()) + return; + + chart2::DataPointLabel aLabel = lcl_CaptionToLabel( nCaption ); + xSeriesPropertySet->setPropertyValue( C2U("Label"), uno::makeAny( aLabel ) ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx new file mode 100644 index 000000000000..1dbd3b8bbaa6 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedDataCaptionProperties.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedDataCaptionProperties.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_DATACAPTION_PROPERTIES_HXX +#define CHART_WRAPPED_DATACAPTION_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedDataCaptionProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ); + static void addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + static void addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_DATACAPTION_PROPERTIES_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx new file mode 100644 index 000000000000..7c4df1455ad4 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.cxx @@ -0,0 +1,204 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedGapwidthProperty.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedGapwidthProperty.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +const sal_Int32 DEFAULT_GAPWIDTH = 100; +const sal_Int32 DEFAULT_OVERLAP = 0; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedBarPositionProperty_Base::WrappedBarPositionProperty_Base( + const ::rtl::OUString& rOuterName + , const ::rtl::OUString& rInnerSequencePropertyName + , sal_Int32 nDefaultValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedDefaultProperty( rOuterName, rtl::OUString(), uno::makeAny( nDefaultValue ) ) + , m_nDimensionIndex(0) + , m_nAxisIndex(0) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_nDefaultValue( nDefaultValue ) + , m_InnerSequencePropertyName( rInnerSequencePropertyName ) +{ +} + +void WrappedBarPositionProperty_Base::setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ) +{ + m_nDimensionIndex = nDimensionIndex; + m_nAxisIndex = nAxisIndex; +} + +WrappedBarPositionProperty_Base::~WrappedBarPositionProperty_Base() +{ +} + +void WrappedBarPositionProperty_Base::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Int32 nNewValue = 0; + if( ! (rOuterValue >>= nNewValue) ) + throw lang::IllegalArgumentException( C2U("GapWidth and Overlap property require value of type sal_Int32"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( !xDiagram.is() ) + return; + + if( m_nDimensionIndex==1 ) + { + Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < aChartTypeList.getLength(); nN++ ) + { + try + { + Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); + if( xProp.is() ) + { + Sequence< sal_Int32 > aBarPositionSequence; + xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + + 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::makeAny( aBarPositionSequence ) ); + } + } + catch( uno::Exception& e ) + { + //the above properties are not supported by all charttypes (only by column and bar) + //in that cases this exception is ok + e.Context.is();//to have debug information without compilation warnings + } + } + } +} + +Any WrappedBarPositionProperty_Base::getPropertyValue( const Reference< beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() ) + { + bool bInnerValueDetected = false; + sal_Int32 nInnerValue = m_nDefaultValue; + + if( m_nDimensionIndex==1 ) + { + Sequence< Reference< chart2::XChartType > > aChartTypeList( DiagramHelper::getChartTypesFromDiagram( xDiagram ) ); + for( sal_Int32 nN = 0; nN < aChartTypeList.getLength() && !bInnerValueDetected; nN++ ) + { + try + { + Reference< beans::XPropertySet > xProp( aChartTypeList[nN], uno::UNO_QUERY ); + if( xProp.is() ) + { + Sequence< sal_Int32 > aBarPositionSequence; + xProp->getPropertyValue( m_InnerSequencePropertyName ) >>= aBarPositionSequence; + if( m_nAxisIndex < aBarPositionSequence.getLength() ) + { + nInnerValue = aBarPositionSequence[m_nAxisIndex]; + bInnerValueDetected = true; + } + } + } + catch( uno::Exception& e ) + { + //the above properties are not supported by all charttypes (only by column and bar) + //in that cases this exception is ok + e.Context.is();//to have debug information without compilation warnings + } + } + } + if( bInnerValueDetected ) + { + m_aOuterValue <<= nInnerValue; + } + } + return m_aOuterValue; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedGapwidthProperty::WrappedGapwidthProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedBarPositionProperty_Base( C2U("GapWidth"), C2U("GapwidthSequence"), DEFAULT_GAPWIDTH, spChart2ModelContact ) +{ +} +WrappedGapwidthProperty::~WrappedGapwidthProperty() +{ +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedBarOverlapProperty::WrappedBarOverlapProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedBarPositionProperty_Base( C2U("Overlap"), C2U("OverlapSequence"), DEFAULT_OVERLAP, spChart2ModelContact ) +{ +} +WrappedBarOverlapProperty::~WrappedBarOverlapProperty() +{ +} + +} // namespace wrapper +} // namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx new file mode 100644 index 000000000000..85e333577206 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedGapwidthProperty.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedGapwidthProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_GAPWIDTH_PROPERTY_HXX +#define CHART_WRAPPED_GAPWIDTH_PROPERTY_HXX + +#include "WrappedDefaultProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> + +namespace chart +{ +namespace wrapper +{ + +class WrappedBarPositionProperty_Base : public WrappedDefaultProperty +{ +public: + WrappedBarPositionProperty_Base( + const ::rtl::OUString& rOuterName + , const ::rtl::OUString& rInnerSequencePropertyName + , sal_Int32 nDefaultValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedBarPositionProperty_Base(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + void setDimensionAndAxisIndex( sal_Int32 nDimensionIndex, sal_Int32 nAxisIndex ); + +protected: + sal_Int32 m_nDimensionIndex; + sal_Int32 m_nAxisIndex; + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + + sal_Int32 m_nDefaultValue; + ::rtl::OUString m_InnerSequencePropertyName; + + mutable ::com::sun::star::uno::Any m_aOuterValue; +}; + +class WrappedGapwidthProperty : public WrappedBarPositionProperty_Base +{ +public: + WrappedGapwidthProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedGapwidthProperty(); +}; + +class WrappedBarOverlapProperty : public WrappedBarPositionProperty_Base +{ +public: + WrappedBarOverlapProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedBarOverlapProperty(); +}; + +} // namespace wrapper +} // namespace chart + +// CHART_WRAPPED_GAPWIDTH_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx new file mode 100644 index 000000000000..00101ef10f34 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.cxx @@ -0,0 +1,202 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedNumberFormatProperty.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedNumberFormatProperty.hxx" +#include "macros.hxx" + +// header for define DBG_ERROR +#include <tools/debug.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ +//............................................................................. + +WrappedNumberFormatProperty::WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedDirectStateProperty( C2U("NumberFormat"), C2U("NumberFormat") ) + , m_spChart2ModelContact(spChart2ModelContact) +{ + m_aOuterValue = getPropertyDefault( 0 ); +} + +WrappedNumberFormatProperty::~WrappedNumberFormatProperty() +{ + if( m_pWrappedLinkNumberFormatProperty ) + { + if( m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty == this ) + m_pWrappedLinkNumberFormatProperty->m_pWrappedNumberFormatProperty = 0; + } +} + +void WrappedNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + sal_Int32 nFormat = 0; + if( ! (rOuterValue >>= nFormat) ) + throw lang::IllegalArgumentException( C2U("Property 'NumberFormat' requires value of type sal_Int32"), 0, 0 ); + + m_aOuterValue = rOuterValue; + if(xInnerPropertySet.is()) + { + bool bUseSourceFormat = !xInnerPropertySet->getPropertyValue( C2U("NumberFormat" )).hasValue(); + if( bUseSourceFormat ) + { + uno::Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) + bUseSourceFormat = false; + } + if( !bUseSourceFormat ) + xInnerPropertySet->setPropertyValue( m_aInnerName, this->convertOuterToInnerValue( rOuterValue ) ); + } +} + +Any WrappedNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( !xInnerPropertySet.is() ) + { + DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue"); + return Any(); + } + Any aRet( xInnerPropertySet->getPropertyValue( m_aInnerName )); + if( !aRet.hasValue() ) + { + sal_Int32 nKey = 0; + Reference< chart2::XDataSeries > xSeries( xInnerPropertySet, uno::UNO_QUERY ); + if( xSeries.is() ) + nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForSeries( xSeries ); + else + { + Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + nKey = m_spChart2ModelContact->getExplicitNumberFormatKeyForAxis( xAxis ); + } + aRet <<= nKey; + } + return aRet; +} + +Any WrappedNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return uno::makeAny( sal_Int32( 0 ) ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedLinkNumberFormatProperty::WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty ) + : WrappedProperty( C2U("LinkNumberFormatToSource"), C2U("") ) + , m_pWrappedNumberFormatProperty( pWrappedNumberFormatProperty ) +{ + if( m_pWrappedNumberFormatProperty ) + { + m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = this; + } +} + +WrappedLinkNumberFormatProperty::~WrappedLinkNumberFormatProperty() +{ + if( m_pWrappedNumberFormatProperty ) + { + if( m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty == this ) + m_pWrappedNumberFormatProperty->m_pWrappedLinkNumberFormatProperty = 0; + } +} + +void WrappedLinkNumberFormatProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( !xInnerPropertySet.is() ) + { + DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::setPropertyValue"); + return; + } + + bool bLinkFormat = false; + if( rOuterValue >>= bLinkFormat ) + { + Any aValue; + if( bLinkFormat ) + { + if( m_pWrappedNumberFormatProperty ) + { + uno::Reference< chart2::XChartDocument > xChartDoc( m_pWrappedNumberFormatProperty->m_spChart2ModelContact->getChart2Document() ); + if( xChartDoc.is() && xChartDoc->hasInternalDataProvider() ) + return; + } + } + else + { + if( m_pWrappedNumberFormatProperty ) + { + aValue = m_pWrappedNumberFormatProperty->getPropertyValue( xInnerPropertySet ); + } + else + aValue <<= sal_Int32( 0 ); + } + + xInnerPropertySet->setPropertyValue( C2U("NumberFormat"), aValue ); + } +} + +Any WrappedLinkNumberFormatProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( !xInnerPropertySet.is() ) + { + DBG_ERROR("missing xInnerPropertySet in WrappedNumberFormatProperty::getPropertyValue"); + return getPropertyDefault(0); + } + bool bLink = ! xInnerPropertySet->getPropertyValue( C2U("NumberFormat" )).hasValue(); + return uno::makeAny( bLink ); +} + +Any WrappedLinkNumberFormatProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + bool bLink = true; + return uno::makeAny( bLink ); +} + +//............................................................................. +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx new file mode 100644 index 000000000000..4d1b9b867840 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedNumberFormatProperty.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedNumberFormatProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_WRAPPEDNUMBERFORMATPROPERTY_HXX +#define CHART2_WRAPPEDNUMBERFORMATPROPERTY_HXX + +#include "WrappedDirectStateProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ +//............................................................................. + +class WrappedLinkNumberFormatProperty; + +class WrappedNumberFormatProperty : public WrappedDirectStateProperty +{ +public: + WrappedNumberFormatProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedNumberFormatProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + friend class WrappedLinkNumberFormatProperty; +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable ::com::sun::star::uno::Any m_aOuterValue; + WrappedLinkNumberFormatProperty* m_pWrappedLinkNumberFormatProperty; +}; + +class WrappedLinkNumberFormatProperty : public WrappedProperty +{ +public: + WrappedLinkNumberFormatProperty( WrappedNumberFormatProperty* pWrappedNumberFormatProperty ); + virtual ~WrappedLinkNumberFormatProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + friend class WrappedNumberFormatProperty; +private: + WrappedNumberFormatProperty* m_pWrappedNumberFormatProperty; +}; + +//............................................................................. +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART2_WRAPPEDNUMBERFORMATPROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx new file mode 100644 index 000000000000..ffbaac3a5eb0 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.cxx @@ -0,0 +1,514 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedScaleProperty.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedScaleProperty.hxx" +#include "macros.hxx" +#include "CommonConverters.hxx" +#include "AxisHelper.hxx" +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <com/sun/star/chart2/ExplicitScaleData.hpp> +#include <com/sun/star/chart2/AxisOrientation.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +WrappedScaleProperty::WrappedScaleProperty( tScaleProperty eScaleProperty + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(OUString(),OUString()) + , m_spChart2ModelContact( spChart2ModelContact ) + , m_eScaleProperty( eScaleProperty ) +{ + switch( m_eScaleProperty ) + { + case SCALE_PROP_MAX: + m_aOuterName = C2U("Max"); + break; + case SCALE_PROP_MIN: + m_aOuterName = C2U("Min"); + break; + case SCALE_PROP_ORIGIN: + m_aOuterName = C2U("Origin"); + break; + case SCALE_PROP_STEPMAIN: + m_aOuterName = C2U("StepMain"); + break; + case SCALE_PROP_STEPHELP: + m_aOuterName = C2U("StepHelp"); + break; + case SCALE_PROP_STEPHELP_COUNT: + m_aOuterName = C2U("StepHelpCount"); + break; + case SCALE_PROP_AUTO_MAX: + m_aOuterName = C2U("AutoMax"); + break; + case SCALE_PROP_AUTO_MIN: + m_aOuterName = C2U("AutoMin"); + break; + case SCALE_PROP_AUTO_ORIGIN: + m_aOuterName = C2U("AutoOrigin"); + break; + case SCALE_PROP_AUTO_STEPMAIN: + m_aOuterName = C2U("AutoStepMain"); + break; + case SCALE_PROP_AUTO_STEPHELP: + m_aOuterName = C2U("AutoStepHelp"); + break; + case SCALE_PROP_LOGARITHMIC: + m_aOuterName = C2U("Logarithmic"); + break; + case SCALE_PROP_REVERSEDIRECTION: + m_aOuterName = C2U("ReverseDirection"); + break; + default: + OSL_ENSURE(false,"unknown scale property"); + break; + } +} + +WrappedScaleProperty::~WrappedScaleProperty() +{ +} + +//static +void WrappedScaleProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedScaleProperty( SCALE_PROP_MAX, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_MIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_ORIGIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPMAIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_STEPHELP_COUNT, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MAX, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_MIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_ORIGIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPMAIN, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_AUTO_STEPHELP, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_LOGARITHMIC, spChart2ModelContact ) ); + rList.push_back( new WrappedScaleProperty( SCALE_PROP_REVERSEDIRECTION, spChart2ModelContact ) ); +} + +void WrappedScaleProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + setPropertyValue( m_eScaleProperty, rOuterValue, xInnerPropertySet ); +} + +Any WrappedScaleProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return getPropertyValue( m_eScaleProperty, xInnerPropertySet ); +} + +void WrappedScaleProperty::setPropertyValue( tScaleProperty eScaleProperty, const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + m_aOuterValue = rOuterValue; + + Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + OSL_ENSURE(xAxis.is(),"need an XAxis"); + if(!xAxis.is()) + return; + + bool bSetScaleData = false; + + chart2::ScaleData aScaleData( xAxis->getScaleData() ); + + sal_Bool bBool = false; + switch( eScaleProperty ) + { + case SCALE_PROP_MAX: + { + aScaleData.Maximum = rOuterValue; + bSetScaleData = true; + break; + } + case SCALE_PROP_MIN: + { + aScaleData.Minimum = rOuterValue; + bSetScaleData = true; + break; + } + case SCALE_PROP_STEPMAIN: + { + aScaleData.IncrementData.Distance = rOuterValue; + bSetScaleData = true; + break; + } + case SCALE_PROP_STEPHELP: + { + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( rSubIncrements.getLength() == 0 ) + rSubIncrements.realloc( 1 ); + + double fStepMain = 0, fStepHelp = 0; + if( (rOuterValue >>= fStepHelp) ) + { + if( AxisHelper::isLogarithmic(aScaleData.Scaling) ) + { + sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepHelp); + rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + } + else if( (fStepHelp != 0.0) && + (aScaleData.IncrementData.Distance >>= fStepMain) ) + { + // approximate interval count + sal_Int32 nIntervalCount = static_cast< sal_Int32 >(fStepMain / fStepHelp); + rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + } + } + bSetScaleData = true; + break; + } + case SCALE_PROP_STEPHELP_COUNT: + { + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( rSubIncrements.getLength() == 0 ) + rSubIncrements.realloc( 1 ); + sal_Int32 nIntervalCount=0; + if( rOuterValue>>=nIntervalCount ) + rSubIncrements[ 0 ].IntervalCount <<= nIntervalCount; + else + rSubIncrements[ 0 ].IntervalCount = Any(); + bSetScaleData = true; + break; + } + case SCALE_PROP_AUTO_MAX: + { + if( (rOuterValue >>= bBool) && bBool ) + aScaleData.Maximum = Any(); + else + aScaleData.Maximum = getPropertyValue( SCALE_PROP_MAX, xInnerPropertySet ); + bSetScaleData = true; + break; + } + case SCALE_PROP_AUTO_MIN: + { + if( (rOuterValue >>= bBool) && bBool ) + aScaleData.Minimum = Any(); + else + aScaleData.Minimum = getPropertyValue( SCALE_PROP_MIN, xInnerPropertySet ); + bSetScaleData = true; + break; + } + case SCALE_PROP_AUTO_STEPMAIN: + { + if( (rOuterValue >>= bBool) && bBool ) + aScaleData.IncrementData.Distance = Any(); + else + aScaleData.IncrementData.Distance = getPropertyValue( SCALE_PROP_STEPMAIN, xInnerPropertySet ); + bSetScaleData = true; + break; + } + case SCALE_PROP_AUTO_STEPHELP: + { + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( rSubIncrements.getLength() == 0 ) + rSubIncrements.realloc( 1 ); + + if( (rOuterValue >>= bBool) && bBool ) + rSubIncrements[ 0 ].IntervalCount = Any(); + else + rSubIncrements[ 0 ].IntervalCount = getPropertyValue( SCALE_PROP_STEPHELP_COUNT, xInnerPropertySet ); + bSetScaleData = true; + break; + } + case SCALE_PROP_ORIGIN: + { + aScaleData.Origin = rOuterValue; + bSetScaleData = true; + break; + } + case SCALE_PROP_AUTO_ORIGIN: + { + if( (rOuterValue >>= bBool) && bBool ) + aScaleData.Origin = Any(); + else + aScaleData.Origin = getPropertyValue( SCALE_PROP_ORIGIN, xInnerPropertySet ); + bSetScaleData = true; + break; + } + case SCALE_PROP_LOGARITHMIC: + { + if( rOuterValue >>= bBool ) + { + bool bWasLogarithm = AxisHelper::isLogarithmic( aScaleData.Scaling ); + + // safe comparison between sal_Bool and bool + if( (!bBool) != (!bWasLogarithm) ) + { + if( bBool ) + aScaleData.Scaling = AxisHelper::createLogarithmicScaling( 10.0 ); + else + aScaleData.Scaling = 0; + bSetScaleData = true; + } + } + break; + } + case SCALE_PROP_REVERSEDIRECTION: + { + if( rOuterValue >>= bBool ) + { + bool bWasReverse = ( AxisOrientation_REVERSE == aScaleData.Orientation ); + if( (!bBool) != (!bWasReverse) ) // safe comparison between sal_Bool and bool + { + aScaleData.Orientation = bBool ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL; + bSetScaleData = true; + } + } + break; + } + default: + { + OSL_ENSURE(false,"unknown scale property"); + break; + } + } + + if( bSetScaleData ) + xAxis->setScaleData( aScaleData ); +} + +Any WrappedScaleProperty::getPropertyValue( tScaleProperty eScaleProperty, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet( m_aOuterValue ); + + Reference< chart2::XAxis > xAxis( xInnerPropertySet, uno::UNO_QUERY ); + OSL_ENSURE(xAxis.is(),"need an XAxis"); + if(!xAxis.is()) + return aRet; + + chart2::ScaleData aScaleData( xAxis->getScaleData() ); + + chart2::ExplicitScaleData aExplicitScale; + chart2::ExplicitIncrementData aExplicitIncrement; + + switch( eScaleProperty ) + { + case SCALE_PROP_MAX: + { + aRet = aScaleData.Maximum; + if( !aRet.hasValue() ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( + xAxis, aExplicitScale, aExplicitIncrement ); + aRet <<= aExplicitScale.Maximum; + } + break; + } + case SCALE_PROP_MIN: + { + aRet = aScaleData.Minimum; + if( !aRet.hasValue() ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( + xAxis, aExplicitScale, aExplicitIncrement ); + aRet <<= aExplicitScale.Minimum; + } + break; + } + + case SCALE_PROP_STEPMAIN: + { + aRet = aScaleData.IncrementData.Distance; + if( !aRet.hasValue() ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( + xAxis, aExplicitScale, aExplicitIncrement ); + aRet <<= aExplicitIncrement.Distance; + } + break; + } + case SCALE_PROP_STEPHELP: + { + // todo: evaluate PostEquidistant + bool bNeedToCalculateExplicitValues = true; + + bool bLogarithmic( AxisHelper::isLogarithmic(aScaleData.Scaling) ); + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( bLogarithmic ) + { + if( rSubIncrements.getLength() > 0 ) + { + sal_Int32 nIntervalCount = 0; + rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount; + aRet = uno::makeAny( double(nIntervalCount) ); + bNeedToCalculateExplicitValues = false; + } + } + else if( aScaleData.IncrementData.Distance.hasValue() ) + { + if( rSubIncrements.getLength() > 0 ) + { + double fStepMain = 0; + sal_Int32 nIntervalCount = 0; + if( (aScaleData.IncrementData.Distance >>= fStepMain) && + (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && + nIntervalCount > 0 ) + { + aRet <<= ( fStepMain / static_cast< double >( nIntervalCount ) ); + bNeedToCalculateExplicitValues = false; + } + } + else + { + aRet = aScaleData.IncrementData.Distance; + bNeedToCalculateExplicitValues = false; + } + } + + if( bNeedToCalculateExplicitValues ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( + xAxis, aExplicitScale, aExplicitIncrement ); + if( aExplicitIncrement.SubIncrements.getLength() > 0 && + aExplicitIncrement.SubIncrements[ 0 ].IntervalCount > 0 ) + { + if( bLogarithmic ) + { + if( rSubIncrements.getLength() > 0 ) + { + sal_Int32 nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; + aRet = uno::makeAny( double(nIntervalCount) ); + } + } + else + aRet <<= ( aExplicitIncrement.Distance / + static_cast< double >( + aExplicitIncrement.SubIncrements[ 0 ].IntervalCount )); + } + else + { + if( bLogarithmic ) + aRet <<= 5.0; + else + aRet <<= aExplicitIncrement.Distance; + } + } + break; + } + case SCALE_PROP_STEPHELP_COUNT: + { + sal_Int32 nIntervalCount = 0; + bool bNeedToCalculateExplicitValues = true; + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( rSubIncrements.getLength() > 0 ) + { + if( (rSubIncrements[ 0 ].IntervalCount >>= nIntervalCount) && (nIntervalCount > 0) ) + bNeedToCalculateExplicitValues = false; + } + if( bNeedToCalculateExplicitValues ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( xAxis, aExplicitScale, aExplicitIncrement ); + if( aExplicitIncrement.SubIncrements.getLength() > 0 ) + nIntervalCount = aExplicitIncrement.SubIncrements[ 0 ].IntervalCount; + } + aRet = uno::makeAny( nIntervalCount ); + break; + } + case SCALE_PROP_AUTO_MAX: + { + aRet <<= (sal_Bool)( !aScaleData.Maximum.hasValue() ); + break; + } + case SCALE_PROP_AUTO_MIN: + { + aRet <<= (sal_Bool)( !aScaleData.Minimum.hasValue() ); + break; + } + case SCALE_PROP_AUTO_STEPMAIN: + { + aRet <<= (sal_Bool)( !aScaleData.IncrementData.Distance.hasValue() ); + break; + } + case SCALE_PROP_AUTO_STEPHELP: + { + Sequence< chart2::SubIncrement >& rSubIncrements( aScaleData.IncrementData.SubIncrements ); + if( rSubIncrements.getLength() > 0 ) + aRet <<= (sal_Bool)( !rSubIncrements[ 0 ].IntervalCount.hasValue() ); + else + aRet <<= sal_True; + break; + } + case SCALE_PROP_ORIGIN: + { + aRet = aScaleData.Origin; + if( !aRet.hasValue() ) + { + m_spChart2ModelContact->getExplicitValuesForAxis( + xAxis, aExplicitScale, aExplicitIncrement ); + aRet <<= aExplicitScale.Origin; + } + break; + } + case SCALE_PROP_AUTO_ORIGIN: + { + aRet <<= !hasDoubleValue(aScaleData.Origin); + break; + } + case SCALE_PROP_LOGARITHMIC: + { + aRet <<= static_cast< sal_Bool >( AxisHelper::isLogarithmic(aScaleData.Scaling) ); + break; + } + case SCALE_PROP_REVERSEDIRECTION: + { + aRet <<= static_cast< sal_Bool >( AxisOrientation_REVERSE == aScaleData.Orientation ); + break; + } + default: + { + OSL_ENSURE(false,"unknown scale property"); + break; + } + } + + return aRet; +} + +} // namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx new file mode 100644 index 000000000000..e03bf050f72f --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleProperty.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedScaleProperty.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SCALE_PROPERTY_HXX +#define CHART_WRAPPED_SCALE_PROPERTY_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedScaleProperty : public WrappedProperty +{ +public: + enum tScaleProperty + { + SCALE_PROP_MAX + , SCALE_PROP_MIN + , SCALE_PROP_ORIGIN + , SCALE_PROP_STEPMAIN + , SCALE_PROP_STEPHELP //deprecated property + , SCALE_PROP_STEPHELP_COUNT + , SCALE_PROP_AUTO_MAX + , SCALE_PROP_AUTO_MIN + , SCALE_PROP_AUTO_ORIGIN + , SCALE_PROP_AUTO_STEPMAIN + , SCALE_PROP_AUTO_STEPHELP + , SCALE_PROP_LOGARITHMIC + , SCALE_PROP_REVERSEDIRECTION + }; + +public: + WrappedScaleProperty( tScaleProperty eScaleProperty, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedScaleProperty(); + + static void addWrappedProperties( std::vector< WrappedProperty* >& rList, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +protected: //methods + void setPropertyValue( tScaleProperty eScaleProperty, const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + ::com::sun::star::uno::Any getPropertyValue( tScaleProperty eScaleProperty, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + tScaleProperty m_eScaleProperty; + + mutable ::com::sun::star::uno::Any m_aOuterValue; +}; + +} // namespace wrapper +} // namespace chart +//............................................................................. + +// CHART_WRAPPED_SCALE_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx new file mode 100644 index 000000000000..5a22ae7f184f --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.cxx @@ -0,0 +1,170 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedScaleTextProperties.cxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" + +#include "WrappedScaleTextProperties.hxx" +#include "FastPropertyIdRanges.hxx" +#include "macros.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedScaleTextProperty : public WrappedProperty +{ +public: + WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedScaleTextProperty(); + + virtual void setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + virtual Any getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +WrappedScaleTextProperty::WrappedScaleTextProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : ::chart::WrappedProperty( C2U( "ScaleText" ), rtl::OUString() ) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedScaleTextProperty::~WrappedScaleTextProperty() +{ +} + +void WrappedScaleTextProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") ); + + if( xInnerPropertySet.is() ) + { + bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + { + if( rOuterValue.hasValue() ) + throw lang::IllegalArgumentException( C2U("Property ScaleText requires value of type boolean"), 0, 0 ); + } + + try + { + if( bNewValue ) + { + awt::Size aRefSize( m_spChart2ModelContact->GetPageSize() ); + xInnerPropertySet->setPropertyValue( aRefSizeName, uno::makeAny( aRefSize ) ); + } + else + xInnerPropertySet->setPropertyValue( aRefSizeName, Any() ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +Any WrappedScaleTextProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + static const OUString aRefSizeName( RTL_CONSTASCII_USTRINGPARAM("ReferencePageSize") ); + + Any aRet( getPropertyDefault( Reference< beans::XPropertyState >( xInnerPropertySet, uno::UNO_QUERY ) ) ); + if( xInnerPropertySet.is() ) + { + if( xInnerPropertySet->getPropertyValue( aRefSizeName ).hasValue() ) + aRet <<= true; + else + aRet <<= false; + } + + return aRet; +} + +Any WrappedScaleTextProperty::getPropertyDefault( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + Any aRet; + aRet <<= false; + return aRet; +} + +namespace +{ +enum +{ + PROP_CHART_SCALE_TEXT = FAST_PROPERTY_ID_START_SCALE_TEXT_PROP +}; + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedScaleTextProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "ScaleText" ), + PROP_CHART_SCALE_TEXT, + ::getBooleanCppuType(), + beans::PropertyAttribute::MAYBEVOID + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedScaleTextProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedScaleTextProperty( spChart2ModelContact ) ); +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx new file mode 100644 index 000000000000..433a91254bcc --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedScaleTextProperties.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedScaleTextProperties.hxx,v $ + * $Revision: 1.1.2.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART_WRAPPED_SCALETEXT_PROPERTIES_HXX +#define CHART_WRAPPED_SCALETEXT_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedScaleTextProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property >& rOutProperties ); + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx new file mode 100644 index 000000000000..e5f45408217e --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.cxx @@ -0,0 +1,134 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSceneProperty.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedSceneProperty.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include "servicenames_charttypes.hxx" +#include "BaseGFXHelper.hxx" + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//static +void WrappedSceneProperty::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedD3DTransformMatrixProperty( spChart2ModelContact ) ); +} + +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- + +WrappedD3DTransformMatrixProperty::WrappedD3DTransformMatrixProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(C2U("D3DTransformMatrix"),C2U("D3DTransformMatrix")) + , m_spChart2ModelContact( spChart2ModelContact ) +{ +} + +WrappedD3DTransformMatrixProperty::~WrappedD3DTransformMatrixProperty() +{ +} + +void WrappedD3DTransformMatrixProperty::setPropertyValue( const Any& rOuterValue, const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + { + drawing::HomogenMatrix aHM; + if( rOuterValue >>= aHM ) + { + ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix( + BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) ); + + ::basegfx::B3DHomMatrix aMatrix; + aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() ); + ::basegfx::B3DHomMatrix aObjectMatrix; + ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix; + + aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix); + + WrappedProperty::setPropertyValue( uno::makeAny(aHM), xInnerPropertySet ); + return; + } + } + + WrappedProperty::setPropertyValue( rOuterValue, xInnerPropertySet ); +} + +Any WrappedD3DTransformMatrixProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + if( DiagramHelper::isPieOrDonutChart( m_spChart2ModelContact->getChart2Diagram() ) ) + { + uno::Any aAMatrix( WrappedProperty::getPropertyValue( xInnerPropertySet ) ); + drawing::HomogenMatrix aHM; + if( aAMatrix >>= aHM ) + { + ::basegfx::B3DTuple aRotation( BaseGFXHelper::GetRotationFromMatrix( + BaseGFXHelper::HomogenMatrixToB3DHomMatrix( aHM ) ) ); + + ::basegfx::B3DHomMatrix aMatrix; + aMatrix.rotate( aRotation.getX(), aRotation.getY(), aRotation.getZ() ); + ::basegfx::B3DHomMatrix aObjectMatrix; + ::basegfx::B3DHomMatrix aNewMatrix = aMatrix*aObjectMatrix; + + aHM = BaseGFXHelper::B3DHomMatrixToHomogenMatrix(aNewMatrix); + + return uno::makeAny(aHM); + } + } + + return WrappedProperty::getPropertyValue( xInnerPropertySet ); +} + +Any WrappedD3DTransformMatrixProperty::getPropertyDefault( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + return WrappedProperty::getPropertyDefault( xInnerPropertyState ); +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx new file mode 100644 index 000000000000..520524e7c4d3 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSceneProperty.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSceneProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SCENE_PROPERTY_HXX +#define CHART_WRAPPED_SCENE_PROPERTY_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedSceneProperty +{ +public: + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- +//---------------------------------------------------------------------------------------------------------------------- + +class WrappedD3DTransformMatrixProperty : public WrappedProperty +{ +public: + WrappedD3DTransformMatrixProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedD3DTransformMatrixProperty(); + + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + +private: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SCENE_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx new file mode 100644 index 000000000000..2cf5a5406dad --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.cxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSeriesAreaOrLineProperty.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedSeriesAreaOrLineProperty.hxx" +#include "DataSeriesPointWrapper.hxx" +#include "macros.hxx" + +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +WrappedSeriesAreaOrLineProperty::WrappedSeriesAreaOrLineProperty( + const rtl::OUString& rOuterName + , const rtl::OUString& rInnerAreaTypeName + , const rtl::OUString& rInnerLineTypeName + , DataSeriesPointWrapper* pDataSeriesPointWrapper ) + : WrappedProperty( rOuterName, C2U( "" ) ) + , m_pDataSeriesPointWrapper( pDataSeriesPointWrapper ) + , m_aInnerAreaTypeName( rInnerAreaTypeName ) + , m_aInnerLineTypeName( rInnerLineTypeName ) +{ +} +WrappedSeriesAreaOrLineProperty::~WrappedSeriesAreaOrLineProperty() +{ +} + +//virtual +::rtl::OUString WrappedSeriesAreaOrLineProperty::getInnerName() const +{ + if( m_pDataSeriesPointWrapper && !m_pDataSeriesPointWrapper->isSupportingAreaProperties() ) + return m_aInnerLineTypeName; + return m_aInnerAreaTypeName; +} + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx new file mode 100644 index 000000000000..8212e6c75938 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesAreaOrLineProperty.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSeriesAreaOrLineProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SERIES_AREA_OR_LINE_PROPERTY_HXX +#define CHART_WRAPPED_SERIES_AREA_OR_LINE_PROPERTY_HXX + +#include "WrappedProperty.hxx" + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class DataSeriesPointWrapper; +class WrappedSeriesAreaOrLineProperty : public WrappedProperty +{ +public: + WrappedSeriesAreaOrLineProperty( const ::rtl::OUString& rOuterName + , const ::rtl::OUString& rInnerAreaTypeName, const ::rtl::OUString& rInnerLineTypeName + , DataSeriesPointWrapper* pDataSeriesPointWrapper ); + virtual ~WrappedSeriesAreaOrLineProperty(); + + virtual ::rtl::OUString getInnerName() const; + +protected: + DataSeriesPointWrapper* m_pDataSeriesPointWrapper; + ::rtl::OUString m_aInnerAreaTypeName; + ::rtl::OUString m_aInnerLineTypeName; +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SERIES_AREA_OR_LINE_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx new file mode 100644 index 000000000000..370d58eb6302 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSeriesOrDiagramProperty.hxx @@ -0,0 +1,192 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSeriesOrDiagramProperty.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX +#define CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include <com/sun/star/chart2/XDataSeries.hpp> + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +enum tSeriesOrDiagramPropertyType +{ + DATA_SERIES, + DIAGRAM +}; + +//PROPERTYTYPE is the type of the outer property + +template< typename PROPERTYTYPE > +class WrappedSeriesOrDiagramProperty : public WrappedProperty +{ +public: + virtual PROPERTYTYPE getValueFromSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet ) const =0; + virtual void setValueToSeries( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xSeriesPropertySet, PROPERTYTYPE aNewValue ) const =0; + + explicit WrappedSeriesOrDiagramProperty( const ::rtl::OUString& rName, const ::com::sun::star::uno::Any& rDefaulValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedProperty(rName,::rtl::OUString()) + , m_spChart2ModelContact(spChart2ModelContact) + , m_aOuterValue(rDefaulValue) + , m_aDefaultValue(rDefaulValue) + , m_ePropertyType( ePropertyType ) + { + } + virtual ~WrappedSeriesOrDiagramProperty() {}; + + bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const + { + bool bHasDetectableInnerValue = false; + rHasAmbiguousValue = false; + if( m_ePropertyType == DIAGRAM && + m_spChart2ModelContact.get() ) + { + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > aSeriesVector( + ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >::const_iterator aIter = + aSeriesVector.begin(); + for( ; aIter != aSeriesVector.end(); aIter++ ) + { + PROPERTYTYPE aCurValue = getValueFromSeries( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >::query( *aIter ) ); + if( !bHasDetectableInnerValue ) + rValue = aCurValue; + else + { + if( rValue != aCurValue ) + { + rHasAmbiguousValue = true; + break; + } + else + rValue = aCurValue; + } + bHasDetectableInnerValue = true; + } + } + return bHasDetectableInnerValue; + } + void setInnerValue( PROPERTYTYPE aNewValue ) const + { + if( m_ePropertyType == DIAGRAM && + m_spChart2ModelContact.get() ) + { + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > > aSeriesVector( + ::chart::DiagramHelper::getDataSeriesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XDataSeries > >::const_iterator aIter = + aSeriesVector.begin(); + for( ; aIter != aSeriesVector.end(); aIter++ ) + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xSeriesPropertySet( *aIter, ::com::sun::star::uno::UNO_QUERY ); + if( xSeriesPropertySet.is() ) + { + setValueToSeries( xSeriesPropertySet, aNewValue ); + } + } + } + } + virtual void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + PROPERTYTYPE aNewValue = PROPERTYTYPE(); + if( ! (rOuterValue >>= aNewValue) ) + throw ::com::sun::star::lang::IllegalArgumentException( C2U("statistic property requires different type"), 0, 0 ); + + if( m_ePropertyType == DIAGRAM ) + { + m_aOuterValue = rOuterValue; + + bool bHasAmbiguousValue = false; + PROPERTYTYPE aOldValue = PROPERTYTYPE(); + if( detectInnerValue( aOldValue, bHasAmbiguousValue ) ) + { + if( bHasAmbiguousValue || aNewValue != aOldValue ) + setInnerValue( aNewValue ); + } + } + else + { + setValueToSeries( xInnerPropertySet, aNewValue ); + } + } + + virtual ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + if( m_ePropertyType == DIAGRAM ) + { + bool bHasAmbiguousValue = false; + PROPERTYTYPE aValue; + if( detectInnerValue( aValue, bHasAmbiguousValue ) ) + { + if(bHasAmbiguousValue) + m_aOuterValue <<= m_aDefaultValue; + else + m_aOuterValue <<= aValue; + } + return m_aOuterValue; + } + else + { + ::com::sun::star::uno::Any aRet( m_aDefaultValue ); + aRet <<= getValueFromSeries( xInnerPropertySet ); + return aRet; + } + } + + virtual ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& /* xInnerPropertyState */ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + return m_aDefaultValue; + } + +protected: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable ::com::sun::star::uno::Any m_aOuterValue; + ::com::sun::star::uno::Any m_aDefaultValue; + tSeriesOrDiagramPropertyType m_ePropertyType; +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SERIES_OR_DIAGRAM_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx new file mode 100644 index 000000000000..abe16ce64a65 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.cxx @@ -0,0 +1,290 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSplineProperties.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedSplineProperties.hxx" +#include "macros.hxx" +#include "FastPropertyIdRanges.hxx" +#include "DiagramHelper.hxx" +#include <com/sun/star/chart2/CurveStyle.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//PROPERTYTYPE is the type of the outer property + +template< typename PROPERTYTYPE > +class WrappedSplineProperty : public WrappedProperty +{ +public: + explicit WrappedSplineProperty( const ::rtl::OUString& rOuterName, const ::rtl::OUString& rInnerName + , const ::com::sun::star::uno::Any& rDefaulValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(rOuterName,OUString()) + , m_spChart2ModelContact(spChart2ModelContact) + , m_aOuterValue(rDefaulValue) + , m_aDefaultValue(rDefaulValue) + , m_aOwnInnerName(rInnerName) + { + } + virtual ~WrappedSplineProperty() {}; + + bool detectInnerValue( PROPERTYTYPE& rValue, bool& rHasAmbiguousValue ) const + { + bool bHasDetectableInnerValue = false; + rHasAmbiguousValue = false; + Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > > aChartTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + { + try + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], ::com::sun::star::uno::UNO_QUERY ); + + Any aSingleValue = this->convertInnerToOuterValue( xChartTypePropertySet->getPropertyValue(m_aOwnInnerName) ); + PROPERTYTYPE aCurValue = PROPERTYTYPE(); + aSingleValue >>= aCurValue; + if( !bHasDetectableInnerValue ) + rValue = aCurValue; + else + { + if( rValue != aCurValue ) + { + rHasAmbiguousValue = true; + break; + } + else + rValue = aCurValue; + } + bHasDetectableInnerValue = true; + } + catch( uno::Exception & ex ) + { + //spline properties are not supported by all charttypes + //in that cases this exception is ok + ex.Context.is();//to have debug information without compilation warnings + } + } + return bHasDetectableInnerValue; + } + void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + PROPERTYTYPE aNewValue; + if( ! (rOuterValue >>= aNewValue) ) + throw ::com::sun::star::lang::IllegalArgumentException( C2U("spline property requires different type"), 0, 0 ); + + m_aOuterValue = rOuterValue; + + bool bHasAmbiguousValue = false; + PROPERTYTYPE aOldValue; + if( detectInnerValue( aOldValue, bHasAmbiguousValue ) ) + { + if( bHasAmbiguousValue || aNewValue != aOldValue ) + { + Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartType > > aChartTypes( + ::chart::DiagramHelper::getChartTypesFromDiagram( m_spChart2ModelContact->getChart2Diagram() ) ); + for( sal_Int32 nN = aChartTypes.getLength(); nN--; ) + { + try + { + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xChartTypePropertySet( aChartTypes[nN], ::com::sun::star::uno::UNO_QUERY ); + if( xChartTypePropertySet.is() ) + { + xChartTypePropertySet->setPropertyValue(m_aOwnInnerName,this->convertOuterToInnerValue(uno::makeAny(aNewValue))); + } + } + catch( uno::Exception & ex ) + { + //spline properties are not supported by all charttypes + //in that cases this exception is ok + ex.Context.is();//to have debug information without compilation warnings + } + } + } + } + } + + ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + bool bHasAmbiguousValue = false; + PROPERTYTYPE aValue; + if( detectInnerValue( aValue, bHasAmbiguousValue ) ) + { + m_aOuterValue <<= aValue; + } + return m_aOuterValue; + } + + ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) + { + return m_aDefaultValue; + } + +protected: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable ::com::sun::star::uno::Any m_aOuterValue; + ::com::sun::star::uno::Any m_aDefaultValue; + // this inner name is not set as inner name at the base class + const OUString m_aOwnInnerName; +}; + +class WrappedSplineTypeProperty : public WrappedSplineProperty< sal_Int32 > +{ +public: + explicit WrappedSplineTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedSplineTypeProperty(); + + virtual ::com::sun::star::uno::Any convertInnerToOuterValue( const ::com::sun::star::uno::Any& rInnerValue ) const; + virtual ::com::sun::star::uno::Any convertOuterToInnerValue( const ::com::sun::star::uno::Any& rOuterValue ) const; +}; + +namespace +{ +enum +{ + //spline properties + PROP_CHART_SPLINE_TYPE = FAST_PROPERTY_ID_START_CHART_SPLINE_PROP + , PROP_CHART_SPLINE_ORDER + , PROP_CHART_SPLINE_RESOLUTION +}; + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedSplineProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "SplineType" ), + PROP_CHART_SPLINE_TYPE, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "SplineOrder" ), + PROP_CHART_SPLINE_ORDER, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "SplineResolution" ), + PROP_CHART_SPLINE_RESOLUTION, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedSplineProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedSplineTypeProperty( spChart2ModelContact ) ); + rList.push_back( new WrappedSplineProperty<sal_Int32>( C2U("SplineOrder"), C2U("SplineOrder"), uno::makeAny(sal_Int32(2)), spChart2ModelContact ) ); + rList.push_back( new WrappedSplineProperty<sal_Int32>( C2U("SplineResolution"), C2U("CurveResolution"), uno::makeAny(sal_Int32(20)), spChart2ModelContact ) ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + + +WrappedSplineTypeProperty::WrappedSplineTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedSplineProperty<sal_Int32>( C2U("SplineType"), C2U("CurveStyle"), uno::makeAny(sal_Int32(0)), spChart2ModelContact ) +{ +} +WrappedSplineTypeProperty::~WrappedSplineTypeProperty() +{ +} +Any WrappedSplineTypeProperty::convertInnerToOuterValue( const Any& rInnerValue ) const +{ + chart2::CurveStyle aInnerValue = chart2::CurveStyle_LINES; + rInnerValue >>= aInnerValue; + + sal_Int32 nOuterValue; + if( chart2::CurveStyle_CUBIC_SPLINES == aInnerValue ) + nOuterValue = 1; + else if( chart2::CurveStyle_B_SPLINES == aInnerValue ) + nOuterValue = 2; + else + nOuterValue = 0; + + return uno::makeAny(nOuterValue); +} +Any WrappedSplineTypeProperty::convertOuterToInnerValue( const Any& rOuterValue ) const +{ + sal_Int32 nOuterValue=0; + rOuterValue >>= nOuterValue; + + chart2::CurveStyle aInnerValue; + + if(1==nOuterValue) + aInnerValue = chart2::CurveStyle_CUBIC_SPLINES; + else if(2==nOuterValue) + aInnerValue = chart2::CurveStyle_B_SPLINES; + else + aInnerValue = chart2::CurveStyle_LINES; + + return uno::makeAny(aInnerValue); +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx new file mode 100644 index 000000000000..364a74747dfe --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSplineProperties.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSplineProperties.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SPLINE_PROPERTIES_HXX +#define CHART_WRAPPED_SPLINE_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedSplineProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ); + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SPLINE_PROPERTIES_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx new file mode 100644 index 000000000000..226bfd14bf4d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.cxx @@ -0,0 +1,1158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedStatisticProperties.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedStatisticProperties.hxx" +#include "WrappedSeriesOrDiagramProperty.hxx" +#include "macros.hxx" +#include "FastPropertyIdRanges.hxx" +#include "RegressionCurveHelper.hxx" +#include "DiagramHelper.hxx" +#include "ErrorBar.hxx" +#include "StatisticsHelper.hxx" + +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart/ChartErrorCategory.hpp> +#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/data/XDataProvider.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +namespace +{ + +Any lcl_getRegressionDefault() +{ + Any aRet; + aRet <<= ::com::sun::star::chart::ChartRegressionCurveType_NONE; + return aRet; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +::com::sun::star::chart::ChartRegressionCurveType lcl_getRegressionCurveType( RegressionCurveHelper::tRegressionType eRegressionType ) +{ + ::com::sun::star::chart::ChartRegressionCurveType eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE; + switch(eRegressionType) + { + case RegressionCurveHelper::REGRESSION_TYPE_LINEAR: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_LINEAR; + break; + case RegressionCurveHelper::REGRESSION_TYPE_LOG: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM; + break; + case RegressionCurveHelper::REGRESSION_TYPE_EXP: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL; + break; + case RegressionCurveHelper::REGRESSION_TYPE_POWER: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_POWER; + break; + default: + eRet = ::com::sun::star::chart::ChartRegressionCurveType_NONE; + break; + } + return eRet; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +RegressionCurveHelper::tRegressionType lcl_getRegressionType( ::com::sun::star::chart::ChartRegressionCurveType eRegressionCurveType ) +{ + RegressionCurveHelper::tRegressionType eRet; + switch(eRegressionCurveType) + { + case ::com::sun::star::chart::ChartRegressionCurveType_LINEAR: + eRet = RegressionCurveHelper::REGRESSION_TYPE_LINEAR; + break; + case ::com::sun::star::chart::ChartRegressionCurveType_LOGARITHM: + eRet = RegressionCurveHelper::REGRESSION_TYPE_LOG; + break; + case ::com::sun::star::chart::ChartRegressionCurveType_EXPONENTIAL: + eRet = RegressionCurveHelper::REGRESSION_TYPE_EXP; + break; + case ::com::sun::star::chart::ChartRegressionCurveType_POLYNOMIAL: + case ::com::sun::star::chart::ChartRegressionCurveType_POWER: + eRet = RegressionCurveHelper::REGRESSION_TYPE_POWER; + break; + default: + eRet = RegressionCurveHelper::REGRESSION_TYPE_NONE; + break; + } + return eRet; +} + +sal_Int32 lcl_getErrorBarStyle( const uno::Reference< beans::XPropertySet >& xErrorBarProperties ) +{ + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + if(xErrorBarProperties.is()) + xErrorBarProperties->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle; + return nStyle; +} + +uno::Reference< chart2::data::XDataProvider > lcl_getDataProviderFromContact( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + uno::Reference< chart2::data::XDataProvider > xResult; + if( spChart2ModelContact.get()) + { + uno::Reference< chart2::XChartDocument > xChartDoc( + spChart2ModelContact->getChart2Document()); + if( xChartDoc.is()) + xResult.set( xChartDoc->getDataProvider()); + } + return xResult; +} + +void lcl_ConvertRangeFromXML( + ::rtl::OUString & rInOutRange, + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + if( rInOutRange.getLength()) + { + uno::Reference< chart2::data::XRangeXMLConversion > xConverter( + lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); + if( xConverter.is()) + { + ::rtl::OUString aResult = xConverter->convertRangeFromXML( rInOutRange ); + rInOutRange = aResult; + } + } +} + +void lcl_ConvertRangeToXML( + ::rtl::OUString & rInOutRange, + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + if( rInOutRange.getLength()) + { + uno::Reference< chart2::data::XRangeXMLConversion > xConverter( + lcl_getDataProviderFromContact( spChart2ModelContact ), uno::UNO_QUERY ); + if( xConverter.is()) + { + ::rtl::OUString aResult = xConverter->convertRangeToXML( rInOutRange ); + rInOutRange = aResult; + } + } +} + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +template< typename PROPERTYTYPE > +class WrappedStatisticProperty : public WrappedSeriesOrDiagramProperty< PROPERTYTYPE > +{ +public: + explicit WrappedStatisticProperty( const OUString& rName, const Any& rDefaulValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< PROPERTYTYPE >(rName,rDefaulValue,spChart2ModelContact,ePropertyType) + {} + virtual ~WrappedStatisticProperty() {}; + + +protected: + uno::Reference< beans::XPropertySet > getOrCreateErrorBarProperties( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const + { + if(!xSeriesPropertySet.is()) + return 0; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties; + if( !xErrorBarProperties.is() ) + { + // todo: use a valid context + xErrorBarProperties = ::chart::createErrorBar( uno::Reference< uno::XComponentContext >() ); + //default in new and old api are different + xErrorBarProperties->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny(sal_Bool(sal_False)) ); + xErrorBarProperties->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny(sal_Bool(sal_False)) ); + xErrorBarProperties->setPropertyValue( C2U( "ErrorBarStyle" ), uno::makeAny(::com::sun::star::chart::ErrorBarStyle::NONE) ); + xSeriesPropertySet->setPropertyValue( C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProperties ) ); + } + return xErrorBarProperties; + } + +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_CONST_ERROR_LOW +class WrappedConstantErrorLowProperty : public WrappedStatisticProperty< double > +{ +public: + virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const; + + explicit WrappedConstantErrorLowProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedConstantErrorLowProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedConstantErrorLowProperty::WrappedConstantErrorLowProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< double >( C2U("ConstantErrorLow") + , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedConstantErrorLowProperty::~WrappedConstantErrorLowProperty() +{ +} + +double WrappedConstantErrorLowProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + double aRet = 0.0; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + xErrorBarProperties->getPropertyValue( C2U( "NegativeError" )) >>= aRet; + else + m_aOuterValue >>= aRet; + } + return aRet; +} +void WrappedConstantErrorLowProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + m_aOuterValue = uno::makeAny( aNewValue ); + if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + { + xErrorBarProperties->setPropertyValue( C2U( "NegativeError" ), m_aOuterValue ); + } + } +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_CONST_ERROR_HIGH +class WrappedConstantErrorHighProperty : public WrappedStatisticProperty< double > +{ +public: + virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const; + + explicit WrappedConstantErrorHighProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedConstantErrorHighProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedConstantErrorHighProperty::WrappedConstantErrorHighProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< double >( C2U("ConstantErrorHigh") + , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedConstantErrorHighProperty::~WrappedConstantErrorHighProperty() +{ +} + +double WrappedConstantErrorHighProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + double aRet = 0.0; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + xErrorBarProperties->getPropertyValue( C2U( "PositiveError" )) >>= aRet; + else + m_aOuterValue >>= aRet; + } + return aRet; +} +void WrappedConstantErrorHighProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + m_aOuterValue = uno::makeAny( aNewValue ); + if( ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + { + xErrorBarProperties->setPropertyValue( C2U( "PositiveError" ), m_aOuterValue ); + } + } +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_MEAN_VALUE +class WrappedMeanValueProperty : public WrappedStatisticProperty< sal_Bool > +{ +public: + virtual sal_Bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Bool aNewValue ) const; + + explicit WrappedMeanValueProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedMeanValueProperty(); +}; + +WrappedMeanValueProperty::WrappedMeanValueProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< sal_Bool >( C2U("MeanValue"), uno::makeAny( sal_False ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedMeanValueProperty::~WrappedMeanValueProperty() +{ +} + +sal_Bool WrappedMeanValueProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + sal_Bool bRet = sal_False; + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); + if( xRegCnt.is() ) + bRet = RegressionCurveHelper::hasMeanValueLine( xRegCnt ); + return bRet; +} +void WrappedMeanValueProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Bool aNewValue ) const +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); + if( xRegCnt.is() ) + { + if(aNewValue) + RegressionCurveHelper::addMeanValueLine( xRegCnt, 0, 0 ); + else + RegressionCurveHelper::removeMeanValueLine( xRegCnt ); + } +} +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_CATEGORY +// deprecated, replaced by ErrorBarStyle +class WrappedErrorCategoryProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorCategory > +{ +public: + virtual ::com::sun::star::chart::ChartErrorCategory getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartErrorCategory aNewValue ) const; + + explicit WrappedErrorCategoryProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorCategoryProperty(); +}; + +WrappedErrorCategoryProperty::WrappedErrorCategoryProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorCategory >( C2U("ErrorCategory") + , uno::makeAny( ::com::sun::star::chart::ChartErrorCategory_NONE ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorCategoryProperty::~WrappedErrorCategoryProperty() +{ +} + +::com::sun::star::chart::ChartErrorCategory WrappedErrorCategoryProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + ::com::sun::star::chart::ChartErrorCategory aRet = ::com::sun::star::chart::ChartErrorCategory_NONE; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + xErrorBarProperties->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle; + switch(nStyle) + { + case ::com::sun::star::chart::ErrorBarStyle::NONE: + aRet = ::com::sun::star::chart::ChartErrorCategory_NONE; + break; + case ::com::sun::star::chart::ErrorBarStyle::VARIANCE: + aRet = ::com::sun::star::chart::ChartErrorCategory_VARIANCE; + break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION: + aRet = ::com::sun::star::chart::ChartErrorCategory_STANDARD_DEVIATION; + break; + case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE: + aRet = ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE; + break; + case ::com::sun::star::chart::ErrorBarStyle::RELATIVE: + aRet = ::com::sun::star::chart::ChartErrorCategory_PERCENT; + break; + case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: + aRet = ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN; + break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR: + break; + case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA: + break; + default: + break; + } + } + return aRet; +} +void WrappedErrorCategoryProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartErrorCategory aNewValue ) const +{ + if( !xSeriesPropertySet.is() ) + return; + + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + sal_Int32 nNewStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + switch(aNewValue) + { + case ::com::sun::star::chart::ChartErrorCategory_NONE: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + break; + case ::com::sun::star::chart::ChartErrorCategory_VARIANCE: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; + break; + case ::com::sun::star::chart::ChartErrorCategory_STANDARD_DEVIATION: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; + break; + case ::com::sun::star::chart::ChartErrorCategory_CONSTANT_VALUE: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; + break; + case ::com::sun::star::chart::ChartErrorCategory_PERCENT: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; + break; + case ::com::sun::star::chart::ChartErrorCategory_ERROR_MARGIN: + nNewStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; + break; + default: + break; + } + xErrorBarProperties->setPropertyValue( C2U( "ErrorBarStyle" ), uno::makeAny(nNewStyle) ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_PERCENT_ERROR +class WrappedPercentageErrorProperty : public WrappedStatisticProperty< double > +{ +public: + virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const; + + explicit WrappedPercentageErrorProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedPercentageErrorProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedPercentageErrorProperty::WrappedPercentageErrorProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< double >( C2U("PercentageError") + , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedPercentageErrorProperty::~WrappedPercentageErrorProperty() +{ +} + +double WrappedPercentageErrorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + double aRet = 0.0; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + xErrorBarProperties->getPropertyValue( C2U( "PositiveError" )) >>= aRet; + else + m_aOuterValue >>= aRet; + } + return aRet; +} +void WrappedPercentageErrorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + m_aOuterValue = uno::makeAny( aNewValue ); + if( ::com::sun::star::chart::ErrorBarStyle::RELATIVE == lcl_getErrorBarStyle( xErrorBarProperties ) ) + { + xErrorBarProperties->setPropertyValue( C2U( "PositiveError" ), m_aOuterValue ); + xErrorBarProperties->setPropertyValue( C2U( "NegativeError" ), m_aOuterValue ); + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_MARGIN +class WrappedErrorMarginProperty : public WrappedStatisticProperty< double > +{ +public: + virtual double getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const; + + explicit WrappedErrorMarginProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorMarginProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedErrorMarginProperty::WrappedErrorMarginProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< double >( C2U("ErrorMargin") + , uno::makeAny( double(0.0) ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorMarginProperty::~WrappedErrorMarginProperty() +{ +} + +double WrappedErrorMarginProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + double aRet = 0.0; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + if( ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN == lcl_getErrorBarStyle( xErrorBarProperties ) ) + xErrorBarProperties->getPropertyValue( C2U( "PositiveError" )) >>= aRet; + else + m_aOuterValue >>= aRet; + } + return aRet; +} +void WrappedErrorMarginProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, double aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + m_aOuterValue = uno::makeAny( aNewValue ); + if( ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN == lcl_getErrorBarStyle( xErrorBarProperties ) ) + { + xErrorBarProperties->setPropertyValue( C2U( "PositiveError" ), m_aOuterValue ); + xErrorBarProperties->setPropertyValue( C2U( "NegativeError" ), m_aOuterValue ); + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_INDICATOR +class WrappedErrorIndicatorProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorIndicatorType > +{ +public: + virtual ::com::sun::star::chart::ChartErrorIndicatorType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartErrorIndicatorType aNewValue ) const; + + explicit WrappedErrorIndicatorProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorIndicatorProperty(); +}; + +WrappedErrorIndicatorProperty::WrappedErrorIndicatorProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< ::com::sun::star::chart::ChartErrorIndicatorType >( C2U("ErrorIndicator") + , uno::makeAny( ::com::sun::star::chart::ChartErrorIndicatorType_NONE ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorIndicatorProperty::~WrappedErrorIndicatorProperty() +{ +} + +::com::sun::star::chart::ChartErrorIndicatorType WrappedErrorIndicatorProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + ::com::sun::star::chart::ChartErrorIndicatorType aRet = ::com::sun::star::chart::ChartErrorIndicatorType_NONE; + m_aDefaultValue >>= aRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + sal_Bool bPositive = sal_False; + sal_Bool bNegative = sal_False; + xErrorBarProperties->getPropertyValue( C2U( "ShowPositiveError" )) >>= bPositive; + xErrorBarProperties->getPropertyValue( C2U( "ShowNegativeError" )) >>= bNegative; + + if( bPositive && bNegative ) + aRet = ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM; + else if( bPositive && !bNegative ) + aRet = ::com::sun::star::chart::ChartErrorIndicatorType_UPPER; + else if( !bPositive && bNegative ) + aRet = ::com::sun::star::chart::ChartErrorIndicatorType_LOWER; + } + return aRet; +} +void WrappedErrorIndicatorProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartErrorIndicatorType aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + sal_Bool bPositive = sal_False; + sal_Bool bNegative = sal_False; + switch( aNewValue ) + { + case ::com::sun::star::chart::ChartErrorIndicatorType_TOP_AND_BOTTOM: + bPositive = sal_True; + bNegative = sal_True; + break; + case ::com::sun::star::chart::ChartErrorIndicatorType_UPPER: + bPositive = sal_True; + break; + case ::com::sun::star::chart::ChartErrorIndicatorType_LOWER: + bNegative = sal_True; + break; + default: + break; + } + + xErrorBarProperties->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny(bPositive) ); + xErrorBarProperties->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny(bNegative) ); + } +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_BAR_STYLE +// this is the new constant group that replaces the deprecated enum ChartErrorCategory +class WrappedErrorBarStyleProperty : public WrappedStatisticProperty< sal_Int32 > +{ +public: + virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nNewValue ) const; + + explicit WrappedErrorBarStyleProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact1, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorBarStyleProperty(); +}; + +WrappedErrorBarStyleProperty::WrappedErrorBarStyleProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< sal_Int32 >( C2U("ErrorBarStyle") + , uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorBarStyleProperty::~WrappedErrorBarStyleProperty() +{ +} + +sal_Int32 WrappedErrorBarStyleProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + sal_Int32 nRet = ::com::sun::star::chart::ErrorBarStyle::NONE; + m_aDefaultValue >>= nRet; + uno::Reference< beans::XPropertySet > xErrorBarProperties; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarProperties ) && xErrorBarProperties.is()) + { + xErrorBarProperties->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nRet; + } + return nRet; +} +void WrappedErrorBarStyleProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nNewValue ) const +{ + if( !xSeriesPropertySet.is() ) + return; + + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + xErrorBarProperties->setPropertyValue( C2U( "ErrorBarStyle" ), uno::makeAny( nNewValue )); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE +class WrappedErrorBarRangePositiveProperty : public WrappedStatisticProperty< OUString > +{ +public: + virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewValue ) const; + + explicit WrappedErrorBarRangePositiveProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorBarRangePositiveProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedErrorBarRangePositiveProperty::WrappedErrorBarRangePositiveProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< OUString >( C2U("ErrorBarRangePositive") + , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorBarRangePositiveProperty::~WrappedErrorBarRangePositiveProperty() +{ +} + +OUString WrappedErrorBarRangePositiveProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + OUString aRet; + m_aDefaultValue >>= aRet; + uno::Reference< chart2::data::XDataSource > xErrorBarDataSource; + if( xSeriesPropertySet.is() && + ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarDataSource ) && + xErrorBarDataSource.is()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarDataSource, true /* positive */, true /* y-error */ )); + if( xSeq.is()) + aRet = xSeq->getSourceRangeRepresentation(); + else + m_aOuterValue >>= aRet; + } + lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact ); + return aRet; +} + +void WrappedErrorBarRangePositiveProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + uno::Reference< chart2::data::XDataProvider > xDataProvider( + lcl_getDataProviderFromContact( m_spChart2ModelContact )); + uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); + if( xDataSource.is() && xDataProvider.is()) + { + OUString aXMLRange( aNewValue ); + lcl_ConvertRangeFromXML( aNewValue, m_spChart2ModelContact ); + StatisticsHelper::setErrorDataSequence( + xDataSource, xDataProvider, aNewValue, true /* positive */, true /* y-error */, &aXMLRange ); + m_aOuterValue <<= aNewValue; + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE +class WrappedErrorBarRangeNegativeProperty : public WrappedStatisticProperty< OUString > +{ +public: + virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewValue ) const; + + explicit WrappedErrorBarRangeNegativeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedErrorBarRangeNegativeProperty(); + +private: + mutable Any m_aOuterValue; +}; + +WrappedErrorBarRangeNegativeProperty::WrappedErrorBarRangeNegativeProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< OUString >( C2U("ErrorBarRangeNegative") + , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType ) +{ +} +WrappedErrorBarRangeNegativeProperty::~WrappedErrorBarRangeNegativeProperty() +{ +} + +OUString WrappedErrorBarRangeNegativeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + OUString aRet; + m_aDefaultValue >>= aRet; + uno::Reference< chart2::data::XDataSource > xErrorBarDataSource; + if( xSeriesPropertySet.is() && + ( xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xErrorBarDataSource ) && + xErrorBarDataSource.is()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarDataSource, false /* positive */, true /* y-error */ )); + if( xSeq.is()) + aRet = xSeq->getSourceRangeRepresentation(); + else + m_aOuterValue >>= aRet; + } + lcl_ConvertRangeToXML( aRet, m_spChart2ModelContact ); + return aRet; +} + +void WrappedErrorBarRangeNegativeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewValue ) const +{ + uno::Reference< beans::XPropertySet > xErrorBarProperties( getOrCreateErrorBarProperties(xSeriesPropertySet) ); + if( xErrorBarProperties.is() ) + { + uno::Reference< chart2::data::XDataProvider > xDataProvider( + lcl_getDataProviderFromContact( m_spChart2ModelContact )); + uno::Reference< chart2::data::XDataSource > xDataSource( xErrorBarProperties, uno::UNO_QUERY ); + if( xDataSource.is() && xDataProvider.is()) + { + OUString aXMLRange( aNewValue ); + lcl_ConvertRangeFromXML( aNewValue, m_spChart2ModelContact ); + StatisticsHelper::setErrorDataSequence( + xDataSource, xDataProvider, aNewValue, false /* positive */, true /* y-error */, &aXMLRange ); + m_aOuterValue <<= aNewValue; + } + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_REGRESSION_CURVES +class WrappedRegressionCurvesProperty : public WrappedStatisticProperty< ::com::sun::star::chart::ChartRegressionCurveType > +{ +public: + virtual ::com::sun::star::chart::ChartRegressionCurveType getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartRegressionCurveType aNewValue ) const; + + explicit WrappedRegressionCurvesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedRegressionCurvesProperty(); +}; + +WrappedRegressionCurvesProperty::WrappedRegressionCurvesProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< ::com::sun::star::chart::ChartRegressionCurveType >( C2U("RegressionCurves") + , lcl_getRegressionDefault(), spChart2ModelContact, ePropertyType ) +{ +} +WrappedRegressionCurvesProperty::~WrappedRegressionCurvesProperty() +{ +} + +::com::sun::star::chart::ChartRegressionCurveType WrappedRegressionCurvesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + ::com::sun::star::chart::ChartRegressionCurveType aRet; + m_aDefaultValue >>= aRet; + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); + if( xRegCnt.is() ) + { + aRet = lcl_getRegressionCurveType( + RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt ) ); + } + return aRet; +} +void WrappedRegressionCurvesProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, ::com::sun::star::chart::ChartRegressionCurveType aNewValue ) const +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); + if( xRegCnt.is() ) + { + RegressionCurveHelper::tRegressionType eNewRegressionType = lcl_getRegressionType( aNewValue ); + RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt ); + if( eNewRegressionType != RegressionCurveHelper::REGRESSION_TYPE_NONE ) + RegressionCurveHelper::addRegressionCurve( eNewRegressionType, xRegCnt, 0, 0 ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//PROP_CHART_STATISTIC_REGRESSION_PROPERTIES +//PROP_CHART_STATISTIC_ERROR_PROPERTIES +//PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES +class WrappedStatisticPropertySetProperty : public WrappedStatisticProperty< Reference< beans::XPropertySet > > +{ +public: + virtual Reference< beans::XPropertySet > getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + // properties are read-only, so this method should never be called + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, Reference< beans::XPropertySet > xNewValue ) const; + + enum PropertySetType + { + PROPERTY_SET_TYPE_REGRESSION, + PROPERTY_SET_TYPE_ERROR_BAR, + PROPERTY_SET_TYPE_MEAN_VALUE + }; + + explicit WrappedStatisticPropertySetProperty( + PropertySetType ePropertySetType, ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedStatisticPropertySetProperty(); + +private: + PropertySetType m_eType; +}; + +WrappedStatisticPropertySetProperty::WrappedStatisticPropertySetProperty( + PropertySetType ePropertySetType + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedStatisticProperty< Reference< beans::XPropertySet > >( + (ePropertySetType == PROPERTY_SET_TYPE_REGRESSION) + ? C2U("DataRegressionProperties") + : (ePropertySetType == PROPERTY_SET_TYPE_ERROR_BAR) + ? C2U("DataErrorProperties") + : C2U("DataMeanValueProperties") + , uno::Any(), spChart2ModelContact, ePropertyType ) + , m_eType( ePropertySetType ) +{ +} +WrappedStatisticPropertySetProperty::~WrappedStatisticPropertySetProperty() +{ +} + +Reference< beans::XPropertySet > WrappedStatisticPropertySetProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + Reference< beans::XPropertySet > xResult; + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropertySet, uno::UNO_QUERY ); + + switch( m_eType ) + { + case PROPERTY_SET_TYPE_REGRESSION: + if( xRegCnt.is() ) + xResult.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + break; + case PROPERTY_SET_TYPE_ERROR_BAR: + if( xSeriesPropertySet.is()) + xSeriesPropertySet->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult; + break; + case PROPERTY_SET_TYPE_MEAN_VALUE: + if( xRegCnt.is() ) + xResult.set( RegressionCurveHelper::getMeanValueLine( xRegCnt ), uno::UNO_QUERY ); + break; + } + + return xResult; +} + +void WrappedStatisticPropertySetProperty::setValueToSeries( + const Reference< beans::XPropertySet >& /* xSeriesPropertySet */ + , Reference< beans::XPropertySet > /* xNewValue */ ) const +{ + OSL_ENSURE( false, "Trying to set a read-only property" ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace +{ +enum +{ + //statistic properties + PROP_CHART_STATISTIC_CONST_ERROR_LOW = FAST_PROPERTY_ID_START_CHART_STATISTIC_PROP, + PROP_CHART_STATISTIC_CONST_ERROR_HIGH, + PROP_CHART_STATISTIC_MEAN_VALUE, + PROP_CHART_STATISTIC_ERROR_CATEGORY, + PROP_CHART_STATISTIC_ERROR_BAR_STYLE, + PROP_CHART_STATISTIC_PERCENT_ERROR, + PROP_CHART_STATISTIC_ERROR_MARGIN, + PROP_CHART_STATISTIC_ERROR_INDICATOR, + PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE, + PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE, + PROP_CHART_STATISTIC_REGRESSION_CURVES, + PROP_CHART_STATISTIC_REGRESSION_PROPERTIES, + PROP_CHART_STATISTIC_ERROR_PROPERTIES, + PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES +}; + +/** @parameter bDataSeriesProperty if true, this property is for a single data + series, if false, it is for the whole diagram, i.e. for all + series + */ +void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) +{ + rList.push_back( new WrappedConstantErrorLowProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedConstantErrorHighProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedMeanValueProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorCategoryProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorBarStyleProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedPercentageErrorProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorMarginProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorIndicatorProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorBarRangePositiveProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedErrorBarRangeNegativeProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedRegressionCurvesProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedStatisticPropertySetProperty( + WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_REGRESSION, spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedStatisticPropertySetProperty( + WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_ERROR_BAR, spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedStatisticPropertySetProperty( + WrappedStatisticPropertySetProperty::PROPERTY_SET_TYPE_MEAN_VALUE, spChart2ModelContact, ePropertyType ) ); +} + +}//anonymous namespace + +//static +void WrappedStatisticProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "ConstantErrorLow" ), + PROP_CHART_STATISTIC_CONST_ERROR_LOW, + ::getCppuType( reinterpret_cast< double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ConstantErrorHigh" ), + PROP_CHART_STATISTIC_CONST_ERROR_HIGH, + ::getCppuType( reinterpret_cast< double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "MeanValue" ), + PROP_CHART_STATISTIC_MEAN_VALUE, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorCategory" ), + PROP_CHART_STATISTIC_ERROR_CATEGORY, + ::getCppuType( reinterpret_cast< ::com::sun::star::chart::ChartErrorCategory * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorBarStyle" ), + PROP_CHART_STATISTIC_ERROR_BAR_STYLE, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "PercentageError" ), + PROP_CHART_STATISTIC_PERCENT_ERROR, + ::getCppuType( reinterpret_cast< double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorMargin" ), + PROP_CHART_STATISTIC_ERROR_MARGIN, + ::getCppuType( reinterpret_cast< double * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorIndicator" ), + PROP_CHART_STATISTIC_ERROR_INDICATOR, + ::getCppuType( reinterpret_cast< ::com::sun::star::chart::ChartErrorIndicatorType * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorBarRangePositive" ), + PROP_CHART_STATISTIC_ERROR_RANGE_POSITIVE, + ::getCppuType( reinterpret_cast< OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "ErrorBarRangeNegative" ), + PROP_CHART_STATISTIC_ERROR_RANGE_NEGATIVE, + ::getCppuType( reinterpret_cast< OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + rOutProperties.push_back( + Property( C2U( "RegressionCurves" ), + PROP_CHART_STATISTIC_REGRESSION_CURVES, + ::getCppuType( reinterpret_cast< const ::com::sun::star::chart::ChartRegressionCurveType * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "DataRegressionProperties" ), + PROP_CHART_STATISTIC_REGRESSION_PROPERTIES, + ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "DataErrorProperties" ), + PROP_CHART_STATISTIC_ERROR_PROPERTIES, + ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "DataMeanValueProperties" ), + PROP_CHART_STATISTIC_MEAN_VALUE_PROPERTIES, + ::getCppuType( reinterpret_cast< const Reference< beans::XPropertySet > * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::READONLY + | beans::PropertyAttribute::MAYBEVOID )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedStatisticProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedStatisticProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx new file mode 100644 index 000000000000..5e20f65a189d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedStatisticProperties.hxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedStatisticProperties.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_STATISTIC_PROPERTIES_HXX +#define CHART_WRAPPED_STATISTIC_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +class WrappedStatisticProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ); + static void addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + static void addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_STATISTIC_PROPERTIES_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx new file mode 100644 index 000000000000..0b68ec120231 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.cxx @@ -0,0 +1,333 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedStockProperties.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedStockProperties.hxx" +#include "macros.hxx" +#include "FastPropertyIdRanges.hxx" +#include "DiagramHelper.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerLockGuard.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +class WrappedStockProperty : public WrappedProperty +{ +public: + explicit WrappedStockProperty( const ::rtl::OUString& rOuterName + , const ::com::sun::star::uno::Any& rDefaulValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedStockProperty(); + + void setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + ::com::sun::star::uno::Any getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + virtual uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( sal_Bool bNewValue, const rtl::OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const = 0; + +protected: + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + mutable ::com::sun::star::uno::Any m_aOuterValue; + ::com::sun::star::uno::Any m_aDefaultValue; +}; + +WrappedStockProperty::WrappedStockProperty( const ::rtl::OUString& rOuterName + , const ::com::sun::star::uno::Any& rDefaulValue + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedProperty(rOuterName,rtl::OUString()) + , m_spChart2ModelContact(spChart2ModelContact) + , m_aOuterValue() + , m_aDefaultValue(rDefaulValue) +{ +} +WrappedStockProperty::~WrappedStockProperty() +{ +} + +void WrappedStockProperty::setPropertyValue( const ::com::sun::star::uno::Any& rOuterValue, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + sal_Bool bNewValue = false; + if( ! (rOuterValue >>= bNewValue) ) + throw lang::IllegalArgumentException( C2U("stock properties require type sal_Bool"), 0, 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 ) + { + Reference< lang::XMultiServiceFactory > xFactory( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFactory ); + + uno::Reference< chart2::XChartTypeTemplate > xTemplate = + getNewTemplate( bNewValue, aTemplateAndService.second, xFactory ); + + if(xTemplate.is()) + { + try + { + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( m_spChart2ModelContact->getChartModel() ); + xTemplate->changeDiagram( xDiagram ); + // \-- locked controllers + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } +} + +::com::sun::star::uno::Any WrappedStockProperty::getPropertyDefault( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + return m_aDefaultValue; +} + +//------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------- + +class WrappedVolumeProperty : public WrappedStockProperty +{ +public: + explicit WrappedVolumeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedVolumeProperty(); + + ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( sal_Bool bNewValue, const rtl::OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const; +}; + +WrappedVolumeProperty::WrappedVolumeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedStockProperty( C2U("Volume"), uno::makeAny(sal_False) , spChart2ModelContact ) +{ +} +WrappedVolumeProperty::~WrappedVolumeProperty() +{ +} + +::com::sun::star::uno::Any WrappedVolumeProperty::getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() && xChartDoc.is() ) + { + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( + DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + if( aSeriesVector.size() > 0 ) + { + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + + if( aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ) ) + || aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ) ) + m_aOuterValue <<= sal_Bool(sal_True); + else if( aTemplateAndService.second.getLength() || !m_aOuterValue.hasValue() ) + m_aOuterValue <<= sal_Bool(sal_False); + } + else if(!m_aOuterValue.hasValue()) + m_aOuterValue <<= sal_Bool(sal_False); + } + return m_aOuterValue; +} + +uno::Reference< chart2::XChartTypeTemplate > WrappedVolumeProperty::getNewTemplate( sal_Bool bNewValue, const rtl::OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +{ + uno::Reference< chart2::XChartTypeTemplate > xTemplate(0); + + if(!xFactory.is()) + return xTemplate; + + if( bNewValue ) //add volume + { + if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ) ), uno::UNO_QUERY ); + else if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ), uno::UNO_QUERY ); + } + else //remove volume + { + if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockLowHighClose" ) ), uno::UNO_QUERY ); + else if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ) ), uno::UNO_QUERY ); + } + return xTemplate; +} + +//------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------- + + +class WrappedUpDownProperty : public WrappedStockProperty +{ +public: + explicit WrappedUpDownProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + virtual ~WrappedUpDownProperty(); + + ::com::sun::star::uno::Any getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xInnerPropertySet ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + uno::Reference< chart2::XChartTypeTemplate > getNewTemplate( sal_Bool bNewValue, const rtl::OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const; +}; +WrappedUpDownProperty::WrappedUpDownProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) + : WrappedStockProperty( C2U("UpDown"), uno::makeAny(sal_False) , spChart2ModelContact ) +{ +} +WrappedUpDownProperty::~WrappedUpDownProperty() +{ +} +::com::sun::star::uno::Any WrappedUpDownProperty::getPropertyValue( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& /*xInnerPropertySet*/ ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException) +{ + Reference< chart2::XChartDocument > xChartDoc( m_spChart2ModelContact->getChart2Document() ); + Reference< chart2::XDiagram > xDiagram( m_spChart2ModelContact->getChart2Diagram() ); + if( xDiagram.is() && xChartDoc.is() ) + { + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesVector( + DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + if( aSeriesVector.size() > 0 ) + { + Reference< lang::XMultiServiceFactory > xFact( xChartDoc->getChartTypeManager(), uno::UNO_QUERY ); + DiagramHelper::tTemplateWithServiceName aTemplateAndService = + DiagramHelper::getTemplateForDiagram( xDiagram, xFact ); + + if( aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ) ) + || aTemplateAndService.second.equals( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ) ) + m_aOuterValue <<= sal_Bool(sal_True); + else if( aTemplateAndService.second.getLength() || !m_aOuterValue.hasValue() ) + m_aOuterValue <<= sal_Bool(sal_False); + } + else if(!m_aOuterValue.hasValue()) + m_aOuterValue <<= sal_Bool(sal_False); + } + return m_aOuterValue; +} +uno::Reference< chart2::XChartTypeTemplate > WrappedUpDownProperty::getNewTemplate( sal_Bool bNewValue, const rtl::OUString& rCurrentTemplate, const Reference< lang::XMultiServiceFactory >& xFactory ) const +{ + uno::Reference< chart2::XChartTypeTemplate > xTemplate(0); + if( bNewValue ) //add open series + { + if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ) ), uno::UNO_QUERY ); + else if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ), uno::UNO_QUERY ); + } + else //remove open series + { + if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockLowHighClose" ) ), uno::UNO_QUERY ); + else if( rCurrentTemplate.equals( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ) ) ) + xTemplate.set( xFactory->createInstance( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ) ), uno::UNO_QUERY ); + } + return xTemplate; +} + +namespace +{ +enum +{ + //spline properties + PROP_CHART_STOCK_VOLUME = FAST_PROPERTY_ID_START_CHART_STOCK_PROP + , PROP_CHART_STOCK_UPDOWN +}; + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedStockProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "Volume" ), + PROP_CHART_STOCK_VOLUME, + ::getCppuType( reinterpret_cast< sal_Bool * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID )); + rOutProperties.push_back( + Property( C2U( "UpDown" ), + PROP_CHART_STOCK_UPDOWN, + ::getCppuType( reinterpret_cast< sal_Bool * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT + | beans::PropertyAttribute::MAYBEVOID )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedStockProperties::addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + rList.push_back( new WrappedVolumeProperty( spChart2ModelContact ) ); + rList.push_back( new WrappedUpDownProperty( spChart2ModelContact ) ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx new file mode 100644 index 000000000000..622eeaf901f5 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedStockProperties.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedStockProperties.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_STOCK_PROPERTIES_HXX +#define CHART_WRAPPED_STOCK_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedStockProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ); + static void addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_STOCK_PROPERTIES_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx new file mode 100644 index 000000000000..59bba9b5973d --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.cxx @@ -0,0 +1,596 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSymbolProperties.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedSymbolProperties.hxx" +#include "WrappedSeriesOrDiagramProperty.hxx" +#include "macros.hxx" +#include "FastPropertyIdRanges.hxx" +#include "ChartTypeHelper.hxx" +#include <com/sun/star/chart2/Symbol.hpp> +#include <com/sun/star/chart2/SymbolStyle.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/beans/PropertyAttribute.hpp> +#include <com/sun/star/chart/ChartSymbolType.hpp> +#include <com/sun/star/drawing/LineStyle.hpp> + +#include <com/sun/star/graphic/XGraphicProvider.hpp> + +// for UNO_NAME_GRAPHOBJ_URLPREFIX +#include <svx/unoprnms.hxx> + +// for Graphic +#include <vcl/graph.hxx> +// for GraphicObject +#include <goodies/grfmgr.hxx> +#include <vcl/outdev.hxx> + +#include <comphelper/processfactory.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::beans::Property; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +class WrappedSymbolTypeProperty : public WrappedSeriesOrDiagramProperty< sal_Int32 > +{ +public: + virtual sal_Int32 getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 aNewValue ) const; + + virtual Any getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException); + virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException); + + explicit WrappedSymbolTypeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedSymbolTypeProperty(); +}; + +class WrappedSymbolBitmapURLProperty : public WrappedSeriesOrDiagramProperty< OUString > +{ +public: + virtual OUString getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, OUString aNewGraphicURL ) const; + + explicit WrappedSymbolBitmapURLProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedSymbolBitmapURLProperty(); +}; + +// this operator is not defined by default +bool operator!=( const awt::Size & rSize1, const awt::Size & rSize2 ) +{ + return (rSize1.Width != rSize2.Width) || (rSize1.Height != rSize2.Height); +} + +class WrappedSymbolSizeProperty : public WrappedSeriesOrDiagramProperty< awt::Size > +{ +public: + virtual awt::Size getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, awt::Size aNewSize ) const; + virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException); + + explicit WrappedSymbolSizeProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedSymbolSizeProperty(); +}; + +class WrappedSymbolAndLinesProperty : public WrappedSeriesOrDiagramProperty< sal_Bool > +{ +public: + virtual sal_Bool getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const; + virtual void setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Bool bDrawLines ) const; + virtual beans::PropertyState getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException); + + explicit WrappedSymbolAndLinesProperty( ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ); + virtual ~WrappedSymbolAndLinesProperty(); +}; + +namespace +{ +enum +{ + //symbol properties + PROP_CHART_SYMBOL_TYPE = FAST_PROPERTY_ID_START_CHART_SYMBOL_PROP, + PROP_CHART_SYMBOL_BITMAP_URL, + PROP_CHART_SYMBOL_SIZE, + PROP_CHART_SYMBOL_AND_LINES +}; + +sal_Int32 lcl_getSymbolType( const ::com::sun::star::chart2::Symbol& rSymbol ) +{ + sal_Int32 nSymbol = ::com::sun::star::chart::ChartSymbolType::NONE; + switch( rSymbol.Style ) + { + case chart2::SymbolStyle_NONE: + break; + case chart2::SymbolStyle_AUTO: + nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; + break; + case chart2::SymbolStyle_STANDARD: + nSymbol = rSymbol.StandardSymbol%8; + break; + case chart2::SymbolStyle_POLYGON://new feature + nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; + break; + case chart2::SymbolStyle_GRAPHIC: + nSymbol = ::com::sun::star::chart::ChartSymbolType::BITMAPURL; + break; + default: + nSymbol = ::com::sun::star::chart::ChartSymbolType::AUTO; + break; + } + return nSymbol; +} +void lcl_setSymbolTypeToSymbol( sal_Int32 nSymbolType, chart2::Symbol& rSymbol ) +{ + switch( nSymbolType ) + { + case ::com::sun::star::chart::ChartSymbolType::NONE: + rSymbol.Style = chart2::SymbolStyle_NONE; + break; + case ::com::sun::star::chart::ChartSymbolType::AUTO: + rSymbol.Style = chart2::SymbolStyle_AUTO; + break; + case ::com::sun::star::chart::ChartSymbolType::BITMAPURL: + rSymbol.Style = chart2::SymbolStyle_GRAPHIC; + break; + default: + rSymbol.Style = chart2::SymbolStyle_STANDARD; + rSymbol.StandardSymbol = nSymbolType; + break; + } +} + +void lcl_addWrappedProperties( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact + , tSeriesOrDiagramPropertyType ePropertyType ) +{ + rList.push_back( new WrappedSymbolTypeProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedSymbolBitmapURLProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedSymbolSizeProperty( spChart2ModelContact, ePropertyType ) ); + rList.push_back( new WrappedSymbolAndLinesProperty( spChart2ModelContact, ePropertyType ) ); +} + +}//anonymous namespace + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//static +void WrappedSymbolProperties::addProperties( ::std::vector< Property > & rOutProperties ) +{ + rOutProperties.push_back( + Property( C2U( "SymbolType" ), + PROP_CHART_SYMBOL_TYPE, + ::getCppuType( reinterpret_cast< sal_Int32 * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "SymbolBitmapURL" ), + PROP_CHART_SYMBOL_BITMAP_URL, + ::getCppuType( reinterpret_cast< ::rtl::OUString * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "SymbolSize" ), + PROP_CHART_SYMBOL_SIZE, + ::getCppuType( reinterpret_cast< awt::Size * >(0)), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); + + rOutProperties.push_back( + Property( C2U( "Lines" ), + PROP_CHART_SYMBOL_AND_LINES, + ::getBooleanCppuType(), + beans::PropertyAttribute::BOUND + | beans::PropertyAttribute::MAYBEDEFAULT )); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedSymbolProperties::addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DATA_SERIES ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +void WrappedSymbolProperties::addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ) +{ + lcl_addWrappedProperties( rList, spChart2ModelContact, DIAGRAM ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedSymbolTypeProperty::WrappedSymbolTypeProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< sal_Int32 >( C2U("SymbolType") + , uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE ) + , spChart2ModelContact + , ePropertyType ) +{ +} +WrappedSymbolTypeProperty::~WrappedSymbolTypeProperty() +{ +} + +sal_Int32 WrappedSymbolTypeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + sal_Int32 aRet = 0; + m_aDefaultValue >>= aRet; + chart2::Symbol aSymbol; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) ) + aRet = lcl_getSymbolType( aSymbol ); + return aRet; +} + +void WrappedSymbolTypeProperty::setValueToSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet, sal_Int32 nSymbolType ) const +{ + if(!xSeriesPropertySet.is()) + return; + + chart2::Symbol aSymbol; + xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol; + + lcl_setSymbolTypeToSymbol( nSymbolType, aSymbol ); + xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); +} + +Any WrappedSymbolTypeProperty::getPropertyValue( const Reference< beans::XPropertySet >& xInnerPropertySet ) const + throw ( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + //the old chart (< OOo 2.3) needs symbol-type="automatic" at the plot-area if any of the series should be able to have symbols + if( m_ePropertyType == DIAGRAM ) + { + bool bHasAmbiguousValue = false; + sal_Int32 aValue = 0; + if( detectInnerValue( aValue, bHasAmbiguousValue ) ) + { + if(bHasAmbiguousValue) + { + m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO ); + } + else + { + if( ::com::sun::star::chart::ChartSymbolType::NONE == aValue ) + m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::NONE ); + else + m_aOuterValue = uno::makeAny( ::com::sun::star::chart::ChartSymbolType::AUTO ); + } + } + return m_aOuterValue; + } + else + { + ::com::sun::star::uno::Any aRet( m_aDefaultValue ); + aRet <<= getValueFromSeries( xInnerPropertySet ); + return aRet; + } +} + +beans::PropertyState WrappedSymbolTypeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + //the special situation for this property here is that the diagram default can be + //different from the normal default and different from all sinlges series values + //so we need to return PropertyState_DIRECT_VALUE for more cases + + if( m_ePropertyType == DATA_SERIES && //single series or point + m_spChart2ModelContact.get()) + { + 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 ) ) + return beans::PropertyState_DIRECT_VALUE; + } + return WrappedProperty::getPropertyState( xInnerPropertyState ); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedSymbolBitmapURLProperty::WrappedSymbolBitmapURLProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< OUString >( C2U("SymbolBitmapURL") + , uno::makeAny( OUString() ), spChart2ModelContact, ePropertyType ) +{ +} + +WrappedSymbolBitmapURLProperty::~WrappedSymbolBitmapURLProperty() +{ +} + +OUString WrappedSymbolBitmapURLProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + OUString aRet; + m_aDefaultValue >>= aRet; + chart2::Symbol aSymbol; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) + && aSymbol.Graphic.is()) + { + GraphicObject aGrObj( Graphic( aSymbol.Graphic )); + aRet = OUString( RTL_CONSTASCII_USTRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX )); + aRet += OUString::createFromAscii( aGrObj.GetUniqueID().GetBuffer()); + } + return aRet; +} + +void WrappedSymbolBitmapURLProperty::setValueToSeries( + const Reference< beans::XPropertySet >& xSeriesPropertySet, + OUString aNewGraphicURL ) const +{ + if(!xSeriesPropertySet.is()) + return; + + chart2::Symbol aSymbol; + if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) + { + bool bMatchesPrefix = + aNewGraphicURL.matchAsciiL( RTL_CONSTASCII_STRINGPARAM( UNO_NAME_GRAPHOBJ_URLPREFIX )); + OSL_ENSURE( bMatchesPrefix, "Invalid URL for Symbol Bitmap" ); + if( bMatchesPrefix ) + { + GraphicObject aGrObj = GraphicObject( + ByteString( U2C( aNewGraphicURL.copy( sizeof( UNO_NAME_GRAPHOBJ_URLPREFIX ) - 1 )))); + aSymbol.Graphic.set( aGrObj.GetGraphic().GetXGraphic()); + xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); + } + else + { + try + { + // @todo: get factory from some context? + Reference< lang::XMultiServiceFactory > xFact( comphelper::getProcessServiceFactory(), uno::UNO_QUERY_THROW ); + Reference< graphic::XGraphicProvider > xGraphProv( + xFact->createInstance( C2U("com.sun.star.graphic.GraphicProvider")), uno::UNO_QUERY_THROW ); + Sequence< beans::PropertyValue > aArgs(1); + aArgs[0] = beans::PropertyValue( + C2U("URL"), -1, uno::makeAny( aNewGraphicURL ), + beans::PropertyState_DIRECT_VALUE ); + aSymbol.Graphic.set( xGraphProv->queryGraphic( aArgs )); + xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } +} + + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +namespace +{ + +void lcl_correctSymbolSizeForBitmaps( chart2::Symbol& rSymbol ) +{ + if( rSymbol.Style != chart2::SymbolStyle_GRAPHIC ) + return; + if( rSymbol.Size.Width != -1 ) + return; + if( rSymbol.Size.Height != -1 ) + return; + + //find a good automatic size + try + { + const awt::Size aDefaultSize(250,250); + awt::Size aSize = aDefaultSize; + uno::Reference< beans::XPropertySet > xProp( rSymbol.Graphic, uno::UNO_QUERY ); + if( xProp.is() ) + { + bool bFoundSize = false; + try + { + if( (xProp->getPropertyValue( C2U( "Size100thMM" ) ) >>= aSize) ) + { + if( aSize.Width == 0 && aSize.Height == 0 ) + aSize = aDefaultSize; + else + bFoundSize = true; + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + + if(!bFoundSize) + { + awt::Size aAWTPixelSize(10,10); + if( (xProp->getPropertyValue( C2U( "SizePixel" ) ) >>= aAWTPixelSize) ) + { + Size aPixelSize(aAWTPixelSize.Width,aAWTPixelSize.Height); + Size aNewSize = ( OutputDevice::LogicToLogic( aPixelSize, MAP_PIXEL, MAP_100TH_MM )); + aSize = awt::Size( aNewSize.Width(), aNewSize.Height() ); + + if( aSize.Width == 0 && aSize.Height == 0 ) + aSize = aDefaultSize; + } + } + } + rSymbol.Size = aSize; + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } +} + +}//end anonymous namespace + +WrappedSymbolSizeProperty::WrappedSymbolSizeProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< awt::Size >( C2U("SymbolSize") + , uno::makeAny( awt::Size(250,250) ), spChart2ModelContact, ePropertyType ) +{ +} + +WrappedSymbolSizeProperty::~WrappedSymbolSizeProperty() +{ +} + +awt::Size WrappedSymbolSizeProperty::getValueFromSeries( const Reference< beans::XPropertySet >& xSeriesPropertySet ) const +{ + awt::Size aRet; + m_aDefaultValue >>= aRet; + chart2::Symbol aSymbol; + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )) + aRet = aSymbol.Size; + return aRet; +} + +void WrappedSymbolSizeProperty::setValueToSeries( + const Reference< beans::XPropertySet >& xSeriesPropertySet, + awt::Size aNewSize ) const +{ + if(!xSeriesPropertySet.is()) + return; + + chart2::Symbol aSymbol; + if( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol ) + { + aSymbol.Size = aNewSize; + lcl_correctSymbolSizeForBitmaps(aSymbol); + xSeriesPropertySet->setPropertyValue( C2U("Symbol"), uno::makeAny( aSymbol ) ); + } +} + +beans::PropertyState WrappedSymbolSizeProperty::getPropertyState( const Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + //only export symbol size if necessary + if( m_ePropertyType == DIAGRAM ) + return beans::PropertyState_DEFAULT_VALUE; + + try + { + chart2::Symbol aSymbol; + Reference< beans::XPropertySet > xSeriesPropertySet( xInnerPropertyState, uno::UNO_QUERY ); + if( xSeriesPropertySet.is() && ( xSeriesPropertySet->getPropertyValue(C2U("Symbol")) >>= aSymbol )) + { + if( chart2::SymbolStyle_NONE != aSymbol.Style ) + return beans::PropertyState_DIRECT_VALUE; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return beans::PropertyState_DEFAULT_VALUE; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +WrappedSymbolAndLinesProperty::WrappedSymbolAndLinesProperty( + ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact, + tSeriesOrDiagramPropertyType ePropertyType ) + : WrappedSeriesOrDiagramProperty< sal_Bool >( C2U("Lines") + , uno::makeAny( sal_True ), spChart2ModelContact, ePropertyType ) +{ +} + +WrappedSymbolAndLinesProperty::~WrappedSymbolAndLinesProperty() +{ +} + +sal_Bool WrappedSymbolAndLinesProperty::getValueFromSeries( const Reference< beans::XPropertySet >& /*xSeriesPropertySet*/ ) const +{ + //do not export this property anymore, instead use a linestyle none for no lines + return sal_True; +} + +void WrappedSymbolAndLinesProperty::setValueToSeries( + const Reference< beans::XPropertySet >& xSeriesPropertySet, + sal_Bool bDrawLines ) const +{ + if(!xSeriesPropertySet.is()) + return; + + drawing::LineStyle eLineStyle( bDrawLines ? drawing::LineStyle_SOLID : drawing::LineStyle_NONE ); + xSeriesPropertySet->setPropertyValue( C2U("LineStyle"), uno::makeAny( eLineStyle ) ); +} + +beans::PropertyState WrappedSymbolAndLinesProperty::getPropertyState( const Reference< beans::XPropertyState >& /*xInnerPropertyState*/ ) const + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + //do not export this property anymore, instead use a linestyle none for no lines + return beans::PropertyState_DEFAULT_VALUE; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +} //namespace wrapper +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx new file mode 100644 index 000000000000..165832ab8664 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedSymbolProperties.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedSymbolProperties.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_SYMBOL_PROPERTIES_HXX +#define CHART_WRAPPED_SYMBOL_PROPERTIES_HXX + +#include "WrappedProperty.hxx" +#include "Chart2ModelContact.hxx" + +#include <boost/shared_ptr.hpp> +#include <vector> + +//............................................................................. +namespace chart +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- +//----------------------------------------------------------------------------------------------------------------- + +class WrappedSymbolProperties +{ +public: + static void addProperties( ::std::vector< ::com::sun::star::beans::Property > & rOutProperties ); + static void addWrappedPropertiesForSeries( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); + static void addWrappedPropertiesForDiagram( std::vector< WrappedProperty* >& rList + , ::boost::shared_ptr< Chart2ModelContact > spChart2ModelContact ); +}; + +} //namespace wrapper +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_SYMBOL_PROPERTIES_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx new file mode 100644 index 000000000000..07532a4ecf22 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.cxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedTextRotationProperty.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "WrappedTextRotationProperty.hxx" +#include "macros.hxx" +#include <com/sun/star/beans/XPropertyState.hpp> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Any; +using ::rtl::OUString; + + +//............................................................................. +namespace chart +{ +//............................................................................. + +WrappedTextRotationProperty::WrappedTextRotationProperty( bool bDirectState ) + : ::chart::WrappedProperty( C2U( "TextRotation" ), C2U( "TextRotation" ) ) + , m_bDirectState( bDirectState ) +{ +} +WrappedTextRotationProperty::~WrappedTextRotationProperty() +{ +} + +beans::PropertyState WrappedTextRotationProperty::getPropertyState( const uno::Reference< beans::XPropertyState >& xInnerPropertyState ) const + throw (beans::UnknownPropertyException, uno::RuntimeException) +{ + if( m_bDirectState ) + return beans::PropertyState_DIRECT_VALUE; + return WrappedProperty::getPropertyState( xInnerPropertyState ); +} + +Any WrappedTextRotationProperty::convertInnerToOuterValue( const Any& rInnerValue ) const +{ + Any aRet; + double fVal = 0; + if( rInnerValue >>= fVal ) + { + sal_Int32 n100thDegrees = static_cast< sal_Int32 >( fVal * 100.0 ); + aRet <<= n100thDegrees; + } + return aRet; +} +Any WrappedTextRotationProperty::convertOuterToInnerValue( const Any& rOuterValue ) const +{ + Any aRet; + sal_Int32 nVal = 0; + if( rOuterValue >>= nVal ) + { + double fDoubleDegrees = ( static_cast< double >( nVal ) / 100.0 ); + aRet <<= fDoubleDegrees; + } + return aRet; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx new file mode 100644 index 000000000000..54fbf38e53d7 --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/WrappedTextRotationProperty.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: WrappedTextRotationProperty.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_WRAPPED_TEXTROTATION_PROPERTY_HXX +#define CHART_WRAPPED_TEXTROTATION_PROPERTY_HXX + +#include "WrappedProperty.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class WrappedTextRotationProperty : public WrappedProperty +{ +public: + WrappedTextRotationProperty( bool bDirectState=false ); + virtual ~WrappedTextRotationProperty(); + + virtual ::com::sun::star::beans::PropertyState getPropertyState( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyState >& xInnerPropertyState ) const + throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException); + +protected: + virtual ::com::sun::star::uno::Any convertInnerToOuterValue( const ::com::sun::star::uno::Any& rInnerValue ) const; + virtual ::com::sun::star::uno::Any convertOuterToInnerValue( const ::com::sun::star::uno::Any& rOuterValue ) const; + + bool m_bDirectState; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +// CHART_WRAPPED_TEXTROTATION_PROPERTY_HXX +#endif diff --git a/chart2/source/controller/chartapiwrapper/makefile.mk b/chart2/source/controller/chartapiwrapper/makefile.mk new file mode 100644 index 000000000000..402b5870292c --- /dev/null +++ b/chart2/source/controller/chartapiwrapper/makefile.mk @@ -0,0 +1,81 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.4.44.3 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJNAME= chart2 +TARGET= chchartapiwrapper + +PRJINC= $(PRJ)$/source + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#Specifies object files to bind into linked libraries. +SLOFILES= \ + $(SLO)$/Chart2ModelContact.obj \ + $(SLO)$/AreaWrapper.obj \ + $(SLO)$/AxisWrapper.obj \ + $(SLO)$/ChartDataWrapper.obj \ + $(SLO)$/ChartDocumentWrapper.obj \ + $(SLO)$/DataSeriesPointWrapper.obj \ + $(SLO)$/DiagramWrapper.obj \ + $(SLO)$/GridWrapper.obj \ + $(SLO)$/LegendWrapper.obj \ + $(SLO)$/TitleWrapper.obj \ + $(SLO)$/MinMaxLineWrapper.obj \ + $(SLO)$/UpDownBarWrapper.obj \ + $(SLO)$/WallFloorWrapper.obj \ + $(SLO)$/WrappedAutomaticPositionProperties.obj \ + $(SLO)$/WrappedCharacterHeightProperty.obj \ + $(SLO)$/WrappedDataCaptionProperties.obj \ + $(SLO)$/WrappedTextRotationProperty.obj \ + $(SLO)$/WrappedGapwidthProperty.obj \ + $(SLO)$/WrappedScaleProperty.obj \ + $(SLO)$/WrappedSplineProperties.obj \ + $(SLO)$/WrappedStockProperties.obj \ + $(SLO)$/WrappedSymbolProperties.obj \ + $(SLO)$/WrappedAxisAndGridExistenceProperties.obj \ + $(SLO)$/WrappedNumberFormatProperty.obj \ + $(SLO)$/WrappedStatisticProperties.obj \ + $(SLO)$/WrappedSceneProperty.obj \ + $(SLO)$/WrappedSeriesAreaOrLineProperty.obj \ + $(SLO)$/WrappedAddInProperty.obj \ + $(SLO)$/WrappedScaleTextProperties.obj + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk diff --git a/chart2/source/controller/controller.map b/chart2/source/controller/controller.map new file mode 100644 index 000000000000..ac2c3750bfe0 --- /dev/null +++ b/chart2/source/controller/controller.map @@ -0,0 +1,8 @@ +UDK_3_0_0 { + global: + component_getImplementationEnvironment; + component_writeInfo; + component_getFactory; + local: + *; +}; diff --git a/chart2/source/controller/dialogs/Bitmaps.hrc b/chart2/source/controller/dialogs/Bitmaps.hrc new file mode 100644 index 000000000000..8823b582a28e --- /dev/null +++ b/chart2/source/controller/dialogs/Bitmaps.hrc @@ -0,0 +1,219 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Bitmaps.hrc,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_BITMAPS_HRC +#define CHART_BITMAPS_HRC + +#ifndef _SOLAR_HRC +#include <svtools/solar.hrc> +#endif + +#ifndef STD_MASKCOLOR +#define STD_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } +#endif + +//----------------------------------------------------------------------------- +// chart types +// Images: + +#define IMG_TYPE_COLUMN (RID_APP_START + 1) +#define IMG_TYPE_BAR (RID_APP_START + 2) +#define IMG_TYPE_PIE (RID_APP_START + 3) +#define IMG_TYPE_AREA (RID_APP_START + 4) +#define IMG_TYPE_LINE (RID_APP_START + 5) +#define IMG_TYPE_XY (RID_APP_START + 6) +#define IMG_TYPE_BUBBLE (RID_APP_START + 7) +#define IMG_TYPE_NET (RID_APP_START + 8) +#define IMG_TYPE_STOCK (RID_APP_START + 9) +#define IMG_TYPE_COLUMN_LINE (RID_APP_START + 10) + +//----------------------------------------------------------------------------- +//Chart Subtypes +// Bitmaps: + +//---------------------- +// Column Chart Subtypes +#define BMP_COLUMNS_2D_1 (RID_APP_START + 1) +#define BMP_COLUMNS_2D_2 (RID_APP_START + 2) +#define BMP_COLUMNS_2D_3 (RID_APP_START + 3) + +#define BMP_COLUMNS_3D (RID_APP_START + 4) +#define BMP_COLUMNS_3D_1 (RID_APP_START + 5) +#define BMP_COLUMNS_3D_2 (RID_APP_START + 6) +#define BMP_COLUMNS_3D_3 (RID_APP_START + 7) + +#define BMP_SAEULE_3D_1 (RID_APP_START + 8) +#define BMP_SAEULE_3D_2 (RID_APP_START + 9) +#define BMP_SAEULE_3D_3 (RID_APP_START + 10) +#define BMP_SAEULE_3D_4 (RID_APP_START + 11) + +#define BMP_KEGEL_3D_1 (RID_APP_START + 12) +#define BMP_KEGEL_3D_2 (RID_APP_START + 13) +#define BMP_KEGEL_3D_3 (RID_APP_START + 14) +#define BMP_KEGEL_3D_4 (RID_APP_START + 15) + +#define BMP_PYRAMID_3D_1 (RID_APP_START + 16) +#define BMP_PYRAMID_3D_2 (RID_APP_START + 17) +#define BMP_PYRAMID_3D_3 (RID_APP_START + 18) +#define BMP_PYRAMID_3D_4 (RID_APP_START + 19) + +//---------------------- +// Bar Chart Subtypes + +#define BMP_BARS_2D_1 (RID_APP_START + 20) +#define BMP_BARS_2D_2 (RID_APP_START + 21) +#define BMP_BARS_2D_3 (RID_APP_START + 22) + +#define BMP_BARS_3D (RID_APP_START + 23) +#define BMP_BARS_3D_1 (RID_APP_START + 24) +#define BMP_BARS_3D_2 (RID_APP_START + 25) +#define BMP_BARS_3D_3 (RID_APP_START + 26) + +#define BMP_ROEHRE_3D_1 (RID_APP_START + 27) +#define BMP_ROEHRE_3D_2 (RID_APP_START + 28) +#define BMP_ROEHRE_3D_3 (RID_APP_START + 29) +#define BMP_ROEHRE_3D_4 (RID_APP_START + 30) + +#define BMP_KEGELQ_3D_1 (RID_APP_START + 31) +#define BMP_KEGELQ_3D_2 (RID_APP_START + 32) +#define BMP_KEGELQ_3D_3 (RID_APP_START + 33) +#define BMP_KEGELQ_3D_4 (RID_APP_START + 34) + +#define BMP_PYRAMIDQ_3D_1 (RID_APP_START + 35) +#define BMP_PYRAMIDQ_3D_2 (RID_APP_START + 36) +#define BMP_PYRAMIDQ_3D_3 (RID_APP_START + 37) +#define BMP_PYRAMIDQ_3D_4 (RID_APP_START + 38) + +//---------------------- +// Pie and Donut Chart Subtypes + +#define BMP_CIRCLES_2D (RID_APP_START + 39) +#define BMP_CIRCLES_2D_EXPLODED (RID_APP_START + 40) +#define BMP_CIRCLES_3D (RID_APP_START + 41) +#define BMP_CIRCLES_3D_EXPLODED (RID_APP_START + 42) +#define BMP_DONUT_2D (RID_APP_START + 43) +#define BMP_DONUT_2D_EXPLODED (RID_APP_START + 44) +#define BMP_DONUT_3D (RID_APP_START + 45) +#define BMP_DONUT_3D_EXPLODED (RID_APP_START + 46) + +//---------------------- +// Points and Lines Chart Subtypes + +#define BMP_POINTS_XVALUES (RID_APP_START + 47) +#define BMP_POINTS_XCATEGORY (RID_APP_START + 48) +#define BMP_POINTS_STACKED (RID_APP_START + 49) + + +#define BMP_LINE_P_XVALUES (RID_APP_START + 50) +#define BMP_LINE_O_XVALUES (RID_APP_START + 51) +#define BMP_LINE3D_XVALUES (RID_APP_START + 52) + +#define BMP_LINE_P_XCATEGORY (RID_APP_START + 53) +#define BMP_LINE_O_XCATEGORY (RID_APP_START + 54) +#define BMP_LINE3D_XCATEGORY (RID_APP_START + 55) + +#define BMP_LINE_P_STACKED (RID_APP_START + 56) +#define BMP_LINE_O_STACKED (RID_APP_START + 57) +#define BMP_LINE3D_STACKED (RID_APP_START + 58) + +#define BMP_LINE_P_XVALUES_SMOOTH (RID_APP_START + 59) +#define BMP_LINE_O_XVALUES_SMOOTH (RID_APP_START + 60) +#define BMP_LINE3D_XVALUES_SMOOTH (RID_APP_START + 61) + +#define BMP_LINE_P_XCATEGORY_SMOOTH (RID_APP_START + 62) +#define BMP_LINE_O_XCATEGORY_SMOOTH (RID_APP_START + 63) +#define BMP_LINE3D_XCATEGORY_SMOOTH (RID_APP_START + 64) + +#define BMP_LINE_P_STACKED_SMOOTH (RID_APP_START + 65) +#define BMP_LINE_O_STACKED_SMOOTH (RID_APP_START + 66) +#define BMP_LINE3D_STACKED_SMOOTH (RID_APP_START + 67) + +//---------------------- +// Area Chart Subtypes + +#define BMP_AREAS_2D (RID_APP_START + 68) +#define BMP_AREAS_2D_1 (RID_APP_START + 69) +#define BMP_AREAS_2D_3 (RID_APP_START + 70) +#define BMP_AREAS_3D (RID_APP_START + 71) +#define BMP_AREAS_3D_1 (RID_APP_START + 72) +#define BMP_AREAS_3D_2 (RID_APP_START + 73) + +//---------------------- +// Net Chart Subtypes + +#define BMP_NET (RID_APP_START + 74) +#define BMP_NET_STACK (RID_APP_START + 75) +#define BMP_NET_SYMB (RID_APP_START + 76) +#define BMP_NET_SYMB_STACK (RID_APP_START + 77) +#define BMP_NET_LINESYMB (RID_APP_START + 78) +#define BMP_NET_LINESYMB_STACK (RID_APP_START + 79) +#define BMP_NET_FILL (RID_APP_START + 80) +#define BMP_NET_FILL_STACK (RID_APP_START + 81) + +//---------------------- +// Stock Chart Subtypes + +#define BMP_STOCK_1 (RID_APP_START + 82) +#define BMP_STOCK_2 (RID_APP_START + 83) +#define BMP_STOCK_3 (RID_APP_START + 84) +#define BMP_STOCK_4 (RID_APP_START + 85) + +//---------------------- +// Column + Line Chart Subtypes + +#define BMP_COLUMN_LINE (RID_APP_START + 86) +#define BMP_COLUMN_LINE_STACKED (RID_APP_START + 87) + +//---------------------- +// Bubble Chart Subtypes +#define BMP_BUBBLE_1 (RID_APP_START + 88) + +//----------------------------------------------------------------------------- +//further Images: + +//SchStatisticTabPage and SchDataStatisticsDlg part 1 +#define BMP_INDICATE_BOTH_VERTI (RID_APP_START + 89) +#define BMP_INDICATE_UP (RID_APP_START + 90) +#define BMP_INDICATE_DOWN (RID_APP_START + 91) +#define BMP_INDICATE_BOTH_HORI (RID_APP_START + 97) +#define BMP_INDICATE_RIGHT (RID_APP_START + 98) +#define BMP_INDICATE_LEFT (RID_APP_START + 99) + +//SchStatisticTabPage and SchDataStatisticsDlg part 2 +#define BMP_REGRESSION_NONE (RID_APP_START + 92) +#define BMP_REGRESSION_LINEAR (RID_APP_START + 93) +#define BMP_REGRESSION_LOG (RID_APP_START + 94) +#define BMP_REGRESSION_EXP (RID_APP_START + 95) +#define BMP_REGRESSION_POWER (RID_APP_START + 96) + +// hide-button for range-choosing +#define IMG_SELECTRANGE (RID_APP_START + 100) + +// CHART_BITMAPS_HRC +#endif diff --git a/chart2/source/controller/dialogs/Bitmaps.src b/chart2/source/controller/dialogs/Bitmaps.src new file mode 100644 index 000000000000..67d8588897d8 --- /dev/null +++ b/chart2/source/controller/dialogs/Bitmaps.src @@ -0,0 +1,546 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Bitmaps.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Bitmaps.hrc" + +Image IMG_TYPE_COLUMN +{ + ImageBitmap = Bitmap { File = "typecolumn_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_BAR +{ + ImageBitmap = Bitmap { File = "typebar_16.png " ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_PIE +{ + ImageBitmap = Bitmap { File = "typepie_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_LINE +{ + ImageBitmap = Bitmap { File = "typepointline_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_XY +{ + ImageBitmap = Bitmap { File = "typexy_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_AREA +{ + ImageBitmap = Bitmap { File = "typearea_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_NET +{ + ImageBitmap = Bitmap { File = "typenet_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_STOCK +{ + ImageBitmap = Bitmap { File = "typestock_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_COLUMN_LINE +{ + ImageBitmap = Bitmap { File = "typecolumnline_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Image IMG_TYPE_BUBBLE +{ + ImageBitmap = Bitmap { File = "typebubble_16.png" ; }; + MaskColor = STD_MASKCOLOR; +}; +Bitmap BMP_BUBBLE_1 +{ + File = "bubble_52x60.png" ; +}; +Bitmap BMP_AREAS_2D +{ + File = "areas_52x60.png" ; +}; +Bitmap BMP_AREAS_2D_1 +{ + File = "areaspiled_52x60.png" ; +}; +Bitmap BMP_AREAS_2D_3 +{ + File = "areasfull_52x60.png" ; +}; +Bitmap BMP_AREAS_3D +{ + File = "areaspiled3d_52x60.png" ; +}; +Bitmap BMP_AREAS_3D_1 +{ + File = "areas3d_52x60.png" ; +}; +Bitmap BMP_AREAS_3D_2 +{ + File = "areasfull3d_52x60.png" ; +}; +//--------------------- +Bitmap BMP_BARS_2D_1 +{ + File = "bar_52x60.png" ; +}; +Bitmap BMP_BARS_2D_2 +{ + File = "barstack_52x60.png" ; +}; +Bitmap BMP_BARS_2D_3 +{ + File = "barpercent_52x60.png" ; +}; +Bitmap BMP_BARS_3D +{ + File = "bar3ddeep_52x60.png" ; +}; +Bitmap BMP_BARS_3D_1 +{ + File = "bar3d_52x60.png" ; +}; +Bitmap BMP_BARS_3D_2 +{ + File = "barstack3d_52x60.png" ; +}; +Bitmap BMP_BARS_3D_3 +{ + File = "barpercent3d_52x60.png" ; +}; +//--------------------- +Bitmap BMP_CIRCLES_2D +{ + File = "pie_52x60.png" ; +}; +Bitmap BMP_CIRCLES_2D_EXPLODED +{ + File = "pieexploded_52x60.png" ; +}; +Bitmap BMP_CIRCLES_3D +{ + File = "pie3d_52x60.png" ; +}; +Bitmap BMP_CIRCLES_3D_EXPLODED +{ + File = "pie3dexploded_52x60.png" ; +}; +//--------------------- +Bitmap BMP_DONUT_2D +{ + File = "donut_52x60.png" ; +}; +Bitmap BMP_DONUT_2D_EXPLODED +{ + File = "donutexploded_52x60.png" ; +}; +Bitmap BMP_DONUT_3D +{ + File = "donut3d_52x60.png" ; +}; +Bitmap BMP_DONUT_3D_EXPLODED +{ + File = "donut3dexploded_52x60.png" ; +}; +//--------------------- +Bitmap BMP_COLUMNS_2D_1 +{ + File = "columns_52x60.png" ; +}; +Bitmap BMP_COLUMNS_2D_2 +{ + File = "columnstack_52x60.png" ; +}; +Bitmap BMP_COLUMNS_2D_3 +{ + File = "columnpercent_52x60.png" ; +}; +Bitmap BMP_COLUMN_LINE +{ + File = "columnline_52x60.png" ; +}; +Bitmap BMP_COLUMN_LINE_STACKED +{ + File = "columnstackline_52x60.png" ; +}; +//--------------------- +Bitmap BMP_COLUMNS_3D +{ + File = "columns3ddeep_52x60.png" ; +}; +Bitmap BMP_COLUMNS_3D_1 +{ + File = "columns3d_52x60.png" ; +}; +Bitmap BMP_COLUMNS_3D_2 +{ + File = "columnstack3d_52x60.png" ; +}; +Bitmap BMP_COLUMNS_3D_3 +{ + File = "columnpercent3d_52x60.png" ; +}; +//--------------------- +Bitmap BMP_KEGELQ_3D_1 +{ + File = "conehori_52x60.png" ; +}; +Bitmap BMP_KEGELQ_3D_2 +{ + File = "conehoristack_52x60.png" ; +}; +Bitmap BMP_KEGELQ_3D_3 +{ + File = "conehoripercent_52x60.png" ; +}; +Bitmap BMP_KEGELQ_3D_4 +{ + File = "conehorideep_52x60.png" ; +}; +Bitmap BMP_KEGEL_3D_1 +{ + File = "cone_52x60.png" ; +}; +Bitmap BMP_KEGEL_3D_2 +{ + File = "conestack_52x60.png" ; +}; +Bitmap BMP_KEGEL_3D_3 +{ + File = "conepercent_52x60.png" ; +}; +Bitmap BMP_KEGEL_3D_4 +{ + File = "conedeep_52x60.png" ; +}; +//--------------------- +Bitmap BMP_POINTS_XVALUES +{ + File = "valueaxisdirectpoints_52x60.png" ; +}; +Bitmap BMP_POINTS_XCATEGORY +{ + File = "nostackdirectpoints_52x60.png" ; +}; +Bitmap BMP_POINTS_STACKED +{ + File = "stackdirectpoints_52x60.png" ; +}; +//--------------------- + +Bitmap BMP_LINE_P_XVALUES +{ + File = "valueaxisdirectboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_XVALUES +{ + File = "valueaxisdirectlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_XVALUES +{ + File = "valueaxisdirect3d_52x60.png" ; +}; + + +Bitmap BMP_LINE_P_XCATEGORY +{ + File = "nostackdirectboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_XCATEGORY +{ + File = "nostackdirectlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_XCATEGORY +{ + File = "nostackdirect3d_52x60.png" ; +}; + + +Bitmap BMP_LINE_P_STACKED +{ + File = "stackdirectboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_STACKED +{ + File = "stackdirectlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_STACKED +{ + File = "stackdirect3d_52x60.png" ; +}; + +//--------------------- +Bitmap BMP_LINE_P_XVALUES_SMOOTH +{ + File = "valueaxissmoothboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_XVALUES_SMOOTH +{ + File = "valueaxissmoothlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_XVALUES_SMOOTH +{ + File = "valueaxissmooth3d_52x60.png" ; +}; +Bitmap BMP_LINE_P_XCATEGORY_SMOOTH +{ + File = "nostacksmoothboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_XCATEGORY_SMOOTH +{ + File = "nostacksmoothlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_XCATEGORY_SMOOTH +{ + File = "nostacksmooth3d_52x60.png" ; +}; +Bitmap BMP_LINE_P_STACKED_SMOOTH +{ + File = "stacksmoothboth_52x60.png" ; +}; +Bitmap BMP_LINE_O_STACKED_SMOOTH +{ + File = "stacksmoothlines_52x60.png" ; +}; +Bitmap BMP_LINE3D_STACKED_SMOOTH +{ + File = "stacksmooth3d_52x60.png" ; +}; +//--------------------- +Bitmap BMP_NET +{ + File = "net_52x60.png" ; +}; +Bitmap BMP_NET_STACK +{ + File = "netstack_52x60.png" ; +}; +Bitmap BMP_NET_SYMB +{ + File = "netpoint_52x60.png" ; +}; +Bitmap BMP_NET_SYMB_STACK +{ + File = "netpointstack_52x60.png" ; +}; +Bitmap BMP_NET_LINESYMB +{ + File = "netlinepoint_52x60.png" ; +}; +Bitmap BMP_NET_LINESYMB_STACK +{ + File = "netlinepointstack_52x60.png" ; +}; +Bitmap BMP_NET_FILL +{ + File = "netfill_52x60.png" ; +}; +Bitmap BMP_NET_FILL_STACK +{ + File = "netstackfill_52x60.png" ; +}; +//--------------------- +Bitmap BMP_PYRAMIDQ_3D_1 +{ + File = "pyramindhori_52x60.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_2 +{ + File = "pyramindhoristack_52x60.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_3 +{ + File = "pyramindhoripercent_52x60.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_4 +{ + File = "pyramindhorideep_52x60.png" ; +}; +Bitmap BMP_PYRAMID_3D_1 +{ + File = "pyramind_52x60.png" ; +}; +Bitmap BMP_PYRAMID_3D_2 +{ + File = "pyramindstack_52x60.png" ; +}; +Bitmap BMP_PYRAMID_3D_3 +{ + File = "pyramindpercent_52x60.png" ; +}; +Bitmap BMP_PYRAMID_3D_4 +{ + File = "pyraminddeep_52x60.png" ; +}; +//--------------------- +Bitmap BMP_ROEHRE_3D_1 +{ + File = "cylinderhori_52x60.png" ; +}; +Bitmap BMP_ROEHRE_3D_2 +{ + File = "cylinderhoristack_52x60.png" ; +}; +Bitmap BMP_ROEHRE_3D_3 +{ + File = "cylinderhoriprocent_52x60.png" ; +}; +Bitmap BMP_ROEHRE_3D_4 +{ + File = "cylinderhorideep_52x60.png" ; +}; +//--------------------- +Bitmap BMP_SAEULE_3D_1 +{ + File = "cylinder_52x60.png" ; +}; +Bitmap BMP_SAEULE_3D_2 +{ + File = "cylinderstack_52x60.png" ; +}; +Bitmap BMP_SAEULE_3D_3 +{ + File = "cylinderpercent_52x60.png" ; +}; +Bitmap BMP_SAEULE_3D_4 +{ + File = "cylinderdeep_52x60.png" ; +}; +//--------------------- +Bitmap BMP_STOCK_1 +{ + File = "stock_52x60.png" ; +}; +Bitmap BMP_STOCK_2 +{ + File = "stockblock_52x60.png" ; +}; +Bitmap BMP_STOCK_3 +{ + File = "stockcolumns_52x60.png" ; +}; +Bitmap BMP_STOCK_4 +{ + File = "stockcolumnsattach_52x60.png" ; +}; +//--------------------- +//--------------------- +//--------------------- +//error indicator +Image BMP_INDICATE_BOTH_VERTI +{ + ImageBitmap = Bitmap + { + File = "errorbothverti_30.png" ; + }; +}; +Image BMP_INDICATE_DOWN +{ + ImageBitmap = Bitmap + { + File = "errordown_30.png" ; + }; +}; +Image BMP_INDICATE_UP +{ + ImageBitmap = Bitmap + { + File = "errorup_30.png" ; + }; +}; +Image BMP_INDICATE_BOTH_HORI +{ + ImageBitmap = Bitmap + { + File = "errorbothhori_30.png" ; + }; +}; +Image BMP_INDICATE_RIGHT +{ + ImageBitmap = Bitmap + { + File = "errorright_30.png" ; + }; +}; +Image BMP_INDICATE_LEFT +{ + ImageBitmap = Bitmap + { + File = "errorleft_30.png" ; + }; +}; + +//--------------------- +//regression curves +Image BMP_REGRESSION_NONE +{ + ImageBitmap = Bitmap + { + File = "regno.bmp" ; + }; +}; +Image BMP_REGRESSION_LINEAR +{ + ImageBitmap = Bitmap + { + File = "reglin.bmp" ; + }; +}; +Image BMP_REGRESSION_LOG +{ + ImageBitmap = Bitmap + { + File = "reglog.bmp" ; + }; +}; +Image BMP_REGRESSION_EXP +{ + ImageBitmap = Bitmap + { + File = "regexp.bmp" ; + }; +}; +Image BMP_REGRESSION_POWER +{ + ImageBitmap = Bitmap + { + File = "regpow.bmp" ; + }; +}; +//--------------------- +Image IMG_SELECTRANGE +{ + ImageBitmap = Bitmap + { + File = "selectrange.png"; + }; + MaskColor = STD_MASKCOLOR; +}; diff --git a/chart2/source/controller/dialogs/Bitmaps_HC.hrc b/chart2/source/controller/dialogs/Bitmaps_HC.hrc new file mode 100644 index 000000000000..8dd4acaffd15 --- /dev/null +++ b/chart2/source/controller/dialogs/Bitmaps_HC.hrc @@ -0,0 +1,216 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Bitmaps_HC.hrc,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _SOLAR_HRC +#include <svtools/solar.hrc> +#endif + +// RID_SCH_START is 30512 (see svtools/solar.hrc) + +// next free: 100 + +#ifndef SC_HC_MASKCOLOR +#define SC_HC_MASKCOLOR Color { Red = 0xFF00; Green = 0x0000; Blue = 0xFF00; } +#endif + +//----------------------------------------------------------------------------- +// chart types +// Images: + +#define IMG_TYPE_COLUMN_HC (RID_SCH_START + 1) +#define IMG_TYPE_BAR_HC (RID_SCH_START + 2) +#define IMG_TYPE_PIE_HC (RID_SCH_START + 3) +#define IMG_TYPE_AREA_HC (RID_SCH_START + 4) +#define IMG_TYPE_LINE_HC (RID_SCH_START + 5) +#define IMG_TYPE_XY_HC (RID_SCH_START + 6) +#define IMG_TYPE_BUBBLE_HC (RID_SCH_START + 7) +#define IMG_TYPE_NET_HC (RID_SCH_START + 8) +#define IMG_TYPE_STOCK_HC (RID_SCH_START + 9) +#define IMG_TYPE_COLUMN_LINE_HC (RID_SCH_START + 10) + +//----------------------------------------------------------------------------- +//Chart Subtypes +// Bitmaps: + +//---------------------- +// Column Chart Subtypes +#define BMP_COLUMNS_2D_1_HC (RID_SCH_START + 1) +#define BMP_COLUMNS_2D_2_HC (RID_SCH_START + 2) +#define BMP_COLUMNS_2D_3_HC (RID_SCH_START + 3) + +#define BMP_COLUMNS_3D_HC (RID_SCH_START + 4) +#define BMP_COLUMNS_3D_1_HC (RID_SCH_START + 5) +#define BMP_COLUMNS_3D_2_HC (RID_SCH_START + 6) +#define BMP_COLUMNS_3D_3_HC (RID_SCH_START + 7) + +#define BMP_SAEULE_3D_1_HC (RID_SCH_START + 8) +#define BMP_SAEULE_3D_2_HC (RID_SCH_START + 9) +#define BMP_SAEULE_3D_3_HC (RID_SCH_START + 10) +#define BMP_SAEULE_3D_4_HC (RID_SCH_START + 11) + +#define BMP_KEGEL_3D_1_HC (RID_SCH_START + 12) +#define BMP_KEGEL_3D_2_HC (RID_SCH_START + 13) +#define BMP_KEGEL_3D_3_HC (RID_SCH_START + 14) +#define BMP_KEGEL_3D_4_HC (RID_SCH_START + 15) + +#define BMP_PYRAMID_3D_1_HC (RID_SCH_START + 16) +#define BMP_PYRAMID_3D_2_HC (RID_SCH_START + 17) +#define BMP_PYRAMID_3D_3_HC (RID_SCH_START + 18) +#define BMP_PYRAMID_3D_4_HC (RID_SCH_START + 19) + +//---------------------- +// Bar Chart Subtypes + +#define BMP_BARS_2D_1_HC (RID_SCH_START + 20) +#define BMP_BARS_2D_2_HC (RID_SCH_START + 21) +#define BMP_BARS_2D_3_HC (RID_SCH_START + 22) + +#define BMP_BARS_3D_HC (RID_SCH_START + 23) +#define BMP_BARS_3D_1_HC (RID_SCH_START + 24) +#define BMP_BARS_3D_2_HC (RID_SCH_START + 25) +#define BMP_BARS_3D_3_HC (RID_SCH_START + 26) + +#define BMP_ROEHRE_3D_1_HC (RID_SCH_START + 27) +#define BMP_ROEHRE_3D_2_HC (RID_SCH_START + 28) +#define BMP_ROEHRE_3D_3_HC (RID_SCH_START + 29) +#define BMP_ROEHRE_3D_4_HC (RID_SCH_START + 30) + +#define BMP_KEGELQ_3D_1_HC (RID_SCH_START + 31) +#define BMP_KEGELQ_3D_2_HC (RID_SCH_START + 32) +#define BMP_KEGELQ_3D_3_HC (RID_SCH_START + 33) +#define BMP_KEGELQ_3D_4_HC (RID_SCH_START + 34) + +#define BMP_PYRAMIDQ_3D_1_HC (RID_SCH_START + 35) +#define BMP_PYRAMIDQ_3D_2_HC (RID_SCH_START + 36) +#define BMP_PYRAMIDQ_3D_3_HC (RID_SCH_START + 37) +#define BMP_PYRAMIDQ_3D_4_HC (RID_SCH_START + 38) + +//---------------------- +// Pie and Donut Chart Subtypes + +#define BMP_CIRCLES_2D_HC (RID_SCH_START + 39) +#define BMP_CIRCLES_2D_EXPLODED_HC (RID_SCH_START + 40) +#define BMP_CIRCLES_3D_HC (RID_SCH_START + 41) +#define BMP_CIRCLES_3D_EXPLODED_HC (RID_SCH_START + 42) +#define BMP_DONUT_2D_HC (RID_SCH_START + 43) +#define BMP_DONUT_2D_EXPLODED_HC (RID_SCH_START + 44) +#define BMP_DONUT_3D_HC (RID_SCH_START + 45) +#define BMP_DONUT_3D_EXPLODED_HC (RID_SCH_START + 46) + +//---------------------- +// Points and Lines Chart Subtypes + +#define BMP_POINTS_XVALUES_HC (RID_SCH_START + 47) +#define BMP_POINTS_XCATEGORY_HC (RID_SCH_START + 48) +#define BMP_POINTS_STACKED_HC (RID_SCH_START + 49) + +#define BMP_LINE_P_XVALUES_HC (RID_SCH_START + 50) +#define BMP_LINE_O_XVALUES_HC (RID_SCH_START + 51) +#define BMP_LINE3D_XVALUES_HC (RID_SCH_START + 52) + +#define BMP_LINE_P_XCATEGORY_HC (RID_SCH_START + 53) +#define BMP_LINE_O_XCATEGORY_HC (RID_SCH_START + 54) +#define BMP_LINE3D_XCATEGORY_HC (RID_SCH_START + 55) + +#define BMP_LINE_P_STACKED_HC (RID_SCH_START + 56) +#define BMP_LINE_O_STACKED_HC (RID_SCH_START + 57) +#define BMP_LINE3D_STACKED_HC (RID_SCH_START + 58) + +#define BMP_LINE_P_XVALUES_SMOOTH_HC (RID_SCH_START + 59) +#define BMP_LINE_O_XVALUES_SMOOTH_HC (RID_SCH_START + 60) +#define BMP_LINE3D_XVALUES_SMOOTH_HC (RID_SCH_START + 61) + +#define BMP_LINE_P_XCATEGORY_SMOOTH_HC (RID_SCH_START + 62) +#define BMP_LINE_O_XCATEGORY_SMOOTH_HC (RID_SCH_START + 63) +#define BMP_LINE3D_XCATEGORY_SMOOTH_HC (RID_SCH_START + 64) + +#define BMP_LINE_P_STACKED_SMOOTH_HC (RID_SCH_START + 65) +#define BMP_LINE_O_STACKED_SMOOTH_HC (RID_SCH_START + 66) +#define BMP_LINE3D_STACKED_SMOOTH_HC (RID_SCH_START + 67) + +//---------------------- +// Area Chart Subtypes + +#define BMP_AREAS_2D_HC (RID_SCH_START + 68) +#define BMP_AREAS_2D_1_HC (RID_SCH_START + 69) +#define BMP_AREAS_2D_3_HC (RID_SCH_START + 70) +#define BMP_AREAS_3D_HC (RID_SCH_START + 71) +#define BMP_AREAS_3D_1_HC (RID_SCH_START + 72) +#define BMP_AREAS_3D_2_HC (RID_SCH_START + 73) + +//---------------------- +// Net Chart Subtypes + +#define BMP_NET_HC (RID_SCH_START + 74) +#define BMP_NET_STACK_HC (RID_SCH_START + 75) +#define BMP_NET_SYMB_HC (RID_SCH_START + 76) +#define BMP_NET_SYMB_STACK_HC (RID_SCH_START + 77) +#define BMP_NET_LINESYMB_HC (RID_SCH_START + 78) +#define BMP_NET_LINESYMB_STACK_HC (RID_SCH_START + 79) +#define BMP_NET_FILL_HC (RID_SCH_START + 80) +#define BMP_NET_FILL_STACK_HC (RID_SCH_START + 81) + +//---------------------- +// Stock Chart Subtypes + +#define BMP_STOCK_1_HC (RID_SCH_START + 82) +#define BMP_STOCK_2_HC (RID_SCH_START + 83) +#define BMP_STOCK_3_HC (RID_SCH_START + 84) +#define BMP_STOCK_4_HC (RID_SCH_START + 85) + +//---------------------- +// Column + Line Chart Subtypes + +#define BMP_COLUMN_LINE_HC (RID_SCH_START + 86) +#define BMP_COLUMN_LINE_STACKED_HC (RID_SCH_START + 87) + +//---------------------- +// Bubble Chart Subtypes +#define BMP_BUBBLE_1_HC (RID_SCH_START + 88) + +//----------------------------------------------------------------------------- +//further Images: + +//SchStatisticTabPage and SchDataStatisticsDlg part 1 +#define BMP_INDICATE_BOTH_VERTI_HC (RID_SCH_START + 89) +#define BMP_INDICATE_UP_HC (RID_SCH_START + 90) +#define BMP_INDICATE_DOWN_HC (RID_SCH_START + 91) +#define BMP_INDICATE_BOTH_HORI_HC (RID_SCH_START + 97) +#define BMP_INDICATE_RIGHT_HC (RID_SCH_START + 98) +#define BMP_INDICATE_LEFT_HC (RID_SCH_START + 99) + +//SchStatisticTabPage and SchDataStatisticsDlg part 2 +#define BMP_REGRESSION_NONE_HC (RID_SCH_START + 92) +#define BMP_REGRESSION_LINEAR_HC (RID_SCH_START + 93) +#define BMP_REGRESSION_LOG_HC (RID_SCH_START + 94) +#define BMP_REGRESSION_EXP_HC (RID_SCH_START + 95) +#define BMP_REGRESSION_POWER_HC (RID_SCH_START + 96) + +// hide-button for range-choosing +#define IMG_SELECTRANGE_HC (RID_SCH_START + 100) diff --git a/chart2/source/controller/dialogs/Bitmaps_HC.src b/chart2/source/controller/dialogs/Bitmaps_HC.src new file mode 100644 index 000000000000..a82893273ae2 --- /dev/null +++ b/chart2/source/controller/dialogs/Bitmaps_HC.src @@ -0,0 +1,546 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Bitmaps_HC.src,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Bitmaps_HC.hrc" + +Image IMG_TYPE_COLUMN_HC +{ + ImageBitmap = Bitmap { File = "typecolumn_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_BAR_HC +{ + ImageBitmap = Bitmap { File = "typebar_16.png " ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_PIE_HC +{ + ImageBitmap = Bitmap { File = "typepie_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_LINE_HC +{ + ImageBitmap = Bitmap { File = "typepointline_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_XY_HC +{ + ImageBitmap = Bitmap { File = "typexy_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_AREA_HC +{ + ImageBitmap = Bitmap { File = "typearea_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_NET_HC +{ + ImageBitmap = Bitmap { File = "typenet_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_STOCK_HC +{ + ImageBitmap = Bitmap { File = "typestock_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_COLUMN_LINE_HC +{ + ImageBitmap = Bitmap { File = "typecolumnline_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Image IMG_TYPE_BUBBLE_HC +{ + ImageBitmap = Bitmap { File = "typebubble_16.png" ; }; + MaskColor = SC_HC_MASKCOLOR; +}; +Bitmap BMP_BUBBLE_1_HC +{ + File = "bubble_52x60_h.png" ; +}; +Bitmap BMP_AREAS_2D_HC +{ + File = "areas_52x60_h.png" ; +}; +Bitmap BMP_AREAS_2D_1_HC +{ + File = "areaspiled_52x60_h.png" ; +}; +Bitmap BMP_AREAS_2D_3_HC +{ + File = "areasfull_52x60_h.png" ; +}; +Bitmap BMP_AREAS_3D_HC +{ + File = "areaspiled3d_52x60_h.png" ; +}; +Bitmap BMP_AREAS_3D_1_HC +{ + File = "areas3d_52x60_h.png" ; +}; +Bitmap BMP_AREAS_3D_2_HC +{ + File = "areasfull3d_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_BARS_2D_1_HC +{ + File = "bar_52x60_h.png" ; +}; +Bitmap BMP_BARS_2D_2_HC +{ + File = "barstack_52x60_h.png" ; +}; +Bitmap BMP_BARS_2D_3_HC +{ + File = "barpercent_52x60_h.png" ; +}; +Bitmap BMP_BARS_3D_HC +{ + File = "bar3ddeep_52x60_h.png" ; +}; +Bitmap BMP_BARS_3D_1_HC +{ + File = "bar3d_52x60_h.png" ; +}; +Bitmap BMP_BARS_3D_2_HC +{ + File = "barstack3d_52x60_h.png" ; +}; +Bitmap BMP_BARS_3D_3_HC +{ + File = "barpercent3d_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_CIRCLES_2D_HC +{ + File = "pie_52x60_h.png" ; +}; +Bitmap BMP_CIRCLES_2D_EXPLODED_HC +{ + File = "pieexploded_52x60_h.png" ; +}; +Bitmap BMP_CIRCLES_3D_HC +{ + File = "pie3d_52x60_h.png" ; +}; +Bitmap BMP_CIRCLES_3D_EXPLODED_HC +{ + File = "pie3dexploded_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_DONUT_2D_HC +{ + File = "donut_52x60_h.png" ; +}; +Bitmap BMP_DONUT_2D_EXPLODED_HC +{ + File = "donutexploded_52x60_h.png" ; +}; +Bitmap BMP_DONUT_3D_HC +{ + File = "donut3d_52x60_h.png" ; +}; +Bitmap BMP_DONUT_3D_EXPLODED_HC +{ + File = "donut3dexploded_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_COLUMNS_2D_1_HC +{ + File = "columns_52x60_h.png" ; +}; +Bitmap BMP_COLUMNS_2D_2_HC +{ + File = "columnstack_52x60_h.png" ; +}; +Bitmap BMP_COLUMNS_2D_3_HC +{ + File = "columnpercent_52x60_h.png" ; +}; +Bitmap BMP_COLUMN_LINE_HC +{ + File = "columnline_52x60_h.png" ; +}; +Bitmap BMP_COLUMN_LINE_STACKED_HC +{ + File = "columnstackline_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_COLUMNS_3D_HC +{ + File = "columns3ddeep_52x60_h.png" ; +}; +Bitmap BMP_COLUMNS_3D_1_HC +{ + File = "columns3d_52x60_h.png" ; +}; +Bitmap BMP_COLUMNS_3D_2_HC +{ + File = "columnstack3d_52x60_h.png" ; +}; +Bitmap BMP_COLUMNS_3D_3_HC +{ + File = "columnpercent3d_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_KEGELQ_3D_1_HC +{ + File = "conehori_52x60_h.png" ; +}; +Bitmap BMP_KEGELQ_3D_2_HC +{ + File = "conehoristack_52x60_h.png" ; +}; +Bitmap BMP_KEGELQ_3D_3_HC +{ + File = "conehoripercent_52x60_h.png" ; +}; +Bitmap BMP_KEGELQ_3D_4_HC +{ + File = "conehorideep_52x60_h.png" ; +}; +Bitmap BMP_KEGEL_3D_1_HC +{ + File = "cone_52x60_h.png" ; +}; +Bitmap BMP_KEGEL_3D_2_HC +{ + File = "conestack_52x60_h.png" ; +}; +Bitmap BMP_KEGEL_3D_3_HC +{ + File = "conepercent_52x60_h.png" ; +}; +Bitmap BMP_KEGEL_3D_4_HC +{ + File = "conedeep_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_POINTS_XVALUES_HC +{ + File = "valueaxisdirectpoints_52x60_h.png" ; +}; +Bitmap BMP_POINTS_XCATEGORY_HC +{ + File = "nostackdirectpoints_52x60_h.png" ; +}; +Bitmap BMP_POINTS_STACKED_HC +{ + File = "stackdirectpoints_52x60_h.png" ; +}; +//--------------------- + +Bitmap BMP_LINE_P_XVALUES_HC +{ + File = "valueaxisdirectboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_XVALUES_HC +{ + File = "valueaxisdirectlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_XVALUES_HC +{ + File = "valueaxisdirect3d_52x60_h.png" ; +}; + + +Bitmap BMP_LINE_P_XCATEGORY_HC +{ + File = "nostackdirectboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_XCATEGORY_HC +{ + File = "nostackdirectlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_XCATEGORY_HC +{ + File = "nostackdirect3d_52x60_h.png" ; +}; + + +Bitmap BMP_LINE_P_STACKED_HC +{ + File = "stackdirectboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_STACKED_HC +{ + File = "stackdirectlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_STACKED_HC +{ + File = "stackdirect3d_52x60_h.png" ; +}; + +//--------------------- +Bitmap BMP_LINE_P_XVALUES_SMOOTH_HC +{ + File = "valueaxissmoothboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_XVALUES_SMOOTH_HC +{ + File = "valueaxissmoothlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_XVALUES_SMOOTH_HC +{ + File = "valueaxissmooth3d_52x60_h.png" ; +}; +Bitmap BMP_LINE_P_XCATEGORY_SMOOTH_HC +{ + File = "nostacksmoothboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_XCATEGORY_SMOOTH_HC +{ + File = "nostacksmoothlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_XCATEGORY_SMOOTH_HC +{ + File = "nostacksmooth3d_52x60_h.png" ; +}; +Bitmap BMP_LINE_P_STACKED_SMOOTH_HC +{ + File = "stacksmoothboth_52x60_h.png" ; +}; +Bitmap BMP_LINE_O_STACKED_SMOOTH_HC +{ + File = "stacksmoothlines_52x60_h.png" ; +}; +Bitmap BMP_LINE3D_STACKED_SMOOTH_HC +{ + File = "stacksmooth3d_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_NET_HC +{ + File = "net_52x60_h.png" ; +}; +Bitmap BMP_NET_STACK_HC +{ + File = "netstack_52x60_h.png" ; +}; +Bitmap BMP_NET_SYMB_HC +{ + File = "netpoint_52x60_h.png" ; +}; +Bitmap BMP_NET_SYMB_STACK_HC +{ + File = "netpointstack_52x60_h.png" ; +}; +Bitmap BMP_NET_LINESYMB_HC +{ + File = "netlinepoint_52x60_h.png" ; +}; +Bitmap BMP_NET_LINESYMB_STACK_HC +{ + File = "netlinepointstack_52x60_h.png" ; +}; +Bitmap BMP_NET_FILL_HC +{ + File = "netfill_52x60_h.png" ; +}; +Bitmap BMP_NET_FILL_STACK_HC +{ + File = "netstackfill_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_PYRAMIDQ_3D_1_HC +{ + File = "pyramindhori_52x60_h.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_2_HC +{ + File = "pyramindhoristack_52x60_h.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_3_HC +{ + File = "pyramindhoripercent_52x60_h.png" ; +}; +Bitmap BMP_PYRAMIDQ_3D_4_HC +{ + File = "pyramindhorideep_52x60_h.png" ; +}; +Bitmap BMP_PYRAMID_3D_1_HC +{ + File = "pyramind_52x60_h.png" ; +}; +Bitmap BMP_PYRAMID_3D_2_HC +{ + File = "pyramindstack_52x60_h.png" ; +}; +Bitmap BMP_PYRAMID_3D_3_HC +{ + File = "pyramindpercent_52x60_h.png" ; +}; +Bitmap BMP_PYRAMID_3D_4_HC +{ + File = "pyraminddeep_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_ROEHRE_3D_1_HC +{ + File = "cylinderhori_52x60_h.png" ; +}; +Bitmap BMP_ROEHRE_3D_2_HC +{ + File = "cylinderhoristack_52x60_h.png" ; +}; +Bitmap BMP_ROEHRE_3D_3_HC +{ + File = "cylinderhoriprocent_52x60_h.png" ; +}; +Bitmap BMP_ROEHRE_3D_4_HC +{ + File = "cylinderhorideep_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_SAEULE_3D_1_HC +{ + File = "cylinder_52x60_h.png" ; +}; +Bitmap BMP_SAEULE_3D_2_HC +{ + File = "cylinderstack_52x60_h.png" ; +}; +Bitmap BMP_SAEULE_3D_3_HC +{ + File = "cylinderpercent_52x60_h.png" ; +}; +Bitmap BMP_SAEULE_3D_4_HC +{ + File = "cylinderdeep_52x60_h.png" ; +}; +//--------------------- +Bitmap BMP_STOCK_1_HC +{ + File = "stock_52x60_h.png" ; +}; +Bitmap BMP_STOCK_2_HC +{ + File = "stockblock_52x60_h.png" ; +}; +Bitmap BMP_STOCK_3_HC +{ + File = "stockcolumns_52x60_h.png" ; +}; +Bitmap BMP_STOCK_4_HC +{ + File = "stockcolumnsattach_52x60_h.png" ; +}; +//--------------------- +//--------------------- +//--------------------- +//error indicator +Image BMP_INDICATE_BOTH_VERTI_HC +{ + ImageBitmap = Bitmap + { + File = "errorbothverti_30_h.png" ; + }; +}; +Image BMP_INDICATE_DOWN_HC +{ + ImageBitmap = Bitmap + { + File = "errordown_30_h.png" ; + }; +}; +Image BMP_INDICATE_UP_HC +{ + ImageBitmap = Bitmap + { + File = "errorup_30_h.png" ; + }; +}; +Image BMP_INDICATE_BOTH_HORI_HC +{ + ImageBitmap = Bitmap + { + File = "errorbothhori_30_h.png" ; + }; +}; +Image BMP_INDICATE_RIGHT_HC +{ + ImageBitmap = Bitmap + { + File = "errorright_30_h.png" ; + }; +}; +Image BMP_INDICATE_LEFT_HC +{ + ImageBitmap = Bitmap + { + File = "errorleft_30_h.png" ; + }; +}; + +//--------------------- +//regression curves +Image BMP_REGRESSION_NONE_HC +{ + ImageBitmap = Bitmap + { + File = "regno_h.bmp" ; + }; +}; +Image BMP_REGRESSION_LINEAR_HC +{ + ImageBitmap = Bitmap + { + File = "reglin_h.bmp" ; + }; +}; +Image BMP_REGRESSION_LOG_HC +{ + ImageBitmap = Bitmap + { + File = "reglog_h.bmp" ; + }; +}; +Image BMP_REGRESSION_EXP_HC +{ + ImageBitmap = Bitmap + { + File = "regexp_h.bmp" ; + }; +}; +Image BMP_REGRESSION_POWER_HC +{ + ImageBitmap = Bitmap + { + File = "regpow_h.bmp" ; + }; +}; +//--------------------- +Image IMG_SELECTRANGE_HC +{ + ImageBitmap = Bitmap + { + File = "selectrange.png"; + }; + MaskColor = SC_HC_MASKCOLOR; +}; diff --git a/chart2/source/controller/dialogs/ChangingResource.cxx b/chart2/source/controller/dialogs/ChangingResource.cxx new file mode 100644 index 000000000000..a668cc1b41b8 --- /dev/null +++ b/chart2/source/controller/dialogs/ChangingResource.cxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChangingResource.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChangingResource.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +ChangingResource::ChangingResource() + : m_pChangeListener(0) +{ +} +ChangingResource::~ChangingResource() +{ +} +void ChangingResource::setChangeListener( ResourceChangeListener* pListener ) +{ + m_pChangeListener = pListener; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/ChangingResource.hxx b/chart2/source/controller/dialogs/ChangingResource.hxx new file mode 100644 index 000000000000..24b24a5095ad --- /dev/null +++ b/chart2/source/controller/dialogs/ChangingResource.hxx @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChangingResource.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CHANGINGRESOURCE_HXX +#define _CHART2_CHANGINGRESOURCE_HXX + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class ChangingResource; +class ResourceChangeListener +{ +public: + virtual void stateChanged( ChangingResource* pResource ) = 0; +}; + +class ChangingResource +{ +public: + ChangingResource(); + virtual ~ChangingResource(); + + virtual void setChangeListener( ResourceChangeListener* pListener ); + +protected: + ResourceChangeListener* m_pChangeListener; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.cxx b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx new file mode 100644 index 000000000000..fa51d17a03d8 --- /dev/null +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.cxx @@ -0,0 +1,1288 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartTypeDialogController.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartTypeDialogController.hxx" +#include "ResId.hxx" +#include "HelpIds.hrc" +#include "Strings.hrc" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "AxisHelper.hxx" + +#include <com/sun/star/chart2/DataPointGeometry3D.hpp> +#include <com/sun/star/chart2/PieChartOffsetMode.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif +// header for class Image +#include <vcl/image.hxx> +// header for class Bitmap +#include <vcl/bitmap.hxx> +#include <vcl/svapp.hxx> + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +// macro for selecting a normal or high contrast bitmap the stack variable +// bIsHighContrast must exist and reflect the correct state +#define SELECT_BITMAP(name) Bitmap( SchResId( bIsHighContrast ? name ## _HC : name )) +#define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name )) + +/* + ( C2U( "com.sun.star.chart2.template.Surface" ), CHSTYLE_3D_SURFACE) + ( C2U( "com.sun.star.chart2.template.Addin" ), CHSTYLE_ADDIN) +*/ + +ChartTypeParameter::ChartTypeParameter() + : nSubTypeIndex( 1 ) + , bXAxisWithValues( false ) + , b3DLook( false ) + , bSymbols( true ) + , bLines( true ) + , eStackMode( GlobalStackMode_NONE ) + , eCurveStyle( CurveStyle_LINES ) + , nCurveResolution(20) + , nSplineOrder(3) + , nGeometry3D(DataPointGeometry3D::CUBOID) + , eThreeDLookScheme(ThreeDLookScheme_Realistic) + , bSortByXValues(sal_False) +{ +} + +ChartTypeParameter::ChartTypeParameter( sal_Int32 SubTypeIndex, bool HasXAxisWithValues + , bool Is3DLook, GlobalStackMode nStackMode + , bool HasSymbols, bool HasLines + , CurveStyle nCurveStyle ) + : nSubTypeIndex( SubTypeIndex ) + , bXAxisWithValues( HasXAxisWithValues ) + , b3DLook( Is3DLook ) + , bSymbols( HasSymbols ) + , bLines( HasLines ) + , eStackMode( nStackMode ) + , eCurveStyle( nCurveStyle ) + , nCurveResolution(20) + , nSplineOrder(3) + , nGeometry3D(DataPointGeometry3D::CUBOID) + , eThreeDLookScheme(ThreeDLookScheme_Realistic) + , bSortByXValues(sal_False) +{ +} +ChartTypeParameter::~ChartTypeParameter() +{ +} + +bool ChartTypeParameter::mapsToSameService( const ChartTypeParameter& rParameter ) const +{ + return this->mapsToSimilarService( rParameter, 0 ); +} +bool ChartTypeParameter::mapsToSimilarService( const ChartTypeParameter& rParameter, sal_Int32 nTheHigherTheLess ) const +{ + sal_Int32 nMax=7; + if(nTheHigherTheLess>nMax) + return true; + if( this->bXAxisWithValues!=rParameter.bXAxisWithValues ) + return nTheHigherTheLess>nMax-1; + if( this->b3DLook!=rParameter.b3DLook ) + return nTheHigherTheLess>nMax-2; + if( this->eStackMode!=rParameter.eStackMode ) + return nTheHigherTheLess>nMax-3; + if( this->nSubTypeIndex!=rParameter.nSubTypeIndex ) + return nTheHigherTheLess>nMax-4; + if( this->bSymbols!=rParameter.bSymbols ) + return nTheHigherTheLess>nMax-5; + if( this->bLines!=rParameter.bLines ) + return nTheHigherTheLess>nMax-6; + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +ChartTypeDialogController::ChartTypeDialogController() + : bSupportsXAxisWithValues(false) + , bSupports3D(true) +{ +} + +ChartTypeDialogController::~ChartTypeDialogController() +{ +} +Image ChartTypeDialogController::getImage( bool /*bIsHighContrast*/ ) +{ + return Image(); +} +bool ChartTypeDialogController::isSubType( const rtl::OUString& rServiceName ) +{ + const tTemplateServiceChartTypeParameterMap& rTemplateMap = this->getTemplateMap(); + tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName )); + if( aIt != rTemplateMap.end()) + return true; + return false; +} +ChartTypeParameter ChartTypeDialogController::getChartTypeParameterForService( + const rtl::OUString& rServiceName + , const uno::Reference< beans::XPropertySet >& xTemplateProps ) +{ + ChartTypeParameter aRet; + const tTemplateServiceChartTypeParameterMap& rTemplateMap = this->getTemplateMap(); + tTemplateServiceChartTypeParameterMap::const_iterator aIt( rTemplateMap.find( rServiceName )); + if( aIt != rTemplateMap.end()) + aRet = (*aIt).second; + if( xTemplateProps.is() ) + { + try + { + xTemplateProps->getPropertyValue( C2U( "CurveStyle" )) >>= aRet.eCurveStyle; + xTemplateProps->getPropertyValue( C2U( "CurveResolution" )) >>= aRet.nCurveResolution; + xTemplateProps->getPropertyValue( C2U( "SplineOrder" )) >>= aRet.nSplineOrder; + } + catch( uno::Exception & ex ) + { + //not all templates need to support CurveStyle, CurveResolution or SplineOrder + ex.Context.is();//to have debug information without compilation warnings + } + + try + { + xTemplateProps->getPropertyValue( C2U( "Geometry3D" )) >>= aRet.nGeometry3D; + } + catch( uno::Exception& ex ) + { + //not all templates need to support CGeometry3D + ex.Context.is();//to have debug information without compilation warnings + } + } + return aRet; +} +void ChartTypeDialogController::adjustSubTypeAndEnableControls( ChartTypeParameter& /*rParameter*/ ) +{ +} +void ChartTypeDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.eStackMode=GlobalStackMode_STACK_Y; + break; + case 3: + rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT; + break; + case 4: + rParameter.eStackMode=GlobalStackMode_STACK_Z; + break; + default: + rParameter.eStackMode=GlobalStackMode_NONE; + break; + } +} +void ChartTypeDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter ) +{ + bool bFoundSomeMatch=false; + + rParameter.bXAxisWithValues = bSupportsXAxisWithValues; + if( rParameter.b3DLook && !bSupports3D ) + rParameter.b3DLook = false; + if(!rParameter.b3DLook && rParameter.eStackMode==GlobalStackMode_STACK_Z) + rParameter.eStackMode = GlobalStackMode_NONE; + + const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap(); + tTemplateServiceChartTypeParameterMap::const_iterator aIter = rMap.begin(); + const tTemplateServiceChartTypeParameterMap::const_iterator aEnd = rMap.end(); + for( sal_Int32 nMatchPrecision=0; nMatchPrecision<7 && !bFoundSomeMatch; nMatchPrecision++ ) + { + for( aIter = rMap.begin(); aIter != aEnd; aIter++ ) + { + if( rParameter.mapsToSimilarService( (*aIter).second, nMatchPrecision ) ) + { + //remind some values + ThreeDLookScheme aScheme = rParameter.eThreeDLookScheme; + sal_Int32 nCurveResolution = rParameter.nCurveResolution; + sal_Int32 nSplineOrder = rParameter.nSplineOrder; + CurveStyle eCurveStyle = rParameter.eCurveStyle; + sal_Int32 nGeometry3D = rParameter.nGeometry3D; + sal_Bool bSortByXValues = rParameter.bSortByXValues; + + rParameter = (*aIter).second; + + //some values should not be changed with charttype + rParameter.eThreeDLookScheme = aScheme; + rParameter.nCurveResolution = nCurveResolution; + rParameter.nSplineOrder =nSplineOrder; + rParameter.eCurveStyle = eCurveStyle; + rParameter.nGeometry3D = nGeometry3D; + rParameter.bSortByXValues = bSortByXValues; + + bFoundSomeMatch = true; + break; + } + } + } + if(!bFoundSomeMatch) + { + if(rMap.begin()!=rMap.end()) + rParameter = (*rMap.begin()).second; + else + rParameter = ChartTypeParameter(); + } +} +rtl::OUString ChartTypeDialogController::getServiceNameForParameter( const ChartTypeParameter& rParameter ) const +{ + ChartTypeParameter aParameter(rParameter); + if( aParameter.bXAxisWithValues ) + aParameter.eStackMode = GlobalStackMode_NONE; + if(!aParameter.b3DLook && aParameter.eStackMode==GlobalStackMode_STACK_Z) + aParameter.eStackMode = GlobalStackMode_NONE; + const tTemplateServiceChartTypeParameterMap& rMap = getTemplateMap(); + tTemplateServiceChartTypeParameterMap::const_iterator aIter = rMap.begin(); + const tTemplateServiceChartTypeParameterMap::const_iterator aEnd = rMap.end(); + for( ; aIter != aEnd; aIter++ ) + { + if( aParameter.mapsToSameService( (*aIter).second ) ) + return (*aIter).first; + } + + OSL_ENSURE( false, "ChartType not implemented yet - use fallback to similar type" ); + for( sal_Int32 nMatchPrecision=1; nMatchPrecision<8; nMatchPrecision++ ) + { + for( aIter = rMap.begin(); aIter != aEnd; aIter++ ) + { + if( aParameter.mapsToSimilarService( (*aIter).second, nMatchPrecision ) ) + return (*aIter).first; + } + } + return ::rtl::OUString(); +} +uno::Reference< XChartTypeTemplate > ChartTypeDialogController::getCurrentTemplate( + const ChartTypeParameter& rParameter + , const uno::Reference< lang::XMultiServiceFactory >& xTemplateManager ) const +{ + uno::Reference< XChartTypeTemplate > xTemplate(0); + + rtl::OUString aServiceName( this->getServiceNameForParameter( rParameter ) ); + if(aServiceName.getLength()) + { + xTemplate.set( xTemplateManager->createInstance( aServiceName ), uno::UNO_QUERY ); + if(xTemplate.is()) + { + uno::Reference< beans::XPropertySet > xTemplateProps( xTemplate, uno::UNO_QUERY ); + if(xTemplateProps.is()) + { + try + { + xTemplateProps->setPropertyValue( C2U( "CurveStyle" ), uno::makeAny(rParameter.eCurveStyle) ); + xTemplateProps->setPropertyValue( C2U( "CurveResolution" ), uno::makeAny(rParameter.nCurveResolution) ); + xTemplateProps->setPropertyValue( C2U( "SplineOrder" ), uno::makeAny(rParameter.nSplineOrder) ); + } + catch( uno::Exception & ex ) + { + //not all templates need to support CurveStyle, CurveResolution or SplineOrder + ex.Context.is();//to have debug information without compilation warnings + } + try + { + xTemplateProps->setPropertyValue( C2U( "Geometry3D" ), uno::makeAny(rParameter.nGeometry3D) ); + } + catch( uno::Exception & ex ) + { + //not all templates need to support Geometry3D + ex.Context.is();//to have debug information without compilation warnings + } + try + { + this->setTemplateProperties( xTemplateProps ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + return xTemplate; +} + +bool ChartTypeDialogController::commitToModel( const ChartTypeParameter& rParameter + , const uno::Reference< XChartDocument >& xChartModel ) +{ + uno::Reference< lang::XMultiServiceFactory > xTemplateManager( xChartModel->getChartTypeManager(), uno::UNO_QUERY ); + uno::Reference< XChartTypeTemplate > xTemplate( this->getCurrentTemplate( rParameter, xTemplateManager ) ); + if(xTemplate.is()) + { + uno::Reference< frame::XModel > xModel( xChartModel, uno::UNO_QUERY); + + // /-- locked controllers + ControllerLockGuard aCtrlLockGuard( xModel ); + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + DiagramHelper::tTemplateWithServiceName aTemplateWithService( + DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager )); + if( aTemplateWithService.first.is()) + aTemplateWithService.first->resetStyles( xDiagram ); + xTemplate->changeDiagram( xDiagram ); + if( Application::GetSettings().GetLayoutRTL() ) + AxisHelper::setRTLAxisLayout( AxisHelper::getCoordinateSystemByIndex( xDiagram, 0 ) ); + if( rParameter.b3DLook ) + ThreeDHelper::setScheme( xDiagram, rParameter.eThreeDLookScheme ); + + //SortByXValues + { + uno::Reference< beans::XPropertySet > xDiaProp( xDiagram, uno::UNO_QUERY ); + if( xDiaProp.is() ) + xDiaProp->setPropertyValue( C2U( "SortByXValues" ), uno::makeAny( rParameter.bSortByXValues ) ); + } + // \-- locked controllers + } + return false; +} +void ChartTypeDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool /*bIsHighContrast*/, const ChartTypeParameter& /*rParameter*/ ) +{ + rSubTypeList.Clear(); +} +bool ChartTypeDialogController::shouldShow_XAxisTypeControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_3DLookControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_StackingControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_DeepStackingControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_SplineControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_GeometryControl() const +{ + return false; +} +bool ChartTypeDialogController::shouldShow_SortByXValuesResourceGroup() const +{ + return false; +} + +void ChartTypeDialogController::showExtraControls( Window* /*pParent*/, const Point& /*rPosition*/, const Size& /*rSize*/ ) +{ +} +void ChartTypeDialogController::hideExtraControls() const +{ +} +void ChartTypeDialogController::fillExtraControls( const ChartTypeParameter& /*rParameter*/ + , const uno::Reference< XChartDocument >& /*xChartModel*/ + , const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const +{ +} +void ChartTypeDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& /*xTemplateProps*/ ) const throw (uno::RuntimeException) +{ +} +//-------------------------------------------------------------------------- + +ColumnOrBarChartDialogController_Base::ColumnOrBarChartDialogController_Base() + : ChartTypeDialogController() +{ +} +ColumnOrBarChartDialogController_Base::~ColumnOrBarChartDialogController_Base() +{ +} +bool ColumnOrBarChartDialogController_Base::shouldShow_3DLookControl() const +{ + return true; +} +bool ColumnOrBarChartDialogController_Base::shouldShow_GeometryControl() const +{ + return true; +} +void ColumnOrBarChartDialogController_Base::adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter ) +{ + if(rParameter.nSubTypeIndex>3 && !rParameter.b3DLook) + { + rParameter.nSubTypeIndex=1; + } +} +//-------------------------------------------------------------------------- +ColumnChartDialogController::ColumnChartDialogController() +{ +} +ColumnChartDialogController::~ColumnChartDialogController() +{ +} +String ColumnChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_COLUMN )); +} +Image ColumnChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_COLUMN ); +} +const tTemplateServiceChartTypeParameterMap& ColumnChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.Column" ), ChartTypeParameter(1,false,false,GlobalStackMode_NONE) ) + ( C2U( "com.sun.star.chart2.template.StackedColumn" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedColumn" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) ) + ( C2U( "com.sun.star.chart2.template.ThreeDColumnFlat" ), ChartTypeParameter(1,false,true,GlobalStackMode_NONE) ) + ( C2U( "com.sun.star.chart2.template.StackedThreeDColumnFlat" ), ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDColumnFlat" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) ) + ( C2U( "com.sun.star.chart2.template.ThreeDColumnDeep" ), ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z) ) + ; + return m_aTemplateMap; +} +void ColumnChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( rParameter.b3DLook ) + { + switch(rParameter.nGeometry3D) + { + case DataPointGeometry3D::CYLINDER: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_SAEULE_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_SAEULE_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_SAEULE_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_SAEULE_3D_4 ) ); + break; + case DataPointGeometry3D::CONE: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_KEGEL_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_KEGEL_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_KEGEL_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_KEGEL_3D_4 ) ); + break; + case DataPointGeometry3D::PYRAMID: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_PYRAMID_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_PYRAMID_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_PYRAMID_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_PYRAMID_3D_4 ) ); + break; + default: //DataPointGeometry3D::CUBOID: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMNS_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMNS_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_COLUMNS_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_COLUMNS_3D ) ); + break; + } + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMNS_2D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMNS_2D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_COLUMNS_2D_3 ) ); + } + + rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_DEEP )) ); +} + +//-------------------------------------------------------------------------- + +BarChartDialogController::BarChartDialogController() +{ +} +BarChartDialogController::~BarChartDialogController() +{ +} +String BarChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_BAR )); +} +Image BarChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_BAR ); +} +const tTemplateServiceChartTypeParameterMap& BarChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.Bar" ), ChartTypeParameter(1,false,false,GlobalStackMode_NONE) ) + ( C2U( "com.sun.star.chart2.template.StackedBar" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedBar" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) ) + ( C2U( "com.sun.star.chart2.template.ThreeDBarFlat" ), ChartTypeParameter(1,false,true,GlobalStackMode_NONE) ) + ( C2U( "com.sun.star.chart2.template.StackedThreeDBarFlat" ), ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDBarFlat" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) ) + ( C2U( "com.sun.star.chart2.template.ThreeDBarDeep" ), ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z) ) + ; + return m_aTemplateMap; +} +void BarChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( rParameter.b3DLook ) + { + switch(rParameter.nGeometry3D) + { + case DataPointGeometry3D::CYLINDER: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_ROEHRE_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_ROEHRE_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_ROEHRE_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_ROEHRE_3D_4 ) ); + break; + case DataPointGeometry3D::CONE: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_KEGELQ_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_KEGELQ_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_KEGELQ_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_KEGELQ_3D_4 ) ); + break; + case DataPointGeometry3D::PYRAMID: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_PYRAMIDQ_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_PYRAMIDQ_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_PYRAMIDQ_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_PYRAMIDQ_3D_4 ) ); + break; + default: //DataPointGeometry3D::CUBOID: + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BARS_3D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_BARS_3D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_BARS_3D_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_BARS_3D ) ); + break; + } + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BARS_2D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_BARS_2D_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_BARS_2D_3 ) ); + } + rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_DEEP )) ); +} + +//-------------------------------------------------------------------------- + +PieChartDialogController::PieChartDialogController() +{ +} +PieChartDialogController::~PieChartDialogController() +{ +} +String PieChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_PIE )); +} +Image PieChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_PIE ); +} +const tTemplateServiceChartTypeParameterMap& PieChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.Pie" ), ChartTypeParameter(1,false,false) ) + ( C2U( "com.sun.star.chart2.template.PieAllExploded" ), ChartTypeParameter(2,false,false) ) + ( C2U( "com.sun.star.chart2.template.Donut" ), ChartTypeParameter(3,false,false) ) + ( C2U( "com.sun.star.chart2.template.DonutAllExploded" ), ChartTypeParameter(4,false,false) ) + ( C2U( "com.sun.star.chart2.template.ThreeDPie" ), ChartTypeParameter(1,false,true) ) + ( C2U( "com.sun.star.chart2.template.ThreeDPieAllExploded" ), ChartTypeParameter(2,false,true) ) + ( C2U( "com.sun.star.chart2.template.ThreeDDonut" ), ChartTypeParameter(3,false,true) ) + ( C2U( "com.sun.star.chart2.template.ThreeDDonutAllExploded" ), ChartTypeParameter(4,false,true) ) + ; + return m_aTemplateMap; +} +void PieChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( rParameter.b3DLook ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_CIRCLES_3D ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_CIRCLES_3D_EXPLODED ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_DONUT_3D ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_DONUT_3D_EXPLODED ) ); + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_CIRCLES_2D ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_CIRCLES_2D_EXPLODED ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_DONUT_2D ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_DONUT_2D_EXPLODED ) ); + } + rSubTypeList.SetItemText( 1, String( SchResId( STR_NORMAL )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_PIE_EXPLODED )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_DONUT )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_DONUT_EXPLODED )) ); +} +bool PieChartDialogController::shouldShow_3DLookControl() const +{ + return true; +} +void PieChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + if(rParameter.eStackMode==GlobalStackMode_STACK_Z) + rParameter.eStackMode = GlobalStackMode_NONE; +} +//-------------------------------------------------------------------------- +LineChartDialogController::LineChartDialogController() +{ +} +LineChartDialogController::~LineChartDialogController() +{ +} +String LineChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_LINE )); +} +Image LineChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_LINE ); +} +const tTemplateServiceChartTypeParameterMap& LineChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + //------------------------------------------------------- + ( C2U( "com.sun.star.chart2.template.Symbol" ), ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false) ) + ( C2U( "com.sun.star.chart2.template.StackedSymbol" ), ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedSymbol" ), ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false) ) + ( C2U( "com.sun.star.chart2.template.LineSymbol" ), ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true) ) + ( C2U( "com.sun.star.chart2.template.StackedLineSymbol" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedLineSymbol" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true) ) + ( C2U( "com.sun.star.chart2.template.Line" ), ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true) ) + ( C2U( "com.sun.star.chart2.template.StackedLine" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedLine" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true) ) + //------------------------------------------------------- + //( C2U( "com.sun.star.chart2.template.ThreeDLine" ), ChartTypeParameter(4,false,true,GlobalStackMode_NONE,false,true) ) + ( C2U( "com.sun.star.chart2.template.StackedThreeDLine" ), ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y,false,true) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDLine" ), ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Y_PERCENT,false,true) ) + ( C2U( "com.sun.star.chart2.template.ThreeDLineDeep" ), ChartTypeParameter(4,false,true,GlobalStackMode_STACK_Z,false,true) ) + //------------------------------------------------------- + ; + return m_aTemplateMap; +} +void LineChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( CurveStyle_LINES==rParameter.eCurveStyle ) + { + //direct lines + if( GlobalStackMode_NONE == rParameter.eStackMode || GlobalStackMode_STACK_Z == rParameter.eStackMode ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XCATEGORY ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XCATEGORY ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XCATEGORY ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XCATEGORY ) ); + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_STACKED ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_STACKED ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_STACKED ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_STACKED ) ); + } + } + else //CurveStyle_LINES + { + if( GlobalStackMode_NONE == rParameter.eStackMode || GlobalStackMode_STACK_Z == rParameter.eStackMode ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XCATEGORY ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XCATEGORY_SMOOTH ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XCATEGORY_SMOOTH ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XCATEGORY_SMOOTH ) ); + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_STACKED ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_STACKED_SMOOTH ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_STACKED_SMOOTH ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_STACKED_SMOOTH ) ); + } + } + + rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_LINES_3D )) ); +} +bool LineChartDialogController::shouldShow_StackingControl() const +{ + return true; +} +bool LineChartDialogController::shouldShow_DeepStackingControl() const +{ + return false; +} +bool LineChartDialogController::shouldShow_SplineControl() const +{ + return true; +} +void LineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = false; + + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.bSymbols = true; + rParameter.bLines = true; + break; + case 3: + rParameter.bSymbols = false; + rParameter.bLines = true; + break; + case 4: + rParameter.bSymbols = false; + rParameter.bLines = true; + rParameter.b3DLook = true; + if( rParameter.eStackMode == GlobalStackMode_NONE ) + rParameter.eStackMode = GlobalStackMode_STACK_Z; + break; + default: + rParameter.bSymbols = true; + rParameter.bLines = false; + break; + } + + if(!rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_STACK_Z ) + rParameter.eStackMode = GlobalStackMode_NONE; +} +void LineChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter ) +{ + if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE ) + rParameter.eStackMode = GlobalStackMode_STACK_Z; + + ChartTypeDialogController::adjustParameterToMainType( rParameter ); +} +//-------------------------------------------------------------------------- +XYChartDialogController::XYChartDialogController() +{ + bSupportsXAxisWithValues = true; +} +XYChartDialogController::~XYChartDialogController() +{ +} +String XYChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_XY )); +} +Image XYChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_XY ); +} +const tTemplateServiceChartTypeParameterMap& XYChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + //------------------------------------------------------- + ( C2U( "com.sun.star.chart2.template.ScatterSymbol" ), ChartTypeParameter(1,true,false,GlobalStackMode_NONE,true,false) ) + ( C2U( "com.sun.star.chart2.template.ScatterLineSymbol" ), ChartTypeParameter(2,true,false,GlobalStackMode_NONE,true,true) ) + ( C2U( "com.sun.star.chart2.template.ScatterLine" ), ChartTypeParameter(3,true,false,GlobalStackMode_NONE,false,true) ) + ( C2U( "com.sun.star.chart2.template.ThreeDScatter" ), ChartTypeParameter(4,true,true,GlobalStackMode_NONE,false,true) ) + ; + return m_aTemplateMap; +} +void XYChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( CurveStyle_LINES==rParameter.eCurveStyle ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XVALUES ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XVALUES ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XVALUES ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XVALUES ) ); + } + else //CurveStyle_LINES + { + //smooth lines + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_POINTS_XVALUES ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_LINE_P_XVALUES_SMOOTH ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_LINE_O_XVALUES_SMOOTH ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_LINE3D_XVALUES_SMOOTH ) ); + } + + rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_LINES_3D )) ); +} +bool XYChartDialogController::shouldShow_SplineControl() const +{ + return true; +} +bool XYChartDialogController::shouldShow_SortByXValuesResourceGroup() const +{ + return true; +} +void XYChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.eStackMode=GlobalStackMode_NONE; + rParameter.b3DLook = false; + + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.bSymbols = true; + rParameter.bLines = true; + break; + case 3: + rParameter.bSymbols = false; + rParameter.bLines = true; + break; + case 4: + rParameter.bSymbols = false; + rParameter.bLines = true; + rParameter.b3DLook = true; + rParameter.eStackMode=GlobalStackMode_STACK_Z; + break; + default: + rParameter.bSymbols = true; + rParameter.bLines = false; + break; + } +} +//-------------------------------------------------------------------------- +AreaChartDialogController::AreaChartDialogController() +{ +} +AreaChartDialogController::~AreaChartDialogController() +{ +} +String AreaChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_AREA )); +} +Image AreaChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_AREA ); +} +bool AreaChartDialogController::shouldShow_3DLookControl() const +{ + return true; +} +const tTemplateServiceChartTypeParameterMap& AreaChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.Area" ), ChartTypeParameter(1,false,false,GlobalStackMode_NONE) ) + ( C2U( "com.sun.star.chart2.template.ThreeDArea" ), ChartTypeParameter(1,false,true,GlobalStackMode_STACK_Z) ) + ( C2U( "com.sun.star.chart2.template.StackedArea" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.StackedThreeDArea" ), ChartTypeParameter(2,false,true,GlobalStackMode_STACK_Y) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedArea" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedThreeDArea" ), ChartTypeParameter(3,false,true,GlobalStackMode_STACK_Y_PERCENT) ) + ; + return m_aTemplateMap; +} +void AreaChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( rParameter.b3DLook ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_AREAS_3D ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_AREAS_3D_1 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_AREAS_3D_2 ) ); + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_AREAS_2D_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_AREAS_2D ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_AREAS_2D_3 ) ); + } + + rSubTypeList.SetItemText( 1, String( SchResId( rParameter.b3DLook ? STR_DEEP : STR_NORMAL )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_STACKED )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_PERCENT )) ); +} +void AreaChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.eCurveStyle = CurveStyle_LINES; + + if( rParameter.nSubTypeIndex>3 ) + rParameter.nSubTypeIndex = 1; + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.eStackMode=GlobalStackMode_STACK_Y; + break; + case 3: + rParameter.eStackMode=GlobalStackMode_STACK_Y_PERCENT; + break; + default: + if( rParameter.b3DLook ) + rParameter.eStackMode=GlobalStackMode_STACK_Z; + else + rParameter.eStackMode=GlobalStackMode_NONE; + break; + } +} +void AreaChartDialogController::adjustParameterToMainType( ChartTypeParameter& rParameter ) +{ + if( rParameter.b3DLook && rParameter.eStackMode == GlobalStackMode_NONE ) + rParameter.eStackMode = GlobalStackMode_STACK_Z; + + ChartTypeDialogController::adjustParameterToMainType( rParameter ); +} +//-------------------------------------------------------------------------- +NetChartDialogController::NetChartDialogController() +{ + bSupports3D = false; +} +NetChartDialogController::~NetChartDialogController() +{ +} +String NetChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_NET )); +} +Image NetChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_NET ); +} +bool NetChartDialogController::shouldShow_StackingControl() const +{ + return true; +} +const tTemplateServiceChartTypeParameterMap& NetChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + //@todo need templates with symbols only + ( C2U( "com.sun.star.chart2.template.NetSymbol" ), ChartTypeParameter(1,false,false,GlobalStackMode_NONE,true,false) ) + ( C2U( "com.sun.star.chart2.template.StackedNetSymbol" ), ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y,true,false) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedNetSymbol" ),ChartTypeParameter(1,false,false,GlobalStackMode_STACK_Y_PERCENT,true,false) ) + + ( C2U( "com.sun.star.chart2.template.Net" ), ChartTypeParameter(2,false,false,GlobalStackMode_NONE,true,true) ) + ( C2U( "com.sun.star.chart2.template.StackedNet" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y,true,true) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedNet" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y_PERCENT,true,true) ) + + ( C2U( "com.sun.star.chart2.template.NetLine" ), ChartTypeParameter(3,false,false,GlobalStackMode_NONE,false,true) ) + ( C2U( "com.sun.star.chart2.template.StackedNetLine" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y,false,true) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedNetLine" ), ChartTypeParameter(3,false,false,GlobalStackMode_STACK_Y_PERCENT,false,true) ) + + ( C2U( "com.sun.star.chart2.template.FilledNet" ), ChartTypeParameter(4,false,false,GlobalStackMode_NONE,false,false) ) + ( C2U( "com.sun.star.chart2.template.StackedFilledNet" ), ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y,false,false) ) + ( C2U( "com.sun.star.chart2.template.PercentStackedFilledNet" ),ChartTypeParameter(4,false,false,GlobalStackMode_STACK_Y_PERCENT,false,false) ) + ; + return m_aTemplateMap; +} +void NetChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ) +{ + rSubTypeList.Clear(); + + if( GlobalStackMode_NONE == rParameter.eStackMode ) + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_NET_SYMB ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_NET_LINESYMB ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_NET ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_NET_FILL ) ); + } + else + { + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_NET_SYMB_STACK ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_NET_LINESYMB_STACK ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_NET_STACK ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_NET_FILL_STACK ) ); + } + + rSubTypeList.SetItemText( 1, String( SchResId( STR_POINTS_ONLY )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_POINTS_AND_LINES )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_LINES_ONLY )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_FILLED )) ); +} +void NetChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = false; + if(rParameter.eStackMode==GlobalStackMode_STACK_Z) + rParameter.eStackMode = GlobalStackMode_NONE; + + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.bSymbols = true; + rParameter.bLines = true; + break; + case 3: + rParameter.bSymbols = false; + rParameter.bLines = true; + break; + case 4: + rParameter.bSymbols = false; + rParameter.bLines = false; + break; + default: + rParameter.bSymbols = true; + rParameter.bLines = false; + break; + } +} +//-------------------------------------------------------------------------- +StockChartDialogController::StockChartDialogController() +{ + bSupports3D = false; +} +StockChartDialogController::~StockChartDialogController() +{ +} +String StockChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_STOCK )); +} +Image StockChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_STOCK ); +} +const tTemplateServiceChartTypeParameterMap& StockChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.StockLowHighClose" ), ChartTypeParameter(1) ) + ( C2U( "com.sun.star.chart2.template.StockOpenLowHighClose" ), ChartTypeParameter(2) ) + ( C2U( "com.sun.star.chart2.template.StockVolumeLowHighClose" ), ChartTypeParameter(3) ) + ( C2U( "com.sun.star.chart2.template.StockVolumeOpenLowHighClose" ),ChartTypeParameter(4) ) + ; + return m_aTemplateMap; +} +void StockChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ ) +{ + rSubTypeList.Clear(); + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_STOCK_1 ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_STOCK_2 ) ); + rSubTypeList.InsertItem( 3, SELECT_BITMAP( BMP_STOCK_3 ) ); + rSubTypeList.InsertItem( 4, SELECT_BITMAP( BMP_STOCK_4 ) ); + + rSubTypeList.SetItemText( 1, String( SchResId( STR_STOCK_1 )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_STOCK_2 )) ); + rSubTypeList.SetItemText( 3, String( SchResId( STR_STOCK_3 )) ); + rSubTypeList.SetItemText( 4, String( SchResId( STR_STOCK_4 )) ); +} +void StockChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = false; + rParameter.eStackMode = GlobalStackMode_NONE; +} +//-------------------------------------------------------------------------- +CombiColumnLineChartDialogController::CombiColumnLineChartDialogController() + : m_pFT_NumberOfLines(0) + , m_pMF_NumberOfLines(0) +{ + bSupports3D = false; +} +CombiColumnLineChartDialogController::~CombiColumnLineChartDialogController() +{ + if(m_pFT_NumberOfLines) + delete m_pFT_NumberOfLines; + if(m_pMF_NumberOfLines) + delete m_pMF_NumberOfLines; +} +String CombiColumnLineChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_COMBI_COLUMN_LINE )); +} +Image CombiColumnLineChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_COLUMN_LINE ); +} +const tTemplateServiceChartTypeParameterMap& CombiColumnLineChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.ColumnWithLine" ), ChartTypeParameter(1) ) + ( C2U( "com.sun.star.chart2.template.StackedColumnWithLine" ), ChartTypeParameter(2,false,false,GlobalStackMode_STACK_Y) ) + ; + return m_aTemplateMap; +} +void CombiColumnLineChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ ) +{ + rSubTypeList.Clear(); + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_COLUMN_LINE ) ); + rSubTypeList.InsertItem( 2, SELECT_BITMAP( BMP_COLUMN_LINE_STACKED ) ); + + rSubTypeList.SetItemText( 1, String( SchResId( STR_LINE_COLUMN )) ); + rSubTypeList.SetItemText( 2, String( SchResId( STR_LINE_STACKEDCOLUMN )) ); +} +void CombiColumnLineChartDialogController::showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize ) +{ + if(!m_pFT_NumberOfLines) + { + m_pFT_NumberOfLines = new FixedText(pParent,pParent->GetStyle()); + m_pFT_NumberOfLines->SetText( String( SchResId( STR_NUMBER_OF_LINES )) ); + } + if(!m_pMF_NumberOfLines) + { + m_pMF_NumberOfLines = new MetricField(pParent,pParent->GetStyle() | WB_SPIN | WB_REPEAT | WB_BORDER ); + m_pMF_NumberOfLines->SetDefaultUnit( FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetUnit( FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetSpinSize(1); + m_pMF_NumberOfLines->SetFirst( 1, FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetLast( 100, FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetMin( 1, FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetMax( 100, FUNIT_CUSTOM ); + m_pMF_NumberOfLines->SetHelpId( HID_SCH_NUM_OF_LINES ); + + m_pMF_NumberOfLines->SetModifyHdl( LINK( this, CombiColumnLineChartDialogController, ChangeLineCountHdl ) ); + } + + Size aDistanceSize( pParent->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,2), MapMode(MAP_APPFONT) ) ); + Size aMFSize( pParent->LogicToPixel( Size(20,RSC_CD_TEXTBOX_HEIGHT), MapMode(MAP_APPFONT) ) ); + m_pMF_NumberOfLines->SetSizePixel( aMFSize ); + + Size aFTSize(m_pFT_NumberOfLines->CalcMinimumSize(rSize.Width()-aMFSize.Width()-aDistanceSize.Width())); + m_pFT_NumberOfLines->SetSizePixel(aFTSize); + + m_pFT_NumberOfLines->SetPosPixel( Point( rPosition.X(), rPosition.Y()+aDistanceSize.Height()) ); + m_pMF_NumberOfLines->SetPosPixel( Point( rPosition.X()+aFTSize.Width()+aDistanceSize.Width(), rPosition.Y()) ); + + m_pFT_NumberOfLines->Show(); + m_pMF_NumberOfLines->Show(); +} +void CombiColumnLineChartDialogController::hideExtraControls() const +{ + if(m_pFT_NumberOfLines) + m_pFT_NumberOfLines->Hide(); + if(m_pMF_NumberOfLines) + m_pMF_NumberOfLines->Hide(); +} +void CombiColumnLineChartDialogController::fillExtraControls( const ChartTypeParameter& /*rParameter*/ + , const uno::Reference< XChartDocument >& xChartModel + , const uno::Reference< beans::XPropertySet >& xTemplateProps ) const +{ + if(!m_pMF_NumberOfLines) + return; + + uno::Reference< frame::XModel > xModel( xChartModel, uno::UNO_QUERY ); + + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + if(!xDiagram.is()) + return; + + sal_Int32 nNumLines = 0; + + if(xTemplateProps.is()) + try + { + xTemplateProps->getPropertyValue( C2U("NumberOfLines") ) >>= nNumLines; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + if( nNumLines < 0 ) + nNumLines = 0; + m_pMF_NumberOfLines->SetValue( nNumLines ); + + sal_Int32 nMaxLines = ChartModelHelper::getDataSeries( xModel ).size() - 1; + if( nMaxLines < 0 ) + nMaxLines = 0; + m_pMF_NumberOfLines->SetLast( nMaxLines ); + m_pMF_NumberOfLines->SetMax( nMaxLines ); +} +void CombiColumnLineChartDialogController::setTemplateProperties( const uno::Reference< beans::XPropertySet >& xTemplateProps ) const throw (uno::RuntimeException) +{ + if( xTemplateProps.is() ) + { + sal_Int32 nNumLines = static_cast< sal_Int32 >( m_pMF_NumberOfLines->GetValue()); + xTemplateProps->setPropertyValue( C2U( "NumberOfLines" ), uno::makeAny(nNumLines) ); + } +} + +IMPL_LINK( CombiColumnLineChartDialogController, ChangeLineCountHdl, void *, EMPTYARG ) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + return 0; +} +void CombiColumnLineChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = false; + if(rParameter.eStackMode==GlobalStackMode_STACK_Z) + rParameter.eStackMode = GlobalStackMode_NONE; + + switch( rParameter.nSubTypeIndex ) + { + case 2: + rParameter.eStackMode=GlobalStackMode_STACK_Y; + break; + default: + rParameter.eStackMode=GlobalStackMode_NONE; + break; + } +} +//-------------------------------------------------------------------------- +BubbleChartDialogController::BubbleChartDialogController() +{ +} +BubbleChartDialogController::~BubbleChartDialogController() +{ +} +String BubbleChartDialogController::getName() +{ + return String( SchResId( STR_TYPE_BUBBLE )); +} +Image BubbleChartDialogController::getImage( bool bIsHighContrast ) +{ + return SELECT_IMAGE( IMG_TYPE_BUBBLE ); +} +const tTemplateServiceChartTypeParameterMap& BubbleChartDialogController::getTemplateMap() const +{ + static tTemplateServiceChartTypeParameterMap m_aTemplateMap = + tTemplateServiceChartTypeParameterMap + ( C2U( "com.sun.star.chart2.template.Bubble" ), ChartTypeParameter(1,true) ) ; + return m_aTemplateMap; +} +void BubbleChartDialogController::fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& /*rParameter*/ ) +{ + rSubTypeList.Clear(); + rSubTypeList.InsertItem( 1, SELECT_BITMAP( BMP_BUBBLE_1 ) ); + + rSubTypeList.SetItemText( 1, String( SchResId( STR_BUBBLE_1 )) ); +} +void BubbleChartDialogController::adjustParameterToSubType( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = false; + rParameter.eStackMode = GlobalStackMode_NONE; +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/ChartTypeDialogController.hxx b/chart2/source/controller/dialogs/ChartTypeDialogController.hxx new file mode 100644 index 000000000000..cdbda807813f --- /dev/null +++ b/chart2/source/controller/dialogs/ChartTypeDialogController.hxx @@ -0,0 +1,320 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartTypeDialogController.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CHARTTYPE_DIALOG_CONTROLLER_HXX +#define _CHART2_CHARTTYPE_DIALOG_CONTROLLER_HXX + +#include "ChangingResource.hxx" +#include "ThreeDHelper.hxx" +#include <comphelper/InlineContainer.hxx> + +#include <com/sun/star/chart2/CurveStyle.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> +#include <svtools/valueset.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class FixedText +#include <vcl/fixed.hxx> +// header for class MetricField +#include <vcl/field.hxx> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +enum GlobalStackMode +{ + GlobalStackMode_NONE, + GlobalStackMode_STACK_Y, + GlobalStackMode_STACK_Y_PERCENT, + GlobalStackMode_STACK_Z +}; + +class ChartTypeParameter +{ +public: + ChartTypeParameter( sal_Int32 nSubTypeIndex, bool bXAxisWithValues=false + , bool b3DLook=false, GlobalStackMode eStackMode=GlobalStackMode_NONE + , bool _bSymbols = true, bool _bLines = true + , ::com::sun::star::chart2::CurveStyle eCurveStyle = ::com::sun::star::chart2::CurveStyle_LINES ); + ChartTypeParameter(); + virtual ~ChartTypeParameter(); + + bool mapsToSameService( const ChartTypeParameter& rParameter ) const; + bool mapsToSimilarService( const ChartTypeParameter& rParameter, sal_Int32 nTheHigherTheLess ) const; + + sal_Int32 nSubTypeIndex;//starting with 1 + + bool bXAxisWithValues; + bool b3DLook; + bool bSymbols; + bool bLines; + + GlobalStackMode eStackMode; + ::com::sun::star::chart2::CurveStyle eCurveStyle; + + sal_Int32 nCurveResolution; + sal_Int32 nSplineOrder; + + sal_Int32 nGeometry3D; + + ThreeDLookScheme eThreeDLookScheme; + sal_Bool bSortByXValues; +}; + +typedef ::comphelper::MakeMap< ::rtl::OUString, ChartTypeParameter > tTemplateServiceChartTypeParameterMap; + +class ChartTypeDialogController : public ChangingResource +{ +public: + ChartTypeDialogController(); + virtual ~ChartTypeDialogController(); + + virtual String getName()=0; + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const = 0; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + + virtual bool shouldShow_XAxisTypeControl() const; + virtual bool shouldShow_3DLookControl() const; + virtual bool shouldShow_StackingControl() const; + virtual bool shouldShow_DeepStackingControl() const; + virtual bool shouldShow_SplineControl() const; + virtual bool shouldShow_GeometryControl() const; + virtual bool shouldShow_SortByXValuesResourceGroup() const; + + virtual void showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize ); + virtual void hideExtraControls() const; + virtual void fillExtraControls( const ChartTypeParameter& rParameter + , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel + , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps=::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >() ) const; + virtual void setTemplateProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps ) const throw (::com::sun::star::uno::RuntimeException); + + virtual bool isSubType( const rtl::OUString& rServiceName ); + virtual ChartTypeParameter getChartTypeParameterForService( const rtl::OUString& rServiceName, const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet >& xTemplateProps ); + virtual void adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter );//if you have different counts of subtypes you may need to adjust the index + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + virtual void adjustParameterToMainType( ChartTypeParameter& rParameter ); + virtual rtl::OUString getServiceNameForParameter( const ChartTypeParameter& rParameter ) const; + virtual bool commitToModel( const ChartTypeParameter& rParameter + , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel ); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > getCurrentTemplate( const ChartTypeParameter& rParameter + , const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xTemplateManager ) const; + +protected: + bool bSupportsXAxisWithValues; + bool bSupports3D; +}; + +class ColumnOrBarChartDialogController_Base : public ChartTypeDialogController +{ +public: + ColumnOrBarChartDialogController_Base(); + virtual ~ColumnOrBarChartDialogController_Base(); + + virtual bool shouldShow_3DLookControl() const; + virtual bool shouldShow_GeometryControl() const; + + virtual void adjustSubTypeAndEnableControls( ChartTypeParameter& rParameter ); +}; + +class ColumnChartDialogController : public ColumnOrBarChartDialogController_Base +{ +public: + ColumnChartDialogController(); + virtual ~ColumnChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); +}; + +class BarChartDialogController : public ColumnOrBarChartDialogController_Base +{ +public: + BarChartDialogController(); + virtual ~BarChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); +}; + +class PieChartDialogController : public ChartTypeDialogController +{ +public: + PieChartDialogController(); + virtual ~PieChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + + virtual bool shouldShow_3DLookControl() const; +}; + +class LineChartDialogController : public ChartTypeDialogController +{ +public: + LineChartDialogController(); + virtual ~LineChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + virtual void adjustParameterToMainType( ChartTypeParameter& rParameter ); + + virtual bool shouldShow_StackingControl() const; + virtual bool shouldShow_DeepStackingControl() const; + virtual bool shouldShow_SplineControl() const; +}; + +class XYChartDialogController : public ChartTypeDialogController +{ +public: + XYChartDialogController(); + virtual ~XYChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + + virtual bool shouldShow_SplineControl() const; + virtual bool shouldShow_SortByXValuesResourceGroup() const; +}; + +class AreaChartDialogController : public ChartTypeDialogController +{ +public: + AreaChartDialogController(); + virtual ~AreaChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + virtual void adjustParameterToMainType( ChartTypeParameter& rParameter ); + + virtual bool shouldShow_3DLookControl() const; +}; + +class NetChartDialogController : public ChartTypeDialogController +{ +public: + NetChartDialogController(); + virtual ~NetChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + + virtual bool shouldShow_StackingControl() const; +}; + +class StockChartDialogController : public ChartTypeDialogController +{ +public: + StockChartDialogController(); + virtual ~StockChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); +}; + +class CombiColumnLineChartDialogController : public ChartTypeDialogController +{ +public: + CombiColumnLineChartDialogController(); + virtual ~CombiColumnLineChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); + + virtual void showExtraControls( Window* pParent, const Point& rPosition, const Size& rSize ); + virtual void hideExtraControls() const; + virtual void fillExtraControls( const ChartTypeParameter& rParameter + , const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartModel + , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps=::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >() ) const; + + virtual void setTemplateProperties( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xTemplateProps ) const throw (::com::sun::star::uno::RuntimeException); + +private: + DECL_LINK( ChangeLineCountHdl, void* ); + +private: + FixedText* m_pFT_NumberOfLines; + MetricField* m_pMF_NumberOfLines; +}; + +class BubbleChartDialogController : public ChartTypeDialogController +{ +public: + BubbleChartDialogController(); + virtual ~BubbleChartDialogController(); + + virtual String getName(); + virtual Image getImage( bool bIsHighContrast ); + virtual const tTemplateServiceChartTypeParameterMap& getTemplateMap() const; + virtual void fillSubTypeList( ValueSet& rSubTypeList, bool bIsHighContrast, const ChartTypeParameter& rParameter ); + virtual void adjustParameterToSubType( ChartTypeParameter& rParameter ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx b/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx new file mode 100644 index 000000000000..58d3f0a2242c --- /dev/null +++ b/chart2/source/controller/dialogs/ChartTypeTemplateProvider.hxx @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartTypeTemplateProvider.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_DIALOGS_TEMPLATEPROVIDER_HXX +#define _CHART2_DIALOGS_TEMPLATEPROVIDER_HXX + +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class ChartTypeTemplateProvider +{ +public: + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > getCurrentTemplate() const =0; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/CommonResources.hrc b/chart2/source/controller/dialogs/CommonResources.hrc new file mode 100644 index 000000000000..e95c57139bff --- /dev/null +++ b/chart2/source/controller/dialogs/CommonResources.hrc @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CommonResources.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RESOURCE_HXX +#define _CHART2_RESOURCE_HXX + +#define BUTTONS_OK_CANCEL_HELP( xPos, yPos, xOffset, yOffset ) \ +OKButton BTN_OK \ +{ \ + Pos = MAP_APPFONT ( xPos , yPos ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ + DefButton = TRUE ; \ +}; \ +CancelButton BTN_CANCEL \ +{ \ + Pos = MAP_APPFONT ( xPos+xOffset , yPos+yOffset ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ +}; \ +HelpButton BTN_HELP \ +{ \ + Pos = MAP_APPFONT ( xPos+xOffset+xOffset , yPos+yOffset+yOffset ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ +}; + +#define BUTTONS_OK_CANCEL_HELP_STACKED( xPos ) \ +BUTTONS_OK_CANCEL_HELP( xPos, 6, 0, 17 ) + +#define BUTTONS_HELP_OK_CANCEL( xPos, yPos, xOffset, yOffset ) \ +HelpButton BTN_HELP \ +{ \ + Pos = MAP_APPFONT ( xPos , yPos ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ +}; \ +OKButton BTN_OK \ +{ \ + Pos = MAP_APPFONT ( xPos+xOffset , yPos+yOffset ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ + DefButton = TRUE ; \ +}; \ +CancelButton BTN_CANCEL \ +{ \ + Pos = MAP_APPFONT ( xPos+xOffset+xOffset , yPos+yOffset+yOffset ) ; \ + Size = MAP_APPFONT ( 50 , 14 ) ; \ + TabStop = TRUE ; \ +}; + +#define BUTTONS_HELP_OK_CANCEL_NEXT( xPos, yPos ) \ +BUTTONS_HELP_OK_CANCEL( xPos, yPos, 53, 0 ) + + +#endif diff --git a/chart2/source/controller/dialogs/DataBrowser.cxx b/chart2/source/controller/dialogs/DataBrowser.cxx new file mode 100644 index 000000000000..b13333dcb323 --- /dev/null +++ b/chart2/source/controller/dialogs/DataBrowser.cxx @@ -0,0 +1,1350 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataBrowser.cxx,v $ + * $Revision: 1.9.8.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +// header for class SvNumberformat +#ifndef _ZFORMAT_HXX +#ifndef _ZFORLIST_DECLARE_TABLE +#define _ZFORLIST_DECLARE_TABLE +#endif +#include <svtools/zformat.hxx> +#endif +// header for SvNumberFormatter +#include <svtools/zforlist.hxx> + +#include "DataBrowser.hxx" +#include "DataBrowserModel.hxx" +#include "Strings.hrc" +#include "ContainerHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "DiagramHelper.hxx" +#include "ChartModelHelper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "servicenames_charttypes.hxx" +#include "ResId.hxx" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "HelpIds.hrc" + +#include <vcl/fixed.hxx> +#include <vcl/image.hxx> +#include <vcl/msgbox.hxx> +#include <rtl/math.hxx> + +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XChartType.hpp> + +#include <com/sun/star/container/XIndexReplace.hpp> + +#include <algorithm> +#include <functional> + +#define SELECT_IMAGE(name,hc) Image( SchResId( hc ? name ## _HC : name )) + +/* BROWSER_COLUMNSELECTION : single cells may be selected rather than only + entire rows + BROWSER_(H|V)LINES : show horizontal or vertical grid-lines + + BROWSER_AUTO_(H|V)SCROLL : scroll automated horizontally or vertically when + cursor is moved beyond the edge of the dialog + BROWSER_HIGHLIGHT_NONE : Do not mark the current row with selection color + (usually blue) + + */ +#define BROWSER_STANDARD_FLAGS \ + BROWSER_COLUMNSELECTION | \ + BROWSER_HLINES | BROWSER_VLINES | \ + BROWSER_AUTO_HSCROLL | BROWSER_AUTO_VSCROLL | \ + BROWSER_HIGHLIGHT_NONE + +// BROWSER_HIDECURSOR would prevent flickering in edit fields, but navigating +// with shift up/down, and entering non-editable cells would be problematic, +// e.g. the first cell, or when being in read-only mode + + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +using namespace ::svt; + +namespace +{ +sal_Int32 lcl_getRowInData( long nRow ) +{ + return static_cast< sal_Int32 >( nRow ); +} + +sal_Int32 lcl_getColumnInData( USHORT nCol ) +{ + return static_cast< sal_Int32 >( nCol ) - 1; +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ + +// ---------------------------------------- +namespace impl +{ + +class SeriesHeaderEdit : public Edit +{ +public: + SeriesHeaderEdit( Window * pParent ); + virtual ~SeriesHeaderEdit(); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + + void setStartColumn( sal_Int32 nStartColumn ); + sal_Int32 getStartColumn() const; + void SetShowWarningBox( bool bShowWarning = true ); + +private: + sal_Int32 m_nStartColumn; + bool m_bShowWarningBox; +}; + +SeriesHeaderEdit::SeriesHeaderEdit( Window * pParent ) : + Edit( pParent ), + m_nStartColumn( 0 ), + m_bShowWarningBox( false ) +{} +SeriesHeaderEdit::~SeriesHeaderEdit() +{} + +void SeriesHeaderEdit::setStartColumn( sal_Int32 nStartColumn ) +{ + m_nStartColumn = nStartColumn; +} + +sal_Int32 SeriesHeaderEdit::getStartColumn() const +{ + return m_nStartColumn; +} + +void SeriesHeaderEdit::SetShowWarningBox( bool bShowWarning ) +{ + m_bShowWarningBox = bShowWarning; +} + +void SeriesHeaderEdit::MouseButtonDown( const MouseEvent& rMEvt ) +{ + Edit::MouseButtonDown( rMEvt ); + + if( m_bShowWarningBox ) + WarningBox( this, WinBits( WB_OK ), + String( SchResId( STR_INVALID_NUMBER ))).Execute(); +} + +class SeriesHeader +{ +public: + explicit SeriesHeader( Window * pParent ); + + void SetColor( const Color & rCol ); + void SetPos( const Point & rPos ); + void SetWidth( sal_Int32 nWidth ); + void SetChartType( const Reference< chart2::XChartType > & xChartType, + bool bSwapXAndYAxis, + bool bIsHighContrast ); + void SetSeriesName( const String & rName ); + void SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol ); + + void SetPixelPosX( sal_Int32 nPos ); + void SetPixelWidth( sal_Int32 nWidth ); + + sal_Int32 GetStartColumn() const; + sal_Int32 GetEndColumn() const; + + void Show(); + + /** call this before destroying the class. This notifies the listeners to + changes of the edit field for the series name. + */ + void applyChanges(); + + void SetGetFocusHdl( const Link& rLink ); + + void SetEditChangedHdl( const Link & rLink ); + + bool HasFocus() const; + +private: + ::boost::shared_ptr< FixedImage > m_spSymbol; + ::boost::shared_ptr< SeriesHeaderEdit > m_spSeriesName; + ::boost::shared_ptr< FixedText > m_spColorBar; + OutputDevice * m_pDevice; + Link m_aChangeLink; + + void notifyChanges(); + DECL_LINK( SeriesNameChanged, void * ); + DECL_LINK( SeriesNameEdited, void * ); + + /// @param bHC </TRUE> for hight-contrast image + static Image GetChartTypeImage( + const Reference< chart2::XChartType > & xChartType, + bool bSwapXAndYAxis, + bool bHC ); + + sal_Int32 m_nStartCol, m_nEndCol; + sal_Int32 m_nWidth; + Point m_aPos; + bool m_bSeriesNameChangePending; +}; + +SeriesHeader::SeriesHeader( Window * pParent ) : + m_spSymbol( new FixedImage( pParent, WB_NOBORDER )), + m_spSeriesName( new SeriesHeaderEdit( pParent )), + m_spColorBar( new FixedText( pParent, WB_NOBORDER )), + m_pDevice( pParent ), + m_nStartCol( 0 ), + m_nEndCol( 0 ), + m_nWidth( 42 ), + m_aPos( 0, 22 ), + m_bSeriesNameChangePending( false ) +{ + m_spSeriesName->EnableUpdateData( 4 * EDIT_UPDATEDATA_TIMEOUT ); // define is in vcl/edit.hxx + m_spSeriesName->SetUpdateDataHdl( LINK( this, SeriesHeader, SeriesNameChanged )); + m_spSeriesName->SetModifyHdl( LINK( this, SeriesHeader, SeriesNameEdited )); + m_spSeriesName->SetSmartHelpId( SmartId( HID_SCH_DATA_SERIES_LABEL )); + Show(); +} + +void SeriesHeader::notifyChanges() +{ + if( m_aChangeLink.IsSet()) + m_aChangeLink.Call( m_spSeriesName.get()); + + m_bSeriesNameChangePending = false; +} + +void SeriesHeader::applyChanges() +{ + if( m_bSeriesNameChangePending ) + { + notifyChanges(); + } +} + +void SeriesHeader::SetColor( const Color & rCol ) +{ + m_spColorBar->SetControlBackground( rCol ); +} + +void SeriesHeader::SetPos( const Point & rPos ) +{ + m_aPos = rPos; + + // chart type symbol + sal_Int32 nHeight = 10; + Point aPos( rPos ); + aPos.setY( aPos.getY() + 2 ); + Size aSize( nHeight, nHeight ); + m_spSymbol->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT )); + m_spSymbol->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT )); + aPos.setY( aPos.getY() - 2 ); + + // series name edit field + aPos.setX( aPos.getX() + nHeight + 2 ); + aSize.setWidth( m_nWidth - nHeight - 2 ); + nHeight = 12; + aSize.setHeight( nHeight ); + m_spSeriesName->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT )); + m_spSeriesName->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT )); + + // color bar + aPos.setX( rPos.getX() + 1 ); + aPos.setY( aPos.getY() + nHeight + 2 ); + nHeight = 3; + aSize.setWidth( m_nWidth - 1 ); + aSize.setHeight( nHeight ); + m_spColorBar->SetPosPixel( m_pDevice->LogicToPixel( aPos, MAP_APPFONT )); + m_spColorBar->SetSizePixel( m_pDevice->LogicToPixel( aSize, MAP_APPFONT )); +} + +void SeriesHeader::SetWidth( sal_Int32 nWidth ) +{ + m_nWidth = nWidth; + SetPos( m_aPos ); +} + + +void SeriesHeader::SetPixelPosX( sal_Int32 nPos ) +{ + Point aPos( m_pDevice->LogicToPixel( m_aPos, MAP_APPFONT )); + aPos.setX( nPos ); + SetPos( m_pDevice->PixelToLogic( aPos, MAP_APPFONT )); +} + +void SeriesHeader::SetPixelWidth( sal_Int32 nWidth ) +{ + SetWidth( m_pDevice->PixelToLogic( Size( nWidth, 0 ), MAP_APPFONT ).getWidth()); +} + +void SeriesHeader::SetChartType( + const Reference< chart2::XChartType > & xChartType, + bool bSwapXAndYAxis, + bool bIsHighContrast ) +{ + m_spSymbol->SetImage( GetChartTypeImage( xChartType, bSwapXAndYAxis, bIsHighContrast )); +} + +void SeriesHeader::SetSeriesName( const String & rName ) +{ + m_spSeriesName->SetText( rName ); +} + +void SeriesHeader::SetRange( sal_Int32 nStartCol, sal_Int32 nEndCol ) +{ + m_nStartCol = nStartCol; + m_nEndCol = (nEndCol > nStartCol) ? nEndCol : nStartCol; + m_spSeriesName->setStartColumn( nStartCol ); +} + +sal_Int32 SeriesHeader::GetStartColumn() const +{ + return m_nStartCol; +} + +sal_Int32 SeriesHeader::GetEndColumn() const +{ + return m_nEndCol; +} + +void SeriesHeader::Show() +{ + m_spSymbol->Show(); + m_spSeriesName->Show(); + m_spColorBar->Show(); +} + +void SeriesHeader::SetEditChangedHdl( const Link & rLink ) +{ + m_aChangeLink = rLink; +} + +IMPL_LINK( SeriesHeader, SeriesNameChanged, void * , EMPTYARG ) +{ + notifyChanges(); + return 0; +} + +IMPL_LINK( SeriesHeader, SeriesNameEdited, void * , EMPTYARG ) +{ + m_bSeriesNameChangePending = true; + return 0; +} + +void SeriesHeader::SetGetFocusHdl( const Link& rLink ) +{ + m_spSeriesName->SetGetFocusHdl( rLink ); +} + +bool SeriesHeader::HasFocus() const +{ + return m_spSeriesName->HasFocus(); +} + +// static +Image SeriesHeader::GetChartTypeImage( + const Reference< chart2::XChartType > & xChartType, + bool bSwapXAndYAxis, + bool bHC ) +{ + Image aResult; + if( !xChartType.is()) + return aResult; + OUString aChartTypeName( xChartType->getChartType()); + + if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_AREA )) + { + aResult = SELECT_IMAGE( IMG_TYPE_AREA, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_COLUMN )) + { + if( bSwapXAndYAxis ) + aResult = SELECT_IMAGE( IMG_TYPE_BAR, bHC ); + else + aResult = SELECT_IMAGE( IMG_TYPE_COLUMN, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_LINE )) + { + aResult = SELECT_IMAGE( IMG_TYPE_LINE, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_SCATTER )) + { + aResult = SELECT_IMAGE( IMG_TYPE_XY, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_PIE )) + { + aResult = SELECT_IMAGE( IMG_TYPE_PIE, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_NET ) + || aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_FILLED_NET ) ) + { + aResult = SELECT_IMAGE( IMG_TYPE_NET, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK )) + { + // @todo: correct image for candle-stick type + aResult = SELECT_IMAGE( IMG_TYPE_STOCK, bHC ); + } + else if( aChartTypeName.equals( CHART2_SERVICE_NAME_CHARTTYPE_BUBBLE )) + { + aResult = SELECT_IMAGE( IMG_TYPE_BUBBLE, bHC ); + } + + return aResult; +} + +struct applyChangesFunctor : public ::std::unary_function< ::boost::shared_ptr< SeriesHeader >, void > +{ + void operator() ( ::boost::shared_ptr< SeriesHeader > spHeader ) + { + spHeader->applyChanges(); + } +}; + +} // namespace impl +// ---------------------------------------- + +namespace +{ + +/** returns false, if no header as the focus. + + If a header has the focus, true is returned and the index of the header + with focus is set at pIndex if pOutIndex is not 0. +*/ +bool lcl_SeriesHeaderHasFocus( + const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader, + sal_Int32 * pOutIndex = 0 ) +{ + sal_Int32 nIndex = 0; + for( ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > >::const_iterator aIt( rSeriesHeader.begin()); + aIt != rSeriesHeader.end(); ++aIt, ++nIndex ) + { + if( (*aIt)->HasFocus()) + { + if( pOutIndex ) + *pOutIndex = nIndex; + return true; + } + } + return false; +} + +sal_Int32 lcl_getColumnInDataOrHeader( + USHORT nCol, const ::std::vector< ::boost::shared_ptr< ::chart::impl::SeriesHeader > > & rSeriesHeader ) +{ + sal_Int32 nColIdx = 0; + bool bHeaderHasFocus( lcl_SeriesHeaderHasFocus( rSeriesHeader, &nColIdx )); + + if( bHeaderHasFocus ) + nColIdx = lcl_getColumnInData( static_cast< USHORT >( rSeriesHeader[nColIdx]->GetStartColumn())); + else + nColIdx = lcl_getColumnInData( nCol ); + + return nColIdx; +} + +} // anonymous namespace + + +DataBrowser::DataBrowser( Window* pParent, const ResId& rId, bool bLiveUpdate ) : + ::svt::EditBrowseBox( pParent, rId, EBBF_SMART_TAB_TRAVEL | EBBF_HANDLE_COLUMN_TEXT, BROWSER_STANDARD_FLAGS ), + m_nSeekRow( 0 ), + m_bIsReadOnly( false ), + m_bIsDirty( false ), + m_bLiveUpdate( bLiveUpdate ), + m_bDataValid( true ), + m_aNumberEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), + m_aTextEditField( & EditBrowseBox::GetDataWindow(), WB_NOBORDER ), + m_rNumberEditController( new ::svt::FormattedFieldCellController( & m_aNumberEditField )), + m_rTextEditController( new ::svt::EditCellController( & m_aTextEditField )) +{ + double fNan; + ::rtl::math::setNan( & fNan ); + m_aNumberEditField.SetDefaultValue( fNan ); + m_aNumberEditField.TreatAsNumber( TRUE ); + RenewTable(); + SetClean(); +} + +DataBrowser::~DataBrowser() +{ +} + +bool DataBrowser::MayInsertRow() const +{ + return ! IsReadOnly() + && ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders )); +} + +bool DataBrowser::MayInsertColumn() const +{ + return ! IsReadOnly(); +} + +bool DataBrowser::MayDeleteRow() const +{ + return ! IsReadOnly() + && ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders )) + && ( GetCurRow() >= 0 ) + && ( GetRowCount() > 1 ); +} + +bool DataBrowser::MayDeleteColumn() const +{ + // if a series header has the focus + if( lcl_SeriesHeaderHasFocus( m_aSeriesHeaders )) + return true; + + return ! IsReadOnly() + && ( GetCurColumnId() > 1 ) + && ( ColCount() > 2 ); +} + +bool DataBrowser::MaySwapRows() const +{ + return ! IsReadOnly() + && ( !lcl_SeriesHeaderHasFocus( m_aSeriesHeaders )) + && ( GetCurRow() >= 0 ) + && ( GetCurRow() < GetRowCount() - 1 ); +} + +bool DataBrowser::MaySwapColumns() const +{ + // if a series header (except the last one) has the focus + { + sal_Int32 nColIndex(0); + if( lcl_SeriesHeaderHasFocus( m_aSeriesHeaders, &nColIndex )) + return (static_cast< sal_uInt32 >( nColIndex ) < (m_aSeriesHeaders.size() - 1)); + } + + return ! IsReadOnly() + && ( GetCurColumnId() > 1 ) + && ( GetCurColumnId() < ColCount() - 1 ); +} + +// bool DataBrowser::MaySortRow() const +// { +// // not implemented +// return false; +// // return ! IsReadOnly() && ( GetCurRow() >= 0 ); +// } + +// bool DataBrowser::MaySortColumn() const +// { +// // not implemented +// return false; +// // return ! IsReadOnly() && ( GetCurColumnId() > 1 ); +// } + +void DataBrowser::clearHeaders() +{ + ::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor()); + m_aSeriesHeaders.clear(); +} + +void DataBrowser::RenewTable() +{ + if( ! m_apDataBrowserModel.get()) + return; + + long nOldRow = GetCurRow(); + USHORT nOldColId = GetCurColumnId(); + + BOOL bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( FALSE ); + + if( IsModified() ) + SaveModified(); + + DeactivateCell(); + + RemoveColumns(); + RowRemoved( 1, GetRowCount() ); + + // for row numbers + InsertHandleColumn( static_cast< sal_uInt16 >( + GetDataWindow().LogicToPixel( Size( 42, 0 )).getWidth() )); + + const sal_Int32 nDefaultColumnWidth = 94; + + sal_Int32 nColumnWidth( GetDataWindow().LogicToPixel( Size( nDefaultColumnWidth, 0 )).getWidth()); + sal_Int32 nColumnCount = m_apDataBrowserModel->getColumnCount(); + // nRowCount is a member of a base class + sal_Int32 nRowCountLocal = m_apDataBrowserModel->getMaxRowCount(); + for( sal_Int32 nColIdx=1; nColIdx<=nColumnCount; ++nColIdx ) + { + InsertDataColumn( static_cast< sal_uInt16 >( nColIdx ), GetColString( nColIdx ), nColumnWidth ); + } + + RowInserted( 1, nRowCountLocal ); + GoToRow( ::std::min( nOldRow, GetRowCount() - 1 )); + GoToColumnId( ::std::min( nOldColId, static_cast< USHORT >( ColCount() - 1 ))); + + Window * pWin = this->GetParent(); + if( !pWin ) + pWin = this; + + // fill series headers + clearHeaders(); + const DataBrowserModel::tDataHeaderVector& aHeaders( m_apDataBrowserModel->getDataHeaders()); + Link aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus )); + Link aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged )); + bool bIsHighContrast = pWin ? (pWin->GetSettings().GetStyleSettings().GetHighContrastMode()) : false; + + for( DataBrowserModel::tDataHeaderVector::const_iterator aIt( aHeaders.begin()); + aIt != aHeaders.end(); ++aIt ) + { + ::boost::shared_ptr< impl::SeriesHeader > spHeader( new impl::SeriesHeader( pWin )); + Reference< beans::XPropertySet > xSeriesProp( aIt->m_xDataSeries, uno::UNO_QUERY ); + sal_Int32 nColor = 0; + // @todo: Set "DraftColor", i.e. interpolated colors for gradients, bitmaps, etc. + if( xSeriesProp.is() && + ( xSeriesProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Color"))) >>= nColor )) + spHeader->SetColor( Color( nColor )); + spHeader->SetChartType( aIt->m_xChartType, aIt->m_bSwapXAndYAxis, bIsHighContrast ); + spHeader->SetSeriesName( + String( DataSeriesHelper::getDataSeriesLabel( + aIt->m_xDataSeries, + (aIt->m_xChartType.is() ? + aIt->m_xChartType->getRoleOfSequenceForSeriesLabel() : + OUString( RTL_CONSTASCII_USTRINGPARAM("values-y")))))); + // index is 1-based, as 0 is for the column that contains the row-numbers + spHeader->SetRange( aIt->m_nStartColumn + 1, aIt->m_nEndColumn + 1 ); + spHeader->SetGetFocusHdl( aFocusLink ); + spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink ); + m_aSeriesHeaders.push_back( spHeader ); + } + + ImplAdjustHeaderControls(); + SetDirty(); + SetUpdateMode( bLastUpdateMode ); + ActivateCell(); + Invalidate(); +} + +String DataBrowser::GetColString( sal_Int32 nColumnId ) const +{ + OSL_ASSERT( m_apDataBrowserModel.get()); + if( nColumnId > 0 ) + return String( m_apDataBrowserModel->getRoleOfColumn( static_cast< sal_Int32 >( nColumnId ) - 1 )); + return String(); +} + +String DataBrowser::GetRowString( sal_Int32 nRow ) const +{ + return String::CreateFromInt32( nRow + 1 ); +} + +String DataBrowser::GetCellText( long nRow, USHORT nColumnId ) const +{ + String aResult; + + if( nColumnId == 0 ) + { + aResult = GetRowString( static_cast< sal_Int32 >( nRow )); + } + else if( nRow >= 0 && + m_apDataBrowserModel.get()) + { + sal_Int32 nColIndex = static_cast< sal_Int32 >( nColumnId ) - 1; + + if( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::NUMBER ) + { + double fData( m_apDataBrowserModel->getCellNumber( nColIndex, nRow )); + sal_Int32 nLabelColor; + bool bColorChanged = false; + + if( ! ::rtl::math::isNan( fData ) && + m_spNumberFormatterWrapper.get() ) + aResult = String( m_spNumberFormatterWrapper->getFormattedString( + GetNumberFormatKey( nRow, nColumnId ), + fData, nLabelColor, bColorChanged )); + } + else + { + OSL_ASSERT( m_apDataBrowserModel->getCellType( nColIndex, nRow ) == DataBrowserModel::TEXT ); + aResult = m_apDataBrowserModel->getCellText( nColIndex, nRow ); + } + } + + return aResult; +} + +double DataBrowser::GetCellNumber( long nRow, USHORT nColumnId ) const +{ + double fResult; + ::rtl::math::setNan( & fResult ); + + if(( nColumnId >= 1 ) && ( nRow >= 0 ) && + m_apDataBrowserModel.get()) + { + fResult = m_apDataBrowserModel->getCellNumber( + static_cast< sal_Int32 >( nColumnId ) - 1, nRow ); + } + + return fResult; +} + +void DataBrowser::Resize() +{ + BOOL bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( FALSE ); + + ::svt::EditBrowseBox::Resize(); + ImplAdjustHeaderControls(); + SetUpdateMode( bLastUpdateMode ); +} + +bool DataBrowser::SetReadOnly( bool bNewState ) +{ + bool bResult = m_bIsReadOnly; + + if( m_bIsReadOnly != bNewState ) + { + m_bIsReadOnly = bNewState; + Invalidate(); + DeactivateCell(); + } + + return bResult; +} + +bool DataBrowser::IsReadOnly() const +{ + return m_bIsReadOnly; +} + + +void DataBrowser::SetClean() +{ + m_bIsDirty = false; +} + +void DataBrowser::SetDirty() +{ + if( !m_bLiveUpdate ) + m_bIsDirty = true; +} + +void DataBrowser::CursorMoved() +{ + EditBrowseBox::CursorMoved(); + + if( GetUpdateMode() && m_aCursorMovedHdlLink.IsSet()) + m_aCursorMovedHdlLink.Call( this ); +} + +void DataBrowser::SetCellModifiedHdl( const Link& rLink ) +{ + m_aCellModifiedLink = rLink; +} + +void DataBrowser::MouseButtonDown( const BrowserMouseEvent& rEvt ) +{ + if( !m_bDataValid ) + ShowWarningBox(); + else + EditBrowseBox::MouseButtonDown( rEvt ); +} + +void DataBrowser::ShowWarningBox() +{ + WarningBox( this, WinBits( WB_OK ), + String( SchResId( STR_INVALID_NUMBER ))).Execute(); +} + +bool DataBrowser::ShowQueryBox() +{ + QueryBox* pQueryBox = new QueryBox( this, WB_YES_NO, String( SchResId( STR_DATA_EDITOR_INCORRECT_INPUT ))); + + return ( pQueryBox->Execute() == RET_YES ); +} + +bool DataBrowser::IsDataValid() +{ + bool bValid = true; + const sal_Int32 nRow = lcl_getRowInData( GetCurRow()); + const sal_Int32 nCol = lcl_getColumnInData( GetCurColumnId()); + + if( m_apDataBrowserModel->getCellType( nCol, nRow ) == DataBrowserModel::NUMBER ) + { + sal_uInt32 nDummy = 0; + double fDummy = 0.0; + String aText( m_aNumberEditField.GetText()); + + if( aText.Len() > 0 && + m_spNumberFormatterWrapper.get() && + m_spNumberFormatterWrapper->getSvNumberFormatter() && + ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( + aText, nDummy, fDummy )) + { + bValid = false; + } + } + + return bValid; +} + +bool DataBrowser::IsEnableItem() +{ + return m_bDataValid; +} + +void DataBrowser::CellModified() +{ + m_bDataValid = IsDataValid(); + SetDirty(); + if( m_aCellModifiedLink.IsSet()) + m_aCursorMovedHdlLink.Call( this ); +} + +void DataBrowser::SetDataFromModel( + const Reference< chart2::XChartDocument > & xChartDoc, + const Reference< uno::XComponentContext > & xContext ) +{ + if( m_bLiveUpdate ) + { + m_xChartDoc.set( xChartDoc ); + } + else + { + Reference< util::XCloneable > xCloneable( xChartDoc, uno::UNO_QUERY ); + if( xCloneable.is()) + m_xChartDoc.set( xCloneable->createClone(), uno::UNO_QUERY ); + } + + m_apDataBrowserModel.reset( new DataBrowserModel( m_xChartDoc, xContext )); + m_spNumberFormatterWrapper.reset( + new NumberFormatterWrapper( + Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ))); + + RenewTable(); + + const sal_Int32 nColCnt = m_apDataBrowserModel->getColumnCount(); + const sal_Int32 nRowCnt = m_apDataBrowserModel->getMaxRowCount(); + if( nRowCnt && nColCnt ) + { + GoToRow( 0 ); + GoToColumnId( 1 ); + } + SetClean(); +} + +void DataBrowser::InsertColumn() +{ + sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders ); + + if( nColIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->insertDataSeries( nColIdx ); + RenewTable(); + } +} + +void DataBrowser::RemoveColumn() +{ + sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders ); + + if( nColIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_bDataValid = true; + m_apDataBrowserModel->removeDataSeries( nColIdx ); + RenewTable(); + } +} + +void DataBrowser::InsertRow() +{ + sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); + + if( nRowIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->insertDataPointForAllSeries( nRowIdx ); + RenewTable(); + } +} + +void DataBrowser::RemoveRow() +{ + sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); + + if( nRowIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_bDataValid = true; + m_apDataBrowserModel->removeDataPointForAllSeries( nRowIdx ); + RenewTable(); + } +} + +void DataBrowser::SwapColumn() +{ + sal_Int32 nColIdx = lcl_getColumnInDataOrHeader( GetCurColumnId(), m_aSeriesHeaders ); + + if( nColIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->swapDataSeries( nColIdx ); + + // keep cursor in swapped column + if( GetCurColumnId() < ColCount() - 1 ) + { + Dispatch( BROWSER_CURSORRIGHT ); + } + RenewTable(); + } +} + +void DataBrowser::SwapRow() +{ + sal_Int32 nRowIdx = lcl_getRowInData( GetCurRow()); + + if( nRowIdx >= 0 && + m_apDataBrowserModel.get()) + { + // save changes made to edit-field + if( IsModified() ) + SaveModified(); + + m_apDataBrowserModel->swapDataPointForAllSeries( nRowIdx ); + + // keep cursor in swapped row + if( GetCurRow() < GetRowCount() - 1 ) + { + Dispatch( BROWSER_CURSORDOWN ); + } + RenewTable(); + } +} + +void DataBrowser::SetCursorMovedHdl( const Link& rLink ) +{ + m_aCursorMovedHdlLink = rLink; +} + +// implementations for ::svt::EditBrowseBox (pure virtual methods) +void DataBrowser::PaintCell( + OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const +{ + Point aPos( rRect.TopLeft()); + aPos.X() += 1; + + String aText = GetCellText( m_nSeekRow, nColumnId ); + Size TxtSize( GetDataWindow().GetTextWidth( aText ), GetDataWindow().GetTextHeight()); + + // clipping + if( aPos.X() < rRect.Right() || aPos.X() + TxtSize.Width() > rRect.Right() || + aPos.Y() < rRect.Top() || aPos.Y() + TxtSize.Height() > rRect.Bottom()) + rDev.SetClipRegion( rRect ); + + // allow for a disabled control ... + sal_Bool bEnabled = IsEnabled(); + Color aOriginalColor = rDev.GetTextColor(); + if( ! bEnabled ) + rDev.SetTextColor( GetSettings().GetStyleSettings().GetDisableColor() ); + + // TEST +// if( nColumnId == 1 ) +// // categories +// rDev.SetFillColor( Color( 0xff, 0xff, 0xff )); +// else if( nColumnId == 2 ) +// // x-values +// rDev.SetFillColor( Color( 0xf0, 0xf0, 0xff )); +// else +// // y-values +// rDev.SetFillColor( Color( 0xff, 0xff, 0xf0 )); + +// rDev.DrawRect( rRect ); + + // draw the text + rDev.DrawText( aPos, aText ); + + // reset the color (if necessary) + if( ! bEnabled ) + rDev.SetTextColor( aOriginalColor ); + + if( rDev.IsClipRegion()) + rDev.SetClipRegion(); +} + +sal_Bool DataBrowser::SeekRow( long nRow ) +{ + if( ! EditBrowseBox::SeekRow( nRow )) + return sal_False; + + if( nRow < 0 ) + m_nSeekRow = - 1; + else + m_nSeekRow = nRow; + + return sal_True; +} + +sal_Bool DataBrowser::IsTabAllowed( sal_Bool bForward ) const +{ + long nRow = GetCurRow(); + long nCol = GetCurColumnId(); + + // column 0 is header-column + long nBadCol = bForward + ? GetColumnCount() - 1 + : 1; + long nBadRow = bForward + ? GetRowCount() - 1 + : 0; + + if( !m_bDataValid ) + { + const_cast< DataBrowser* >( this )->ShowWarningBox(); + return sal_False; + } + + return ( nRow != nBadRow || + nCol != nBadCol ); +} + +::svt::CellController* DataBrowser::GetController( long nRow, sal_uInt16 nCol ) +{ + if( m_bIsReadOnly ) + return 0; + + if( CellContainsNumbers( nRow, nCol )) + { + m_aNumberEditField.UseInputStringForFormatting(); + m_aNumberEditField.SetFormatKey( GetNumberFormatKey( nRow, nCol )); + return m_rNumberEditController; + } + + return m_rTextEditController; +} + +void DataBrowser::InitController( + ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ) +{ + if( rController == m_rTextEditController ) + { + String aText( GetCellText( nRow, nCol ) ); + m_aTextEditField.SetText( aText ); + m_aTextEditField.SetSelection( Selection( 0, aText.Len() )); + } + else if( rController == m_rNumberEditController ) + { + // treat invalid and empty text as Nan + m_aNumberEditField.EnableNotANumber( true ); + if( ::rtl::math::isNan( GetCellNumber( nRow, nCol ))) + m_aNumberEditField.SetTextValue( String()); + else + m_aNumberEditField.SetValue( GetCellNumber( nRow, nCol ) ); + String aText( m_aNumberEditField.GetText()); + m_aNumberEditField.SetSelection( Selection( 0, aText.Len())); + } + else + { + DBG_ERROR( "Invalid Controller" ); + } +} + +bool DataBrowser::CellContainsNumbers( sal_Int32 nRow, sal_uInt16 nCol ) const +{ + if( ! m_apDataBrowserModel.get()) + return false; + return (m_apDataBrowserModel->getCellType( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )) == + DataBrowserModel::NUMBER); +} + +sal_uInt32 DataBrowser::GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const +{ + if( ! m_apDataBrowserModel.get()) + return 0; + return m_apDataBrowserModel->getNumberFormatKey( lcl_getColumnInData( nCol ), lcl_getRowInData( nRow )); +} + +sal_Bool DataBrowser::SaveModified() +{ + if( ! IsModified() ) + return sal_True; + + sal_Bool bChangeValid = sal_True; + + const sal_Int32 nRow = lcl_getRowInData( GetCurRow()); + const sal_Int32 nCol = lcl_getColumnInData( GetCurColumnId()); + + DBG_ASSERT( nRow >= 0 || nCol >= 0, "This cell should not be modified!" ); + + switch( m_apDataBrowserModel->getCellType( nCol, nRow )) + { + case DataBrowserModel::NUMBER: + { + sal_uInt32 nDummy = 0; + double fDummy = 0.0; + String aText( m_aNumberEditField.GetText()); + // an empty string is valid, if no numberformatter exists, all + // values are treated as valid + if( aText.Len() > 0 && + m_spNumberFormatterWrapper.get() && + m_spNumberFormatterWrapper->getSvNumberFormatter() && + ! m_spNumberFormatterWrapper->getSvNumberFormatter()->IsNumberFormat( + aText, nDummy, fDummy )) + { + bChangeValid = sal_False; + } + else + { + double fData = m_aNumberEditField.GetValue(); + bChangeValid = m_apDataBrowserModel->setCellNumber( nCol, nRow, fData ); + } + } + break; + case DataBrowserModel::TEXT: + { + OUString aText( m_aTextEditField.GetText()); + bChangeValid = m_apDataBrowserModel->setCellText( nCol, nRow, aText ); + } + break; + } + + // the first valid change changes this to true + if( bChangeValid ) + { + RowModified( GetCurRow(), GetCurColumnId()); + ::svt::CellController* pCtrl = GetController( GetCurRow(), GetCurColumnId()); + if( pCtrl ) + pCtrl->ClearModified(); + SetDirty(); + } + + return bChangeValid; +} + +bool DataBrowser::EndEditing() +{ + if( IsModified()) + SaveModified(); + + // apply changes made to series headers + ::std::for_each( m_aSeriesHeaders.begin(), m_aSeriesHeaders.end(), impl::applyChangesFunctor()); + + if( m_bDataValid ) + return true; + else + return ShowQueryBox(); +} + +sal_Int16 DataBrowser::GetFirstVisibleColumNumber() const +{ + return GetFirstVisibleColNumber(); +} + +void DataBrowser::ColumnResized( USHORT nColId ) +{ + BOOL bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( FALSE ); + + EditBrowseBox::ColumnResized( nColId ); + ImplAdjustHeaderControls(); + SetUpdateMode( bLastUpdateMode ); +} + +// virtual void MouseMove( const MouseEvent& rEvt ); + +void DataBrowser::EndScroll() +{ + BOOL bLastUpdateMode = GetUpdateMode(); + SetUpdateMode( FALSE ); + + EditBrowseBox::EndScroll(); + RenewSeriesHeaders(); + + SetUpdateMode( bLastUpdateMode ); +} + +void DataBrowser::RenewSeriesHeaders() +{ + Window * pWin = this->GetParent(); + if( !pWin ) + pWin = this; + + clearHeaders(); + DataBrowserModel::tDataHeaderVector aHeaders( m_apDataBrowserModel->getDataHeaders()); + Link aFocusLink( LINK( this, DataBrowser, SeriesHeaderGotFocus )); + Link aSeriesHeaderChangedLink( LINK( this, DataBrowser, SeriesHeaderChanged )); + bool bIsHighContrast = pWin ? (pWin->GetSettings().GetStyleSettings().GetHighContrastMode()) : false; + + for( DataBrowserModel::tDataHeaderVector::const_iterator aIt( aHeaders.begin()); + aIt != aHeaders.end(); ++aIt ) + { + ::boost::shared_ptr< impl::SeriesHeader > spHeader( new impl::SeriesHeader( pWin )); + Reference< beans::XPropertySet > xSeriesProp( aIt->m_xDataSeries, uno::UNO_QUERY ); + sal_Int32 nColor = 0; + if( xSeriesProp.is() && + ( xSeriesProp->getPropertyValue( OUString( RTL_CONSTASCII_USTRINGPARAM("Color"))) >>= nColor )) + spHeader->SetColor( Color( nColor )); + spHeader->SetChartType( aIt->m_xChartType, aIt->m_bSwapXAndYAxis, bIsHighContrast ); + spHeader->SetSeriesName( + String( DataSeriesHelper::getDataSeriesLabel( + aIt->m_xDataSeries, + (aIt->m_xChartType.is() ? + aIt->m_xChartType->getRoleOfSequenceForSeriesLabel() : + OUString( RTL_CONSTASCII_USTRINGPARAM("values-y")))))); + spHeader->SetRange( aIt->m_nStartColumn + 1, aIt->m_nEndColumn + 1 ); + spHeader->SetGetFocusHdl( aFocusLink ); + spHeader->SetEditChangedHdl( aSeriesHeaderChangedLink ); + m_aSeriesHeaders.push_back( spHeader ); + } + + ImplAdjustHeaderControls(); +} + +void DataBrowser::ImplAdjustHeaderControls() +{ + sal_uInt16 nColCount = this->GetColumnCount(); + sal_uInt32 nCurrentPos = this->GetPosPixel().getX(); + sal_uInt32 nMaxPos = nCurrentPos + this->GetOutputSizePixel().getWidth(); + sal_uInt32 nStartPos = nCurrentPos; + + // width of header column + nCurrentPos += this->GetColumnWidth( 0 ); + tSeriesHeaderContainer::iterator aIt( m_aSeriesHeaders.begin()); + sal_uInt16 i = this->GetFirstVisibleColumNumber(); + while( (aIt != m_aSeriesHeaders.end()) && ((*aIt)->GetStartColumn() < i) ) + ++aIt; + for( ; i < nColCount && aIt != m_aSeriesHeaders.end(); ++i ) + { + if( (*aIt)->GetStartColumn() == i ) + nStartPos = nCurrentPos; + + nCurrentPos += (this->GetColumnWidth( i )); + + if( (*aIt)->GetEndColumn() == i ) + { + if( nStartPos < nMaxPos ) + { + (*aIt)->SetPixelPosX( nStartPos + 2 ); + (*aIt)->SetPixelWidth( nCurrentPos - nStartPos - 3 ); + } + else + // do not hide, to get focus events. Move outside the dialog for "hiding" + (*aIt)->SetPixelPosX( nMaxPos + 42 ); + ++aIt; + } + } +} + +IMPL_LINK( DataBrowser, SeriesHeaderGotFocus, impl::SeriesHeaderEdit*, pEdit ) +{ + if( pEdit ) + { + pEdit->SetShowWarningBox( !m_bDataValid ); + + if( !m_bDataValid ) + GoToCell( 0, 0 ); + else + { + //DeactivateCell(); + MakeFieldVisible( GetCurRow(), static_cast< sal_uInt16 >( pEdit->getStartColumn()), true /* bComplete */ ); + ActivateCell(); + m_aCursorMovedHdlLink.Call( this ); + } + } + return 0; +} + +IMPL_LINK( DataBrowser, SeriesHeaderChanged, impl::SeriesHeaderEdit*, pEdit ) +{ + if( pEdit ) + { + Reference< chart2::XDataSeries > xSeries( + m_apDataBrowserModel->getDataSeriesByColumn( pEdit->getStartColumn() - 1 )); + Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); + if( xSource.is()) + { + Reference< chart2::XChartType > xChartType( + m_apDataBrowserModel->getHeaderForSeries( xSeries ).m_xChartType ); + if( xChartType.is()) + { + Reference< chart2::data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, xChartType->getRoleOfSequenceForSeriesLabel())); + if( xLabeledSeq.is()) + { + Reference< container::XIndexReplace > xIndexReplace( xLabeledSeq->getLabel(), uno::UNO_QUERY ); + if( xIndexReplace.is()) + xIndexReplace->replaceByIndex( + 0, uno::makeAny( OUString( pEdit->GetText()))); + } + } + } + } + return 0; +} + +sal_Int32 DataBrowser::GetTotalWidth() const +{ + ULONG nWidth = 0; + for ( USHORT nCol = 0; nCol < ColCount(); ++nCol ) + nWidth += GetColumnWidth( nCol ); + return static_cast< sal_Int32 >( nWidth ); +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/DataBrowser.hxx b/chart2/source/controller/dialogs/DataBrowser.hxx new file mode 100644 index 000000000000..a4147af84fcb --- /dev/null +++ b/chart2/source/controller/dialogs/DataBrowser.hxx @@ -0,0 +1,209 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataBrowser.hxx,v $ + * $Revision: 1.6.8.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef CHART_DATA_BROWSER_HXX +#define CHART_DATA_BROWSER_HXX + +#include <svtools/editbrowsebox.hxx> +#include <vcl/outdev.hxx> +#include <svtools/fmtfield.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <vector> +#include <memory> +#include <boost/shared_ptr.hpp> + +namespace com { namespace sun { namespace star { + namespace chart2 { + class XChartDocument; + } +}}} + +namespace chart +{ + +class DataBrowserModel; +class NumberFormatterWrapper; + +namespace impl +{ +class SeriesHeader; +class SeriesHeaderEdit; +} + +class DataBrowser : public ::svt::EditBrowseBox +{ +protected: + // EditBrowseBox overridables + virtual void PaintCell( OutputDevice& rDev, const Rectangle& rRect, sal_uInt16 nColumnId ) const; + virtual sal_Bool SeekRow( long nRow ); + virtual sal_Bool IsTabAllowed( sal_Bool bForward ) const; + virtual ::svt::CellController* GetController( long nRow, sal_uInt16 nCol ); + virtual void InitController( ::svt::CellControllerRef& rController, long nRow, sal_uInt16 nCol ); + virtual sal_Bool SaveModified(); + virtual void CursorMoved(); + // called whenever the control of the current cell has been modified + virtual void CellModified(); + virtual void ColumnResized( USHORT nColId ); + virtual void EndScroll(); + virtual void MouseButtonDown( const BrowserMouseEvent& rEvt ); + + void SetDirty(); + +public: + DataBrowser( Window* pParent, const ResId & rId, bool bLiveUpdate ); + virtual ~DataBrowser(); + + /** GetCellText returns the text at the given position + @param nRow + the number of the row + @param nColId + the ID of the column + @return + the text out of the cell + */ + virtual String GetCellText(long nRow, USHORT nColId) const; + + /** returns the number in the given cell. If a cell is empty or contains a + string, the result will be Nan + */ + double GetCellNumber( long nRow, USHORT nColumnId ) const; + + // Window + virtual void Resize(); + + /// @return old state + bool SetReadOnly( bool bNewState ); + bool IsReadOnly() const; + + /// reset the dirty status, if changes have been saved + void SetClean(); + + void SetDataFromModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + +// void setNumberFormatter(); + + // predicates to determine what actions are possible at the current cursor + // position. This depends on the implementation of the according mutators + // below. (They are used for enabling toolbar icons) + bool MayInsertRow() const; + bool MayInsertColumn() const; + bool MayDeleteRow() const; + bool MayDeleteColumn() const; + + bool MaySwapRows() const; + bool MaySwapColumns() const; + +// bool MaySortRow() const; +// bool MaySortColumn() const; + + // mutators mutating data + void InsertRow(); + void InsertColumn(); + void RemoveRow(); + void RemoveColumn(); + + using BrowseBox::RemoveColumn; + using BrowseBox::MouseButtonDown; + + void SwapRow(); + void SwapColumn(); + + void SetCursorMovedHdl( const Link& rLink ); + + void SetCellModifiedHdl( const Link& rLink ); + + /// confirms all pending changes to be ready to be closed + bool EndEditing(); + + // calls the protected inline-function BrowseBox::GetFirstVisibleColNumber() + sal_Int16 GetFirstVisibleColumNumber() const; + + sal_Int32 GetTotalWidth() const; + + bool CellContainsNumbers( sal_Int32 nRow, sal_uInt16 nCol ) const; + + sal_uInt32 GetNumberFormatKey( sal_Int32 nRow, sal_uInt16 nCol ) const; + + bool IsEnableItem(); + bool IsDataValid(); + void ShowWarningBox(); + bool ShowQueryBox(); + + void RenewSeriesHeaders(); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDoc; + ::std::auto_ptr< DataBrowserModel > m_apDataBrowserModel; + + typedef ::std::vector< ::boost::shared_ptr< impl::SeriesHeader > > tSeriesHeaderContainer; + tSeriesHeaderContainer m_aSeriesHeaders; + + ::boost::shared_ptr< NumberFormatterWrapper > m_spNumberFormatterWrapper; + + /// the row that is currently painted + long m_nSeekRow; + bool m_bIsReadOnly; + bool m_bIsDirty; + bool m_bLiveUpdate; + bool m_bDataValid; + + FormattedField m_aNumberEditField; + Edit m_aTextEditField; + + /// note: m_aNumberEditField must precede this member! + ::svt::CellControllerRef m_rNumberEditController; + /// note: m_aTextEditField must precede this member! + ::svt::CellControllerRef m_rTextEditController; + + Link m_aCursorMovedHdlLink; + Link m_aCellModifiedLink; + + void clearHeaders(); + void RenewTable(); + void ImplAdjustHeaderControls(); + + String GetColString( sal_Int32 nColumnId ) const; + String GetRowString( sal_Int32 nRow ) const; + + DECL_LINK( SeriesHeaderGotFocus, impl::SeriesHeaderEdit* ); + DECL_LINK( SeriesHeaderChanged, impl::SeriesHeaderEdit* ); + + /// not implemented: inhibit copy construction + DataBrowser( const DataBrowser & ); +}; + +} // namespace chart + +#endif // CHART_DATA_BROWSER_HXX diff --git a/chart2/source/controller/dialogs/DataBrowserModel.cxx b/chart2/source/controller/dialogs/DataBrowserModel.cxx new file mode 100644 index 000000000000..1db67c6721af --- /dev/null +++ b/chart2/source/controller/dialogs/DataBrowserModel.cxx @@ -0,0 +1,926 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataBrowserModel.cxx,v $ + * $Revision: 1.6.16.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "DataBrowserModel.hxx" +#include "DialogModel.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "PropertyHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "macros.hxx" +#include "StatisticsHelper.hxx" +#include "ContainerHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "chartview/ExplicitValueProvider.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/XDataSink.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 <rtl/math.hxx> + +#include <algorithm> + +#if OSL_DEBUG_LEVEL > 1 +#include <cstdio> +#endif + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ +OUString lcl_getRole( + const Reference< chart2::data::XDataSequence > & xSeq ) +{ + OUString aResult; + Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY ); + if( xProp.is()) + { + try + { + xProp->getPropertyValue( C2U("Role")) >>= aResult; + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + return aResult; +} + + +OUString lcl_getRole( + const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) +{ + OUString aResult; + if( xLSeq.is()) + aResult = lcl_getRole( xLSeq->getValues()); + return aResult; +} + +OUString lcl_getUIRoleName( + const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) +{ + OUString aResult( lcl_getRole( xLSeq )); + if( aResult.getLength()) + aResult = ::chart::DialogModel::ConvertRoleFromInternalToUI( aResult ); + return aResult; +} + +void lcl_copyDataSequenceProperties( + const Reference< chart2::data::XDataSequence > & xOldSequence, + const Reference< chart2::data::XDataSequence > & xNewSequence ) +{ + Reference< beans::XPropertySet > xOldSeqProp( xOldSequence, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xNewSeqProp( xNewSequence, uno::UNO_QUERY ); + comphelper::copyProperties( xOldSeqProp, xNewSeqProp ); +} + +bool lcl_SequenceOfSeriesIsShared( + const Reference< chart2::XDataSeries > & xSeries, + const Reference< chart2::data::XDataSequence > & xValues ) +{ + bool bResult = false; + if( !xValues.is()) + return bResult; + try + { + OUString aValuesRole( lcl_getRole( xValues )); + OUString aValuesRep( xValues->getSourceRangeRepresentation()); + Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); + for( sal_Int32 i=0; i<aLSeq.getLength(); ++i ) + if( aLSeq[i].is() && + lcl_getRole( aLSeq[i] ).equals( aValuesRole )) + { + // getValues().is(), because lcl_getRole checked that already + bResult = (aValuesRep == aLSeq[i]->getValues()->getSourceRangeRepresentation()); + // assumption: a role appears only once in a series + break; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return bResult; +} + +typedef ::std::vector< Reference< chart2::data::XLabeledDataSequence > > lcl_tSharedSeqVec; + +lcl_tSharedSeqVec lcl_getSharedSequences( const Sequence< Reference< chart2::XDataSeries > > & 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 ) + return aResult; + + Reference< chart2::data::XDataSource > xSource( rSeries[0], uno::UNO_QUERY ); + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeq( xSource->getDataSequences()); + for( sal_Int32 nIdx=0; nIdx<aLSeq.getLength(); ++nIdx ) + { + Reference< chart2::data::XDataSequence > xValues( aLSeq[nIdx]->getValues()); + bool bShared = true; + for( sal_Int32 nSeriesIdx=1; nSeriesIdx<rSeries.getLength(); ++nSeriesIdx ) + { + bShared = lcl_SequenceOfSeriesIsShared( rSeries[nSeriesIdx], xValues ); + if( !bShared ) + break; + } + if( bShared ) + aResult.push_back( aLSeq[nIdx] ); + } + + return aResult; +} + +sal_Int32 lcl_getValuesRepresentationIndex( + const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) +{ + sal_Int32 nResult = -1; + if( xLSeq.is()) + { + Reference< chart2::data::XDataSequence > xSeq( xLSeq->getValues()); + if( xSeq.is()) + { + OUString aRep( xSeq->getSourceRangeRepresentation()); + nResult = aRep.toInt32(); + } + } + return nResult; +} + +struct lcl_RepresentationsOfLSeqMatch : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +{ + lcl_RepresentationsOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : + m_aValuesRep( xLSeq.is() ? + (xLSeq->getValues().is() ? xLSeq->getValues()->getSourceRangeRepresentation() : OUString()) + : OUString() ) + {} + bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) + { + return (xLSeq.is() && + xLSeq->getValues().is() && + (xLSeq->getValues()->getSourceRangeRepresentation() == m_aValuesRep )); + } +private: + OUString m_aValuesRep; +}; + +struct lcl_RolesOfLSeqMatch : public ::std::unary_function< Reference< chart2::data::XLabeledDataSequence >, bool > +{ + lcl_RolesOfLSeqMatch( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) : + m_aRole( lcl_getRole( xLSeq )) + {} + bool operator() ( const Reference< chart2::data::XLabeledDataSequence > & xLSeq ) + { + return lcl_getRole( xLSeq ).equals( m_aRole ); + } +private: + OUString m_aRole; +}; + +bool lcl_ShowCategories( const Reference< chart2::XDiagram > & /* xDiagram */ ) +{ + // show categories for all charts + return true; +// return DiagramHelper::isCategoryDiagram( xDiagram ); +} + +bool lcl_ShowCategoriesAsDataLabel( const Reference< chart2::XDiagram > & xDiagram ) +{ + return ! ::chart::DiagramHelper::isCategoryDiagram( xDiagram ); +} + +} // anonymous namespace + +namespace chart +{ + + +struct DataBrowserModel::tDataColumn +{ + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > m_xDataSeries; + sal_Int32 m_nIndexInDataSeries; + ::rtl::OUString m_aUIRoleName; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence > m_xLabeledDataSequence; + eCellType m_eCellType; + sal_Int32 m_nNumberFormatKey; + + // default CTOR + tDataColumn() : m_nIndexInDataSeries( -1 ), m_eCellType( TEXT ), m_nNumberFormatKey( 0 ) {} + // "full" CTOR + tDataColumn( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xDataSeries, + sal_Int32 nIndexInDataSeries, + ::rtl::OUString aUIRoleName, + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence > xLabeledDataSequence, + eCellType aCellType, + sal_Int32 nNumberFormatKey ) : + m_xDataSeries( xDataSeries ), + m_nIndexInDataSeries( nIndexInDataSeries ), + m_aUIRoleName( aUIRoleName ), + m_xLabeledDataSequence( xLabeledDataSequence ), + m_eCellType( aCellType ), + m_nNumberFormatKey( nNumberFormatKey ) + {} +}; + +struct DataBrowserModel::implColumnLess : public ::std::binary_function< + DataBrowserModel::tDataColumn, DataBrowserModel::tDataColumn, bool > +{ + bool operator() ( const first_argument_type & rLeft, const second_argument_type & rRight ) + { + if( rLeft.m_xLabeledDataSequence.is() && rRight.m_xLabeledDataSequence.is()) + { + return DialogModel::GetRoleIndexForSorting( lcl_getRole( rLeft.m_xLabeledDataSequence )) < + DialogModel::GetRoleIndexForSorting( lcl_getRole( rRight.m_xLabeledDataSequence )); + } + return true; + } +}; + +DataBrowserModel::DataBrowserModel( + const Reference< chart2::XChartDocument > & xChartDoc, + const Reference< uno::XComponentContext > & xContext ) : + m_xChartDocument( xChartDoc ), + m_xContext( xContext ), + m_apDialogModel( new DialogModel( xChartDoc, xContext )) +{ + updateFromModel(); +} + +DataBrowserModel::~DataBrowserModel() +{} + +namespace +{ +struct lcl_DataSeriesOfHeaderMatches : public ::std::unary_function< ::chart::DataBrowserModel::tDataHeader, bool > +{ + lcl_DataSeriesOfHeaderMatches( + const Reference< chart2::XDataSeries > & xSeriesToCompareWith ) : + m_xSeries( xSeriesToCompareWith ) + {} + bool operator() ( const ::chart::DataBrowserModel::tDataHeader & rHeader ) + { + return (m_xSeries == rHeader.m_xDataSeries); + } +private: + Reference< chart2::XDataSeries > m_xSeries; +}; +} + +void DataBrowserModel::insertDataSeries( sal_Int32 nAfterColumnIndex ) +{ + OSL_ASSERT( m_apDialogModel.get()); + Reference< chart2::XInternalDataProvider > xDataProvider( + m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); + if( xDataProvider.is()) + { + sal_Int32 nStartCol = 0; + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); + Reference< chart2::XChartType > xChartType; + Reference< chart2::XDataSeries > xSeries; + if( static_cast< tDataColumnVector::size_type >( nAfterColumnIndex ) <= m_aColumns.size()) + xSeries.set( m_aColumns[nAfterColumnIndex].m_xDataSeries ); + + sal_Int32 nSeriesNumberFormat = 0; + if( xSeries.is()) + { + xChartType.set( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries )); + tDataHeaderVector::const_iterator aIt( + ::std::find_if( m_aHeaders.begin(), m_aHeaders.end(), + lcl_DataSeriesOfHeaderMatches( xSeries ))); + if( aIt != m_aHeaders.end()) + nStartCol = aIt->m_nEndColumn; + + Reference< beans::XPropertySet > xSeriesProps( xSeries, uno::UNO_QUERY ); + if( xSeriesProps.is() ) + xSeriesProps->getPropertyValue( C2U( "NumberFormat" )) >>= nSeriesNumberFormat; + } + else + { + xChartType.set( DiagramHelper::getChartTypeByIndex( xDiagram, 0 )); + nStartCol = nAfterColumnIndex; + } + + if( xChartType.is()) + { + sal_Int32 nOffset = 0; + if( xDiagram.is() && lcl_ShowCategories( xDiagram )) + ++nOffset; + // get shared sequences of current series + Reference< chart2::XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY ); + lcl_tSharedSeqVec aSharedSequences; + if( xSeriesCnt.is()) + aSharedSequences = lcl_getSharedSequences( xSeriesCnt->getDataSeries()); + Reference< chart2::XDataSeries > xNewSeries( + m_apDialogModel->insertSeriesAfter( xSeries, xChartType, true /* bCreateDataCachedSequences */ )); + if( xNewSeries.is()) + { + { + Reference< chart2::data::XDataSource > xSource( xNewSeries, uno::UNO_QUERY ); + if( xSource.is()) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSequences( + xSource->getDataSequences()); + sal_Int32 nSeqIdx = 0; + sal_Int32 nSeqSize = aLSequences.getLength(); + nStartCol -= (nOffset - 1); + for( sal_Int32 nIndex = nStartCol; + (nSeqIdx < nSeqSize); + ++nSeqIdx ) + { + lcl_tSharedSeqVec::const_iterator aSharedIt( + ::std::find_if( aSharedSequences.begin(), aSharedSequences.end(), + lcl_RolesOfLSeqMatch( aLSequences[nSeqIdx] ))); + if( aSharedIt != aSharedSequences.end()) + { + aLSequences[nSeqIdx]->setValues( (*aSharedIt)->getValues()); + aLSequences[nSeqIdx]->setLabel( (*aSharedIt)->getLabel()); + } + else + { + xDataProvider->insertSequence( nIndex - 1 ); + + // values + Reference< chart2::data::XDataSequence > xNewSeq( + xDataProvider->createDataSequenceByRangeRepresentation( + OUString::valueOf( nIndex ))); + lcl_copyDataSequenceProperties( + aLSequences[nSeqIdx]->getValues(), xNewSeq ); + aLSequences[nSeqIdx]->setValues( xNewSeq ); + + // labels + Reference< chart2::data::XDataSequence > xNewLabelSeq( + xDataProvider->createDataSequenceByRangeRepresentation( + OUString( RTL_CONSTASCII_USTRINGPARAM( "label " )) + + OUString::valueOf( 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 immidiately + Reference< beans::XPropertySet > xNewSeriesProps( xNewSeries, uno::UNO_QUERY ); + if( xNewSeriesProps.is() ) + xNewSeriesProps->setPropertyValue( C2U( "NumberFormat" ), uno::makeAny( nSeriesNumberFormat ) ); + } + + updateFromModel(); + } + } + } +} + +void DataBrowserModel::removeDataSeries( sal_Int32 nAtColumnIndex ) +{ + OSL_ASSERT( m_apDialogModel.get()); + if( static_cast< tDataColumnVector::size_type >( nAtColumnIndex ) < m_aColumns.size()) + { + Reference< chart2::XDataSeries > xSeries( m_aColumns[nAtColumnIndex].m_xDataSeries ); + if( xSeries.is()) + { + m_apDialogModel->deleteSeries( + xSeries, getHeaderForSeries( xSeries ).m_xChartType ); + + //delete sequences from internal data provider that are not used anymore + //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 > xSourceOfDeletedSeries( xSeries, uno::UNO_QUERY ); + if( xDataProvider.is() && xSourceOfDeletedSeries.is()) + { + ::std::vector< sal_Int32 > aSequenceIndexesToDelete; + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequencesOfDeletedSeries( xSourceOfDeletedSeries->getDataSequences() ); + Reference< chart2::XDataSeriesContainer > xSeriesCnt( getHeaderForSeries( xSeries ).m_xChartType, uno::UNO_QUERY ); + if( xSeriesCnt.is()) + { + Reference< chart2::data::XDataSource > xRemainingDataSource( DataSeriesHelper::getDataSource( xSeriesCnt->getDataSeries() ) ); + if( xRemainingDataSource.is() ) + { + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aRemainingSeq( ContainerHelper::SequenceToVector( xRemainingDataSource->getDataSequences() ) ); + for( sal_Int32 i=0; i<aSequencesOfDeletedSeries.getLength(); ++i ) + { + ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aHitIt( + ::std::find_if( aRemainingSeq.begin(), aRemainingSeq.end(), + lcl_RepresentationsOfLSeqMatch( aSequencesOfDeletedSeries[i] ))); + // if not used by the remaining series this sequence can be deleted + if( aHitIt == aRemainingSeq.end() ) + aSequenceIndexesToDelete.push_back( lcl_getValuesRepresentationIndex( aSequencesOfDeletedSeries[i] ) ); + } + } + } + + // delete unnecessary sequences of the internal data + // iterate using greatest index first, so that deletion does not + // shift other sequences that will be deleted later + ::std::sort( aSequenceIndexesToDelete.begin(), aSequenceIndexesToDelete.end()); + for( ::std::vector< sal_Int32 >::reverse_iterator aIt( + aSequenceIndexesToDelete.rbegin()); aIt != aSequenceIndexesToDelete.rend(); ++aIt ) + { + if( *aIt != -1 ) + xDataProvider->deleteSequence( *aIt ); + } + } + updateFromModel(); + } + } +} + +void DataBrowserModel::swapDataSeries( sal_Int32 nFirstColumnIndex ) +{ + OSL_ASSERT( m_apDialogModel.get()); + if( static_cast< tDataColumnVector::size_type >( nFirstColumnIndex ) < m_aColumns.size() - 1 ) + { + Reference< chart2::XDataSeries > xSeries( m_aColumns[nFirstColumnIndex].m_xDataSeries ); + if( xSeries.is()) + { + m_apDialogModel->moveSeries( xSeries, DialogModel::MOVE_DOWN ); + updateFromModel(); + } + } +} + +void DataBrowserModel::swapDataPointForAllSeries( sal_Int32 nFirstIndex ) +{ + OSL_ASSERT( m_apDialogModel.get()); + Reference< chart2::XInternalDataProvider > xDataProvider( + m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); + // lockControllers + ControllerLockGuard aGuard( m_apDialogModel->getChartModel()); + if( xDataProvider.is()) + xDataProvider->swapDataPointWithNextOneForAllSequences( nFirstIndex ); + // unlockControllers +} + +void DataBrowserModel::insertDataPointForAllSeries( sal_Int32 nAfterIndex ) +{ + Reference< chart2::XInternalDataProvider > xDataProvider( + m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); + // lockControllers + ControllerLockGuard aGuard( m_apDialogModel->getChartModel()); + if( xDataProvider.is()) + xDataProvider->insertDataPointForAllSequences( nAfterIndex ); + // unlockControllers +} + +void DataBrowserModel::removeDataPointForAllSeries( sal_Int32 nAtIndex ) +{ + Reference< chart2::XInternalDataProvider > xDataProvider( + m_apDialogModel->getDataProvider(), uno::UNO_QUERY ); + // lockControllers + ControllerLockGuard aGuard( m_apDialogModel->getChartModel()); + if( xDataProvider.is()) + xDataProvider->deleteDataPointForAllSequences( nAtIndex ); + // unlockControllers +} + +DataBrowserModel::tDataHeader DataBrowserModel::getHeaderForSeries( + const Reference< chart2::XDataSeries > & xSeries ) const +{ + for( tDataHeaderVector::const_iterator aIt( m_aHeaders.begin()); + aIt != m_aHeaders.end(); ++aIt ) + { + if( aIt->m_xDataSeries == xSeries ) + return (*aIt); + } + return tDataHeader(); +} + +Reference< chart2::XDataSeries > + DataBrowserModel::getDataSeriesByColumn( sal_Int32 nColumn ) const +{ + tDataColumnVector::size_type nIndex( nColumn ); + if( nIndex < m_aColumns.size()) + return m_aColumns[nIndex].m_xDataSeries; + return 0; +} + +DataBrowserModel::eCellType DataBrowserModel::getCellType( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) +{ + eCellType eResult = TEXT; + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size()) + eResult = m_aColumns[nIndex].m_eCellType; + return eResult; +} + +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()) + { + Reference< chart2::data::XNumericalDataSequence > xData( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY ); + if( xData.is()) + { + Sequence< double > aValues( xData->getNumericalData()); + if( nAtRow < aValues.getLength()) + fResult = aValues[nAtRow]; + } + } + return fResult; +} + +OUString DataBrowserModel::getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ) +{ + OUString aResult; + + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size() && + m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) + { + Reference< chart2::data::XTextualDataSequence > xData( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY ); + if( xData.is()) + { + Sequence< OUString > aValues( xData->getTextualData()); + if( nAtRow < aValues.getLength()) + aResult = aValues[nAtRow]; + } + } + return aResult; +} + +sal_uInt32 DataBrowserModel::getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 /* nAtRow */ ) +{ + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size()) + return m_aColumns[ nIndex ].m_nNumberFormatKey; + return 0; +} + +bool DataBrowserModel::setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const uno::Any & rValue ) +{ + bool bResult = false; + tDataColumnVector::size_type nIndex( nAtColumn ); + if( nIndex < m_aColumns.size() && + m_aColumns[ nIndex ].m_xLabeledDataSequence.is()) + { + bResult = true; + try + { + // label + if( nAtRow == -1 ) + { + Reference< container::XIndexReplace > xIndexReplace( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getLabel(), uno::UNO_QUERY_THROW ); + xIndexReplace->replaceByIndex( 0, rValue ); + } + else + { + Reference< container::XIndexReplace > xIndexReplace( + m_aColumns[ nIndex ].m_xLabeledDataSequence->getValues(), uno::UNO_QUERY_THROW ); + xIndexReplace->replaceByIndex( nAtRow, rValue ); + } + } + catch( const uno::Exception & ex ) + { + (void)(ex); + bResult = false; + } + } + return bResult; +} + +bool DataBrowserModel::setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ) +{ + return (getCellType( nAtColumn, nAtRow ) == NUMBER) && + setCellAny( nAtColumn, nAtRow, uno::makeAny( fValue )); +} + +bool DataBrowserModel::setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText ) +{ + return (getCellType( nAtColumn, nAtRow ) == TEXT) && + setCellAny( nAtColumn, nAtRow, uno::makeAny( rText )); +} + +sal_Int32 DataBrowserModel::getColumnCount() const +{ + return static_cast< sal_Int32 >( m_aColumns.size()); +} + +sal_Int32 DataBrowserModel::getMaxRowCount() const +{ + sal_Int32 nResult = 0; + tDataColumnVector::const_iterator aIt( m_aColumns.begin()); + for( ; aIt != m_aColumns.end(); ++aIt ) + { + if( aIt->m_xLabeledDataSequence.is()) + { + Reference< chart2::data::XDataSequence > xSeq( + aIt->m_xLabeledDataSequence->getValues()); + if( !xSeq.is()) + continue; + sal_Int32 nLength( xSeq->getData().getLength()); + if( nLength > nResult ) + nResult = nLength; + } + } + + return nResult; +} + +OUString DataBrowserModel::getRoleOfColumn( sal_Int32 nColumnIndex ) const +{ + if( nColumnIndex != -1 && + static_cast< sal_uInt32 >( nColumnIndex ) < m_aColumns.size()) + return m_aColumns[ nColumnIndex ].m_aUIRoleName; + return OUString(); +} + +Reference< chart2::data::XLabeledDataSequence > + DataBrowserModel::getCategories() const throw() +{ + OSL_ASSERT( m_apDialogModel.get()); + return m_apDialogModel->getCategories(); +} + +const DataBrowserModel::tDataHeaderVector& DataBrowserModel::getDataHeaders() const +{ + return m_aHeaders; +} + +void DataBrowserModel::updateFromModel() +{ + if( !m_xChartDocument.is()) + return; + m_aColumns.clear(); + m_aHeaders.clear(); + + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_xChartDocument )); + 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 ); + + sal_Int32 nHeaderStart = 0; + sal_Int32 nHeaderEnd = 0; + if( lcl_ShowCategories( xDiagram )) + { + Reference< chart2::data::XLabeledDataSequence > xCategories( this->getCategories()); + tDataColumn aCategories; + aCategories.m_xLabeledDataSequence.set( xCategories ); + if( lcl_ShowCategoriesAsDataLabel( xDiagram )) + aCategories.m_aUIRoleName = DialogModel::GetRoleDataLabel(); + else + aCategories.m_aUIRoleName = lcl_getUIRoleName( xCategories ); + aCategories.m_eCellType = TEXT; + m_aColumns.push_back( aCategories ); + ++nHeaderStart; + } + + Reference< chart2::XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY ); + if( !xCooSysCnt.is()) + return; + Sequence< Reference< chart2::XCoordinateSystem > > aCooSysSeq( xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++nCooSysIdx ) + { + Reference< chart2::XChartTypeContainer > xCTCnt( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY_THROW ); + Sequence< Reference< chart2::XChartType > > aChartTypes( xCTCnt->getChartTypes()); + sal_Int32 nXAxisNumberFormat = DataSeriesHelper::getNumberFormatKeyFromAxis( 0, aCooSysSeq[nCooSysIdx], 0, 0 ); + + for( sal_Int32 nCTIdx=0; nCTIdx<aChartTypes.getLength(); ++nCTIdx ) + { + Reference< chart2::XDataSeriesContainer > xSeriesCnt( aChartTypes[nCTIdx], uno::UNO_QUERY ); + if( xSeriesCnt.is()) + { + rtl::OUString aRoleForDataLabelNumberFormat = ChartTypeHelper::getRoleOfSequenceForDataLabelNumberFormatDetection( aChartTypes[nCTIdx] ); + + Sequence< Reference< chart2::XDataSeries > > aSeries( xSeriesCnt->getDataSeries()); + lcl_tSharedSeqVec aSharedSequences( lcl_getSharedSequences( aSeries )); + for( lcl_tSharedSeqVec::const_iterator aIt( aSharedSequences.begin()); + aIt != aSharedSequences.end(); ++aIt ) + { + tDataColumn aSharedSequence; + aSharedSequence.m_xLabeledDataSequence = *aIt; + aSharedSequence.m_aUIRoleName = lcl_getUIRoleName( *aIt ); + 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( sal_Int32 nSeriesIdx=0; nSeriesIdx<aSeries.getLength(); ++nSeriesIdx ) + { + tDataColumnVector::size_type nStartColIndex = m_aColumns.size(); + Reference< chart2::XDataSeries > xSeries( aSeries[nSeriesIdx] ); + Reference< chart2::data::XDataSource > xSource( xSeries, uno::UNO_QUERY ); + if( xSource.is()) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aLSeqs( xSource->getDataSequences()); + if( aLSeqs.getLength() == 0 ) + continue; + nHeaderEnd = nHeaderStart; + + // @todo: dimension index 1 for y-values used here. This is just a guess + sal_Int32 nYAxisNumberFormatKey = + DataSeriesHelper::getNumberFormatKeyFromAxis( + aSeries[nSeriesIdx], aCooSysSeq[nCooSysIdx], 1 ); + + sal_Int32 nSeqIdx=0; + for( ; nSeqIdx<aLSeqs.getLength(); ++nSeqIdx ) + { + sal_Int32 nSequenceNumberFormatKey = nYAxisNumberFormatKey; + OUString aRole = lcl_getRole( aLSeqs[nSeqIdx] ); + + if( aRole.equals( aRoleForDataLabelNumberFormat ) ) + { + nSequenceNumberFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( + Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY ), xSeries, -1, xDiagram ); + } + else if( aRole.equals( C2U( "values-x" ) ) ) + nSequenceNumberFormatKey = nXAxisNumberFormat; + + if( ::std::find_if( aSharedSequences.begin(), aSharedSequences.end(), + lcl_RepresentationsOfLSeqMatch( aLSeqs[nSeqIdx] )) == aSharedSequences.end()) + { + // no shared sequence + m_aColumns.push_back( + tDataColumn( + aSeries[nSeriesIdx], + nSeqIdx, + lcl_getUIRoleName( aLSeqs[nSeqIdx] ), + aLSeqs[nSeqIdx], + NUMBER, + nSequenceNumberFormatKey )); + ++nHeaderEnd; + } + // else skip + } + bool bSwapXAndYAxis = false; + try + { + Reference< beans::XPropertySet > xProp( aCooSysSeq[nCooSysIdx], uno::UNO_QUERY ); + xProp->getPropertyValue( OUString(RTL_CONSTASCII_USTRINGPARAM("SwapXAndYAxis"))) >>= bSwapXAndYAxis; + } + catch( const beans::UnknownPropertyException & ex ) + { + (void)ex; + } + + // add ranges for error bars if present for a series + if( StatisticsHelper::usesErrorBarRanges( aSeries[nSeriesIdx], /* bYError = */ true )) + addErrorBarRanges( aSeries[nSeriesIdx], nYAxisNumberFormatKey, nSeqIdx, nHeaderEnd ); + + m_aHeaders.push_back( + tDataHeader( + aSeries[nSeriesIdx], + aChartTypes[nCTIdx], + bSwapXAndYAxis, + nHeaderStart, + nHeaderEnd - 1 )); + + nHeaderStart = nHeaderEnd; + + ::std::sort( m_aColumns.begin() + nStartColIndex, m_aColumns.end(), implColumnLess() ); + } + } + } + } + } +} + +void DataBrowserModel::addErrorBarRanges( + const Reference< chart2::XDataSeries > & xDataSeries, + sal_Int32 nNumberFormatKey, + sal_Int32 & rInOutSequenceIndex, + sal_Int32 & rInOutHeaderEnd ) +{ + try + { + ::std::vector< Reference< chart2::data::XLabeledDataSequence > > aSequences; + + // x error bars + // ------------ + Reference< chart2::data::XDataSource > xErrorSource( + StatisticsHelper::getErrorBars( xDataSeries, /* bYError = */ false ), uno::UNO_QUERY ); + + // positive x error bars + Reference< chart2::data::XLabeledDataSequence > xErrorLSequence( + StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( + xErrorSource, + /* bPositiveValue = */ true, + /* bYError = */ false )); + if( xErrorLSequence.is()) + aSequences.push_back( xErrorLSequence ); + + // negative x error bars + xErrorLSequence.set( + StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( + xErrorSource, + /* bPositiveValue = */ false, + /* bYError = */ false )); + if( xErrorLSequence.is()) + aSequences.push_back( xErrorLSequence ); + + // y error bars + // ------------ + xErrorSource.set( + StatisticsHelper::getErrorBars( xDataSeries, /* bYError = */ true ), uno::UNO_QUERY ); + + // positive y error bars + xErrorLSequence.set( + StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( + xErrorSource, + /* bPositiveValue = */ true, + /* bYError = */ true )); + if( xErrorLSequence.is()) + aSequences.push_back( xErrorLSequence ); + + // negative y error bars + xErrorLSequence.set( + StatisticsHelper::getErrorLabeledDataSequenceFromDataSource( + xErrorSource, + /* bPositiveValue = */ false, + /* bYError = */ true )); + if( xErrorLSequence.is()) + aSequences.push_back( xErrorLSequence ); + + + for( ::std::vector< Reference< chart2::data::XLabeledDataSequence > >::const_iterator aIt( aSequences.begin()); + aIt != aSequences.end(); ++aIt ) + { + m_aColumns.push_back( + tDataColumn( + xDataSeries, + rInOutSequenceIndex, + lcl_getUIRoleName( *aIt ), + *aIt, + NUMBER, + nNumberFormatKey )); + ++rInOutSequenceIndex; + ++rInOutHeaderEnd; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/DataBrowserModel.hxx b/chart2/source/controller/dialogs/DataBrowserModel.hxx new file mode 100644 index 000000000000..95a3e4b2f0fa --- /dev/null +++ b/chart2/source/controller/dialogs/DataBrowserModel.hxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataBrowserModel.hxx,v $ + * $Revision: 1.7.16.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DATABROWSERMODEL_HXX +#define CHART2_DATABROWSERMODEL_HXX + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> +#include <vector> + +namespace com { namespace sun { namespace star { namespace chart2 { + class XDataSeries; + class XChartType; + namespace data { + class XLabeledDataSequence; + } +}}}} + +namespace chart +{ + +class DialogModel; + +class DataBrowserModel +{ +public: + explicit DataBrowserModel( + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~DataBrowserModel(); + + /** Inserts a new data series after the data series to which the data column + with index nAfterColumnIndex belongs. + */ + void insertDataSeries( sal_Int32 nAfterColumnIndex ); + + /** Removes a data series to which the data column with index nAtColumnIndex + belongs. + */ + void removeDataSeries( 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 + }; + + eCellType getCellType( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + /// If getCellType( nAtColumn, nAtRow ) returns TEXT, the result will be Nan + double getCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + ::rtl::OUString getCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + sal_uInt32 getNumberFormatKey( sal_Int32 nAtColumn, sal_Int32 nAtRow ); + + /// returns </TRUE> if the number could successfully be set at the given position + bool setCellNumber( sal_Int32 nAtColumn, sal_Int32 nAtRow, double fValue ); + /// returns </TRUE> if the text could successfully be set at the given position + bool setCellText( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::rtl::OUString & rText ); + bool setCellAny( sal_Int32 nAtColumn, sal_Int32 nAtRow, const ::com::sun::star::uno::Any & aValue ); + + sal_Int32 getColumnCount() const; + sal_Int32 getMaxRowCount() const; + + // returns the UI string of the corresponding role + ::rtl::OUString getRoleOfColumn( sal_Int32 nColumnIndex ) const; + + struct tDataHeader + { + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > m_xDataSeries; + ::com::sun::star::uno::Reference< + ::com::sun::star::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( + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > xDataSeries, + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > 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; + + tDataHeader getHeaderForSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > &xSeries ) const; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > + getDataSeriesByColumn( sal_Int32 nColumn ) const; + +private: + void updateFromModel(); + + void addErrorBarRanges( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xDataSeries, + sal_Int32 nNumberFormatKey, + sal_Int32 & rInOutSequenceIndex, + sal_Int32 & rInOutHeaderEnd ); + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence > + getCategories() const throw(); + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > m_xContext; + ::std::auto_ptr< DialogModel > m_apDialogModel; + + struct tDataColumn; + struct implColumnLess; + + typedef ::std::vector< tDataColumn > tDataColumnVector; + + tDataColumnVector m_aColumns; + tDataHeaderVector m_aHeaders; +}; + +} // namespace chart + +// CHART2_DATABROWSERMODEL_HXX +#endif diff --git a/chart2/source/controller/dialogs/DialogModel.cxx b/chart2/source/controller/dialogs/DialogModel.cxx new file mode 100644 index 000000000000..69e693911c22 --- /dev/null +++ b/chart2/source/controller/dialogs/DialogModel.cxx @@ -0,0 +1,843 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DialogModel.cxx,v $ + * $Revision: 1.7.16.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "DialogModel.hxx" +#include "RangeSelectionHelper.hxx" +#include "PropertyHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "DataSourceHelper.hxx" +#include "DiagramHelper.hxx" +#include "macros.hxx" +#include "Strings.hrc" +#include "ResId.hxx" +#include "ContainerHelper.hxx" +#include "CommonFunctors.hxx" +#include "ControllerLockGuard.hxx" +#include "ChartTypeHelper.hxx" + +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/chart2/AxisType.hpp> +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> + +#include <tools/string.hxx> + +#include <utility> +#include <algorithm> +#include <iterator> +#include <functional> +#include <numeric> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::chart::ContainerHelper; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +// ---------------------------------------- + +namespace +{ +const OUString lcl_aLabelRole( RTL_CONSTASCII_USTRINGPARAM( "label" )); + +struct lcl_ChartTypeToSeriesCnt : ::std::unary_function< + Reference< XChartType >, Reference< XDataSeriesContainer > > +{ + Reference< XDataSeriesContainer > operator() ( + const Reference< XChartType > & xChartType ) + { + return Reference< XDataSeriesContainer >::query( xChartType ); + } +}; + +OUString lcl_ConvertRole( const OUString & rRoleString, bool bFromInternalToUI ) +{ + OUString aResult( rRoleString ); + + typedef ::std::map< OUString, OUString > tTranslationMap; + static tTranslationMap aTranslationMap; + + if( aTranslationMap.size() == 0 ) + { + aTranslationMap[ C2U( "categories" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_CATEGORIES ))); + aTranslationMap[ C2U( "error-bars-x" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_X_ERROR ))); + aTranslationMap[ C2U( "error-bars-x-positive" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_X_ERROR_POSITIVE ))); + aTranslationMap[ C2U( "error-bars-x-negative" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_X_ERROR_NEGATIVE ))); + aTranslationMap[ C2U( "error-bars-y" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_Y_ERROR ))); + aTranslationMap[ C2U( "error-bars-y-positive" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_Y_ERROR_POSITIVE ))); + aTranslationMap[ C2U( "error-bars-y-negative" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_Y_ERROR_NEGATIVE ))); + aTranslationMap[ C2U( "label" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_LABEL ))); + aTranslationMap[ C2U( "values-first" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_FIRST ))); + aTranslationMap[ C2U( "values-last" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_LAST ))); + aTranslationMap[ C2U( "values-max" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_MAX ))); + aTranslationMap[ C2U( "values-min" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_MIN ))); + aTranslationMap[ C2U( "values-x" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_X ))); + aTranslationMap[ C2U( "values-y" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_Y ))); + aTranslationMap[ C2U( "values-size" ) ] = OUString( String( ::chart::SchResId( STR_DATA_ROLE_SIZE ))); + } + + if( bFromInternalToUI ) + { + tTranslationMap::const_iterator aIt( aTranslationMap.find( rRoleString )); + if( aIt != aTranslationMap.end()) + { + aResult = (*aIt).second; + } + } + else + { + tTranslationMap::const_iterator aIt( + ::std::find_if( aTranslationMap.begin(), aTranslationMap.end(), + ::std::compose1( ::std::bind2nd( + ::std::equal_to< tTranslationMap::mapped_type >(), + rRoleString ), + ::std::select2nd< tTranslationMap::value_type >()))); + + if( aIt != aTranslationMap.end()) + aResult = (*aIt).first; + } + + return aResult; +} + +typedef ::std::map< ::rtl::OUString, sal_Int32 > lcl_tRoleIndexMap; + +void lcl_createRoleIndexMap( lcl_tRoleIndexMap & rOutMap ) +{ + rOutMap.clear(); + sal_Int32 nIndex = 0; + + rOutMap[ C2U( "label" ) ] = ++nIndex; + rOutMap[ C2U( "categories" ) ] = ++nIndex; + rOutMap[ C2U( "values-x" ) ] = ++nIndex; + rOutMap[ C2U( "values-y" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-x" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-x-positive" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-x-negative" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-y" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-y-positive" ) ] = ++nIndex; + rOutMap[ C2U( "error-bars-y-negative" ) ] = ++nIndex; + rOutMap[ C2U( "values-first" ) ] = ++nIndex; + rOutMap[ C2U( "values-min" ) ] = ++nIndex; + rOutMap[ C2U( "values-max" ) ] = ++nIndex; + rOutMap[ C2U( "values-last" ) ] = ++nIndex; + rOutMap[ C2U( "values-size" ) ] = ++nIndex; +} + +struct lcl_DataSeriesContainerAppend : public + ::std::iterator< ::std::output_iterator_tag, Reference< XDataSeriesContainer > > +{ + 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()) + { + Sequence< Reference< XDataSeries > > aSeq( xVal->getDataSeries()); + OUString aRole( RTL_CONSTASCII_USTRINGPARAM("values-y")); + Reference< XChartType > xCT( xVal, uno::UNO_QUERY ); + if( xCT.is()) + aRole = xCT->getRoleOfSequenceForSeriesLabel(); + for( sal_Int32 nI = 0; nI < aSeq.getLength(); ++ nI ) + { + m_rDestCnt.push_back( + chart::DialogModel::tSeriesWithChartTypeByName( + ::chart::DataSeriesHelper::getDataSeriesLabel( aSeq[nI], aRole ), + ::std::make_pair( aSeq[nI], xCT ))); + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return *this; + } + + lcl_DataSeriesContainerAppend & operator* () { return *this; } + lcl_DataSeriesContainerAppend & operator++ () { return *this; } + lcl_DataSeriesContainerAppend & operator++ (int) { return *this; } + +private: + tContainerType & m_rDestCnt; +}; + +struct lcl_RolesWithRangeAppend : public + ::std::iterator< ::std::output_iterator_tag, Reference< data::XLabeledDataSequence > > +{ + typedef ::chart::DialogModel::tRolesWithRanges tContainerType; + + explicit lcl_RolesWithRangeAppend( tContainerType & rCnt, + const ::rtl::OUString & aLabelRole ) + : m_rDestCnt( rCnt ), + m_aRoleForLabelSeq( aLabelRole ) + {} + + lcl_RolesWithRangeAppend & operator= ( const value_type & xVal ) + { + try + { + if( xVal.is()) + { + // data sequence + Reference< data::XDataSequence > xSeq( xVal->getValues()); + if( xSeq.is()) + { + OUString aRole; + Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY_THROW ); + if( xProp->getPropertyValue( C2U("Role")) >>= aRole ) + { + m_rDestCnt.insert( + tContainerType::value_type( + aRole, xSeq->getSourceRangeRepresentation())); + // label + if( aRole.equals( m_aRoleForLabelSeq )) + { + Reference< data::XDataSequence > xLabelSeq( xVal->getLabel()); + if( xLabelSeq.is()) + { + m_rDestCnt.insert( + tContainerType::value_type( + lcl_aLabelRole, xLabelSeq->getSourceRangeRepresentation())); + } + } + } + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return *this; + } + + lcl_RolesWithRangeAppend & operator* () { return *this; } + lcl_RolesWithRangeAppend & operator++ () { return *this; } + lcl_RolesWithRangeAppend & operator++ (int) { return *this; } + +private: + tContainerType & m_rDestCnt; + OUString m_aRoleForLabelSeq; +}; + +void lcl_SetSequenceRole( + const Reference< data::XDataSequence > & xSeq, + const OUString & rRole ) +{ + Reference< beans::XPropertySet > xProp( xSeq, uno::UNO_QUERY ); + if( xProp.is()) + xProp->setPropertyValue( C2U("Role"), uno::makeAny( rRole )); +} + +Reference< XDataSeries > lcl_CreateNewSeries( + const Reference< uno::XComponentContext > & xContext, + const Reference< XChartType > & xChartType, + sal_Int32 nNewSeriesIndex, + sal_Int32 nTotalNumberOfSeriesInCTGroup, + const Reference< XDiagram > & xDiagram, + const Reference< XChartTypeTemplate > & xTemplate, + bool bCreateDataCachedSequences ) +{ + // create plain series + Reference< XDataSeries > xResult( + xContext->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.chart2.DataSeries" ), + xContext ), uno::UNO_QUERY ); + 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( + C2U("Color"), uno::makeAny( xColorScheme->getColorByIndex( nNewSeriesIndex ))); + } + sal_Int32 nGroupIndex=0; + if( xChartType.is()) + { + Sequence< Reference< XChartType > > aCTs( + ::chart::DiagramHelper::getChartTypesFromDiagram( xDiagram )); + for( ; nGroupIndex<aCTs.getLength(); ++nGroupIndex) + if( aCTs[nGroupIndex] == xChartType ) + break; + if( nGroupIndex == aCTs.getLength()) + nGroupIndex = 0; + } + xTemplate->applyStyle( xResult, nGroupIndex, nNewSeriesIndex, nTotalNumberOfSeriesInCTGroup ); + } + + if( bCreateDataCachedSequences ) + { + // set chart type specific roles + Reference< data::XDataSink > xSink( xResult, uno::UNO_QUERY ); + if( xChartType.is() && xSink.is()) + { + ::std::vector< Reference< data::XLabeledDataSequence > > aNewSequences; + const OUString aRoleOfSeqForSeriesLabel = xChartType->getRoleOfSequenceForSeriesLabel(); + const OUString aLabel( String( ::chart::SchResId( STR_DATA_UNNAMED_SERIES ))); + const Sequence< OUString > aRoles( xChartType->getSupportedMandatoryRoles()); + const Sequence< OUString > aOptRoles( xChartType->getSupportedOptionalRoles()); + sal_Int32 nI = 0; + + for(nI=0; nI<aRoles.getLength(); ++nI) + { + if( aRoles[nI].equals( lcl_aLabelRole )) + continue; + Reference< data::XDataSequence > xSeq( ::chart::DataSourceHelper::createCachedDataSequence() ); + lcl_SetSequenceRole( xSeq, aRoles[nI] ); + // assert that aRoleOfSeqForSeriesLabel is part of the mandatory roles + if( aRoles[nI].equals( aRoleOfSeqForSeriesLabel )) + { + Reference< data::XDataSequence > xLabel( ::chart::DataSourceHelper::createCachedDataSequence( aLabel )); + lcl_SetSequenceRole( xLabel, lcl_aLabelRole ); + aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq, xLabel )); + } + else + aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq )); + } + + for(nI=0; nI<aOptRoles.getLength(); ++nI) + { + if( aOptRoles[nI].equals( lcl_aLabelRole )) + continue; + Reference< data::XDataSequence > xSeq( ::chart::DataSourceHelper::createCachedDataSequence()); + lcl_SetSequenceRole( xSeq, aOptRoles[nI] ); + aNewSequences.push_back( ::chart::DataSourceHelper::createLabeledDataSequence( xSeq )); + } + + xSink->setData( ContainerToSequence( aNewSequences )); + } + } + + return xResult; +} + +struct lcl_addSeriesNumber : public ::std::binary_function< + sal_Int32, Reference< XDataSeriesContainer >, sal_Int32 > +{ + sal_Int32 operator() ( sal_Int32 nCurrentNumber, const Reference< XDataSeriesContainer > & xCnt ) const + { + if( xCnt.is()) + return nCurrentNumber + (xCnt->getDataSeries().getLength()); + return nCurrentNumber; + } +}; + +} // anonymous namespace + +// ---------------------------------------- + + +namespace chart +{ + +DialogModel::DialogModel( + const Reference< XChartDocument > & xChartDocument, + const Reference< uno::XComponentContext > & xContext ) : + m_xChartDocument( xChartDocument ), + m_xContext( xContext ), + m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ) +{ + createBackup(); +} + +DialogModel::~DialogModel() +{} + +void DialogModel::setTemplate( + const Reference< XChartTypeTemplate > & xTemplate ) +{ + m_xTemplate = xTemplate; +} + +::boost::shared_ptr< RangeSelectionHelper > + DialogModel::getRangeSelectionHelper() const +{ + if( ! m_spRangeSelectionHelper.get()) + m_spRangeSelectionHelper.reset( + new RangeSelectionHelper( m_xChartDocument )); + + return m_spRangeSelectionHelper; +} + +Reference< frame::XModel > DialogModel::getChartModel() const +{ + Reference< frame::XModel > xResult( m_xChartDocument, uno::UNO_QUERY ); + return xResult; +} + +Reference< data::XDataProvider > DialogModel::getDataProvider() const +{ + Reference< data::XDataProvider > xResult; + if( m_xChartDocument.is()) + xResult.set( m_xChartDocument->getDataProvider()); + return xResult; +} + +::std::vector< Reference< XDataSeriesContainer > > + DialogModel::getAllDataSeriesContainers() const +{ + ::std::vector< Reference< XDataSeriesContainer > > aResult; + + try + { + Reference< XDiagram > xDiagram; + if( m_xChartDocument.is()) + xDiagram.set( m_xChartDocument->getFirstDiagram()); + if( xDiagram.is()) + { + Reference< XCoordinateSystemContainer > xCooSysCnt( + xDiagram, uno::UNO_QUERY_THROW ); + Sequence< Reference< XCoordinateSystem > > aCooSysSeq( + xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 i=0; i<aCooSysSeq.getLength(); ++i ) + { + Reference< XChartTypeContainer > xCTCnt( aCooSysSeq[i], uno::UNO_QUERY_THROW ); + Sequence< Reference< XChartType > > aChartTypeSeq( xCTCnt->getChartTypes()); + ::std::transform( + aChartTypeSeq.getConstArray(), aChartTypeSeq.getConstArray() + aChartTypeSeq.getLength(), + ::std::back_inserter( aResult ), + lcl_ChartTypeToSeriesCnt() ); + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return aResult; +} + +::std::vector< DialogModel::tSeriesWithChartTypeByName > + DialogModel::getAllDataSeriesWithLabel() const +{ + ::std::vector< tSeriesWithChartTypeByName > aResult; + ::std::vector< Reference< XDataSeriesContainer > > aContainers( + getAllDataSeriesContainers()); + + ::std::copy( aContainers.begin(), aContainers.end(), + lcl_DataSeriesContainerAppend( aResult )); + return aResult; +} + +DialogModel::tRolesWithRanges DialogModel::getRolesWithRanges( + const Reference< XDataSeries > & xSeries, + const ::rtl::OUString & aRoleOfSequenceForLabel, + const Reference< chart2::XChartType > & xChartType ) const +{ + DialogModel::tRolesWithRanges aResult; + try + { + Reference< data::XDataSource > xSource( xSeries, uno::UNO_QUERY_THROW ); + const Sequence< Reference< data::XLabeledDataSequence > > aSeq( xSource->getDataSequences()); + ::std::copy( aSeq.getConstArray(), aSeq.getConstArray() + aSeq.getLength(), + lcl_RolesWithRangeAppend( aResult, aRoleOfSequenceForLabel )); + if( xChartType.is()) + { + // add missing mandatory roles + Sequence< OUString > aRoles( xChartType->getSupportedMandatoryRoles()); + OUString aEmptyString; + sal_Int32 nI = 0; + for( nI=0; nI < aRoles.getLength(); ++nI ) + { + if( aResult.find( aRoles[nI] ) == aResult.end() ) + aResult.insert( DialogModel::tRolesWithRanges::value_type( aRoles[nI], aEmptyString )); + } + + // add missing optional roles + aRoles = xChartType->getSupportedOptionalRoles(); + for( nI=0; nI < aRoles.getLength(); ++nI ) + { + if( aResult.find( aRoles[nI] ) == aResult.end() ) + aResult.insert( DialogModel::tRolesWithRanges::value_type( aRoles[nI], aEmptyString )); + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aResult; +} + +void DialogModel::moveSeries( + const Reference< XDataSeries > & xSeries, + eMoveDirection eDirection ) +{ + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); + + Reference< XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + DiagramHelper::moveSeries( xDiagram, xSeries, eDirection==MOVE_UP ); +} + +Reference< chart2::XDataSeries > DialogModel::insertSeriesAfter( + const Reference< XDataSeries > & xSeries, + const Reference< XChartType > & xChartType, + bool bCreateDataCachedSequences /* = false */ ) +{ + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); + Reference< XDataSeries > xNewSeries; + + try + { + sal_Int32 nSeriesInChartType = 0; + const sal_Int32 nTotalSeries = countSeries(); + if( xChartType.is()) + { + Reference< XDataSeriesContainer > xCnt( xChartType, uno::UNO_QUERY_THROW ); + nSeriesInChartType = xCnt->getDataSeries().getLength(); + } + + // create new series + xNewSeries.set( + lcl_CreateNewSeries( + m_xContext, + xChartType, + nTotalSeries, // new series' index + nSeriesInChartType, + m_xChartDocument->getFirstDiagram(), + m_xTemplate, + bCreateDataCachedSequences )); + + // add new series to container + if( xNewSeries.is()) + { + Reference< XDataSeriesContainer > xSeriesCnt( xChartType, uno::UNO_QUERY_THROW ); + ::std::vector< Reference< XDataSeries > > aSeries( + SequenceToVector( xSeriesCnt->getDataSeries())); + ::std::vector< Reference< XDataSeries > >::iterator aIt = + ::std::find( aSeries.begin(), aSeries.end(), xSeries ); + if( aIt == aSeries.end()) + // if we have no series we insert at the first position. + aIt = aSeries.begin(); + else + // vector::insert inserts before, so we have to advance + ++aIt; + aSeries.insert( aIt, xNewSeries ); + xSeriesCnt->setDataSeries( ContainerToSequence( aSeries )); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return xNewSeries; +} + +void DialogModel::deleteSeries( + const Reference< XDataSeries > & xSeries, + const Reference< XChartType > & xChartType ) +{ + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); + + DataSeriesHelper::deleteSeries( xSeries, xChartType ); +} + +Reference< data::XLabeledDataSequence > DialogModel::getCategories() const +{ + Reference< data::XLabeledDataSequence > xResult; + try + { + if( m_xChartDocument.is()) + { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + xResult.set( DiagramHelper::getCategoriesFromDiagram( xDiagram )); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return xResult; +} + +void DialogModel::setCategories( const Reference< chart2::data::XLabeledDataSequence > & xCategories ) +{ + if( m_xChartDocument.is()) + { + Reference< chart2::XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + if( xDiagram.is()) + { + // categories + bool bSupportsCategories = true; + + Reference< XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + if( xFirstChartType.is() ) + { + sal_Int32 nAxisType = ChartTypeHelper::getAxisType( xFirstChartType, 0 ); // x-axis + bSupportsCategories = (nAxisType == AxisType::CATEGORY); + } + DiagramHelper::setCategoriesToDiagram( xCategories, xDiagram, true, bSupportsCategories ); + } + } +} + +OUString DialogModel::getCategoriesRange() const +{ + Reference< data::XLabeledDataSequence > xLSeq( getCategories()); + OUString aRange; + if( xLSeq.is()) + { + Reference< data::XDataSequence > xSeq( xLSeq->getValues()); + if( xSeq.is()) + aRange = xSeq->getSourceRangeRepresentation(); + } + return aRange; +} + +bool DialogModel::isCategoryDiagram() const +{ + bool bRet = false; + if( m_xChartDocument.is()) + bRet = DiagramHelper::isCategoryDiagram( m_xChartDocument->getFirstDiagram() ); + return bRet; +} + +void DialogModel::detectArguments( + OUString & rOutRangeString, + bool & rOutUseColumns, + bool & rOutFirstCellAsLabel, + bool & rOutHasCategories ) const +{ + try + { + uno::Sequence< sal_Int32 > aSequenceMapping;//todo YYYX + + // Note: unused data is currently not supported in being passed to detectRangeSegmentation + if( m_xChartDocument.is()) + DataSourceHelper::detectRangeSegmentation( + Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY_THROW ), + rOutRangeString, aSequenceMapping, rOutUseColumns, rOutFirstCellAsLabel, rOutHasCategories ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +bool DialogModel::allArgumentsForRectRangeDetected() const +{ + return DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument ); +} + +void DialogModel::startControllerLockTimer() +{ + m_aTimerTriggeredControllerLock.startTimer(); +} + +bool DialogModel::setData( + const Sequence< beans::PropertyValue > & rArguments ) +{ + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aLockedControllers( Reference< frame::XModel >( m_xChartDocument, uno::UNO_QUERY ) ); + + Reference< data::XDataProvider > xDataProvider( getDataProvider()); + if( ! xDataProvider.is() || + ! m_xTemplate.is() ) + { + OSL_ENSURE( false, "Model objects missing" ); + return false; + } + + try + { + Reference< chart2::data::XDataSource > xDataSource( + xDataProvider->createDataSource( rArguments ) ); + + Reference< chart2::XDataInterpreter > xInterpreter( + m_xTemplate->getDataInterpreter()); + if( xInterpreter.is()) + { + ::std::vector< Reference< XDataSeries > > aSeriesToReUse( + DiagramHelper::getDataSeriesFromDiagram( m_xChartDocument->getFirstDiagram())); + applyInterpretedData( + xInterpreter->interpretDataSource( + xDataSource, rArguments, + ContainerToSequence( aSeriesToReUse )), + aSeriesToReUse, + true /* bSetStyles */); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + return false; + } + + return true; +} + +// static +OUString DialogModel::ConvertRoleFromInternalToUI( const OUString & rRoleString ) +{ + return lcl_ConvertRole( rRoleString, true ); +} + +// static +OUString DialogModel::GetRoleDataLabel() +{ + return OUString( String( ::chart::SchResId( STR_OBJECT_DATALABELS ))); +} + +// static + +sal_Int32 DialogModel::GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ) +{ + static lcl_tRoleIndexMap aRoleIndexMap; + + if( aRoleIndexMap.empty()) + lcl_createRoleIndexMap( aRoleIndexMap ); + + lcl_tRoleIndexMap::const_iterator aIt( aRoleIndexMap.find( rInternalRoleString )); + if( aIt != aRoleIndexMap.end()) + return aIt->second; + + return 0; +} + +// private methods + +void DialogModel::createBackup() +{ + OSL_ENSURE( ! m_xBackupChartDocument.is(), "Cloning already cloned model" ); + try + { + Reference< util::XCloneable > xCloneable( m_xChartDocument, uno::UNO_QUERY_THROW ); + m_xBackupChartDocument.set( xCloneable->createClone(), uno::UNO_QUERY_THROW ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void DialogModel::applyInterpretedData( + const InterpretedData & rNewData, + const ::std::vector< Reference< XDataSeries > > & rSeriesToReUse, + bool bSetStyles ) +{ + if( ! m_xChartDocument.is()) + return; + + m_aTimerTriggeredControllerLock.startTimer(); + Reference< XDiagram > xDiagram( m_xChartDocument->getFirstDiagram()); + if( xDiagram.is()) + { + // styles + if( bSetStyles && m_xTemplate.is() ) + { + sal_Int32 nGroup = 0; + sal_Int32 nSeriesCounter = 0; + sal_Int32 nNewSeriesIndex = static_cast< sal_Int32 >( rSeriesToReUse.size()); + const sal_Int32 nOuterSize=rNewData.Series.getLength(); + + for(; nGroup < nOuterSize; ++nGroup) + { + Sequence< Reference< XDataSeries > > aSeries( rNewData.Series[ nGroup ] ); + const sal_Int32 nSeriesInGroup = aSeries.getLength(); + 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()) + { + // @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( + C2U("Color"), uno::makeAny( xColorScheme->getColorByIndex( nSeriesCounter ))); + } + m_xTemplate->applyStyle( aSeries[nSeries], nGroup, nNewSeriesIndex++, nSeriesInGroup ); + } + } + } + } + + // data series + ::std::vector< Reference< XDataSeriesContainer > > aSeriesCnt( getAllDataSeriesContainers()); + ::std::vector< Sequence< Reference< XDataSeries > > > aNewSeries( + SequenceToVector( rNewData.Series )); + + OSL_ASSERT( aSeriesCnt.size() == aNewSeries.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(); + ++aSrcIt, ++aDestIt ) + { + try + { + OSL_ASSERT( (*aDestIt).is()); + (*aDestIt)->setDataSeries( *aSrcIt ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + DialogModel::setCategories(rNewData.Categories); + } + + OSL_ASSERT( ! rNewData.UnusedData.hasElements()); +} + +sal_Int32 DialogModel::countSeries() const +{ + ::std::vector< Reference< XDataSeriesContainer > > aCnt( getAllDataSeriesContainers()); + return ::std::accumulate( aCnt.begin(), aCnt.end(), 0, lcl_addSeriesNumber()); +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/DialogModel.hxx b/chart2/source/controller/dialogs/DialogModel.hxx new file mode 100644 index 000000000000..744262cbbd1f --- /dev/null +++ b/chart2/source/controller/dialogs/DialogModel.hxx @@ -0,0 +1,200 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DialogModel.hxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DIALOGMODEL_HXX +#define CHART2_DIALOGMODEL_HXX + +#include "TimerTriggeredControllerLock.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <vector> +#include <map> +#include <boost/shared_ptr.hpp> + +namespace com { namespace sun { namespace star { namespace chart2 { + class XDataSeriesContainer; + class XDataSeries; + class XChartType; + class XChartTypeTemplate; + struct InterpretedData; + namespace data { + class XDataProvider; + class XLabeledDataSequence; + } +}}}} + +namespace chart +{ + +class RangeSelectionHelper; + +class DialogModel +{ +public: + explicit DialogModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + ~DialogModel(); + + typedef ::std::pair< + ::rtl::OUString, + ::std::pair< ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries >, + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > > > + tSeriesWithChartTypeByName; + + typedef ::std::map< ::rtl::OUString, ::rtl::OUString > + tRolesWithRanges; + + void setTemplate( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > & xTemplate ); + + ::boost::shared_ptr< RangeSelectionHelper > + getRangeSelectionHelper() const; + + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > + getChartModel() const; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataProvider > + getDataProvider() const; + + ::std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeriesContainer > > + getAllDataSeriesContainers() const; + + ::std::vector< tSeriesWithChartTypeByName > + getAllDataSeriesWithLabel() const; + + tRolesWithRanges getRolesWithRanges( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xSeries, + const ::rtl::OUString & aRoleOfSequenceForLabel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > & xChartType ) const; + + enum eMoveDirection + { + MOVE_DOWN, + MOVE_UP + }; + + void moveSeries( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xSeries, + eMoveDirection eDirection ); + + /// @return the newly inserted series + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > insertSeriesAfter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xSeries, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > & xChartType, + bool bCreateDataCachedSequences = false ); + + void deleteSeries( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xSeries, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > & xChartType ); + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence > + getCategories() const; + + void setCategories( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XLabeledDataSequence > & xCategories ); + + ::rtl::OUString getCategoriesRange() const; + + bool isCategoryDiagram() const; + + void detectArguments( + ::rtl::OUString & rOutRangeString, + bool & rOutUseColumns, bool & rOutFirstCellAsLabel, bool & rOutHasCategories ) const; + + bool allArgumentsForRectRangeDetected() const; + + bool setData( const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > & rArguments ); + + void startControllerLockTimer(); + + static ::rtl::OUString ConvertRoleFromInternalToUI( const ::rtl::OUString & rRoleString ); + static ::rtl::OUString GetRoleDataLabel(); + + // pass a role string (not translated) and get an index that serves for + // relative ordering, to get e.g. x-values and y-values in the right order + static sal_Int32 GetRoleIndexForSorting( const ::rtl::OUString & rInternalRoleString ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > + m_xChartDocument; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > + m_xBackupChartDocument; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > + m_xTemplate; + + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > + m_xContext; + + mutable ::boost::shared_ptr< RangeSelectionHelper > + m_spRangeSelectionHelper; + + TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; + +private: + void createBackup(); + + void applyInterpretedData( + const ::com::sun::star::chart2::InterpretedData & rNewData, + const ::std::vector< ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > > & rSeriesToReUse, + bool bSetStyles ); + + sal_Int32 countSeries() const; +}; + +} // namespace chart + +// CHART2_DIALOGMODEL_HXX +#endif diff --git a/chart2/source/controller/dialogs/ObjectNameProvider.cxx b/chart2/source/controller/dialogs/ObjectNameProvider.cxx new file mode 100644 index 000000000000..24b717adba7f --- /dev/null +++ b/chart2/source/controller/dialogs/ObjectNameProvider.cxx @@ -0,0 +1,857 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectNameProvider.cxx,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ObjectNameProvider.hxx" +#include "ResId.hxx" +#include "Strings.hrc" +#include "macros.hxx" +#include "AxisHelper.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "TitleHelper.hxx" +#include "AxisIndexDefines.hxx" +#include "ExplicitCategoriesProvider.hxx" +#include "CommonConverters.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "RegressionCurveHelper.hxx" +#include <rtl/math.hxx> +#include <tools/debug.hxx> +#include <tools/string.hxx> + +// #include <svtools/syslocale.hxx> + +#include <com/sun/star/chart2/XTitle.hpp> +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::com::sun::star::uno::Any; +using rtl::OUString; + +namespace +{ + +OUString lcl_getDataSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) +{ + OUString aRet; + + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); + if( xDiagram.is() && xSeries.is() ) + { + Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + if( xChartType.is() ) + { + aRet = ::chart::DataSeriesHelper::getDataSeriesLabel( + xSeries, xChartType->getRoleOfSequenceForSeriesLabel() ) ; + } + } + + return aRet; +} + +OUString lcl_getFullSeriesName( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel ) +{ + OUString aRet = String(SchResId(STR_TIP_DATASERIES)); + OUString aWildcard( C2U("%SERIESNAME") ); + sal_Int32 nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); + return aRet; +} + +void lcl_addText( OUString& rOut, const OUString& rSeparator, const OUString& rNext ) +{ + if( rOut.getLength() && rNext.getLength() ) + rOut+=rSeparator; + if( rNext.getLength() ) + rOut+=rNext; +} + +OUString lcl_getDataPointValueText( const Reference< XDataSeries >& xSeries, sal_Int32 nPointIndex, + const Reference< XCoordinateSystem >& xCooSys, + const Reference< frame::XModel >& xChartModel ) +{ + + OUString aRet; + + Reference<data::XDataSource> xDataSource( + uno::Reference<data::XDataSource>( xSeries, uno::UNO_QUERY ) ); + if(!xDataSource.is()) + return aRet; + + Sequence< Reference< data::XLabeledDataSequence > > aDataSequences( xDataSource->getDataSequences() ); + + rtl::OUString aX, aY, aY_Min, aY_Max, aY_First, aY_Last, a_Size; + double fValue = 0; + + uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( xChartModel, uno::UNO_QUERY ); + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + sal_Int32 nLabelColor = 0;//dummy + bool bColorChanged;//dummy + + for(sal_Int32 nN = aDataSequences.getLength();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 + { + uno::Any aARole = xProp->getPropertyValue( C2U( "Role" ) ); + rtl::OUString aRole; + aARole >>= aRole; + + if( aRole.equals(C2U("values-x")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aX = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-y")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aY = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-first")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aY_First = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-min")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aY_Min = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-max")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aY_Max = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-last")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + aY_Last = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + else if( aRole.equals(C2U("values-size")) ) + { + aData[nPointIndex]>>= fValue; + sal_Int32 nNumberFormatKey = xDataSequence->getNumberFormatKeyByIndex( nPointIndex ); + a_Size = aNumberFormatterWrapper.getFormattedString( nNumberFormatKey, fValue, nLabelColor, bColorChanged ); + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } + + if( aX.getLength() == 0 ) + { + rtl::OUString aCategory = ::rtl::OUString( String(SchResId(STR_TIP_CATEGORY_VALUE))); + + replaceParamterInString( aCategory + , C2U("%CATEGORYVALUE") + , ExplicitCategoriesProvider::getCategoryByIndex( xCooSys, nPointIndex ) + ); + + aRet = aCategory; + } + else + { + aRet = aX; + } + + OUString aSeparator(C2U(" ")); + + lcl_addText( aRet, aSeparator, aY ); + lcl_addText( aRet, aSeparator, aY_First ); + lcl_addText( aRet, aSeparator, aY_Min ); + lcl_addText( aRet, aSeparator, aY_Max ); + lcl_addText( aRet, aSeparator, aY_Last ); + lcl_addText( aRet, aSeparator, a_Size ); + + return aRet; +} + +} //end anonymous namespace + +rtl::OUString ObjectNameProvider::getName( ObjectType eObjectType, bool bPlural ) +{ + rtl::OUString aRet; + switch( eObjectType ) + { + case OBJECTTYPE_PAGE: + aRet=String(SchResId(STR_OBJECT_PAGE)); + break; + case OBJECTTYPE_TITLE: + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_TITLES)); + else + aRet=String(SchResId(STR_OBJECT_TITLE)); + } + break; + case OBJECTTYPE_LEGEND: + aRet=String(SchResId(STR_OBJECT_LEGEND)); + break; + case OBJECTTYPE_LEGEND_ENTRY: + aRet=String(SchResId(STR_OBJECT_LEGEND_SYMBOL));//@todo change string if we do differenciate symbol and legend entry in future + break; + case OBJECTTYPE_DIAGRAM: + aRet=String(SchResId(STR_OBJECT_DIAGRAM)); + break; + case OBJECTTYPE_DIAGRAM_WALL: + aRet=String(SchResId(STR_OBJECT_DIAGRAM_WALL)); + break; + case OBJECTTYPE_DIAGRAM_FLOOR: + aRet=String(SchResId(STR_OBJECT_DIAGRAM_FLOOR)); + break; + case OBJECTTYPE_AXIS: + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_AXES)); + else + aRet=String(SchResId(STR_OBJECT_AXIS)); + } + break; + case OBJECTTYPE_AXIS_UNITLABEL: + aRet=String(SchResId(STR_OBJECT_LABEL));//@todo maybe a more concrete name + break; + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: //maybe todo: different names for subgrids + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_GRIDS)); + else + aRet=String(SchResId(STR_OBJECT_GRID)); + } + break; + case OBJECTTYPE_DATA_SERIES: + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_DATASERIES_PLURAL)); + else + aRet=String(SchResId(STR_OBJECT_DATASERIES)); + } + break; + case OBJECTTYPE_DATA_POINT: + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_DATAPOINTS)); + else + aRet=String(SchResId(STR_OBJECT_DATAPOINT)); + } + break; + case OBJECTTYPE_DATA_LABELS: + aRet=String(SchResId(STR_OBJECT_DATALABELS)); + break; + case OBJECTTYPE_DATA_LABEL: + aRet=String(SchResId(STR_OBJECT_LABEL)); + break; + case OBJECTTYPE_DATA_ERRORS: + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe distinguish plural singular + break; + case OBJECTTYPE_DATA_ERRORS_X: + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future + break; + case OBJECTTYPE_DATA_ERRORS_Y: + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future + break; + case OBJECTTYPE_DATA_ERRORS_Z: + aRet=String(SchResId(STR_OBJECT_ERROR_BARS));//@todo? maybe specialize in future + break; + case OBJECTTYPE_DATA_AVERAGE_LINE: + aRet=String(SchResId(STR_OBJECT_AVERAGE_LINE)); + break; + case OBJECTTYPE_DATA_CURVE: + { + if(bPlural) + aRet=String(SchResId(STR_OBJECT_CURVES)); + else + aRet=String(SchResId(STR_OBJECT_CURVE)); + } + break; + case OBJECTTYPE_DATA_STOCK_RANGE: + //aRet=String(SchResId()); + break; + case OBJECTTYPE_DATA_STOCK_LOSS: + aRet=String(SchResId(STR_OBJECT_STOCK_LOSS)); + break; + case OBJECTTYPE_DATA_STOCK_GAIN: + aRet=String(SchResId(STR_OBJECT_STOCK_GAIN)); + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: + aRet=String(SchResId(STR_OBJECT_CURVE_EQUATION)); + break; + default: //OBJECTTYPE_UNKNOWN + ; + } + return aRet; +} +//static +rtl::OUString ObjectNameProvider::getAxisName( const rtl::OUString& rObjectCID + , const uno::Reference< frame::XModel >& xChartModel ) +{ + rtl::OUString aRet; + + + + Reference< XAxis > xAxis( + ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); + + sal_Int32 nCooSysIndex = 0; + sal_Int32 nDimensionIndex = 0; + sal_Int32 nAxisIndex = 0; + AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram( xChartModel ), nCooSysIndex, nDimensionIndex, nAxisIndex ); + + switch(nDimensionIndex) + { + case 0://x-axis + if( nAxisIndex == 0 ) + aRet=String(SchResId(STR_OBJECT_AXIS_X)); + else + aRet=String(SchResId(STR_OBJECT_SECONDARY_X_AXIS)); + break; + case 1://y-axis + if( nAxisIndex == 0 ) + aRet=String(SchResId(STR_OBJECT_AXIS_Y)); + else + aRet=String(SchResId(STR_OBJECT_SECONDARY_Y_AXIS)); + break; + case 2://z-axis + aRet=String(SchResId(STR_OBJECT_AXIS_Z)); + break; + default://axis + aRet=String(SchResId(STR_OBJECT_AXIS)); + break; + } + + return aRet; +} + +//static +OUString ObjectNameProvider::getTitleNameByType( TitleHelper::eTitleType eType ) +{ + OUString aRet; + + switch(eType) + { + case TitleHelper::MAIN_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_MAIN)); + break; + case TitleHelper::SUB_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SUB)); + break; + case TitleHelper::X_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_X_AXIS)); + break; + case TitleHelper::Y_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_Y_AXIS)); + break; + case TitleHelper::Z_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_Z_AXIS)); + break; + case TitleHelper::SECONDARY_X_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_X_AXIS)); + break; + case TitleHelper::SECONDARY_Y_AXIS_TITLE: + aRet=String(SchResId(STR_OBJECT_TITLE_SECONDARY_Y_AXIS)); + break; + default: + DBG_ERROR("unknown title type"); + break; + } + + if( !aRet.getLength() ) + aRet=String(SchResId(STR_OBJECT_TITLE)); + + return aRet; +} + +//static +OUString ObjectNameProvider::getTitleName( const OUString& rObjectCID + , const Reference< frame::XModel >& xChartModel ) +{ + OUString aRet; + + Reference< XTitle > xTitle( + ObjectIdentifier::getObjectPropertySet( rObjectCID , xChartModel ), uno::UNO_QUERY ); + if( xTitle.is() ) + { + TitleHelper::eTitleType eType; + if( TitleHelper::getTitleType( eType, xTitle, xChartModel ) ) + aRet = ObjectNameProvider::getTitleNameByType( eType ); + } + if( !aRet.getLength() ) + aRet=String(SchResId(STR_OBJECT_TITLE)); + + return aRet; +} + +//static +rtl::OUString ObjectNameProvider::getGridName( const rtl::OUString& rObjectCID + , const uno::Reference< frame::XModel >& xChartModel ) +{ + rtl::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 ) + , nCooSysIndex , nDimensionIndex, nAxisIndex ); + + bool bMainGrid = (ObjectIdentifier::getObjectType( rObjectCID ) == OBJECTTYPE_GRID); + + if( bMainGrid ) + { + switch(nDimensionIndex) + { + case 0://x-axis + aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_X)); + break; + case 1://y-axis + aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Y)); + break; + case 2://z-axis + aRet=String(SchResId(STR_OBJECT_GRID_MAJOR_Z)); + break; + default://axis + aRet=String(SchResId(STR_OBJECT_GRID)); + break; + } + } + else + { + switch(nDimensionIndex) + { + case 0://x-axis + aRet=String(SchResId(STR_OBJECT_GRID_MINOR_X)); + break; + case 1://y-axis + aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Y)); + break; + case 2://z-axis + aRet=String(SchResId(STR_OBJECT_GRID_MINOR_Z)); + break; + default://axis + aRet=String(SchResId(STR_OBJECT_GRID)); + break; + } + } + return aRet; +} + +rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< chart2::XChartDocument >& xChartDocument, bool bVerbose ) +{ + return getHelpText( rObjectCID, Reference< frame::XModel >( xChartDocument, uno::UNO_QUERY ), bVerbose ); +} + +rtl::OUString ObjectNameProvider::getHelpText( const rtl::OUString& rObjectCID, const Reference< frame::XModel >& xChartModel, bool bVerbose ) +{ + rtl::OUString aRet; + ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); + if( OBJECTTYPE_AXIS == eObjectType ) + { + aRet=ObjectNameProvider::getAxisName( rObjectCID, xChartModel ); + } + else if( OBJECTTYPE_GRID == eObjectType + || OBJECTTYPE_SUBGRID == eObjectType ) + { + aRet=ObjectNameProvider::getGridName( rObjectCID, xChartModel ); + } + else if( OBJECTTYPE_TITLE == eObjectType ) + { + aRet=ObjectNameProvider::getTitleName( rObjectCID, xChartModel ); + } + else if( OBJECTTYPE_DATA_SERIES == eObjectType ) + { + aRet = lcl_getFullSeriesName( rObjectCID, xChartModel ); + } + else if( OBJECTTYPE_DATA_POINT == eObjectType ) + { + if( bVerbose ) + { + OUString aNewLine(C2U("\n")); + + aRet=String(SchResId(STR_TIP_DATAPOINT_INDEX)); + aRet+=aNewLine; + aRet+=String(SchResId(STR_TIP_DATASERIES)); + aRet+=aNewLine; + aRet+=String(SchResId(STR_TIP_DATAPOINT_VALUES)); + } + else + aRet=String(SchResId(STR_TIP_DATAPOINT)); + + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); + if( xDiagram.is() && xSeries.is() ) + { + sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + + //replace data point index + sal_Int32 nIndex = -1; + OUString aWildcard( C2U("%POINTNUMBER") ); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + { + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), OUString::valueOf(nPointIndex+1) ); + } + + //replace data series index + aWildcard = C2U("%SERIESNUMBER"); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + { + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( + DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + sal_Int32 nSeriesIndex = -1; + for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) + { + if( aSeriesVector[nSeriesIndex] == xSeries ) + { + break; + } + } + + OUString aReplacement( OUString::valueOf(nSeriesIndex+1) ); + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), aReplacement ); + } + + //replace point values + aWildcard = C2U("%POINTVALUES"); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataPointValueText( + xSeries,nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) ); + + //replace series name + aWildcard = C2U("%SERIESNAME"); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), lcl_getDataSeriesName( rObjectCID, xChartModel ) ); + } + } + /* + else if( OBJECTTYPE_DIAGRAM == eObjectType ) + { + //todo different names for different diagram types ??? + //or different names for series of diferent charttypes + } + */ + else if( OBJECTTYPE_DATA_CURVE == eObjectType ) + { + if( bVerbose ) + { + aRet = String( SchResId( STR_OBJECT_CURVE_WITH_PARAMETERS )); + Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel )); + Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + if( xCurveCnt.is()) + { + Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xCurveCnt )); + if( xCurve.is()) + { + try + { + Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW ); + RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); + + // replace formula + sal_Int32 nIndex = -1; + OUString aWildcard( C2U("%FORMULA") ); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + aRet = aRet.replaceAt( nIndex, aWildcard.getLength(), xCalculator->getRepresentation()); + + // replace r^2 + aWildcard = C2U("%RSQUARED"); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + { + sal_Unicode aDecimalSep( '.' ); + //@todo: enable this code when a localized decimal + //separator is also available for the formula +// SvtSysLocale aSysLocale; +// OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep()); +// if( aSep.getLength() == 1 ) +// aDecimalSep = aSep.toChar(); + double fR( xCalculator->getCorrelationCoefficient()); + aRet = aRet.replaceAt( + nIndex, aWildcard.getLength(), + ::rtl::math::doubleToUString( + fR*fR, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + else + { + // non-verbose + aRet = ObjectNameProvider::getName( eObjectType, false ); + } + } + else if( OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType ) + { + if( bVerbose ) + { + aRet = String( 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()) + { + Reference< chart2::XRegressionCurve > xCurve( RegressionCurveHelper::getMeanValueLine( xCurveCnt )); + if( xCurve.is()) + { + try + { + Reference< chart2::XRegressionCurveCalculator > xCalculator( xCurve->getCalculator(), uno::UNO_QUERY_THROW ); + RegressionCurveHelper::initializeCurveCalculator( xCalculator, xSeries, xChartModel ); + + sal_Unicode aDecimalSep( '.' ); + // replace average value +// SvtSysLocale aSysLocale; +// OUString aSep( aSysLocale.GetLocaleData().getNumDecimalSep()); +// if( aSep.getLength() == 1 ) +// aDecimalSep = aSep.toChar(); + + sal_Int32 nIndex = -1; + OUString aWildcard( C2U("%AVERAGE_VALUE") ); + nIndex = aRet.indexOf( aWildcard ); + // as the curve is constant, the value at any x-value is ok + if( nIndex != -1 ) + { + const double fMeanValue( xCalculator->getCurveValue( 0.0 )); + aRet = aRet.replaceAt( + nIndex, aWildcard.getLength(), + ::rtl::math::doubleToUString( + fMeanValue, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + } + + // replace standard deviation + aWildcard = C2U("%STD_DEVIATION"); + nIndex = aRet.indexOf( aWildcard ); + if( nIndex != -1 ) + { + const double fStdDev( xCalculator->getCorrelationCoefficient()); + aRet = aRet.replaceAt( + nIndex, aWildcard.getLength(), + ::rtl::math::doubleToUString( + fStdDev, rtl_math_StringFormat_G, 4, aDecimalSep, true )); + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + else + { + // non-verbose + aRet = ObjectNameProvider::getName( eObjectType, false ); + } + } + else + { + aRet = ObjectNameProvider::getName( eObjectType, false ); + } + return aRet; +} + +// static +rtl::OUString ObjectNameProvider::getSelectedObjectText( const rtl::OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ) +{ + rtl::OUString aRet; + ObjectType eObjectType( ObjectIdentifier::getObjectType(rObjectCID) ); + Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY ); + + if( OBJECTTYPE_DATA_POINT == eObjectType ) + { + aRet = String( SchResId( STR_STATUS_DATAPOINT_MARKED )); + + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rObjectCID , xChartModel ), uno::UNO_QUERY ); + if( xDiagram.is() && xSeries.is() ) + { + sal_Int32 nPointIndex( ObjectIdentifier::getParticleID(rObjectCID).toInt32() ); + + // replace data point index + replaceParamterInString( aRet, C2U("%POINTNUMBER"), OUString::valueOf( nPointIndex + 1 )); + + // replace data series index + { + ::std::vector< Reference< chart2::XDataSeries > > aSeriesVector( + DiagramHelper::getDataSeriesFromDiagram( xDiagram ) ); + sal_Int32 nSeriesIndex = -1; + for( nSeriesIndex=aSeriesVector.size();nSeriesIndex--;) + { + if( aSeriesVector[nSeriesIndex] == xSeries ) + break; + } + replaceParamterInString( aRet, C2U("%SERIESNUMBER"), OUString::valueOf( nSeriesIndex + 1 ) ); + } + + // replace point value + replaceParamterInString( aRet, C2U("%POINTVALUES"), lcl_getDataPointValueText( + xSeries, nPointIndex, DataSeriesHelper::getCoordinateSystemOfSeries(xSeries, xDiagram), xChartModel ) ); + } + } + else + { + // use the verbose text including the formula for trend lines + const bool bVerbose( OBJECTTYPE_DATA_CURVE == eObjectType || OBJECTTYPE_DATA_AVERAGE_LINE == eObjectType ); + const OUString aHelpText( getHelpText( rObjectCID, xChartModel, bVerbose )); + if( aHelpText.getLength()) + { + aRet = String( SchResId( STR_STATUS_OBJECT_MARKED )); + replaceParamterInString( aRet, C2U("%OBJECTNAME"), aHelpText ); + } + } + + return aRet; +} + + +// static +rtl::OUString ObjectNameProvider::getNameForCID( + const rtl::OUString& rObjectCID, + const uno::Reference< chart2::XChartDocument >& xChartDocument ) +{ + ObjectType eType( ObjectIdentifier::getObjectType( rObjectCID )); + Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY ); + + switch( eType ) + { + case OBJECTTYPE_AXIS: + return getAxisName( rObjectCID, xModel ); + case OBJECTTYPE_TITLE: + return getTitleName( rObjectCID, xModel ); + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: + return getGridName( rObjectCID, xModel ); + case OBJECTTYPE_DATA_SERIES: + return lcl_getFullSeriesName( rObjectCID, xModel ); + //case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_DATA_POINT: + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + case OBJECTTYPE_DATA_CURVE: + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_CURVE_EQUATION: + { + rtl::OUString aRet = lcl_getFullSeriesName( rObjectCID, xModel ); + aRet += C2U(" "); + if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) + { + aRet += getName( OBJECTTYPE_DATA_POINT ); + sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( rObjectCID ); + aRet += C2U(" "); + aRet += OUString::valueOf(nPointIndex+1); + + if( eType == OBJECTTYPE_DATA_LABEL ) + { + aRet += C2U(" "); + aRet += getName( OBJECTTYPE_DATA_LABEL ); + } + } + else + aRet += getName( eType ); + return aRet; + } + default: + break; + } + + return getName( eType ); +} + +//static +rtl::OUString ObjectNameProvider::getName_ObjectForSeries( + ObjectType eObjectType, + const rtl::OUString& rSeriesCID, + const uno::Reference< chart2::XChartDocument >& xChartDocument ) +{ + uno::Reference< frame::XModel> xChartModel( xChartDocument, uno::UNO_QUERY ); + Reference< XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( rSeriesCID , xChartModel ), uno::UNO_QUERY ); + if( xSeries.is() ) + { + OUString aRet = String(SchResId(STR_OBJECT_FOR_SERIES)); + replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, false /*bPlural*/ ) ); + replaceParamterInString( aRet, C2U("%SERIESNAME"), lcl_getDataSeriesName( rSeriesCID, xChartModel ) ); + return aRet; + } + else + return ObjectNameProvider::getName_ObjectForAllSeries( eObjectType ); +} + +//static +rtl::OUString ObjectNameProvider::getName_ObjectForAllSeries( ObjectType eObjectType ) +{ + OUString aRet = String(SchResId(STR_OBJECT_FOR_ALL_SERIES)); + replaceParamterInString( aRet, C2U("%OBJECTNAME"), getName( eObjectType, true /*bPlural*/ ) ); + return aRet; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/RangeEdit.cxx b/chart2/source/controller/dialogs/RangeEdit.cxx new file mode 100644 index 000000000000..9d17ea541aff --- /dev/null +++ b/chart2/source/controller/dialogs/RangeEdit.cxx @@ -0,0 +1,73 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeEdit.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "RangeEdit.hxx" + +namespace chart +{ + +//============================================================================ +// class RangeEdit +//---------------------------------------------------------------------------- +RangeEdit::RangeEdit( Window* pParent, const ResId& rResId): + Edit( pParent , rResId ) +{ + EnableUpdateData( 1000 ); +} + +RangeEdit::~RangeEdit() +{ +} + +void RangeEdit::SetKeyInputHdl( const Link& rKeyInputLink ) +{ + m_aKeyInputLink = rKeyInputLink; +} + +void RangeEdit::KeyInput( const KeyEvent& rKEvt ) +{ + const KeyCode& rKeyCode = rKEvt.GetKeyCode(); + if( !rKeyCode.GetModifier() && rKeyCode.GetCode() == KEY_F2 ) + { + if ( m_aKeyInputLink.IsSet() ) + { + m_aKeyInputLink.Call( NULL ); + } + } + else + Edit::KeyInput( rKEvt ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/RangeSelectionButton.cxx b/chart2/source/controller/dialogs/RangeSelectionButton.cxx new file mode 100644 index 000000000000..9e0749e91bb3 --- /dev/null +++ b/chart2/source/controller/dialogs/RangeSelectionButton.cxx @@ -0,0 +1,59 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionButton.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "RangeSelectionButton.hxx" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "Strings.hrc" +#include "ResId.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +RangeSelectionButton::RangeSelectionButton( Window *pParent, const ResId& rResId ) : + ImageButton( pParent, rResId ) +{ + SetModeImage( Image( SchResId(IMG_SELECTRANGE) ), BMP_COLOR_NORMAL ); + SetModeImage( Image( SchResId(IMG_SELECTRANGE_HC) ), BMP_COLOR_HIGHCONTRAST ); + this->SetQuickHelpText(SchResId(STR_TIP_SELECT_RANGE)); +} + +RangeSelectionButton::~RangeSelectionButton() +{ +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/RangeSelectionHelper.cxx b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx new file mode 100644 index 000000000000..88f93413ce67 --- /dev/null +++ b/chart2/source/controller/dialogs/RangeSelectionHelper.cxx @@ -0,0 +1,201 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionHelper.cxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "RangeSelectionHelper.hxx" +#include "RangeSelectionListener.hxx" +#include "macros.hxx" +#include "ControllerLockGuard.hxx" +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/text/XText.hpp> +#include <com/sun/star/embed/XEmbeddedObject.hpp> +#include <com/sun/star/embed/EmbedStates.hpp> +#include <com/sun/star/embed/XComponentSupplier.hpp> +#include <com/sun/star/sheet/XCellRangeAddressable.hpp> +#include <com/sun/star/sheet/XSpreadsheetDocument.hpp> +#include <com/sun/star/sheet/XCellRangesAccess.hpp> +#include <com/sun/star/chart2/data/XRangeXMLConversion.hpp> +#include <rtl/ustrbuf.hxx> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +// ---------------------------------------- + +namespace chart +{ + +RangeSelectionHelper::RangeSelectionHelper( + const Reference< chart2::XChartDocument > & xChartDocument ) : + m_xChartDocument( xChartDocument ) +{} + +RangeSelectionHelper::~RangeSelectionHelper() +{} + +bool RangeSelectionHelper::hasRangeSelection() +{ + return getRangeSelection().is(); +} + +Reference< sheet::XRangeSelection > RangeSelectionHelper::getRangeSelection() +{ + if( !m_xRangeSelection.is() && + m_xChartDocument.is() ) + { + try + { + Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); + if( xDataProvider.is()) + m_xRangeSelection.set( xDataProvider->getRangeSelection()); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + + m_xRangeSelection.clear(); + } + } + + return m_xRangeSelection; +} + +void RangeSelectionHelper::raiseRangeSelectionDocument() +{ + Reference< sheet::XRangeSelection > xRangeSel( getRangeSelection()); + if( xRangeSel.is()) + { + try + { + // bring document to front + Reference< frame::XController > xCtrl( xRangeSel, uno::UNO_QUERY ); + if( xCtrl.is()) + { + Reference< frame::XFrame > xFrame( xCtrl->getFrame()); + if( xFrame.is()) + { + Reference< awt::XTopWindow > xWin( xFrame->getContainerWindow(), + uno::UNO_QUERY_THROW ); + xWin->toFront(); + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } +} + +bool RangeSelectionHelper::chooseRange( + const OUString & aCurrentRange, + const OUString & aUIString, + RangeSelectionListenerParent & rListenerParent ) +{ + ControllerLockGuard aGuard( Reference< frame::XModel >(m_xChartDocument, uno::UNO_QUERY ) ); + + bool bResult = true; + raiseRangeSelectionDocument(); + + try + { + Reference< sheet::XRangeSelection > xRangeSel( getRangeSelection()); + if( xRangeSel.is()) + { + Sequence< beans::PropertyValue > aArgs( 4 ); + aArgs[0] = beans::PropertyValue( + C2U("InitialValue"), -1, uno::makeAny( aCurrentRange ), + beans::PropertyState_DIRECT_VALUE ); + aArgs[1] = beans::PropertyValue( + C2U("Title"), -1, + uno::makeAny( aUIString ), + beans::PropertyState_DIRECT_VALUE ); + aArgs[2] = beans::PropertyValue( + C2U("CloseOnMouseRelease"), -1, uno::makeAny( true ), + beans::PropertyState_DIRECT_VALUE ); + aArgs[3] = beans::PropertyValue( + C2U("MultiSelectionMode"), -1, uno::makeAny( true ), + beans::PropertyState_DIRECT_VALUE ); + + if( m_xRangeSelectionListener.is() ) + stopRangeListening(); + m_xRangeSelectionListener.set( Reference< sheet::XRangeSelectionListener >( + new RangeSelectionListener( rListenerParent, aCurrentRange, Reference< frame::XModel >(m_xChartDocument, uno::UNO_QUERY ) ))); + + xRangeSel->addRangeSelectionListener( m_xRangeSelectionListener ); + xRangeSel->startRangeSelection( aArgs ); + } + } + catch( uno::Exception & ex ) + { + bResult = false; + ASSERT_EXCEPTION( ex ); + } + + return bResult; +} + +void RangeSelectionHelper::stopRangeListening( bool bRemoveListener /* = true */ ) +{ + if( bRemoveListener && + m_xRangeSelectionListener.is() && + m_xRangeSelection.is() ) + { + m_xRangeSelection->removeRangeSelectionListener( m_xRangeSelectionListener ); + } + + m_xRangeSelectionListener = 0; +} + +bool RangeSelectionHelper::verifyCellRange( const OUString & rRangeStr ) +{ + Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); + if( ! xDataProvider.is()) + return false; + + return xDataProvider->createDataSequenceByRangeRepresentationPossible( rRangeStr ); +} + +bool RangeSelectionHelper::verifyArguments( const Sequence< beans::PropertyValue > & rArguments ) +{ + Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); + if( ! xDataProvider.is()) + return false; + + return xDataProvider->createDataSourcePossible( rArguments ); +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/RangeSelectionListener.cxx b/chart2/source/controller/dialogs/RangeSelectionListener.cxx new file mode 100644 index 000000000000..397124581280 --- /dev/null +++ b/chart2/source/controller/dialogs/RangeSelectionListener.cxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionListener.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "RangeSelectionListener.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +RangeSelectionListener::RangeSelectionListener( + RangeSelectionListenerParent & rParent, + const ::rtl::OUString & rInitialRange, + const Reference< frame::XModel >& xModelToLockController ) : + m_rParent( rParent ), + m_aRange( rInitialRange ), + m_aControllerLockGuard( xModelToLockController ) +{} + +RangeSelectionListener::~RangeSelectionListener() +{} + +// ____ XRangeSelectionListener ____ +void SAL_CALL RangeSelectionListener::done( const sheet::RangeSelectionEvent& aEvent ) + throw (uno::RuntimeException) +{ + m_aRange = aEvent.RangeDescriptor; + m_rParent.listeningFinished( m_aRange ); +} + +void SAL_CALL RangeSelectionListener::aborted( const sheet::RangeSelectionEvent& /*aEvent*/ ) + throw (uno::RuntimeException) +{ + m_rParent.listeningFinished( m_aRange ); +} + +// ____ XEventListener ____ +void SAL_CALL RangeSelectionListener::disposing( const lang::EventObject& /*Source*/ ) + throw (uno::RuntimeException) +{ + m_rParent.disposingRangeSelection(); +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/ResourceIds.hrc b/chart2/source/controller/dialogs/ResourceIds.hrc new file mode 100644 index 000000000000..8674aba240da --- /dev/null +++ b/chart2/source/controller/dialogs/ResourceIds.hrc @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ResourceIds.hrc,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_RESOURCE_IDS_HRC +#define _CHART2_RESOURCE_IDS_HRC + +//----------------------------------------------------------------------------- +//for strings see Strings.hrc + +//----------------------------------------------------------------------------- +//for Bimaps see Bimaps.hrc and Bimaps_HC.hrc + +//----------------------------------------------------------------------------- +//Dialog Ids: +#define DLG_DIAGRAM_TYPE 743 +#define DLG_CHART_WIZARD 902 +#define DLG_DATA_SOURCE 901 +#define DLG_AXIS_OR_GRID 839 +#define DLG_DATA_DESCR 836 +#define DLG_LEGEND 835 +#define DLG_TITLE 834 +#define DLG_3D_VIEW 752 +#define DLG_OBJECT_PROPERTIES 903 +#define DLG_SPLINE_PROPERTIES 904 +#define DLG_DATA_TRENDLINE 841 +#define DLG_DATA_YERRORBAR 842 + +//----------------------------------------------------------------------------- +//TabPage Ids: +#define TP_LEGEND_POS 900 +#define TP_DATA_DESCR 901 +#define TP_ALIGNMENT 902 +//#define TP_SYMBOL 906 +#define TP_LAYOUT 907 +#define TP_OPTIONS 908 +#define TP_POLAROPTIONS 909 +#define TP_AXIS_LABEL 920 +#define TP_SCALE 903 +#define TP_AXIS_POSITIONS 904 +#define TP_CHARTTYPE 910 +#define TP_RANGECHOOSER 911 +#define TP_WIZARD_TITLEANDOBJECTS 912 +#define TP_LOCATION 913 +#define TP_DATA_SOURCE 914 + +#define TP_3D_SCENEGEOMETRY 915 +#define TP_3D_SCENEAPPEARANCE 916 +#define TP_3D_SCENEILLUMINATION 917 + +#define TP_TRENDLINE 918 +#define TP_YERRORBAR 919 + +//----------------------------------------------------------------------------- +//listbox Ids: +#define LB_BAR_GEOMETRY 1000 +#define LB_TEXT_SEPARATOR 1001 + +//----------------------------------------------------------------------------- + +#endif diff --git a/chart2/source/controller/dialogs/Strings.src b/chart2/source/controller/dialogs/Strings.src new file mode 100644 index 000000000000..b7ef643e3ff3 --- /dev/null +++ b/chart2/source/controller/dialogs/Strings.src @@ -0,0 +1,606 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Strings.src,v $ + * $Revision: 1.12.72.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Strings.hrc" + +String STR_DLG_CHART_WIZARD +{ + Text [ en-US ] = "Chart Wizard" ; +}; + +String STR_DLG_SMOOTH_LINE_PROPERTIES +{ + Text [ en-US ] = "Smooth Lines" ; +}; + +String STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE +{ + Text [ en-US ] = "Number Format for Percentage Value" ; +}; + +String STR_PAGE_CHARTTYPE +{ + Text [ en-US ] = "Chart Type" ; +}; + +String STR_PAGE_DATA_RANGE +{ + Text [ en-US ] = "Data Range"; +}; + +String STR_PAGE_CHART_ELEMENTS +{ + Text [ en-US ] = "Chart Elements"; +}; + +String STR_PAGE_CHART_LOCATION +{ + Text [ en-US ] = "Chart Location"; +}; + +String STR_PAGE_LINE +{ + Text [ en-US ] = "Line" ; +}; + +String STR_PAGE_BORDER +{ + Text [ en-US ] = "Borders" ; +}; + +String STR_PAGE_AREA +{ + Text [ en-US ] = "Area" ; +}; + +String STR_PAGE_TRANSPARENCY +{ + Text [ en-US ] = "Transparency"; +}; + +String STR_PAGE_FONT +{ + Text [ en-US ] = "Font" ; +}; + +String STR_PAGE_FONT_EFFECTS +{ + Text [ en-US ] = "Font Effects" ; +}; + +String STR_PAGE_NUMBERS +{ + Text [ en-US ] = "Numbers" ; +}; + +String STR_PAGE_POSITION +{ + Text [ en-US ] = "Position" ; +}; + +String STR_PAGE_LAYOUT +{ + Text [ en-US ] = "Layout"; +}; + +String STR_PAGE_OPTIONS +{ + Text [ en-US ] = "Options"; +}; + +String STR_PAGE_SCALE +{ + Text [ en-US ] = "Scale" ; +}; + +String STR_PAGE_POSITIONING +{ + Text [ en-US ] = "Positioning" ; +}; + +// String STR_PAGE_STATISTICS +// { +// Text [ en-US ] = "Statistics" ; +// }; + +String STR_PAGE_TRENDLINE_TYPE +{ + Text[ en-US ] = "Type"; +}; + +String STR_PAGE_YERROR_BARS +{ + Text[ en-US ] = "Y Error Bars"; +}; + +String STR_PAGE_ALIGNMENT +{ + Text [ en-US ] = "Alignment" ; +}; + +String STR_PAGE_PERSPECTIVE +{ + Text [ en-US ] = "Perspective" ; +}; +String STR_PAGE_APPEARANCE +{ + Text [ en-US ] = "Appearance" ; +}; +String STR_PAGE_ILLUMINATION +{ + Text [ en-US ] = "Illumination" ; +}; + +String STR_PAGE_ASIAN +{ + Text [ en-US ] = "Asian Typography" ; +}; + +String STR_OBJECT_AVERAGE_LINE_WITH_PARAMETERS +{ + Text [ en-US ] = "Mean value line with value %AVERAGE_VALUE and standard deviation %STD_DEVIATION"; +}; + +String STR_OBJECT_AXIS +{ + Text [ en-US ] = "Axis" ; +}; +String STR_OBJECT_AXIS_X +{ + Text [ en-US ] = "X Axis" ; +}; +String STR_OBJECT_AXIS_Y +{ + Text [ en-US ] = "Y Axis" ; +}; +String STR_OBJECT_AXIS_Z +{ + Text [ en-US ] = "Z Axis" ; +}; +String STR_OBJECT_SECONDARY_X_AXIS +{ + Text [ en-US ] = "Secondary X Axis" ; +}; +String STR_OBJECT_SECONDARY_Y_AXIS +{ + Text [ en-US ] = "Secondary Y Axis" ; +}; + +String STR_OBJECT_AXES +{ + Text [ en-US ] = "Axes" ; +}; +String STR_OBJECT_GRIDS +{ + Text [ en-US ] = "Grids" ; +}; +String STR_OBJECT_GRID +{ + Text [ en-US ] = "Grid" ; +}; +String STR_OBJECT_GRID_MAJOR_X +{ + Text [ en-US ] = "X Axis Major Grid" ; +}; +String STR_OBJECT_GRID_MAJOR_Y +{ + Text [ en-US ] = "Y Axis Major Grid" ; +}; +String STR_OBJECT_GRID_MAJOR_Z +{ + Text [ en-US ] = "Z Axis Major Grid" ; +}; +String STR_OBJECT_GRID_MINOR_X +{ + Text [ en-US ] = "X Axis Minor Grid" ; +}; +String STR_OBJECT_GRID_MINOR_Y +{ + Text [ en-US ] = "Y Axis Minor Grid" ; +}; +String STR_OBJECT_GRID_MINOR_Z +{ + Text [ en-US ] = "Z Axis Minor Grid" ; +}; + +String STR_OBJECT_LEGEND +{ + Text [ en-US ] = "Legend" ; +}; + +String STR_OBJECT_TITLE +{ + Text [ en-US ] = "Title" ; +}; +String STR_OBJECT_TITLES +{ + Text [ en-US ] = "Titles" ; +}; +String STR_OBJECT_TITLE_MAIN +{ + Text [ en-US ] = "Main Title" ; +}; +String STR_OBJECT_TITLE_SUB +{ + Text [ en-US ] = "Subtitle" ; +}; +String STR_OBJECT_TITLE_X_AXIS +{ + Text [ en-US ] = "X Axis Title" ; +}; +String STR_OBJECT_TITLE_Y_AXIS +{ + Text [ en-US ] = "Y Axis Title" ; +}; +String STR_OBJECT_TITLE_Z_AXIS +{ + Text [ en-US ] = "Z Axis Title" ; +}; +String STR_OBJECT_TITLE_SECONDARY_X_AXIS +{ + Text [ en-US ] = "Secondary X Axis Title" ; +}; +String STR_OBJECT_TITLE_SECONDARY_Y_AXIS +{ + Text [ en-US ] = "Secondary Y Axis Title" ; +}; +String STR_OBJECT_LABEL +{ + Text [ en-US ] = "Label" ; +}; + +String STR_OBJECT_DATALABELS +{ + Text [ en-US ] = "Data Labels" ; +}; +String STR_OBJECT_DATAPOINT +{ + Text [ en-US ] = "Data Point" ; +}; +String STR_OBJECT_DATAPOINTS +{ + Text [ en-US ] = "Data Points" ; +}; +String STR_OBJECT_LEGEND_SYMBOL +{ + Text [ en-US ] = "Legend Key" ; +}; +String STR_OBJECT_DATASERIES +{ + Text [ en-US ] = "Data Series" ; +}; +String STR_OBJECT_DATASERIES_PLURAL +{ + Text [ en-US ] = "Data Series" ; +}; +String STR_OBJECT_CURVE +{ + Text [ en-US ] = "Trend Line"; +}; +String STR_OBJECT_CURVES +{ + Text [ en-US ] = "Trend Lines"; +}; +String STR_OBJECT_CURVE_WITH_PARAMETERS +{ + Text [ en-US ] = "Trend line %FORMULA with accuracy R² = %RSQUARED"; +}; +String STR_OBJECT_AVERAGE_LINE +{ + Text [ en-US ] = "Mean Value Line"; +}; +String STR_OBJECT_CURVE_EQUATION +{ + Text[ en-US ] = "Equation"; +}; + +String STR_OBJECT_ERROR_BARS +{ + Text [ en-US ] = "Error Bars"; +}; +String STR_OBJECT_STOCK_LOSS +{ + Text [ en-US ] = "Stock Loss"; +}; + +String STR_OBJECT_STOCK_GAIN +{ + Text [ en-US ] = "Stock Gain"; +}; + +String STR_OBJECT_PAGE +{ + Text [ en-US ] = "Chart Area" ; +}; +String STR_OBJECT_DIAGRAM +{ + Text [ en-US ] = "Chart" ; +}; +String STR_OBJECT_DIAGRAM_WALL +{ + Text [ en-US ] = "Chart Wall" ; +}; +String STR_OBJECT_DIAGRAM_FLOOR +{ + Text [ en-US ] = "Chart Floor" ; +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +String STR_TIP_SELECT_RANGE +{ + Text [ en-US ] = "Select data range" ; +}; + +String STR_TIP_CHOOSECOLOR +{ + Text [ en-US ] = "Select a color using the color dialog" ; +}; + +String STR_TIP_LIGHTSOURCE_X +{ + Text [ en-US ] = "Light Source %LIGHTNUMBER" ; +}; + +String STR_TIP_DATASERIES +{ + Text [ en-US ] = "Data Series '%SERIESNAME'" ; +}; + +String STR_TIP_DATAPOINT_INDEX +{ + Text [ en-US ] = "Data Point %POINTNUMBER"; +}; + +String STR_TIP_DATAPOINT_VALUES +{ + Text [ en-US ] = "Values: %POINTVALUES"; +}; + +String STR_TIP_CATEGORY_VALUE +{ + Text [ en-US ] = "'%CATEGORYVALUE'"; +}; + +String STR_TIP_DATAPOINT +{ + Text [ en-US ] = "Data Point %POINTNUMBER, data series %SERIESNUMBER, values: %POINTVALUES"; +}; + +String STR_STATUS_DATAPOINT_MARKED +{ + Text [ en-US ] = "Data point %POINTNUMBER in data series %SERIESNUMBER selected, values: %POINTVALUES"; +}; + +String STR_STATUS_OBJECT_MARKED +{ + Text [ en-US ] = "%OBJECTNAME selected" ; +}; + +String STR_STATUS_PIE_SEGMENT_EXPLODED +{ + Text [ en-US ] = "Pie exploded by %PERCENTVALUE percent"; +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +String STR_OBJECT_FOR_SERIES +{ + Text [ en-US ] = "%OBJECTNAME for Data Series '%SERIESNAME'" ; +}; + +String STR_OBJECT_FOR_ALL_SERIES +{ + Text [ en-US ] = "%OBJECTNAME for all Data Series" ; +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +String STR_ACTION_EDIT_CHARTTYPE +{ + Text [ en-US ] = "Edit chart type" ; +}; +String STR_ACTION_EDIT_DATA_RANGES +{ + Text [ en-US ] = "Edit data ranges" ; +}; +String STR_ACTION_EDIT_3D_VIEW +{ + Text [ en-US ] = "Edit 3D view" ; +}; +String STR_ACTION_EDIT_CHART_DATA +{ + Text [ en-US ] = "Edit chart data"; +}; +String STR_ACTION_TOGGLE_LEGEND +{ + Text [ en-US ] = "Legend on/off" ; +}; +String STR_ACTION_TOGGLE_GRID_HORZ +{ + Text [ en-US ] = "Horizontal grid on/off" ; +}; +String STR_ACTION_SCALE_TEXT +{ + Text [ en-US ] = "Scale Text" ; +}; +String STR_ACTION_REARRANGE_CHART +{ + Text [ en-US ] = "Automatic Layout" ; +}; +String STR_ACTION_NOTPOSSIBLE +{ + Text [ en-US ] = "This function cannot be completed with the selected objects." ; +}; + +String STR_COLUMN_LABEL +{ + Text [ en-US ] = "Column %COLUMNNUMBER" ; +}; +String STR_ROW_LABEL +{ + Text [ en-US ] = "Row %ROWNUMBER" ; +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//for range didalog +String STR_DATA_ROLE_LABEL +{ + Text [ en-US ] = "Name" ; +}; + +String STR_DATA_ROLE_X +{ + Text [ en-US ] = "X-Values" ; +}; + +String STR_DATA_ROLE_Y +{ + Text [ en-US ] = "Y-Values" ; +}; + +String STR_DATA_ROLE_SIZE +{ + Text [ en-US ] = "Bubble Sizes" ; +}; + +String STR_DATA_ROLE_X_ERROR +{ + Text [ en-US ] = "X-Error-Bars" ; +}; +String STR_DATA_ROLE_X_ERROR_POSITIVE +{ + Text [ en-US ] = "Positive X-Error-Bars" ; +}; +String STR_DATA_ROLE_X_ERROR_NEGATIVE +{ + Text [ en-US ] = "Negative X-Error-Bars" ; +}; + +String STR_DATA_ROLE_Y_ERROR +{ + Text [ en-US ] = "Y-Error-Bars" ; +}; +String STR_DATA_ROLE_Y_ERROR_POSITIVE +{ + Text [ en-US ] = "Positive Y-Error-Bars" ; +}; +String STR_DATA_ROLE_Y_ERROR_NEGATIVE +{ + Text [ en-US ] = "Negative Y-Error-Bars" ; +}; + +String STR_DATA_ROLE_FIRST +{ + Text [ en-US ] = "Open Values" ; +}; + +String STR_DATA_ROLE_LAST +{ + Text [ en-US ] = "Close Values" ; +}; + +String STR_DATA_ROLE_MIN +{ + Text [ en-US ] = "Low Values" ; +}; + +String STR_DATA_ROLE_MAX +{ + Text [ en-US ] = "High Values" ; +}; + +String STR_DATA_ROLE_CATEGORIES +{ + Text [ en-US ] = "Categories"; +}; + +String STR_DATA_UNNAMED_SERIES +{ + Text [ en-US ] = "Unnamed Series"; +}; + +String STR_DATA_UNNAMED_SERIES_WITH_INDEX +{ + Text [ en-US ] = "Unnamed Series %NUMBER" ; +}; + +String STR_DATA_SELECT_RANGE_FOR_SERIES +{ + Text [ en-US ] = "Select Range for %VALUETYPE of %SERIESNAME" ; +}; + +String STR_DATA_SELECT_RANGE_FOR_CATEGORIES +{ + Text [ en-US ] = "Select Range for Categories" ; +}; + +String STR_DATA_SELECT_RANGE_FOR_DATALABELS +{ + Text [ en-US ] = "Select Range for data labels" ; +}; +String STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS +{ + Text [ en-US ] = "Select Range for Positive Error Bars" ; +}; +String STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS +{ + Text [ en-US ] = "Select Range for Negative Error Bars" ; +}; + +String STR_DATA_EDITOR_INCORRECT_INPUT +{ + Text [ en-US ] = "Your last input is incorrect.\nIgnore this change and close the dialog?" ; +}; + +// frame direction ------------------------------------------------------------ + +String STR_TEXT_DIRECTION_LTR +{ + Text [ en-US ] = "Left-to-right"; +}; + +String STR_TEXT_DIRECTION_RTL +{ + Text [ en-US ] = "Right-to-left"; +}; + +String STR_TEXT_DIRECTION_SUPER +{ + Text [ en-US ] = "Use superordinate object settings"; +}; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- diff --git a/chart2/source/controller/dialogs/Strings_AdditionalControls.src b/chart2/source/controller/dialogs/Strings_AdditionalControls.src new file mode 100644 index 000000000000..0da80dd482d2 --- /dev/null +++ b/chart2/source/controller/dialogs/Strings_AdditionalControls.src @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Strings_AdditionalControls.src,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Strings.hrc" + +String STR_3DSCHEME_SIMPLE +{ + Text [ en-US ] = "Simple"; +}; +String STR_3DSCHEME_REALISTIC +{ + Text [ en-US ] = "Realistic"; +}; +String STR_3DSCHEME_CUSTOM +{ + Text [ en-US ] = "Custom"; +}; + +String STR_BAR_GEOMETRY +{ + Text [ en-US ] = "Shape"; +}; + +String STR_NUMBER_OF_LINES +{ + Text [ en-US ] = "~Number of lines"; +}; + +String STR_TEXT_SEPARATOR +{ + Text [ en-US ] = "Separator"; +}; + +//----------------------------------- diff --git a/chart2/source/controller/dialogs/Strings_ChartTypes.src b/chart2/source/controller/dialogs/Strings_ChartTypes.src new file mode 100644 index 000000000000..f2731b2971c2 --- /dev/null +++ b/chart2/source/controller/dialogs/Strings_ChartTypes.src @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Strings_ChartTypes.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Strings.hrc" + +String STR_TYPE_COLUMN +{ + Text [ en-US ] = "Column" ; +}; +String STR_TYPE_BAR +{ + Text [ en-US ] = "Bar" ; +}; +String STR_TYPE_AREA +{ + Text [ en-US ] = "Area" ; +}; +String STR_TYPE_PIE +{ + Text [ en-US ] = "Pie" ; +}; +String STR_PIE_EXPLODED +{ + Text [ en-US ] = "Exploded Pie Chart" ; +}; +String STR_DONUT_EXPLODED +{ + Text [ en-US ] = "Exploded Donut Chart" ; +}; +String STR_DONUT +{ + Text [ en-US ] = "Donut" ; +}; +String STR_TYPE_LINE +{ + Text [ en-US ] = "Line" ; +}; +String STR_TYPE_XY +{ + Text [ en-US ] = "XY (Scatter)" ; +}; +String STR_POINTS_AND_LINES +{ + Text [ en-US ] = "Points and Lines" ; +}; +String STR_POINTS_ONLY +{ + //@todo or symbols instead of points?? + Text [ en-US ] = "Points Only" ; +}; +String STR_LINES_ONLY +{ + Text [ en-US ] = "Lines Only" ; +}; +String STR_LINES_3D +{ + Text [ en-US ] = "3D Lines" ; +}; +//----------------------------------------------------------------------------- +String STR_TYPE_COMBI_COLUMN_LINE +{ + Text [ en-US ] = "Column and Line" ; +}; +String STR_LINE_COLUMN +{ + Text [ en-US ] = "Columns and Lines" ; +}; +String STR_LINE_STACKEDCOLUMN +{ + Text [ en-US ] = "Stacked Columns and Lines" ; +}; +//----------------------------------------------------------------------------- +String STR_TYPE_NET +{ + Text [ en-US ] = "Net" ; +}; +//----------------------------------------------------------------------------- +String STR_TYPE_STOCK +{ + Text [ en-US ] = "Stock"; +}; +String STR_STOCK_1 +{ + Text [ en-US ] = "Stock Chart 1"; +}; +String STR_STOCK_2 +{ + Text [ en-US ] = "Stock Chart 2"; +}; +String STR_STOCK_3 +{ + Text [ en-US ] = "Stock Chart 3"; +}; +String STR_STOCK_4 +{ + Text [ en-US ] = "Stock Chart 4"; +}; +//----------------------------------------------------------------------------- +String STR_NORMAL +{ + Text [ en-US ] = "Normal" ; +}; +String STR_STACKED +{ + Text [ en-US ] = "Stacked" ; +}; +String STR_PERCENT +{ + Text [ en-US ] = "Percent Stacked" ; +}; + +String STR_DEEP +{ + Text [ en-US ] = "Deep" ; +}; +String STR_FILLED +{ + Text [ en-US ] = "Filled" ; +}; +//----------------------------------------------------------------------------- +String STR_TYPE_BUBBLE +{ + Text [ en-US ] = "Bubble" ; +}; +String STR_BUBBLE_1 +{ + Text [ en-US ] = "Bubble Chart" ; +}; +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- diff --git a/chart2/source/controller/dialogs/Strings_Scale.src b/chart2/source/controller/dialogs/Strings_Scale.src new file mode 100644 index 000000000000..b1234548b43d --- /dev/null +++ b/chart2/source/controller/dialogs/Strings_Scale.src @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Strings_Scale.src,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Strings.hrc" + +String STR_INVALID_NUMBER +{ + Text [ en-US ] = "Numbers are required. Check your input." ; +}; +String STR_STEP_GT_ZERO +{ + Text [ en-US ] = "The major interval requires a positive number. Check your input." ; +}; +String STR_BAD_LOGARITHM +{ + Text [ en-US ] = "The logarithmic scale requires positive numbers. Check your input." ; +}; +String STR_MIN_GREATER_MAX +{ + Text [ en-US ] = "The minimum must be lower than the maximum. Check your input." ; +}; diff --git a/chart2/source/controller/dialogs/Strings_Statistic.src b/chart2/source/controller/dialogs/Strings_Statistic.src new file mode 100644 index 000000000000..9f6572c6ae82 --- /dev/null +++ b/chart2/source/controller/dialogs/Strings_Statistic.src @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: Strings_Statistic.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "Strings.hrc" + +//SchStatisticTabPage and SchDataStatisticsDlg +String STR_INDICATE_BOTH +{ + Text [ en-US ] = "Negative and Positive" ; +}; +String STR_INDICATE_DOWN +{ + Text [ en-US ] = "Negative" ; +}; +String STR_INDICATE_UP +{ + Text [ en-US ] = "Positive" ; +}; + +// used for own data in error bar dialog +String STR_CONTROLTEXT_ERROR_BARS_FROM_DATA +{ + Text [ en-US ] = "From Data Table" ; +}; + +//------------------------------------------------------------------------ +//------------------------------------------------------------------------ + +String STR_REGRESSION_LINEAR +{ + Text [ en-US ] = "Linear Regression" ; +}; +String STR_REGRESSION_LOG +{ + Text [ en-US ] = "Logarithmic Regression" ; +}; +String STR_REGRESSION_EXP +{ + Text [ en-US ] = "Exponential Regression" ; +}; +String STR_REGRESSION_POWER +{ + Text [ en-US ] = "Power Regression" ; +}; + +String STR_STATISTICS_IN_LEGEND +{ + Text [ en-US ] = "%REGRESSIONCURVE for %SERIESNAME" ; +}; diff --git a/chart2/source/controller/dialogs/TabPages.hrc b/chart2/source/controller/dialogs/TabPages.hrc new file mode 100644 index 000000000000..8c92c062ad14 --- /dev/null +++ b/chart2/source/controller/dialogs/TabPages.hrc @@ -0,0 +1,176 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TabPages.hrc,v $ + * $Revision: 1.7.20.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_TABPAGES_HRC +#define CHART_TABPAGES_HRC + +#include "ResourceIds.hrc" + +//see attrib.hrc in old chart + +//#define TP_LEGEND_POS 900 +#define GRP_LEGEND 1 +#define FL_LEGEND_TEXTORIENT 2 +#define FT_LEGEND_TEXTDIR 3 +#define LB_LEGEND_TEXTDIR 4 + +//#define TP_DATA_DESCR 901 + +//#define TP_ALIGNMENT 902 +////#define FL_ORDER 2 +////#define RBT_SIDEBYSIDE 1 +////#define RBT_UPDOWN 2 +////#define RBT_DOWNUP 3 +////#define RBT_AUTOORDER 4 + +//#define TP_STAT 905 +#define FL_TEXTBREAK 3 +#define CBX_TEXTBREAK 2 +#define CBX_TEXTOVERLAP 4 + +//Seit 4/1998 koennen Texte frei gedreht werden: SCHATTR_TEXT_DEGREES +// ID's for title rotation tabpage +#define CTR_DIAL 6030 +#define BTN_TXTSTACKED 6031 +#define FT_DEGREES 6032 +#define NF_ORIENT 6033 +#define CTR_DUMMY 6034 +#define FT_DUMMY 6035 +#define FL_ALIGN 6037 +#define FT_TEXTDIR 6038 +#define LB_TEXTDIR 6039 + +/* +//Symbol-Tabpage (zum Teil sehr Aehnlich der SVX_AREA_TABPAGE) (obsolete) +//#define TP_SYMBOL 906 +#define RBT_COLOR 1 +#define RBT_GRADIENT 2 +#define RBT_HATCHING 3 +#define RBT_BITMAP 4 +#define RBT_INVISIBLE 5 +#define LB_COLOR 1 +#define LB_GRADIENT 2 +#define LB_HATCHING 3 +#define LB_BITMAP 4 + +#define GRP_FILL 1 +#define CTL_BITMAP_PREVIEW 6 +*/ + +//------------ +//from old chart tplabel.hrc + +//#define TP_AXIS_LABEL 920 + +#define CB_AXIS_LABEL_SCHOW_DESCR 1 + +//#define FL_AXIS_LABEL_FORMATTING 2 + +#define FL_AXIS_LABEL_ORIENTATION 3 +#define CT_AXIS_LABEL_DIAL 4 +#define PB_AXIS_LABEL_TEXTSTACKED 5 +#define FT_AXIS_LABEL_DEGREES 6 +#define NF_AXIS_LABEL_ORIENT 7 +#define FT_UNUSED 8 +#define CT_UNUSED 9 + +#define FL_AXIS_LABEL_TEXTFLOW 10 +#define CB_AXIS_LABEL_TEXTOVERLAP 11 +#define CB_AXIS_LABEL_TEXTBREAK 12 + +#define FL_AXIS_LABEL_ORDER 13 +#define RB_AXIS_LABEL_SIDEBYSIDE 14 +#define RB_AXIS_LABEL_UPDOWN 15 +#define RB_AXIS_LABEL_DOWNUP 16 +#define RB_AXIS_LABEL_AUTOORDER 17 + +#define FL_SEPARATOR 18 + +#define FT_AXIS_TEXTDIR 19 +#define LB_AXIS_TEXTDIR 20 + +//#define TP_SCALE 903 + +#define FL_SCALE 1 + +#define TXT_MIN 1 +#define TXT_MAX 2 +#define TXT_STEP_MAIN 3 +#define TXT_STEP_HELP 4 +#define TXT_ORIGIN 5 + +#define CBX_AUTO_MIN 1 +#define CBX_AUTO_MAX 2 +#define CBX_AUTO_STEP_MAIN 3 +#define CBX_AUTO_STEP_HELP 4 +#define CBX_AUTO_ORIGIN 5 +#define CBX_LOGARITHM 6 +#define CBX_REVERSE 7 + +#define EDT_STEP_MAIN 1 +#define EDT_MAX 2 +#define EDT_MIN 3 +#define EDT_ORIGIN 4 + +#define MT_STEPHELP 10 + +//#define TP_AXIS_POSITIONS 904 + +#define FL_AXIS_LINE 1 +#define FL_LABELS 2 +#define FL_TICKS 3 +#define FL_VERTICAL 4 +#define FL_GRIDS 5 + +#define FT_CROSSES_OTHER_AXIS_AT 1 +#define FT_AXIS_LABEL_DISTANCE 2 +#define FT_PLACE_LABELS 3 +#define FT_MAJOR 4 +#define FT_MINOR 5 +#define FT_PLACE_TICKS 6 + +#define LB_CROSSES_OTHER_AXIS_AT 1 +#define LB_PLACE_LABELS 2 +#define EDT_CROSSES_OTHER_AXIS_AT 3 +#define EDT_CROSSES_OTHER_AXIS_AT_CATEGORY 4 +#define EDT_AXIS_LABEL_DISTANCE 5 +#define LB_PLACE_TICKS 6 + +#define CB_AXIS_BETWEEN_CATEGORIES 1 +#define CB_TICKS_INNER 2 +#define CB_TICKS_OUTER 3 +#define CB_MINOR_INNER 4 +#define CB_MINOR_OUTER 5 +#define CB_MAJOR_GRID 6 +#define CB_MINOR_GRID 7 + +#define PB_MAJOR_GRID 1 +#define PB_MINOR_GRID 2 + +#endif diff --git a/chart2/source/controller/dialogs/TextDirectionListBox.cxx b/chart2/source/controller/dialogs/TextDirectionListBox.cxx new file mode 100644 index 000000000000..d1365b908eac --- /dev/null +++ b/chart2/source/controller/dialogs/TextDirectionListBox.cxx @@ -0,0 +1,63 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TextDirectionListBox.cxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "TextDirectionListBox.hxx" +#include "ResId.hxx" +#include "Strings.hrc" +#include <svtools/languageoptions.hxx> +#include <vcl/window.hxx> + +namespace chart +{ + +TextDirectionListBox::TextDirectionListBox( Window* pParent, const ResId& rResId, Window* pWindow1, Window* pWindow2 ) : + svx::FrameDirectionListBox( pParent, rResId ) +{ + InsertEntryValue( String( SchResId( STR_TEXT_DIRECTION_LTR ) ), FRMDIR_HORI_LEFT_TOP ); + InsertEntryValue( String( SchResId( STR_TEXT_DIRECTION_RTL ) ), FRMDIR_HORI_RIGHT_TOP ); + InsertEntryValue( String( SchResId( STR_TEXT_DIRECTION_SUPER ) ), FRMDIR_ENVIRONMENT ); + + if( !SvtLanguageOptions().IsCTLFontEnabled() ) + { + Hide(); + if( pWindow1 ) pWindow1->Hide(); + if( pWindow2 ) pWindow2->Hide(); + } +} + +TextDirectionListBox::~TextDirectionListBox() +{ +} + +} //namespace chart + diff --git a/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx b/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx new file mode 100644 index 000000000000..54d520eef94d --- /dev/null +++ b/chart2/source/controller/dialogs/TimerTriggeredControllerLock.cxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TimerTriggeredControllerLock.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "TimerTriggeredControllerLock.hxx" + +// header for define EDIT_UPDATEDATA_TIMEOUT +#include <vcl/edit.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; + +TimerTriggeredControllerLock::TimerTriggeredControllerLock( const uno::Reference< frame::XModel >& xModel ) + : m_xModel( xModel ) + , m_apControllerLockGuard() + , m_aTimer() +{ + m_aTimer.SetTimeout( 4*EDIT_UPDATEDATA_TIMEOUT ); + m_aTimer.SetTimeoutHdl( LINK( this, TimerTriggeredControllerLock, TimerTimeout ) ); +} +TimerTriggeredControllerLock::~TimerTriggeredControllerLock() +{ + m_aTimer.Stop(); +} + +void TimerTriggeredControllerLock::startTimer() +{ + if(!m_apControllerLockGuard.get()) + m_apControllerLockGuard = std::auto_ptr< ControllerLockGuard >( new ControllerLockGuard(m_xModel) ); + m_aTimer.Start(); +} +IMPL_LINK( TimerTriggeredControllerLock, TimerTimeout, void*, EMPTYARG ) +{ + m_apControllerLockGuard.reset(); + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/TitleDialogData.cxx b/chart2/source/controller/dialogs/TitleDialogData.cxx new file mode 100644 index 000000000000..4f5418df04cc --- /dev/null +++ b/chart2/source/controller/dialogs/TitleDialogData.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleDialogData.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "TitleDialogData.hxx" +#include "TitleHelper.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +TitleDialogData::TitleDialogData( ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider ) + : aPossibilityList(7) + , aExistenceList(7) + , aTextList(7) + , apReferenceSizeProvider( apRefSizeProvider ) +{ + sal_Int32 nN = 0; + for(nN=7;nN--;) + aPossibilityList[nN]=sal_True; + for(nN=7;nN--;) + aExistenceList[nN]=sal_False; +} + +void TitleDialogData::readFromModel( const uno::Reference< frame::XModel>& xChartModel ) +{ + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(xChartModel); + + //get possibilities + uno::Sequence< sal_Bool > aAxisPossibilityList; + AxisHelper::getAxisOrGridPossibilities( aAxisPossibilityList, xDiagram ); + this->aPossibilityList[2]=aAxisPossibilityList[0];//x axis title + this->aPossibilityList[3]=aAxisPossibilityList[1];//y axis title + this->aPossibilityList[4]=aAxisPossibilityList[2];//z axis title + this->aPossibilityList[5]=aAxisPossibilityList[3];//secondary x axis title + this->aPossibilityList[6]=aAxisPossibilityList[4];//secondary y axis title + + //find out which title exsist 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 ); + nTitleIndex++) + { + uno::Reference< XTitle > xTitle = TitleHelper::getTitle( + static_cast< TitleHelper::eTitleType >( nTitleIndex ), xChartModel ); + this->aExistenceList[nTitleIndex] = xTitle.is(); + this->aTextList[nTitleIndex]=TitleHelper::getCompleteString( xTitle ); + } +} + +bool TitleDialogData::writeDifferenceToModel( + const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext + , 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 ); + nN++) + { + if( !pOldState || ( pOldState->aExistenceList[nN] != this->aExistenceList[nN] ) ) + { + if(this->aExistenceList[nN]) + { + TitleHelper::createTitle( + static_cast< TitleHelper::eTitleType >( nN ), this->aTextList[nN], xChartModel, xContext, + apReferenceSizeProvider.get() ); + bChanged = true; + } + else + { + TitleHelper::removeTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ); + bChanged = true; + } + } + else if( !pOldState || ( pOldState->aTextList[nN] != this->aTextList[nN] ) ) + { + //change content + uno::Reference< XTitle > xTitle( + TitleHelper::getTitle( static_cast< TitleHelper::eTitleType >( nN ), xChartModel ) ); + if(xTitle.is()) + { + TitleHelper::setCompleteString( this->aTextList[nN], xTitle, xContext ); + bChanged = true; + } + } + } + return bChanged; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_ChartType.cxx b/chart2/source/controller/dialogs/dlg_ChartType.cxx new file mode 100644 index 000000000000..74e112132d87 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ChartType.cxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType.cxx,v $ + * $Revision: 1.15 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_ChartType.hxx" +#include "dlg_ChartType.hrc" +#include "ResId.hxx" +#include "ResourceIds.hrc" +#include "Strings.hrc" +#include "tp_ChartType.hxx" +#include "macros.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +ChartTypeDialog::ChartTypeDialog( Window* pParent + , const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext ) + : ModalDialog( pParent, SchResId( DLG_DIAGRAM_TYPE )) + , m_aFL( this, SchResId( FL_BUTTONS ) ) + , m_aBtnOK( this, SchResId( BTN_OK ) ) + , m_aBtnCancel( this, SchResId( BTN_CANCEL ) ) + , m_aBtnHelp( this, SchResId( BTN_HELP ) ) + , m_pChartTypeTabPage(0) + , m_xChartModel(xChartModel) + , m_xCC( xContext ) +{ + FreeResource(); + + this->SetText(String(SchResId(STR_PAGE_CHARTTYPE))); + + //don't create the tabpages before FreeResource, otherwise the help ids are not matched correctly + m_pChartTypeTabPage = new ChartTypeTabPage(this,uno::Reference< XChartDocument >::query(m_xChartModel),m_xCC,true/*live update*/,true/*hide title description*/); + m_pChartTypeTabPage->initializePage(); + m_pChartTypeTabPage->Show(); + } + +ChartTypeDialog::~ChartTypeDialog() +{ + delete m_pChartTypeTabPage; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_ChartType.hrc b/chart2/source/controller/dialogs/dlg_ChartType.hrc new file mode 100644 index 000000000000..2c7af5c390ab --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ChartType.hrc @@ -0,0 +1,38 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define TABCTRL 1 + +#define FL_BUTTONS 1 + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 diff --git a/chart2/source/controller/dialogs/dlg_ChartType.src b/chart2/source/controller/dialogs/dlg_ChartType.src new file mode 100644 index 000000000000..819462716bb6 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ChartType.src @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType.src,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_ChartType.hrc" +#include "dlg_CreationWizard.hrc" +#include "HelpIds.hrc" +#include "SchSlotIds.hxx" + +// for BUTTONS_OK_CANCEL_HELP_STACKED +#include "CommonResources.hrc" + +#define CHART_TYPE_DLG_HEIGHT (CHART_WIZARD_PAGEHEIGHT+18) +#define CHART_TYPE_DLG_WIDTH (CHART_WIZARD_PAGEWIDTH - 7) + +ModalDialog DLG_DIAGRAM_TYPE +{ + HelpID = SID_DIAGRAM_TYPE ; + + Size = MAP_APPFONT ( CHART_TYPE_DLG_WIDTH , CHART_TYPE_DLG_HEIGHT ) ; + + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + + FixedLine FL_BUTTONS + { + Pos = MAP_APPFONT ( 0 , CHART_TYPE_DLG_HEIGHT-24 ) ; + Size = MAP_APPFONT ( CHART_TYPE_DLG_WIDTH , 8 ) ; + }; + + BUTTONS_OK_CANCEL_HELP( CHART_TYPE_DLG_WIDTH-161 ,CHART_TYPE_DLG_HEIGHT-17 , 53, 0 ) +}; diff --git a/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx b/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx new file mode 100644 index 000000000000..4cbc53bf453f --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ChartType_UNO.cxx @@ -0,0 +1,142 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType_UNO.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_ChartType_UNO.hxx" +#include "dlg_ChartType.hxx" +#include "servicenames.hxx" +#include <osl/mutex.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +uno::Reference< uno::XInterface > + SAL_CALL ChartTypeUnoDlg::Create(const uno::Reference< uno::XComponentContext >& _xContext) +{ + return *(new ChartTypeUnoDlg(_xContext)); +} +// ----------------------------------------------------------------------------- +ChartTypeUnoDlg::ChartTypeUnoDlg( const uno::Reference< uno::XComponentContext >& _xContext ) + : ChartTypeUnoDlg_BASE( _xContext ) +{ +} +// ----------------------------------------------------------------------------- +ChartTypeUnoDlg::~ChartTypeUnoDlg() +{ + // we do this here cause the base class' call to destroyDialog won't reach us anymore : we're within an dtor, + // so this virtual-method-call the base class does does not work, we're already dead then ... + if (m_pDialog) + { + ::osl::MutexGuard aGuard(m_aMutex); + if (m_pDialog) + destroyDialog(); + } +} +//------------------------------------------------------------------------- +// lang::XServiceInfo +//------------------------------------------------------------------------- +::rtl::OUString SAL_CALL ChartTypeUnoDlg::getImplementationName() throw(uno::RuntimeException) +{ + return getImplementationName_Static(); +} + +//------------------------------------------------------------------------- +::rtl::OUString ChartTypeUnoDlg::getImplementationName_Static() throw(uno::RuntimeException) +{ + return CHART_TYPE_DIALOG_SERVICE_IMPLEMENTATION_NAME; +} + +//------------------------------------------------------------------------- +::comphelper::StringSequence SAL_CALL ChartTypeUnoDlg::getSupportedServiceNames() throw(uno::RuntimeException) +{ + return getSupportedServiceNames_Static(); +} + +//------------------------------------------------------------------------- + +uno::Sequence< rtl::OUString > ChartTypeUnoDlg::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 1 ); + aSNS.getArray()[ 0 ] = CHART_TYPE_DIALOG_SERVICE_NAME; + return aSNS; +} +//------------------------------------------------------------------------- +uno::Sequence< sal_Int8 > SAL_CALL ChartTypeUnoDlg::getImplementationId( void ) throw( uno::RuntimeException ) +{ + static ::cppu::OImplementationId aId; + return aId.getImplementationId(); +} +//------------------------------------------------------------------------------ +void ChartTypeUnoDlg::implInitialize(const uno::Any& _rValue) +{ + beans::PropertyValue aProperty; + if (_rValue >>= aProperty) + { + if (0 == aProperty.Name.compareToAscii("ChartModel")) + m_xChartModel.set(aProperty.Value,uno::UNO_QUERY); + else + ChartTypeUnoDlg_BASE::implInitialize(_rValue); + } + else + ChartTypeUnoDlg_BASE::implInitialize(_rValue); +} +//------------------------------------------------------------------------------ +Dialog* ChartTypeUnoDlg::createDialog(Window* _pParent) +{ + return new ChartTypeDialog( _pParent, m_xChartModel, m_aContext.getUNOContext() ); +} +//------------------------------------------------------------------------- +//------------------------------------------------------------------------- +uno::Reference<beans::XPropertySetInfo> SAL_CALL ChartTypeUnoDlg::getPropertySetInfo() throw(uno::RuntimeException) +{ + return createPropertySetInfo( getInfoHelper() ); +} + +//------------------------------------------------------------------------- +::cppu::IPropertyArrayHelper& ChartTypeUnoDlg::getInfoHelper() +{ + return *const_cast<ChartTypeUnoDlg*>(this)->getArrayHelper(); +} + +//------------------------------------------------------------------------------ +::cppu::IPropertyArrayHelper* ChartTypeUnoDlg::createArrayHelper( ) const +{ + uno::Sequence< beans::Property > aProps; + describeProperties(aProps); + return new ::cppu::OPropertyArrayHelper(aProps); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx new file mode 100644 index 000000000000..3c38eb4288a3 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_CreationWizard.cxx @@ -0,0 +1,270 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_CreationWizard.hxx" +#include "dlg_CreationWizard.hrc" +#include "ResId.hxx" +#include "macros.hxx" +#include "Strings.hrc" +#include "HelpIds.hrc" + +#include "tp_ChartType.hxx" +#include "tp_RangeChooser.hxx" +#include "tp_Wizard_TitlesAndObjects.hxx" +#include "tp_Location.hxx" + +#include "tp_DataSource.hxx" +#include "ChartTypeTemplateProvider.hxx" +#include "DialogModel.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +//#define LOCATION_PAGE 1 + +#define PATH_FULL 1 +#define STATE_FIRST 0 +#define STATE_CHARTTYPE STATE_FIRST +#define STATE_SIMPLE_RANGE 1 +#define STATE_DATA_SERIES 2 +#define STATE_OBJECTS 3 +#define STATE_LOCATION 4 + +#ifdef LOCATION_PAGE +#define STATE_LAST STATE_LOCATION +#else +#define STATE_LAST STATE_OBJECTS +#endif + +namespace +{ +#ifdef LOCATION_PAGE + const sal_Int32 nPageCount = 5; +#else + const sal_Int32 nPageCount = 4; +#endif +} + +CreationWizard::CreationWizard( Window* pParent, const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext + , sal_Int32 nOnePageOnlyIndex ) + : svt::RoadmapWizard( pParent, SchResId(DLG_CHART_WIZARD) + , ( nOnePageOnlyIndex >= 0 && nOnePageOnlyIndex < nPageCount ) + ? WZB_HELP | WZB_CANCEL | WZB_FINISH + : WZB_HELP | WZB_CANCEL | WZB_PREVIOUS | WZB_NEXT | WZB_FINISH + ) + , m_xChartModel(xChartModel,uno::UNO_QUERY) + , m_xCC( xContext ) + , m_bIsClosable(true) + , m_nOnePageOnlyIndex(nOnePageOnlyIndex) + , m_pTemplateProvider(0) + , m_nFirstState(STATE_FIRST) + , m_nLastState(STATE_LAST) + , m_aTimerTriggeredControllerLock( xChartModel ) + , m_bCanTravel( true ) +{ + m_apDialogModel.reset( new DialogModel( m_xChartModel, m_xCC )); + // Do not call FreeResource(), because there are no sub-elements defined in + // the dialog resource + ShowButtonFixedLine( TRUE ); + defaultButton( WZB_FINISH ); + + if( m_nOnePageOnlyIndex < 0 || m_nOnePageOnlyIndex >= nPageCount ) + { + m_nOnePageOnlyIndex = -1; + this->setTitleBase(String(SchResId(STR_DLG_CHART_WIZARD))); + } + else + this->setTitleBase(String()); + + declarePath( PATH_FULL + , STATE_CHARTTYPE + , STATE_SIMPLE_RANGE + , STATE_DATA_SERIES + , STATE_OBJECTS +#ifdef LOCATION_PAGE + , STATE_LOCATION +#endif + , WZS_INVALID_STATE + ); + this->SetRoadmapSmartHelpId( SmartId( HID_SCH_WIZARD_ROADMAP ) ); + this->SetRoadmapInteractive( sal_True ); + Size aAdditionalRoadmapSize( LogicToPixel( Size( 85, 0 ), MAP_APPFONT ) ); + Size aSize( this->GetSizePixel() ); + aSize.Width() += aAdditionalRoadmapSize.Width(); + this->SetSizePixel( aSize ); + + uno::Reference< chart2::XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY ); + bool bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider()); + + if( bHasOwnData ) + { + this->enableState( STATE_SIMPLE_RANGE, false ); + this->enableState( STATE_DATA_SERIES, false ); + } + + // Call ActivatePage, to create and activate the first page + ActivatePage(); +} +CreationWizard::~CreationWizard() +{ +} + +svt::OWizardPage* CreationWizard::createPage(WizardState nState) +{ + svt::OWizardPage* pRet = 0; + if(m_nOnePageOnlyIndex!=-1 && m_nOnePageOnlyIndex!=nState) + return pRet; + bool bDoLiveUpdate = m_nOnePageOnlyIndex == -1; + switch( nState ) + { + case STATE_CHARTTYPE: + { + m_aTimerTriggeredControllerLock.startTimer(); + ChartTypeTabPage* pChartTypeTabPage = new ChartTypeTabPage(this,m_xChartModel,m_xCC,bDoLiveUpdate); + pRet = pChartTypeTabPage; + m_pTemplateProvider = pChartTypeTabPage; + if( m_pTemplateProvider && + m_apDialogModel.get() ) + m_apDialogModel->setTemplate( m_pTemplateProvider->getCurrentTemplate()); + } + break; + case STATE_SIMPLE_RANGE: + { + m_aTimerTriggeredControllerLock.startTimer(); + pRet = new RangeChooserTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this); + } + break; + case STATE_DATA_SERIES: + { + m_aTimerTriggeredControllerLock.startTimer(); + pRet = new DataSourceTabPage(this,*(m_apDialogModel.get()),m_pTemplateProvider,this); + } + break; + case STATE_OBJECTS: + { + pRet = new TitlesAndObjectsTabPage(this,m_xChartModel,m_xCC); + m_aTimerTriggeredControllerLock.startTimer(); + } + break; +#ifdef LOCATION_PAGE + case STATE_LOCATION: + { + m_aTimerTriggeredControllerLock.startTimer(); + pRet = new LocationTabPage(this,m_xChartModel,m_xCC); + } + break; +#endif + default: + break; + } + if(pRet) + pRet->SetText(String());//remove title of pages to not get them in the wizard title + return pRet; +} + +sal_Bool CreationWizard::leaveState( WizardState /*_nState*/ ) +{ + return m_bCanTravel; +} + +svt::WizardTypes::WizardState CreationWizard::determineNextState( WizardState nCurrentState ) const +{ + if( !m_bCanTravel ) + return WZS_INVALID_STATE; + if( nCurrentState == m_nLastState ) + return WZS_INVALID_STATE; + svt::WizardTypes::WizardState nNextState = nCurrentState + 1; + while( !isStateEnabled( nNextState ) && nNextState <= m_nLastState ) + ++nNextState; + return (nNextState==m_nLastState+1) ? WZS_INVALID_STATE : nNextState; +} +void CreationWizard::enterState(WizardState nState) +{ + m_aTimerTriggeredControllerLock.startTimer(); + enableButtons( WZB_PREVIOUS, bool( nState > m_nFirstState ) ); + enableButtons( WZB_NEXT, bool( nState < m_nLastState ) ); + if( isStateEnabled( nState )) + svt::RoadmapWizard::enterState(nState); +} + +bool CreationWizard::isClosable() +{ + //@todo + return m_bIsClosable; +} + +void CreationWizard::setInvalidPage( TabPage * /* pTabPage */ ) +{ + m_bCanTravel = false; +} + +void CreationWizard::setValidPage( TabPage * /* pTabPage */ ) +{ + m_bCanTravel = true; +} + +String CreationWizard::getStateDisplayName( WizardState nState ) const +{ + USHORT nResId = 0; + switch( nState ) + { + case STATE_CHARTTYPE: + nResId = STR_PAGE_CHARTTYPE; + break; + case STATE_SIMPLE_RANGE: + nResId = STR_PAGE_DATA_RANGE; + break; + case STATE_DATA_SERIES: + nResId = STR_OBJECT_DATASERIES_PLURAL; + break; + case STATE_OBJECTS: + nResId = STR_PAGE_CHART_ELEMENTS; + break; +#ifdef LOCATION_PAGE + case STATE_LOCATION: + nResId = STR_PAGE_CHART_LOCATION; + break; +#endif + default: + break; + } + return String(SchResId(nResId)); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.hrc b/chart2/source/controller/dialogs/dlg_CreationWizard.hrc new file mode 100644 index 000000000000..832a49329765 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_CreationWizard.hrc @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define CHART_WIZARD_PAGEWIDTH 250 +#define CHART_WIZARD_PAGEHEIGHT 140 +//width 198 height 150 diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard.src b/chart2/source/controller/dialogs/dlg_CreationWizard.src new file mode 100644 index 000000000000..88caf15874c5 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_CreationWizard.src @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "dlg_CreationWizard.hrc" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" + +ModalDialog DLG_CHART_WIZARD +{ + HelpID = HID_SCH_CHART_AUTO_FORMAT ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( CHART_WIZARD_PAGEWIDTH , CHART_WIZARD_PAGEHEIGHT+30 ) ; + Moveable = TRUE ; + Closeable = TRUE ; +}; diff --git a/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx new file mode 100644 index 000000000000..c28e0265d983 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_CreationWizard_UNO.cxx @@ -0,0 +1,436 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard_UNO.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_CreationWizard_UNO.hxx" +#include "dlg_CreationWizard.hxx" +#include "macros.hxx" +#include "servicenames.hxx" +#include "ContainerHelper.hxx" +#include "TimerTriggeredControllerLock.hxx" +#include <osl/mutex.hxx> +#include <vos/mutex.hxx> +// header for class Application +#include <vcl/svapp.hxx> +#include <toolkit/awt/vclxwindow.hxx> +// header for define RET_CANCEL +#include <vcl/msgbox.hxx> +// header for class OImplementationId +#include <cppuhelper/typeprovider.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/XDesktop.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +CreationWizardUnoDlg::CreationWizardUnoDlg( const uno::Reference< uno::XComponentContext >& xContext ) + : OComponentHelper( m_aMutex ) + , m_xChartModel( 0 ) + , m_xCC( xContext ) + , m_xParentWindow( 0 ) + , m_pDialog( 0 ) + , m_bUnlockControllersOnExecute(false) +{ + uno::Reference< frame::XDesktop > xDesktop( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.frame.Desktop" ), m_xCC ), uno::UNO_QUERY ); + if( xDesktop.is() ) + { + uno::Reference< frame::XTerminateListener > xListener( this ); + xDesktop->addTerminateListener( xListener ); + } +} +CreationWizardUnoDlg::~CreationWizardUnoDlg() +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + if( m_pDialog ) + { + delete m_pDialog; + m_pDialog = 0; + } +} +//------------------------------------------------------------------------- +// lang::XServiceInfo +APPHELPER_XSERVICEINFO_IMPL(CreationWizardUnoDlg,CHART_WIZARD_DIALOG_SERVICE_IMPLEMENTATION_NAME) + + uno::Sequence< rtl::OUString > CreationWizardUnoDlg +::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 1 ); + aSNS.getArray()[ 0 ] = CHART_WIZARD_DIALOG_SERVICE_NAME; + return aSNS; +} + +//------------------------------------------------------------------------- +// XInterface +uno::Any SAL_CALL CreationWizardUnoDlg::queryInterface( const uno::Type& aType ) throw (uno::RuntimeException) +{ + return OComponentHelper::queryInterface( aType ); +} +void SAL_CALL CreationWizardUnoDlg::acquire() throw () +{ + OComponentHelper::acquire(); +} +void SAL_CALL CreationWizardUnoDlg::release() throw () +{ + OComponentHelper::release(); +} +uno::Any SAL_CALL CreationWizardUnoDlg::queryAggregation( uno::Type const & rType ) throw (uno::RuntimeException) +{ + if (rType == ::getCppuType( (uno::Reference< ui::dialogs::XExecutableDialog > const *)0 )) + { + void * p = static_cast< ui::dialogs::XExecutableDialog * >( this ); + return uno::Any( &p, rType ); + } + else if (rType == ::getCppuType( (uno::Reference< lang::XServiceInfo > const *)0 )) + { + void * p = static_cast< lang::XTypeProvider * >( this ); + return uno::Any( &p, rType ); + } + else if (rType == ::getCppuType( (uno::Reference< lang::XInitialization > const *)0 )) + { + void * p = static_cast< lang::XInitialization * >( this ); + return uno::Any( &p, rType ); + } + else if (rType == ::getCppuType( (uno::Reference< frame::XTerminateListener > const *)0 )) + { + void * p = static_cast< frame::XTerminateListener * >( this ); + return uno::Any( &p, rType ); + } + else if (rType == ::getCppuType( (uno::Reference< beans::XPropertySet > const *)0 )) + { + void * p = static_cast< beans::XPropertySet * >( this ); + return uno::Any( &p, rType ); + } + return OComponentHelper::queryAggregation( rType ); +} + +//------------------------------------------------------------------------- +#define LCL_CPPUTYPE(t) (::getCppuType( reinterpret_cast< const uno::Reference<t> *>(0))) + +uno::Sequence< uno::Type > CreationWizardUnoDlg::getTypes() throw(uno::RuntimeException) +{ + static uno::Sequence< uno::Type > aTypeList; + + // /-- + ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() ); + if( !aTypeList.getLength() ) + { + ::std::vector< uno::Type > aTypes; + aTypes.push_back( LCL_CPPUTYPE( lang::XComponent )); + aTypes.push_back( LCL_CPPUTYPE( lang::XTypeProvider )); + aTypes.push_back( LCL_CPPUTYPE( uno::XAggregation )); + aTypes.push_back( LCL_CPPUTYPE( uno::XWeak )); + aTypes.push_back( LCL_CPPUTYPE( lang::XServiceInfo )); + aTypes.push_back( LCL_CPPUTYPE( lang::XInitialization )); + aTypes.push_back( LCL_CPPUTYPE( frame::XTerminateListener )); + aTypes.push_back( LCL_CPPUTYPE( ui::dialogs::XExecutableDialog )); + aTypes.push_back( LCL_CPPUTYPE( beans::XPropertySet )); + aTypeList = ::chart::ContainerHelper::ContainerToSequence( aTypes ); + } + + return aTypeList; + // \-- +} +uno::Sequence< sal_Int8 > SAL_CALL CreationWizardUnoDlg::getImplementationId( void ) throw( uno::RuntimeException ) +{ + static uno::Sequence< sal_Int8 > aId; + if( aId.getLength() == 0 ) + { + aId.realloc( 16 ); + rtl_createUuid( (sal_uInt8 *)aId.getArray(), 0, sal_True ); + } + return aId; +} + +//------------------------------------------------------------------------- + +// XTerminateListener +void SAL_CALL CreationWizardUnoDlg::queryTermination( const lang::EventObject& /*Event*/ ) throw( frame::TerminationVetoException, uno::RuntimeException) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + + // we will never give a veto here + if( m_pDialog && !m_pDialog->isClosable() ) + { + m_pDialog->ToTop(); + throw frame::TerminationVetoException(); + } +} + +//------------------------------------------------------------------------- + +void SAL_CALL CreationWizardUnoDlg::notifyTermination( const lang::EventObject& /*Event*/ ) throw (uno::RuntimeException) +{ + // we are going down, so dispose us! + dispose(); +} + +void SAL_CALL CreationWizardUnoDlg::disposing( const lang::EventObject& /*Source*/ ) throw (uno::RuntimeException) +{ + //Listener should deregister himself and relaese all references to the closing object. +} + +//------------------------------------------------------------------------- +void SAL_CALL CreationWizardUnoDlg::setTitle( const ::rtl::OUString& /*rTitle*/ ) throw(uno::RuntimeException) +{ +} +//------------------------------------------------------------------------- +void CreationWizardUnoDlg::createDialogOnDemand() +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + if( !m_pDialog ) + { + Window* pParent = NULL; + if( !m_xParentWindow.is() && m_xChartModel.is() ) + { + uno::Reference< frame::XController > xController( + m_xChartModel->getCurrentController() ); + if( xController.is() ) + { + uno::Reference< frame::XFrame > xFrame( + xController->getFrame() ); + if(xFrame.is()) + m_xParentWindow = xFrame->getContainerWindow(); + } + } + if( m_xParentWindow.is() ) + { + VCLXWindow* pImplementation = VCLXWindow::GetImplementation(m_xParentWindow); + if (pImplementation) + pParent = pImplementation->GetWindow(); + } + uno::Reference< XComponent > xComp( this ); + if( m_xChartModel.is() ) + { + m_pDialog = new CreationWizard( pParent, m_xChartModel, m_xCC ); + m_pDialog->AddEventListener( LINK( this, CreationWizardUnoDlg, DialogEventHdl ) ); + } + } +} +//------------------------------------------------------------------------- +IMPL_LINK( CreationWizardUnoDlg, DialogEventHdl, VclWindowEvent*, pEvent ) +{ + if(pEvent && (pEvent->GetId() == VCLEVENT_OBJECT_DYING) ) + m_pDialog = 0;//avoid duplicate destruction of m_pDialog + return 0; +} + +//------------------------------------------------------------------------- +sal_Int16 SAL_CALL CreationWizardUnoDlg::execute( ) throw(uno::RuntimeException) +{ + sal_Int16 nRet = RET_CANCEL; + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + createDialogOnDemand(); + if( !m_pDialog ) + return nRet; + TimerTriggeredControllerLock aTimerTriggeredControllerLock( m_xChartModel ); + if( m_bUnlockControllersOnExecute && m_xChartModel.is() ) + m_xChartModel->unlockControllers(); + nRet = m_pDialog->Execute(); + } + return nRet; +} + +//------------------------------------------------------------------------- +void SAL_CALL CreationWizardUnoDlg::initialize( const uno::Sequence< uno::Any >& aArguments ) throw(uno::Exception, uno::RuntimeException) +{ + const uno::Any* pArguments = aArguments.getConstArray(); + for(sal_Int32 i=0; i<aArguments.getLength(); ++i, ++pArguments) + { + beans::PropertyValue aProperty; + if(*pArguments >>= aProperty) + { + if( aProperty.Name.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ParentWindow" ) ) == 0 ) + { + aProperty.Value >>= m_xParentWindow; + } + else if( aProperty.Name.compareToAscii( RTL_CONSTASCII_STRINGPARAM( "ChartModel" ) ) == 0 ) + { + aProperty.Value >>= m_xChartModel; + } + } + } +} + +//------------------------------------------------------------------------- +// ____ OComponentHelper ____ +/// Called in dispose method after the listeners were notified. +void SAL_CALL CreationWizardUnoDlg::disposing() +{ + m_xChartModel.clear(); + m_xParentWindow.clear(); + + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + if( m_pDialog ) + { + delete m_pDialog; + m_pDialog = 0; + } + + try + { + uno::Reference< frame::XDesktop > xDesktop( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.frame.Desktop" ), m_xCC ), uno::UNO_QUERY ); + if( xDesktop.is() ) + { + uno::Reference< frame::XTerminateListener > xListener( this ); + xDesktop->removeTerminateListener( xListener ); + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + // \-- +} + +//XPropertySet +uno::Reference< beans::XPropertySetInfo > SAL_CALL CreationWizardUnoDlg::getPropertySetInfo() + throw (uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); + return 0; +} + +void SAL_CALL CreationWizardUnoDlg::setPropertyValue( const ::rtl::OUString& rPropertyName + , const uno::Any& rValue ) + throw (beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException + , lang::WrappedTargetException, uno::RuntimeException) +{ + if( rPropertyName.equals(C2U("Position")) ) + { + awt::Point aPos; + if( ! (rValue >>= aPos) ) + throw lang::IllegalArgumentException( C2U("Property 'Position' requires value of type awt::Point"), 0, 0 ); + + //set left upper outer corner relative to screen + //pixels, screen position + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + createDialogOnDemand(); + if( m_pDialog ) + { + m_pDialog->SetPosPixel( Point(0,0) ); + Rectangle aRect( m_pDialog->GetWindowExtentsRelative( 0 ) ); + + Point aNewOuterPos = Point( aPos.X - aRect.Left(), aPos.Y - aRect.Top() ); + m_pDialog->SetPosPixel( aNewOuterPos ); + } + } + else if( rPropertyName.equals(C2U("Size")) ) + { + //read only property, do nothing + } + else if( rPropertyName.equals(C2U("UnlockControllersOnExecute")) ) + { + if( ! (rValue >>= m_bUnlockControllersOnExecute) ) + throw lang::IllegalArgumentException( C2U("Property 'UnlockControllers' requires value of type boolean"), 0, 0 ); + } + else + throw beans::UnknownPropertyException( C2U("unknown property was tried to set to chart wizard"), 0 ); +} + +uno::Any SAL_CALL CreationWizardUnoDlg::getPropertyValue( const ::rtl::OUString& rPropertyName ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + uno::Any aRet; + if( rPropertyName.equals(C2U("Position")) ) + { + //get left upper outer corner relative to screen + //pixels, screen position + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + createDialogOnDemand(); + if( m_pDialog ) + { + Rectangle aRect( m_pDialog->GetWindowExtentsRelative( 0 ) ); + awt::Point aPoint(aRect.Left(),aRect.Top()); + aRet = uno::makeAny( aPoint ); + } + } + else if( rPropertyName.equals(C2U("Size")) ) + { + //get outer size inclusive decoration + //pixels, screen position + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + createDialogOnDemand(); + if( m_pDialog ) + { + Rectangle aRect( m_pDialog->GetWindowExtentsRelative( 0 ) ); + awt::Size aSize(aRect.GetWidth(),aRect.GetHeight()); + aRet = uno::makeAny( aSize ); + } + } + else if( rPropertyName.equals(C2U("UnlockControllersOnExecute")) ) + { + aRet = uno::makeAny( m_bUnlockControllersOnExecute ); + } + else + throw beans::UnknownPropertyException( C2U("unknown property was tried to get from chart wizard"), 0 ); + return aRet; +} + +void SAL_CALL CreationWizardUnoDlg::addPropertyChangeListener( + const ::rtl::OUString& /* aPropertyName */, const uno::Reference< beans::XPropertyChangeListener >& /* xListener */ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} +void SAL_CALL CreationWizardUnoDlg::removePropertyChangeListener( + const ::rtl::OUString& /* aPropertyName */, const uno::Reference< beans::XPropertyChangeListener >& /* aListener */ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +void SAL_CALL CreationWizardUnoDlg::addVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, const uno::Reference< beans::XVetoableChangeListener >& /* aListener */ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +void SAL_CALL CreationWizardUnoDlg::removeVetoableChangeListener( const ::rtl::OUString& /* PropertyName */, const uno::Reference< beans::XVetoableChangeListener >& /* aListener */ ) + throw (beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) +{ + OSL_ENSURE(false,"not implemented"); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.cxx b/chart2/source/controller/dialogs/dlg_DataEditor.cxx new file mode 100644 index 000000000000..f3b601453bee --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataEditor.cxx @@ -0,0 +1,392 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataEditor.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_DataEditor.hxx" +#include "dlg_DataEditor.hrc" +#include "Strings.hrc" +#include "DataBrowser.hxx" + +#include "ResId.hxx" +#include "Strings.hrc" +#include "SchSlotIds.hxx" +#include <sfx2/dispatch.hxx> +#include <vcl/msgbox.hxx> +#include <vcl/taskpanelist.hxx> +#include <svtools/miscopt.hxx> +#include <svtools/pathoptions.hxx> + +// for SfxBoolItem +#include <svtools/eitem.hxx> + +#include <vcl/edit.hxx> + +#include <com/sun/star/frame/XStorable.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> + +// for storing/reading the position and size of the dialog +// #include <svtools/viewoptions.hxx> + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + + +namespace chart +{ + +DataEditor::DataEditor( + Window* pParent, + const Reference< chart2::XChartDocument > & xChartDoc, + const Reference< uno::XComponentContext > & xContext ) : + ModalDialog( pParent, SchResId( DLG_DIAGRAM_DATA )), + m_bReadOnly( false ), + m_apBrwData( new DataBrowser( this, SchResId( CTL_DATA ), true /* bLiveUpdate */)), + m_aTbxData( this, SchResId( TBX_DATA )), + m_xChartDoc( xChartDoc ), + m_xContext( xContext ), + m_aToolboxImageList( SchResId( IL_DIAGRAM_DATA )), + m_aToolboxImageListHighContrast( SchResId( IL_HC_DIAGRAM_DATA )) +{ + FreeResource(); + + // set min size to current size + SetMinOutputSizePixel( GetOutputSizePixel() ); + + ApplyImageList(); + + m_aTbxData.SetSizePixel( m_aTbxData.CalcWindowSizePixel() ); + m_aTbxData.SetSelectHdl( LINK( this, DataEditor, ToolboxHdl )); + + m_apBrwData->SetCursorMovedHdl( LINK( this, DataEditor, BrowserCursorMovedHdl )); + m_apBrwData->SetCellModifiedHdl( LINK( this, DataEditor, CellModified )); + + UpdateData(); + GrabFocus(); + m_apBrwData->GrabFocus(); + + bool bReadOnly = true; + Reference< frame::XStorable > xStor( m_xChartDoc, uno::UNO_QUERY ); + if( xStor.is()) + bReadOnly = xStor->isReadonly(); + SetReadOnly( bReadOnly ); + + // #101228# change buttons to flat-look if set so by user + SvtMiscOptions aMiscOptions; + const sal_Int16 nStyle( aMiscOptions.GetToolboxStyle() ); + // react on changes + aMiscOptions.AddListener( LINK( this, DataEditor, MiscHdl ) ); + m_aTbxData.SetOutStyle( nStyle ); + + // set good window width + Size aWinSize( GetOutputSizePixel()); + Size aWinSizeWithBorder( GetSizePixel()); + Point aWinPos( OutputToAbsoluteScreenPixel( GetPosPixel())); + sal_Int32 nMinWidth = aWinSize.getWidth(); + sal_Int32 nMaxWidth = GetDesktopRectPixel().getWidth() - + (aWinSizeWithBorder.getWidth() - aWinSize.getWidth() + aWinPos.getX()) - 10; // leave some space + sal_Int32 nBrowserWidth = m_apBrwData->GetTotalWidth() + 12 + 16; // plus padding + 16? + sal_Int32 nWindowWidth = ::std::max( nMinWidth, nBrowserWidth ); + nWindowWidth = ::std::min( nMaxWidth, nBrowserWidth ); + aWinSize.setWidth( nWindowWidth ); + SetOutputSizePixel( aWinSize ); + AdaptBrowseBoxSize(); + +// ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); + + // allow travelling to toolbar with F6 + notifySystemWindow( this, & m_aTbxData, ::comphelper::mem_fun( & TaskPaneList::AddWindow )); +} + +DataEditor::~DataEditor() +{ + notifySystemWindow( this, & m_aTbxData, ::comphelper::mem_fun( & TaskPaneList::RemoveWindow )); + + SvtMiscOptions aMiscOptions; + aMiscOptions.RemoveListener( LINK( this, DataEditor, MiscHdl ) ); + + OSL_TRACE( "DataEditor: DTOR" ); +} + +// react on click (or keypress) on toolbar icon +IMPL_LINK( DataEditor, ToolboxHdl, void *, EMPTYARG ) +{ + switch( m_aTbxData.GetCurItemId() ) + { + case TBI_DATA_INSERT_ROW: + m_apBrwData->InsertRow(); + break; + case TBI_DATA_INSERT_COL: + m_apBrwData->InsertColumn(); +// ImplAdjustHeaderControls( true /* bRefreshFromModel */ ); + break; + case TBI_DATA_DELETE_ROW: + m_apBrwData->RemoveRow(); + break; + case TBI_DATA_DELETE_COL: + m_apBrwData->RemoveColumn(); +// ImplAdjustHeaderControls( true /* bRefreshFromModel */ ); + break; + case TBI_DATA_SWAP_COL : + m_apBrwData->SwapColumn (); +// ImplAdjustHeaderControls( true /* bRefreshFromModel */ ); + break; + case TBI_DATA_SWAP_ROW : + m_apBrwData->SwapRow (); + break; +// case TBI_DATA_SORT_COL : +// m_apBrwData->QuickSortCol(); +// break; +// case TBI_DATA_SORT_ROW : +// m_apBrwData->QuickSortRow(); +// break; +// case TBI_DATA_SORT_TABLE_COL : +// m_apBrwData->QuickSortTableCols (); +// break; +// case TBI_DATA_SORT_TABLE_ROW : +// m_apBrwData->QuickSortTableRows (); +// break; + } + + return 0; +} + +// refresh toolbar icons according to currently selected cell in brwose box +IMPL_LINK( DataEditor, BrowserCursorMovedHdl, void *, EMPTYARG ) +{ + if( m_bReadOnly ) + return 0; + + if( m_apBrwData->IsEnableItem() ) + { + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, m_apBrwData->MayInsertRow() ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, m_apBrwData->MayInsertColumn() ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, m_apBrwData->MayDeleteRow() ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, m_apBrwData->MayDeleteColumn() ); + + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, m_apBrwData->MaySwapColumns() ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, m_apBrwData->MaySwapRows() ); + } + else + { + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); + } +// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, m_apBrwData->MaySortColumn() ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, m_apBrwData->MaySortRow() ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, m_apBrwData->MaySortColumn() ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, m_apBrwData->MaySortRow() ); + + return 0; +} + +// disable all modifying controls +void DataEditor::SetReadOnly( bool bReadOnly ) +{ + m_bReadOnly = bReadOnly; + if( m_bReadOnly ) + { + m_aTbxData.EnableItem( TBI_DATA_INSERT_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_INSERT_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_ROW, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_DELETE_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_COL, FALSE ); + m_aTbxData.EnableItem( TBI_DATA_SWAP_ROW, FALSE ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_COL, FALSE ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_ROW, FALSE ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_ROW, FALSE ); +// m_aTbxData.EnableItem( TBI_DATA_SORT_TABLE_COL, FALSE ); + } + + m_apBrwData->SetReadOnly( m_bReadOnly ); +} + +IMPL_LINK( DataEditor, MiscHdl, void*, EMPTYARG ) +{ + SvtMiscOptions aMiscOptions; + sal_Int16 nStyle( aMiscOptions.GetToolboxStyle() ); + + m_aTbxData.SetOutStyle( nStyle ); + + return 0L; +} + +IMPL_LINK( DataEditor, CellModified, void*, EMPTYARG ) +{ + return 0; +} + +// IMPL_LINK( DataEditor, BrowserColumnResized, void*, EMPTYARG ) +// { +// ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); +// return 0; +// } + +// IMPL_LINK( DataEditor, BrowserContentScrolled, void*, EMPTYARG ) +// { +// ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); +// return 0; +// } + +void DataEditor::UpdateData() +{ + m_apBrwData->SetDataFromModel( m_xChartDoc, m_xContext ); +} + +// react on the change of the underlying document by displaying the new data +// void DataEditor::SFX_NOTIFY( +// SfxBroadcaster& rBC, +// const TypeId& rBCType, +// const SfxHint& rHint, +// const TypeId& rHintType ) +// { +// if( rHint.Type() == TYPE(SfxSimpleHint) ) +// { +// // note: if dynamic_cast works this should be changed +// switch( static_cast< const SfxSimpleHint & >( rHint ).GetId()) +// { +// case SFX_HINT_DOCCHANGED: +// UpdateData(); +// break; + +// case SFX_HINT_DYING: +// break; +// } +// } +// } + +// { +// BOOL bRet = TRUE; + +// // confirm changes currently made and not saved +// m_apBrwData->EndEditing(); + +// if( m_apBrwData->IsDirty() ) +// { +// QueryBox aSafetyQuery( this, WB_YES_NO_CANCEL | WB_DEF_YES, +// String( SchResId( STR_DIAGRAM_DATA_SAFETY_QUERY ))); +// long nQueryResult = aSafetyQuery.Execute(); + +// bRet = ( nQueryResult != RET_CANCEL ); + +// if( nQueryResult == RET_YES ) +// { +// // save changes +// ApplyChangesToModel(); +// } +// } + +// if( bRet ) +// { +// // close child window +// SfxBoolItem aItem( SID_DIAGRAM_DATA, FALSE ); +// if( m_pBindings ) +// { +// SfxDispatcher* pDisp = m_pBindings->GetDispatcher(); +// if( pDisp ) +// pDisp->Execute( SID_DIAGRAM_DATA, SFX_CALLMODE_ASYNCHRON, &aItem, 0L); +// else +// DBG_ERROR( "Couldn't dispatch command" ); +// } +// } + +// return ( bRet? SfxFloatingWindow::Close(): FALSE ); +// } + +void DataEditor::AdaptBrowseBoxSize() +{ + Size aSize( PixelToLogic( GetResizeOutputSizePixel(), MAP_APPFONT )); + Size aDataSize; + + aDataSize.setWidth( aSize.getWidth() - 12 ); + aDataSize.setHeight( aSize.getHeight() - 31 -24 ); + + m_apBrwData->SetSizePixel( LogicToPixel( aDataSize, MAP_APPFONT )); +} + +void DataEditor::Resize() +{ + Dialog::Resize(); + AdaptBrowseBoxSize(); +// ImplAdjustHeaderControls( false /* bRefreshFromModel */ ); +} + +BOOL DataEditor::Close() +{ + if( ApplyChangesToModel() ) + return ModalDialog::Close(); + else + return TRUE; +} + +bool DataEditor::ApplyChangesToModel() +{ + return m_apBrwData->EndEditing(); +} + +// sets the correct toolbar icons depending on the current mode (e.g. high contrast) +void DataEditor::ApplyImageList() +{ + bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + + ImageList& rImgLst = bIsHighContrast + ? m_aToolboxImageListHighContrast + : m_aToolboxImageList; + + m_aTbxData.SetImageList( rImgLst ); +} + +// add/remove a window (the toolbar) to/from the global list, so that F6 +// travels/no longer travels over this window. _rMemFunc may be +// TaskPaneList::AddWindow or TaskPaneList::RemoveWindow +void DataEditor::notifySystemWindow( + Window* pWindow, Window* pToRegister, + ::comphelper::mem_fun1_t< TaskPaneList, Window* > rMemFunc ) +{ + OSL_ENSURE( pWindow, "Window must not be null!" ); + if( !pWindow ) + return; + Window* pParent = pWindow->GetParent(); + while( pParent && ! pParent->IsSystemWindow() ) + { + pParent = pParent->GetParent(); + } + if ( pParent && pParent->IsSystemWindow()) + { + SystemWindow* pSystemWindow = static_cast< SystemWindow* >( pParent ); + rMemFunc( pSystemWindow->GetTaskPaneList(),( pToRegister )); + } +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.hrc b/chart2/source/controller/dialogs/dlg_DataEditor.hrc new file mode 100644 index 000000000000..4ce4433fe7fd --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataEditor.hrc @@ -0,0 +1,55 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataEditor.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#define DLG_DIAGRAM_DATA 744 + +#define FT_POS 1 +#define TBX_EDIT 1 +#define EDT_FIELD 1 +#define TBX_DATA 2 +#define CTL_DATA 1 + +// images for toolbox image list +#define TBI_DATA_INSERT_ROW 1 +#define TBI_DATA_INSERT_COL 2 +#define TBI_DATA_DELETE_ROW 3 +#define TBI_DATA_DELETE_COL 4 +#define TBI_DATA_SWAP_COL 5 +#define TBI_DATA_SWAP_ROW 6 +#define TBI_DATA_TRANSFER 7 + +// #define TBI_DATA_SORT_ROW 7 +// #define TBI_DATA_SORT_COL 8 +// #define TBI_DATA_SORT_TABLE_ROW 9 +// #define TBI_DATA_SORT_TABLE_COL 10 +// #define TBI_DATA_TRANSFER 11 + +// image lists (normal and high-contrast) for toolbox +#define IL_DIAGRAM_DATA 1 +#define IL_HC_DIAGRAM_DATA 2 diff --git a/chart2/source/controller/dialogs/dlg_DataEditor.src b/chart2/source/controller/dialogs/dlg_DataEditor.src new file mode 100644 index 000000000000..116757475bbb --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataEditor.src @@ -0,0 +1,145 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataEditor.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_DataEditor.hrc" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" + +// Mask Color for standard images +#define IMAGE_BUTTON_STD_MASK_COLOR Color { Red = 0xff00; Green = 0x0000; Blue = 0xff00; } +// Mask Color for high-contrast images +#define IMAGE_BUTTON_HC_MASK_COLOR IMAGE_BUTTON_STD_MASK_COLOR + +#define ADDITIONAL_SPACE_ABOVE_TABLE 17 + +ModalDialog DLG_DIAGRAM_DATA +{ + HelpID = SID_DIAGRAM_DATA ; + OutputSize = TRUE ; + Hide = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( 0 , 0 ) ; + Size = MAP_APPFONT ( 244 , 152 ) ; + + Text [ en-US ] = "Data Table"; + + Moveable = TRUE ; + Closeable = TRUE ; + Sizeable = TRUE ; + Control CTL_DATA + { + HelpID = HID_SCH_CTL_DATA ; + Border = TRUE ; + Pos = MAP_APPFONT ( 6 , 24 + ADDITIONAL_SPACE_ABOVE_TABLE ) ; + Size = MAP_APPFONT ( 232 , 121 - ADDITIONAL_SPACE_ABOVE_TABLE ) ; + TabStop = TRUE ; + }; + ToolBox TBX_DATA + { + HelpID = HID_SCH_TBX_DATA ; + SVLook = TRUE ; + TabStop = TRUE ; + Pos = MAP_APPFONT ( 4 , 2 ) ; + ItemList = + { + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_INSERT_ROW ; + Identifier = TBI_DATA_INSERT_ROW ; + Text [ en-US ] = "Insert Row" ; + }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_INSERT_COL ; + Identifier = TBI_DATA_INSERT_COL ; + Text [ en-US ] = "Insert Series" ; + }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_DELETE_ROW ; + Identifier = TBI_DATA_DELETE_ROW ; + Text [ en-US ] = "Delete Row" ; + }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_DELETE_COL ; + Identifier = TBI_DATA_DELETE_COL ; + Text [ en-US ] = "Delete Series" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_SWAP_COL ; + Identifier = TBI_DATA_SWAP_COL ; + Text [ en-US ] = "Move Series Right" ; + }; + ToolBoxItem + { + HelpID = HID_SCH_TBI_DATA_SWAP_ROW ; + Identifier = TBI_DATA_SWAP_ROW ; + Text [ en-US ] = "Move Row Down" ; + }; + ToolBoxItem + { + Type = TOOLBOXITEM_SEPARATOR ; + }; + }; + }; + +#define IMAGE_ID_LIST \ + IdList = \ + { \ + TBI_DATA_INSERT_ROW; \ + TBI_DATA_INSERT_COL; \ + TBI_DATA_DELETE_ROW; \ + TBI_DATA_DELETE_COL; \ + TBI_DATA_SWAP_COL; \ + TBI_DATA_SWAP_ROW; \ + TBI_DATA_TRANSFER; \ + }; \ + IdCount = { 7; } + + ImageList IL_DIAGRAM_DATA + { + Prefix = "dataeditor_icon"; + MaskColor = IMAGE_BUTTON_STD_MASK_COLOR; + IMAGE_ID_LIST; + }; + + ImageList IL_HC_DIAGRAM_DATA + { + Prefix = "dataeditor_icon_h"; + MaskColor = IMAGE_BUTTON_HC_MASK_COLOR; + IMAGE_ID_LIST; + }; +}; diff --git a/chart2/source/controller/dialogs/dlg_DataSource.cxx b/chart2/source/controller/dialogs/dlg_DataSource.cxx new file mode 100644 index 000000000000..1aa7db1f0f17 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataSource.cxx @@ -0,0 +1,256 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataSource.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_DataSource.hxx" +#include "dlg_DataSource.hrc" +#include "Strings.hrc" +#include "ResId.hxx" +#include "ChartTypeTemplateProvider.hxx" +#include "DiagramHelper.hxx" +#include "DialogModel.hxx" +#include "HelpIds.hrc" + +#include "tp_RangeChooser.hxx" +#include "tp_DataSource.hxx" + +// for RET_OK +#include <vcl/msgbox.hxx> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using namespace ::chart; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +// -------------------------------------------------------------------------------- + + +namespace chart +{ + +// ---------------------------------------- + +class DocumentChartTypeTemplateProvider : public ChartTypeTemplateProvider +{ +public: + DocumentChartTypeTemplateProvider( + const Reference< chart2::XChartDocument > & xDoc ); + virtual ~DocumentChartTypeTemplateProvider(); + + // ____ ChartTypeTemplateProvider ____ + virtual Reference< chart2::XChartTypeTemplate > getCurrentTemplate() const; + +private: + Reference< chart2::XChartTypeTemplate > m_xTemplate; +}; + +DocumentChartTypeTemplateProvider::DocumentChartTypeTemplateProvider( + const Reference< chart2::XChartDocument > & xDoc ) +{ + if( xDoc.is()) + { + Reference< chart2::XDiagram > xDia( xDoc->getFirstDiagram()); + if( xDia.is()) + { + DiagramHelper::tTemplateWithServiceName aResult( + DiagramHelper::getTemplateForDiagram( + xDia, + Reference< lang::XMultiServiceFactory >( + xDoc->getChartTypeManager(), uno::UNO_QUERY ) )); + m_xTemplate.set( aResult.first ); + } + } +} + +DocumentChartTypeTemplateProvider::~DocumentChartTypeTemplateProvider() +{} + +Reference< chart2::XChartTypeTemplate > DocumentChartTypeTemplateProvider::getCurrentTemplate() const +{ + return m_xTemplate; +} + +// ---------------------------------------- + +class DataSourceTabControl : public TabControl +{ +public: + DataSourceTabControl( Window* pParent, const ResId& rResId ); + ~DataSourceTabControl(); + + virtual long DeactivatePage(); + + void DisableTabToggling(); + void EnableTabToggling(); + +private: + bool m_bTogglingEnabled; +}; + +DataSourceTabControl::DataSourceTabControl( Window* pParent, const ResId& rResId ) : + TabControl( pParent, rResId ), + m_bTogglingEnabled( true ) +{} + +DataSourceTabControl::~DataSourceTabControl() +{} + +// Note that the result is long, but is intended to be a bool +long DataSourceTabControl::DeactivatePage() +{ + bool bCanDeactivate( TabControl::DeactivatePage() != 0 ); + + bCanDeactivate = (bCanDeactivate && m_bTogglingEnabled); + + return (bCanDeactivate ? 1 : 0 ); +} + +void DataSourceTabControl::DisableTabToggling() +{ + m_bTogglingEnabled = false; +} + +void DataSourceTabControl::EnableTabToggling() +{ + m_bTogglingEnabled = true; +} + +// ---------------------------------------- + +// static +USHORT DataSourceDialog::m_nLastPageId = 0; + +DataSourceDialog::DataSourceDialog( + Window * pParent, + const Reference< XChartDocument > & xChartDocument, + const Reference< uno::XComponentContext > & xContext ) : + + TabDialog( pParent, SchResId( DLG_DATA_SOURCE )), + + m_xChartDocument( xChartDocument ), + m_xContext( xContext ), + m_apDocTemplateProvider( new DocumentChartTypeTemplateProvider( xChartDocument )), + m_apDialogModel( new DialogModel( xChartDocument, xContext )), + + m_pTabControl( new DataSourceTabControl( this, SchResId( TABCTRL ) )), + m_aBtnOK( this, SchResId( BTN_OK ) ), + m_aBtnCancel( this, SchResId( BTN_CANCEL ) ), + m_aBtnHelp( this, SchResId( BTN_HELP ) ), + + m_pRangeChooserTabePage(0), + m_pDataSourceTabPage(0), + m_bRangeChooserTabIsValid( true ), + m_bDataSourceTabIsValid( true ) +{ + FreeResource(); + + //don't create the tabpages before FreeResource, otherwise the help ids are not matched correctly + m_pRangeChooserTabePage = new RangeChooserTabPage( m_pTabControl, *(m_apDialogModel.get()), + m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); + m_pDataSourceTabPage = new DataSourceTabPage( m_pTabControl, *(m_apDialogModel.get()), + m_apDocTemplateProvider.get(), this, true /* bHideDescription */ ); + + m_pTabControl->InsertPage( TP_RANGECHOOSER, String( SchResId( STR_PAGE_DATA_RANGE ))); + m_pTabControl->InsertPage( TP_DATA_SOURCE, String( SchResId( STR_OBJECT_DATASERIES_PLURAL ))); + + m_pTabControl->SetTabPage( TP_RANGECHOOSER, m_pRangeChooserTabePage ); + m_pTabControl->SetTabPage( TP_DATA_SOURCE, m_pDataSourceTabPage ); + + m_pTabControl->SelectTabPage( m_nLastPageId ); + + SetHelpId( HID_SCH_DLG_RANGES ); +} + +DataSourceDialog::~DataSourceDialog() +{ + delete m_pRangeChooserTabePage; + delete m_pDataSourceTabPage; + + m_nLastPageId = m_pTabControl->GetCurPageId(); + delete m_pTabControl; +} + +short DataSourceDialog::Execute() +{ + short nResult = TabDialog::Execute(); + if( nResult == RET_OK ) + { + if( m_pRangeChooserTabePage ) + m_pRangeChooserTabePage->commitPage(); + if( m_pDataSourceTabPage ) + m_pDataSourceTabPage->commitPage(); + } + return nResult; +} + +void DataSourceDialog::setInvalidPage( TabPage * pTabPage ) +{ + if( pTabPage == m_pRangeChooserTabePage ) + m_bRangeChooserTabIsValid = false; + else if( pTabPage == m_pDataSourceTabPage ) + m_bDataSourceTabIsValid = false; + + if( ! (m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid )) + { + m_aBtnOK.Enable( FALSE ); + OSL_ASSERT( m_pTabControl ); + // note: there seems to be no suitable mechanism to address pages by + // identifier, at least it is unclear what the page identifiers are. + // @todo: change the fixed numbers to identifiers + if( m_bRangeChooserTabIsValid ) + m_pTabControl->SetCurPageId( m_pTabControl->GetPageId( 1 )); + else if( m_bDataSourceTabIsValid ) + m_pTabControl->SetCurPageId( m_pTabControl->GetPageId( 0 )); + m_pTabControl->DisableTabToggling(); + } +} + +void DataSourceDialog::setValidPage( TabPage * pTabPage ) +{ + if( pTabPage == m_pRangeChooserTabePage ) + m_bRangeChooserTabIsValid = true; + else if( pTabPage == m_pDataSourceTabPage ) + m_bDataSourceTabIsValid = true; + + if( m_bRangeChooserTabIsValid && m_bDataSourceTabIsValid ) + { + m_aBtnOK.Enable( TRUE ); + OSL_ASSERT( m_pTabControl ); + m_pTabControl->EnableTabToggling(); + } +} + + +} // namespace chart diff --git a/chart2/source/controller/dialogs/dlg_DataSource.hrc b/chart2/source/controller/dialogs/dlg_DataSource.hrc new file mode 100644 index 000000000000..c1386c706a08 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataSource.hrc @@ -0,0 +1,36 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataSource.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define TABCTRL 1 + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 diff --git a/chart2/source/controller/dialogs/dlg_DataSource.src b/chart2/source/controller/dialogs/dlg_DataSource.src new file mode 100644 index 000000000000..ecf87eb49f35 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_DataSource.src @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataSource.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "dlg_DataSource.hrc" +#include "HelpIds.hrc" + +// for BUTTONS_OK_CANCEL_HELP_STACKED +#include "CommonResources.hrc" + +TabDialog DLG_DATA_SOURCE +{ + HelpID = HID_SCH_DLG_RANGES ; + + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE ; + Text [ en-US ] = "Data Ranges" ; + TabControl TABCTRL + { + OutputSize = TRUE ; + Pos = MAP_APPFONT ( 3 , 3 ) ; + }; + BUTTONS_OK_CANCEL_HELP_STACKED( 200 ) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx new file mode 100644 index 000000000000..99b88b956c88 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.cxx @@ -0,0 +1,167 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertAxis_Grid.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "dlg_InsertAxis_Grid.hxx" +#include "dlg_InsertAxis_Grid.hrc" + +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" +#include "NoWarningThisInCTOR.hxx" +#include "ObjectNameProvider.hxx" + +// header for class SfxBoolItem +#include <svtools/eitem.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +InsertAxisOrGridDialogData::InsertAxisOrGridDialogData() + : aPossibilityList(6) + , aExistenceList(6) +{ + sal_Int32 nN = 0; + for(nN=6;nN--;) + aPossibilityList[nN]=true; + for(nN=6;nN--;) + aExistenceList[nN]=false; +} + +//============================== +// +// SchAxisDlg +// +//============================== + +SchAxisDlg::SchAxisDlg( Window* pWindow + , const InsertAxisOrGridDialogData& rInput, BOOL bAxisDlg ) + : + ModalDialog( pWindow, SchResId( DLG_AXIS_OR_GRID )), + + aFlPrimary( this, SchResId( FL_PRIMARY_AXIS )), + aFlPrimaryGrid( this, SchResId( FL_PRIMARY_GRID )), + aCbPrimaryX( this, SchResId( CB_X_PRIMARY )), + aCbPrimaryY( this, SchResId( CB_Y_PRIMARY )), + aCbPrimaryZ( this, SchResId( CB_Z_PRIMARY )), + + aFlSecondary( this, SchResId( FL_SECONDARY_AXIS )), + aFlSecondaryGrid( this, SchResId( FL_SECONDARY_GRID )), + aCbSecondaryX( this, SchResId( CB_X_SECONDARY )), + aCbSecondaryY( this, SchResId( CB_Y_SECONDARY )), + aCbSecondaryZ( this, SchResId( CB_Z_SECONDARY )), + + aPbOK( this, SchResId( BTN_OK )), + aPbCancel( this, SchResId( BTN_CANCEL )), + aPbHelp( this, SchResId( BTN_HELP )) + + //rOutAttrs( rInAttrs ) +{ + FreeResource(); + if(!bAxisDlg) + { + SetHelpId( SID_INSERT_GRIDS ); + SetText( ObjectNameProvider::getName(OBJECTTYPE_GRID,true) ); + + aCbPrimaryX.SetHelpId( HID_SCH_CB_XGRID ); + aCbPrimaryY.SetHelpId( HID_SCH_CB_YGRID ); + aCbPrimaryZ.SetHelpId( HID_SCH_CB_ZGRID ); + aCbSecondaryX.SetHelpId( HID_SCH_CB_SECONDARY_XGRID ); + aCbSecondaryY.SetHelpId( HID_SCH_CB_SECONDARY_YGRID ); + aCbSecondaryZ.SetHelpId( HID_SCH_CB_SECONDARY_ZGRID ); + + aFlPrimary.Hide(); + aFlSecondary.Hide(); + aFlPrimaryGrid.Show(); + aFlSecondaryGrid.Show(); + } + else + { + SetText( ObjectNameProvider::getName(OBJECTTYPE_AXIS,true) ); + + //todo: remove if secondary z axis are possible somewhere + { + aCbSecondaryZ.Hide(); + + Size aSize( GetSizePixel() ); + //aSize.Height() -= aCbSecondaryZ.GetSizePixel().Height(); + aSize.Height() -= ( aCbSecondaryZ.GetPosPixel().Y() - aCbSecondaryY.GetPosPixel().Y() ); + SetSizePixel(aSize); + } + } + + aCbPrimaryX.Check( rInput.aExistenceList[0] ); + aCbPrimaryY.Check( rInput.aExistenceList[1] ); + aCbPrimaryZ.Check( rInput.aExistenceList[2] ); + aCbSecondaryX.Check( rInput.aExistenceList[3] ); + aCbSecondaryY.Check( rInput.aExistenceList[4] ); + aCbSecondaryZ.Check( rInput.aExistenceList[5] ); + + aCbPrimaryX.Enable( rInput.aPossibilityList[0] ); + aCbPrimaryY.Enable( rInput.aPossibilityList[1] ); + aCbPrimaryZ.Enable( rInput.aPossibilityList[2] ); + aCbSecondaryX.Enable( rInput.aPossibilityList[3] ); + aCbSecondaryY.Enable( rInput.aPossibilityList[4] ); + aCbSecondaryZ.Enable( rInput.aPossibilityList[5] ); +} + +SchAxisDlg::~SchAxisDlg() +{ +} + +void SchAxisDlg::getResult( InsertAxisOrGridDialogData& rOutput ) +{ + rOutput.aExistenceList[0]=aCbPrimaryX.IsChecked(); + rOutput.aExistenceList[1]=aCbPrimaryY.IsChecked(); + rOutput.aExistenceList[2]=aCbPrimaryZ.IsChecked(); + rOutput.aExistenceList[3]=aCbSecondaryX.IsChecked(); + rOutput.aExistenceList[4]=aCbSecondaryY.IsChecked(); + rOutput.aExistenceList[5]=aCbSecondaryZ.IsChecked(); +} + +SchGridDlg::SchGridDlg( Window* pParent, const InsertAxisOrGridDialogData& rInput ) + : SchAxisDlg( pParent, rInput, false )//rInAttrs, b3D, bNet, bSecondaryX, bSecondaryY, false ) +{ +} + +SchGridDlg::~SchGridDlg() +{ +} + +//............................................................................. +} //namespace chart +//............................................................................. + + + diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.hrc b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.hrc new file mode 100644 index 000000000000..083e2593717e --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.hrc @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertAxis_Grid.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_PRIMARY_AXIS 1 +#define FL_SECONDARY_AXIS 2 + +#define FL_PRIMARY_GRID 3 +#define FL_SECONDARY_GRID 4 + +#define CB_X_PRIMARY 1 +#define CB_Y_PRIMARY 2 +#define CB_Z_PRIMARY 3 + +#define CB_X_SECONDARY 4 +#define CB_Y_SECONDARY 5 +#define CB_Z_SECONDARY 6 + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 diff --git a/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.src b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.src new file mode 100644 index 000000000000..55643f40a54c --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertAxis_Grid.src @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertAxis_Grid.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertAxis_Grid.hrc" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" +#include "CommonResources.hrc" +#include "res_SecondaryAxisCheckBoxes.hrc" + +ModalDialog DLG_AXIS_OR_GRID +{ + HelpID = SID_INSERT_AXIS ; + OutputSize = TRUE ; + SVLook = TRUE ; + //Size = MAP_APPFONT ( 160 , 99 ) ; + Size = MAP_APPFONT ( 160 , 113 ) ; + Moveable = TRUE ; + + FixedLine FL_PRIMARY_AXIS + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 92 , 8 ) ; + Text [ en-US ] = "Axes" ; + }; + FixedLine FL_PRIMARY_GRID + { + Hide = TRUE ; + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 92 , 8 ) ; + Text [ en-US ] = "Major grids" ; + }; + CheckBox CB_X_PRIMARY + { + HelpID = HID_SCH_CB_XAXIS; + + Pos = MAP_APPFONT ( 12 , 14 ); + Size = MAP_APPFONT ( 80 , 10 ); + TabStop = TRUE; + Text [ en-US ] = "~X axis"; + }; + CheckBox CB_Y_PRIMARY + { + HelpID = HID_SCH_CB_YAXIS; + + Pos = MAP_APPFONT ( 12 , 28 ); + Size = MAP_APPFONT ( 80 , 10 ); + TabStop = TRUE; + Text [ en-US ] = "~Y axis"; + }; + CheckBox CB_Z_PRIMARY + { + HelpID = HID_SCH_CB_ZAXIS; + + Pos = MAP_APPFONT ( 12 , 42 ); + Size = MAP_APPFONT ( 80 , 10 ); + TabStop = TRUE; + Text [ en-US ] = "~Z axis"; + }; + + FixedLine FL_SECONDARY_AXIS + { + Pos = MAP_APPFONT ( 6 , 58 ) ; + Size = MAP_APPFONT ( 92 , 8 ) ; + Text [ en-US ] = "Secondary axes" ; + }; + FixedLine FL_SECONDARY_GRID + { + Hide = TRUE ; + Pos = MAP_APPFONT ( 6 , 58 ) ; + Size = MAP_APPFONT ( 92 , 8 ) ; + Text [ en-US ] = "Minor grids" ; + }; + SECONDARYAXISCHECKBOXES( 12, 69, 0, 14 ) + BUTTONS_OK_CANCEL_HELP_STACKED(104) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx new file mode 100644 index 000000000000..d7eb3357e6e8 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertDataLabel.cxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertDataLabel.cxx,v $ + * $Revision: 1.10.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_InsertDataLabel.hxx" +#include "dlg_InsertDataLabel.hrc" +#include "ResId.hxx" +#include "ObjectNameProvider.hxx" +#include "res_DataLabel.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +DataLabelsDialog::DataLabelsDialog(Window* pWindow, const SfxItemSet& rInAttrs, SvNumberFormatter* pFormatter) : + ModalDialog(pWindow, SchResId(DLG_DATA_DESCR)), + m_aBtnOK(this, SchResId(BTN_OK)), + m_aBtnCancel(this, SchResId(BTN_CANCEL)), + m_aBtnHelp(this, SchResId(BTN_HELP)), + m_apDataLabelResources( new DataLabelResources(this,rInAttrs) ), + m_rInAttrs(rInAttrs) +{ + FreeResource(); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_LABELS ) ); + + m_apDataLabelResources->SetNumberFormatter( pFormatter ); + Reset(); +} + +DataLabelsDialog::~DataLabelsDialog() +{ +} + +void DataLabelsDialog::Reset() +{ + m_apDataLabelResources->Reset(m_rInAttrs); +} + +void DataLabelsDialog::FillItemSet(SfxItemSet& rOutAttrs) +{ + m_apDataLabelResources->FillItemSet(rOutAttrs); +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/dlg_InsertDataLabel.hrc b/chart2/source/controller/dialogs/dlg_InsertDataLabel.hrc new file mode 100644 index 000000000000..a6ac7c164c73 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertDataLabel.hrc @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertDataLabel.hrc,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertDataLabel.src b/chart2/source/controller/dialogs/dlg_InsertDataLabel.src new file mode 100644 index 000000000000..091628a2c73e --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertDataLabel.src @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertDataLabel.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertDataLabel.hrc" +#include "SchSlotIds.hxx" +#include "CommonResources.hrc" +#include "res_DataLabel.hrc" + +ModalDialog DLG_DATA_DESCR +{ + HelpID = SID_INSERT_DESCRIPTION ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 316 , 185 ) ; + Moveable = TRUE ; + BUTTONS_OK_CANCEL_HELP_STACKED(260) + RESOURCE_DATALABEL( 6, 7 ) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx new file mode 100644 index 000000000000..535b07a7df38 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.cxx @@ -0,0 +1,137 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertErrorBars.cxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_InsertErrorBars.hxx" +#include "dlg_InsertErrorBars.hrc" +#include "res_ErrorBar.hxx" +#include "ResourceIds.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "chartview/ExplicitValueProvider.hxx" +#include "ChartModelHelper.hxx" +#include "ObjectIdentifier.hxx" +#include "DiagramHelper.hxx" +#include "AxisHelper.hxx" +#include "ObjectNameProvider.hxx" + +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> + +using ::rtl::OUString; +using ::com::sun::star::uno::Reference; +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +//............................................................................. +namespace chart +{ +//............................................................................. + +InsertErrorBarsDialog::InsertErrorBarsDialog( + Window* pParent, const SfxItemSet& rMyAttrs, + const uno::Reference< chart2::XChartDocument > & xChartDocument, + ErrorBarResources::tErrorBarType eType /* = ErrorBarResources::ERROR_BAR_Y */ ) : + ModalDialog( pParent, SchResId( DLG_DATA_YERRORBAR )), + rInAttrs( rMyAttrs ), + aBtnOK( this, SchResId( BTN_OK )), + aBtnCancel( this, SchResId( BTN_CANCEL )), + aBtnHelp( this, SchResId( BTN_HELP )), + m_apErrorBarResources( new ErrorBarResources( + this, this, rInAttrs, + /* bNoneAvailable = */ true, eType )) +{ + FreeResource(); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ); + + m_apErrorBarResources->SetChartDocumentForRangeChoosing( xChartDocument ); +} + +InsertErrorBarsDialog::~InsertErrorBarsDialog() +{ +} + +void InsertErrorBarsDialog::FillItemSet(SfxItemSet& rOutAttrs) +{ + m_apErrorBarResources->FillItemSet(rOutAttrs); +} + +void InsertErrorBarsDialog::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ModalDialog::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + m_apErrorBarResources->FillValueSets(); +} + +void InsertErrorBarsDialog::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ) +{ + m_apErrorBarResources->SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth ); +} + +//static +double InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( + const Reference< frame::XModel >& xChartModel, + const Reference< uno::XInterface >& xChartView, + const OUString& rSelectedObjectCID ) +{ + double fStepWidth = 0.001; + + ExplicitValueProvider* pExplicitValueProvider( ExplicitValueProvider::getExplicitValueProvider(xChartView) ); + if( pExplicitValueProvider ) + { + Reference< XAxis > xAxis; + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedObjectCID, xChartModel ); + xAxis = DiagramHelper::getAttachedAxis( xSeries, xDiagram ); + if(!xAxis.is()) + xAxis = AxisHelper::getAxis( 1/*nDimensionIndex*/, true/*bMainAxis*/, xDiagram ); + if(xAxis.is()) + { + ExplicitScaleData aExplicitScale; + ExplicitIncrementData aExplicitIncrement; + pExplicitValueProvider->getExplicitValuesForAxis( xAxis,aExplicitScale, aExplicitIncrement ); + + fStepWidth = aExplicitIncrement.Distance; + if( aExplicitIncrement.SubIncrements.getLength() && aExplicitIncrement.SubIncrements[0].IntervalCount>0 ) + fStepWidth=fStepWidth/double(aExplicitIncrement.SubIncrements[0].IntervalCount); + else + fStepWidth/=10; + } + } + + return fStepWidth; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.hrc b/chart2/source/controller/dialogs/dlg_InsertErrorBars.hrc new file mode 100644 index 000000000000..c545ad60edfd --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.hrc @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertErrorBars.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertErrorBars.src b/chart2/source/controller/dialogs/dlg_InsertErrorBars.src new file mode 100644 index 000000000000..b83103ee54ae --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertErrorBars.src @@ -0,0 +1,46 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertErrorBars.src,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertErrorBars.hrc" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" +#include "CommonResources.hrc" +#include "res_ErrorBar.hrc" + +ModalDialog DLG_DATA_YERRORBAR +{ +// HelpID = SID_INSERT_STATISTICS ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 300 , 156 ) ; + Moveable = TRUE ; + BUTTONS_OK_CANCEL_HELP_STACKED( 244 ) + RESOURCE_ERRORBARS( 244 - 6, 14 ) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.cxx b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx new file mode 100644 index 000000000000..9ffaa2b28490 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertLegend.cxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertLegend.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "dlg_InsertLegend.hxx" +#include "dlg_InsertLegend.hrc" +#include "res_LegendPosition.hxx" +#include "ObjectNameProvider.hxx" +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" + +// header for enum SvxChartLegendPos +#include <svx/chrtitem.hxx> +// header for class SfxItemPool +#include <svtools/itempool.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; + +SchLegendDlg::SchLegendDlg(Window* pWindow, const uno::Reference< uno::XComponentContext>& xCC ) + : ModalDialog(pWindow, SchResId(DLG_LEGEND)) + , m_apLegendPositionResources( new LegendPositionResources(this,xCC) ) + , aBtnOK(this, SchResId(BTN_OK)) + , aBtnCancel(this, SchResId(BTN_CANCEL)) + , aBtnHelp(this, SchResId(BTN_HELP)) +{ + FreeResource(); + this->SetText( ObjectNameProvider::getName(OBJECTTYPE_LEGEND) ); +} + +SchLegendDlg::~SchLegendDlg() +{ +} + +void SchLegendDlg::init( const uno::Reference< frame::XModel >& xChartModel ) +{ + m_apLegendPositionResources->writeToResources( xChartModel ); +} + +bool SchLegendDlg::writeToModel( const uno::Reference< frame::XModel >& xChartModel ) const +{ + m_apLegendPositionResources->writeToModel( xChartModel ); + return true; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.hrc b/chart2/source/controller/dialogs/dlg_InsertLegend.hrc new file mode 100644 index 000000000000..723b1c0d3fda --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertLegend.hrc @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertLegend.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertLegend.src b/chart2/source/controller/dialogs/dlg_InsertLegend.src new file mode 100644 index 000000000000..263c37a1df33 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertLegend.src @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertLegend.src,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertLegend.hrc" +#include "SchSlotIds.hxx" +#include "CommonResources.hrc" +#include "res_LegendPosition.hrc" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +ModalDialog DLG_LEGEND +{ + HelpID = SID_INSERT_CHART_LEGEND ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 135 , 80 ) ; + Moveable = TRUE ; + BUTTONS_OK_CANCEL_HELP_STACKED( 79 ) + RESOURCE_LEGENDDISPLAY( 6, 6 ) + RESOURCE_LEGENDPOSITION( 15, 6 + RSC_CD_FIXEDTEXT_HEIGHT +6 ) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertTitle.cxx b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx new file mode 100644 index 000000000000..22fddfe29afb --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTitle.cxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTitle.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "dlg_InsertTitle.hxx" +#include "dlg_InsertTitle.hrc" +#include "res_Titles.hxx" +#include "ResId.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "ObjectNameProvider.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchTitleDlg::SchTitleDlg(Window* pWindow, const TitleDialogData& rInput ) + : ModalDialog(pWindow, SchResId(DLG_TITLE)) + , m_apTitleResources( new TitleResources(this,true) ) + , aBtnOK(this, SchResId(BTN_OK)) + , aBtnCancel(this, SchResId(BTN_CANCEL)) + , aBtnHelp(this, SchResId(BTN_HELP)) +{ + FreeResource(); + + this->SetText( ObjectNameProvider::getName(OBJECTTYPE_TITLE,true) ); + m_apTitleResources->writeToResources( rInput ); +} + +SchTitleDlg::~SchTitleDlg() +{ +} + +void SchTitleDlg::getResult( TitleDialogData& rOutput ) +{ + m_apTitleResources->readFromResources( rOutput ); +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/dlg_InsertTitle.hrc b/chart2/source/controller/dialogs/dlg_InsertTitle.hrc new file mode 100644 index 000000000000..effbc246ca9f --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTitle.hrc @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTitle.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertTitle.src b/chart2/source/controller/dialogs/dlg_InsertTitle.src new file mode 100644 index 000000000000..626d0b7ec481 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTitle.src @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTitle.src,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertTitle.hrc" +#include "res_Titlesx.hrc" +#include "SchSlotIds.hxx" +#include "CommonResources.hrc" + +ModalDialog DLG_TITLE +{ + HelpID = SID_INSERT_TITLE ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 220 , 156 ) ; + Moveable = TRUE ; + BUTTONS_OK_CANCEL_HELP_STACKED(164) + TITLES(6,6,152,6,10) +}; diff --git a/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx b/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx new file mode 100644 index 000000000000..042baa292f65 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTrendline.cxx @@ -0,0 +1,117 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTrendline.cxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_InsertTrendline.hxx" +#include "dlg_InsertTrendline.hrc" +#include "res_Trendline.hxx" +#include "ResourceIds.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "chartview/ExplicitValueProvider.hxx" +#include "ChartModelHelper.hxx" +#include "ObjectIdentifier.hxx" +#include "DiagramHelper.hxx" +#include "AxisHelper.hxx" +#include "ObjectNameProvider.hxx" +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> + +#include <svtools/controldims.hrc> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +namespace +{ +void lcl_SetControlXPos( Control & rControl, long nPosPixel ) +{ + Point aPos( rControl.GetPosPixel()); + aPos.setX( nPosPixel ); + rControl.SetPosPixel( aPos ); +} +} // anonymous namespace + +//............................................................................. +namespace chart +{ +//............................................................................. + +InsertTrendlineDialog::InsertTrendlineDialog( Window* pParent, const SfxItemSet& rMyAttrs ) : + ModalDialog( pParent, SchResId( DLG_DATA_TRENDLINE )), + rInAttrs( rMyAttrs ), + aBtnOK( this, SchResId( BTN_OK )), + aBtnCancel( this, SchResId( BTN_CANCEL )), + aBtnHelp( this, SchResId( BTN_HELP )), + m_apTrendlineResources( new TrendlineResources( this, rInAttrs, true )) +{ + FreeResource(); + this->SetText( ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ); +} + +InsertTrendlineDialog::~InsertTrendlineDialog() +{ +} + +void InsertTrendlineDialog::adjustSize() +{ + long nControlsRightEdge = m_apTrendlineResources->adjustControlSizes(); + long nButtonXPos = nControlsRightEdge + + LogicToPixel( Size( RSC_SP_CTRL_X, 10 ), MapMode( MAP_APPFONT )).getWidth(); + lcl_SetControlXPos( aBtnOK, nButtonXPos ); + lcl_SetControlXPos( aBtnCancel, nButtonXPos ); + lcl_SetControlXPos( aBtnHelp, nButtonXPos ); + + Size aDialogSize( GetSizePixel()); + aDialogSize.setWidth( + nControlsRightEdge + + LogicToPixel( Size( RSC_SP_CTRL_X + RSC_CD_PUSHBUTTON_WIDTH + RSC_SP_DLG_INNERBORDER_RIGHT, 0 ), + MapMode( MAP_APPFONT )).getWidth()); + SetSizePixel( aDialogSize ); +} + +void InsertTrendlineDialog::FillItemSet(SfxItemSet& rOutAttrs) +{ + m_apTrendlineResources->FillItemSet(rOutAttrs); +} + +void InsertTrendlineDialog::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ModalDialog::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + m_apTrendlineResources->FillValueSets(); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_InsertTrendline.hrc b/chart2/source/controller/dialogs/dlg_InsertTrendline.hrc new file mode 100644 index 000000000000..cb9de59a5cbb --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTrendline.hrc @@ -0,0 +1,34 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTrendline.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 diff --git a/chart2/source/controller/dialogs/dlg_InsertTrendline.src b/chart2/source/controller/dialogs/dlg_InsertTrendline.src new file mode 100644 index 000000000000..002e769a1037 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_InsertTrendline.src @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTrendline.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_InsertTrendline.hrc" +#include "SchSlotIds.hxx" +#include "HelpIds.hrc" +#include "CommonResources.hrc" +#include "res_Trendline.hrc" + +// is only an initial size, will be calculated to contain all controls +#define DLG_DATA_TRENDLINE_RES_WIDTH 130 +#define DLG_DATA_TRENDLINE_ADD_TO_RES 62 + +ModalDialog DLG_DATA_TRENDLINE +{ + HelpID = SID_INSERT_STATISTICS ; + OutputSize = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT( DLG_DATA_TRENDLINE_RES_WIDTH + DLG_DATA_TRENDLINE_ADD_TO_RES, 172 ); + Moveable = TRUE ; + BUTTONS_OK_CANCEL_HELP_STACKED( DLG_DATA_TRENDLINE_RES_WIDTH + DLG_DATA_TRENDLINE_ADD_TO_RES ) + RESOURCE_TRENDLINE( DLG_DATA_TRENDLINE_RES_WIDTH, 22 ) +}; + diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.cxx b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx new file mode 100644 index 000000000000..c8684bdaecbc --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.cxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_NumberFormat.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_NumberFormat.hxx" + +// header for class SfxItemSet +#include <svtools/itemset.hxx> + +// header for class SvxNumberInfoItem +#define ITEMID_NUMBERINFO SID_ATTR_NUMBERFORMAT_INFO +#include <svx/numinf.hxx> + +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include <sfx2/tabdlg.hxx> + +// header for SvNumberFormatter +#include <svtools/zforlist.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +NumberFormatDialog::NumberFormatDialog(Window* pParent, SfxItemSet& rSet) + : SfxSingleTabDialog( pParent, rSet, 0 ) +{ + SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create(); + ::CreateTabPage fnCreatePage = pFact->GetTabPageCreatorFunc( RID_SVXPAGE_NUMBERFORMAT ); + if ( fnCreatePage ) + { + SfxTabPage* pTabPage = (*fnCreatePage)( this, rSet ); + pTabPage->PageCreated(rSet); + SetTabPage(pTabPage); + } +} + +NumberFormatDialog::~NumberFormatDialog() +{ +} + +//static +SfxItemSet NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ) +{ + static const USHORT nWhichPairs[] = + { + SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_INFO, + SID_ATTR_NUMBERFORMAT_NOLANGUAGE, SID_ATTR_NUMBERFORMAT_NOLANGUAGE, + SID_ATTR_NUMBERFORMAT_ONE_AREA, SID_ATTR_NUMBERFORMAT_ONE_AREA, + SID_ATTR_NUMBERFORMAT_SOURCE, SID_ATTR_NUMBERFORMAT_SOURCE, + 0 + }; + return SfxItemSet( rItemPool, nWhichPairs ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_NumberFormat.hxx b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx new file mode 100644 index 000000000000..5f42cc468771 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_NumberFormat.hxx @@ -0,0 +1,57 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_NumberFormat.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DLG_NUMBERFORMAT_HXX +#define CHART2_DLG_NUMBERFORMAT_HXX + +#include <sfx2/basedlgs.hxx> + +class Window; +class SfxItemSet; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class NumberFormatDialog : public SfxSingleTabDialog +{ +public: + NumberFormatDialog(Window* pParent, SfxItemSet& rSet); + ~NumberFormatDialog(); + + static SfxItemSet CreateEmptyItemSetForNumberFormatDialog( SfxItemPool& rItemPool ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx new file mode 100644 index 000000000000..097c6c1d0107 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.cxx @@ -0,0 +1,653 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ObjectProperties.cxx,v $ + * $Revision: 1.23.42.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#ifndef _ZFORLIST_HXX +#ifndef _ZFORLIST_DECLARE_TABLE +#define _ZFORLIST_DECLARE_TABLE +#endif +#include <svtools/zforlist.hxx> +#endif + +#include "dlg_ObjectProperties.hxx" +#include "ResourceIds.hrc" +#include "Strings.hrc" +#include "TabPages.hrc" +#include "tp_AxisLabel.hxx" +#include "tp_DataLabel.hxx" +#include "tp_LegendPosition.hxx" +#include "tp_PointGeometry.hxx" +#include "tp_Scale.hxx" +#include "tp_AxisPositions.hxx" +#include "tp_ErrorBars.hxx" +#include "tp_Trendline.hxx" +#include "tp_SeriesToAxis.hxx" +#include "tp_TitleRotation.hxx" +#include "tp_PolarOptions.hxx" +#include "ResId.hxx" +#include "ViewElementListProvider.hxx" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "ObjectNameProvider.hxx" +#include "DiagramHelper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "AxisIndexDefines.hxx" +#include "AxisHelper.hxx" + +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <svtools/intitem.hxx> +#include <svtools/languageoptions.hxx> + +#include <svx/svxids.hrc> + +#include <svx/drawitem.hxx> +#include <svx/ofaitem.hxx> +#include <svx/svxgrahicitem.hxx> + +#include <svx/dialogs.hrc> +#include <svx/flstitem.hxx> +#include <svx/tabline.hxx> + +#include <svx/flagsdef.hxx> +#include <svx/numinf.hxx> + +#include <svtools/cjkoptions.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +ObjectPropertiesDialogParameter::ObjectPropertiesDialogParameter( const rtl::OUString& rObjectCID ) + : m_aObjectCID( rObjectCID ) + , m_eObjectType( ObjectIdentifier::getObjectType( m_aObjectCID ) ) + , m_bAffectsMultipleObjects(false) + , m_aLocalizedName() + , m_bHasGeometryProperties(false) + , m_bHasStatisticProperties(false) + , m_bProvidesSecondaryYAxis(false) + , m_bProvidesOverlapAndGapWidth(false) + , m_bProvidesBarConnectors(false) + , m_bHasAreaProperties(false) + , m_bHasSymbolProperties(false) + , m_bHasNumberProperties(false) + , m_bProvidesStartingAngle(false) + , m_bProvidesMissingValueTreatments(false) + , m_bHasScaleProperties(false) + , m_bCanAxisLabelsBeStaggered(false) + , m_bSupportingAxisPositioning(false) + , m_bShowAxisOrigin(false) + , m_bIsCrossingAxisIsCategoryAxis(false) + , m_aCategories() + , m_xChartDocument( 0 ) +{ + rtl::OUString aParticleID = ObjectIdentifier::getParticleID( m_aObjectCID ); + m_bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS")); +} +ObjectPropertiesDialogParameter::~ObjectPropertiesDialogParameter() +{ +} +ObjectType ObjectPropertiesDialogParameter::getObjectType() const +{ + return m_eObjectType; +} +rtl::OUString ObjectPropertiesDialogParameter::getLocalizedName() const +{ + return m_aLocalizedName; +} + +void ObjectPropertiesDialogParameter::init( const uno::Reference< frame::XModel >& 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 ); + + bool bHasSeriesProperties = (OBJECTTYPE_DATA_SERIES==m_eObjectType); + bool bHasDataPointproperties = (OBJECTTYPE_DATA_POINT==m_eObjectType); + + if( bHasSeriesProperties || bHasDataPointproperties ) + { + m_bHasGeometryProperties = ChartTypeHelper::isSupportingGeometryProperties( xChartType, nDimensionCount ); + m_bHasAreaProperties = ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ); + m_bHasSymbolProperties = ChartTypeHelper::isSupportingSymbolProperties( xChartType, nDimensionCount ); + + if( bHasSeriesProperties ) + { + m_bHasStatisticProperties = ChartTypeHelper::isSupportingStatisticProperties( xChartType, nDimensionCount ); + m_bProvidesSecondaryYAxis = ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount, 1 ); + m_bProvidesOverlapAndGapWidth = ChartTypeHelper::isSupportingOverlapAndGapWidthProperties( xChartType, nDimensionCount ); + m_bProvidesBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount ); + m_bProvidesStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType ); + + m_bProvidesMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ) + .getLength() ? true : false; + } + } + + if( OBJECTTYPE_DATA_ERRORS == m_eObjectType ) + m_bHasStatisticProperties = true; + + if( OBJECTTYPE_AXIS == m_eObjectType ) + { + //show scale properties only for a single axis not for multiselection + m_bHasScaleProperties = !m_bAffectsMultipleObjects; + + if( m_bHasScaleProperties ) + { + uno::Reference< XAxis > xAxis( ObjectIdentifier::getAxisForCID( m_aObjectCID, xChartModel ) ); + if( xAxis.is() ) + { + //no scale page for series axis + ScaleData aData( xAxis->getScaleData() ); + if( chart2::AxisType::SERIES == aData.AxisType ) + m_bHasScaleProperties = false; + if( chart2::AxisType::REALNUMBER == aData.AxisType || chart2::AxisType::PERCENT == aData.AxisType ) + m_bHasNumberProperties = true; + + sal_Int32 nCooSysIndex=0; + sal_Int32 nDimensionIndex=0; + sal_Int32 nAxisIndex=0; + if( AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ) ) + { + xChartType = AxisHelper::getFirstChartTypeWithSeriesAttachedToAxisIndex( xDiagram, nAxisIndex ); + //show positioning controls only if they make sense + m_bSupportingAxisPositioning = ChartTypeHelper::isSupportingAxisPositioning( xChartType, nDimensionCount, nDimensionIndex ); + + //show axis origin only for secondary y axis + if( 1==nDimensionIndex && 1==nAxisIndex && ChartTypeHelper::isSupportingBaseValue( xChartType ) ) + m_bShowAxisOrigin = true; + } + + //is the crossin main axis a category axes?: + uno::Reference< XCoordinateSystem > xCooSys( AxisHelper::getCoordinateSystemOfAxis( xAxis, xDiagram ) ); + uno::Reference< XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( xAxis, xCooSys ) ); + if( xCrossingMainAxis.is() ) + { + ScaleData aScale( xCrossingMainAxis->getScaleData() ); + m_bIsCrossingAxisIsCategoryAxis = ( chart2::AxisType::CATEGORY == aScale.AxisType ); + if( m_bIsCrossingAxisIsCategoryAxis ) + m_aCategories = DiagramHelper::generateAutomaticCategories( Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY) ); + } + } + } + + //no staggering of labels for 3D axis + m_bCanAxisLabelsBeStaggered = nDimensionCount==2; + } + + //create gui name for this object + { + if( !m_bAffectsMultipleObjects && OBJECTTYPE_AXIS == m_eObjectType ) + { + m_aLocalizedName = ObjectNameProvider::getAxisName( m_aObjectCID, xChartModel ); + } + else if( !m_bAffectsMultipleObjects && ( OBJECTTYPE_GRID == m_eObjectType || OBJECTTYPE_SUBGRID == m_eObjectType ) ) + { + m_aLocalizedName = ObjectNameProvider::getGridName( m_aObjectCID, xChartModel ); + } + else if( !m_bAffectsMultipleObjects && OBJECTTYPE_TITLE == m_eObjectType ) + { + m_aLocalizedName = ObjectNameProvider::getTitleName( m_aObjectCID, xChartModel ); + } + else + { + switch( m_eObjectType ) + { + case OBJECTTYPE_DATA_POINT: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_CURVE: + case OBJECTTYPE_DATA_CURVE_EQUATION: + if( m_bAffectsMultipleObjects ) + m_aLocalizedName = ObjectNameProvider::getName_ObjectForAllSeries( m_eObjectType ); + else + m_aLocalizedName = ObjectNameProvider::getName_ObjectForSeries( m_eObjectType, m_aObjectCID, m_xChartDocument ); + break; + default: + m_aLocalizedName = ObjectNameProvider::getName(m_eObjectType,m_bAffectsMultipleObjects); + break; + } + } + } +} + +bool ObjectPropertiesDialogParameter::HasGeometryProperties() const +{ + return m_bHasGeometryProperties; +} +bool ObjectPropertiesDialogParameter::HasStatisticProperties() const +{ + return m_bHasStatisticProperties; +} +bool ObjectPropertiesDialogParameter::ProvidesSecondaryYAxis() const +{ + return m_bProvidesSecondaryYAxis; +} +bool ObjectPropertiesDialogParameter::ProvidesOverlapAndGapWidth() const +{ + return m_bProvidesOverlapAndGapWidth; +} +bool ObjectPropertiesDialogParameter::ProvidesBarConnectors() const +{ + return m_bProvidesBarConnectors; +} +bool ObjectPropertiesDialogParameter::HasAreaProperties() const +{ + return m_bHasAreaProperties; +} +bool ObjectPropertiesDialogParameter::HasSymbolProperties() const +{ + return m_bHasSymbolProperties; +} +bool ObjectPropertiesDialogParameter::HasScaleProperties() const +{ + return m_bHasScaleProperties; +} +bool ObjectPropertiesDialogParameter::CanAxisLabelsBeStaggered() const +{ + return m_bCanAxisLabelsBeStaggered; +} +bool ObjectPropertiesDialogParameter::ShowAxisOrigin() const +{ + return m_bShowAxisOrigin; +} +bool ObjectPropertiesDialogParameter::IsSupportingAxisPositioning() const +{ + return m_bSupportingAxisPositioning; +} +bool ObjectPropertiesDialogParameter::IsCrossingAxisIsCategoryAxis() const +{ + return m_bIsCrossingAxisIsCategoryAxis; +} +const uno::Sequence< rtl::OUString >& ObjectPropertiesDialogParameter::GetCategories() const +{ + return m_aCategories; +} +bool ObjectPropertiesDialogParameter::HasNumberProperties() const +{ + return m_bHasNumberProperties; +} +bool ObjectPropertiesDialogParameter::ProvidesStartingAngle() const +{ + return m_bProvidesStartingAngle; +} +bool ObjectPropertiesDialogParameter::ProvidesMissingValueTreatments() const +{ + return m_bProvidesMissingValueTreatments; +} +uno::Reference< chart2::XChartDocument > ObjectPropertiesDialogParameter::getDocument() const +{ + return m_xChartDocument; +} + +//const USHORT nNoArrowDlg = 1100; +const USHORT nNoArrowNoShadowDlg = 1101; + +//------------------------------------------------------------------- +//------------------------------------------------------------------- +//------------------------------------------------------------------- + +void SchAttribTabDlg::setSymbolInformation( SfxItemSet* pSymbolShapeProperties, + Graphic* pAutoSymbolGraphic ) +{ + m_pSymbolShapeProperties = pSymbolShapeProperties; + m_pAutoSymbolGraphic = pAutoSymbolGraphic; +} + +void SchAttribTabDlg::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ) +{ + m_fAxisMinorStepWidthForErrorBarDecimals = fMinorStepWidth; +} + +SchAttribTabDlg::SchAttribTabDlg(Window* pParent, + const SfxItemSet* pAttr, + const ObjectPropertiesDialogParameter* pDialogParameter, + const ViewElementListProvider* pViewElementListProvider, + const uno::Reference< util::XNumberFormatsSupplier >& xNumberFormatsSupplier + ) + : SfxTabDialog(pParent, SchResId(DLG_OBJECT_PROPERTIES), pAttr) + , eObjectType(pDialogParameter->getObjectType()) + , nDlgType(nNoArrowNoShadowDlg) + , nPageType(0) + , m_pParameter( pDialogParameter ) + , m_pViewElementListProvider( pViewElementListProvider ) + , m_pNumberFormatter(0) + , m_pSymbolShapeProperties(NULL) + , m_pAutoSymbolGraphic(NULL) + , m_fAxisMinorStepWidthForErrorBarDecimals(0.1) + , m_bOKPressed(false) +{ + FreeResource(); + + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + m_pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); + + this->SetText( pDialogParameter->getLocalizedName() ); + + SvtCJKOptions aCJKOptions; + + switch (eObjectType) + { + case OBJECTTYPE_TITLE: + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); + AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); + AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); + AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); + AddTabPage(TP_ALIGNMENT, String(SchResId(STR_PAGE_ALIGNMENT)), SchAlignmentTabPage::Create, NULL); + if( aCJKOptions.IsAsianTypographyEnabled() ) + AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); + break; + + case OBJECTTYPE_LEGEND: + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); + AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); + AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); + AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); + AddTabPage(TP_LEGEND_POS, String(SchResId(STR_PAGE_POSITION)), SchLegendPosTabPage::Create, NULL); + if( aCJKOptions.IsAsianTypographyEnabled() ) + AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); + break; + + case OBJECTTYPE_DATA_SERIES: + case OBJECTTYPE_DATA_POINT: + if( m_pParameter->ProvidesSecondaryYAxis() || m_pParameter->ProvidesOverlapAndGapWidth() || m_pParameter->ProvidesMissingValueTreatments() ) + AddTabPage(TP_OPTIONS, String(SchResId(STR_PAGE_OPTIONS)),SchOptionTabPage::Create, NULL); + if( m_pParameter->ProvidesStartingAngle()) + AddTabPage(TP_POLAROPTIONS, String(SchResId(STR_PAGE_OPTIONS)),PolarOptionsTabPage::Create, NULL); + + if( m_pParameter->HasGeometryProperties() ) + AddTabPage(TP_LAYOUT, String(SchResId(STR_PAGE_LAYOUT)),SchLayoutTabPage::Create, NULL); + + if(m_pParameter->HasAreaProperties()) + { + AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); + AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); + } + AddTabPage(RID_SVXPAGE_LINE, String(SchResId( m_pParameter->HasAreaProperties() ? STR_PAGE_BORDER : STR_PAGE_LINE ))); + break; + + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_LABELS: + AddTabPage(TP_DATA_DESCR, String(SchResId(STR_OBJECT_DATALABELS)), DataLabelsTabPage::Create, NULL); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); + AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); + if( aCJKOptions.IsAsianTypographyEnabled() ) + AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); + + break; + + case OBJECTTYPE_AXIS: + { + if( m_pParameter->HasScaleProperties() ) + AddTabPage(TP_SCALE, String(SchResId(STR_PAGE_SCALE)), ScaleTabPage::Create, NULL); + + if( m_pParameter->HasScaleProperties() )//no positioning page for z axes so far as the tickmarks are not shown so far + AddTabPage(TP_AXIS_POSITIONS, String(SchResId(STR_PAGE_POSITIONING)), AxisPositionsTabPage::Create, NULL); + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); + AddTabPage(TP_AXIS_LABEL, String(SchResId(STR_OBJECT_LABEL)), SchAxisLabelTabPage::Create, NULL); + if( m_pParameter->HasNumberProperties() ) + AddTabPage(RID_SVXPAGE_NUMBERFORMAT, String(SchResId(STR_PAGE_NUMBERS))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); + AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); + if( aCJKOptions.IsAsianTypographyEnabled() ) + AddTabPage(RID_SVXPAGE_PARA_ASIAN, String(SchResId(STR_PAGE_ASIAN))); + break; + } + + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + AddTabPage(TP_YERRORBAR, String(SchResId(STR_PAGE_YERROR_BARS)), ErrorBarsTabPage::Create, NULL); + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); + break; + + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: + case OBJECTTYPE_DATA_AVERAGE_LINE: + case OBJECTTYPE_DATA_STOCK_RANGE: + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); + break; + + case OBJECTTYPE_DATA_CURVE: + AddTabPage(TP_TRENDLINE, String(SchResId(STR_PAGE_TRENDLINE_TYPE)), TrendlineTabPage::Create, NULL); + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_LINE))); + break; + + case OBJECTTYPE_DATA_STOCK_LOSS: + case OBJECTTYPE_DATA_STOCK_GAIN: + case OBJECTTYPE_PAGE: + case OBJECTTYPE_DIAGRAM_FLOOR: + case OBJECTTYPE_DIAGRAM_WALL: + case OBJECTTYPE_DIAGRAM: + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); + AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); + AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); + break; + + case OBJECTTYPE_LEGEND_ENTRY: + case OBJECTTYPE_AXIS_UNITLABEL: + case OBJECTTYPE_UNKNOWN: + // nothing + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: + AddTabPage(RID_SVXPAGE_LINE, String(SchResId(STR_PAGE_BORDER))); + AddTabPage(RID_SVXPAGE_AREA, String(SchResId(STR_PAGE_AREA))); + AddTabPage(RID_SVXPAGE_TRANSPARENCE, String(SchResId(STR_PAGE_TRANSPARENCY))); + AddTabPage(RID_SVXPAGE_CHAR_NAME, String(SchResId(STR_PAGE_FONT))); + AddTabPage(RID_SVXPAGE_CHAR_EFFECTS, String(SchResId(STR_PAGE_FONT_EFFECTS))); + AddTabPage(RID_SVXPAGE_NUMBERFORMAT, String(SchResId(STR_PAGE_NUMBERS))); + if( SvtLanguageOptions().IsCTLFontEnabled() ) + /* When rotation is supported for equation text boxes, use + SchAlignmentTabPage::Create here. The special + SchAlignmentTabPage::CreateWithoutRotation can be deleted. */ + AddTabPage(TP_ALIGNMENT, String(SchResId(STR_PAGE_ALIGNMENT)), SchAlignmentTabPage::CreateWithoutRotation, NULL); + break; + } + + // used to find out if user left the dialog with OK. When OK is pressed but + // no changes were done, Cancel is returned by the SfxTabDialog. See method + // DialogWasClosedWithOK. + m_aOriginalOKClickHdl = GetOKButton().GetClickHdl(); + GetOKButton().SetClickHdl( LINK( this, SchAttribTabDlg, OKPressed )); +} + +SchAttribTabDlg::~SchAttribTabDlg() +{ + delete m_pSymbolShapeProperties; + delete m_pAutoSymbolGraphic; +} + +void SchAttribTabDlg::PageCreated(USHORT nId, SfxTabPage &rPage) +{ + SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool())); + switch (nId) + { + case TP_LAYOUT: + break; + case RID_SVXPAGE_LINE: + aSet.Put (SvxColorTableItem(m_pViewElementListProvider->GetColorTable(),SID_COLOR_TABLE)); + aSet.Put (SvxDashListItem(m_pViewElementListProvider->GetDashList(),SID_DASH_LIST)); + aSet.Put (SvxLineEndListItem(m_pViewElementListProvider->GetLineEndList(),SID_LINEEND_LIST)); + aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType)); + aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); + + 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(SID_GRAPHIC,*m_pAutoSymbolGraphic)); + } + rPage.PageCreated(aSet); + //rPage.ActivatePage(*GetInputSetImpl()); //what for? + break; + + case RID_SVXPAGE_AREA: + aSet.Put(SvxColorTableItem(m_pViewElementListProvider->GetColorTable(),SID_COLOR_TABLE)); + aSet.Put(SvxGradientListItem(m_pViewElementListProvider->GetGradientList(),SID_GRADIENT_LIST)); + aSet.Put(SvxHatchListItem(m_pViewElementListProvider->GetHatchList(),SID_HATCH_LIST)); + aSet.Put(SvxBitmapListItem(m_pViewElementListProvider->GetBitmapList(),SID_BITMAP_LIST)); + aSet.Put(SfxUInt16Item(SID_PAGE_TYPE,nPageType)); + aSet.Put(SfxUInt16Item(SID_DLG_TYPE,nDlgType)); + rPage.PageCreated(aSet); + //rPage.ActivatePage(*GetInputSetImpl()); //what for? + break; + + case RID_SVXPAGE_TRANSPARENCE: + aSet.Put (SfxUInt16Item(SID_PAGE_TYPE,nPageType)); + aSet.Put (SfxUInt16Item(SID_DLG_TYPE,nDlgType)); + rPage.PageCreated(aSet); + break; + + case RID_SVXPAGE_CHAR_NAME: + + //CHINA001 ((SvxCharNamePage&)rPage). + //CHINA001 SetFontList(SvxFontListItem(m_pViewElementListProvider->getFontList())); + aSet.Put (SvxFontListItem(m_pViewElementListProvider->getFontList(), SID_ATTR_CHAR_FONTLIST)); //CHINA001 + rPage.PageCreated(aSet); //CHINA001 + break; + + case RID_SVXPAGE_CHAR_EFFECTS: + //CHINA001 ((SvxCharEffectsPage&) rPage).DisableControls( DISABLE_CASEMAP ); + aSet.Put (SfxUInt16Item(SID_DISABLE_CTL,DISABLE_CASEMAP)); //CHINA001 + rPage.PageCreated(aSet); + break; + + case TP_AXIS_LABEL: + { + bool bShowStaggeringControls = m_pParameter->CanAxisLabelsBeStaggered(); + ((SchAxisLabelTabPage&)rPage).ShowStaggeringControls( bShowStaggeringControls ); + break; + } + + case TP_ALIGNMENT: + break; + + + case TP_AXIS_POSITIONS: + { + AxisPositionsTabPage* pPage = dynamic_cast< AxisPositionsTabPage* >( &rPage ); + if(pPage) + { + pPage->SetNumFormatter( m_pNumberFormatter ); + if( m_pParameter->IsCrossingAxisIsCategoryAxis() ) + { + pPage->SetCrossingAxisIsCategoryAxis( m_pParameter->IsCrossingAxisIsCategoryAxis() ); + pPage->SetCategories( m_pParameter->GetCategories() ); + } + pPage->SupportAxisPositioning( m_pParameter->IsSupportingAxisPositioning() ); + } + } + break; + + case TP_SCALE: + { + ScaleTabPage* pScaleTabPage = dynamic_cast< ScaleTabPage* >( &rPage ); + if(pScaleTabPage) + { + pScaleTabPage->SetNumFormatter( m_pNumberFormatter ); + pScaleTabPage->ShowAxisOrigin( m_pParameter->ShowAxisOrigin() ); + } + } + break; + + case TP_DATA_DESCR: + { + DataLabelsTabPage* pLabelPage = dynamic_cast< DataLabelsTabPage* >( &rPage ); + if( pLabelPage ) + pLabelPage->SetNumberFormatter( m_pNumberFormatter ); + } + break; + + case RID_SVXPAGE_NUMBERFORMAT: + aSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const USHORT)SID_ATTR_NUMBERFORMAT_INFO)); + rPage.PageCreated(aSet); + break; + + case TP_YERRORBAR: + { + ErrorBarsTabPage * pTabPage = dynamic_cast< ErrorBarsTabPage * >( &rPage ); + OSL_ASSERT( pTabPage ); + if( pTabPage ) + { + pTabPage->SetAxisMinorStepWidthForErrorBarDecimals( m_fAxisMinorStepWidthForErrorBarDecimals ); + pTabPage->SetErrorBarType( ErrorBarResources::ERROR_BAR_Y ); + pTabPage->SetChartDocumentForRangeChoosing( m_pParameter->getDocument()); + } + break; + } + case TP_OPTIONS: + { + SchOptionTabPage* pTabPage = dynamic_cast< SchOptionTabPage* >( &rPage ); + if( pTabPage && m_pParameter ) + pTabPage->Init( m_pParameter->ProvidesSecondaryYAxis(), m_pParameter->ProvidesOverlapAndGapWidth(), + m_pParameter->ProvidesBarConnectors() ); + break; + } + } +} + +IMPL_LINK( SchAttribTabDlg, OKPressed, void * , EMPTYARG ) +{ + m_bOKPressed = true; + return m_aOriginalOKClickHdl.Call( this ); +} + +bool SchAttribTabDlg::DialogWasClosedWithOK() const +{ + return m_bOKPressed; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_ObjectProperties.src b/chart2/source/controller/dialogs/dlg_ObjectProperties.src new file mode 100644 index 000000000000..487a5d59271c --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_ObjectProperties.src @@ -0,0 +1,42 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ObjectProperties.src,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +TabDialog DLG_OBJECT_PROPERTIES +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + TabControl 1 + { + OutputSize = TRUE ; + Pos = MAP_APPFONT ( 3 , 3 ) ; + }; +}; diff --git a/chart2/source/controller/dialogs/dlg_View3D.cxx b/chart2/source/controller/dialogs/dlg_View3D.cxx new file mode 100644 index 000000000000..75a7917ad3dc --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_View3D.cxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_View3D.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_View3D.hxx" +#include "dlg_View3D.hrc" +#include "Strings.hrc" +#include "TabPages.hrc" +#include "ResId.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "tp_3D_SceneGeometry.hxx" +#include "tp_3D_SceneAppearance.hxx" +#include "tp_3D_SceneIllumination.hxx" +#include "ChartModelHelper.hxx" +#include "macros.hxx" +#include "ControllerLockGuard.hxx" +#include <com/sun/star/beans/XPropertySet.hpp> + +// for RET_OK +#include <vcl/msgbox.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +//----------------------------------------------------------------------------- +//------------------------------------------------------------------- +//------------------------------------------------------------------- + +// static +USHORT View3DDialog::m_nLastPageId = 0; + +View3DDialog::View3DDialog(Window* pParent, const uno::Reference< frame::XModel > & xChartModel, XColorTable* pColorTable ) + : TabDialog(pParent,SchResId(DLG_3D_VIEW)) + , m_aTabControl(this,SchResId(TABCTRL)) + , m_aBtnOK(this,SchResId(BTN_OK)) + , m_aBtnCancel(this,SchResId(BTN_CANCEL)) + , m_aBtnHelp(this,SchResId(BTN_HELP)) + , m_pGeometry(0) + , m_pAppearance(0) + , m_pIllumination(0) + , m_aControllerLocker(xChartModel) +{ + FreeResource(); + + uno::Reference< beans::XPropertySet > xSceneProperties( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + m_pGeometry = new ThreeD_SceneGeometry_TabPage(&m_aTabControl,xSceneProperties,m_aControllerLocker); + m_pAppearance = new ThreeD_SceneAppearance_TabPage(&m_aTabControl,xChartModel,m_aControllerLocker); + m_pIllumination = new ThreeD_SceneIllumination_TabPage(&m_aTabControl,xSceneProperties,xChartModel,pColorTable); + + m_aTabControl.InsertPage( TP_3D_SCENEGEOMETRY, String(SchResId(STR_PAGE_PERSPECTIVE)) ); + m_aTabControl.InsertPage( TP_3D_SCENEAPPEARANCE, String(SchResId(STR_PAGE_APPEARANCE)) ); + m_aTabControl.InsertPage( TP_3D_SCENEILLUMINATION, String(SchResId(STR_PAGE_ILLUMINATION)) ); + + m_aTabControl.SetTabPage( TP_3D_SCENEGEOMETRY, m_pGeometry ); + m_aTabControl.SetTabPage( TP_3D_SCENEAPPEARANCE, m_pAppearance ); + m_aTabControl.SetTabPage( TP_3D_SCENEILLUMINATION, m_pIllumination ); + + m_aTabControl.SelectTabPage( m_nLastPageId ); +} + +View3DDialog::~View3DDialog() +{ + delete m_pGeometry; + delete m_pAppearance; + delete m_pIllumination; + + m_nLastPageId = m_aTabControl.GetCurPageId(); +} + +short View3DDialog::Execute() +{ + short nResult = TabDialog::Execute(); + if( nResult == RET_OK ) + { + if( m_pGeometry ) + m_pGeometry->commitPendingChanges(); + if( m_pAppearance ) + m_pAppearance->commitPendingChanges(); + if( m_pIllumination ) + m_pIllumination->commitPendingChanges(); + } + return nResult; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/dlg_View3D.hrc b/chart2/source/controller/dialogs/dlg_View3D.hrc new file mode 100644 index 000000000000..d91d075dd2c7 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_View3D.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_View3D.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +//position and size defines: +#define VIEW3D_PAGE_WIDTH 160 +#define VIEW3D_PAGE_HEIGHT 110 + +//resource ids: + +#define TABCTRL 1 + +#define BTN_OK 1 +#define BTN_CANCEL 2 +#define BTN_HELP 3 diff --git a/chart2/source/controller/dialogs/dlg_View3D.src b/chart2/source/controller/dialogs/dlg_View3D.src new file mode 100644 index 000000000000..96bff67ad945 --- /dev/null +++ b/chart2/source/controller/dialogs/dlg_View3D.src @@ -0,0 +1,51 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_View3D.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "dlg_View3D.hrc" +#include "SchSlotIds.hxx" +#include "CommonResources.hrc" + +TabDialog DLG_3D_VIEW +{ + HelpID = SID_3D_VIEW ; + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Size = MAP_APPFONT ( VIEW3D_PAGE_WIDTH , VIEW3D_PAGE_HEIGHT+40 ) ; + Text [ en-US ] = "3D View" ; + TabControl TABCTRL + { + OutputSize = TRUE ; + Pos = MAP_APPFONT ( 3 , 3 ) ; + Size = MAP_APPFONT ( VIEW3D_PAGE_WIDTH , VIEW3D_PAGE_HEIGHT ) ; + }; + BUTTONS_OK_CANCEL_HELP_STACKED(VIEW3D_PAGE_HEIGHT+3) +}; + diff --git a/chart2/source/controller/dialogs/hidother.src b/chart2/source/controller/dialogs/hidother.src new file mode 100644 index 000000000000..4f409d14094b --- /dev/null +++ b/chart2/source/controller/dialogs/hidother.src @@ -0,0 +1,119 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: hidother.src,v $ + * $Revision: 1.7.56.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "SchSlotIds.hxx" + +hidspecial SID_INSERT_GRIDS {HelpId= SID_INSERT_GRIDS; }; + +hidspecial HID_SCH_CB_XAXIS {HelpId= HID_SCH_CB_XAXIS; }; +hidspecial HID_SCH_CB_YAXIS {HelpId= HID_SCH_CB_YAXIS; }; +hidspecial HID_SCH_CB_ZAXIS {HelpId= HID_SCH_CB_ZAXIS; }; +hidspecial HID_SCH_CB_SECONDARY_XAXIS {HelpId= HID_SCH_CB_SECONDARY_XAXIS; }; +hidspecial HID_SCH_CB_SECONDARY_YAXIS {HelpId= HID_SCH_CB_SECONDARY_YAXIS; }; +hidspecial HID_SCH_CB_SECONDARY_ZAXIS {HelpId= HID_SCH_CB_SECONDARY_ZAXIS; }; + +hidspecial HID_SCH_CB_XGRID {HelpId= HID_SCH_CB_XGRID; }; +hidspecial HID_SCH_CB_YGRID {HelpId= HID_SCH_CB_YGRID; }; +hidspecial HID_SCH_CB_ZGRID {HelpId= HID_SCH_CB_ZGRID; }; +hidspecial HID_SCH_CB_SECONDARY_XGRID {HelpId= HID_SCH_CB_SECONDARY_XGRID; }; +hidspecial HID_SCH_CB_SECONDARY_YGRID {HelpId= HID_SCH_CB_SECONDARY_YGRID; }; +hidspecial HID_SCH_CB_SECONDARY_ZGRID {HelpId= HID_SCH_CB_SECONDARY_ZGRID; }; + +hidspecial HID_SCH_CT_INDICATE {HelpId= HID_SCH_CT_INDICATE; }; + +hidspecial HID_SCH_STATISTIK_MEANVALUE {HelpId= HID_SCH_STATISTIK_MEANVALUE; }; +hidspecial HID_SCH_STATISTIK_NO_ERROR {HelpId= HID_SCH_STATISTIK_NO_ERROR; }; +hidspecial HID_SCH_STATISTIK_VARIANT {HelpId= HID_SCH_STATISTIK_VARIANT; }; +hidspecial HID_SCH_STATISTIK_SIGMA {HelpId= HID_SCH_STATISTIK_SIGMA; }; +hidspecial HID_SCH_STATISTIK_PERCENT {HelpId= HID_SCH_STATISTIK_PERCENT; }; +hidspecial HID_SCH_STATISTIK_FUNCTION {HelpId= HID_SCH_STATISTIK_FUNCTION; }; +hidspecial HID_SCH_STATISTIK_RANGE {HelpId= HID_SCH_STATISTIK_RANGE; }; +hidspecial HID_SCH_STATISTIK_FUNCTION_LB {HelpId= HID_SCH_STATISTIK_FUNCTION_LB; }; +hidspecial HID_SCH_STATISTIK_POSITIVE_VALUE {HelpId= HID_SCH_STATISTIK_POSITIVE_VALUE; }; +hidspecial HID_SCH_STATISTIK_POSITIVE_RANGE {HelpId= HID_SCH_STATISTIK_POSITIVE_RANGE; }; +hidspecial HID_SCH_STATISTIK_POSITIVE_RANGE_CHOOSER {HelpId= HID_SCH_STATISTIK_POSITIVE_RANGE_CHOOSER; }; +hidspecial HID_SCH_STATISTIK_NEGATIVE_VALUE {HelpId= HID_SCH_STATISTIK_NEGATIVE_VALUE; }; +hidspecial HID_SCH_STATISTIK_NEGATIVE_RANGE {HelpId= HID_SCH_STATISTIK_NEGATIVE_RANGE; }; +hidspecial HID_SCH_STATISTIK_NEGATIVE_RANGE_CHOOSER {HelpId= HID_SCH_STATISTIK_NEGATIVE_RANGE_CHOOSER; }; +hidspecial HID_SCH_STATISTIK_SAME_FOR_BOTH {HelpId= HID_SCH_STATISTIK_SAME_FOR_BOTH; }; +hidspecial HID_SCH_STATISTIK_SHOW_BOTH {HelpId= HID_SCH_STATISTIK_SHOW_BOTH; }; +hidspecial HID_SCH_STATISTIK_SHOW_POSITIVE {HelpId= HID_SCH_STATISTIK_SHOW_POSITIVE; }; +hidspecial HID_SCH_STATISTIK_SHOW_NEGATIVE {HelpId= HID_SCH_STATISTIK_SHOW_NEGATIVE; }; +hidspecial HID_SCH_STATISTIK_BIGERROR {HelpId= HID_SCH_STATISTIK_BIGERROR; }; +hidspecial HID_SCH_STATISTIK_CONSTERROR {HelpId= HID_SCH_STATISTIK_CONSTERROR; }; +hidspecial HID_SCH_STATISTIK_PERCENT_VALUE {HelpId= HID_SCH_STATISTIK_PERCENT_VALUE; }; +hidspecial HID_SCH_STATISTIK_BIGERROR_VALUE {HelpId= HID_SCH_STATISTIK_BIGERROR_VALUE; }; +hidspecial HID_SCH_STATISTIK_PLUS_VALUE {HelpId= HID_SCH_STATISTIK_PLUS_VALUE; }; +hidspecial HID_SCH_STATISTIK_MINUS_VALUE {HelpId= HID_SCH_STATISTIK_MINUS_VALUE; }; + +hidspecial HID_SCH_LEGEND_SHOW {HelpId= HID_SCH_LEGEND_SHOW; }; +hidspecial HID_SCH_LEGEND_POS_LEFT {HelpId= HID_SCH_LEGEND_POS_LEFT; }; +hidspecial HID_SCH_LEGEND_POS_TOP {HelpId= HID_SCH_LEGEND_POS_TOP; }; +hidspecial HID_SCH_LEGEND_POS_RIGHT {HelpId= HID_SCH_LEGEND_POS_RIGHT; }; +hidspecial HID_SCH_LEGEND_POS_BOTTOM {HelpId= HID_SCH_LEGEND_POS_BOTTOM; }; + +hidspecial HID_SCH_DATALABEL_VALUE {HelpId= HID_SCH_DATALABEL_VALUE; }; +hidspecial HID_SCH_DATALABEL_NUMBER {HelpId= HID_SCH_DATALABEL_NUMBER; }; +hidspecial HID_SCH_DATALABEL_PERCENT {HelpId= HID_SCH_DATALABEL_PERCENT; }; +hidspecial HID_SCH_DATALABEL_TEXT {HelpId= HID_SCH_DATALABEL_TEXT; }; +hidspecial HID_SCH_DATALABEL_SYMBOL {HelpId= HID_SCH_DATALABEL_SYMBOL; }; +hidspecial HID_SCH_PB_NUMBERFORMAT {HelpId= HID_SCH_PB_NUMBERFORMAT; }; +hidspecial HID_SCH_PB_PERCENT_NUMBERFORMAT {HelpId= HID_SCH_PB_PERCENT_NUMBERFORMAT; }; +hidspecial HID_SCH_DATALABEL_SEPARATOR {HelpId= HID_SCH_DATALABEL_SEPARATOR; }; +hidspecial HID_SCH_DATALABEL_PLACEMENT {HelpId= HID_SCH_DATALABEL_PLACEMENT; }; +hidspecial HID_SCH_TEXTDIRECTION {HelpId= HID_SCH_TEXTDIRECTION; }; +hidspecial HID_SCH_TEXTDIRECTION_TITLE {HelpId= HID_SCH_TEXTDIRECTION_TITLE; }; +hidspecial HID_SCH_TEXTDIRECTION_EQUATION {HelpId= HID_SCH_TEXTDIRECTION_EQUATION; }; +hidspecial HID_SCH_DATALABEL_ROTATION_KNOB {HelpId= HID_SCH_DATALABEL_ROTATION_KNOB; }; +hidspecial HID_SCH_DATALABEL_ROTATION_EDIT {HelpId= HID_SCH_DATALABEL_ROTATION_EDIT; }; + +hidspecial HID_SCH_TITLE_MAIN {HelpId= HID_SCH_TITLE_MAIN; }; +hidspecial HID_SCH_TITLE_SUB {HelpId= HID_SCH_TITLE_SUB; }; +hidspecial HID_SCH_TITLE_X {HelpId= HID_SCH_TITLE_X; }; +hidspecial HID_SCH_TITLE_Y {HelpId= HID_SCH_TITLE_Y; }; +hidspecial HID_SCH_TITLE_Z {HelpId= HID_SCH_TITLE_Z; }; +hidspecial HID_SCH_TITLE_SECONDARY_X {HelpId= HID_SCH_TITLE_SECONDARY_X; }; +hidspecial HID_SCH_TITLE_SECONDARY_Y {HelpId= HID_SCH_TITLE_SECONDARY_Y; }; + +hidspecial HID_SCH_NUM_OF_LINES {HelpId= HID_SCH_NUM_OF_LINES; }; + +hidspecial HID_SCH_WIZARD_ROADMAP {HelpId= HID_SCH_WIZARD_ROADMAP; }; +hidspecial HID_SCH_WIN_DOCUMENT {HelpId= HID_SCH_WIN_DOCUMENT; }; +hidspecial HID_SCH_DATA_SERIES_LABEL {HelpId= HID_SCH_DATA_SERIES_LABEL; }; + +hidspecial HID_SCH_STARTING_ANGLE_DIAL {HelpId= HID_SCH_STARTING_ANGLE_DIAL; }; + +hidspecial HID_SCH_TRENDLINE_RB_NONE {HelpId= HID_SCH_TRENDLINE_RB_NONE; }; +hidspecial HID_SCH_TRENDLINE_RB_LINEAR {HelpId= HID_SCH_TRENDLINE_RB_LINEAR; }; +hidspecial HID_SCH_TRENDLINE_RB_LOGARITHMIC {HelpId= HID_SCH_TRENDLINE_RB_LOGARITHMIC; }; +hidspecial HID_SCH_TRENDLINE_RB_EXPONENTIAL {HelpId= HID_SCH_TRENDLINE_RB_EXPONENTIAL; }; +hidspecial HID_SCH_TRENDLINE_RB_POWER {HelpId= HID_SCH_TRENDLINE_RB_POWER; }; +hidspecial HID_SCH_TRENDLINE_SHOW_EQUATION {HelpId= HID_SCH_TRENDLINE_SHOW_EQUATION; }; +hidspecial HID_SCH_TRENDLINE_SHOW_R_SQUARED {HelpId= HID_SCH_TRENDLINE_SHOW_R_SQUARED; }; diff --git a/chart2/source/controller/dialogs/makefile.mk b/chart2/source/controller/dialogs/makefile.mk new file mode 100644 index 000000000000..6b64f2cae8db --- /dev/null +++ b/chart2/source/controller/dialogs/makefile.mk @@ -0,0 +1,205 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.19.72.1 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcdialogs + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE +GEN_HID_OTHER=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# i26518 the gcc-3.0.4 requires to enhance the template-depth +# this seems to be a compiler issue, so we recommend not to use 3.0.x anymore +.IF "$(COM)"=="GCC" + CFLAGS+=-ftemplate-depth-128 +.ENDIF + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES= \ + $(SLO)$/ObjectNameProvider.obj \ + $(SLO)$/TimerTriggeredControllerLock.obj \ + $(SLO)$/ChangingResource.obj \ + $(SLO)$/DataBrowser.obj \ + $(SLO)$/DataBrowserModel.obj \ + $(SLO)$/DialogModel.obj \ + $(SLO)$/TitleDialogData.obj \ + $(SLO)$/res_Titles.obj \ + $(SLO)$/res_TextSeparator.obj \ + $(SLO)$/res_ErrorBar.obj \ + $(SLO)$/res_Trendline.obj \ + $(SLO)$/res_BarGeometry.obj \ + $(SLO)$/res_LegendPosition.obj \ + $(SLO)$/res_DataLabel.obj \ + $(SLO)$/ChartTypeDialogController.obj \ + $(SLO)$/tp_ChartType.obj \ + $(SLO)$/tp_RangeChooser.obj \ + $(SLO)$/tp_Wizard_TitlesAndObjects.obj \ + $(SLO)$/tp_Location.obj \ + $(SLO)$/tp_AxisLabel.obj \ + $(SLO)$/tp_AxisPositions.obj \ + $(SLO)$/tp_DataLabel.obj \ + $(SLO)$/tp_DataSource.obj \ + $(SLO)$/tp_DataSourceControls.obj \ + $(SLO)$/tp_LegendPosition.obj \ + $(SLO)$/tp_PointGeometry.obj \ + $(SLO)$/tp_Scale.obj \ + $(SLO)$/tp_Trendline.obj \ + $(SLO)$/tp_ErrorBars.obj \ + $(SLO)$/tp_SeriesToAxis.obj \ + $(SLO)$/tp_TitleRotation.obj \ + $(SLO)$/tp_3D_SceneGeometry.obj \ + $(SLO)$/tp_3D_SceneAppearance.obj \ + $(SLO)$/tp_3D_SceneIllumination.obj \ + $(SLO)$/tp_PolarOptions.obj \ + $(SLO)$/dlg_ObjectProperties.obj \ + $(SLO)$/dlg_DataEditor.obj \ + $(SLO)$/dlg_DataSource.obj \ + $(SLO)$/dlg_View3D.obj \ + $(SLO)$/dlg_InsertAxis_Grid.obj \ + $(SLO)$/dlg_InsertDataLabel.obj \ + $(SLO)$/dlg_InsertLegend.obj \ + $(SLO)$/dlg_InsertTrendline.obj \ + $(SLO)$/dlg_InsertErrorBars.obj \ + $(SLO)$/dlg_InsertTitle.obj \ + $(SLO)$/dlg_CreationWizard.obj \ + $(SLO)$/dlg_CreationWizard_UNO.obj \ + $(SLO)$/dlg_ChartType_UNO.obj \ + $(SLO)$/dlg_ChartType.obj \ + $(SLO)$/dlg_NumberFormat.obj \ + $(SLO)$/RangeSelectionButton.obj \ + $(SLO)$/RangeSelectionHelper.obj \ + $(SLO)$/RangeSelectionListener.obj \ + $(SLO)$/RangeEdit.obj \ + $(SLO)$/TextDirectionListBox.obj + +# --- Resources --------------------------------------------------------------- + +# Bitmaps.src +# Bitmaps_HC.src + + +SRC1FILES= \ + res_TextSeparator.src \ + res_BarGeometry.src \ + tp_ChartType.src \ + tp_RangeChooser.src \ + tp_Wizard_TitlesAndObjects.src \ + tp_Location.src \ + tp_AxisLabel.src \ + tp_AxisPositions.src \ + tp_DataLabel.src \ + tp_DataSource.src \ + tp_LegendPosition.src \ + tp_PointGeometry.src \ + tp_Scale.src \ + tp_Trendline.src \ + tp_ErrorBars.src \ + tp_SeriesToAxis.src \ + tp_TitleRotation.src \ + tp_3D_SceneGeometry.src \ + tp_3D_SceneAppearance.src \ + tp_3D_SceneIllumination.src \ + tp_PolarOptions.src \ + dlg_ObjectProperties.src \ + Strings_Statistic.src \ + Strings_Scale.src \ + Strings_ChartTypes.src \ + Strings_AdditionalControls.src \ + Strings.src \ + Bitmaps.src \ + Bitmaps_HC.src \ + dlg_DataEditor.src \ + dlg_DataSource.src \ + dlg_View3D.src \ + dlg_InsertAxis_Grid.src \ + dlg_InsertDataLabel.src \ + dlg_InsertLegend.src \ + dlg_InsertTrendline.src \ + dlg_InsertErrorBars.src \ + dlg_InsertTitle.src \ + dlg_ChartType.src \ + dlg_CreationWizard.src + +SRS1NAME=$(TARGET) + +# --- Targets ----------------------------------------------------------------- +LOCALIZE_ME=res_DataLabel_tmpl.hrc res_LegendPosition_tmpl.hrc res_Trendline_tmpl.hrc res_ErrorBar_tmpl.hrc res_Titlesx_tmpl.hrc res_SecondaryAxisCheckBoxes_tmpl.hrc +.INCLUDE: target.mk +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_DataLabel.hrc +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_LegendPosition.hrc +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_Trendline.hrc +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_ErrorBar.hrc +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_Titlesx.hrc +$(SRS)$/chcdialogs.srs: $(INCCOM)$/res_SecondaryAxisCheckBoxes.hrc + +#dependencies: + +$(SRS)$/chcdialogs.srs: \ + Bitmaps.hrc \ + Bitmaps_HC.hrc \ + CommonResources.hrc \ + ResourceIds.hrc \ + ..$/..$/inc$/Strings.hrc \ + TabPages.hrc \ + dlg_CreationWizard.hrc \ + dlg_DataSource.hrc \ + dlg_InsertAxis_Grid.hrc \ + dlg_InsertDataLabel.hrc \ + dlg_InsertLegend.hrc \ + dlg_InsertTrendline.hrc \ + dlg_InsertErrorBars.hrc \ + dlg_InsertTitle.hrc \ + dlg_View3D.hrc \ + res_Titles.hrc \ + tp_3D_SceneAppearance.hrc \ + tp_3D_SceneGeometry.hrc \ + tp_3D_SceneIllumination.hrc \ + tp_PolarOptions.hrc \ + tp_ChartType.hrc \ + tp_DataSource.hrc \ + tp_Location.hrc \ + tp_RangeChooser.hrc \ + tp_Wizard_TitlesAndObjects.hrc + +# res_DataLabel.hrc \ +# res_LegendPosition.hrc \ +# res_Statistic.hrc \ + +#$(SRS)$/chcdialogs.srs: $(SOLARINCDIR)$/svx$/globlmn.hrc + diff --git a/chart2/source/controller/dialogs/res_BarGeometry.cxx b/chart2/source/controller/dialogs/res_BarGeometry.cxx new file mode 100644 index 000000000000..a98ce3833e56 --- /dev/null +++ b/chart2/source/controller/dialogs/res_BarGeometry.cxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_BarGeometry.cxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_BarGeometry.hxx" +#include "ResourceIds.hrc" +#include "Strings.hrc" +#include "ResId.hxx" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +BarGeometryResources::BarGeometryResources( Window* pWindow ) + : m_aFT_Geometry( pWindow, pWindow->GetStyle() ) + , m_aLB_Geometry( pWindow, SchResId( LB_BAR_GEOMETRY ) ) +{ + m_aFT_Geometry.SetText( String( SchResId( STR_BAR_GEOMETRY )) ); + m_aFT_Geometry.SetSizePixel( m_aFT_Geometry.CalcMinimumSize() ); +} +void BarGeometryResources::SetPosPixel( const Point& rPosition ) +{ + Window* pWindow( m_aFT_Geometry.GetParent() ); + + Size aDistanceSize( 2,2 ); + if( pWindow ) + aDistanceSize = Size( pWindow->LogicToPixel( Size(0,RSC_SP_CTRL_DESC_Y), MapMode(MAP_APPFONT) ) ); + + m_aFT_Geometry.SetPosPixel( rPosition ); + m_aLB_Geometry.SetPosPixel( Point( rPosition.X()+aDistanceSize.Width(), rPosition.Y()+m_aFT_Geometry.GetSizePixel().Height()+aDistanceSize.Height()) ); +} +Size BarGeometryResources::GetSizePixel() const +{ + long nHeight = m_aLB_Geometry.GetPosPixel().Y() + - m_aFT_Geometry.GetPosPixel().Y(); + nHeight += m_aLB_Geometry.GetSizePixel().Height(); + + long nWidth = m_aLB_Geometry.GetSizePixel().Width(); + if( nWidth < m_aFT_Geometry.GetSizePixel().Width() ) + nWidth = m_aFT_Geometry.GetSizePixel().Width(); + + return Size( nHeight, nWidth ); +} +BarGeometryResources::~BarGeometryResources() +{ +} + +void BarGeometryResources::SetSelectHdl( const Link& rLink ) +{ + m_aLB_Geometry.SetSelectHdl( rLink ); +} + +void BarGeometryResources::Show( bool bShow ) +{ + m_aFT_Geometry.Show( bShow ); + m_aLB_Geometry.Show( bShow ); +} +void BarGeometryResources::Enable( bool bEnable ) +{ + m_aFT_Geometry.Enable( bEnable ); + m_aLB_Geometry.Enable( bEnable ); +} + +USHORT BarGeometryResources::GetSelectEntryCount() const +{ + return m_aLB_Geometry.GetSelectEntryCount(); +} +USHORT BarGeometryResources::GetSelectEntryPos() const +{ + return m_aLB_Geometry.GetSelectEntryPos(); +} +void BarGeometryResources::SelectEntryPos( USHORT nPos ) +{ + if( nPos < m_aLB_Geometry.GetEntryCount() ) + m_aLB_Geometry.SelectEntryPos( nPos ); +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/res_BarGeometry.hxx b/chart2/source/controller/dialogs/res_BarGeometry.hxx new file mode 100644 index 000000000000..8bf2d81259a3 --- /dev/null +++ b/chart2/source/controller/dialogs/res_BarGeometry.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_BarGeometry.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RES_BARGEOMETRY_HXX +#define _CHART2_RES_BARGEOMETRY_HXX + +// header for class FixedText +#include <vcl/fixed.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class BarGeometryResources +{ +public: + BarGeometryResources( Window* pParent ); + virtual ~BarGeometryResources(); + + void SetPosPixel( const Point& rPosition ); + Size GetSizePixel() const; + + void Show( bool bShow ); + void Enable( bool bEnable ); + + USHORT GetSelectEntryCount() const; + USHORT GetSelectEntryPos() const; + void SelectEntryPos( USHORT nPos ); + + void SetSelectHdl( const Link& rLink ); + +private: + FixedText m_aFT_Geometry; + ListBox m_aLB_Geometry; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/res_BarGeometry.src b/chart2/source/controller/dialogs/res_BarGeometry.src new file mode 100644 index 000000000000..a36087b2039d --- /dev/null +++ b/chart2/source/controller/dialogs/res_BarGeometry.src @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_BarGeometry.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" +#include "HelpIds.hrc" + +ListBox LB_BAR_GEOMETRY +{ + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( 6 , 17 ) ; + Size = MAP_APPFONT ( 89 , 38 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=FALSE; + DDExtraWidth = TRUE ; + HelpID = HID_SCH_LB_BAR_GEOMETRY; + + StringList [ en-US ] = + { + "Box" ; + "Cylinder" ; + "Cone" ; + "Pyramid" ; + }; +}; diff --git a/chart2/source/controller/dialogs/res_DataLabel.cxx b/chart2/source/controller/dialogs/res_DataLabel.cxx new file mode 100644 index 000000000000..c6129629a51a --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataLabel.cxx @@ -0,0 +1,422 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_DataLabel.cxx,v $ + * $Revision: 1.5.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_DataLabel.hxx" +#include "res_DataLabel_IDs.hrc" + +#include "Strings.hrc" +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "dlg_NumberFormat.hxx" + +// header for class SvxNumberInfoItem +#include <svx/numinf.hxx> +#include <svtools/eitem.hxx> +// for SfxUInt32Item +#include <svtools/intitem.hxx> +// header for class SfxStringItem +#include <svtools/stritem.hxx> +//SfxIntegerListItem +#include <svtools/ilstitem.hxx> +#include <svx/eeitem.hxx> +#include <svx/frmdiritem.hxx> + +// header for define RET_OK +#include <vcl/msgbox.hxx> +#include <svx/svxids.hrc> +// header for SvNumberFormatter +#include <svtools/zforlist.hxx> +#include <svtools/controldims.hrc> + + +//............................................................................. +namespace chart +{ +//............................................................................. + +namespace +{ + +bool lcl_ReadNumberFormatFromItemSet( const SfxItemSet& rSet, USHORT nValueWhich, USHORT nSourceFormatWhich, ULONG& rnFormatKeyOut, bool& rbSourceFormatOut, bool& rbSourceFormatMixedStateOut ) +{ + bool bSet = false; + const SfxPoolItem *pItem1 = NULL; + if( rSet.GetItemState( nValueWhich, TRUE, &pItem1 ) == SFX_ITEM_SET ) + { + const SfxUInt32Item * pNumItem = dynamic_cast< const SfxUInt32Item * >( pItem1 ); + if( pNumItem ) + { + rnFormatKeyOut = pNumItem->GetValue(); + bSet = true; + } + } + + rbSourceFormatMixedStateOut=true; + const SfxPoolItem *pItem2 = NULL; + if( rSet.GetItemState( nSourceFormatWhich, TRUE, &pItem2 ) == SFX_ITEM_SET ) + { + const SfxBoolItem * pBoolItem = dynamic_cast< const SfxBoolItem * >( pItem2 ); + if( pBoolItem ) + { + rbSourceFormatOut = pBoolItem->GetValue(); + rbSourceFormatMixedStateOut=false; + } + } + return bSet; +} + +void lcl_setBoolItemToCheckBox( const SfxItemSet& rInAttrs, USHORT nWhichId, CheckBox& rCheckbox ) +{ + rCheckbox.EnableTriState( FALSE ); + + const SfxPoolItem *pPoolItem = NULL; + if( rInAttrs.GetItemState(nWhichId, TRUE, &pPoolItem) == SFX_ITEM_SET ) + rCheckbox.Check( ((const SfxBoolItem*)pPoolItem)->GetValue() ); + else + { + rCheckbox.EnableTriState( TRUE ); + rCheckbox.SetState( STATE_DONTKNOW ); + } +} + +}//end anonymous namespace + +DataLabelResources::DataLabelResources( Window* pWindow, const SfxItemSet& rInAttrs ) + : m_aCBNumber(pWindow, SchResId(CB_VALUE_AS_NUMBER)), + m_aPB_NumberFormatForValue(pWindow, SchResId(PB_NUMBERFORMAT)), + m_aCBPercent(pWindow, SchResId(CB_VALUE_AS_PERCENTAGE)), + m_aPB_NumberFormatForPercent(pWindow, SchResId(PB_PERCENT_NUMBERFORMAT)), + m_aCBCategory(pWindow, SchResId(CB_CATEGORY)), + m_aCBSymbol(pWindow, SchResId(CB_SYMBOL)), + m_aSeparatorResources(pWindow), + m_aFT_LabelPlacement(pWindow, SchResId(FT_LABEL_PLACEMENT)), + m_aLB_LabelPlacement(pWindow, SchResId(LB_LABEL_PLACEMENT)), + m_aFL_Rotate(pWindow, SchResId(FL_LABEL_ROTATE)), + m_aDC_Dial(pWindow, SchResId(CT_LABEL_DIAL)), + m_aFT_Degrees(pWindow, SchResId(FT_LABEL_DEGREES)), + m_aNF_Degrees(pWindow, SchResId(NF_LABEL_DEGREES)), + m_aFT_TextDirection(pWindow, SchResId(FT_LABEL_TEXTDIR)), + m_aLB_TextDirection(pWindow, SchResId(LB_LABEL_TEXTDIR), &m_aFT_TextDirection), + m_pNumberFormatter(0), + m_bNumberFormatMixedState(true), + m_bPercentFormatMixedState(true), + m_nNumberFormatForValue(0), + m_nNumberFormatForPercent(11), + m_bSourceFormatMixedState(true), + m_bPercentSourceMixedState(true), + m_bSourceFormatForValue(true), + m_bSourceFormatForPercent(true), + m_pWindow(pWindow), + m_pPool(rInAttrs.GetPool()) +{ + //fill label placement list + std::map< sal_Int32, XubString > aPlacementToStringMap; + for( sal_Int32 nEnum=0; nEnum<m_aLB_LabelPlacement.GetEntryCount(); ++nEnum ) + aPlacementToStringMap[nEnum]=m_aLB_LabelPlacement.GetEntry(static_cast<USHORT>(nEnum)); + + ::com::sun::star::uno::Sequence < sal_Int32 > aAvailabelPlacementList; + const SfxPoolItem *pPoolItem = NULL; + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS, TRUE, &pPoolItem) == SFX_ITEM_SET ) + aAvailabelPlacementList =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); + + m_aLB_LabelPlacement.Clear(); + for( sal_Int32 nN=0; nN<aAvailabelPlacementList.getLength(); ++nN ) + { + USHORT nListBoxPos = static_cast<USHORT>( nN ); + sal_Int32 nPlacement = aAvailabelPlacementList[nN]; + m_aPlacementToListBoxMap[nPlacement]=nListBoxPos; + m_aListBoxToPlacementMap[nListBoxPos]=nPlacement; + m_aLB_LabelPlacement.InsertEntry( aPlacementToStringMap[nPlacement] ); + } + m_aLB_LabelPlacement.SetDropDownLineCount(m_aLB_LabelPlacement.GetEntryCount()); + + //replace&resize push buttons and resize checkboxes + Size aControlDistance( pWindow->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) ); + long nPBWidth = ::std::max( m_aPB_NumberFormatForPercent.CalcMinimumSize().getWidth(), m_aPB_NumberFormatForValue.CalcMinimumSize().getWidth() ) + + 20; //the min with is to small to fit, hm... so add alittle + long nCBXWidth = ::std::max( m_aCBNumber.CalcMinimumSize().getWidth(), m_aCBPercent.CalcMinimumSize().getWidth() ); + long nNewPBXPos = m_aCBNumber.GetPosPixel().X() + nCBXWidth + aControlDistance.Width(); + long nPageWidth = pWindow->LogicToPixel( Size(260,185), MapMode(MAP_APPFONT) ).getWidth(); + if( nNewPBXPos + nPBWidth > nPageWidth ) + { + if( nPBWidth > nPageWidth/2 ) + nPBWidth = nPageWidth/2; + nNewPBXPos = nPageWidth-nPBWidth; + nCBXWidth = nPageWidth-m_aCBNumber.GetPosPixel().X()-nPBWidth-aControlDistance.Width(); + } + m_aPB_NumberFormatForValue.SetPosPixel( Point( nNewPBXPos, m_aPB_NumberFormatForValue.GetPosPixel().Y() ) ); + m_aPB_NumberFormatForPercent.SetPosPixel( Point( nNewPBXPos, m_aPB_NumberFormatForPercent.GetPosPixel().Y() ) ); + + Size aPBSize( m_aPB_NumberFormatForPercent.GetSizePixel() ); + aPBSize.setWidth( nPBWidth ); + m_aPB_NumberFormatForValue.SetSizePixel( aPBSize ); + m_aPB_NumberFormatForPercent.SetSizePixel( aPBSize ); + + Size aCBSize( m_aCBNumber.GetSizePixel() ); + aCBSize.setWidth(nCBXWidth); + m_aCBNumber.SetSizePixel( aCBSize ); + m_aCBPercent.SetSizePixel( aCBSize ); + + //place and align separator and label placement listboxes + Size aSize( m_aFT_LabelPlacement.GetSizePixel() ); + aSize.setWidth( m_aFT_LabelPlacement.CalcMinimumSize().getWidth() ); + m_aFT_LabelPlacement.SetSizePixel(aSize); + + long nWantedMinLeftBorder = m_aFT_LabelPlacement.GetPosPixel().X() + aSize.getWidth () + aControlDistance.Width(); + + m_aSeparatorResources.PositionBelowControl(m_aCBSymbol); + m_aSeparatorResources.AlignListBoxWidthAndXPos( nWantedMinLeftBorder, -1, m_aLB_LabelPlacement.CalcMinimumSize().getWidth() ); + m_aSeparatorResources.Show(true); + + aSize = m_aLB_LabelPlacement.GetSizePixel(); + aSize.setWidth( m_aSeparatorResources.GetCurrentListBoxSize().getWidth() ); + m_aLB_LabelPlacement.SetSizePixel(aSize); + m_aLB_LabelPlacement.SetPosPixel( Point( m_aSeparatorResources.GetCurrentListBoxPosition().X(), m_aLB_LabelPlacement.GetPosPixel().Y() ) ); + + //some click handler + m_aPB_NumberFormatForValue.SetClickHdl( LINK( this, DataLabelResources, NumberFormatDialogHdl ) ); + m_aPB_NumberFormatForPercent.SetClickHdl( LINK( this, DataLabelResources, NumberFormatDialogHdl ) ); + m_aCBNumber.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); + m_aCBPercent.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); + m_aCBCategory.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); + m_aCBSymbol.SetClickHdl( LINK( this, DataLabelResources, CheckHdl )); + + 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) == SFX_ITEM_SET ) + { + bool bForbidPercentValue = (static_cast< const SfxBoolItem & >( rInAttrs.Get( SCHATTR_DATADESCR_NO_PERCENTVALUE )).GetValue() ); + if( bForbidPercentValue ) + m_aCBPercent.Enable(false); + } + + m_aDC_Dial.SetLinkedField( &m_aNF_Degrees ); +} + +DataLabelResources::~DataLabelResources() +{ +} + +void DataLabelResources::SetNumberFormatter( SvNumberFormatter* pFormatter ) +{ + m_pNumberFormatter = pFormatter; +} + +IMPL_LINK( DataLabelResources, NumberFormatDialogHdl, PushButton *, pButton ) +{ + if( !m_pPool || !m_pNumberFormatter ) + { + DBG_ERROR("Missing item pool or number formatter"); + return 1; + } + + if( pButton == &m_aPB_NumberFormatForValue && !m_aCBNumber.IsChecked()) + m_aCBNumber.Check(); + else if( pButton == &m_aPB_NumberFormatForPercent && !m_aCBPercent.IsChecked()) + m_aCBPercent.Check(); + + SfxItemSet aNumberSet = NumberFormatDialog::CreateEmptyItemSetForNumberFormatDialog( *m_pPool ); + aNumberSet.Put (SvxNumberInfoItem( m_pNumberFormatter, (const USHORT)SID_ATTR_NUMBERFORMAT_INFO)); + + bool bPercent = ( pButton == &m_aPB_NumberFormatForPercent ); + + ULONG& 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; + + if(!rbMixedState) + aNumberSet.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, rnFormatKey )); + aNumberSet.Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, rUseSourceFormat )); + + NumberFormatDialog aDlg(m_pWindow, aNumberSet); + if( bPercent ) + aDlg.SetText( String( SchResId( STR_DLG_NUMBERFORMAT_FOR_PERCENTAGE_VALUE ) ) ); + if( RET_OK == aDlg.Execute() ) + { + const SfxItemSet* pResult = aDlg.GetOutputItemSet(); + if( pResult ) + { + bool bOldSource = rUseSourceFormat; + ULONG nOldFormat = rnFormatKey; + bool bOldMixedState = rbMixedState || rbSourceMixedState; + + rbMixedState = !lcl_ReadNumberFormatFromItemSet( *pResult, SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_SOURCE, rnFormatKey, rUseSourceFormat, rbSourceMixedState ); + + //todo this maybe can be removed when the numberformatter dialog does handle mixed state for source format correctly + if( bOldMixedState && bOldSource == rUseSourceFormat && nOldFormat == rnFormatKey ) + rbMixedState = rbSourceMixedState = true; + } + } + return 0; +} + +IMPL_LINK( DataLabelResources, CheckHdl, CheckBox*, pBox ) +{ + if( pBox ) + pBox->EnableTriState( FALSE ); + EnableControls(); + return 0; +} + +void DataLabelResources::EnableControls() +{ + m_aCBSymbol.Enable( m_aCBNumber.IsChecked() || (m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled()) || m_aCBCategory.IsChecked() ); + + //enable separator + { + long nNumberOfCheckedLabelParts = 0; + if( m_aCBNumber.IsChecked() ) + ++nNumberOfCheckedLabelParts; + if( m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled() ) + ++nNumberOfCheckedLabelParts; + if( m_aCBCategory.IsChecked() ) + ++nNumberOfCheckedLabelParts; + m_aSeparatorResources.Enable( nNumberOfCheckedLabelParts > 1 ); + bool bEnableTextDir = nNumberOfCheckedLabelParts > 0; + m_aFT_TextDirection.Enable( bEnableTextDir ); + m_aLB_TextDirection.Enable( bEnableTextDir ); + bool bEnablePlacement = nNumberOfCheckedLabelParts > 0 && m_aLB_LabelPlacement.GetEntryCount()>1; + m_aFT_LabelPlacement.Enable( bEnablePlacement ); + m_aLB_LabelPlacement.Enable( bEnablePlacement ); + } + + m_aPB_NumberFormatForValue.Enable( m_pNumberFormatter && m_aCBNumber.IsChecked() ); + m_aPB_NumberFormatForPercent.Enable( m_pNumberFormatter && m_aCBPercent.IsChecked() && m_aCBPercent.IsEnabled() ); + + bool bEnableRotation = ( m_aCBNumber.IsChecked() || m_aCBPercent.IsChecked() || m_aCBCategory.IsChecked() ); + m_aFL_Rotate.Enable( bEnableRotation ); + m_aDC_Dial.Enable( bEnableRotation ); + m_aFT_Degrees.Enable( bEnableRotation ); + m_aNF_Degrees.Enable( bEnableRotation ); +} + +BOOL DataLabelResources::FillItemSet( SfxItemSet& rOutAttrs ) const +{ + if( m_aCBNumber.IsChecked() ) + { + if( !m_bNumberFormatMixedState ) + rOutAttrs.Put( SfxUInt32Item( SID_ATTR_NUMBERFORMAT_VALUE, m_nNumberFormatForValue )); + if( !m_bSourceFormatMixedState ) + rOutAttrs.Put( SfxBoolItem( SID_ATTR_NUMBERFORMAT_SOURCE, m_bSourceFormatForValue )); + } + if( m_aCBPercent.IsChecked() ) + { + if( !m_bPercentFormatMixedState ) + rOutAttrs.Put( SfxUInt32Item( SCHATTR_PERCENT_NUMBERFORMAT_VALUE, m_nNumberFormatForPercent )); + if( !m_bPercentSourceMixedState ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, m_bSourceFormatForPercent )); + } + + if( m_aCBNumber.GetState()!= STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_NUMBER, m_aCBNumber.IsChecked() ) ); + if( m_aCBPercent.GetState()!= STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_PERCENTAGE, m_aCBPercent.IsChecked() ) ); + if( m_aCBCategory.GetState()!= STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_CATEGORY, m_aCBCategory.IsChecked() ) ); + if( m_aCBSymbol.GetState()!= STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_DATADESCR_SHOW_SYMBOL, m_aCBSymbol.IsChecked()) ); + + rOutAttrs.Put( SfxStringItem( SCHATTR_DATADESCR_SEPARATOR, m_aSeparatorResources.GetValue() ) ); + ::std::map< USHORT, sal_Int32 >::const_iterator aIt( m_aListBoxToPlacementMap.find(m_aLB_LabelPlacement.GetSelectEntryPos()) ); + if(aIt!=m_aListBoxToPlacementMap.end()) + { + sal_Int32 nValue = aIt->second; + rOutAttrs.Put( SfxInt32Item( SCHATTR_DATADESCR_PLACEMENT, nValue ) ); + } + + if( m_aLB_TextDirection.GetSelectEntryCount() > 0 ) + rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLB_TextDirection.GetSelectEntryValue() ) ); + + if( m_aDC_Dial.IsVisible() ) + { + sal_Int32 nDegrees = m_aDC_Dial.GetRotation(); + rOutAttrs.Put(SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); + } + + return TRUE; +} + +void DataLabelResources::Reset(const SfxItemSet& rInAttrs) +{ + // default state + m_aCBSymbol.Enable( FALSE ); + + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_NUMBER, m_aCBNumber ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_PERCENTAGE, m_aCBPercent ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_CATEGORY, m_aCBCategory ); + lcl_setBoolItemToCheckBox( rInAttrs, SCHATTR_DATADESCR_SHOW_SYMBOL, m_aCBSymbol ); + + 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 = NULL; + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_SEPARATOR, TRUE, &pPoolItem) == SFX_ITEM_SET ) + m_aSeparatorResources.SetValue( ((const SfxStringItem*)pPoolItem)->GetValue() ); + else + m_aSeparatorResources.SetDefault(); + + if( rInAttrs.GetItemState(SCHATTR_DATADESCR_PLACEMENT, TRUE, &pPoolItem) == SFX_ITEM_SET ) + { + sal_Int32 nPlacement = ((const SfxInt32Item*)pPoolItem)->GetValue(); + ::std::map< sal_Int32, USHORT >::const_iterator aIt( m_aPlacementToListBoxMap.find(nPlacement) ); + if(aIt!=m_aPlacementToListBoxMap.end()) + { + USHORT nPos = aIt->second; + m_aLB_LabelPlacement.SelectEntryPos( nPos ); + } + else + m_aLB_LabelPlacement.SetNoSelection(); + } + else + m_aLB_LabelPlacement.SetNoSelection(); + + if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + m_aLB_TextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); + + if( rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + sal_Int32 nDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + m_aDC_Dial.SetRotation( nDegrees ); + } + else + m_aDC_Dial.SetRotation( 0 ); + + EnableControls(); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/res_DataLabel.hxx b/chart2/source/controller/dialogs/res_DataLabel.hxx new file mode 100644 index 000000000000..e560eed9f573 --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataLabel.hxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_DataLabel.hxx,v $ + * $Revision: 1.5.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RES_DATALABEL_HXX +#define CHART2_RES_DATALABEL_HXX + +#include "res_TextSeparator.hxx" +// header for class CheckBox +#include <vcl/button.hxx> +// header for class SfxItemSet +#include <svtools/itemset.hxx> +#include "TextDirectionListBox.hxx" + +#include <svx/dialcontrol.hxx> + +class SvNumberFormatter; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class DataLabelResources +{ +public: + DataLabelResources( Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~DataLabelResources(); + + BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + void Reset(const SfxItemSet& rInAttrs); + + void SetNumberFormatter( SvNumberFormatter* pFormatter ); + +private: + CheckBox m_aCBNumber; + PushButton m_aPB_NumberFormatForValue; + CheckBox m_aCBPercent; + PushButton m_aPB_NumberFormatForPercent; + CheckBox m_aCBCategory; + CheckBox m_aCBSymbol; + + TextSeparatorResources m_aSeparatorResources; + + FixedText m_aFT_LabelPlacement; + ListBox m_aLB_LabelPlacement; + + FixedLine m_aFL_Rotate; + svx::DialControl m_aDC_Dial; + FixedText m_aFT_Degrees; + NumericField m_aNF_Degrees; + + FixedText m_aFT_TextDirection; + TextDirectionListBox m_aLB_TextDirection; + + ::std::map< sal_Int32, USHORT > m_aPlacementToListBoxMap; + ::std::map< USHORT, sal_Int32 > m_aListBoxToPlacementMap; + + SvNumberFormatter* m_pNumberFormatter; + bool m_bNumberFormatMixedState; + bool m_bPercentFormatMixedState; + ULONG m_nNumberFormatForValue; + ULONG m_nNumberFormatForPercent; + + bool m_bSourceFormatMixedState; + bool m_bPercentSourceMixedState; + bool m_bSourceFormatForValue; + bool m_bSourceFormatForPercent; + + Window* m_pWindow; + SfxItemPool* m_pPool; + + DECL_LINK(NumberFormatDialogHdl, PushButton * ); + DECL_LINK(CheckHdl, CheckBox* ); + void EnableControls(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/res_DataLabel_IDs.hrc b/chart2/source/controller/dialogs/res_DataLabel_IDs.hrc new file mode 100644 index 000000000000..31112bdc3340 --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataLabel_IDs.hrc @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_DataLabel_IDs.hrc,v $ + * $Revision: 1.5.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define CB_VALUE_AS_NUMBER 1 +#define CB_VALUE_AS_PERCENTAGE 2 +#define CB_CATEGORY 3 +#define CB_SYMBOL 4 + +#define PB_NUMBERFORMAT 20 +#define PB_PERCENT_NUMBERFORMAT 21 + +#define FT_LABEL_PLACEMENT 2 +#define LB_LABEL_PLACEMENT 2 + +#define FT_LABEL_TEXTDIR 31 +#define LB_LABEL_TEXTDIR 32 + +#define FL_LABEL_ROTATE 40 +#define CT_LABEL_DIAL 40 +#define FT_LABEL_DEGREES 40 +#define NF_LABEL_DEGREES 40 diff --git a/chart2/source/controller/dialogs/res_DataLabel_tmpl.hrc b/chart2/source/controller/dialogs/res_DataLabel_tmpl.hrc new file mode 100644 index 000000000000..bc21882dd841 --- /dev/null +++ b/chart2/source/controller/dialogs/res_DataLabel_tmpl.hrc @@ -0,0 +1,172 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_DataLabel_tmpl.hrc,v $ + * $Revision: 1.11.20.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RESOURCE_DATALABEL_HXX +#define _CHART2_RESOURCE_DATALABEL_HXX + +#include "HelpIds.hrc" +#include "res_DataLabel_IDs.hrc" + +#define WORKAROUND \ + StringList [ en-US ] = \ + { \ + "Best fit" ; \ + "Center" ; \ + "Above" ; \ + "Top left" ; \ + "Left" ; \ + "Bottom left" ; \ + "Below" ; \ + "Bottom right" ; \ + "Right" ; \ + "Top right" ; \ + "Inside" ; \ + "Outside" ; \ + "Near origin" ; \ + }; + + +#define RESOURCE_DATALABEL( xpos, ypos ) \ +CheckBox CB_VALUE_AS_NUMBER \ +{ \ + HelpID = HID_SCH_DATALABEL_VALUE; \ + Pos = MAP_APPFONT ( xpos , ypos ) ; \ + Size = MAP_APPFONT ( 136 , 10 ) ; \ + TabStop = TRUE ; \ + Text [ en-US ] = "Show value as ~number" ; \ +}; \ +PushButton PB_NUMBERFORMAT \ +{ \ + HelpID = HID_SCH_PB_NUMBERFORMAT; \ + TabStop = TRUE ; \ + Pos = MAP_APPFONT ( xpos+100 , ypos-3 ) ; \ + Size = MAP_APPFONT ( 100 , 14 ) ; \ + Text [ en-US ] = "Number ~format..." ; \ +}; \ +CheckBox CB_VALUE_AS_PERCENTAGE \ +{ \ + HelpID = HID_SCH_DATALABEL_PERCENT; \ + Pos = MAP_APPFONT ( xpos , ypos+17 ) ; \ + Size = MAP_APPFONT ( 136 , 10 ) ; \ + TabStop = TRUE ; \ + Text [ en-US ] = "Show value as ~percentage" ; \ +}; \ +PushButton PB_PERCENT_NUMBERFORMAT \ +{ \ + HelpID = HID_SCH_PB_PERCENT_NUMBERFORMAT; \ + TabStop = TRUE ; \ + Pos = MAP_APPFONT ( xpos+100 , ypos+17-3 ) ; \ + Size = MAP_APPFONT ( 100 , 14 ) ; \ + Text [ en-US ] = "Percentage f~ormat..." ; \ +}; \ +CheckBox CB_CATEGORY \ +{ \ + HelpID = HID_SCH_DATALABEL_TEXT; \ + Pos = MAP_APPFONT ( xpos , ypos+33 ); \ + Size = MAP_APPFONT ( 254 , 10 ); \ + TabStop = TRUE; \ + Text [ en-US ] = "Show ~category"; \ +}; \ +CheckBox CB_SYMBOL \ +{ \ + HelpID = HID_SCH_DATALABEL_SYMBOL; \ + Pos = MAP_APPFONT ( xpos , ypos+49 ) ; \ + Size = MAP_APPFONT ( 254 , 10 ) ; \ + TabStop = TRUE ; \ + Text [ en-US ] = "Show ~legend key" ; \ +}; \ +FixedText FT_LABEL_PLACEMENT \ +{ \ + Pos = MAP_APPFONT ( xpos , ypos+84 ) ; \ + Size = MAP_APPFONT ( 182 , 10 ) ; \ + TabStop = FALSE ; \ + Text [ en-US ] = "Place~ment"; \ +}; \ +ListBox LB_LABEL_PLACEMENT \ +{ \ + HelpID = HID_SCH_DATALABEL_PLACEMENT; \ + Border = TRUE ; \ + AutoHScroll = TRUE ; \ + Pos = MAP_APPFONT ( xpos+100 , ypos+82 ) ; \ + Size = MAP_APPFONT ( 89 , 12 ) ; \ + TabStop = TRUE ; \ + Group = TRUE ; \ + DropDown=TRUE; \ + DDExtraWidth = TRUE ; \ + WORKAROUND \ +}; \ +FixedLine FL_LABEL_ROTATE \ +{ \ + Pos = MAP_APPFONT ( xpos, ypos+103 ) ; \ + Size = MAP_APPFONT ( 248, 8 ) ; \ + Text [ en-US ] = "Rotate Text" ; \ +}; \ +Control CT_LABEL_DIAL \ +{ \ + HelpId = HID_SCH_DATALABEL_ROTATION_KNOB ; \ + Pos = MAP_APPFONT ( xpos+6 , ypos+116 ) ; \ + Size = MAP_APPFONT ( 43 , 43 ) ; \ + Text = "ABCD" ; \ +}; \ +FixedText FT_LABEL_DEGREES \ +{ \ + Pos = MAP_APPFONT ( xpos+87 , ypos+133 ) ; \ + Size = MAP_APPFONT ( 46, 8 ) ; \ + Text [ en-US ] = "~Degrees" ; \ +}; \ +NumericField NF_LABEL_DEGREES \ +{ \ + HelpId = HID_SCH_DATALABEL_ROTATION_EDIT ; \ + Pos = MAP_APPFONT ( xpos+55 , ypos+131 ) ; \ + Size = MAP_APPFONT ( 28 , 12 ) ; \ + Border = TRUE ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + Minimum = 0 ; \ + Maximum = 359 ; \ + SpinSize = 5 ; \ +}; \ +FixedText FT_LABEL_TEXTDIR \ +{ \ + Pos = MAP_APPFONT ( xpos , ypos+162 ) ; \ + Size = MAP_APPFONT ( 64 , 8 ) ; \ + Text [ en-US ] = "Te~xt direction" ; \ +}; \ +ListBox LB_LABEL_TEXTDIR \ +{ \ + HelpID = HID_SCH_TEXTDIRECTION; \ + Pos = MAP_APPFONT ( xpos+66 , ypos+160 ) ; \ + Size = MAP_APPFONT ( 170 , 100 ) ; \ + Border = TRUE; \ + TabStop = TRUE; \ + DropDown = TRUE; \ +}; + +#endif diff --git a/chart2/source/controller/dialogs/res_ErrorBar.cxx b/chart2/source/controller/dialogs/res_ErrorBar.cxx new file mode 100644 index 000000000000..73af56b5a4d0 --- /dev/null +++ b/chart2/source/controller/dialogs/res_ErrorBar.cxx @@ -0,0 +1,773 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_ErrorBar.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_ErrorBar.hxx" +#include "res_ErrorBar_IDs.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "RangeSelectionHelper.hxx" +// for RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR +#include "TabPageNotifiable.hxx" + +#include <rtl/math.hxx> +#include <vcl/dialog.hxx> +#include <svtools/stritem.hxx> + +using namespace ::com::sun::star; + +namespace +{ +void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) +{ + if( pDialog ) + { + pDialog->Show( bEnable ? FALSE : TRUE ); + pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + } +} + +sal_uInt16 lcl_getLbEntryPosByErrorKind( SvxChartKindError eErrorKind ) +{ + sal_uInt16 nResult = 0; + switch( eErrorKind ) + { + // for these cases select the default in the list box + case CHERROR_NONE: + case CHERROR_PERCENT: + case CHERROR_CONST: + case CHERROR_RANGE: + nResult = CHART_LB_FUNCTION_STD_DEV; + break; + case CHERROR_VARIANT: + nResult = CHART_LB_FUNCTION_VARIANCE; + break; + case CHERROR_SIGMA: + nResult = CHART_LB_FUNCTION_STD_DEV; + break; + case CHERROR_BIGERROR: + nResult = CHART_LB_FUNCTION_ERROR_MARGIN; + break; + case CHERROR_STDERROR: + nResult = CHART_LB_FUNCTION_STD_ERROR; + break; + } + return nResult; +} +} // anonymous namespace + + +//............................................................................. +namespace chart +{ +//............................................................................. + +// macro for selecting a normal or high contrast bitmap the stack variable +// bIsHighContrast must exist and reflect the correct state +#define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name )) + +enum StatIndicator +{ + INDICATE_BOTH, + INDICATE_UP, + INDICATE_DOWN +}; + +ErrorBarResources::ErrorBarResources( Window* pParent, Dialog * pParentDialog, + const SfxItemSet& rInAttrs, bool bNoneAvailable, + tErrorBarType eType /* = ERROR_BAR_Y */ ) : + + m_aFlErrorCategory( pParent, SchResId( FL_ERROR )), + m_aRbNone( pParent, SchResId( RB_NONE )), + m_aRbConst( pParent, SchResId( RB_CONST )), + m_aRbPercent( pParent, SchResId( RB_PERCENT )), + m_aRbFunction( pParent, SchResId( RB_FUNCTION )), + m_aRbRange( pParent, SchResId( RB_RANGE )), + m_aLbFunction( pParent, SchResId( LB_FUNCTION )), + + m_aFlParameters( pParent, SchResId( FL_PARAMETERS )), + m_aFtPositive( pParent, SchResId( FT_POSITIVE )), + m_aMfPositive( pParent, SchResId( MF_POSITIVE )), + m_aEdRangePositive( pParent, SchResId( ED_RANGE_POSITIVE )), + m_aIbRangePositive( pParent, SchResId( IB_RANGE_POSITIVE )), + m_aFtNegative( pParent, SchResId( FT_NEGATIVE )), + m_aMfNegative( pParent, SchResId( MF_NEGATIVE )), + m_aEdRangeNegative( pParent, SchResId( ED_RANGE_NEGATIVE )), + m_aIbRangeNegative( pParent, SchResId( IB_RANGE_NEGATIVE )), + m_aCbSyncPosNeg( pParent, SchResId( CB_SYN_POS_NEG )), + + m_aFlIndicate( pParent, SchResId( FL_INDICATE )), + m_aRbBoth( pParent, SchResId( RB_BOTH )), + m_aRbPositive( pParent, SchResId( RB_POSITIVE )), + m_aRbNegative( pParent, SchResId( RB_NEGATIVE )), + m_aFiBoth( pParent, SchResId( FI_BOTH )), + m_aFiPositive( pParent, SchResId( FI_POSITIVE )), + m_aFiNegative( pParent, SchResId( FI_NEGATIVE )), + + m_eErrorKind( CHERROR_NONE ), + m_eIndicate( CHINDICATE_BOTH ), + m_bErrorKindUnique( true ), + m_bIndicatorUnique( true ), + m_bPlusUnique( true ), + m_bMinusUnique( true ), + m_bRangePosUnique( true ), + m_bRangeNegUnique( true ), + m_bNoneAvailable( bNoneAvailable ), + m_eErrorBarType( eType ), + m_nConstDecimalDigits( 1 ), + m_nConstSpinSize( 1 ), + m_pParentWindow( pParent ), + m_pParentDialog( pParentDialog ), + m_pCurrentRangeChoosingField( 0 ), + m_bHasInternalDataProvider( true ) +{ + if( m_bNoneAvailable ) + m_aRbNone.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); + else + m_aRbNone.Hide(); + + m_aRbConst.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); + m_aRbPercent.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); + m_aRbFunction.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); + m_aRbRange.SetClickHdl( LINK( this, ErrorBarResources, CategoryChosen )); + m_aLbFunction.SetSelectHdl( LINK( this, ErrorBarResources, CategoryChosen )); + + m_aCbSyncPosNeg.Check( FALSE ); + m_aCbSyncPosNeg.SetToggleHdl( LINK( this, ErrorBarResources, SynchronizePosAndNeg )); + + m_aMfPositive.SetModifyHdl( LINK( this, ErrorBarResources, PosValueChanged )); + m_aEdRangePositive.SetModifyHdl( LINK( this, ErrorBarResources, RangeChanged )); + m_aEdRangeNegative.SetModifyHdl( LINK( this, ErrorBarResources, RangeChanged )); + + m_aRbPositive.SetClickHdl( LINK( this, ErrorBarResources, IndicatorChanged )); + m_aRbNegative.SetClickHdl( LINK( this, ErrorBarResources, IndicatorChanged )); + m_aRbBoth.SetClickHdl( LINK( this, ErrorBarResources, IndicatorChanged )); + + m_aIbRangePositive.SetClickHdl( LINK( this, ErrorBarResources, ChooseRange )); + m_aIbRangeNegative.SetClickHdl( LINK( this, ErrorBarResources, ChooseRange )); + m_aIbRangePositive.SetQuickHelpText( String( SchResId( STR_TIP_SELECT_RANGE ))); + m_aIbRangeNegative.SetQuickHelpText( String( SchResId( STR_TIP_SELECT_RANGE ))); + + FillValueSets(); + Reset( rInAttrs ); +} + +ErrorBarResources::~ErrorBarResources() +{ +} + +void ErrorBarResources::SetErrorBarType( tErrorBarType eNewType ) +{ + if( m_eErrorBarType != eNewType ) + { + m_eErrorBarType = eNewType; + FillValueSets(); + } +} + +void ErrorBarResources::SetChartDocumentForRangeChoosing( + const uno::Reference< chart2::XChartDocument > & xChartDocument ) +{ + if( xChartDocument.is()) + m_bHasInternalDataProvider = xChartDocument->hasInternalDataProvider(); + m_apRangeSelectionHelper.reset( new RangeSelectionHelper( xChartDocument )); + + // has internal data provider => rename "cell range" to "from data" + OSL_ASSERT( m_apRangeSelectionHelper.get()); + if( m_bHasInternalDataProvider ) + { + m_aRbRange.SetText( String( SchResId( STR_CONTROLTEXT_ERROR_BARS_FROM_DATA ))); + } + + if( m_aRbRange.IsChecked()) + { + isRangeFieldContentValid( m_aEdRangePositive ); + isRangeFieldContentValid( m_aEdRangeNegative ); + } +} + +void ErrorBarResources::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ) +{ + if( fMinorStepWidth < 0 ) + fMinorStepWidth = -fMinorStepWidth; + + sal_Int32 nExponent = static_cast< sal_Int32 >( ::rtl::math::approxFloor( log10( fMinorStepWidth ))); + if( nExponent <= 0 ) + { + // one digit precision more + m_nConstDecimalDigits = static_cast< sal_uInt16 >( (-nExponent) + 1 ); + m_nConstSpinSize = 10; + } + else + { + m_nConstDecimalDigits = 0; + m_nConstSpinSize = static_cast< sal_Int64 >( pow( 10.0, (int)nExponent )); + } +} + +void ErrorBarResources::UpdateControlStates() +{ + // function + bool bIsFunction = m_aRbFunction.IsChecked(); + m_aLbFunction.Enable( bIsFunction ); + + // range buttons + bool bShowRange = ( m_aRbRange.IsChecked()); + bool bCanChooseRange = + ( bShowRange && + m_apRangeSelectionHelper.get() && + m_apRangeSelectionHelper->hasRangeSelection()); + + m_aMfPositive.Show( ! bShowRange ); + m_aMfNegative.Show( ! bShowRange ); + + // use range but without range chooser => hide controls + m_aEdRangePositive.Show( bShowRange && ! m_bHasInternalDataProvider ); + m_aIbRangePositive.Show( bCanChooseRange ); + m_aEdRangeNegative.Show( bShowRange && ! m_bHasInternalDataProvider ); + m_aIbRangeNegative.Show( bCanChooseRange ); + + bool bShowPosNegAndSync = ! (bShowRange && m_bHasInternalDataProvider); + m_aFtPositive.Show( bShowPosNegAndSync ); + m_aFtNegative.Show( bShowPosNegAndSync ); + m_aCbSyncPosNeg.Show( bShowPosNegAndSync ); + m_aFlParameters.Show( bShowPosNegAndSync ); + + // unit for metric fields + bool bIsErrorMargin( + ( m_aRbFunction.IsChecked()) && + ( m_aLbFunction.GetSelectEntryPos() == CHART_LB_FUNCTION_ERROR_MARGIN )); + bool bIsPercentage( m_aRbPercent.IsChecked() || bIsErrorMargin ); + String aCustomUnit; + + if( bIsPercentage ) + { + aCustomUnit = String( RTL_CONSTASCII_USTRINGPARAM( " %" )); + m_aMfPositive.SetDecimalDigits( 1 ); + m_aMfPositive.SetSpinSize( 10 ); + m_aMfNegative.SetDecimalDigits( 1 ); + m_aMfNegative.SetSpinSize( 10 ); + } + else + { + m_aMfPositive.SetDecimalDigits( m_nConstDecimalDigits ); + m_aMfPositive.SetSpinSize( m_nConstSpinSize ); + m_aMfNegative.SetDecimalDigits( m_nConstDecimalDigits ); + m_aMfNegative.SetSpinSize( m_nConstSpinSize ); + } + m_aMfPositive.SetCustomUnitText( aCustomUnit ); + m_aMfNegative.SetCustomUnitText( aCustomUnit ); + + // positive and negative value fields + bool bPosEnabled = ( m_aRbPositive.IsChecked() || m_aRbBoth.IsChecked()); + bool bNegEnabled = ( m_aRbNegative.IsChecked() || m_aRbBoth.IsChecked()); + if( !( bPosEnabled || bNegEnabled )) + { + // all three controls are not checked -> ambiguous state + bPosEnabled = true; + bNegEnabled = true; + } + + // functions with only one parameter + bool bOneParameterCategory = + bIsErrorMargin || m_aRbPercent.IsChecked(); + if( bOneParameterCategory ) + { + m_aCbSyncPosNeg.Check(); + } + + if( m_aCbSyncPosNeg.IsChecked()) + { + bPosEnabled = true; + bNegEnabled = false; + } + + // all functions except error margin take no arguments + if( m_aRbFunction.IsChecked() && + ( m_aLbFunction.GetSelectEntryPos() != CHART_LB_FUNCTION_ERROR_MARGIN )) + { + bPosEnabled = false; + bNegEnabled = false; + } + + // enable/disable pos/neg fields + m_aFtPositive.Enable( bPosEnabled ); + m_aFtNegative.Enable( bNegEnabled ); + if( bShowRange ) + { + m_aEdRangePositive.Enable( bPosEnabled ); + m_aIbRangePositive.Enable( bPosEnabled ); + m_aEdRangeNegative.Enable( bNegEnabled ); + m_aIbRangeNegative.Enable( bNegEnabled ); + } + else + { + m_aMfPositive.Enable( bPosEnabled ); + m_aMfNegative.Enable( bNegEnabled ); + } + + m_aCbSyncPosNeg.Enable( + !bOneParameterCategory && + ( bPosEnabled || bNegEnabled )); + + // mark invalid entries in the range fields + if( bShowRange && ! m_bHasInternalDataProvider ) + { + isRangeFieldContentValid( m_aEdRangePositive ); + isRangeFieldContentValid( m_aEdRangeNegative ); + } +} + +IMPL_LINK( ErrorBarResources, CategoryChosen, void *, ) +{ + m_bErrorKindUnique = true; + SvxChartKindError eOldError = m_eErrorKind; + + if( m_aRbNone.IsChecked()) + m_eErrorKind = CHERROR_NONE; + else if( m_aRbConst.IsChecked()) + m_eErrorKind = CHERROR_CONST; + else if( m_aRbPercent.IsChecked()) + m_eErrorKind = CHERROR_PERCENT; + else if( m_aRbRange.IsChecked()) + m_eErrorKind = CHERROR_RANGE; + else if( m_aRbFunction.IsChecked()) + { + if( m_aLbFunction.GetSelectEntryCount() == 1 ) + { + switch( m_aLbFunction.GetSelectEntryPos()) + { + case CHART_LB_FUNCTION_STD_ERROR: + m_eErrorKind = CHERROR_STDERROR; break; + case CHART_LB_FUNCTION_STD_DEV: + m_eErrorKind = CHERROR_SIGMA; break; + case CHART_LB_FUNCTION_VARIANCE: + m_eErrorKind = CHERROR_VARIANT; break; + case CHART_LB_FUNCTION_ERROR_MARGIN: + m_eErrorKind = CHERROR_BIGERROR; break; + default: + m_bErrorKindUnique = false; + } + } + else + m_bErrorKindUnique = false; + } + else + { + OSL_ENSURE( false, "Unknown category chosen" ); + m_bErrorKindUnique = false; + } + + // changed to range + if( m_eErrorKind == CHERROR_RANGE && + eOldError != CHERROR_RANGE ) + { + m_aCbSyncPosNeg.Check( + (m_aEdRangePositive.GetText().Len() > 0) && + m_aEdRangePositive.GetText().Equals( + m_aEdRangeNegative.GetText())); + } + // changed from range + else if( m_eErrorKind != CHERROR_RANGE && + eOldError == CHERROR_RANGE ) + { + m_aCbSyncPosNeg.Check( + m_aMfPositive.GetValue() == m_aMfNegative.GetValue()); + } + + UpdateControlStates(); + return 0; +} + +IMPL_LINK( ErrorBarResources, SynchronizePosAndNeg, void *, EMPTYARG ) +{ + UpdateControlStates(); + PosValueChanged( 0 ); + return 0; +} + +IMPL_LINK( ErrorBarResources, PosValueChanged, void *, EMPTYARG ) +{ + if( m_aCbSyncPosNeg.IsChecked()) + { + if( m_aRbRange.IsChecked()) + { + m_aEdRangeNegative.SetText( m_aEdRangePositive.GetText()); + m_bRangeNegUnique = m_bRangePosUnique; + } + else + m_aMfNegative.SetValue( m_aMfPositive.GetValue()); + } + + return 0; +} + +IMPL_LINK( ErrorBarResources, IndicatorChanged, void *, EMPTYARG ) +{ + m_bIndicatorUnique = true; + if( m_aRbBoth.IsChecked()) + m_eIndicate = CHINDICATE_BOTH; + else if( m_aRbPositive.IsChecked()) + m_eIndicate = CHINDICATE_UP; + else if( m_aRbNegative.IsChecked()) + m_eIndicate = CHINDICATE_DOWN; + else + m_bIndicatorUnique = false; + + UpdateControlStates(); + return 0; +} + +IMPL_LINK( ErrorBarResources, ChooseRange, RangeSelectionButton *, pButton ) +{ + OSL_ASSERT( m_apRangeSelectionHelper.get()); + if( ! m_apRangeSelectionHelper.get()) + return 0; + OSL_ASSERT( m_pCurrentRangeChoosingField == 0 ); + + ::rtl::OUString aUIString; + if( pButton == &m_aIbRangePositive ) + { + m_pCurrentRangeChoosingField = &m_aEdRangePositive; + aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_POSITIVE_ERRORBARS ))); + } + else + { + m_pCurrentRangeChoosingField = &m_aEdRangeNegative; + aUIString = ::rtl::OUString( String( SchResId( STR_DATA_SELECT_RANGE_FOR_NEGATIVE_ERRORBARS ))); + } + + OSL_ASSERT( m_pParentDialog ); + if( m_pParentDialog ) + { + lcl_enableRangeChoosing( true, m_pParentDialog ); + m_apRangeSelectionHelper->chooseRange( + m_pCurrentRangeChoosingField->GetText(), + aUIString, *this ); + } + else + m_pCurrentRangeChoosingField = 0; + + return 0; +} + +IMPL_LINK( ErrorBarResources, RangeChanged, Edit *, pEdit ) +{ + if( pEdit == & m_aEdRangePositive ) + { + m_bRangePosUnique = true; + PosValueChanged( 0 ); + } + else + { + m_bRangeNegUnique = true; + } + + isRangeFieldContentValid( *pEdit ); + + return 0; +} + +void ErrorBarResources::Reset(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem *pPoolItem = NULL; + SfxItemState aState = SFX_ITEM_UNKNOWN; + + // category + m_eErrorKind = CHERROR_NONE; + aState = rInAttrs.GetItemState( SCHATTR_STAT_KIND_ERROR, TRUE, &pPoolItem ); + m_bErrorKindUnique = ( aState != SFX_ITEM_DONTCARE ); + + if( aState == SFX_ITEM_SET ) + m_eErrorKind = ((const SvxChartKindErrorItem*) pPoolItem)->GetValue(); + + m_aLbFunction.SelectEntryPos( lcl_getLbEntryPosByErrorKind( m_eErrorKind )); + + if( m_bErrorKindUnique ) + { + switch( m_eErrorKind ) + { + case CHERROR_NONE: + m_aRbNone.Check(); + break; + case CHERROR_PERCENT: + m_aRbPercent.Check(); + break; + case CHERROR_CONST: + m_aRbConst.Check(); + break; + case CHERROR_STDERROR: + case CHERROR_VARIANT: + case CHERROR_SIGMA: + case CHERROR_BIGERROR: + m_aRbFunction.Check(); + break; + case CHERROR_RANGE: + m_aRbRange.Check(); + break; + } + } + else + { + m_aRbNone.Check( FALSE ); + m_aRbConst.Check( FALSE ); + m_aRbPercent.Check( FALSE ); + m_aRbFunction.Check( FALSE ); + } + + // parameters + aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTPLUS, TRUE, &pPoolItem ); + m_bPlusUnique = ( aState != SFX_ITEM_DONTCARE ); + double fPlusValue = 0.0; + if( aState == SFX_ITEM_SET ) + { + fPlusValue = ((const SvxDoubleItem*) pPoolItem)->GetValue(); + sal_Int32 nPlusValue = static_cast< sal_Int32 >( fPlusValue * pow(10.0,m_aMfPositive.GetDecimalDigits()) ); + m_aMfPositive.SetValue( nPlusValue ); + } + + aState = rInAttrs.GetItemState( SCHATTR_STAT_CONSTMINUS, TRUE, &pPoolItem ); + m_bMinusUnique = ( aState != SFX_ITEM_DONTCARE ); + double fMinusValue = 0.0; + if( aState == SFX_ITEM_SET ) + { + fMinusValue = ((const SvxDoubleItem*) pPoolItem)->GetValue(); + sal_Int32 nMinusValue = static_cast< sal_Int32 >( fMinusValue * pow(10.0,m_aMfNegative.GetDecimalDigits()) ); + m_aMfNegative.SetValue( nMinusValue ); + + if( m_eErrorKind != CHERROR_RANGE && + fPlusValue == fMinusValue ) + m_aCbSyncPosNeg.Check(); + } + + // indicator + aState = rInAttrs.GetItemState( SCHATTR_STAT_INDICATE, TRUE, &pPoolItem ); + m_bIndicatorUnique = ( aState != SFX_ITEM_DONTCARE ); + if( aState == SFX_ITEM_SET) + m_eIndicate = ((const SvxChartIndicateItem * ) pPoolItem)->GetValue(); + + if( m_bIndicatorUnique ) + { + switch( m_eIndicate ) + { + case CHINDICATE_NONE : + // no longer used, use both as default + m_eIndicate = CHINDICATE_BOTH; + // fall-through intended to BOTH + case CHINDICATE_BOTH : + m_aRbBoth.Check(); break; + case CHINDICATE_UP : + m_aRbPositive.Check(); break; + case CHINDICATE_DOWN : + m_aRbNegative.Check(); break; + } + } + else + { + m_aRbBoth.Check( FALSE ); + m_aRbPositive.Check( FALSE ); + m_aRbNegative.Check( FALSE ); + } + + // ranges + aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_POS, TRUE, &pPoolItem ); + m_bRangePosUnique = ( aState != SFX_ITEM_DONTCARE ); + if( aState == SFX_ITEM_SET ) + { + String sRangePositive = (static_cast< const SfxStringItem * >( pPoolItem ))->GetValue(); + m_aEdRangePositive.SetText( sRangePositive ); + } + + aState = rInAttrs.GetItemState( SCHATTR_STAT_RANGE_NEG, TRUE, &pPoolItem ); + m_bRangeNegUnique = ( aState != SFX_ITEM_DONTCARE ); + if( aState == SFX_ITEM_SET ) + { + String sRangeNegative = (static_cast< const SfxStringItem * >( pPoolItem ))->GetValue(); + m_aEdRangeNegative.SetText( sRangeNegative ); + if( m_eErrorKind == CHERROR_RANGE && + sRangeNegative.Len() > 0 && + sRangeNegative.Equals( m_aEdRangePositive.GetText())) + m_aCbSyncPosNeg.Check(); + } + + UpdateControlStates(); +} + +BOOL ErrorBarResources::FillItemSet(SfxItemSet& rOutAttrs) const +{ + if( m_bErrorKindUnique ) + rOutAttrs.Put( SvxChartKindErrorItem( m_eErrorKind, SCHATTR_STAT_KIND_ERROR )); + if( m_bIndicatorUnique ) + rOutAttrs.Put( SvxChartIndicateItem( m_eIndicate, SCHATTR_STAT_INDICATE )); + + if( m_bErrorKindUnique ) + { + if( m_eErrorKind == CHERROR_RANGE ) + { + String aPosRange; + String aNegRange; + if( m_bHasInternalDataProvider ) + { + // the strings aPosRange/aNegRange have to be set to a non-empty + // arbitrary string to generate error-bar sequences + aPosRange.Assign( sal_Unicode('x')); + aNegRange = aPosRange; + } + else + { + aPosRange = m_aEdRangePositive.GetText(); + if( m_aCbSyncPosNeg.IsChecked()) + aNegRange = aPosRange; + else + aNegRange = m_aEdRangeNegative.GetText(); + } + + if( m_bRangePosUnique ) + rOutAttrs.Put( SfxStringItem( SCHATTR_STAT_RANGE_POS, aPosRange )); + if( m_bRangeNegUnique ) + rOutAttrs.Put( SfxStringItem( SCHATTR_STAT_RANGE_NEG, aNegRange )); + } + else if( m_eErrorKind == CHERROR_CONST || + m_eErrorKind == CHERROR_PERCENT || + m_eErrorKind == CHERROR_BIGERROR ) + { + double fPosValue = static_cast< double >( m_aMfPositive.GetValue()) / + pow( 10.0, m_aMfPositive.GetDecimalDigits()); + double fNegValue = 0.0; + + if( m_aCbSyncPosNeg.IsChecked()) + fNegValue = fPosValue; + else + fNegValue = static_cast< double >( m_aMfNegative.GetValue()) / + pow( 10.0, m_aMfNegative.GetDecimalDigits()); + + rOutAttrs.Put( SvxDoubleItem( fPosValue, SCHATTR_STAT_CONSTPLUS )); + rOutAttrs.Put( SvxDoubleItem( fNegValue, SCHATTR_STAT_CONSTMINUS )); + } + } + + return TRUE; +} + +void ErrorBarResources::FillValueSets() +{ + bool bIsHighContrast = ( true && m_aRbConst.GetSettings().GetStyleSettings().GetHighContrastMode() ); + + // do not scale images, show then centered +// m_aFiPositive.SetStyle( (m_aFiPositive.GetStyle() & (~WB_SCALE)) | WB_CENTER ); +// m_aFiNegative.SetStyle( (m_aFiNegative.GetStyle() & (~WB_SCALE)) | WB_CENTER ); +// m_aFiBoth.SetStyle( (m_aFiBoth.GetStyle() & (~WB_SCALE)) | WB_CENTER ); + + if( m_eErrorBarType == ERROR_BAR_Y ) + { + m_aFiNegative.SetImage( SELECT_IMAGE( BMP_INDICATE_DOWN )); + m_aFiPositive.SetImage( SELECT_IMAGE( BMP_INDICATE_UP )); + m_aFiBoth.SetImage( SELECT_IMAGE( BMP_INDICATE_BOTH_VERTI )); + } + else if( m_eErrorBarType == ERROR_BAR_X ) + { + m_aFiNegative.SetImage( SELECT_IMAGE( BMP_INDICATE_LEFT )); + m_aFiPositive.SetImage( SELECT_IMAGE( BMP_INDICATE_RIGHT )); + m_aFiBoth.SetImage( SELECT_IMAGE( BMP_INDICATE_BOTH_HORI )); + } +} + +void ErrorBarResources::listeningFinished( + const ::rtl::OUString & rNewRange ) +{ + OSL_ASSERT( m_apRangeSelectionHelper.get()); + if( ! m_apRangeSelectionHelper.get()) + return; + + // rNewRange becomes invalid after removing the listener + ::rtl::OUString aRange( rNewRange ); + +// m_rDialogModel.startControllerLockTimer(); + + // stop listening + m_apRangeSelectionHelper->stopRangeListening(); + + // change edit field + if( m_pParentWindow ) + { + m_pParentWindow->ToTop(); + m_pParentWindow->GrabFocus(); + } + + if( m_pCurrentRangeChoosingField ) + { + m_pCurrentRangeChoosingField->SetText( String( aRange )); + m_pCurrentRangeChoosingField->GrabFocus(); + PosValueChanged( 0 ); + } + + m_pCurrentRangeChoosingField = 0; + + UpdateControlStates(); + OSL_ASSERT( m_pParentDialog ); + if( m_pParentDialog ) + lcl_enableRangeChoosing( false, m_pParentDialog ); +} + +void ErrorBarResources::disposingRangeSelection() +{ + OSL_ASSERT( m_apRangeSelectionHelper.get()); + if( m_apRangeSelectionHelper.get()) + m_apRangeSelectionHelper->stopRangeListening( false ); +} + +bool ErrorBarResources::isRangeFieldContentValid( Edit & rEdit ) +{ + ::rtl::OUString aRange( rEdit.GetText()); + bool bIsValid = ( aRange.getLength() == 0 ) || + ( m_apRangeSelectionHelper.get() && + m_apRangeSelectionHelper->verifyCellRange( aRange )); + + if( bIsValid || !rEdit.IsEnabled()) + { + rEdit.SetControlForeground(); + rEdit.SetControlBackground(); + } + else + { + rEdit.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR ); + rEdit.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR ); + } + + return bIsValid; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/res_ErrorBar_IDs.hrc b/chart2/source/controller/dialogs/res_ErrorBar_IDs.hrc new file mode 100644 index 000000000000..8bac3e9c9e87 --- /dev/null +++ b/chart2/source/controller/dialogs/res_ErrorBar_IDs.hrc @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_ErrorBar_IDs.hrc,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define FL_ERROR 1 +#define FL_INDICATE 2 +#define FL_PARAMETERS 3 + +#define FT_POSITIVE 1 +#define FT_NEGATIVE 2 + +#define RB_NONE 1 +#define RB_CONST 2 +#define RB_PERCENT 3 +#define RB_FUNCTION 4 +#define RB_BOTH 5 +#define RB_POSITIVE 6 +#define RB_NEGATIVE 7 +#define RB_RANGE 8 + +#define ED_RANGE_POSITIVE 1 +#define ED_RANGE_NEGATIVE 2 + +#define FI_BOTH 1 +#define FI_POSITIVE 2 +#define FI_NEGATIVE 3 +#define IB_RANGE_POSITIVE 4 +#define IB_RANGE_NEGATIVE 5 + +#define LB_FUNCTION 1 + +#define MF_POSITIVE 1 +#define MF_NEGATIVE 2 + +#define CB_SYN_POS_NEG 1 + +#define CHART_LB_FUNCTION_STD_ERROR 0 +#define CHART_LB_FUNCTION_STD_DEV 1 +#define CHART_LB_FUNCTION_VARIANCE 2 +#define CHART_LB_FUNCTION_ERROR_MARGIN 3 diff --git a/chart2/source/controller/dialogs/res_ErrorBar_tmpl.hrc b/chart2/source/controller/dialogs/res_ErrorBar_tmpl.hrc new file mode 100644 index 000000000000..6372f3000571 --- /dev/null +++ b/chart2/source/controller/dialogs/res_ErrorBar_tmpl.hrc @@ -0,0 +1,231 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_ErrorBar_tmpl.hrc,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RESOURCE_ERRORBARS_HXX +#define _CHART2_RESOURCE_ERRORBARS_HXX + +#include "res_ErrorBar_IDs.hrc" +#define WORKAROUND \ +StringList [ en-US ] = \ + { \ + < "Standard Error" ; CHART_LB_FUNCTION_STD_ERROR ; >; \ + < "Standard Deviation" ; CHART_LB_FUNCTION_STD_DEV ; >; \ + < "Variance" ; CHART_LB_FUNCTION_VARIANCE ; >; \ + < "Error Margin" ; CHART_LB_FUNCTION_ERROR_MARGIN ; >; \ + }; + + +#define RESOURCE_ERRORBARS(availablewidth, yoffset) \ +FixedLine FL_ERROR \ +{ \ + Pos = MAP_APPFONT ( 6 , 6 ) ; \ + Size = MAP_APPFONT ( 116 , 8 ) ; \ + Text [ en-US ] = "Error Category" ; \ +}; \ +RadioButton RB_NONE \ +{ \ + HelpID = HID_SCH_STATISTIK_NO_ERROR; \ + Pos = MAP_APPFONT ( 12 , 20 ) ; \ + Size = MAP_APPFONT ( 110 , 10 ) ; \ + Text [ en-US ] = "~None" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RB_CONST \ +{ \ + HelpID = HID_SCH_STATISTIK_CONSTERROR; \ + Pos = MAP_APPFONT ( 12 , 20 + yoffset ) ; \ + Size = MAP_APPFONT ( 110 , 10 ) ; \ + Text [ en-US ] = "~Constant Value" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RB_PERCENT \ +{ \ + HelpID = HID_SCH_STATISTIK_PERCENT; \ + Pos = MAP_APPFONT ( 12 , 34 + yoffset ) ; \ + Size = MAP_APPFONT ( 110 , 10 ) ; \ + Text [ en-US ] = "~Percentage" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RB_FUNCTION \ +{ \ + HelpID = HID_SCH_STATISTIK_FUNCTION; \ + Pos = MAP_APPFONT ( 12 , 48 + yoffset ) ; \ + Size = MAP_APPFONT ( 12 , 10 ) ; \ + Text [ en-US ] = "" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RB_RANGE \ +{ \ + HelpID = HID_SCH_STATISTIK_RANGE; \ + Pos = MAP_APPFONT( 12, 62 + yoffset ) ; \ + Size = MAP_APPFONT( 110, 10 ) ; \ + Text [ en-US ] = "Cell ~Range" ; \ + TabStop = TRUE ; \ +}; \ +ListBox LB_FUNCTION \ +{ \ + HelpID = HID_SCH_STATISTIK_FUNCTION_LB; \ + Pos = MAP_APPFONT ( 22 , 46 + yoffset ) ; \ + Size = MAP_APPFONT ( 94 , 59 ) ; \ + DropDown = TRUE; \ + Border = TRUE; \ + WORKAROUND\ +}; \ +FixedLine FL_PARAMETERS \ +{ \ + Pos = MAP_APPFONT ( 6 , 82 + yoffset ) ; \ + Size = MAP_APPFONT ( availablewidth - 12, 8 ) ; \ + Text [ en-US ] = "Parameters" ; \ +}; \ +FixedText FT_POSITIVE \ +{ \ + Pos = MAP_APPFONT ( 12 , 94 + yoffset ) ; \ + Size = MAP_APPFONT ( 46 , 8 ) ; \ + Text [ en-US ] = "P~ositive (+)"; \ +}; \ +MetricField MF_POSITIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_POSITIVE_VALUE; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 60 , 92 + yoffset ) ; \ + Size = MAP_APPFONT ( 56 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + Minimum = 0 ; \ + StrictFormat = TRUE ; \ + Unit = FUNIT_CUSTOM ; \ + SpinSize = 100 ; \ + DecimalDigits = 2 ; \ +}; \ +Edit ED_RANGE_POSITIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_POSITIVE_RANGE; \ + Border = TRUE ; \ + Hide = TRUE; \ + Pos = MAP_APPFONT ( 60 , 92 + yoffset ) ; \ + Size = MAP_APPFONT ( 90 , 12 ) ; \ +}; \ +ImageButton IB_RANGE_POSITIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_POSITIVE_RANGE_CHOOSER; \ + Hide = TRUE; \ + Pos = MAP_APPFONT ( 152 , 91 + yoffset ) ; \ + Size = MAP_APPFONT ( 14 , 14 ) ; \ + TabStop = TRUE ; \ +}; \ +FixedText FT_NEGATIVE \ +{ \ + Pos = MAP_APPFONT ( 12 , 110 + yoffset ) ; \ + Size = MAP_APPFONT ( 46 , 8 ) ; \ + Text [ en-US ] = "~Negative (-)"; \ +}; \ +MetricField MF_NEGATIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_NEGATIVE_VALUE; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( 60 , 108 + yoffset ) ; \ + Size = MAP_APPFONT ( 56 , 12 ) ; \ + TabStop = TRUE ; \ + Repeat = TRUE ; \ + Spin = TRUE ; \ + Minimum = 0 ; \ + StrictFormat = TRUE ; \ + Unit = FUNIT_CUSTOM ; \ + SpinSize = 100 ; \ + DecimalDigits = 2 ; \ +}; \ +Edit ED_RANGE_NEGATIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_NEGATIVE_RANGE; \ + Border = TRUE ; \ + Hide = TRUE; \ + Pos = MAP_APPFONT ( 60 , 108 + yoffset ) ; \ + Size = MAP_APPFONT ( 90 , 12 ) ; \ +}; \ +ImageButton IB_RANGE_NEGATIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_NEGATIVE_RANGE_CHOOSER; \ + Hide = TRUE; \ + Pos = MAP_APPFONT ( 152 , 107 + yoffset ) ; \ + Size = MAP_APPFONT ( 14 , 14 ) ; \ + TabStop = TRUE ; \ +}; \ +CheckBox CB_SYN_POS_NEG \ +{ \ + HelpID = HID_SCH_STATISTIK_SAME_FOR_BOTH; \ + Pos = MAP_APPFONT ( 12 , 126 + yoffset ); \ + Size = MAP_APPFONT ( availablewidth - 12 , 10 ); \ + TabStop = TRUE; \ + Text[ en-US ] = "Same value for both"; \ +}; \ +FixedLine FL_INDICATE \ +{ \ + Pos = MAP_APPFONT ( 130 , 6 ) ; \ + Size = MAP_APPFONT ( availablewidth - 136 , 8 ) ; \ + Text [ en-US ] = "Error Indicator" ; \ +}; \ +RadioButton RB_BOTH \ +{ \ + HelpID = HID_SCH_STATISTIK_SHOW_BOTH; \ + Pos = MAP_APPFONT ( 154 , 22 ); \ + Size = MAP_APPFONT ( 90 , 10 ); \ + Text[ en-US ] = "Positive ~and Negative"; \ +}; \ +RadioButton RB_POSITIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_SHOW_POSITIVE; \ + Pos = MAP_APPFONT ( 154 , 43 ); \ + Size = MAP_APPFONT ( 90 , 10 ); \ + Text[ en-US ] = "Pos~itive"; \ +}; \ +RadioButton RB_NEGATIVE \ +{ \ + HelpID = HID_SCH_STATISTIK_SHOW_NEGATIVE; \ + Pos = MAP_APPFONT ( 154 , 64 ); \ + Size = MAP_APPFONT ( 90 , 10 ); \ + Text[ en-US ] = "Ne~gative"; \ +}; \ +FixedImage FI_BOTH \ +{ \ + Pos = MAP_APPFONT ( 134 , 18 ); \ + Size = MAP_APPFONT ( 18 , 18 ); \ +}; \ +FixedImage FI_POSITIVE \ +{ \ + Pos = MAP_APPFONT ( 134 , 39 ); \ + Size = MAP_APPFONT ( 18 , 18 ); \ +}; \ +FixedImage FI_NEGATIVE \ +{ \ + Pos = MAP_APPFONT ( 134 , 60 ); \ + Size = MAP_APPFONT ( 18 , 18 ); \ +}; + +#endif diff --git a/chart2/source/controller/dialogs/res_LegendPosition.cxx b/chart2/source/controller/dialogs/res_LegendPosition.cxx new file mode 100644 index 000000000000..45623ebad3c5 --- /dev/null +++ b/chart2/source/controller/dialogs/res_LegendPosition.cxx @@ -0,0 +1,268 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_LegendPosition.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_LegendPosition.hxx" +#include "ResourceIds.hrc" +#include "Strings.hrc" +#include "res_LegendPosition_IDs.hrc" +#include "ResId.hxx" +#include "ChartModelHelper.hxx" +#include "macros.hxx" +#include "LegendHelper.hxx" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif +#include <com/sun/star/chart2/LegendPosition.hpp> +#include <com/sun/star/chart2/LegendExpansion.hpp> + +//itemset stuff +#include "chartview/ChartSfxItemIds.hxx" +#include <svx/chrtitem.hxx> +// header for class SfxItemPool +#include <svtools/itempool.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +LegendPositionResources::LegendPositionResources( Window* pWindow ) + : m_xCC() //unused in this scenario + , m_aCbxShow( pWindow ) //unused in this scenario + , m_aRbtLeft( pWindow, SchResId(RBT_LEFT) ) + , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) + , m_aRbtRight( pWindow, SchResId(RBT_RIGHT) ) + , m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) ) +{ + m_aCbxShow.Check();//legend is assumed to be visible in this scenario + impl_setRadioButtonToggleHdl(); +} + +LegendPositionResources::LegendPositionResources( Window* pWindow, const uno::Reference< uno::XComponentContext >& xCC ) + : m_xCC( xCC ) + , m_aCbxShow( pWindow, SchResId(CBX_SHOWLEGEND) ) + , m_aRbtLeft( pWindow, SchResId(RBT_LEFT) ) + , m_aRbtTop( pWindow, SchResId(RBT_TOP) ) + , m_aRbtRight( pWindow, SchResId(RBT_RIGHT) ) + , m_aRbtBottom( pWindow, SchResId(RBT_BOTTOM) ) +{ + m_aCbxShow.SetToggleHdl( LINK( this, LegendPositionResources, PositionEnableHdl ) ); + impl_setRadioButtonToggleHdl(); +} + +void LegendPositionResources::impl_setRadioButtonToggleHdl() +{ + m_aRbtLeft.SetToggleHdl( LINK( this, LegendPositionResources, PositionChangeHdl ) ); + m_aRbtTop.SetToggleHdl( LINK( this, LegendPositionResources, PositionChangeHdl ) ); + m_aRbtRight.SetToggleHdl( LINK( this, LegendPositionResources, PositionChangeHdl ) ); + m_aRbtBottom.SetToggleHdl( LINK( this, LegendPositionResources, PositionChangeHdl ) ); +} + +LegendPositionResources::~LegendPositionResources() +{ +} + +void LegendPositionResources::writeToResources( const uno::Reference< frame::XModel >& xChartModel ) +{ + try + { + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xChartModel ); + uno::Reference< beans::XPropertySet > xProp( xDiagram->getLegend(), uno::UNO_QUERY ); + if( xProp.is() ) + { + //show + sal_Bool bShowLegend = sal_False; + xProp->getPropertyValue( C2U("Show") ) >>= bShowLegend; + m_aCbxShow.Check( bShowLegend ); + PositionEnableHdl(0); + + //position + chart2::LegendPosition ePos; + xProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos; + switch( ePos ) + { + case chart2::LegendPosition_LINE_START: + m_aRbtLeft.Check(); + break; + case chart2::LegendPosition_LINE_END: + m_aRbtRight.Check(); + break; + case chart2::LegendPosition_PAGE_START: + m_aRbtTop.Check(); + break; + case chart2::LegendPosition_PAGE_END: + m_aRbtBottom.Check(); + break; + + case chart2::LegendPosition_CUSTOM: + default: + m_aRbtRight.Check(); + break; + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void LegendPositionResources::writeToModel( const ::com::sun::star::uno::Reference< frame::XModel >& xChartModel ) const +{ + try + { + sal_Bool bShowLegend = static_cast<sal_Bool>(m_aCbxShow.IsChecked()); + uno::Reference< beans::XPropertySet > xProp( LegendHelper::getLegend( xChartModel,m_xCC,bShowLegend ), uno::UNO_QUERY ); + if( xProp.is() ) + { + //show + xProp->setPropertyValue( C2U("Show"), uno::makeAny( bShowLegend )); + + //position + chart2::LegendPosition eNewPos; + chart2::LegendExpansion eExp = chart2::LegendExpansion_HIGH; + + if( m_aRbtLeft.IsChecked() ) + eNewPos = chart2::LegendPosition_LINE_START; + else if( m_aRbtRight.IsChecked() ) + { + eNewPos = chart2::LegendPosition_LINE_END; + } + else if( m_aRbtTop.IsChecked() ) + { + eNewPos = chart2::LegendPosition_PAGE_START; + eExp = chart2::LegendExpansion_WIDE; + } + else if( m_aRbtBottom.IsChecked() ) + { + eNewPos = chart2::LegendPosition_PAGE_END; + eExp = chart2::LegendExpansion_WIDE; + } + + xProp->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos )); + xProp->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExp )); + xProp->setPropertyValue( C2U( "RelativePosition" ), uno::Any()); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +IMPL_LINK( LegendPositionResources, PositionEnableHdl, void*, EMPTYARG ) +{ + BOOL bEnable = m_aCbxShow.IsChecked(); + + m_aRbtLeft.Enable( bEnable ); + m_aRbtTop.Enable( bEnable ); + m_aRbtRight.Enable( bEnable ); + m_aRbtBottom.Enable( bEnable ); + + m_aChangeLink.Call(NULL); + + return 0; +} + +void LegendPositionResources::initFromItemSet( const SfxItemSet& rInAttrs ) +{ + SvxChartLegendPos ePos = CHLEGEND_NONE; + + const SfxPoolItem* pPoolItem = NULL; + if( rInAttrs.GetItemState( SCHATTR_LEGEND_POS, + TRUE, &pPoolItem ) != SFX_ITEM_SET ) + pPoolItem = &(rInAttrs.GetPool()->GetDefaultItem( SCHATTR_LEGEND_POS )); + + if( pPoolItem ) + ePos = ((const SvxChartLegendPosItem*)pPoolItem)->GetValue(); + + switch( ePos ) + { + case CHLEGEND_LEFT: + m_aRbtLeft.Check(TRUE); + break; + case CHLEGEND_TOP: + m_aRbtTop.Check(TRUE); + break; + case CHLEGEND_RIGHT: + m_aRbtRight.Check(TRUE); + break; + case CHLEGEND_BOTTOM: + m_aRbtBottom.Check(TRUE); + break; + default: + break; + } +} + +void LegendPositionResources::writeToItemSet( SfxItemSet& rOutAttrs ) const +{ + SvxChartLegendPos ePos; + + if( m_aRbtLeft.IsChecked() ) + ePos = CHLEGEND_LEFT; + else if( m_aRbtTop.IsChecked() ) + ePos = CHLEGEND_TOP; + else if( m_aRbtRight.IsChecked() ) + ePos = CHLEGEND_RIGHT; + else if( m_aRbtBottom.IsChecked() ) + ePos = CHLEGEND_BOTTOM; + else + ePos = CHLEGEND_NONE; + + rOutAttrs.Put(SvxChartLegendPosItem( ePos, SCHATTR_LEGEND_POS )); +} + +IMPL_LINK( LegendPositionResources, PositionChangeHdl, RadioButton*, pRadio ) +{ + //for each radio click ther are coming two change events + //first uncheck of previous button -> ignore that call + //the second call gives the check of the new button + if( pRadio && pRadio->IsChecked() ) + m_aChangeLink.Call(NULL); + return 0; +} + +void LegendPositionResources::SetChangeHdl( const Link& rLink ) +{ + m_aChangeLink = rLink; +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/res_LegendPosition.hxx b/chart2/source/controller/dialogs/res_LegendPosition.hxx new file mode 100644 index 000000000000..571a0dfc33ff --- /dev/null +++ b/chart2/source/controller/dialogs/res_LegendPosition.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_LegendPosition.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RES_LEGENPOSITION_HXX +#define _CHART2_RES_LEGENPOSITION_HXX + +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#include <vcl/fixed.hxx> +// header for class SfxItemSet +#include <svtools/itemset.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class LegendPositionResources +{ +public: + //constructor without Display checkbox + LegendPositionResources( Window* pParent ); + //constructor inclusive Display checkbox + LegendPositionResources( Window* pParent, const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext>& xCC ); + virtual ~LegendPositionResources(); + + void writeToResources( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + void writeToModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ) const; + + + void initFromItemSet( const SfxItemSet& rInAttrs ); + void writeToItemSet( SfxItemSet& rOutAttrs ) const; + + void SetChangeHdl( const Link& rLink ); + + DECL_LINK( PositionEnableHdl, void* ); + DECL_LINK( PositionChangeHdl, RadioButton* ); + +private: + void impl_setRadioButtonToggleHdl(); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; + + CheckBox m_aCbxShow; + + RadioButton m_aRbtLeft; + RadioButton m_aRbtTop; + RadioButton m_aRbtRight; + RadioButton m_aRbtBottom; + + Link m_aChangeLink; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/res_LegendPosition_IDs.hrc b/chart2/source/controller/dialogs/res_LegendPosition_IDs.hrc new file mode 100644 index 000000000000..a6ebfed27028 --- /dev/null +++ b/chart2/source/controller/dialogs/res_LegendPosition_IDs.hrc @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_LegendPosition_IDs.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define CBX_SHOWLEGEND 21 +#define RBT_LEFT 22 +#define RBT_TOP 23 +#define RBT_RIGHT 24 +#define RBT_BOTTOM 25 diff --git a/chart2/source/controller/dialogs/res_LegendPosition_tmpl.hrc b/chart2/source/controller/dialogs/res_LegendPosition_tmpl.hrc new file mode 100644 index 000000000000..b0f056763f55 --- /dev/null +++ b/chart2/source/controller/dialogs/res_LegendPosition_tmpl.hrc @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_LegendPosition_tmpl.hrc,v $ + * $Revision: 1.7.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RESOURCE_LEGEND_HXX +#define _CHART2_RESOURCE_LEGEND_HXX + +#include "HelpIds.hrc" +#include "res_LegendPosition_IDs.hrc" + +#define RESOURCE_LEGENDDISPLAY( xpos , ypos ) \ +CheckBox CBX_SHOWLEGEND \ +{ \ + HelpID = HID_SCH_LEGEND_SHOW ; \ + Pos = MAP_APPFONT ( xpos , ypos ) ; \ + Size = MAP_APPFONT ( 67 , 12 ) ; \ + Text [ en-US ] = "~Display legend" ; \ + TabStop = TRUE ; \ +}; + +#define RESOURCE_LEGENDPOSITION( xpos , ypos ) \ +RadioButton RBT_LEFT \ +{ \ + HelpID = HID_SCH_LEGEND_POS_LEFT ; \ + Pos = MAP_APPFONT ( xpos , ypos ) ; \ + Size = MAP_APPFONT ( 75 , 10 ) ; \ + Text [ en-US ] = "~Left" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RBT_RIGHT \ +{ \ + HelpID = HID_SCH_LEGEND_POS_RIGHT ; \ + Pos = MAP_APPFONT ( xpos , ypos+14 ) ; \ + Size = MAP_APPFONT ( 75 , 10 ) ; \ + Text [ en-US ] = "~Right" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RBT_TOP \ +{ \ + HelpID = HID_SCH_LEGEND_POS_TOP ; \ + Pos = MAP_APPFONT ( xpos , ypos+28 ) ; \ + Size = MAP_APPFONT ( 75 , 10 ) ; \ + Text [ en-US ] = "~Top" ; \ + TabStop = TRUE ; \ +}; \ +RadioButton RBT_BOTTOM \ +{ \ + HelpID = HID_SCH_LEGEND_POS_BOTTOM ; \ + Pos = MAP_APPFONT ( xpos , ypos+42 ) ; \ + Size = MAP_APPFONT ( 75 , 10 ) ; \ + Text [ en-US ] = "~Bottom" ; \ + TabStop = TRUE ; \ +}; + +// height of RESOURCE_LEGENDPOSITION - don't forget to update when this is changed +#define RESOURCE_LEGENDPOSITION_HEIGHT 52 + +#endif diff --git a/chart2/source/controller/dialogs/res_SecondaryAxisCheckBoxes_tmpl.hrc b/chart2/source/controller/dialogs/res_SecondaryAxisCheckBoxes_tmpl.hrc new file mode 100644 index 000000000000..9d7d0e23fd02 --- /dev/null +++ b/chart2/source/controller/dialogs/res_SecondaryAxisCheckBoxes_tmpl.hrc @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_SecondaryAxisCheckBoxes_tmpl.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_SECONDARYAXISCHECKBOXES_HXX +#define _CHART2_SECONDARYAXISCHECKBOXES_HXX + +#define SECONDARYAXISCHECKBOXES_WIDTH 42 +#define SECONDARYAXISCHECKBOXES_HEIGHT 10 + +#define SECONDARYAXISCHECKBOXES( xpos, ypos, xOffset, yOffset ) \ +CheckBox CB_X_SECONDARY \ +{ \ + HelpID = HID_SCH_CB_SECONDARY_XAXIS; \ + Pos = MAP_APPFONT ( xpos , ypos ); \ + Size = MAP_APPFONT ( SECONDARYAXISCHECKBOXES_WIDTH , SECONDARYAXISCHECKBOXES_HEIGHT ); \ + TabStop = TRUE; \ + Text [ en-US ] = "X ~axis"; \ +}; \ +CheckBox CB_Y_SECONDARY \ +{ \ + HelpID = HID_SCH_CB_SECONDARY_YAXIS; \ + Pos = MAP_APPFONT ( xpos+xOffset , ypos+yOffset ); \ + Size = MAP_APPFONT ( SECONDARYAXISCHECKBOXES_WIDTH , SECONDARYAXISCHECKBOXES_HEIGHT ); \ + TabStop = TRUE; \ + Text [ en-US ] = "Y ax~is"; \ +}; \ +CheckBox CB_Z_SECONDARY \ +{ \ + HelpID = HID_SCH_CB_SECONDARY_ZAXIS; \ + Pos = MAP_APPFONT ( xpos+2*xOffset , ypos+2*yOffset ); \ + Size = MAP_APPFONT ( SECONDARYAXISCHECKBOXES_WIDTH , SECONDARYAXISCHECKBOXES_HEIGHT ); \ + TabStop = TRUE; \ + Text [ en-US ] = "Z axi~s"; \ +}; + +#endif diff --git a/chart2/source/controller/dialogs/res_TextSeparator.cxx b/chart2/source/controller/dialogs/res_TextSeparator.cxx new file mode 100644 index 000000000000..298499ed39d9 --- /dev/null +++ b/chart2/source/controller/dialogs/res_TextSeparator.cxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_TextSeparator.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_TextSeparator.hxx" +#include "ResourceIds.hrc" +#include "Strings.hrc" +#include "ResId.hxx" +#include "macros.hxx" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +TextSeparatorResources::TextSeparatorResources( Window* pWindow ) + : m_aFT_Separator( pWindow, pWindow->GetStyle() ) + , m_aLB_Separator( pWindow , SchResId( LB_TEXT_SEPARATOR ) ) + , m_aEntryMap() + , m_nDefaultPos(0) +{ + m_aFT_Separator.SetText( String( SchResId( STR_TEXT_SEPARATOR )) ); + m_aFT_Separator.SetSizePixel( m_aFT_Separator.CalcMinimumSize() ); + + m_aLB_Separator.SetDropDownLineCount(m_aLB_Separator.GetEntryCount()); + m_aLB_Separator.SetSizePixel( m_aLB_Separator.CalcMinimumSize() ); + + m_aEntryMap[ C2U( " " ) ] = 0; + m_aEntryMap[ C2U( ", " ) ] = 1; + m_aEntryMap[ C2U( "; " ) ] = 2; + m_aEntryMap[ C2U( "\n" ) ] = 3; +} +TextSeparatorResources::~TextSeparatorResources() +{ +} +void TextSeparatorResources::Show( bool bShow ) +{ + m_aFT_Separator.Show( bShow ); + m_aLB_Separator.Show( bShow ); +} +void TextSeparatorResources::Enable( bool bEnable ) +{ + m_aFT_Separator.Enable( bEnable ); + m_aLB_Separator.Enable( bEnable ); +} +void TextSeparatorResources::PositionBelowControl( const Window& rWindow ) +{ + Point aPoint( rWindow.GetPosPixel() ); + Size aSize( rWindow.GetSizePixel() ); + aPoint.Y() += aSize.Height(); + Size aBigDistanceSize( rWindow.LogicToPixel( Size(0,RSC_SP_CTRL_Y), MapMode(MAP_APPFONT) ) ); + aPoint.Y() += aBigDistanceSize.Height(); + + Size aDistanceSize( rWindow.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, (RSC_CD_DROPDOWN_HEIGHT-RSC_CD_FIXEDTEXT_HEIGHT)/2), MapMode(MAP_APPFONT) ) ); + aPoint.Y() += aDistanceSize.Height(); + + m_aFT_Separator.SetPosPixel( aPoint ); + m_aLB_Separator.SetPosPixel( Point( aPoint.X()+m_aFT_Separator.GetSizePixel().Width()+aDistanceSize.Width(), aPoint.Y()-aDistanceSize.Height()-1) ); +} + +void TextSeparatorResources::AlignListBoxWidthAndXPos( long nWantedLeftBorder /*use -1 to indicate that this can be automatic*/ + , long nWantedRightBorder /*use -1 to indicate that this can be automatic*/ + , long nMinimumListBoxWidth /*use -1 to indicate that this can be automatic*/ ) +{ + long nMinPossibleLeftBorder = m_aFT_Separator.GetPosPixel().X() + m_aFT_Separator.GetSizePixel().Width() + 1 ; + if( nWantedLeftBorder >= 0 && nWantedLeftBorder>nMinPossibleLeftBorder ) + { + Point aPos( m_aLB_Separator.GetPosPixel() ); + aPos.X() = nWantedLeftBorder; + m_aLB_Separator.SetPosPixel( aPos ); + } + + long nMinPossibleRightBorder = m_aLB_Separator.GetPosPixel().X() + m_aLB_Separator.CalcMinimumSize().Width() - 1 ; + if( nWantedRightBorder < m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth ) + nWantedRightBorder = m_aLB_Separator.GetPosPixel().X() + nMinimumListBoxWidth; + + if( nWantedRightBorder >= 0 && nWantedRightBorder > nMinPossibleRightBorder ) + { + Size aSize( m_aLB_Separator.GetSizePixel() ); + aSize.Width() = nWantedRightBorder-m_aLB_Separator.GetPosPixel().X(); + m_aLB_Separator.SetSizePixel(aSize); + } +} + +Point TextSeparatorResources::GetCurrentListBoxPosition() const +{ + return m_aLB_Separator.GetPosPixel(); +} + +Size TextSeparatorResources::GetCurrentListBoxSize() const +{ + return m_aLB_Separator.GetSizePixel(); +} + +void TextSeparatorResources::SetValue( const rtl::OUString& rSeparator ) +{ + ::std::map< ::rtl::OUString, USHORT >::iterator aIter( m_aEntryMap.find(rSeparator) ); + if( aIter == m_aEntryMap.end() ) + m_aLB_Separator.SelectEntryPos( m_nDefaultPos ); + else + m_aLB_Separator.SelectEntryPos( aIter->second ); +} + +void TextSeparatorResources::SetDefault() +{ + m_aLB_Separator.SelectEntryPos( m_nDefaultPos ); +} + +rtl::OUString TextSeparatorResources::GetValue() const +{ + USHORT nPos = m_aLB_Separator.GetSelectEntryPos(); + ::std::map< ::rtl::OUString, USHORT >::const_iterator aIter( m_aEntryMap.begin() ); + while( aIter != m_aEntryMap.end() ) + { + if(aIter->second==nPos ) + return aIter->first; + ++aIter; + } + return C2U( " " ); +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/res_TextSeparator.hxx b/chart2/source/controller/dialogs/res_TextSeparator.hxx new file mode 100644 index 000000000000..fb8365206fb5 --- /dev/null +++ b/chart2/source/controller/dialogs/res_TextSeparator.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_TextSeparator.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RES_TEXTSEPARATOR_HXX +#define CHART2_RES_TEXTSEPARATOR_HXX + +// header for class FixedText +#include <vcl/fixed.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> + +#include <map> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class TextSeparatorResources +{ +public: + TextSeparatorResources( Window* pParent ); + virtual ~TextSeparatorResources(); + + void Show( bool bShow ); + void Enable( bool bEnable ); + + void PositionBelowControl( const Window& rWindow ); + void AlignListBoxWidthAndXPos( long nWantedLeftBorder /*use -1 to indicate that this can be automatic*/ + , long nWantedRightBorder /*use -1 to indicate that this can be automatic*/ + , long nMinimumListBoxWidth /*use -1 to indicate that this can be automatic*/ ); + Point GetCurrentListBoxPosition() const; + Size GetCurrentListBoxSize() const; + + ::rtl::OUString GetValue() const; + void SetValue( const ::rtl::OUString& rSeparator ); + void SetDefault(); + +private: + FixedText m_aFT_Separator; + ListBox m_aLB_Separator; + + ::std::map< ::rtl::OUString, USHORT > m_aEntryMap; + + const USHORT m_nDefaultPos; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/res_TextSeparator.src b/chart2/source/controller/dialogs/res_TextSeparator.src new file mode 100644 index 000000000000..b3616f225a3f --- /dev/null +++ b/chart2/source/controller/dialogs/res_TextSeparator.src @@ -0,0 +1,52 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_TextSeparator.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" +#include "HelpIds.hrc" + +ListBox LB_TEXT_SEPARATOR +{ + HelpID = HID_SCH_DATALABEL_SEPARATOR; \ + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( 6 , 17 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Space" ; + "Comma" ; + "Semicolon" ; + "New line" ; + }; +}; diff --git a/chart2/source/controller/dialogs/res_Titles.cxx b/chart2/source/controller/dialogs/res_Titles.cxx new file mode 100644 index 000000000000..1ac0e4338b72 --- /dev/null +++ b/chart2/source/controller/dialogs/res_Titles.cxx @@ -0,0 +1,227 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Titles.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "res_Titles.hxx" +#include "res_Titles.hrc" +#include "ResId.hxx" +#include "TitleDialogData.hxx" + + #ifndef _SVT_CONTROLDIMS_HRC_ + #include <svtools/controldims.hrc> + #endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +TitleResources::TitleResources( Window* pWindow, bool bShowSecondaryAxesTitle ) + : m_aFT_Main(pWindow, SchResId(FT_MAINTITLE)) + , m_aEd_Main(pWindow, SchResId(ED_MAINTITLE)) + , m_aFT_Sub(pWindow, SchResId(FT_SUBTITLE)) + , m_aEd_Sub(pWindow, SchResId(ED_SUBTITLE)) + , m_aFL_Axes(pWindow, SchResId(FL_AXES)) + , m_aFT_XAxis(pWindow, SchResId(FT_TITLE_X_AXIS)) + , m_aEd_XAxis(pWindow, SchResId(ED_X_AXIS)) + , m_aFT_YAxis(pWindow, SchResId(FT_TITLE_Y_AXIS)) + , m_aEd_YAxis(pWindow, SchResId(ED_Y_AXIS)) + , m_aFT_ZAxis(pWindow, SchResId(FT_TITLE_Z_AXIS)) + , m_aEd_ZAxis(pWindow, SchResId(ED_Z_AXIS)) + , m_aFL_SecondaryAxes(pWindow, SchResId(FL_SECONDARY_AXES)) + , m_aFT_SecondaryXAxis(pWindow, SchResId(FT_TITLE_SECONDARY_X_AXIS)) + , m_aEd_SecondaryXAxis(pWindow, SchResId(ED_SECONDARY_X_AXIS)) + , m_aFT_SecondaryYAxis(pWindow, SchResId(FT_TITLE_SECONDARY_Y_AXIS)) + , m_aEd_SecondaryYAxis(pWindow, SchResId(ED_SECONDARY_Y_AXIS)) +{ + long nMaxTextWidth = ::std::max( m_aFT_Main.CalcMinimumSize().Width(),m_aFT_Sub.CalcMinimumSize().Width() ) ; + nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_XAxis.CalcMinimumSize().Width() ) ; + nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_YAxis.CalcMinimumSize().Width() ) ; + nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_ZAxis.CalcMinimumSize().Width() ) ; + if( bShowSecondaryAxesTitle ) + { + nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryXAxis.CalcMinimumSize().Width() ) ; + nMaxTextWidth = ::std::max( nMaxTextWidth, m_aFT_SecondaryYAxis.CalcMinimumSize().Width() ) ; + } + + Size aControlDistance( m_aFT_Main.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) ); + long nEditFieldXPos = m_aFT_Main.GetPosPixel().X() + nMaxTextWidth + aControlDistance.Width(); + long nEditFieldWidth = m_aEd_Main.GetPosPixel().X() + m_aEd_Main.GetSizePixel().Width() - nEditFieldXPos; + + if( nEditFieldWidth > 10 ) + { + Size aFTSize( m_aFT_Main.GetSizePixel() ); + aFTSize.Width() = nMaxTextWidth; + m_aFT_Main.SetSizePixel(aFTSize); + m_aFT_Sub.SetSizePixel(aFTSize); + m_aFT_XAxis.SetSizePixel(aFTSize); + m_aFT_YAxis.SetSizePixel(aFTSize); + m_aFT_ZAxis.SetSizePixel(aFTSize); + if( bShowSecondaryAxesTitle ) + { + m_aFT_SecondaryXAxis.SetSizePixel(aFTSize); + m_aFT_SecondaryYAxis.SetSizePixel(aFTSize); + } + + m_aEd_Main.SetPosPixel( Point( nEditFieldXPos, m_aEd_Main.GetPosPixel().Y() ) ); + m_aEd_Sub.SetPosPixel( Point( nEditFieldXPos, m_aEd_Sub.GetPosPixel().Y() ) ); + m_aEd_XAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_XAxis.GetPosPixel().Y() ) ); + m_aEd_YAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_YAxis.GetPosPixel().Y() ) ); + m_aEd_ZAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_ZAxis.GetPosPixel().Y() ) ); + if(bShowSecondaryAxesTitle) + { + m_aEd_SecondaryXAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryXAxis.GetPosPixel().Y() ) ); + m_aEd_SecondaryYAxis.SetPosPixel( Point( nEditFieldXPos, m_aEd_SecondaryYAxis.GetPosPixel().Y() ) ); + } + + Size aEditSize( m_aEd_Main.GetSizePixel() ); + aEditSize.Width() = nEditFieldWidth; + m_aEd_Main.SetSizePixel( aEditSize ); + m_aEd_Sub.SetSizePixel( aEditSize ); + m_aEd_XAxis.SetSizePixel( aEditSize ); + m_aEd_YAxis.SetSizePixel( aEditSize ); + m_aEd_ZAxis.SetSizePixel( aEditSize ); + if(bShowSecondaryAxesTitle) + { + m_aEd_SecondaryXAxis.SetSizePixel( aEditSize ); + m_aEd_SecondaryYAxis.SetSizePixel( aEditSize ); + } + } + + m_aFT_SecondaryXAxis.Show( bShowSecondaryAxesTitle ); + m_aEd_SecondaryXAxis.Show( bShowSecondaryAxesTitle ); + m_aFT_SecondaryYAxis.Show( bShowSecondaryAxesTitle ); + m_aEd_SecondaryYAxis.Show( bShowSecondaryAxesTitle ); +} + +TitleResources::~TitleResources() +{ +} + +void TitleResources::SetUpdateDataHdl( const Link& rLink ) +{ + ULONG nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; + + m_aEd_Main.EnableUpdateData( nTimeout ); + m_aEd_Main.SetUpdateDataHdl( rLink ); + + m_aEd_Sub.EnableUpdateData( nTimeout ); + m_aEd_Sub.SetUpdateDataHdl( rLink ); + + m_aEd_XAxis.EnableUpdateData( nTimeout ); + m_aEd_XAxis.SetUpdateDataHdl( rLink ); + + m_aEd_YAxis.EnableUpdateData( nTimeout ); + m_aEd_YAxis.SetUpdateDataHdl( rLink ); + + m_aEd_ZAxis.EnableUpdateData( nTimeout ); + m_aEd_ZAxis.SetUpdateDataHdl( rLink ); + + m_aEd_SecondaryXAxis.EnableUpdateData( nTimeout ); + m_aEd_SecondaryXAxis.SetUpdateDataHdl( rLink ); + + m_aEd_SecondaryYAxis.EnableUpdateData( nTimeout ); + m_aEd_SecondaryYAxis.SetUpdateDataHdl( rLink ); +} + +bool TitleResources::IsModified() +{ + return m_aEd_Main.IsModified() + || m_aEd_Sub.IsModified() + || m_aEd_XAxis.IsModified() + || m_aEd_YAxis.IsModified() + || m_aEd_ZAxis.IsModified() + || m_aEd_SecondaryXAxis.IsModified() + || m_aEd_SecondaryYAxis.IsModified(); +} + +void TitleResources::ClearModifyFlag() +{ + m_aEd_Main.ClearModifyFlag(); + m_aEd_Sub.ClearModifyFlag(); + m_aEd_XAxis.ClearModifyFlag(); + m_aEd_YAxis.ClearModifyFlag(); + m_aEd_ZAxis.ClearModifyFlag(); + m_aEd_SecondaryXAxis.ClearModifyFlag(); + m_aEd_SecondaryYAxis.ClearModifyFlag(); +} + +void TitleResources::writeToResources( const TitleDialogData& rInput ) +{ + m_aFT_Main.Enable( rInput.aPossibilityList[0] ); + m_aFT_Sub.Enable( rInput.aPossibilityList[1] ); + m_aFT_XAxis.Enable( rInput.aPossibilityList[2] ); + m_aFT_YAxis.Enable( rInput.aPossibilityList[3] ); + m_aFT_ZAxis.Enable( rInput.aPossibilityList[4] ); + m_aFT_SecondaryXAxis.Enable( rInput.aPossibilityList[5] ); + m_aFT_SecondaryYAxis.Enable( rInput.aPossibilityList[6] ); + + m_aEd_Main.Enable( rInput.aPossibilityList[0] ); + m_aEd_Sub.Enable( rInput.aPossibilityList[1] ); + m_aEd_XAxis.Enable( rInput.aPossibilityList[2] ); + m_aEd_YAxis.Enable( rInput.aPossibilityList[3] ); + m_aEd_ZAxis.Enable( rInput.aPossibilityList[4] ); + m_aEd_SecondaryXAxis.Enable( rInput.aPossibilityList[5] ); + m_aEd_SecondaryYAxis.Enable( rInput.aPossibilityList[6] ); + + m_aEd_Main.SetText(rInput.aTextList[0]); + m_aEd_Sub.SetText(rInput.aTextList[1]); + m_aEd_XAxis.SetText(rInput.aTextList[2]); + m_aEd_YAxis.SetText(rInput.aTextList[3]); + m_aEd_ZAxis.SetText(rInput.aTextList[4]); + m_aEd_SecondaryXAxis.SetText(rInput.aTextList[5]); + m_aEd_SecondaryYAxis.SetText(rInput.aTextList[6]); +} + +void TitleResources::readFromResources( TitleDialogData& rOutput ) +{ + rOutput.aExistenceList[0] = static_cast<sal_Bool>(m_aEd_Main.GetText().Len()!=0); + rOutput.aExistenceList[1] = static_cast<sal_Bool>(m_aEd_Sub.GetText().Len()!=0); + rOutput.aExistenceList[2] = static_cast<sal_Bool>(m_aEd_XAxis.GetText().Len()!=0); + rOutput.aExistenceList[3] = static_cast<sal_Bool>(m_aEd_YAxis.GetText().Len()!=0); + rOutput.aExistenceList[4] = static_cast<sal_Bool>(m_aEd_ZAxis.GetText().Len()!=0); + rOutput.aExistenceList[5] = static_cast<sal_Bool>(m_aEd_SecondaryXAxis.GetText().Len()!=0); + rOutput.aExistenceList[6] = static_cast<sal_Bool>(m_aEd_SecondaryYAxis.GetText().Len()!=0); + + rOutput.aTextList[0] = m_aEd_Main.GetText(); + rOutput.aTextList[1] = m_aEd_Sub.GetText(); + rOutput.aTextList[2] = m_aEd_XAxis.GetText(); + rOutput.aTextList[3] = m_aEd_YAxis.GetText(); + rOutput.aTextList[4] = m_aEd_ZAxis.GetText(); + rOutput.aTextList[5] = m_aEd_SecondaryXAxis.GetText(); + rOutput.aTextList[6] = m_aEd_SecondaryYAxis.GetText(); +} + +//............................................................................. +} //namespace chart +//............................................................................. + diff --git a/chart2/source/controller/dialogs/res_Titles.hrc b/chart2/source/controller/dialogs/res_Titles.hrc new file mode 100644 index 000000000000..7bc3f83685bb --- /dev/null +++ b/chart2/source/controller/dialogs/res_Titles.hrc @@ -0,0 +1,50 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Titles.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RES_TITLES_HRC +#define _CHART2_RES_TITLES_HRC + +#define ED_MAINTITLE 1 +#define ED_SUBTITLE 2 +#define ED_X_AXIS 3 +#define ED_Y_AXIS 4 +#define ED_Z_AXIS 5 +#define ED_SECONDARY_X_AXIS 6 +#define ED_SECONDARY_Y_AXIS 7 +#define FT_MAINTITLE 1 +#define FT_SUBTITLE 2 +#define FT_TITLE_X_AXIS 3 +#define FT_TITLE_Y_AXIS 4 +#define FT_TITLE_Z_AXIS 5 +#define FT_TITLE_SECONDARY_X_AXIS 6 +#define FT_TITLE_SECONDARY_Y_AXIS 7 +#define FL_AXES 1 +#define FL_SECONDARY_AXES 2 + +#endif diff --git a/chart2/source/controller/dialogs/res_Titles.hxx b/chart2/source/controller/dialogs/res_Titles.hxx new file mode 100644 index 000000000000..63771b821ca1 --- /dev/null +++ b/chart2/source/controller/dialogs/res_Titles.hxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Titles.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RES_TITLES_HXX +#define _CHART2_RES_TITLES_HXX + +#include "TitleDialogData.hxx" +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class TitleResources +{ +public: + TitleResources( Window* pParent, bool bShowSecondaryAxesTitle ); + virtual ~TitleResources(); + + void writeToResources( const TitleDialogData& rInput ); + void readFromResources( TitleDialogData& rOutput ); + + void SetUpdateDataHdl( const Link& rLink ); + bool IsModified(); + void ClearModifyFlag(); + +private: + FixedText m_aFT_Main; + Edit m_aEd_Main; + FixedText m_aFT_Sub; + Edit m_aEd_Sub; + + FixedLine m_aFL_Axes; + FixedText m_aFT_XAxis; + Edit m_aEd_XAxis; + FixedText m_aFT_YAxis; + Edit m_aEd_YAxis; + FixedText m_aFT_ZAxis; + Edit m_aEd_ZAxis; + + FixedLine m_aFL_SecondaryAxes; + FixedText m_aFT_SecondaryXAxis; + Edit m_aEd_SecondaryXAxis; + FixedText m_aFT_SecondaryYAxis; + Edit m_aEd_SecondaryYAxis; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/res_Titlesx_tmpl.hrc b/chart2/source/controller/dialogs/res_Titlesx_tmpl.hrc new file mode 100644 index 000000000000..8e305cd95c21 --- /dev/null +++ b/chart2/source/controller/dialogs/res_Titlesx_tmpl.hrc @@ -0,0 +1,152 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Titlesx_tmpl.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RES_TITLES_SRC +#define _CHART2_RES_TITLES_SRC + +#include "res_Titles.hrc" +#include "HelpIds.hrc" + +#define TITLES_HEIGHT 12 +#define indentLabel 3 +#define fixedLinesHeight RSC_CD_FIXEDLINE_HEIGHT + +#define TITLES( xpos, ypos, availableWidth, indentLabel, fixedLinesHeight ) \ +Edit ED_MAINTITLE \ +{ \ + HelpID = HID_SCH_TITLE_MAIN; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_SUBTITLE \ +{ \ + HelpID = HID_SCH_TITLE_SUB; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+TITLES_HEIGHT+4 ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_X_AXIS \ +{ \ + HelpID = HID_SCH_TITLE_X; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+2*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_Y_AXIS \ +{ \ + HelpID = HID_SCH_TITLE_Y; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+3*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_Z_AXIS \ +{ \ + HelpID = HID_SCH_TITLE_Z; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+4*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_SECONDARY_X_AXIS \ +{ \ + HelpID = HID_SCH_TITLE_SECONDARY_X; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+5*(TITLES_HEIGHT+4)+8+2*(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +Edit ED_SECONDARY_Y_AXIS \ +{ \ + HelpID = HID_SCH_TITLE_SECONDARY_Y; \ + Border = TRUE ; \ + Pos = MAP_APPFONT ( xpos+indentLabel+(availableWidth-2*indentLabel-4)/2+4 , ypos+6*(TITLES_HEIGHT+4)+8+2*(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + TabStop = TRUE ; \ +}; \ +FixedText FT_MAINTITLE \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2 ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "~Title" ; \ +}; \ +FixedText FT_SUBTITLE \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+TITLES_HEIGHT+4 ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "~Subtitle" ; \ +}; \ +FixedLine FL_AXES \ +{ \ + Pos = MAP_APPFONT( xpos ,ypos+2+2*(TITLES_HEIGHT+4)+0 ); \ + Size = MAP_APPFONT( availableWidth ,fixedLinesHeight ); \ + Text[ en-US ] = "Axes"; \ +}; \ +FixedText FT_TITLE_X_AXIS \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+2*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "~X axis" ; \ +}; \ +FixedText FT_TITLE_Y_AXIS \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+3*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "~Y axis" ; \ +}; \ +FixedText FT_TITLE_Z_AXIS \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+4*(TITLES_HEIGHT+4)+4+(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "~Z axis" ; \ +}; \ +FixedLine FL_SECONDARY_AXES \ +{ \ + Pos = MAP_APPFONT( xpos ,ypos+2+5*(TITLES_HEIGHT+4)+3+(fixedLinesHeight+3) ); \ + Size = MAP_APPFONT( availableWidth ,fixedLinesHeight ); \ + Text[ en-US ] = "Secondary Axes"; \ +}; \ +FixedText FT_TITLE_SECONDARY_X_AXIS \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+5*(TITLES_HEIGHT+4)+8+2*(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "X ~axis" ; \ +}; \ +FixedText FT_TITLE_SECONDARY_Y_AXIS \ +{ \ + Pos = MAP_APPFONT ( xpos+indentLabel , ypos+2+6*(TITLES_HEIGHT+4)+8+2*(fixedLinesHeight+3) ) ; \ + Size = MAP_APPFONT ( (availableWidth-2*indentLabel-4)/2 , TITLES_HEIGHT ) ; \ + Text [ en-US ] = "Y ax~is" ; \ +}; + +#endif diff --git a/chart2/source/controller/dialogs/res_Trendline.cxx b/chart2/source/controller/dialogs/res_Trendline.cxx new file mode 100644 index 000000000000..b53df44463a6 --- /dev/null +++ b/chart2/source/controller/dialogs/res_Trendline.cxx @@ -0,0 +1,285 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Trendline.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "dlg_InsertTrendline.hrc" +#include "res_Trendline.hxx" +#include "res_Trendline_IDs.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "chartview/ChartSfxItemIds.hxx" + +#include <vector> +#include <algorithm> + +// macro for selecting a normal or high contrast bitmap the stack variable +// bIsHighContrast must exist and reflect the correct state +#define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name )) + +namespace +{ +template< class T > + long lcl_getRightEdge( T & rControl ) +{ + return rControl.CalcMinimumSize().Width() + rControl.GetPosPixel().X() - rControl.GetParent()->GetPosPixel().X(); +} + +template< class T > + void lcl_AdjustControlSize( T & rControl ) +{ + Size aSize( rControl.GetSizePixel()); + aSize.setWidth( rControl.CalcMinimumSize().Width()); + rControl.SetSizePixel( aSize ); +} + +void lcl_AdjustControlSize( Control & rControl, long nRightEdge ) +{ + Size aSize( rControl.GetSizePixel()); + Point aPosition( rControl.GetPosPixel()); + aSize.setWidth( nRightEdge - aPosition.getX()); + rControl.SetSizePixel( aSize ); +} + +} // anonymous namespace + +namespace chart +{ + +enum StatTrendLine +{ + TRENDLINE_NONE, + TRENDLINE_LINE, + TRENDLINE_LOG, + TRENDLINE_EXP, + TRENDLINE_POW +}; + +TrendlineResources::TrendlineResources( Window * pParent, const SfxItemSet& rInAttrs, bool bNoneAvailable ) : + m_aFLType( pParent, SchResId( FL_TYPE )), + + m_aRBNone( pParent, SchResId( RB_NONE )), + m_aRBLinear( pParent, SchResId( RB_LINEAR )), + m_aRBLogarithmic( pParent, SchResId( RB_LOGARITHMIC )), + m_aRBExponential( pParent, SchResId( RB_EXPONENTIAL )), + m_aRBPower( pParent, SchResId( RB_POWER )), + + m_aFINone( pParent, SchResId( FI_NONE )), + m_aFILinear( pParent, SchResId( FI_LINEAR )), + m_aFILogarithmic( pParent, SchResId( FI_LOGARITHMIC )), + m_aFIExponential( pParent, SchResId( FI_EXPONENTIAL )), + m_aFIPower( pParent, SchResId( FI_POWER )), + + m_aFLEquation( pParent, SchResId( FL_EQUATION )), + m_aCBShowEquation( pParent, SchResId( CB_SHOW_EQUATION )), + m_aCBShowCorrelationCoeff( pParent, SchResId( CB_SHOW_CORRELATION_COEFF )), + m_eTrendLineType( CHREGRESS_NONE ), + m_bNoneAvailable( bNoneAvailable ), + m_bTrendLineUnique( true ) +{ + FillValueSets(); + + if( m_bNoneAvailable ) + m_aRBNone.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + else + m_aRBNone.Hide(); + + m_aRBLinear.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + m_aRBLogarithmic.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + m_aRBExponential.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + m_aRBPower.SetClickHdl( LINK(this, TrendlineResources, SelectTrendLine )); + + Reset( rInAttrs ); + UpdateControlStates(); +} + +TrendlineResources::~TrendlineResources() +{} + +long TrendlineResources::adjustControlSizes() +{ + // calculate right edge + ::std::vector< long > aControlRightEdges; + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBNone )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBLinear )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBLogarithmic )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBExponential )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aRBPower )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowEquation )); + aControlRightEdges.push_back( lcl_getRightEdge( m_aCBShowCorrelationCoeff )); + + lcl_AdjustControlSize( m_aRBNone ); + lcl_AdjustControlSize( m_aRBLinear ); + lcl_AdjustControlSize( m_aRBLogarithmic ); + lcl_AdjustControlSize( m_aRBExponential ); + lcl_AdjustControlSize( m_aRBPower ); + lcl_AdjustControlSize( m_aCBShowEquation ); + lcl_AdjustControlSize( m_aCBShowCorrelationCoeff ); + + // Note: FixedLine has no CalcMinimumSize, workaround: use a FixedText + FixedText aDummyTextCtrl( m_aFLType.GetParent()); + aDummyTextCtrl.SetText( m_aFLType.GetText()); + aControlRightEdges.push_back( lcl_getRightEdge( aDummyTextCtrl )); + aDummyTextCtrl.SetText( m_aFLEquation.GetText()); + aControlRightEdges.push_back( lcl_getRightEdge( aDummyTextCtrl )); + + long nRightEdgeOfControls = *(::std::max_element( aControlRightEdges.begin(), aControlRightEdges.end())); + // leave some more space after the longest text + nRightEdgeOfControls += m_aFLType.LogicToPixel( Size( 6, 0 ), MapMode( MAP_APPFONT )).getWidth(); + + lcl_AdjustControlSize( m_aFLType, nRightEdgeOfControls ); + lcl_AdjustControlSize( m_aFLEquation, nRightEdgeOfControls ); + + return nRightEdgeOfControls; +} + +IMPL_LINK( TrendlineResources, SelectTrendLine, RadioButton *, pRadioButton ) +{ + if( pRadioButton == &m_aRBLinear ) + m_eTrendLineType = CHREGRESS_LINEAR; + else if( pRadioButton == &m_aRBLogarithmic ) + m_eTrendLineType = CHREGRESS_LOG; + else if( pRadioButton == &m_aRBExponential ) + m_eTrendLineType = CHREGRESS_EXP; + else if( pRadioButton == &m_aRBPower ) + m_eTrendLineType = CHREGRESS_POWER; + else if( pRadioButton == &m_aRBNone ) + { + OSL_ASSERT( m_bNoneAvailable ); + m_eTrendLineType = CHREGRESS_NONE; + } + m_bTrendLineUnique = true; + + UpdateControlStates(); + + return 0; +} + +void TrendlineResources::Reset( const SfxItemSet& rInAttrs ) +{ + const SfxPoolItem *pPoolItem = NULL; + SfxItemState aState = SFX_ITEM_UNKNOWN; + + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_TYPE, TRUE, &pPoolItem ); + m_bTrendLineUnique = ( aState != SFX_ITEM_DONTCARE ); + if( aState == SFX_ITEM_SET ) + { + const SvxChartRegressItem * pItem = dynamic_cast< const SvxChartRegressItem * >( pPoolItem ); + if( pItem ) + m_eTrendLineType = pItem->GetValue(); + } + + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_EQUATION, TRUE, &pPoolItem ); + if( aState == SFX_ITEM_DONTCARE ) + { + m_aCBShowEquation.EnableTriState( TRUE ); + m_aCBShowEquation.SetState( STATE_DONTKNOW ); + } + else + { + m_aCBShowEquation.EnableTriState( FALSE ); + if( aState == SFX_ITEM_SET ) + m_aCBShowEquation.Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); + } + + aState = rInAttrs.GetItemState( SCHATTR_REGRESSION_SHOW_COEFF, TRUE, &pPoolItem ); + if( aState == SFX_ITEM_DONTCARE ) + { + m_aCBShowCorrelationCoeff.EnableTriState( TRUE ); + m_aCBShowCorrelationCoeff.SetState( STATE_DONTKNOW ); + } + else + { + m_aCBShowCorrelationCoeff.EnableTriState( FALSE ); + if( aState == SFX_ITEM_SET ) + m_aCBShowCorrelationCoeff.Check( static_cast< const SfxBoolItem * >( pPoolItem )->GetValue()); + } + + if( m_bTrendLineUnique ) + { + switch( m_eTrendLineType ) + { + case CHREGRESS_LINEAR : + m_aRBLinear.Check(); + break; + case CHREGRESS_LOG : + m_aRBLogarithmic.Check(); + break; + case CHREGRESS_EXP : + m_aRBExponential.Check(); + break; + case CHREGRESS_POWER : + m_aRBPower.Check(); + break; + case CHREGRESS_NONE: + OSL_ASSERT( m_bNoneAvailable ); + m_aRBNone.Check(); + break; + } + } +} + +BOOL TrendlineResources::FillItemSet(SfxItemSet& rOutAttrs) const +{ + if( m_bTrendLineUnique ) + rOutAttrs.Put( SvxChartRegressItem( m_eTrendLineType, SCHATTR_REGRESSION_TYPE )); + if( m_aCBShowEquation.GetState() != STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_EQUATION, m_aCBShowEquation.IsChecked() )); + if( m_aCBShowCorrelationCoeff.GetState() != STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_REGRESSION_SHOW_COEFF, m_aCBShowCorrelationCoeff.IsChecked() )); + return TRUE; +} + +void TrendlineResources::FillValueSets() +{ + bool bIsHighContrast = ( true && m_aFLType.GetSettings().GetStyleSettings().GetHighContrastMode() ); + + if( m_bNoneAvailable ) + m_aFINone.SetImage( SELECT_IMAGE( BMP_REGRESSION_NONE )); + m_aFILinear.SetImage( SELECT_IMAGE( BMP_REGRESSION_LINEAR )); + m_aFILogarithmic.SetImage( SELECT_IMAGE( BMP_REGRESSION_LOG )); + m_aFIExponential.SetImage( SELECT_IMAGE( BMP_REGRESSION_EXP )); + m_aFIPower.SetImage( SELECT_IMAGE( BMP_REGRESSION_POWER )); +} + +void TrendlineResources::UpdateControlStates() +{ + if( m_bNoneAvailable ) + { + bool bEnableEquationControls = !m_bTrendLineUnique || (m_eTrendLineType != CHREGRESS_NONE); + m_aCBShowEquation.Enable( bEnableEquationControls ); + m_aCBShowCorrelationCoeff.Enable( bEnableEquationControls ); + } +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/res_Trendline.hxx b/chart2/source/controller/dialogs/res_Trendline.hxx new file mode 100644 index 000000000000..e1becbf8631f --- /dev/null +++ b/chart2/source/controller/dialogs/res_Trendline.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Trendline.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RES_TRENDLINE_HXX +#define CHART2_RES_TRENDLINE_HXX + +#include <vcl/window.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <svtools/valueset.hxx> +#include <svtools/itemset.hxx> +#include <svx/chrtitem.hxx> + +namespace chart +{ + +class TrendlineResources +{ +public: + TrendlineResources( Window* pParent, const SfxItemSet& rInAttrs, bool bNoneAvailable ); + virtual ~TrendlineResources(); + + void Reset(const SfxItemSet& rInAttrs); + BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + + void FillValueSets(); + + long adjustControlSizes(); + +private: + FixedLine m_aFLType; + RadioButton m_aRBNone; + RadioButton m_aRBLinear; + RadioButton m_aRBLogarithmic; + RadioButton m_aRBExponential; + RadioButton m_aRBPower; + + FixedImage m_aFINone; + FixedImage m_aFILinear; + FixedImage m_aFILogarithmic; + FixedImage m_aFIExponential; + FixedImage m_aFIPower; + + FixedLine m_aFLEquation; + CheckBox m_aCBShowEquation; + CheckBox m_aCBShowCorrelationCoeff; + + SvxChartRegress m_eTrendLineType; + + bool m_bNoneAvailable; + bool m_bTrendLineUnique; + + void UpdateControlStates(); + DECL_LINK( SelectTrendLine, RadioButton * ); +}; + +} // namespace chart + +// CHART2_RES_TRENDLINE_HXX +#endif diff --git a/chart2/source/controller/dialogs/res_Trendline_IDs.hrc b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc new file mode 100644 index 000000000000..4bb318bfa7ee --- /dev/null +++ b/chart2/source/controller/dialogs/res_Trendline_IDs.hrc @@ -0,0 +1,47 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Trendline_IDs.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#define FL_TYPE 1 +#define FL_EQUATION 2 + +#define FI_NONE 1 +#define FI_LINEAR 2 +#define FI_LOGARITHMIC 3 +#define FI_EXPONENTIAL 4 +#define FI_POWER 5 + +#define RB_NONE 1 +#define RB_LINEAR 2 +#define RB_LOGARITHMIC 3 +#define RB_EXPONENTIAL 4 +#define RB_POWER 5 + +#define CB_SHOW_EQUATION 1 +#define CB_SHOW_CORRELATION_COEFF 2 diff --git a/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc new file mode 100644 index 000000000000..45fc55435594 --- /dev/null +++ b/chart2/source/controller/dialogs/res_Trendline_tmpl.hrc @@ -0,0 +1,126 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_Trendline_tmpl.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_RESOURCE_TRENDLINE_HXX +#define _CHART2_RESOURCE_TRENDLINE_HXX + +#include "res_Trendline_IDs.hrc" +#include "HelpIds.hrc" + +#define RESOURCE_TRENDLINE(availablewidth, yoffset) \ +FixedLine FL_TYPE \ +{ \ + Pos = MAP_APPFONT( 6 ,6 ); \ + Size = MAP_APPFONT( availablewidth - 12 ,8 ); \ + Text[ en-US ] = "Regression Type"; \ +}; \ +RadioButton RB_NONE \ +{ \ + HelpId = HID_SCH_TRENDLINE_RB_NONE; \ + Pos = MAP_APPFONT( 29, 22 ); \ + Size = MAP_APPFONT( 100, 10 ); \ + Text[ en-US ] = "~None"; \ +}; \ +RadioButton RB_LINEAR \ +{ \ + HelpId = HID_SCH_TRENDLINE_RB_LINEAR; \ + Pos = MAP_APPFONT( 29, 22 + yoffset ); \ + Size = MAP_APPFONT( 100, 10 ); \ + Text[ en-US ] = "~Linear"; \ +}; \ +RadioButton RB_LOGARITHMIC \ +{ \ + HelpId = HID_SCH_TRENDLINE_RB_LOGARITHMIC; \ + Pos = MAP_APPFONT( 29, 44 + yoffset ); \ + Size = MAP_APPFONT( 100, 10 ); \ + Text[ en-US ] = "L~ogarithmic"; \ +}; \ +RadioButton RB_EXPONENTIAL \ +{ \ + HelpId = HID_SCH_TRENDLINE_RB_EXPONENTIAL; \ + Pos = MAP_APPFONT( 29, 66 + yoffset ); \ + Size = MAP_APPFONT( 100, 10 ); \ + Text[ en-US ] = "E~xponential"; \ +}; \ +RadioButton RB_POWER \ +{ \ + HelpId = HID_SCH_TRENDLINE_RB_POWER; \ + Pos = MAP_APPFONT( 29, 88 + yoffset ); \ + Size = MAP_APPFONT( 100, 10 ); \ + Text[ en-US ] = "~Power"; \ +}; \ +FixedImage FI_NONE \ +{ \ + Pos = MAP_APPFONT( 10, 18 ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedImage FI_LINEAR \ +{ \ + Pos = MAP_APPFONT( 10, 18 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedImage FI_LOGARITHMIC \ +{ \ + Pos = MAP_APPFONT( 10, 40 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedImage FI_EXPONENTIAL \ +{ \ + Pos = MAP_APPFONT( 10, 62 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedImage FI_POWER \ +{ \ + Pos = MAP_APPFONT( 10, 84 + yoffset ); \ + Size = MAP_APPFONT( 18, 18 ); \ +}; \ +FixedLine FL_EQUATION \ +{ \ + Pos = MAP_APPFONT( 6, 108 + yoffset ); \ + Size = MAP_APPFONT( availablewidth - 12, 8 ); \ + Text[ en-US ] = "Equation"; \ +}; \ +CheckBox CB_SHOW_EQUATION \ +{ \ + HelpId = HID_SCH_TRENDLINE_SHOW_EQUATION; \ + Pos = MAP_APPFONT( 10, 120 + yoffset ); \ + Size = MAP_APPFONT( availablewidth - 20, 10 ); \ + TabStop = TRUE; \ + Text[ en-US ] = "Show ~equation"; \ +}; \ +CheckBox CB_SHOW_CORRELATION_COEFF \ +{ \ + HelpId = HID_SCH_TRENDLINE_SHOW_R_SQUARED; \ + Pos = MAP_APPFONT( 10, 134 + yoffset ); \ + Size = MAP_APPFONT( availablewidth - 20, 10 ); \ + TabStop = TRUE; \ + Text[ en-US ] = "Show ~coefficient of determination (R²)"; \ +}; + +#endif diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx new file mode 100644 index 000000000000..61911a23dc3d --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.cxx @@ -0,0 +1,366 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneAppearance.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_3D_SceneAppearance.hxx" +#include "tp_3D_SceneAppearance.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "NoWarningThisInCTOR.hxx" +#include "ChartModelHelper.hxx" +#include "ThreeDHelper.hxx" +#include "macros.hxx" +#include <rtl/math.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +using namespace ::com::sun::star; + +namespace +{ + +struct lcl_ModelProperties +{ + drawing::ShadeMode m_aShadeMode; + sal_Int32 m_nRoundedEdges; + sal_Int32 m_nObjectLines; + ::chart::ThreeDLookScheme m_eScheme; + + lcl_ModelProperties() : + m_nRoundedEdges(-1), + m_nObjectLines(-1), + m_eScheme(::chart::ThreeDLookScheme_Unknown) + {} +}; + +lcl_ModelProperties lcl_getPropertiesFromModel( uno::Reference< frame::XModel > & 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( C2U("D3DSceneShadeMode")) >>= aProps.m_aShadeMode; + ::chart::ThreeDHelper::getRoundedEdgesAndObjectLines( xDiagram, aProps.m_nRoundedEdges, aProps.m_nObjectLines ); + aProps.m_eScheme = ::chart::ThreeDHelper::detectScheme( xDiagram ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + return aProps; +} + +void lcl_setShadeModeAtModel( uno::Reference< frame::XModel > & xModel, drawing::ShadeMode aShadeMode ) +{ + try + { + uno::Reference< beans::XPropertySet > xDiaProp( + ::chart::ChartModelHelper::findDiagram( xModel ), uno::UNO_QUERY_THROW ); + xDiaProp->setPropertyValue( C2U("D3DSceneShadeMode"), uno::makeAny( aShadeMode )); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +} // anonymous namespace + +//............................................................................. +namespace chart +{ +//............................................................................. + +#define POS_3DSCHEME_SIMPLE 0 +#define POS_3DSCHEME_REALISTIC 1 +#define POS_3DSCHEME_CUSTOM 2 + +ThreeD_SceneAppearance_TabPage::ThreeD_SceneAppearance_TabPage( + Window* pWindow + , const uno::Reference< frame::XModel > & xChartModel + , ControllerLockHelper & rControllerLockHelper ) + : TabPage ( pWindow, SchResId( TP_3D_SCENEAPPEARANCE ) ) + , m_xChartModel ( xChartModel ) + , m_aFT_Scheme ( this, SchResId( FT_SCHEME ) ) + , m_aLB_Scheme ( this, SchResId( LB_SCHEME ) ) + , m_aFL_Seperator ( this, SchResId( FL_SEPERATOR ) ) + , m_aCB_RoundedEdge ( this, SchResId( CB_ROUNDEDEDGE ) ) + , m_aCB_Shading ( this, SchResId( CB_SHADING ) ) + , m_aCB_ObjectLines ( this, SchResId( CB_OBJECTLINES ) ) + , m_bUpdateOtherControls( true ) + , m_bCommitToModel( true ) + , m_rControllerLockHelper( rControllerLockHelper ) +{ + FreeResource(); + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_SIMPLE)),POS_3DSCHEME_SIMPLE); + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_REALISTIC)),POS_3DSCHEME_REALISTIC); + m_aLB_Scheme.SetDropDownLineCount(2); + + m_aLB_Scheme.SetSelectHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectSchemeHdl ) ); + + m_aCB_RoundedEdge.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); + m_aCB_Shading.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectShading ) ); + m_aCB_ObjectLines.SetToggleHdl( LINK( this, ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines ) ); + + m_aCB_RoundedEdge.EnableTriState( TRUE ); + m_aCB_Shading.EnableTriState( TRUE ); + m_aCB_ObjectLines.EnableTriState( TRUE ); + + initControlsFromModel(); +} + +ThreeD_SceneAppearance_TabPage::~ThreeD_SceneAppearance_TabPage() +{} + +void ThreeD_SceneAppearance_TabPage::ActivatePage() +{ + updateScheme(); +} + +void ThreeD_SceneAppearance_TabPage::commitPendingChanges() +{ +} + +void ThreeD_SceneAppearance_TabPage::applyRoundedEdgeAndObjectLinesToModel() +{ + if(!m_bCommitToModel) + return; + + sal_Int32 nObjectLines = -1; + + switch( m_aCB_ObjectLines.GetState()) + { + case STATE_NOCHECK: + nObjectLines = 0; + break; + case STATE_CHECK: + nObjectLines = 1; + break; + case STATE_DONTKNOW: + nObjectLines = -1; + break; + } + + sal_Int32 nCurrentRoundedEdges = -1; + switch( m_aCB_RoundedEdge.GetState() ) + { + case STATE_NOCHECK: + nCurrentRoundedEdges = 0; + break; + case STATE_CHECK: + nCurrentRoundedEdges = 5; + break; + case STATE_DONTKNOW: + nCurrentRoundedEdges = -1; + break; + } + + // /-- locked controllers + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + ThreeDHelper::setRoundedEdgesAndObjectLines( + ::chart::ChartModelHelper::findDiagram( m_xChartModel ), nCurrentRoundedEdges, nObjectLines ); + // \-- locked controllers +} + +void ThreeD_SceneAppearance_TabPage::applyShadeModeToModel() +{ + if(!m_bCommitToModel) + return; + + drawing::ShadeMode aShadeMode = drawing::ShadeMode_PHONG; + + switch( m_aCB_Shading.GetState()) + { + case STATE_NOCHECK: + aShadeMode = drawing::ShadeMode_FLAT; + break; + case STATE_CHECK: + aShadeMode = drawing::ShadeMode_SMOOTH; + break; + case STATE_DONTKNOW: + // nothing + break; + } + + lcl_setShadeModeAtModel( m_xChartModel, aShadeMode ); +} + +void ThreeD_SceneAppearance_TabPage::initControlsFromModel() +{ + m_bCommitToModel = false; + m_bUpdateOtherControls = false; + + lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel )); + + if(aProps.m_aShadeMode == drawing::ShadeMode_FLAT) + { + m_aCB_Shading.EnableTriState( FALSE ); + m_aCB_Shading.Check(FALSE); + } + else if(aProps.m_aShadeMode == drawing::ShadeMode_SMOOTH) + { + m_aCB_Shading.EnableTriState( FALSE ); + m_aCB_Shading.Check(TRUE); + } + else + { + m_aCB_Shading.EnableTriState( TRUE ); + m_aCB_Shading.SetState( STATE_DONTKNOW ); + } + + if(aProps.m_nObjectLines == 0) + { + m_aCB_ObjectLines.EnableTriState( FALSE ); + m_aCB_ObjectLines.Check(FALSE); + } + else if(aProps.m_nObjectLines==1) + { + m_aCB_ObjectLines.EnableTriState( FALSE ); + m_aCB_ObjectLines.Check(TRUE); + } + else + { + m_aCB_ObjectLines.EnableTriState( TRUE ); + m_aCB_ObjectLines.SetState( STATE_DONTKNOW ); + } + + if(aProps.m_nRoundedEdges >= 5) + { + m_aCB_RoundedEdge.EnableTriState( FALSE ); + m_aCB_RoundedEdge.Check(TRUE); + } + else if(aProps.m_nRoundedEdges<0) + { + m_aCB_RoundedEdge.EnableTriState( FALSE ); + m_aCB_RoundedEdge.SetState( STATE_DONTKNOW ); + } + else + { + m_aCB_RoundedEdge.EnableTriState( TRUE ); + m_aCB_RoundedEdge.Check(FALSE); + } + m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); + + updateScheme(); + + m_bCommitToModel = true; + m_bUpdateOtherControls = true; +} + +void ThreeD_SceneAppearance_TabPage::updateScheme() +{ + lcl_ModelProperties aProps( lcl_getPropertiesFromModel( m_xChartModel )); + + if( m_aLB_Scheme.GetEntryCount() == (POS_3DSCHEME_CUSTOM+1) ) + { + m_aLB_Scheme.RemoveEntry(POS_3DSCHEME_CUSTOM); + m_aLB_Scheme.SetDropDownLineCount(2); + } + switch( aProps.m_eScheme ) + { + case ThreeDLookScheme_Simple: + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_SIMPLE ); + break; + case ThreeDLookScheme_Realistic: + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_REALISTIC ); + break; + case ThreeDLookScheme_Unknown: + { + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_CUSTOM)),POS_3DSCHEME_CUSTOM); + m_aLB_Scheme.SelectEntryPos( POS_3DSCHEME_CUSTOM ); + m_aLB_Scheme.SetDropDownLineCount(3); + } + break; + } +} + +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectSchemeHdl, void*, EMPTYARG ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + { + // /-- locked controllers + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + uno::Reference< chart2::XDiagram > xDiagram( ::chart::ChartModelHelper::findDiagram( m_xChartModel ) ); + + if( m_aLB_Scheme.GetSelectEntryPos() == POS_3DSCHEME_REALISTIC ) + ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Realistic ); + else if( m_aLB_Scheme.GetSelectEntryPos() == POS_3DSCHEME_SIMPLE ) + ThreeDHelper::setScheme( xDiagram, ThreeDLookScheme_Simple ); + else + { + OSL_ENSURE( false, "Invalid Entry selected" ); + } + // \-- locked controllers + } + + // update other controls + initControlsFromModel(); + return 0; +} + +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectShading, void*, EMPTYARG ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + m_aCB_Shading.EnableTriState( FALSE ); + applyShadeModeToModel(); + updateScheme(); + return 0; +} +IMPL_LINK( ThreeD_SceneAppearance_TabPage, SelectRoundedEdgeOrObjectLines, CheckBox*, pCheckBox ) +{ + if( !m_bUpdateOtherControls ) + return 0; + + if( pCheckBox == &m_aCB_ObjectLines ) + { + m_aCB_ObjectLines.EnableTriState( FALSE ); + m_bUpdateOtherControls = false; + m_aCB_RoundedEdge.Enable( !m_aCB_ObjectLines.IsChecked() ); + if(!m_aCB_RoundedEdge.IsEnabled()) + m_aCB_RoundedEdge.Check(FALSE); + m_bUpdateOtherControls = true; + } + else + m_aCB_RoundedEdge.EnableTriState( FALSE ); + applyRoundedEdgeAndObjectLinesToModel(); + updateScheme(); + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hrc b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hrc new file mode 100644 index 000000000000..7c2344768f46 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hrc @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneAppearance.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define FT_SCHEME 1 + +#define CB_OBJECTLINES 1 +#define CB_SHADING 2 +#define CB_ROUNDEDEDGE 3 + +#define FL_SEPERATOR 1 + +#define LB_SHADING 1 +#define LB_SCHEME 2 diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx new file mode 100644 index 000000000000..72ef5f99a500 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneAppearance.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_3D_SCENE_APPEARANCE_HXX +#define _CHART2_TP_3D_SCENE_APPEARANCE_HXX + +// header for class TabPage +#include <vcl/tabpage.hxx> +// header for class FixedLine +#include <vcl/fixed.hxx> +// header for class MetricField +#include <vcl/field.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class ListBox +#include <vcl/lstbox.hxx> +#include <com/sun/star/drawing/ShadeMode.hpp> +#include <com/sun/star/frame/XModel.hpp> + +#include "ControllerLockGuard.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ThreeD_SceneAppearance_TabPage : public TabPage +{ +public: + ThreeD_SceneAppearance_TabPage( + Window* pWindow, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xChartModel, + ControllerLockHelper & rControllerLockHelper ); + virtual ~ThreeD_SceneAppearance_TabPage(); + + // has to be called in case the dialog was closed with OK + void commitPendingChanges(); + + virtual void ActivatePage(); + +private: + DECL_LINK( SelectSchemeHdl, void* ); + DECL_LINK( SelectShading, void* ); + DECL_LINK( SelectRoundedEdgeOrObjectLines, CheckBox* ); + + void initControlsFromModel(); + void applyShadeModeToModel(); + void applyRoundedEdgeAndObjectLinesToModel(); + void updateScheme(); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + m_xChartModel; + + FixedText m_aFT_Scheme; + ListBox m_aLB_Scheme; + + FixedLine m_aFL_Seperator; + + CheckBox m_aCB_RoundedEdge; + CheckBox m_aCB_Shading; + CheckBox m_aCB_ObjectLines; + + bool m_bUpdateOtherControls; + bool m_bCommitToModel; + + ControllerLockHelper & m_rControllerLockHelper; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_3D_SceneAppearance.src b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.src new file mode 100644 index 000000000000..b42db4745425 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneAppearance.src @@ -0,0 +1,101 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneAppearance.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "tp_3D_SceneAppearance.hrc" +#include "dlg_View3D.hrc" +#include "SchSlotIds.hxx" + +#define WIDTH_FL 108 +#define WIDTH_LB 57 +#define WIDTH_FT 41 + +#define HEIGHT_FL 8 +#define HEIGHT_LB 12 +#define HEIGHT_FT 10 + +#define POS_X_0 6 +#define POS_X_1 6 +#define POS_X_2 POS_X_1+WIDTH_FT+4 + +#define POS_Y_SCHEME 8 +#define POS_Y_SEPERATOR (POS_Y_SCHEME+13) + +#define POS_Y_SHADING (POS_Y_SEPERATOR+16) +#define POS_Y_OBJECTLINES (POS_Y_SHADING+16) +#define POS_Y_ROUNDEDEDGE (POS_Y_OBJECTLINES+16) + + +TabPage TP_3D_SCENEAPPEARANCE +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Hide = TRUE ; + Size = MAP_APPFONT ( VIEW3D_PAGE_WIDTH , VIEW3D_PAGE_HEIGHT ) ; + + FixedText FT_SCHEME + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_SCHEME ) ; + Size = MAP_APPFONT ( WIDTH_FT , HEIGHT_FT ) ; + Text [ en-US ] = "Sche~me" ; + }; + ListBox LB_SCHEME + { + Border = TRUE; + TabStop = TRUE; + DropDown = TRUE; + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_SCHEME-2 ) ; + Size = MAP_APPFONT ( WIDTH_LB , HEIGHT_LB ) ; + }; + FixedLine FL_SEPERATOR + { + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_SEPERATOR ) ; + Size = MAP_APPFONT ( WIDTH_FL , HEIGHT_FL ) ; + }; + + CheckBox CB_SHADING + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_SHADING ) ; + Size = MAP_APPFONT ( WIDTH_FL , HEIGHT_LB ) ; + Text [ en-US ] = "~Shading" ; + }; + CheckBox CB_OBJECTLINES + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_OBJECTLINES ) ; + Size = MAP_APPFONT ( WIDTH_FL , HEIGHT_LB ) ; + Text [ en-US ] = "~Object borders" ; + }; + Checkbox CB_ROUNDEDEDGE + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_ROUNDEDEDGE ) ; + Size = MAP_APPFONT ( WIDTH_FL , HEIGHT_LB ) ; + Text [ en-US ] = "~Rounded edges" ; + }; +}; + diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx new file mode 100644 index 000000000000..dbed68f2417b --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.cxx @@ -0,0 +1,300 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneGeometry.cxx,v $ + * + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_3D_SceneGeometry.hxx" +#include "tp_3D_SceneGeometry.hrc" +#include "ResId.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "BaseGFXHelper.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "ThreeDHelper.hxx" +#include <rtl/math.hxx> +#include <svx/unoprnms.hxx> +#include <com/sun/star/drawing/ProjectionMode.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +//using namespace ::com::sun::star::chart2; + +namespace +{ + +void lcl_shiftAngleToValidRange( sal_Int64& rnAngleDegree ) +{ + //valid range: ]-180,180] + while( rnAngleDegree<=-180 ) + rnAngleDegree+=360; + while( rnAngleDegree>180 ) + rnAngleDegree-=360; +} + +void lcl_SetMetricFieldLimits( MetricField& rField, sal_Int64 nLimit ) +{ + rField.SetMin(-1*nLimit); + rField.SetFirst(-1*nLimit); + rField.SetMax(nLimit); + rField.SetLast(nLimit); +} + +} +ThreeD_SceneGeometry_TabPage::ThreeD_SceneGeometry_TabPage( Window* pWindow + , const uno::Reference< beans::XPropertySet > & xSceneProperties + , ControllerLockHelper & rControllerLockHelper ) + : TabPage ( pWindow, SchResId( TP_3D_SCENEGEOMETRY ) ) + , m_xSceneProperties( xSceneProperties ) + , m_aCbxRightAngledAxes( this, SchResId( CBX_RIGHT_ANGLED_AXES ) ) + , m_aFtXRotation ( this, SchResId( FT_X_ROTATION ) ) + , m_aMFXRotation ( this, SchResId( MTR_FLD_X_ROTATION ) ) + , m_aFtYRotation ( this, SchResId( FT_Y_ROTATION ) ) + , m_aMFYRotation ( this, SchResId( MTR_FLD_Y_ROTATION ) ) + , m_aFtZRotation ( this, SchResId( FT_Z_ROTATION ) ) + , m_aMFZRotation ( this, SchResId( MTR_FLD_Z_ROTATION ) ) + , m_aCbxPerspective ( this, SchResId( CBX_PERSPECTIVE ) ) + , m_aMFPerspective ( this, SchResId( MTR_FLD_PERSPECTIVE ) ) + , m_nXRotation(0) + , m_nYRotation(0) + , m_nZRotation(0) + , m_bAngleChangePending( false ) + , m_bPerspectiveChangePending( false ) + , m_rControllerLockHelper( rControllerLockHelper ) +{ + FreeResource(); + + double fXAngle, fYAngle, fZAngle; + ThreeDHelper::getRotationAngleFromDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); + + fXAngle = BaseGFXHelper::Rad2Deg( fXAngle ); + fYAngle = BaseGFXHelper::Rad2Deg( fYAngle ); + fZAngle = BaseGFXHelper::Rad2Deg( fZAngle ); + + DBG_ASSERT( fZAngle>=-90 && fZAngle<=90, "z angle is out of valid range" ); + + lcl_SetMetricFieldLimits( m_aMFZRotation, 90 ); + + m_nXRotation = ::basegfx::fround(fXAngle*pow(10.0,m_aMFXRotation.GetDecimalDigits())); + m_nYRotation = ::basegfx::fround(-1.0*fYAngle*pow(10.0,m_aMFYRotation.GetDecimalDigits())); + m_nZRotation = ::basegfx::fround(-1.0*fZAngle*pow(10.0,m_aMFZRotation.GetDecimalDigits())); + + lcl_shiftAngleToValidRange( m_nXRotation ); + lcl_shiftAngleToValidRange( m_nYRotation ); + lcl_shiftAngleToValidRange( m_nZRotation ); + + m_aMFXRotation.SetValue(m_nXRotation); + m_aMFYRotation.SetValue(m_nYRotation); + m_aMFZRotation.SetValue(m_nZRotation); + + const ULONG nTimeout = 4*EDIT_UPDATEDATA_TIMEOUT; + Link aAngleChangedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleChanged )); + Link aAngleEditedLink( LINK( this, ThreeD_SceneGeometry_TabPage, AngleEdited )); + + m_aMFXRotation.EnableUpdateData( nTimeout ); + m_aMFXRotation.SetUpdateDataHdl( aAngleChangedLink ); + m_aMFXRotation.SetModifyHdl( aAngleEditedLink ); + + m_aMFYRotation.EnableUpdateData( nTimeout ); + m_aMFYRotation.SetUpdateDataHdl( aAngleChangedLink ); + m_aMFYRotation.SetModifyHdl( aAngleEditedLink ); + + m_aMFZRotation.EnableUpdateData( nTimeout ); + m_aMFZRotation.SetUpdateDataHdl( aAngleChangedLink ); + m_aMFZRotation.SetModifyHdl( aAngleEditedLink ); + + drawing::ProjectionMode aProjectionMode = drawing::ProjectionMode_PERSPECTIVE; + m_xSceneProperties->getPropertyValue( C2U("D3DScenePerspective")) >>= aProjectionMode; + m_aCbxPerspective.Check( aProjectionMode == drawing::ProjectionMode_PERSPECTIVE ); + m_aCbxPerspective.SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveToggled )); + + sal_Int32 nPerspectivePercentage = 20; + m_xSceneProperties->getPropertyValue( C2U("Perspective")) >>= nPerspectivePercentage; + m_aMFPerspective.SetValue( nPerspectivePercentage ); + + m_aMFPerspective.EnableUpdateData( nTimeout ); + m_aMFPerspective.SetUpdateDataHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveChanged ) ); + m_aMFPerspective.SetModifyHdl( LINK( this, ThreeD_SceneGeometry_TabPage, PerspectiveEdited ) ); + m_aMFPerspective.Enable( m_aCbxPerspective.IsChecked() ); + + + //RightAngledAxes + sal_Bool bRightAngledAxes = false; + + uno::Reference< chart2::XDiagram > xDiagram( m_xSceneProperties, uno::UNO_QUERY ); + if( ChartTypeHelper::isSupportingRightAngledAxes( + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) + { + m_xSceneProperties->getPropertyValue( C2U("RightAngledAxes")) >>= bRightAngledAxes; + m_aCbxRightAngledAxes.SetToggleHdl( LINK( this, ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled )); + m_aCbxRightAngledAxes.Check( bRightAngledAxes ); + } + else + { + m_aCbxRightAngledAxes.Enable(false); + } +} + +ThreeD_SceneGeometry_TabPage::~ThreeD_SceneGeometry_TabPage() +{ +} + +void ThreeD_SceneGeometry_TabPage::commitPendingChanges() +{ + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + if( m_bAngleChangePending ) + applyAnglesToModel(); + if( m_bPerspectiveChangePending ) + applyPerspectiveToModel(); +} + +void ThreeD_SceneGeometry_TabPage::applyAnglesToModel() +{ + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + double fXAngle = 0.0, fYAngle = 0.0, fZAngle = 0.0; + + if( !m_aMFZRotation.IsEmptyFieldValue() ) + m_nZRotation = m_aMFZRotation.GetValue(); + + fXAngle = double(m_nXRotation)/double(pow(10.0,m_aMFXRotation.GetDecimalDigits())); + fYAngle = double(-1.0*m_nYRotation)/double(pow(10.0,m_aMFYRotation.GetDecimalDigits())); + fZAngle = double(-1.0*m_nZRotation)/double(pow(10.0,m_aMFZRotation.GetDecimalDigits())); + + fXAngle = BaseGFXHelper::Deg2Rad( fXAngle ); + fYAngle = BaseGFXHelper::Deg2Rad( fYAngle ); + fZAngle = BaseGFXHelper::Deg2Rad( fZAngle ); + + ThreeDHelper::setRotationAngleToDiagram( m_xSceneProperties, fXAngle, fYAngle, fZAngle ); + + m_bAngleChangePending = false; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, AngleEdited, void*, EMPTYARG ) +{ + m_nXRotation = m_aMFXRotation.GetValue(); + m_nYRotation = m_aMFYRotation.GetValue(); + + m_bAngleChangePending = true; + return 0; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, AngleChanged, void*, EMPTYARG ) +{ + applyAnglesToModel(); + return 0; +} + +void ThreeD_SceneGeometry_TabPage::applyPerspectiveToModel() +{ + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + drawing::ProjectionMode aMode = m_aCbxPerspective.IsChecked() + ? drawing::ProjectionMode_PERSPECTIVE + : drawing::ProjectionMode_PARALLEL; + + try + { + m_xSceneProperties->setPropertyValue( C2U("D3DScenePerspective"), uno::makeAny( aMode )); + m_xSceneProperties->setPropertyValue( C2U("Perspective"), uno::makeAny( (sal_Int32)m_aMFPerspective.GetValue() )); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + m_bPerspectiveChangePending = false; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, PerspectiveEdited, void*, EMPTYARG ) +{ + m_bPerspectiveChangePending = true; + return 0; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, PerspectiveChanged, void*, EMPTYARG ) +{ + applyPerspectiveToModel(); + return 0; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, PerspectiveToggled, void*, EMPTYARG ) +{ + m_aMFPerspective.Enable( m_aCbxPerspective.IsChecked() ); + applyPerspectiveToModel(); + return 0; +} + +IMPL_LINK( ThreeD_SceneGeometry_TabPage, RightAngledAxesToggled, void*, EMPTYARG ) +{ + ControllerLockHelperGuard aGuard( m_rControllerLockHelper ); + + bool bEnableZ = !m_aCbxRightAngledAxes.IsChecked(); + m_aFtZRotation.Enable( bEnableZ ); + m_aMFZRotation.Enable( bEnableZ ); + m_aMFZRotation.EnableEmptyFieldValue( !bEnableZ ); + if( !bEnableZ ) + { + m_nXRotation = m_aMFXRotation.GetValue(); + m_nYRotation = m_aMFYRotation.GetValue(); + m_nZRotation = m_aMFZRotation.GetValue(); + + m_aMFXRotation.SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nXRotation), ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes()))); + m_aMFYRotation.SetValue(static_cast<sal_Int64>(ThreeDHelper::getValueClippedToRange(static_cast<double>(m_nYRotation), ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes()))); + m_aMFZRotation.SetEmptyFieldValue(); + + lcl_SetMetricFieldLimits( m_aMFXRotation, static_cast<sal_Int64>(ThreeDHelper::getXDegreeAngleLimitForRightAngledAxes())); + lcl_SetMetricFieldLimits( m_aMFYRotation, static_cast<sal_Int64>(ThreeDHelper::getYDegreeAngleLimitForRightAngledAxes())); + } + else + { + lcl_SetMetricFieldLimits( m_aMFXRotation, 180 ); + lcl_SetMetricFieldLimits( m_aMFYRotation, 180 ); + + m_aMFXRotation.SetValue(m_nXRotation); + m_aMFYRotation.SetValue(m_nYRotation); + m_aMFZRotation.SetValue(m_nZRotation); + } + + ThreeDHelper::switchRightAngledAxes( m_xSceneProperties, m_aCbxRightAngledAxes.IsChecked(), true /*bRotateLights*/ ); + + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hrc b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hrc new file mode 100644 index 000000000000..5f1892de2885 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneGeometry.hrc,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define FT_X_ROTATION 1 +#define FT_Y_ROTATION 2 +#define FT_Z_ROTATION 3 + +#define MTR_FLD_X_ROTATION 1 +#define MTR_FLD_Y_ROTATION 2 +#define MTR_FLD_Z_ROTATION 3 +#define MTR_FLD_PERSPECTIVE 4 + +#define CBX_PERSPECTIVE 1 +#define CBX_RIGHT_ANGLED_AXES 2 + diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx new file mode 100644 index 000000000000..2b56f9fcc490 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneGeometry.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_3D_SCENE_GEOMETRY_HXX +#define _CHART2_TP_3D_SCENE_GEOMETRY_HXX + +#include <com/sun/star/beans/XPropertySet.hpp> +#include <basegfx/matrix/b3dhommatrix.hxx> + +// header for class TabPage +#include <vcl/tabpage.hxx> +// header for class FixedLine +#include <vcl/fixed.hxx> +// header for class MetricField +#include <vcl/field.hxx> +// header for class OKButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif + +#include "ControllerLockGuard.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ThreeD_SceneGeometry_TabPage : public TabPage +{ +public: + ThreeD_SceneGeometry_TabPage( Window* pWindow, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & xSceneProperties, + ControllerLockHelper & rControllerLockHelper ); + virtual ~ThreeD_SceneGeometry_TabPage(); + + // has to be called in case the dialog was closed with OK + void commitPendingChanges(); + + // is called by timer to apply changes to model + DECL_LINK( AngleChanged, void* ); + // is called immediately when a field changes + DECL_LINK( AngleEdited, void* ); + + // is called by timer to apply changes to model + DECL_LINK( PerspectiveChanged, void* ); + // is called immediately when a field changes + DECL_LINK( PerspectiveEdited, void* ); + DECL_LINK( PerspectiveToggled, void* ); + DECL_LINK( RightAngledAxesToggled, void* ); + +private: + void fillDialogAnglesFromModel() const; + void applyAnglesToModel(); + void applyPerspectiveToModel(); + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > m_xSceneProperties; + + CheckBox m_aCbxRightAngledAxes; + + FixedText m_aFtXRotation; + MetricField m_aMFXRotation; + + FixedText m_aFtYRotation; + MetricField m_aMFYRotation; + + FixedText m_aFtZRotation; + MetricField m_aMFZRotation; + + CheckBox m_aCbxPerspective; + MetricField m_aMFPerspective; + + //to keep old values when switching to right angled axes + sal_Int64 m_nXRotation; + sal_Int64 m_nYRotation; + sal_Int64 m_nZRotation; + + bool m_bAngleChangePending; + bool m_bPerspectiveChangePending; + + ControllerLockHelper & m_rControllerLockHelper; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_3D_SceneGeometry.src b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.src new file mode 100644 index 000000000000..76b2005e4963 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneGeometry.src @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneGeometry.src,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "tp_3D_SceneGeometry.hrc" +#include "dlg_View3D.hrc" +#include "SchSlotIds.hxx" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +#define WIDTH_FL 108 +#define WIDTH_MF 57 +#define WIDTH_FT 50 + +#define HEIGHT_FL 8 +#define HEIGHT_MF 12 +#define HEIGHT_FT 10 + +#define POS_X_0 6 +#define POS_X_1 6 +#define POS_X_2 POS_X_1+WIDTH_FT+4 + +#define POS_Y_0 (8) +#define POS_Y_1 (POS_Y_0+RSC_CD_FIXEDTEXT_HEIGHT+10) +#define POS_Y_2 (POS_Y_1+RSC_CD_FIXEDTEXT_HEIGHT+8) +#define POS_Y_3 (POS_Y_2+RSC_CD_FIXEDTEXT_HEIGHT+8) +#define POS_Y_4 (POS_Y_3+RSC_CD_FIXEDTEXT_HEIGHT+12) + +#define CUSTOMUNITTEXT_DEGREE \ +Border = TRUE ; \ +TabStop = TRUE ; \ +Repeat = TRUE ; \ +Spin = TRUE ; \ +Minimum = -180 ; \ +Maximum = 180 ; \ +StrictFormat = TRUE ; \ +DecimalDigits = 0 ; \ +First = -180 ; \ +Last = 180 ; \ +SpinSize = 1 ; \ +Unit = FUNIT_CUSTOM ; \ +CustomUnitText [ en-US ] = " degrees" ; + +TabPage TP_3D_SCENEGEOMETRY +{ + HelpID = SID_3D_VIEW ; + OutputSize = TRUE ; + SVLook = TRUE ; + Hide = TRUE ; + Size = MAP_APPFONT ( VIEW3D_PAGE_WIDTH , VIEW3D_PAGE_HEIGHT ) ; + + CheckBox CBX_RIGHT_ANGLED_AXES + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_0 ) ; + Size = MAP_APPFONT ( (WIDTH_FT+WIDTH_MF) , HEIGHT_FT ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Right-angled axes" ; + }; + FixedText FT_X_ROTATION + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_1 ) ; + Size = MAP_APPFONT ( WIDTH_FT , HEIGHT_FT ) ; + Text [ en-US ] = "~X rotation" ; + }; + FixedText FT_Y_ROTATION + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_2 ) ; + Size = MAP_APPFONT ( WIDTH_FT , HEIGHT_FT ) ; + Text [ en-US ] = "~Y rotation" ; + }; + FixedText FT_Z_ROTATION + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_3 ) ; + Size = MAP_APPFONT ( WIDTH_FT , HEIGHT_FT ) ; + Text [ en-US ] = "~Z rotation" ; + }; + MetricField MTR_FLD_X_ROTATION + { + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_1-2 ) ; + Size = MAP_APPFONT ( WIDTH_MF , HEIGHT_MF ) ; + CUSTOMUNITTEXT_DEGREE + }; + MetricField MTR_FLD_Y_ROTATION + { + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_2-2 ) ; + Size = MAP_APPFONT ( WIDTH_MF , HEIGHT_MF ) ; + CUSTOMUNITTEXT_DEGREE + }; + MetricField MTR_FLD_Z_ROTATION + { + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_3-2 ) ; + Size = MAP_APPFONT ( WIDTH_MF , HEIGHT_MF ) ; + CUSTOMUNITTEXT_DEGREE + }; + + CheckBox CBX_PERSPECTIVE + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_4 ) ; + Size = MAP_APPFONT ( WIDTH_FT , HEIGHT_FT ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Perspective" ; + }; + MetricField MTR_FLD_PERSPECTIVE + { + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_4-2 ) ; + Size = MAP_APPFONT ( WIDTH_MF , HEIGHT_MF ) ; + Border = TRUE ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + Maximum = 100 ; + StrictFormat = TRUE ; + DecimalDigits = 0 ; + First = 0 ; + Last = 100 ; + SpinSize = 5 ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = "%" ; + }; +}; + diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx new file mode 100644 index 000000000000..fc01dc881fc3 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.cxx @@ -0,0 +1,653 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneIllumination.cxx,v $ + * $Revision: 1.4.68.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_3D_SceneIllumination.hxx" +#include "tp_3D_SceneIllumination.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "Bitmaps.hrc" +#include "Bitmaps_HC.hrc" +#include "CommonConverters.hxx" +#include "NoWarningThisInCTOR.hxx" + +#ifndef _SVX_DIALOGS_HRC +#include "svx/dialogs.hrc" +#endif +// header for define SVX_RES +#include <svx/dialmgr.hxx> +#include <rtl/math.hxx> + +// header for class SvColorDialog +#include <svtools/colrdlg.hxx> + +// header for define RET_OK +#include <vcl/msgbox.hxx> + +#include <svx/svx3ditems.hxx> +#include <svx/svddef.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +LightButton::LightButton( Window* pParent, const ResId& rResId, sal_Int32 nLightNumber ) + : ImageButton( pParent, rResId ) + , m_bLightOn(false) +{ + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF) ), BMP_COLOR_NORMAL ); + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H) ), BMP_COLOR_HIGHCONTRAST ); + + String aTipHelpStr( SchResId(STR_TIP_LIGHTSOURCE_X) ); + rtl::OUString aTipHelp( aTipHelpStr ); + const rtl::OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%LIGHTNUMBER" )); + sal_Int32 nIndex = aTipHelp.indexOf( aReplacementStr ); + if( nIndex != -1 ) + { + aTipHelp = aTipHelp.replaceAt(nIndex, aReplacementStr.getLength(), + rtl::OUString::valueOf( nLightNumber ) ); + } + this->SetQuickHelpText( String( aTipHelp ) ); +} +LightButton::~LightButton() +{ +} +void LightButton::switchLightOn(bool bOn) +{ + if( m_bLightOn==bOn ) + return; + m_bLightOn = bOn; + if(m_bLightOn) + { + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON) ), BMP_COLOR_NORMAL ); + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_ON_H) ), BMP_COLOR_HIGHCONTRAST ); + } + else + { + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF) ), BMP_COLOR_NORMAL ); + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_LIGHT_OFF_H) ), BMP_COLOR_HIGHCONTRAST ); + } +} +bool LightButton::isLightOn() const +{ + return m_bLightOn; +} + +//----------------------------------------------------------------------------- + +ColorButton::ColorButton( Window* pParent, const ResId& rResId ) + : ImageButton( pParent, rResId ) +{ + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG) ), BMP_COLOR_NORMAL ); + SetModeImage( Image( SVX_RES(RID_SVXIMAGE_COLORDLG_H) ), BMP_COLOR_HIGHCONTRAST ); + + this->SetQuickHelpText( String( SchResId(STR_TIP_CHOOSECOLOR) ) ); +} +ColorButton::~ColorButton() +{ +} + +//----------------------------------------------------------------------------- + +struct LightSource +{ + long nDiffuseColor; + ::com::sun::star::drawing::Direction3D aDirection; + bool bIsEnabled; + + LightSource() : + nDiffuseColor( 0xcccccc ), + aDirection( 1.0, 1.0, -1.0 ), + bIsEnabled( false ) + {} +}; + +struct LightSourceInfo +{ + LightButton* pButton; + LightSource aLightSource; + + LightSourceInfo(); + void initButtonFromSource(); +}; + +LightSourceInfo::LightSourceInfo() + : pButton(0) + , aLightSource() +{ + aLightSource.nDiffuseColor = 0xffffff; // white + aLightSource.aDirection = drawing::Direction3D(1,1,1); + aLightSource.bIsEnabled = sal_False; +} +void LightSourceInfo::initButtonFromSource() +{ + if(!pButton) + return; + pButton->SetModeImage( Image( SVX_RES( aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON : RID_SVXIMAGE_LIGHT_OFF ) ), BMP_COLOR_NORMAL ); + pButton->SetModeImage( Image( SVX_RES( aLightSource.bIsEnabled ? RID_SVXIMAGE_LIGHT_ON_H : RID_SVXIMAGE_LIGHT_OFF_H ) ), BMP_COLOR_HIGHCONTRAST ); +} + +//----------------------------------------------------------------------------- + +namespace +{ + rtl::OUString lcl_makeColorName( Color rColor ) + { + String aStr(SVX_RES(RID_SVXFLOAT3D_FIX_R)); + aStr += String::CreateFromInt32((INT32)rColor.GetRed()); + aStr += sal_Unicode(' '); + aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_G)); + aStr += String::CreateFromInt32((INT32)rColor.GetGreen()); + aStr += sal_Unicode(' '); + aStr += String(SVX_RES(RID_SVXFLOAT3D_FIX_B)); + aStr += String::CreateFromInt32((INT32)rColor.GetBlue()); + return aStr; + } + void lcl_selectColor( ColorListBox& rListBox, const Color& rColor ) + { + rListBox.SetNoSelection(); + rListBox.SelectEntry( rColor ); + if( rListBox.GetSelectEntryCount() == 0 ) + { + USHORT nPos = rListBox.InsertEntry( rColor, lcl_makeColorName( rColor ) ); + rListBox.SelectEntryPos( nPos ); + } + } + + ::chart::LightSource lcl_getLightSourceFromProperties( + const uno::Reference< beans::XPropertySet > & xSceneProperties, + sal_Int32 nIndex ) + { + ::chart::LightSource aResult; + if( 0 <= nIndex && nIndex < 8 ) + { + ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor")); + ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection")); + ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn")); + ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 )); + + try + { + xSceneProperties->getPropertyValue( aColorPropertyPrefix + aIndex ) >>= aResult.nDiffuseColor; + xSceneProperties->getPropertyValue( aDirectionPropertyPrefix + aIndex ) >>= aResult.aDirection; + xSceneProperties->getPropertyValue( aEnabledPropertyPrefix + aIndex ) >>= aResult.bIsEnabled; + } + catch( const uno::Exception & ex ) + { + (void)(ex); // no warning in non-debug builds + OSL_ENSURE( false, ::rtl::OUStringToOString( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + } + return aResult; + } + + void lcl_setLightSource( + const uno::Reference< beans::XPropertySet > & xSceneProperties, + const ::chart::LightSource & rLightSource, + sal_Int32 nIndex ) + { + if( 0 <= nIndex && nIndex < 8 ) + { + ::rtl::OUString aColorPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightColor")); + ::rtl::OUString aDirectionPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightDirection")); + ::rtl::OUString aEnabledPropertyPrefix( RTL_CONSTASCII_USTRINGPARAM("D3DSceneLightOn")); + ::rtl::OUString aIndex( ::rtl::OUString::valueOf( nIndex + 1 )); + + try + { + xSceneProperties->setPropertyValue( aColorPropertyPrefix + aIndex, + uno::makeAny( rLightSource.nDiffuseColor )); + xSceneProperties->setPropertyValue( aDirectionPropertyPrefix + aIndex, + uno::makeAny( rLightSource.aDirection )); + xSceneProperties->setPropertyValue( aEnabledPropertyPrefix + aIndex, + uno::makeAny( rLightSource.bIsEnabled )); + } + catch( const uno::Exception & ex ) + { + (void)(ex); // no warning in non-debug builds + OSL_ENSURE( false, ::rtl::OUStringToOString( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + } + } + + Color lcl_getAmbientColor( + const uno::Reference< beans::XPropertySet > & xSceneProperties ) + { + sal_Int32 nResult = 0x000000; + try + { + xSceneProperties->getPropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor"))) >>= nResult; + } + catch( const uno::Exception & ex ) + { + (void)(ex); // no warning in non-debug builds + OSL_ENSURE( false, ::rtl::OUStringToOString( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + return Color( nResult ); + } + + void lcl_setAmbientColor( + const uno::Reference< beans::XPropertySet > & xSceneProperties, + const Color & rColor ) + { + try + { + xSceneProperties->setPropertyValue( + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("D3DSceneAmbientColor")), + uno::makeAny( rColor.GetColor())); + } + catch( const uno::Exception & ex ) + { + (void)(ex); // no warning in non-debug builds + OSL_ENSURE( false, ::rtl::OUStringToOString( + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "Property Exception caught. Message: " )) + + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + } +} + +//----------------------------------------------------------------------------- + +ThreeD_SceneIllumination_TabPage::ThreeD_SceneIllumination_TabPage( Window* pWindow + , const uno::Reference< beans::XPropertySet > & xSceneProperties + , const uno::Reference< frame::XModel >& xChartModel + , XColorTable* pColorTable ) + : TabPage ( pWindow, SchResId( TP_3D_SCENEILLUMINATION ) ) + , m_aFT_LightSource( this, SchResId( FT_LIGHTSOURCE ) ) + , m_aBtn_Light1( this, SchResId( BTN_LIGHT_1 ), 1 ) + , m_aBtn_Light2( this, SchResId( BTN_LIGHT_2 ), 2 ) + , m_aBtn_Light3( this, SchResId( BTN_LIGHT_3 ), 3 ) + , m_aBtn_Light4( this, SchResId( BTN_LIGHT_4 ), 4 ) + , m_aBtn_Light5( this, SchResId( BTN_LIGHT_5 ), 5 ) + , m_aBtn_Light6( this, SchResId( BTN_LIGHT_6 ), 6 ) + , m_aBtn_Light7( this, SchResId( BTN_LIGHT_7 ), 7 ) + , m_aBtn_Light8( this, SchResId( BTN_LIGHT_8 ), 8 ) + , m_aLB_LightSource( this, SchResId( LB_LIGHTSOURCE ) ) + , m_aBtn_LightSource_Color( this, SchResId( BTN_LIGHTSOURCE_COLOR ) ) + , m_aFT_AmbientLight( this, SchResId( FT_AMBIENTLIGHT ) ) + , m_aLB_AmbientLight( this, SchResId( LB_AMBIENTLIGHT ) ) + , m_aBtn_AmbientLight_Color( this, SchResId( BTN_AMBIENT_COLOR ) ) + , m_aCtl_Preview( this, SchResId( CTL_LIGHT_PREVIEW ) ) + , m_pLightSourceInfoList(0) + , m_xSceneProperties( xSceneProperties ) + , m_aTimerTriggeredControllerLock( xChartModel ) + , m_bInCommitToModel( false ) + , m_aModelChangeListener( LINK( this, ThreeD_SceneIllumination_TabPage, fillControlsFromModel ) ) + , m_xChartModel( xChartModel ) +{ + FreeResource(); + + if(pColorTable) + { + m_aLB_AmbientLight.Fill( pColorTable ); + m_aLB_LightSource.Fill( pColorTable ); + } + m_aLB_AmbientLight.SetDropDownLineCount(10); + m_aLB_LightSource.SetDropDownLineCount(10); + + m_pLightSourceInfoList = new LightSourceInfo[8]; + 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(0); + + m_aBtn_Light1.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light2.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light3.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light4.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light5.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light6.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light7.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + m_aBtn_Light8.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl ) ); + + m_aLB_AmbientLight.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); + m_aLB_LightSource.SetSelectHdl( LINK( this, ThreeD_SceneIllumination_TabPage, SelectColorHdl ) ); + + m_aBtn_AmbientLight_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); + m_aBtn_LightSource_Color.SetClickHdl( LINK( this, ThreeD_SceneIllumination_TabPage, ColorDialogHdl ) ); + + m_aCtl_Preview.SetUserInteractiveChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewChangeHdl ) ); + m_aCtl_Preview.SetUserSelectionChangeCallback( LINK( this, ThreeD_SceneIllumination_TabPage, PreviewSelectHdl ) ); + + ClickLightSourceButtonHdl(&m_aBtn_Light2); + + //m_aDelyedModelChangeTimer.SetTimeout( 4*EDIT_UPDATEDATA_TIMEOUT ); + + m_aModelChangeListener.startListening( uno::Reference< util::XModifyBroadcaster >(m_xSceneProperties, uno::UNO_QUERY) ); +} + +ThreeD_SceneIllumination_TabPage::~ThreeD_SceneIllumination_TabPage() +{ + delete[] m_pLightSourceInfoList; +} + +void ThreeD_SceneIllumination_TabPage::commitPendingChanges() +{ +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, fillControlsFromModel, void *, EMPTYARG ) +{ + if( m_bInCommitToModel )//don't read own changes + return 0; + + sal_Int32 nL=0; + for( nL=0; nL<8; nL++) + m_pLightSourceInfoList[nL].aLightSource = lcl_getLightSourceFromProperties( m_xSceneProperties, nL ); + for( nL=0; nL<8; nL++) + m_pLightSourceInfoList[nL].initButtonFromSource(); + + lcl_selectColor( m_aLB_AmbientLight, lcl_getAmbientColor( m_xSceneProperties )); + + this->updatePreview(); + + return 0; +} + +void ThreeD_SceneIllumination_TabPage::applyLightSourceToModel( sal_uInt32 nLightNumber ) +{ + ControllerLockGuard aGuard( m_xChartModel ); + m_bInCommitToModel = true; + sal_Int32 nIndex( nLightNumber ); + lcl_setLightSource( m_xSceneProperties, m_pLightSourceInfoList[nIndex].aLightSource, nIndex ); + m_bInCommitToModel = false; +} + +void ThreeD_SceneIllumination_TabPage::applyLightSourcesToModel() +{ + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aGuard( m_xChartModel ); + for( sal_Int32 nL=0; nL<8; nL++) + applyLightSourceToModel( nL ); + m_aTimerTriggeredControllerLock.startTimer(); +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, PreviewChangeHdl, void*, EMPTYARG ) +{ + m_aTimerTriggeredControllerLock.startTimer(); + + //update m_pLightSourceInfoList from preview + const SfxItemSet a3DLightAttributes(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes()); + LightSourceInfo* pInfo = &m_pLightSourceInfoList[0]; + + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_1)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_1)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection1Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_1)).GetValue()); + + pInfo = &m_pLightSourceInfoList[1]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_2)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_2)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection2Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_2)).GetValue()); + + pInfo = &m_pLightSourceInfoList[2]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_3)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_3)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection3Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_3)).GetValue()); + + pInfo = &m_pLightSourceInfoList[3]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_4)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_4)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection4Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_4)).GetValue()); + + pInfo = &m_pLightSourceInfoList[4]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_5)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_5)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection5Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_5)).GetValue()); + + pInfo = &m_pLightSourceInfoList[5]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_6)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_6)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection6Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_6)).GetValue()); + + pInfo = &m_pLightSourceInfoList[6]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_7)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_7)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection7Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_7)).GetValue()); + + pInfo = &m_pLightSourceInfoList[7]; + pInfo->aLightSource.nDiffuseColor = ((const Svx3DLightcolor8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTCOLOR_8)).GetValue().GetColor(); + pInfo->aLightSource.bIsEnabled = ((const Svx3DLightOnOff8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTON_8)).GetValue(); + pInfo->aLightSource.aDirection = B3DVectorToDirection3D(((const Svx3DLightDirection8Item&)a3DLightAttributes.Get(SDRATTR_3DSCENE_LIGHTDIRECTION_8)).GetValue()); + + applyLightSourcesToModel(); + + return 0; +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, PreviewSelectHdl, void*, EMPTYARG ) +{ + sal_uInt32 nLightNumber = m_aCtl_Preview.GetSvx3DLightControl().GetSelectedLight(); + if(nLightNumber<8) + { + LightButton* pButton = m_pLightSourceInfoList[nLightNumber].pButton; + if(!pButton->IsChecked()) + ClickLightSourceButtonHdl(pButton); + + applyLightSourcesToModel(); + } + return 0; +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, ColorDialogHdl, Button*, pButton ) +{ + bool bIsAmbientLight = (pButton==&m_aBtn_AmbientLight_Color); + ColorLB* pListBox = ( bIsAmbientLight ? &m_aLB_AmbientLight : &m_aLB_LightSource); + + SvColorDialog aColorDlg( this ); + aColorDlg.SetColor( pListBox->GetSelectEntryColor() ); + if( aColorDlg.Execute() == RET_OK ) + { + Color aColor( aColorDlg.GetColor()); + lcl_selectColor( *pListBox, aColor ); + if( bIsAmbientLight ) + { + m_bInCommitToModel = true; + lcl_setAmbientColor( m_xSceneProperties, aColor ); + m_bInCommitToModel = false; + } + else + { + //get active lightsource: + LightSourceInfo* pInfo = 0; + sal_Int32 nL=0; + for( nL=0; nL<8; nL++) + { + pInfo = &m_pLightSourceInfoList[nL]; + if(pInfo->pButton->IsChecked()) + break; + pInfo = 0; + } + if(pInfo) + applyLightSourceToModel( nL ); + } + SelectColorHdl( pListBox ); + } + return 0; +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, SelectColorHdl, ColorLB*, pListBox ) +{ + if(pListBox==&m_aLB_AmbientLight) + { + m_bInCommitToModel = true; + lcl_setAmbientColor( m_xSceneProperties, pListBox->GetSelectEntryColor().GetColor()); + m_bInCommitToModel = false; + } + else if(pListBox==&m_aLB_LightSource) + { + //get active lightsource: + LightSourceInfo* pInfo = 0; + sal_Int32 nL=0; + for( nL=0; nL<8; nL++) + { + pInfo = &m_pLightSourceInfoList[nL]; + if(pInfo->pButton->IsChecked()) + break; + pInfo = 0; + } + if(pInfo) + { + pInfo->aLightSource.nDiffuseColor = pListBox->GetSelectEntryColor().GetColor(); + applyLightSourceToModel( nL ); + } + } + this->updatePreview(); + return 0; +} + +IMPL_LINK( ThreeD_SceneIllumination_TabPage, ClickLightSourceButtonHdl, LightButton*, pButton ) +{ + if( !pButton ) + return 0; + + LightSourceInfo* pInfo = 0; + sal_Int32 nL=0; + for( nL=0; nL<8; nL++) + { + if( m_pLightSourceInfoList[nL].pButton == pButton ) + { + pInfo = &m_pLightSourceInfoList[nL]; + break; + } + } + + //update light button + bool bIsChecked = pButton->IsChecked(); + if(bIsChecked) + { + pButton->switchLightOn(!pButton->isLightOn()); + if(pInfo) + { + pInfo->aLightSource.bIsEnabled=pButton->isLightOn(); + applyLightSourceToModel( nL ); + } + } + else + { + ControllerLockGuard aGuard( m_xChartModel ); + for( nL=0; nL<8; nL++) + { + LightButton* pLightButton = m_pLightSourceInfoList[nL].pButton; + pLightButton->Check( pLightButton == pButton ); + } + } + + //update color list box + if(pInfo) + { + lcl_selectColor( m_aLB_LightSource, pInfo->aLightSource.nDiffuseColor ); + } + this->updatePreview(); + return 0; +} + +void ThreeD_SceneIllumination_TabPage::updatePreview() +{ + SfxItemSet aItemSet(m_aCtl_Preview.GetSvx3DLightControl().Get3DAttributes()); + LightSourceInfo* pInfo = &m_pLightSourceInfoList[0]; + + // AmbientColor + aItemSet.Put(Svx3DAmbientcolorItem(m_aLB_AmbientLight.GetSelectEntryColor())); + + aItemSet.Put(Svx3DLightcolor1Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff1Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection1Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[1]; + aItemSet.Put(Svx3DLightcolor2Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff2Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection2Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[2]; + aItemSet.Put(Svx3DLightcolor3Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff3Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection3Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[3]; + aItemSet.Put(Svx3DLightcolor4Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff4Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection4Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[4]; + aItemSet.Put(Svx3DLightcolor5Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff5Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection5Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[5]; + aItemSet.Put(Svx3DLightcolor6Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff6Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection6Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[6]; + aItemSet.Put(Svx3DLightcolor7Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff7Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection7Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + pInfo = &m_pLightSourceInfoList[7]; + aItemSet.Put(Svx3DLightcolor8Item(pInfo->aLightSource.nDiffuseColor)); + aItemSet.Put(Svx3DLightOnOff8Item(pInfo->aLightSource.bIsEnabled)); + aItemSet.Put(Svx3DLightDirection8Item(Direction3DToB3DVector(pInfo->aLightSource.aDirection))); + + // set lights and ambient light + m_aCtl_Preview.GetSvx3DLightControl().Set3DAttributes(aItemSet); + + // select light + for(sal_uInt32 a(0); a < 8; a++) + { + if(m_pLightSourceInfoList[a].pButton->IsChecked()) + { + m_aCtl_Preview.GetSvx3DLightControl().SelectLight(a); + m_aCtl_Preview.CheckSelection(); + break; + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc new file mode 100644 index 000000000000..cf8d6f562371 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hrc @@ -0,0 +1,49 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneIllumination.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" + +#define FT_AMBIENTLIGHT 1 +#define FT_LIGHTSOURCE 2 + +#define LB_AMBIENTLIGHT 1 +#define LB_LIGHTSOURCE 2 + +#define BTN_AMBIENT_COLOR 1 +#define BTN_LIGHTSOURCE_COLOR 2 +#define BTN_LIGHT_1 3 +#define BTN_LIGHT_2 4 +#define BTN_LIGHT_3 5 +#define BTN_LIGHT_4 6 +#define BTN_LIGHT_5 7 +#define BTN_LIGHT_6 8 +#define BTN_LIGHT_7 9 +#define BTN_LIGHT_8 10 + +#define CTL_LIGHT_PREVIEW 1 diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx new file mode 100644 index 000000000000..64607a4cad63 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneIllumination.hxx,v $ + * $Revision: 1.3.68.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_3D_SCENE_ILLUMIMATION_HXX +#define _CHART2_TP_3D_SCENE_ILLUMIMATION_HXX + +#include "ModifyListenerCallBack.hxx" +#include "TimerTriggeredControllerLock.hxx" + +// #ifndef _COM_SUN_STAR_CHART2_SCENEDESCRIPTOR_HPP_ +// #include <com/sun/star/chart2/SceneDescriptor.hpp> +// #endif +#include <com/sun/star/beans/XPropertySet.hpp> + +// header for class TabPage +#include <vcl/tabpage.hxx> +// header for class FixedText +#include <vcl/fixed.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class ColorLB +#include <svx/dlgctrl.hxx> +// header for class SvxLightCtl3D +#include <svx/dlgctl3d.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class LightButton : public ImageButton +{ +public: + LightButton( Window* pParent, const ResId& rResId, sal_Int32 nLightNumber ); + virtual ~LightButton(); + + void switchLightOn(bool bOn); + bool isLightOn() const; + +private: + bool m_bLightOn; +}; + +class ColorButton : public ImageButton +{ +public: + ColorButton( Window* pParent, const ResId& rResId ); + virtual ~ColorButton(); +}; + +struct LightSourceInfo; + +class ThreeD_SceneIllumination_TabPage : public TabPage +{ +public: + ThreeD_SceneIllumination_TabPage( + Window* pWindow, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & xSceneProperties, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, + XColorTable* pColorTable=0 ); + virtual ~ThreeD_SceneIllumination_TabPage(); + + // has to be called in case the dialog was closed with OK + void commitPendingChanges(); + +private: + DECL_LINK( ClickLightSourceButtonHdl, LightButton* ); + DECL_LINK( SelectColorHdl, ColorLB* ); + DECL_LINK( ColorDialogHdl, Button* ); + DECL_LINK( PreviewChangeHdl, void* ); + DECL_LINK( PreviewSelectHdl, void* ); + + void updatePreview(); + +private: + DECL_LINK(fillControlsFromModel, void *); + + void applyLightSourceToModel( sal_uInt32 nLightNumber ); + void applyLightSourcesToModel(); + + FixedText m_aFT_LightSource; + + 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; + + ColorLB m_aLB_LightSource; + ColorButton m_aBtn_LightSource_Color; + + FixedText m_aFT_AmbientLight; + ColorLB m_aLB_AmbientLight; + ColorButton m_aBtn_AmbientLight_Color; + + SvxLightCtl3D m_aCtl_Preview; + + LightSourceInfo* m_pLightSourceInfoList; + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > m_xSceneProperties; + + TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; + + bool m_bInCommitToModel; + + ModifyListenerCallBack m_aModelChangeListener; + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xChartModel; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src new file mode 100644 index 000000000000..d2919b9078ca --- /dev/null +++ b/chart2/source/controller/dialogs/tp_3D_SceneIllumination.src @@ -0,0 +1,165 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_3D_SceneIllumination.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "tp_3D_SceneIllumination.hrc" +#include "dlg_View3D.hrc" +#include "SchSlotIds.hxx" + +#define WIDTH_HEAD 108 +#define WIDTH_FT 41 +#define WIDTH_LB 57 +#define WIDTH_IB 12 +#define BUTTON_DISTANCE 14 + +#define HEIGHT_IB 12 +#define HEIGHT_FT 10 +#define HEIGHT_LB 12 + +#define POS_X_0 6 +#define POS_X_1 (POS_X_0+WIDTH_LB+4) +#define POS_X_2 (POS_X_1+WIDTH_IB+6) + +#define WIDTH_PREVIEW (VIEW3D_PAGE_WIDTH-POS_X_2-6) + +#define POS_Y_LIGHTSOURCE_HEAD 3 +#define POS_Y_LIGHTSOURCE_BUTTONS (POS_Y_LIGHTSOURCE_HEAD+12) +#define POS_Y_LIGHTSOURCE_BUTTONS_2 (POS_Y_LIGHTSOURCE_BUTTONS+HEIGHT_IB+2) +#define POS_Y_LIGHTSOURCE (POS_Y_LIGHTSOURCE_BUTTONS_2+16) + +#define POS_Y_AMBIENT_HEAD (POS_Y_LIGHTSOURCE+18) +#define POS_Y_AMBIENT (POS_Y_AMBIENT_HEAD+12) + +#define POS_Y_PREVIEW POS_Y_LIGHTSOURCE_BUTTONS + +#define HEIGHT_PREVIEW POS_Y_AMBIENT+HEIGHT_LB-POS_Y_PREVIEW + +TabPage TP_3D_SCENEILLUMINATION +{ + OutputSize = TRUE ; + SVLook = TRUE ; + Hide = TRUE ; + Size = MAP_APPFONT ( VIEW3D_PAGE_WIDTH , VIEW3D_PAGE_HEIGHT ) ; + + FixedText FT_LIGHTSOURCE + { + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_LIGHTSOURCE_HEAD ) ; + Size = MAP_APPFONT ( WIDTH_HEAD , HEIGHT_FT ) ; + Text [ en-US ] = "~Light source" ; + }; + ImageButton BTN_LIGHT_1 + { + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_LIGHTSOURCE_BUTTONS ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_2 + { + Pos = MAP_APPFONT ( POS_X_0+BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_3 + { + Pos = MAP_APPFONT ( POS_X_0+2*BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_4 + { + Pos = MAP_APPFONT ( POS_X_0+3*BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_5 + { + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_LIGHTSOURCE_BUTTONS_2 ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_6 + { + Pos = MAP_APPFONT ( POS_X_0+1*BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS_2 ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_7 + { + Pos = MAP_APPFONT ( POS_X_0+2*BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS_2 ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ImageButton BTN_LIGHT_8 + { + Pos = MAP_APPFONT ( POS_X_0+3*BUTTON_DISTANCE , POS_Y_LIGHTSOURCE_BUTTONS_2 ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + }; + ListBox LB_LIGHTSOURCE + { + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_LIGHTSOURCE ) ; + Size = MAP_APPFONT ( WIDTH_LB , HEIGHT_LB ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + ImageButton BTN_LIGHTSOURCE_COLOR + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_LIGHTSOURCE ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + TabStop = TRUE ; + }; + + + + + FixedText FT_AMBIENTLIGHT + { + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_AMBIENT_HEAD ) ; + Size = MAP_APPFONT ( WIDTH_HEAD , HEIGHT_FT ) ; + Text [ en-US ] = "~Ambient light" ; + }; + ListBox LB_AMBIENTLIGHT + { + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_0 , POS_Y_AMBIENT ) ; + Size = MAP_APPFONT ( WIDTH_LB , HEIGHT_LB ) ; + TabStop = TRUE ; + DropDown = TRUE ; + }; + ImageButton BTN_AMBIENT_COLOR + { + Pos = MAP_APPFONT ( POS_X_1 , POS_Y_AMBIENT ) ; + Size = MAP_APPFONT ( WIDTH_IB , HEIGHT_IB ) ; + TabStop = TRUE ; + }; + + + + Control CTL_LIGHT_PREVIEW + { + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_2 , POS_Y_PREVIEW ) ; + Size = MAP_APPFONT ( WIDTH_PREVIEW , HEIGHT_PREVIEW ) ; + TabStop = TRUE ; + }; +}; + diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.cxx b/chart2/source/controller/dialogs/tp_AxisLabel.cxx new file mode 100644 index 000000000000..ae20b1db1d2b --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisLabel.cxx @@ -0,0 +1,326 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisLabel.cxx,v $ + * $Revision: 1.10.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_AxisLabel.hxx" + +#include "ResId.hxx" +#include "TabPages.hrc" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" + +// header for SvxChartTextOrientItem / SvxChartTextOrderItem +#include <svx/chrtitem.hxx> + +// header for SfxInt32Item +#include <svtools/intitem.hxx> +#include <svx/eeitem.hxx> +#include <svx/frmdiritem.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchAxisLabelTabPage::SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : + SfxTabPage( pParent, SchResId( TP_AXIS_LABEL ), rInAttrs ), + + aCbShowDescription( this, SchResId( CB_AXIS_LABEL_SCHOW_DESCR ) ), + + aFlOrder( this, SchResId( FL_AXIS_LABEL_ORDER ) ), + aRbSideBySide( this, SchResId( RB_AXIS_LABEL_SIDEBYSIDE ) ), + aRbUpDown( this, SchResId( RB_AXIS_LABEL_UPDOWN ) ), + aRbDownUp( this, SchResId( RB_AXIS_LABEL_DOWNUP ) ), + aRbAuto( this, SchResId( RB_AXIS_LABEL_AUTOORDER ) ), + + aFlSeparator( this, SchResId( FL_SEPARATOR ) ), + aFlTextFlow( this, SchResId( FL_AXIS_LABEL_TEXTFLOW ) ), + aCbTextOverlap( this, SchResId( CB_AXIS_LABEL_TEXTOVERLAP ) ), + aCbTextBreak( this, SchResId( CB_AXIS_LABEL_TEXTBREAK ) ), + + aFlOrient( this, SchResId( FL_AXIS_LABEL_ORIENTATION ) ), + aCtrlDial( this, SchResId( CT_AXIS_LABEL_DIAL ) ), + aFtRotate( this, SchResId( FT_AXIS_LABEL_DEGREES ) ), + aNfRotate( this, SchResId( NF_AXIS_LABEL_ORIENT ) ), + aCbStacked( this, SchResId( PB_AXIS_LABEL_TEXTSTACKED ) ), + aOrientHlp( aCtrlDial, aNfRotate, aCbStacked ), + + m_aFtTextDirection( this, SchResId( FT_AXIS_TEXTDIR ) ), + m_aLbTextDirection( this, SchResId( LB_AXIS_TEXTDIR ), &m_aFtTextDirection ), + + m_bShowStaggeringControls( true ), + + m_nInitialDegrees( 0 ), + m_bHasInitialDegrees( true ), + m_bInitialStacking( false ), + m_bHasInitialStacking( true ) +{ + FreeResource(); + + aCbStacked.EnableTriState( FALSE ); + aOrientHlp.AddDependentWindow( aFlOrient ); + aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK ); + + aCbShowDescription.SetClickHdl( LINK( this, SchAxisLabelTabPage, ToggleShowLabel ) ); + + // Make the fixed line separator vertical. + aFlSeparator.SetStyle (aFlSeparator.GetStyle() | WB_VERT); + + Construct(); +} + +SchAxisLabelTabPage::~SchAxisLabelTabPage() +{} + +void SchAxisLabelTabPage::Construct() +{ +} + + +SfxTabPage* SchAxisLabelTabPage::Create( Window* pParent, const SfxItemSet& rAttrs ) +{ + return new SchAxisLabelTabPage( pParent, rAttrs ); +} + +BOOL SchAxisLabelTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + bool bStacked = false; + if( aOrientHlp.GetStackedState() != STATE_DONTKNOW ) + { + bStacked = aOrientHlp.GetStackedState() == STATE_CHECK; + if( !m_bHasInitialStacking || (bStacked != m_bInitialStacking) ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) ); + } + + if( aCtrlDial.HasRotation() ) + { + sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation(); + if( !m_bHasInitialDegrees || (nDegrees != m_nInitialDegrees) ) + rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); + } + + if( m_bShowStaggeringControls ) + { + SvxChartTextOrder eOrder = CHTXTORDER_SIDEBYSIDE; + bool bRadioButtonChecked = true; + + if( aRbUpDown.IsChecked()) + eOrder = CHTXTORDER_UPDOWN; + else if( aRbDownUp.IsChecked()) + eOrder = CHTXTORDER_DOWNUP; + else if( aRbAuto.IsChecked()) + eOrder = CHTXTORDER_AUTO; + else if( aRbSideBySide.IsChecked()) + eOrder = CHTXTORDER_SIDEBYSIDE; + else + bRadioButtonChecked = false; + + if( bRadioButtonChecked ) + rOutAttrs.Put( SvxChartTextOrderItem( eOrder, SCHATTR_TEXT_ORDER )); + } + + if( aCbTextOverlap.GetState() != STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_OVERLAP, aCbTextOverlap.IsChecked() ) ); + if( aCbTextBreak.GetState() != STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXTBREAK, aCbTextBreak.IsChecked() ) ); + if( aCbShowDescription.GetState() != STATE_DONTKNOW ) + rOutAttrs.Put( SfxBoolItem( SCHATTR_AXIS_SHOWDESCR, aCbShowDescription.IsChecked() ) ); + + if( m_aLbTextDirection.GetSelectEntryCount() > 0 ) + rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) ); + + return TRUE; +} + +void SchAxisLabelTabPage::Reset( const SfxItemSet& rInAttrs ) +{ + const SfxPoolItem* pPoolItem = NULL; + SfxItemState aState = SFX_ITEM_UNKNOWN; + + // show description ---------- + aState = rInAttrs.GetItemState( SCHATTR_AXIS_SHOWDESCR, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_DONTCARE ) + { + aCbShowDescription.EnableTriState( TRUE ); + aCbShowDescription.SetState( STATE_DONTKNOW ); + } + else + { + aCbShowDescription.EnableTriState( FALSE ); + BOOL bCheck = FALSE; + if( aState == SFX_ITEM_SET ) + bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + aCbShowDescription.Check( bCheck ); + + if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) + aCbShowDescription.Hide(); + } + + // Rotation as orient item or in degrees ---------- + + // check new degree item + m_nInitialDegrees = 0; + aState = rInAttrs.GetItemState( SCHATTR_TEXT_DEGREES, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_SET ) + m_nInitialDegrees = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + + m_bHasInitialDegrees = aState != SFX_ITEM_DONTCARE; + if( m_bHasInitialDegrees ) + aCtrlDial.SetRotation( m_nInitialDegrees ); + else + aCtrlDial.SetNoRotation(); + + // check stacked item + m_bInitialStacking = false; + aState = rInAttrs.GetItemState( SCHATTR_TEXT_STACKED, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_SET ) + m_bInitialStacking = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + + m_bHasInitialStacking = aState != SFX_ITEM_DONTCARE; + if( m_bHasInitialDegrees ) + aOrientHlp.SetStackedState( m_bInitialStacking ? STATE_CHECK : STATE_NOCHECK ); + else + aOrientHlp.SetStackedState( STATE_DONTKNOW ); + + if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); + + // Text overlap ---------- + aState = rInAttrs.GetItemState( SCHATTR_TEXT_OVERLAP, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_DONTCARE ) + { + aCbTextOverlap.EnableTriState( TRUE ); + aCbTextOverlap.SetState( STATE_DONTKNOW ); + } + else + { + aCbTextOverlap.EnableTriState( FALSE ); + BOOL bCheck = FALSE; + if( aState == SFX_ITEM_SET ) + bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + aCbTextOverlap.Check( bCheck ); + + if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) + aCbTextOverlap.Hide(); + } + + // text break ---------- + aState = rInAttrs.GetItemState( SCHATTR_TEXTBREAK, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_DONTCARE ) + { + aCbTextBreak.EnableTriState( TRUE ); + aCbTextBreak.SetState( STATE_DONTKNOW ); + } + else + { + aCbTextBreak.EnableTriState( FALSE ); + BOOL bCheck = FALSE; + if( aState == SFX_ITEM_SET ) + bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + aCbTextBreak.Check( bCheck ); + + if( ( aState & SFX_ITEM_DEFAULT ) == 0 ) + { + aCbTextBreak.Hide(); + if( ! aCbTextOverlap.IsVisible() ) + aFlTextFlow.Hide(); + } + } + + // text order ---------- + if( m_bShowStaggeringControls ) + { + aState = rInAttrs.GetItemState( SCHATTR_TEXT_ORDER, FALSE, &pPoolItem ); + if( aState == SFX_ITEM_SET ) + { + SvxChartTextOrder eOrder = static_cast< const SvxChartTextOrderItem * >( pPoolItem )->GetValue(); + + switch( eOrder ) + { + case CHTXTORDER_SIDEBYSIDE: + aRbSideBySide.Check(); + break; + case CHTXTORDER_UPDOWN: + aRbUpDown.Check(); + break; + case CHTXTORDER_DOWNUP: + aRbDownUp.Check(); + break; + case CHTXTORDER_AUTO: + aRbAuto.Check(); + break; + } + } + } + + ToggleShowLabel( (void*)0 ); +} + +void SchAxisLabelTabPage::ShowStaggeringControls( BOOL bShowStaggeringControls ) +{ + m_bShowStaggeringControls = bShowStaggeringControls; + + if( !m_bShowStaggeringControls ) + { + aRbSideBySide.Hide(); + aRbUpDown.Hide(); + aRbDownUp.Hide(); + aRbAuto.Hide(); + aFlOrder.Hide(); + } +} + +// event handling routines +// ----------------------- + +IMPL_LINK ( SchAxisLabelTabPage, ToggleShowLabel, void *, EMPTYARG ) +{ + BOOL bEnable = ( aCbShowDescription.GetState() != STATE_NOCHECK ); + + aOrientHlp.Enable( bEnable ); + aFlOrder.Enable( bEnable ); + aRbSideBySide.Enable( bEnable ); + aRbUpDown.Enable( bEnable ); + aRbDownUp.Enable( bEnable ); + aRbAuto.Enable( bEnable ); + + aFlTextFlow.Enable( bEnable ); + aCbTextOverlap.Enable( bEnable ); + aCbTextBreak.Enable( bEnable ); + + m_aFtTextDirection.Enable( bEnable ); + m_aLbTextDirection.Enable( bEnable ); + + return 0L; +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.hxx b/chart2/source/controller/dialogs/tp_AxisLabel.hxx new file mode 100644 index 000000000000..1e0aa8e578f0 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisLabel.hxx @@ -0,0 +1,102 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisLabel.hxx,v $ + * $Revision: 1.8.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_AXISLABEL_HXX +#define _CHART2_TP_AXISLABEL_HXX + +#include <sfx2/tabdlg.hxx> +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <svx/dialcontrol.hxx> +#include <svx/wrapfield.hxx> +#include <svx/orienthelper.hxx> +#include "TextDirectionListBox.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class SchAxisLabelTabPage : public SfxTabPage +{ +private: + CheckBox aCbShowDescription; + + FixedLine aFlOrder; + RadioButton aRbSideBySide; + RadioButton aRbUpDown; + RadioButton aRbDownUp; + RadioButton aRbAuto; + + FixedLine aFlSeparator; + FixedLine aFlTextFlow; + CheckBox aCbTextOverlap; + CheckBox aCbTextBreak; + + FixedLine aFlOrient; + svx::DialControl aCtrlDial; + FixedText aFtRotate; + svx::WrapField aNfRotate; + TriStateBox aCbStacked; + svx::OrientationHelper aOrientHlp; + + FixedText m_aFtTextDirection; + TextDirectionListBox m_aLbTextDirection; + + BOOL m_bShowStaggeringControls; + + sal_Int32 m_nInitialDegrees; + bool m_bHasInitialDegrees; /// false = DialControl in tristate + bool m_bInitialStacking; + bool m_bHasInitialStacking; /// false = checkbox in tristate + + DECL_LINK ( ToggleShowLabel, void* ); + +public: + SchAxisLabelTabPage( Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~SchAxisLabelTabPage(); + + void Construct(); + + static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); + virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual void Reset( const SfxItemSet& rInAttrs ); + + void ShowStaggeringControls( BOOL bShowStaggeringControls ); +}; +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/tp_AxisLabel.src b/chart2/source/controller/dialogs/tp_AxisLabel.src new file mode 100644 index 000000000000..090ef525de8f --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisLabel.src @@ -0,0 +1,189 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisLabel.src,v $ + * $Revision: 1.10.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" + +TabPage TP_AXIS_LABEL +{ + HelpID = HID_SCH_TP_AXIS_LABEL; + Size = MAP_APPFONT ( 260 , 185 ) ; + Hide = TRUE; + + CheckBox CB_AXIS_LABEL_SCHOW_DESCR + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 248 , 12 ) ; + + Text [ en-US ] = "Sho~w labels"; + }; + + FixedLine FL_AXIS_LABEL_ORIENTATION + { + Pos = MAP_APPFONT ( 6 , 91 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + + Text [ en-US ] = "Text orientation" ; + }; + Control CT_AXIS_LABEL_DIAL + { + HelpId = HID_SCH_ALIGNMENT_CTR_DIAL ; + Pos = MAP_APPFONT ( 12 , 105 ) ; + Size = MAP_APPFONT ( 43 , 43 ) ; + Text = "ABCD" ; + }; + TriStateBox PB_AXIS_LABEL_TEXTSTACKED + { + HelpId = HID_SCH_ALIGNMENT_STACKED ; + Pos = MAP_APPFONT ( 139 , 105 ) ; + Size = MAP_APPFONT ( 115 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Ve~rtically stacked"; + }; + FixedText FT_AXIS_LABEL_DEGREES + { + Pos = MAP_APPFONT ( 93 , 122 ) ; + Size = MAP_APPFONT ( 60 , 8 ) ; + Text [ en-US ] = "~Degrees" ; + }; + NumericField NF_AXIS_LABEL_ORIENT + { + HelpId = HID_SCH_ALIGNMENT_DEGREES ; + Border = TRUE ; + Pos = MAP_APPFONT ( 61 , 120 ) ; + Size = MAP_APPFONT ( 28 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + StrictFormat = TRUE ; + SpinSize = 5 ; + Minimum = 0 ; + Maximum = 359 ; + }; + FixedText FT_UNUSED + { + //only necessary for constructor of SvxWinOrientation + Hide = TRUE ; + Pos = MAP_APPFONT ( 204 , 117 ) ; + Size = MAP_APPFONT ( 50 , 10 ) ; + }; + Control CT_UNUSED + { + //only necessary for constructor of SvxWinOrientation + Hide = TRUE ; + Pos = MAP_APPFONT ( 204 , 133 ) ; + Size = MAP_APPFONT ( 50 , 15 ) ; + }; + FixedLine FL_SEPARATOR + { + Pos = MAP_APPFONT ( 128 , 33 ) ; + Size = MAP_APPFONT ( 4 , 52 ) ; + }; + + FixedLine FL_AXIS_LABEL_TEXTFLOW + { + Pos = MAP_APPFONT ( 133 , 22 ) ; + Size = MAP_APPFONT ( 121 , 8 ) ; + + Text [ en-US ] = "Text flow" ; + }; + CheckBox CB_AXIS_LABEL_TEXTOVERLAP + { + Pos = MAP_APPFONT ( 139 , 33 ) ; + Size = MAP_APPFONT ( 115 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "O~verlap" ; + }; + CheckBox CB_AXIS_LABEL_TEXTBREAK + { + Pos = MAP_APPFONT ( 139 , 47 ) ; + Size = MAP_APPFONT ( 115 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "~Break" ; + }; + + + FixedLine FL_AXIS_LABEL_ORDER + { + Pos = MAP_APPFONT ( 6 , 22 ) ; + Size = MAP_APPFONT ( 121 , 8 ) ; + + Text [ en-US ] = "Order" ; + }; + RadioButton RB_AXIS_LABEL_SIDEBYSIDE + { + Pos = MAP_APPFONT ( 12 , 33 ) ; + Size = MAP_APPFONT ( 112 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "~Tile" ; + }; + RadioButton RB_AXIS_LABEL_UPDOWN + { + Pos = MAP_APPFONT ( 12 , 47 ) ; + Size = MAP_APPFONT ( 112 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "St~agger odd" ; + }; + RadioButton RB_AXIS_LABEL_DOWNUP + { + Pos = MAP_APPFONT ( 12 , 61 ) ; + Size = MAP_APPFONT ( 112 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "Stagger ~even" ; + }; + RadioButton RB_AXIS_LABEL_AUTOORDER + { + Pos = MAP_APPFONT ( 12 , 75 ) ; + Size = MAP_APPFONT ( 112 , 10 ) ; + TabStop = TRUE ; + + Text [ en-US ] = "A~utomatic" ; + }; + + FixedText FT_AXIS_TEXTDIR + { + Pos = MAP_APPFONT ( 12 , 156 ) ; + Size = MAP_APPFONT ( 64 , 8 ) ; + Text [ en-US ] = "Te~xt direction" ; + }; + ListBox LB_AXIS_TEXTDIR + { + Pos = MAP_APPFONT ( 78 , 154 ) ; + Size = MAP_APPFONT ( 170 , 100 ) ; + Border = TRUE; + TabStop = TRUE; + DropDown = TRUE; + }; +}; + diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.cxx b/chart2/source/controller/dialogs/tp_AxisPositions.cxx new file mode 100644 index 000000000000..d1e17f677646 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisPositions.cxx @@ -0,0 +1,501 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisPositions.cxx,v $ + * $Revision: 1.1.4.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_AxisPositions.hxx" + +#include "ResId.hxx" +#include "TabPages.hrc" +#include "Strings.hrc" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "AxisHelper.hxx" + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#include <rtl/math.hxx> +// header for class SvxDoubleItem +#include <svx/chrtitem.hxx> +// header for class SfxBoolItem +#include <svtools/eitem.hxx> +// header for SfxInt32Item +#include <svtools/intitem.hxx> + +// header for class WarningBox +#include <vcl/msgbox.hxx> + +// header for class SvNumberformat +#ifndef _ZFORMAT_HXX +#ifndef _ZFORLIST_DECLARE_TABLE +#define _ZFORLIST_DECLARE_TABLE +#endif +#include <svtools/zformat.hxx> +#endif + +#include <svtools/controldims.hrc> + +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart2/AxisType.hpp> + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +namespace +{ +void lcl_newXPos( Control& rControl, long nXPos ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.X() = nXPos; + rControl.SetPosPixel(aPos); +} + +void lcl_shiftY( Control& rControl, long nYDiff ) +{ + Point aPos( rControl.GetPosPixel() ); + aPos.Y() += nYDiff; + rControl.SetPosPixel(aPos); +} + +} + +AxisPositionsTabPage::AxisPositionsTabPage(Window* pWindow,const SfxItemSet& rInAttrs) + : SfxTabPage(pWindow, SchResId(TP_AXIS_POSITIONS), rInAttrs) + + , m_aFL_AxisLine(this,SchResId(FL_AXIS_LINE)) + , m_aFT_CrossesAt(this,SchResId(FT_CROSSES_OTHER_AXIS_AT)) + , m_aLB_CrossesAt(this,SchResId(LB_CROSSES_OTHER_AXIS_AT)) + , m_aED_CrossesAt(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT)) + , m_aED_CrossesAtCategory(this,SchResId(EDT_CROSSES_OTHER_AXIS_AT_CATEGORY)) + , m_aCB_AxisBetweenCategories(this, SchResId(CB_AXIS_BETWEEN_CATEGORIES)) + + , m_aFL_Labels(this,SchResId(FL_LABELS)) + , m_aFT_PlaceLabels( this, SchResId( FT_PLACE_LABELS ) ) + , m_aLB_PlaceLabels( this, SchResId( LB_PLACE_LABELS ) ) + , m_aFT_LabelDistance( this, SchResId( FT_AXIS_LABEL_DISTANCE ) ) + , m_aED_LabelDistance( this, SchResId( EDT_AXIS_LABEL_DISTANCE ) ) + + , m_aFL_Ticks(this,SchResId(FL_TICKS)) + , m_aFT_Major(this,SchResId(FT_MAJOR)) + , m_aCB_TicksInner(this,SchResId(CB_TICKS_INNER)) + , m_aCB_TicksOuter(this,SchResId(CB_TICKS_OUTER)) + , m_aFT_Minor(this,SchResId(FT_MINOR)) + , m_aCB_MinorInner(this,SchResId(CB_MINOR_INNER)) + , m_aCB_MinorOuter(this,SchResId(CB_MINOR_OUTER)) + + , m_aFL_Vertical(this,SchResId(FL_VERTICAL)) + , m_aFT_PlaceTicks(this,SchResId(FT_PLACE_TICKS)) + , m_aLB_PlaceTicks(this,SchResId(LB_PLACE_TICKS)) + + , m_aFL_Grids(this,SchResId(FL_GRIDS)) + , m_aCB_MajorGrid(this,SchResId(CB_MAJOR_GRID)) + , m_aPB_MajorGrid(this,SchResId(PB_MAJOR_GRID)) + , m_aCB_MinorGrid(this,SchResId(CB_MINOR_GRID)) + , m_aPB_MinorGrid(this,SchResId(PB_MINOR_GRID)) + + , m_pNumFormatter(NULL) + , m_bCrossingAxisIsCategoryAxis(false) + , m_aCategories() +{ + FreeResource(); + SetExchangeSupport(); + + const long nDialogWidth = GetSizePixel().Width(); + const long nDistance = LogicToPixel( Size(RSC_SP_CTRL_X, 0), MapMode(MAP_APPFONT) ).Width(); + + //axis line controls + { + if( m_aFT_CrossesAt.CalcMinimumSize().Width() < m_aFT_CrossesAt.GetSizePixel().Width() ) + { + m_aFT_CrossesAt.SetSizePixel(m_aFT_CrossesAt.CalcMinimumSize()); + long nXPos = m_aFT_CrossesAt.GetPosPixel().X() + m_aFT_CrossesAt.GetSizePixel().Width() + nDistance; + lcl_newXPos( m_aLB_CrossesAt, nXPos ); + + nXPos += m_aLB_CrossesAt.GetSizePixel().Width() + nDistance; + lcl_newXPos( m_aED_CrossesAt, nXPos ); + lcl_newXPos( m_aED_CrossesAtCategory, nXPos ); + } + } + + long nFixTextHeight = m_aFT_PlaceLabels.GetSizePixel().Height(); + long nLabelPlacementWidth = m_aFT_PlaceLabels.CalcMinimumSize().Width(); + long nMarkPlacementWidth = m_aFT_PlaceTicks.CalcMinimumSize().Width(); + + + long nWidth_0 = ::std::max( m_aFT_Major.CalcMinimumSize().Width(), m_aFT_Minor.CalcMinimumSize().Width() ); + nWidth_0 = ::std::max( nWidth_0, nLabelPlacementWidth ); + nWidth_0 = ::std::max( nWidth_0, nMarkPlacementWidth ); + nLabelPlacementWidth = nMarkPlacementWidth = nWidth_0; + + //label placement + { + m_aFT_PlaceLabels.SetSizePixel( Size( nLabelPlacementWidth, nFixTextHeight ) ); + long nXPos = m_aFT_PlaceLabels.GetPosPixel().X() + nLabelPlacementWidth + nDistance; + lcl_newXPos( m_aLB_PlaceLabels, nXPos ); + m_aLB_PlaceLabels.SetSizePixel(m_aLB_PlaceLabels.CalcMinimumSize()); + } + + //tickmark placement + { + m_aFT_PlaceTicks.SetSizePixel( Size( nMarkPlacementWidth, nFixTextHeight ) ); + long nXPos = m_aFT_PlaceTicks.GetPosPixel().X() + nMarkPlacementWidth + nDistance; + lcl_newXPos( m_aLB_PlaceTicks, nXPos ); + m_aLB_PlaceTicks.SetSizePixel( m_aLB_PlaceTicks.CalcMinimumSize() ); + } + + //tickmark controls + { + long nWidth_1 = ::std::max( m_aCB_TicksInner.CalcMinimumSize().Width(), m_aCB_MinorInner.CalcMinimumSize().Width() ); + long nWidth_2 = ::std::max( m_aCB_TicksOuter.CalcMinimumSize().Width(), m_aCB_MinorOuter.CalcMinimumSize().Width() ); + + long nLeftSpace = nDialogWidth - nWidth_0 - nWidth_1 - nWidth_2 - 3*nDistance; + + if(nLeftSpace>=0) + { + m_aFT_Major.SetSizePixel(m_aFT_Major.CalcMinimumSize()); + m_aFT_Minor.SetSizePixel(m_aFT_Minor.CalcMinimumSize()); + + m_aCB_TicksInner.SetSizePixel( m_aCB_TicksInner.CalcMinimumSize() ); + m_aCB_MinorInner.SetSizePixel( m_aCB_MinorInner.CalcMinimumSize() ); + + m_aCB_TicksOuter.SetSizePixel( m_aCB_TicksOuter.CalcMinimumSize() ); + m_aCB_MinorOuter.SetSizePixel( m_aCB_MinorOuter.CalcMinimumSize() ); + + long nXPos = m_aFT_Major.GetPosPixel().X() + nWidth_0 + nDistance; + lcl_newXPos( m_aCB_TicksInner, nXPos ); + lcl_newXPos( m_aCB_MinorInner, nXPos ); + + nXPos += nWidth_1 + nDistance; + lcl_newXPos( m_aCB_TicksOuter, nXPos ); + lcl_newXPos( m_aCB_MinorOuter, nXPos ); + + nXPos += nWidth_2 + nDistance; + lcl_newXPos( m_aFL_Vertical, nXPos ); + } + } + + //right alignement of listboxes: + { + long nLabelRightBorder = m_aLB_PlaceLabels.GetPosPixel().X() + m_aLB_PlaceLabels.GetSizePixel().Width(); + long nTickmarksRightBorder = m_aLB_PlaceTicks.GetPosPixel().X() + m_aLB_PlaceTicks.GetSizePixel().Width(); + + long nNewRightBorder = ::std::max( m_aLB_CrossesAt.GetPosPixel().X() + m_aLB_CrossesAt.GetSizePixel().Width(), nLabelRightBorder); + nNewRightBorder = ::std::max( nTickmarksRightBorder, nNewRightBorder ); + + long nListBoxHeight = m_aLB_PlaceLabels.GetSizePixel().Height(); + m_aLB_PlaceLabels.SetSizePixel( Size( m_aLB_PlaceLabels.GetSizePixel().Width()+nNewRightBorder-nLabelRightBorder, nListBoxHeight ) ); + m_aLB_PlaceTicks.SetSizePixel( Size( m_aLB_PlaceTicks.GetSizePixel().Width()+nNewRightBorder-nTickmarksRightBorder, nListBoxHeight ) ); + } + + m_aLB_CrossesAt.SetSelectHdl( LINK( this, AxisPositionsTabPage, CrossesAtSelectHdl ) ); + m_aLB_CrossesAt.SetDropDownLineCount( m_aLB_CrossesAt.GetEntryCount() ); + + m_aLB_PlaceLabels.SetSelectHdl( LINK( this, AxisPositionsTabPage, PlaceLabelsSelectHdl ) ); + m_aLB_PlaceLabels.SetDropDownLineCount( m_aLB_PlaceLabels.GetEntryCount() ); + m_aLB_PlaceTicks.SetDropDownLineCount( m_aLB_PlaceTicks.GetEntryCount() ); +} + +SfxTabPage* AxisPositionsTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) +{ + return new AxisPositionsTabPage(pWindow, rOutAttrs); +} + +BOOL AxisPositionsTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + // axis line + USHORT nPos = m_aLB_CrossesAt.GetSelectEntryPos(); + rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_POSITION, nPos+1 )); + if( 2==nPos ) + { + double fCrossover = m_aED_CrossesAt.GetValue(); + if( m_bCrossingAxisIsCategoryAxis ) + fCrossover = m_aED_CrossesAtCategory.GetSelectEntryPos()+1; + rOutAttrs.Put(SvxDoubleItem(fCrossover,SCHATTR_AXIS_POSITION_VALUE)); + } + + // labels + USHORT nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); + if( nLabelPos != LISTBOX_ENTRY_NOTFOUND ) + rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_LABEL_POSITION, nLabelPos )); + + // tick marks + long nTicks=0; + long nMinorTicks=0; + + if(m_aCB_MinorInner.IsChecked()) + nMinorTicks|=CHAXIS_MARK_INNER; + if(m_aCB_MinorOuter.IsChecked()) + nMinorTicks|=CHAXIS_MARK_OUTER; + if(m_aCB_TicksInner.IsChecked()) + nTicks|=CHAXIS_MARK_INNER; + if(m_aCB_TicksOuter.IsChecked()) + nTicks|=CHAXIS_MARK_OUTER; + + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_TICKS,nTicks)); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_HELPTICKS,nMinorTicks)); + + USHORT nMarkPos = m_aLB_PlaceTicks.GetSelectEntryPos(); + if( nMarkPos != LISTBOX_ENTRY_NOTFOUND ) + rOutAttrs.Put( SfxInt32Item( SCHATTR_AXIS_MARK_POSITION, nMarkPos )); + + return TRUE; +} + +void AxisPositionsTabPage::Reset(const SfxItemSet& rInAttrs) +{ + //init and enable controls + m_aED_CrossesAt.Show( !m_bCrossingAxisIsCategoryAxis ); + m_aED_CrossesAtCategory.Show( m_bCrossingAxisIsCategoryAxis ); + const sal_Int32 nMaxCount = LISTBOX_ENTRY_NOTFOUND; + if( m_bCrossingAxisIsCategoryAxis ) + { + for( sal_Int32 nN=0; nN<m_aCategories.getLength() && nN<nMaxCount; nN++ ) + m_aED_CrossesAtCategory.InsertEntry( m_aCategories[nN] ); + + USHORT nCount = m_aED_CrossesAtCategory.GetEntryCount(); + if( nCount>30 ) + nCount=30; + m_aED_CrossesAtCategory.SetDropDownLineCount( nCount ); + } + + if( m_aLB_CrossesAt.GetEntryCount() > 3 ) + { + if( m_bCrossingAxisIsCategoryAxis ) + m_aLB_CrossesAt.RemoveEntry(2); + else + m_aLB_CrossesAt.RemoveEntry(3); + } + + //fill controls + const SfxPoolItem *pPoolItem = NULL; + + //axis line + if(rInAttrs.GetItemState(SCHATTR_AXIS_POSITION,TRUE, &pPoolItem)== SFX_ITEM_SET) + { + bool bZero = false; + USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + if(nPos==0) + { + //switch to value + bZero = true; + nPos = 2; + } + else + nPos--; + + if( nPos < m_aLB_CrossesAt.GetEntryCount() ) + m_aLB_CrossesAt.SelectEntryPos( nPos ); + CrossesAtSelectHdl( (void*)0 ); + + if( rInAttrs.GetItemState(SCHATTR_AXIS_POSITION_VALUE,TRUE, &pPoolItem)== SFX_ITEM_SET || bZero ) + { + double fCrossover = 0.0; + if( !bZero ) + fCrossover = (((const SvxDoubleItem*)pPoolItem)->GetValue()); + if( m_bCrossingAxisIsCategoryAxis ) + m_aED_CrossesAtCategory.SelectEntryPos( static_cast<USHORT>(::rtl::math::round(fCrossover-1.0)) ); + else + m_aED_CrossesAt.SetValue(fCrossover); + } + else + { + m_aED_CrossesAtCategory.SetNoSelection(); + m_aED_CrossesAt.SetTextValue(XubString()); + } + } + else + { + m_aLB_CrossesAt.SetNoSelection(); + m_aED_CrossesAt.Enable( FALSE ); + } + + // Labels + if( rInAttrs.GetItemState( SCHATTR_AXIS_LABEL_POSITION, FALSE, &pPoolItem ) == SFX_ITEM_SET ) + { + USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + if( nPos < m_aLB_PlaceLabels.GetEntryCount() ) + m_aLB_PlaceLabels.SelectEntryPos( nPos ); + } + else + m_aLB_PlaceLabels.SetNoSelection(); + PlaceLabelsSelectHdl( (void*)0 ); + + // Tick marks + long nTicks=0,nMinorTicks=0; + if(rInAttrs.GetItemState(SCHATTR_AXIS_TICKS,TRUE, &pPoolItem)== SFX_ITEM_SET) + nTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); + if(rInAttrs.GetItemState(SCHATTR_AXIS_HELPTICKS,TRUE, &pPoolItem)== SFX_ITEM_SET) + nMinorTicks=((const SfxInt32Item*)pPoolItem)->GetValue(); + + m_aCB_TicksInner.Check(BOOL(nTicks&CHAXIS_MARK_INNER)); + m_aCB_TicksOuter.Check(BOOL(nTicks&CHAXIS_MARK_OUTER)); + m_aCB_MinorInner.Check(BOOL(nMinorTicks&CHAXIS_MARK_INNER)); + m_aCB_MinorOuter.Check(BOOL(nMinorTicks&CHAXIS_MARK_OUTER)); + + // Tick position + if( rInAttrs.GetItemState( SCHATTR_AXIS_MARK_POSITION, FALSE, &pPoolItem ) == SFX_ITEM_SET ) + { + USHORT nPos = (USHORT)static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + if( nPos < m_aLB_PlaceTicks.GetEntryCount() ) + m_aLB_PlaceTicks.SelectEntryPos( nPos ); + } + else + m_aLB_PlaceTicks.SetNoSelection(); + + + if( !m_bSupportAxisPositioning ) + { + m_aFL_AxisLine.Show(false); + m_aFT_CrossesAt.Show(false); + m_aLB_CrossesAt.Show(false); + m_aED_CrossesAt.Show(false); + m_aED_CrossesAtCategory.Show(false); + m_aCB_AxisBetweenCategories.Show(false); + + m_aFL_Labels.Show(false); + m_aFT_PlaceLabels.Show(false); + m_aLB_PlaceLabels.Show(false); + m_aFT_LabelDistance.Show(false); + m_aED_LabelDistance.Show(false); + + m_aFL_Vertical.Show(false); + m_aFT_PlaceTicks.Show(false); + m_aLB_PlaceTicks.Show(false); + + long nYDiff = m_aFL_AxisLine.GetPosPixel().Y() - m_aFL_Ticks.GetPosPixel().Y(); + lcl_shiftY( m_aFL_Ticks, nYDiff ); + lcl_shiftY( m_aFT_Major, nYDiff ); + lcl_shiftY( m_aCB_TicksInner, nYDiff ); + lcl_shiftY( m_aCB_TicksOuter, nYDiff ); + + lcl_shiftY( m_aFT_Minor, nYDiff ); + lcl_shiftY( m_aCB_MinorInner, nYDiff ); + lcl_shiftY( m_aCB_MinorOuter, nYDiff ); + } + else if( !AxisHelper::isAxisPositioningEnabled() ) + { + m_aFL_AxisLine.Enable(false); + m_aFT_CrossesAt.Enable(false); + m_aLB_CrossesAt.Enable(false); + m_aED_CrossesAt.Enable(false); + m_aED_CrossesAtCategory.Enable(false); + m_aCB_AxisBetweenCategories.Enable(false); + + m_aFL_Labels.Enable(false); + m_aFT_PlaceLabels.Enable(false); + m_aLB_PlaceLabels.Enable(false); + m_aFT_LabelDistance.Enable(false); + m_aED_LabelDistance.Enable(false); + + m_aFL_Vertical.Enable(false); + m_aFT_PlaceTicks.Enable(false); + m_aLB_PlaceTicks.Enable(false); + + //todo: maybe set a special help id to all those controls + } +} + +int AxisPositionsTabPage::DeactivatePage(SfxItemSet* pItemSet) +{ + if( pItemSet ) + FillItemSet( *pItemSet ); + + return LEAVE_PAGE; +} + +void AxisPositionsTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) +{ + m_pNumFormatter = pFormatter; + m_aED_CrossesAt.SetFormatter( m_pNumFormatter ); + m_aED_CrossesAt.UseInputStringForFormatting(); + + const SfxPoolItem *pPoolItem = NULL; + if( GetItemSet().GetItemState( SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + ULONG nFmt = (ULONG)((const SfxInt32Item*)pPoolItem)->GetValue(); + m_aED_CrossesAt.SetFormatKey( nFmt ); + } +} + +void AxisPositionsTabPage::SetCrossingAxisIsCategoryAxis( bool bCrossingAxisIsCategoryAxis ) +{ + m_bCrossingAxisIsCategoryAxis = bCrossingAxisIsCategoryAxis; +} + +void AxisPositionsTabPage::SetCategories( const ::com::sun::star::uno::Sequence< rtl::OUString >& rCategories ) +{ + m_aCategories = rCategories; +} + +void AxisPositionsTabPage::SupportAxisPositioning( bool bSupportAxisPositioning ) +{ + m_bSupportAxisPositioning = bSupportAxisPositioning; +} + +IMPL_LINK ( AxisPositionsTabPage, CrossesAtSelectHdl, void *, EMPTYARG ) +{ + USHORT nPos = m_aLB_CrossesAt.GetSelectEntryPos(); + m_aED_CrossesAt.Show( (2==nPos) && !m_bCrossingAxisIsCategoryAxis ); + m_aED_CrossesAtCategory.Show( (2==nPos) && m_bCrossingAxisIsCategoryAxis ); + + if(! m_aED_CrossesAt.GetText().Len() ) + m_aED_CrossesAt.SetValue(0.0); + if( 0 == m_aED_CrossesAtCategory.GetSelectEntryCount() ) + m_aED_CrossesAtCategory.SelectEntryPos(0); + + PlaceLabelsSelectHdl( (void*)0 ); + return 0; +} + +IMPL_LINK ( AxisPositionsTabPage, PlaceLabelsSelectHdl, void *, EMPTYARG ) +{ + USHORT nLabelPos = m_aLB_PlaceLabels.GetSelectEntryPos(); + + bool bEnableTickmarkPlacement = (nLabelPos>1); + if( bEnableTickmarkPlacement ) + { + USHORT nAxisPos = m_aLB_CrossesAt.GetSelectEntryPos(); + if( nLabelPos-2 == nAxisPos ) + bEnableTickmarkPlacement=false; + } + m_aFT_PlaceTicks.Enable(bEnableTickmarkPlacement); + m_aLB_PlaceTicks.Enable(bEnableTickmarkPlacement); + + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.hxx b/chart2/source/controller/dialogs/tp_AxisPositions.hxx new file mode 100644 index 000000000000..913f1a08a2f9 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisPositions.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisPositions.hxx,v $ + * $Revision: 1.1.4.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_AXISPOSITIONS_HXX +#define _CHART2_TP_AXISPOSITIONS_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> +#include <svtools/fmtfield.hxx> +#include <vcl/fixed.hxx> +#include <vcl/button.hxx> +#include <vcl/field.hxx> +#include <vcl/lstbox.hxx> +//class SvNumberFormatter; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class AxisPositionsTabPage : public SfxTabPage +{ +public: + AxisPositionsTabPage( Window* pParent, const SfxItemSet& rInAttrs ); + + static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); + virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual void Reset( const SfxItemSet& rInAttrs ); + using TabPage::DeactivatePage; + virtual int DeactivatePage( SfxItemSet* pItemSet = NULL ); + + void SetNumFormatter( SvNumberFormatter* pFormatter ); + + void SetCrossingAxisIsCategoryAxis( bool bCrossingAxisIsCategoryAxis ); + void SetCategories( const ::com::sun::star::uno::Sequence< rtl::OUString >& rCategories ); + + void SupportAxisPositioning( bool bSupportAxisPositioning ); + +private: //methods: + DECL_LINK( CrossesAtSelectHdl, void* ); + DECL_LINK( PlaceLabelsSelectHdl, void* ); + +private: //member: + FixedLine m_aFL_AxisLine; + FixedText m_aFT_CrossesAt; + ListBox m_aLB_CrossesAt; + FormattedField m_aED_CrossesAt; + ComboBox m_aED_CrossesAtCategory; + CheckBox m_aCB_AxisBetweenCategories; + + FixedLine m_aFL_Labels; + FixedText m_aFT_PlaceLabels; + ListBox m_aLB_PlaceLabels; + FixedText m_aFT_LabelDistance; + FormattedField m_aED_LabelDistance; + + FixedLine m_aFL_Ticks; + + FixedText m_aFT_Major; + CheckBox m_aCB_TicksInner; + CheckBox m_aCB_TicksOuter; + + FixedText m_aFT_Minor; + CheckBox m_aCB_MinorInner; + CheckBox m_aCB_MinorOuter; + + FixedLine m_aFL_Vertical; + FixedText m_aFT_PlaceTicks; + ListBox m_aLB_PlaceTicks; + + FixedLine m_aFL_Grids; + CheckBox m_aCB_MajorGrid; + PushButton m_aPB_MajorGrid; + CheckBox m_aCB_MinorGrid; + PushButton m_aPB_MinorGrid; + + SvNumberFormatter* m_pNumFormatter; + + bool m_bCrossingAxisIsCategoryAxis; + ::com::sun::star::uno::Sequence< rtl::OUString > m_aCategories; + + bool m_bSupportAxisPositioning; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_AxisPositions.src b/chart2/source/controller/dialogs/tp_AxisPositions.src new file mode 100644 index 000000000000..1628c1afaa3f --- /dev/null +++ b/chart2/source/controller/dialogs/tp_AxisPositions.src @@ -0,0 +1,295 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_AxisPositions.src,v $ + * $Revision: 1.1.4.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" + +#define Y0 3 +#define Y1 (Y0+13) +#define Y2 (Y1) +#define Y3 (Y2+16) +#define Y4 (Y3+13) +#define Y5 (Y4) +#define Y6 (Y5+16) +#define Y7 (Y6+13) +#define Y8 (Y7+16) +#define Y9 (Y8+16) +#define Y10 (Y9+16) +#define Y11 (Y10+13) +#define Y12 (Y11+16) + +#define EDITWIDTH 50 +#define LABELWIDTH 88 +#define MAXLABELWIDTH 138 + +#define X1 6 +#define X2 11 +#define X3 (X2+LABELWIDTH+4) +#define X4 (X2+MAXLABELWIDTH+4) +#define X5 (X4+EDITWIDTH+5) + +#define XTICK_1 X2 +#define XTICK_2 (XTICK_1+60) +#define XTICK_3 (XTICK_2+60) +#define XTICK_4 (XTICK_3+60) +#define XTICK_5 (XTICK_4+6) +#define TICKWIDTH 59 + +TabPage TP_AXIS_POSITIONS +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine FL_AXIS_LINE + { + Pos = MAP_APPFONT ( X1 , Y0 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Axis line" ; + }; + + FixedText FT_CROSSES_OTHER_AXIS_AT + { + Pos = MAP_APPFONT ( X2 , Y1 ) ; + Size = MAP_APPFONT ( MAXLABELWIDTH , 8 ) ; + Text [ en-US ] = "~Cross other axis at" ; + }; + ListBox LB_CROSSES_OTHER_AXIS_AT + { + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X4 , Y1-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Start" ; + "End" ; + "Value" ; + "Category" ; + }; + }; + SpinField EDT_CROSSES_OTHER_AXIS_AT + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X5 , Y1-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + }; + ComboBox EDT_CROSSES_OTHER_AXIS_AT_CATEGORY + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X5 , Y1-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + DropDown = TRUE ; + TabStop = TRUE ; + }; + + CheckBox CB_AXIS_BETWEEN_CATEGORIES + { + Hide = TRUE; + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Axis ~between categories" ; + }; + + FixedLine FL_LABELS + { + Pos = MAP_APPFONT ( X1 , Y3 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Labels" ; + }; + FixedText FT_PLACE_LABELS + { + Pos = MAP_APPFONT ( X2 , Y4 ) ; + Size = MAP_APPFONT ( MAXLABELWIDTH , 8 ) ; + Text [ en-US ] = "~Place labels" ; + }; + ListBox LB_PLACE_LABELS + { + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X4 , Y4-2 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "Near axis" ; + "Near axis (other side)" ; + "Outside start" ; + "Outside end" ; + }; + }; + + FixedText FT_AXIS_LABEL_DISTANCE + { + Hide = TRUE; + Pos = MAP_APPFONT ( X2 , Y5 ) ; + Size = MAP_APPFONT ( MAXLABELWIDTH , 8 ) ; + Text [ en-US ] = "~Distance" ; + }; + SpinField EDT_AXIS_LABEL_DISTANCE + { + Hide = TRUE; + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X4 , Y5-2 ) ; + Size = MAP_APPFONT ( 89 , 12 ) ; + TabStop = TRUE ; + }; + + FixedLine FL_TICKS + { + Pos = MAP_APPFONT ( X1 , Y6 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text[ en-US ] = "Interval marks"; + }; + FixedText FT_MAJOR + { + Pos = MAP_APPFONT ( XTICK_1 , Y7 ) ; + Size = MAP_APPFONT ( TICKWIDTH , 8 ) ; + Text [ en-US ] = "Major:" ; + }; + CheckBox CB_TICKS_INNER + { + Pos = MAP_APPFONT ( XTICK_2 , Y7 ) ; + Size = MAP_APPFONT ( TICKWIDTH , 10 ) ; + Text [ en-US ] = "~Inner"; + }; + CheckBox CB_TICKS_OUTER + { + Pos = MAP_APPFONT ( XTICK_3 , Y7 ) ; + Size = MAP_APPFONT ( TICKWIDTH , 10 ) ; + Text [ en-US ] = "~Outer"; + }; + + FixedText FT_MINOR + { + Pos = MAP_APPFONT ( XTICK_1 , Y8 ) ; + Size = MAP_APPFONT ( TICKWIDTH , 8 ) ; + Text [ en-US ] = "Minor:" ; + }; + CheckBox CB_MINOR_INNER + { + Pos = MAP_APPFONT ( XTICK_2 , Y8 ); + Size = MAP_APPFONT ( TICKWIDTH , 10 ) ; + Text [ en-US ] = "I~nner"; + }; + CheckBox CB_MINOR_OUTER + { + Pos = MAP_APPFONT ( XTICK_3 , Y8 ) ; + Size = MAP_APPFONT ( TICKWIDTH , 10 ) ; + Text [ en-US ] = "O~uter"; + }; + + FixedLine FL_VERTICAL + { + Hide = TRUE ; + Pos = MAP_APPFONT ( XTICK_4 , Y7 ) ; + Size = MAP_APPFONT ( 6 , 25 ) ; + Vert = TRUE ; + }; + + FixedText FT_PLACE_TICKS + { + Pos = MAP_APPFONT ( X2 , Y9 ); + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Place ~marks"; + }; + ListBox LB_PLACE_TICKS + { + Border = TRUE ; + AutoHScroll = TRUE ; + Pos = MAP_APPFONT ( X3 , Y9-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Group = TRUE ; + DropDown=TRUE; + DDExtraWidth = TRUE ; + + StringList [ en-US ] = + { + "At labels" ; + "At axis" ; + "At axis and labels" ; + }; + }; + + + FixedLine FL_GRIDS + { + Hide = TRUE ; + Pos = MAP_APPFONT ( X1 , Y10 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text[ en-US ] = "Grids"; + }; + CheckBox CB_MAJOR_GRID + { + Hide = TRUE ; + Pos = MAP_APPFONT ( X2 , Y11 ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Show major ~grid" ; + }; + PushButton PB_MAJOR_GRID + { + Hide = TRUE ; + TabStop = TRUE; + Pos = MAP_APPFONT ( X3 , Y11-2 ); + Size = MAP_APPFONT ( 54 , 14 ); + Text [ en-US ] = "Mo~re..."; + }; + CheckBox CB_MINOR_GRID + { + Hide = TRUE ; + Pos = MAP_APPFONT ( X2 , Y12 ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Show minor grid" ; + }; + PushButton PB_MINOR_GRID + { + Hide = TRUE ; + TabStop = TRUE; + Pos = MAP_APPFONT ( X3 , Y12-2 ); + Size = MAP_APPFONT ( 54 , 14 ); + Text [ en-US ] = "Mor~e..."; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_ChartType.cxx b/chart2/source/controller/dialogs/tp_ChartType.cxx new file mode 100644 index 000000000000..d5f8d5d22adb --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartType.cxx @@ -0,0 +1,1166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ChartType.cxx,v $ + * $Revision: 1.8.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_ChartType.hxx" +#include "tp_ChartType.hrc" +#include "Strings.hrc" +#include "ResId.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "res_BarGeometry.hxx" +#include "ControllerLockGuard.hxx" +#include "macros.hxx" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +// header for define RET_OK +#include <vcl/msgbox.hxx> +#include <tools/debug.hxx> + +//for auto_ptr +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +// macro for selecting a normal or high contrast bitmap the stack variable +// bIsHighContrast must exist and reflect the correct state +#define SELECT_BITMAP(name) Bitmap( SchResId( bIsHighContrast ? name ## _HC : name )) +#define SELECT_IMAGE(name) Image( SchResId( bIsHighContrast ? name ## _HC : name )) + +//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- + +namespace +{ + long lcl_getDistance() + { + return 6; + } + + sal_Bool lcl_getSortByXValues( const uno::Reference< chart2::XChartDocument >& xChartDoc ) + { + sal_Bool bRet = sal_False; + if( xChartDoc.is() ) + { + try + { + uno::Reference< beans::XPropertySet > xDiaProp( xChartDoc->getFirstDiagram(), uno::UNO_QUERY_THROW ); + xDiaProp->getPropertyValue( C2U( "SortByXValues" ) ) >>= bRet; + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + return bRet; + } +} + +//-------------------------------------------------------------------------- +class AxisTypeResourceGroup : public ChangingResource +{ +public: + AxisTypeResourceGroup( Window* pWindow ); + virtual ~AxisTypeResourceGroup(); + + void showControls( bool bShow ); + Point getPosition(); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( AxisTypeCheckHdl, CheckBox* ); +private: + CheckBox m_aCB_XAxis_Categories; +}; +AxisTypeResourceGroup::AxisTypeResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aCB_XAxis_Categories( pWindow, SchResId( CB_X_AXIS_CATEGORIES ) ) +{ + m_aCB_XAxis_Categories.SetToggleHdl( LINK( this, AxisTypeResourceGroup, AxisTypeCheckHdl ) ); +} +AxisTypeResourceGroup::~AxisTypeResourceGroup() +{ +} +void AxisTypeResourceGroup::showControls( bool bShow ) +{ + m_aCB_XAxis_Categories.Show(bShow); +} +Point AxisTypeResourceGroup::getPosition() +{ + return m_aCB_XAxis_Categories.GetPosPixel(); +} +long AxisTypeResourceGroup::getHeight() +{ + return m_aCB_XAxis_Categories.GetSizePixel().Height(); +} +void AxisTypeResourceGroup::setPosition( const Point& rPoint ) +{ + m_aCB_XAxis_Categories.SetPosPixel(rPoint); +} +void AxisTypeResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + m_aCB_XAxis_Categories.Check(!rParameter.bXAxisWithValues); +} +void AxisTypeResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + rParameter.bXAxisWithValues = !m_aCB_XAxis_Categories.IsChecked(); +} +IMPL_LINK( AxisTypeResourceGroup, AxisTypeCheckHdl, CheckBox*, EMPTYARG ) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + return 0; +} +//-------------------------------------------------------------------------- + +#define POS_3DSCHEME_SIMPLE 0 +#define POS_3DSCHEME_REALISTIC 1 + +class Dim3DLookResourceGroup : public ChangingResource +{ +public: + Dim3DLookResourceGroup( Window* pWindow ); + virtual ~Dim3DLookResourceGroup(); + + void showControls( bool bShow ); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( Dim3DLookCheckHdl, CheckBox* ); + DECL_LINK( SelectSchemeHdl, void* ); + +private: + CheckBox m_aCB_3DLook; + ListBox m_aLB_Scheme; +}; +Dim3DLookResourceGroup::Dim3DLookResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aCB_3DLook( pWindow, SchResId( CB_3D_LOOK ) ) + , m_aLB_Scheme( pWindow, SchResId( LB_3D_SCHEME ) ) +{ + m_aCB_3DLook.SetToggleHdl( LINK( this, Dim3DLookResourceGroup, Dim3DLookCheckHdl ) ); + + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_SIMPLE))); + m_aLB_Scheme.InsertEntry(String(SchResId(STR_3DSCHEME_REALISTIC))); + m_aLB_Scheme.SetDropDownLineCount(2); + + m_aLB_Scheme.SetSelectHdl( LINK( this, Dim3DLookResourceGroup, SelectSchemeHdl ) ); +} +Dim3DLookResourceGroup::~Dim3DLookResourceGroup() +{ +} +void Dim3DLookResourceGroup::showControls( bool bShow ) +{ + m_aCB_3DLook.Show(bShow); + m_aLB_Scheme.Show(bShow); +} +long Dim3DLookResourceGroup::getHeight() +{ + return m_aCB_3DLook.GetSizePixel().Height() + m_aLB_Scheme.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height(); +} +void Dim3DLookResourceGroup::setPosition( const Point& rPoint ) +{ + m_aCB_3DLook.SetPosPixel(rPoint); + Size aSize( m_aCB_3DLook.CalcMinimumSize() ); + m_aCB_3DLook.SetPosSizePixel(rPoint,aSize); + Point aLBPos(rPoint); + aLBPos.X() += aSize.Width() + + m_aLB_Scheme.LogicToPixel( Size(6,0), MapMode(MAP_APPFONT) ).Width(); + aLBPos.Y() -= m_aLB_Scheme.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height(); + m_aLB_Scheme.SetPosPixel(aLBPos); +} +void Dim3DLookResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + m_aCB_3DLook.Check(rParameter.b3DLook); + m_aLB_Scheme.Enable(rParameter.b3DLook); + + if( rParameter.eThreeDLookScheme == ThreeDLookScheme_Simple ) + m_aLB_Scheme.SelectEntryPos(POS_3DSCHEME_SIMPLE); + else if( rParameter.eThreeDLookScheme == ThreeDLookScheme_Realistic ) + m_aLB_Scheme.SelectEntryPos(POS_3DSCHEME_REALISTIC); + else + m_aLB_Scheme.SetNoSelection(); +} +void Dim3DLookResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + rParameter.b3DLook = m_aCB_3DLook.IsChecked(); + USHORT nPos = m_aLB_Scheme.GetSelectEntryPos(); + if( POS_3DSCHEME_SIMPLE == nPos ) + rParameter.eThreeDLookScheme = ThreeDLookScheme_Simple; + else if( POS_3DSCHEME_REALISTIC == nPos ) + rParameter.eThreeDLookScheme = ThreeDLookScheme_Realistic; + else + rParameter.eThreeDLookScheme = ThreeDLookScheme_Unknown; +} +IMPL_LINK( Dim3DLookResourceGroup, Dim3DLookCheckHdl, CheckBox*, EMPTYARG ) +{ + if(m_pChangeListener) + m_pChangeListener->stateChanged(this); + return 0; +} +IMPL_LINK( Dim3DLookResourceGroup, SelectSchemeHdl, void*, EMPTYARG ) +{ + if(m_pChangeListener) + m_pChangeListener->stateChanged(this); + return 0; +} + +//-------------------------------------------------------------------------- + +class SortByXValuesResourceGroup : public ChangingResource +{ +public: + SortByXValuesResourceGroup( Window* pWindow ); + virtual ~SortByXValuesResourceGroup(); + + void showControls( bool bShow ); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( SortByXValuesCheckHdl, CheckBox* ); + +private: + CheckBox m_aCB_XValueSorting; +}; +SortByXValuesResourceGroup::SortByXValuesResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aCB_XValueSorting( pWindow, SchResId( CB_XVALUE_SORTING ) ) +{ + m_aCB_XValueSorting.SetToggleHdl( LINK( this, SortByXValuesResourceGroup, SortByXValuesCheckHdl ) ); +} +SortByXValuesResourceGroup::~SortByXValuesResourceGroup() +{ +} +void SortByXValuesResourceGroup::showControls( bool bShow ) +{ + m_aCB_XValueSorting.Show(bShow); +} +long SortByXValuesResourceGroup::getHeight() +{ + return m_aCB_XValueSorting.GetSizePixel().Height(); +} +void SortByXValuesResourceGroup::setPosition( const Point& rPoint ) +{ + m_aCB_XValueSorting.SetPosPixel(rPoint); +} +void SortByXValuesResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + m_aCB_XValueSorting.Check( rParameter.bSortByXValues ); +} +void SortByXValuesResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + rParameter.bSortByXValues = m_aCB_XValueSorting.IsChecked(); +} +IMPL_LINK( SortByXValuesResourceGroup, SortByXValuesCheckHdl, CheckBox*, EMPTYARG ) +{ + if(m_pChangeListener) + m_pChangeListener->stateChanged(this); + return 0; +} +//-------------------------------------------------------------------------- +class StackingResourceGroup : public ChangingResource +{ +public: + StackingResourceGroup( Window* pWindow ); + virtual ~StackingResourceGroup(); + + void showControls( bool bShow, bool bShowDeepStacking ); + Point getPosition(); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( StackingChangeHdl, RadioButton* ); + DECL_LINK( StackingEnableHdl, void* ); + +private: + CheckBox m_aCB_Stacked; + RadioButton m_aRB_Stack_Y; + RadioButton m_aRB_Stack_Y_Percent; + RadioButton m_aRB_Stack_Z; + + bool m_bShowDeepStacking; +}; +StackingResourceGroup::StackingResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aCB_Stacked( pWindow, SchResId( CB_STACKED ) ) + , m_aRB_Stack_Y( pWindow, SchResId( RB_STACK_Y ) ) + , m_aRB_Stack_Y_Percent( pWindow, SchResId( RB_STACK_Y_PERCENT ) ) + , m_aRB_Stack_Z( pWindow, SchResId( RB_STACK_Z ) ) + , m_bShowDeepStacking(true) +{ + m_aCB_Stacked.SetToggleHdl( LINK( this, StackingResourceGroup, StackingEnableHdl ) ); + m_aRB_Stack_Y.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); + m_aRB_Stack_Y_Percent.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); + m_aRB_Stack_Z.SetToggleHdl( LINK( this, StackingResourceGroup, StackingChangeHdl ) ); +} +StackingResourceGroup::~StackingResourceGroup() +{ +} +void StackingResourceGroup::showControls( bool bShow, bool bShowDeepStacking ) +{ + m_bShowDeepStacking = bShowDeepStacking; + m_aCB_Stacked.Show(bShow); + m_aRB_Stack_Y.Show(bShow); + m_aRB_Stack_Y_Percent.Show(bShow); + m_aRB_Stack_Z.Show(bShow&&bShowDeepStacking); +} +Point StackingResourceGroup::getPosition() +{ + return m_aCB_Stacked.GetPosPixel(); +} +long StackingResourceGroup::getHeight() +{ + RadioButton& rLastButton = m_bShowDeepStacking ? m_aRB_Stack_Z : m_aRB_Stack_Y_Percent; + + long nHeight = rLastButton.GetPosPixel().Y() + - m_aCB_Stacked.GetPosPixel().Y(); + nHeight += rLastButton.GetSizePixel().Height(); + return nHeight; +} +void StackingResourceGroup::setPosition( const Point& rPoint ) +{ + Point aOld = this->getPosition(); + long nDiffY = rPoint.Y() - aOld.Y(); + long nDiffX = rPoint.X() - aOld.X(); + m_aCB_Stacked.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) ); + + aOld = m_aRB_Stack_Y.GetPosPixel(); + m_aRB_Stack_Y.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) ); + + aOld = m_aRB_Stack_Y_Percent.GetPosPixel(); + m_aRB_Stack_Y_Percent.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) ); + + aOld = m_aRB_Stack_Z.GetPosPixel(); + m_aRB_Stack_Z.SetPosPixel( Point( aOld.X()+nDiffX, aOld.Y()+nDiffY ) ); +} +void StackingResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + m_aCB_Stacked.Check( rParameter.eStackMode!=GlobalStackMode_NONE + && rParameter.eStackMode!=GlobalStackMode_STACK_Z ); //todo remove this condition if z stacking radio button is really used + switch( rParameter.eStackMode ) + { + case GlobalStackMode_STACK_Y: + m_aRB_Stack_Y.Check(); + break; + case GlobalStackMode_STACK_Y_PERCENT: + m_aRB_Stack_Y_Percent.Check(); + break; + case GlobalStackMode_STACK_Z: + //todo uncomment this condition if z stacking radio button is really used + /* + if( rParameter.b3DLook ) + m_aRB_Stack_Z.Check(); + else + */ + m_aRB_Stack_Y.Check(); + break; + default: + m_aRB_Stack_Y.Check(); + break; + } + //dis/enabling + m_aCB_Stacked.Enable( !rParameter.bXAxisWithValues ); + m_aRB_Stack_Y.Enable( m_aCB_Stacked.IsChecked() && !rParameter.bXAxisWithValues ); + m_aRB_Stack_Y_Percent.Enable( m_aCB_Stacked.IsChecked() && !rParameter.bXAxisWithValues ); + m_aRB_Stack_Z.Enable( m_aCB_Stacked.IsChecked() && rParameter.b3DLook ); +} +void StackingResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + if(!m_aCB_Stacked.IsChecked()) + rParameter.eStackMode = GlobalStackMode_NONE; + else if(m_aRB_Stack_Y.IsChecked()) + rParameter.eStackMode = GlobalStackMode_STACK_Y; + else if(m_aRB_Stack_Y_Percent.IsChecked()) + rParameter.eStackMode = GlobalStackMode_STACK_Y_PERCENT; + else if(m_aRB_Stack_Z.IsChecked()) + rParameter.eStackMode = GlobalStackMode_STACK_Z; +} +IMPL_LINK( StackingResourceGroup, StackingChangeHdl, RadioButton*, pRadio ) +{ + //for each radio click ther are coming two change events + //first uncheck of previous button -> ignore that call + //the second call gives the check of the new button + if( m_pChangeListener && pRadio && pRadio->IsChecked() ) + m_pChangeListener->stateChanged(this); + return 0; +} +IMPL_LINK( StackingResourceGroup, StackingEnableHdl, void*, EMPTYARG ) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + return 0; +} +//-------------------------------------------------------------------------- +class SplinePropertiesDialog : public ModalDialog +{ +public: + SplinePropertiesDialog( Window* pParent ); + virtual ~SplinePropertiesDialog(); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter, bool bSmoothLines ); + + virtual void StateChanged( StateChangedType nType ); + +private: + DECL_LINK( SplineModeRadioHdl, RadioButton* ); + + void adjustControlPositions(); + void adjustSize(); + +private: + RadioButton m_aRB_Splines_Cubic; + RadioButton m_aRB_Splines_B; + + FixedLine m_aFL_SplineSeparator; + + FixedText m_aFT_SplineResolution; + MetricField m_aMF_SplineResolution; + FixedText m_aFT_SplineOrder; + MetricField m_aMF_SplineOrder; + + FixedLine m_aFL_DialogButtons; + OKButton m_aBP_OK; + CancelButton m_aBP_Cancel; + HelpButton m_aBP_Help; +}; + +SplinePropertiesDialog::SplinePropertiesDialog( Window* pParent ) + : ModalDialog( pParent, SchResId( DLG_SPLINE_PROPERTIES ) ) + , m_aRB_Splines_Cubic( this, SchResId( RB_SPLINES_CUBIC ) ) + , m_aRB_Splines_B( this, SchResId( RB_SPLINES_B ) ) + , m_aFL_SplineSeparator( this, SchResId( FL_SPLINE_SEPARATOR ) ) + , m_aFT_SplineResolution( this, SchResId( FT_SPLINE_RESOLUTION ) ) + , m_aMF_SplineResolution( this, SchResId( MF_SPLINE_RESOLUTION ) ) + , m_aFT_SplineOrder( this, SchResId( FT_SPLINE_ORDER ) ) + , m_aMF_SplineOrder( this, SchResId( MF_SPLINE_ORDER ) ) + , m_aFL_DialogButtons( this, SchResId( FL_SPLINE_DIALOGBUTTONS ) ) + , m_aBP_OK( this, SchResId(BTN_OK) ) + , m_aBP_Cancel( this, SchResId(BTN_CANCEL) ) + , m_aBP_Help( this, SchResId(BTN_HELP) ) +{ + FreeResource(); + + this->SetText( String( SchResId( STR_DLG_SMOOTH_LINE_PROPERTIES ) ) ); + + m_aRB_Splines_Cubic.SetToggleHdl( LINK( this, SplinePropertiesDialog, SplineModeRadioHdl ) ); + m_aRB_Splines_B.SetToggleHdl( LINK( this, SplinePropertiesDialog, SplineModeRadioHdl ) ); +} + +SplinePropertiesDialog::~SplinePropertiesDialog() +{ +} + +void SplinePropertiesDialog::StateChanged( StateChangedType nType ) +{ + Dialog::StateChanged( nType ); + + if( nType == STATE_CHANGE_INITSHOW ) + { + adjustControlPositions(); + adjustSize(); + } +} + +void SplinePropertiesDialog::adjustControlPositions() +{ + //position of controls: + //---------------- + //fixed line and Fixed texts as near as possible to radio controls + long nRBWidth = ::std::max( m_aRB_Splines_Cubic.CalcMinimumSize().Width(), m_aRB_Splines_B.CalcMinimumSize().Width()); + long nFLXPos = m_aRB_Splines_Cubic.GetPosPixel().X()+nRBWidth+m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,0), MapMode(MAP_APPFONT) ).Width(); + long nFTXPos = nFLXPos + m_aFL_SplineSeparator.GetSizePixel().Width() + m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,0), MapMode(MAP_APPFONT) ).Width(); + + m_aRB_Splines_Cubic.SetSizePixel( Size( nRBWidth, m_aRB_Splines_Cubic.GetSizePixel().Height() ) ); + m_aRB_Splines_B.SetSizePixel( Size( nRBWidth, m_aRB_Splines_B.GetSizePixel().Height() ) ); + + m_aFL_SplineSeparator.SetPosPixel( Point( nFLXPos, m_aFL_SplineSeparator.GetPosPixel().Y() ) ); + + m_aFT_SplineOrder.SetPosPixel( Point( nFTXPos, m_aFT_SplineOrder.GetPosPixel().Y() ) ); + m_aFT_SplineResolution.SetPosPixel( Point( nFTXPos, m_aFT_SplineResolution.GetPosPixel().Y() ) ); + + //---------------- + //move metric controls as near to text as possible + long nFTWidth = ::std::max( m_aFT_SplineOrder.CalcMinimumSize().Width(), m_aFT_SplineResolution.CalcMinimumSize().Width()); + long nMFXPos = m_aFT_SplineOrder.GetPosPixel().X()+nFTWidth+m_aFT_SplineOrder.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,0), MapMode(MAP_APPFONT) ).Width(); + + m_aFT_SplineOrder.SetSizePixel( Size( nFTWidth, m_aFT_SplineOrder.GetSizePixel().Height() ) ); + m_aFT_SplineResolution.SetSizePixel( Size( nFTWidth, m_aFT_SplineResolution.GetSizePixel().Height() ) ); + + m_aMF_SplineOrder.SetPosPixel( Point( nMFXPos, m_aMF_SplineOrder.GetPosPixel().Y() ) ); + m_aMF_SplineResolution.SetPosPixel( Point( nMFXPos, m_aMF_SplineResolution.GetPosPixel().Y() ) ); +} + +void SplinePropertiesDialog::adjustSize() +{ + Size aDlgSize( this->GetSizePixel() ); + long nBorder = m_aRB_Splines_Cubic.GetPosPixel().X(); + long nX = m_aMF_SplineOrder.GetPosPixel().X() + m_aMF_SplineOrder.GetSizePixel().Width(); + if(aDlgSize.Width()< (nX+nBorder) ) + { + aDlgSize.Width() = (nX+nBorder); + this->SetSizePixel(aDlgSize); + + Size aLineSize( m_aFL_DialogButtons.GetSizePixel() ); + aLineSize.Width() = aDlgSize.Width(); + m_aFL_DialogButtons.SetSizePixel(aLineSize); + } +} +void SplinePropertiesDialog::fillControls( const ChartTypeParameter& rParameter ) +{ + switch(rParameter.eCurveStyle) + { + case CurveStyle_CUBIC_SPLINES: + m_aRB_Splines_Cubic.Check(); + break; + case CurveStyle_B_SPLINES: + m_aRB_Splines_B.Check(); + break; + default: + m_aRB_Splines_Cubic.Check(); + break; + } + m_aMF_SplineOrder.SetValue( rParameter.nSplineOrder ); + m_aMF_SplineResolution.SetValue( rParameter.nCurveResolution ); + + //dis/enabling + m_aFT_SplineOrder.Enable(m_aRB_Splines_B.IsChecked()); + m_aMF_SplineOrder.Enable(m_aRB_Splines_B.IsChecked()); +} +void SplinePropertiesDialog::fillParameter( ChartTypeParameter& rParameter, bool bSmoothLines ) +{ + if(!bSmoothLines) + rParameter.eCurveStyle=CurveStyle_LINES; + else if(m_aRB_Splines_Cubic.IsChecked()) + rParameter.eCurveStyle=CurveStyle_CUBIC_SPLINES; + else if(m_aRB_Splines_B.IsChecked()) + rParameter.eCurveStyle=CurveStyle_B_SPLINES; + + rParameter.nCurveResolution = static_cast< sal_Int32 >( m_aMF_SplineResolution.GetValue()); + rParameter.nSplineOrder = static_cast< sal_Int32 >( m_aMF_SplineOrder.GetValue()); +} +IMPL_LINK( SplinePropertiesDialog, SplineModeRadioHdl, RadioButton*, EMPTYARG ) +{ + m_aFT_SplineOrder.Enable(m_aRB_Splines_B.IsChecked()); + m_aMF_SplineOrder.Enable(m_aRB_Splines_B.IsChecked()); + return 0; +} + +//-------------------------------------------------------------------------- + +class SplineResourceGroup : public ChangingResource +{ +public: + SplineResourceGroup( Window* pWindow ); + virtual ~SplineResourceGroup(); + + void showControls( bool bShow ); + Point getPosition(); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( SplineChangeHdl, void* ); + DECL_LINK( SplineDetailsDialogHdl, void* ); + SplinePropertiesDialog& getSplinePropertiesDialog(); + +private: + CheckBox m_aCB_Splines; + PushButton m_aPB_DetailsDialog; + ::std::auto_ptr< SplinePropertiesDialog > m_pSplinePropertiesDialog; +}; +SplineResourceGroup::SplineResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aCB_Splines( pWindow, SchResId( CB_SPLINES ) ) + , m_aPB_DetailsDialog( pWindow, SchResId( PB_SPLINE_DIALOG ) ) + , m_pSplinePropertiesDialog() +{ + m_aCB_Splines.SetToggleHdl( LINK( this, SplineResourceGroup, SplineChangeHdl ) ); + m_aPB_DetailsDialog.SetClickHdl( LINK( this, SplineResourceGroup, SplineDetailsDialogHdl ) ); + m_aPB_DetailsDialog.SetQuickHelpText( String( SchResId(STR_DLG_SMOOTH_LINE_PROPERTIES) ) ); + + Size aButtonSize( m_aPB_DetailsDialog.GetSizePixel() ); + Size aMinSize( m_aPB_DetailsDialog.CalcMinimumSize() ); + sal_Int32 nDistance = 10; + if( pWindow ) + { + Size aDistanceSize( pWindow->LogicToPixel( Size(RSC_SP_CTRL_DESC_X,2), MapMode(MAP_APPFONT) ) ); + nDistance = 2*aDistanceSize.Width(); + } + aButtonSize.Width() = aMinSize.Width() + nDistance; + m_aPB_DetailsDialog.SetSizePixel( aButtonSize ); +} +SplineResourceGroup::~SplineResourceGroup() +{ +} +SplinePropertiesDialog& SplineResourceGroup::getSplinePropertiesDialog() +{ + if( !m_pSplinePropertiesDialog.get() ) + m_pSplinePropertiesDialog = ::std::auto_ptr< SplinePropertiesDialog >( new SplinePropertiesDialog( m_aPB_DetailsDialog.GetParent() ) ); + return *m_pSplinePropertiesDialog; +} +void SplineResourceGroup::showControls( bool bShow ) +{ + m_aCB_Splines.Show(bShow); + m_aPB_DetailsDialog.Show(bShow); +} +Point SplineResourceGroup::getPosition() +{ + return m_aCB_Splines.GetPosPixel(); +} +long SplineResourceGroup::getHeight() +{ + return m_aCB_Splines.GetSizePixel().Height() + m_aPB_DetailsDialog.LogicToPixel( Size(0,2), MapMode(MAP_APPFONT) ).Height(); +} +void SplineResourceGroup::setPosition( const Point& rPoint ) +{ + Size aSize( m_aCB_Splines.CalcMinimumSize() ); + Size aDistanceSize( m_aCB_Splines.LogicToPixel( Size(RSC_SP_CTRL_GROUP_X,1), MapMode(MAP_APPFONT) ) ); + m_aCB_Splines.SetSizePixel( aSize ); + + Point aOld = this->getPosition(); + long nDiffY = rPoint.Y() - aOld.Y(); + long nDiffX = rPoint.X() - aOld.X(); + + Point aNew( aOld.X()+nDiffX, aOld.Y()+nDiffY ); + m_aCB_Splines.SetPosPixel( aNew ); + + aNew.X() += ( aSize.Width() + aDistanceSize.Width() ); + aNew.Y() -= 3*aDistanceSize.Height(); + m_aPB_DetailsDialog.SetPosPixel( aNew ); +} + +void SplineResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + m_aCB_Splines.Check( rParameter.eCurveStyle!=CurveStyle_LINES ); + getSplinePropertiesDialog().fillControls( rParameter ); +} +void SplineResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + getSplinePropertiesDialog().fillParameter( rParameter, m_aCB_Splines.IsChecked() ); +} +IMPL_LINK( SplineResourceGroup, SplineChangeHdl, void*, EMPTYARG ) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + return 0; +} + +IMPL_LINK( SplineResourceGroup, SplineDetailsDialogHdl, void*, EMPTYARG ) +{ + + ChartTypeParameter aOldParameter; + getSplinePropertiesDialog().fillParameter( aOldParameter, m_aCB_Splines.IsChecked() ); + + BOOL bOldSmoothLines = m_aCB_Splines.IsChecked(); + m_aCB_Splines.Check(); + if( RET_OK == getSplinePropertiesDialog().Execute() ) + { + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + } + else + { + //restore old state: + m_aCB_Splines.Check( bOldSmoothLines ); + getSplinePropertiesDialog().fillControls( aOldParameter ); + } + return 0; +} + +//-------------------------------------------------------------------------- + +class GeometryResourceGroup : public ChangingResource +{ +public: + GeometryResourceGroup( Window* pWindow ); + virtual ~GeometryResourceGroup(); + + void showControls( bool bShow ); + long getHeight(); + void setPosition( const Point& rPoint ); + + void fillControls( const ChartTypeParameter& rParameter ); + void fillParameter( ChartTypeParameter& rParameter ); + +private: + DECL_LINK( GeometryChangeHdl, void* ); + +private: + BarGeometryResources m_aGeometryResources; +}; +GeometryResourceGroup::GeometryResourceGroup( Window* pWindow ) + : ChangingResource() + , m_aGeometryResources( pWindow ) +{ + m_aGeometryResources.SetSelectHdl( LINK( this, GeometryResourceGroup, GeometryChangeHdl ) ); +} +GeometryResourceGroup::~GeometryResourceGroup() +{ +} +void GeometryResourceGroup::showControls( bool bShow ) +{ + m_aGeometryResources.Show(bShow); +} +long GeometryResourceGroup::getHeight() +{ + return m_aGeometryResources.GetSizePixel().Height(); +} +void GeometryResourceGroup::setPosition( const Point& rPoint ) +{ + m_aGeometryResources.SetPosPixel( rPoint ); +} + +void GeometryResourceGroup::fillControls( const ChartTypeParameter& rParameter ) +{ + USHORT nGeometry3D = static_cast<USHORT>(rParameter.nGeometry3D); + m_aGeometryResources.SelectEntryPos(nGeometry3D); + m_aGeometryResources.Enable(rParameter.b3DLook); +} +void GeometryResourceGroup::fillParameter( ChartTypeParameter& rParameter ) +{ + rParameter.nGeometry3D = 1; + if( m_aGeometryResources.GetSelectEntryCount() ) + rParameter.nGeometry3D = m_aGeometryResources.GetSelectEntryPos(); +} +IMPL_LINK( GeometryResourceGroup, GeometryChangeHdl, void*, EMPTYARG ) +{ + if( m_pChangeListener ) + m_pChangeListener->stateChanged(this); + return 0; +} + +//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- +//-------------------------------------------------------------------------- + +ChartTypeTabPage::ChartTypeTabPage( Window* pParent + , const uno::Reference< XChartDocument >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext + , bool bDoLiveUpdate, bool bHideDescription ) + : OWizardPage( pParent, SchResId(TP_CHARTTYPE) ) + , m_aFT_ChooseType( this, SchResId( FT_CHARTTYPE ) ) + , m_aMainTypeList( this, SchResId( LB_CHARTTYPE ) ) + , m_aSubTypeList( this, SchResId( CT_CHARTVARIANT ) ) + , m_pAxisTypeResourceGroup( new AxisTypeResourceGroup(this) ) + , m_pDim3DLookResourceGroup( new Dim3DLookResourceGroup(this) ) + , m_pStackingResourceGroup( new StackingResourceGroup(this) ) + , m_pSplineResourceGroup( new SplineResourceGroup(this) ) + , m_pGeometryResourceGroup( new GeometryResourceGroup( this ) ) + , m_pSortByXValuesResourceGroup( new SortByXValuesResourceGroup( this ) ) + , m_nYTopPos(0) + , m_xChartModel( xChartModel ) + , m_xCC( xContext ) + , m_aChartTypeDialogControllerList(0) + , m_pCurrentMainType(0) + , m_nChangingCalls(0) + , m_bDoLiveUpdate(bDoLiveUpdate) + , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) ) +{ + FreeResource(); + + if( bHideDescription ) + { + m_aFT_ChooseType.Hide(); + long nYDiff = m_aMainTypeList.GetPosPixel().Y() - m_aFT_ChooseType.GetPosPixel().Y(); + + Point aOldPos( m_aMainTypeList.GetPosPixel() ); + m_aMainTypeList.SetPosPixel( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) ); + + aOldPos = m_aSubTypeList.GetPosPixel(); + m_aSubTypeList.SetPosPixel( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) ); + + aOldPos = m_pAxisTypeResourceGroup->getPosition(); + m_pAxisTypeResourceGroup->setPosition( Point( aOldPos.X(), aOldPos.Y() - nYDiff ) ); + + Size aSize( this->GetSizePixel() ); + this->SetSizePixel( Size( aSize.Width(), aSize.Height()-nYDiff+3 ) ); + } + else + { + Font aFont( m_aFT_ChooseType.GetControlFont() ); + aFont.SetWeight( WEIGHT_BOLD ); + m_aFT_ChooseType.SetControlFont( aFont ); + + m_aFT_ChooseType.SetStyle( m_aFT_ChooseType.GetStyle() | WB_NOLABEL ); + } + + this->SetText( String(SchResId(STR_PAGE_CHARTTYPE)) ); + + m_aMainTypeList.SetStyle(m_aMainTypeList.GetStyle() | WB_ITEMBORDER | WB_DOUBLEBORDER | WB_FLATVALUESET | WB_3DLOOK ); + m_aMainTypeList.SetSelectHdl( LINK( this, ChartTypeTabPage, SelectMainTypeHdl ) ); + m_aSubTypeList.SetSelectHdl( LINK( this, ChartTypeTabPage, SelectSubTypeHdl ) ); + + m_aSubTypeList.SetStyle(m_aSubTypeList.GetStyle() | + WB_ITEMBORDER | WB_DOUBLEBORDER | WB_NAMEFIELD | WB_FLATVALUESET | WB_3DLOOK ); + m_aSubTypeList.SetColCount(4); + m_aSubTypeList.SetLineCount(1); + + bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + + m_aChartTypeDialogControllerList.push_back(new ColumnChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new BarChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new PieChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new AreaChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new LineChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new XYChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new BubbleChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new NetChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new StockChartDialogController() ); + m_aChartTypeDialogControllerList.push_back(new CombiColumnLineChartDialogController() ); + + ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); + const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end(); + for( ; aIter != aEnd; aIter++ ) + { + m_aMainTypeList.InsertEntry( (*aIter)->getName(), (*aIter)->getImage( bIsHighContrast ) ); + (*aIter)->setChangeListener( this ); + } + + m_nYTopPos = m_pAxisTypeResourceGroup->getPosition().Y(); + + m_pAxisTypeResourceGroup->setChangeListener( this ); + m_pDim3DLookResourceGroup->setChangeListener( this ); + m_pStackingResourceGroup->setChangeListener( this ); + m_pSplineResourceGroup->setChangeListener( this ); + m_pGeometryResourceGroup->setChangeListener( this ); + m_pSortByXValuesResourceGroup->setChangeListener( this ); +} + +ChartTypeTabPage::~ChartTypeTabPage() +{ + //delete all dialog controller + ::std::vector< ChartTypeDialogController* >::const_iterator aIter = m_aChartTypeDialogControllerList.begin(); + const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end(); + for( ; aIter != aEnd; aIter++ ) + { + delete *aIter; + } + m_aChartTypeDialogControllerList.clear(); + + //delete all resource helper + delete m_pAxisTypeResourceGroup; + delete m_pDim3DLookResourceGroup; + delete m_pStackingResourceGroup; + delete m_pSplineResourceGroup; + delete m_pGeometryResourceGroup; + delete m_pSortByXValuesResourceGroup; +} +ChartTypeParameter ChartTypeTabPage::getCurrentParamter() const +{ + ChartTypeParameter aParameter; + aParameter.nSubTypeIndex = static_cast<sal_Int32>( m_aSubTypeList.GetSelectItemId() ); + m_pAxisTypeResourceGroup->fillParameter( aParameter ); + m_pDim3DLookResourceGroup->fillParameter( aParameter ); + m_pStackingResourceGroup->fillParameter( aParameter ); + m_pSplineResourceGroup->fillParameter( aParameter ); + m_pGeometryResourceGroup->fillParameter( aParameter ); + m_pSortByXValuesResourceGroup->fillParameter( aParameter ); + return aParameter; +} +void ChartTypeTabPage::commitToModel( const ChartTypeParameter& rParameter ) +{ + if( !m_pCurrentMainType ) + return; + + m_aTimerTriggeredControllerLock.startTimer(); + ControllerLockGuard aLockedControllers( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) ); + m_pCurrentMainType->commitToModel( rParameter, m_xChartModel ); +} +void ChartTypeTabPage::stateChanged( ChangingResource* /*pResource*/ ) +{ + if(m_nChangingCalls) + return; + m_nChangingCalls++; + + ChartTypeParameter aParameter( this->getCurrentParamter() ); + if( m_pCurrentMainType ) + { + m_pCurrentMainType->adjustParameterToSubType( aParameter ); + m_pCurrentMainType->adjustSubTypeAndEnableControls( aParameter ); + } + if( m_bDoLiveUpdate ) + commitToModel( aParameter ); + + //detect the new ThreeDLookScheme + aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) ); + aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel ); + //the controls have to be enabled/disabled accordingly + this->fillAllControls( aParameter ); + + m_nChangingCalls--; +} +ChartTypeDialogController* ChartTypeTabPage::getSelectedMainType() +{ + ChartTypeDialogController* pTypeController = 0; + ::std::vector< ChartTypeDialogController* >::size_type nM = static_cast< ::std::vector< ChartTypeDialogController* >::size_type >( + m_aMainTypeList.GetSelectEntryPos() ); + if( nM<m_aChartTypeDialogControllerList.size() ) + pTypeController = m_aChartTypeDialogControllerList[nM]; + return pTypeController; +} +IMPL_LINK( ChartTypeTabPage, SelectSubTypeHdl, void *, EMPTYARG ) +{ + if( m_pCurrentMainType ) + { + ChartTypeParameter aParameter( this->getCurrentParamter() ); + m_pCurrentMainType->adjustParameterToSubType( aParameter ); + this->fillAllControls( aParameter, false ); + if( m_bDoLiveUpdate ) + commitToModel( aParameter ); + } + return 0; +} + +IMPL_LINK( ChartTypeTabPage, SelectMainTypeHdl, void *, EMPTYARG ) +{ + ChartTypeParameter aParameter( this->getCurrentParamter() ); + + if( m_pCurrentMainType ) + { + m_pCurrentMainType->adjustParameterToSubType( aParameter ); + m_pCurrentMainType->hideExtraControls(); + } + + m_pCurrentMainType = this->getSelectedMainType(); + if( m_pCurrentMainType ) + { + this->showAllControls(*m_pCurrentMainType); + + m_pCurrentMainType->adjustParameterToMainType( aParameter ); + if( m_bDoLiveUpdate ) + commitToModel( aParameter ); + //detect the new ThreeDLookScheme + aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( ChartModelHelper::findDiagram( m_xChartModel ) ); + if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Simple ) + aParameter.eThreeDLookScheme=ThreeDLookScheme_Simple; + + aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel ); + this->fillAllControls( aParameter ); + uno::Reference< beans::XPropertySet > xTemplateProps( this->getCurrentTemplate(), uno::UNO_QUERY ); + m_pCurrentMainType->fillExtraControls(aParameter,m_xChartModel,xTemplateProps); + } + return 0; +} + +void ChartTypeTabPage::showAllControls( ChartTypeDialogController& rTypeController ) +{ + m_aSubTypeList.Show(); + + long nYPos = m_nYTopPos; + + //------ + bool bShow = rTypeController.shouldShow_XAxisTypeControl(); + long nXPos = m_pAxisTypeResourceGroup->getPosition().X(); + m_pAxisTypeResourceGroup->showControls( bShow ); + if(bShow) + { + m_pAxisTypeResourceGroup->setPosition( Point( nXPos, nYPos ) ); + nYPos += m_pAxisTypeResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + bShow = rTypeController.shouldShow_3DLookControl(); + m_pDim3DLookResourceGroup->showControls( bShow ); + if(bShow) + { + m_pDim3DLookResourceGroup->setPosition( Point( nXPos, nYPos ) ); + nYPos += m_pDim3DLookResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + bShow = rTypeController.shouldShow_StackingControl(); + m_pStackingResourceGroup->showControls( bShow, rTypeController.shouldShow_DeepStackingControl() ); + if(bShow) + { + long nStackingXPos = nXPos; + if( rTypeController.shouldShow_XAxisTypeControl() ) + nStackingXPos += this->LogicToPixel( Size(RSC_SP_CHK_TEXTINDENT,0), MapMode(MAP_APPFONT) ).Width(); + m_pStackingResourceGroup->setPosition( Point( nStackingXPos, nYPos ) ); + nYPos += m_pStackingResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + bShow = rTypeController.shouldShow_SplineControl(); + m_pSplineResourceGroup->showControls( bShow ); + if(bShow) + { + m_pSplineResourceGroup->setPosition( Point( nXPos, nYPos ) ); + nYPos += m_pSplineResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + bShow = rTypeController.shouldShow_GeometryControl(); + m_pGeometryResourceGroup->showControls( bShow ); + if(bShow) + { + m_pGeometryResourceGroup->setPosition( Point( nXPos+17, nYPos ) ); + nYPos += m_pGeometryResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + bShow = rTypeController.shouldShow_SortByXValuesResourceGroup(); + m_pSortByXValuesResourceGroup->showControls( bShow ); + if(bShow) + { + m_pSortByXValuesResourceGroup->setPosition( Point( nXPos, nYPos ) ); + nYPos += m_pSortByXValuesResourceGroup->getHeight() + lcl_getDistance(); + } + //------ + Size aPageSize( this->GetSizePixel() ); + Size aRemainingSize = Size( aPageSize.Width()-nXPos, aPageSize.Height()-nYPos ); + rTypeController.showExtraControls( this, Point( nXPos, nYPos ), aRemainingSize ); +} + +void ChartTypeTabPage::fillAllControls( const ChartTypeParameter& rParameter, bool bAlsoResetSubTypeList ) +{ + m_nChangingCalls++; + if( m_pCurrentMainType && bAlsoResetSubTypeList ) + { + bool bIsHighContrast = ( true && GetSettings().GetStyleSettings().GetHighContrastMode() ); + m_pCurrentMainType->fillSubTypeList( m_aSubTypeList, bIsHighContrast, rParameter ); + } + m_aSubTypeList.SelectItem( static_cast<USHORT>( rParameter.nSubTypeIndex) ); + m_pAxisTypeResourceGroup->fillControls( rParameter ); + m_pDim3DLookResourceGroup->fillControls( rParameter ); + m_pStackingResourceGroup->fillControls( rParameter ); + m_pSplineResourceGroup->fillControls( rParameter ); + m_pGeometryResourceGroup->fillControls( rParameter ); + m_pSortByXValuesResourceGroup->fillControls( rParameter ); + m_nChangingCalls--; +} + +void ChartTypeTabPage::initializePage() +{ + if( !m_xChartModel.is() ) + return; + uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY ); + uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY); + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel ) ); + DiagramHelper::tTemplateWithServiceName aTemplate = + DiagramHelper::getTemplateForDiagram( xDiagram, xTemplateManager ); + ::rtl::OUString aServiceName( aTemplate.second ); + + bool bFound = false; + + ::std::vector< ChartTypeDialogController* >::iterator aIter = m_aChartTypeDialogControllerList.begin(); + const ::std::vector< ChartTypeDialogController* >::const_iterator aEnd = m_aChartTypeDialogControllerList.end(); + for( USHORT nM=0; aIter != aEnd; aIter++, nM++ ) + { + if( (*aIter)->isSubType(aServiceName) ) + { + bFound = true; + + m_aMainTypeList.SelectEntryPos( nM ); + this->showAllControls( **aIter ); + uno::Reference< beans::XPropertySet > xTemplateProps( aTemplate.first, uno::UNO_QUERY ); + ChartTypeParameter aParameter = (*aIter)->getChartTypeParameterForService( aServiceName, xTemplateProps ); + m_pCurrentMainType = this->getSelectedMainType(); + + //set ThreeDLookScheme + aParameter.eThreeDLookScheme = ThreeDHelper::detectScheme( xDiagram ); + if(!aParameter.b3DLook && aParameter.eThreeDLookScheme!=ThreeDLookScheme_Simple ) + aParameter.eThreeDLookScheme=ThreeDLookScheme_Simple; + + aParameter.bSortByXValues = lcl_getSortByXValues( m_xChartModel ); + + this->fillAllControls( aParameter ); + if( m_pCurrentMainType ) + m_pCurrentMainType->fillExtraControls(aParameter,m_xChartModel,xTemplateProps); + break; + } + } + + if( !bFound ) + { + m_aSubTypeList.Hide(); + m_pAxisTypeResourceGroup->showControls( false ); + m_pDim3DLookResourceGroup->showControls( false ); + m_pStackingResourceGroup->showControls( false, false ); + m_pSplineResourceGroup->showControls( false ); + m_pGeometryResourceGroup->showControls( false ); + m_pSortByXValuesResourceGroup->showControls( false ); + } +} + +sal_Bool ChartTypeTabPage::commitPage( CommitPageReason /*eReason*/ ) +{ + //commit changes to model + if( !m_bDoLiveUpdate && m_pCurrentMainType ) + { + ChartTypeParameter aParameter( this->getCurrentParamter() ); + m_pCurrentMainType->adjustParameterToSubType( aParameter ); + commitToModel( aParameter ); + } + + return sal_True;//return false if this page should not be left +} + +uno::Reference< XChartTypeTemplate > ChartTypeTabPage::getCurrentTemplate() const +{ + if( m_pCurrentMainType && m_xChartModel.is() ) + { + ChartTypeParameter aParameter( this->getCurrentParamter() ); + m_pCurrentMainType->adjustParameterToSubType( aParameter ); + uno::Reference< lang::XMultiServiceFactory > xTemplateManager( m_xChartModel->getChartTypeManager(), uno::UNO_QUERY ); + return m_pCurrentMainType->getCurrentTemplate( aParameter, xTemplateManager ); + } + return 0; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_ChartType.hrc b/chart2/source/controller/dialogs/tp_ChartType.hrc new file mode 100644 index 000000000000..073c2547f09a --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartType.hrc @@ -0,0 +1,65 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ChartType.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define BTN_OK 1 +#define BTN_CANCEL 1 +#define BTN_HELP 1 + +#define LB_3D_SCHEME 1 +#define LB_CHARTTYPE 2 +#define CT_CHARTVARIANT 3 + +#define FL_SPLINE_SEPARATOR 2 +#define FL_SPLINE_DIALOGBUTTONS 3 + +#define FT_CHARTTYPE 1 +#define FT_SPLINE_ORDER 3 +#define FT_SPLINE_RESOLUTION 4 + +#define CB_X_AXIS_CATEGORIES 1 +#define CB_3D_LOOK 2 +#define CB_STACKED 3 +#define CB_SPLINES 4 +#define CB_XVALUE_SORTING 5 + +#define PB_SPLINE_DIALOG 1 + +#define RB_STACK_Y 2 +#define RB_STACK_Y_PERCENT 3 +#define RB_STACK_Z 4 + +#define RB_SPLINES_CUBIC 5 +#define RB_SPLINES_B 6 + +#define MF_SPLINE_ORDER 1 +#define MF_SPLINE_RESOLUTION 2 + diff --git a/chart2/source/controller/dialogs/tp_ChartType.hxx b/chart2/source/controller/dialogs/tp_ChartType.hxx new file mode 100644 index 000000000000..878c845eb84c --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartType.hxx @@ -0,0 +1,128 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ChartType.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_TP_CHARTTYPE_HXX +#define _CHART2_TP_CHARTTYPE_HXX + +#include <vector> + +#include "ChartTypeDialogController.hxx" +#include "ChartTypeTemplateProvider.hxx" +#include "TimerTriggeredControllerLock.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <svtools/wizardmachine.hxx> +#include <svtools/valueset.hxx> +#include <vcl/fixed.hxx> +// header for class MetricField +#include <vcl/field.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class ChartTypeResourceGroup; +class AxisTypeResourceGroup; +class Dim3DLookResourceGroup; +class StackingResourceGroup; +class SplineResourceGroup; +class GeometryResourceGroup; +class ChartTypeParameter; +class SortByXValuesResourceGroup; + +class ChartTypeTabPage : public ResourceChangeListener, public svt::OWizardPage, public ChartTypeTemplateProvider +{ +public: + ChartTypeTabPage( Window* pParent + , const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext + , bool bDoLiveUpdate, bool bHideDescription = false ); + virtual ~ChartTypeTabPage(); + + virtual void initializePage(); + virtual sal_Bool commitPage( CommitPageReason eReason ); + + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > getCurrentTemplate() const; + +protected: + ChartTypeDialogController* getSelectedMainType(); + void showAllControls( ChartTypeDialogController& rTypeController ); + void fillAllControls( const ChartTypeParameter& rParameter, bool bAlsoResetSubTypeList=true ); + ChartTypeParameter getCurrentParamter() const; + + virtual void stateChanged( ChangingResource* pResource ); + + void commitToModel( const ChartTypeParameter& rParameter ); + + DECL_LINK( SelectMainTypeHdl, void* ); + DECL_LINK( SelectSubTypeHdl, void* ); + +protected: + FixedText m_aFT_ChooseType; + ListBox m_aMainTypeList; + ValueSet m_aSubTypeList; + + AxisTypeResourceGroup* m_pAxisTypeResourceGroup; + Dim3DLookResourceGroup* m_pDim3DLookResourceGroup; + StackingResourceGroup* m_pStackingResourceGroup; + SplineResourceGroup* m_pSplineResourceGroup; + GeometryResourceGroup* m_pGeometryResourceGroup; + SortByXValuesResourceGroup* m_pSortByXValuesResourceGroup; + + long m_nYTopPos;//top y position of the different ResourceGroups (AxisTypeResourceGroup, etc) + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > m_xCC; + + ::std::vector< ChartTypeDialogController* > m_aChartTypeDialogControllerList; + ChartTypeDialogController* m_pCurrentMainType; + + sal_Int32 m_nChangingCalls; + bool m_bDoLiveUpdate; + + TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/tp_ChartType.src b/chart2/source/controller/dialogs/tp_ChartType.src new file mode 100644 index 000000000000..ee8df4cad389 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ChartType.src @@ -0,0 +1,262 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ChartType.src,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "tp_ChartType.hrc" +#include "SchSlotIds.hxx" +#include "dlg_CreationWizard.hrc" +#include "CommonResources.hrc" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +#define MASKCOLOR MaskColor = Color { Red = 0xC000 ; Green = 0xC000 ; Blue = 0xC000 ; } + +#define WIDTH_MAINLIST 75 +#define HEIGHT_MAINLIST 122 +#define WIDTH_IMAGELIST 150 +#define HEIGHT_IMAGELIST 50 +#define WIDTH_3D 100 +#define POS_X_MAINLIST 6 +#define POS_X_IMAGELIST (POS_X_MAINLIST+WIDTH_MAINLIST+6) +#define POS_Y1 8 +#define POS_Y_LIST (POS_Y1+RSC_CD_FIXEDTEXT_HEIGHT+4) +#define POS_Y_VALUE_X_AXIS (POS_Y_LIST+HEIGHT_IMAGELIST+RSC_SP_CTRL_Y+2) +#define POS_Y_3D_LOOK (POS_Y_VALUE_X_AXIS+RSC_CD_CHECKBOX_HEIGHT+RSC_SP_CTRL_Y) +#define POS_Y_STACKING (POS_Y_3D_LOOK+RSC_CD_CHECKBOX_HEIGHT+RSC_SP_CTRL_Y) +#define POS_Y_SPLINES (POS_Y_STACKING+4*12+12) +#define POS_Y_XVALUE_SORTING (POS_Y_SPLINES+4+12) + +#define POS_X_SPLINES_1 (8) +#define POS_Y_SPLINES_2 (8) +#define POS_Y_SPLINES_3 (POS_Y_SPLINES_2+13) +#define POS_Y_SPLINES_4 (POS_Y_SPLINES_3+13) +#define POS_Y_SPLINES_5 (POS_Y_SPLINES_4+RSC_CD_FIXEDTEXT_HEIGHT) + +#define SPLINES_WIDTH_RADIO 45 +#define SPLINES_WIDTH_METRIC_TEXT 60 +#define POS_X_SPLINE_EXTRAS (POS_X_SPLINES_1+SPLINES_WIDTH_RADIO+RSC_SP_FLGR_SPACE_X+RSC_CD_FIXEDLINE_WIDTH+2*RSC_SP_FLGR_SPACE_X) +#define WIZ_FIXEDLINE_WIDTH (CHART_WIZARD_PAGEWIDTH-POS_X_MAINLIST-6) +#define WIDTH_XVALUE_SORTING (WIDTH_IMAGELIST) + +#define SPLINE_DIALOG_WIDTH 172 +#define SPLINE_DIALOG_HEIGHT 59 + +TabPage TP_CHARTTYPE +{ + Hide = TRUE ; + HelpID = SID_DIAGRAM_TYPE; + SVLook = TRUE ; + Size = MAP_APPFONT ( CHART_WIZARD_PAGEWIDTH , CHART_WIZARD_PAGEHEIGHT ) ; + + FixedText FT_CHARTTYPE + { + Pos = MAP_APPFONT ( POS_X_MAINLIST-1 , POS_Y1 ) ; + Size = MAP_APPFONT ( WIZ_FIXEDLINE_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + TabStop = FALSE ; + Text [ en-US ] = "Choose a chart type"; + }; + ListBox LB_CHARTTYPE + { + HelpId = HID_SCH_CTL_TYPE ; + Border = TRUE ; + TabStop = TRUE ; + Pos = MAP_APPFONT ( POS_X_MAINLIST , POS_Y_LIST ) ; + Size = MAP_APPFONT ( WIDTH_MAINLIST, HEIGHT_MAINLIST ) ; + }; + Control CT_CHARTVARIANT + { + HelpId = HID_SCH_CTL_VARIANT ; + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_LIST ) ; + Size = MAP_APPFONT ( WIDTH_IMAGELIST , HEIGHT_IMAGELIST ) ; + TabStop = TRUE ; + }; + + CheckBox CB_X_AXIS_CATEGORIES + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_VALUE_X_AXIS ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + Text [ en-US ] = "X axis with Categories" ; + }; + CheckBox CB_3D_LOOK + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_3D_LOOK ) ; + Size = MAP_APPFONT ( WIDTH_3D , 10 ) ; + Text [ en-US ] = "~3D Look" ; + }; + ListBox LB_3D_SCHEME + { + Border = TRUE; + TabStop = TRUE; + DropDown = TRUE; + Pos = MAP_APPFONT ( POS_X_IMAGELIST+WIDTH_3D+4 , POS_Y_3D_LOOK ) ; + Size = MAP_APPFONT ( 60, 12 ) ; + }; + + CheckBox CB_STACKED + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_STACKING ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + Text [ en-US ] = "~Stack series" ; + }; + RadioButton RB_STACK_Y + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST+RSC_SP_CHK_TEXTINDENT, POS_Y_STACKING+12 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + //Uebereinander (summiere Y-Werte) + //On top (sum Y-values) + Text [ en-US ] = "On top"; + }; + RadioButton RB_STACK_Y_PERCENT + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST+RSC_SP_CHK_TEXTINDENT, POS_Y_STACKING+2*12 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Percent"; + }; + RadioButton RB_STACK_Z + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST+RSC_SP_CHK_TEXTINDENT, POS_Y_STACKING+3*12 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + //Hintereinander (verteile Datenreihen auf der Z-Achse) + //Deep (spread series on Z-Axis) + Text [ en-US ] = "Deep"; + }; + + CheckBox CB_SPLINES + { + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_SPLINES ) ; + Size = MAP_APPFONT ( 150 , 10 ) ; + Text [ en-US ] = "S~mooth lines" ; + }; + + PushButton PB_SPLINE_DIALOG + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_SPLINES-6 ) ; + Size = MAP_APPFONT ( 12 , 14 ) ; + Text [ en-US ] = "Properties..." ; + }; + + CheckBox CB_XVALUE_SORTING + { + TabStop = TRUE ; + Pos = MAP_APPFONT ( POS_X_IMAGELIST , POS_Y_XVALUE_SORTING ) ; + Size = MAP_APPFONT ( WIDTH_XVALUE_SORTING , 10 ) ; + Text [ en-US ] = "~Sort by X values" ; + }; + +}; + +ModalDialog DLG_SPLINE_PROPERTIES +{ + HelpID = HID_SCH_DLG_SPLINE_PROPERTIES; + Size = MAP_APPFONT ( SPLINE_DIALOG_WIDTH , SPLINE_DIALOG_HEIGHT ) ; + OutputSize = TRUE ; + SVLook = TRUE ; + Moveable = TRUE ; + Closeable = TRUE; + RadioButton RB_SPLINES_CUBIC + { + Pos = MAP_APPFONT ( POS_X_SPLINES_1, POS_Y_SPLINES_2 ) ; + Size = MAP_APPFONT ( SPLINES_WIDTH_RADIO , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Cubic spline"; + }; + RadioButton RB_SPLINES_B + { + Pos = MAP_APPFONT ( POS_X_SPLINES_1, POS_Y_SPLINES_3 ) ; + Size = MAP_APPFONT ( SPLINES_WIDTH_RADIO , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "B-Spline"; + }; + + FixedLine FL_SPLINE_SEPARATOR + { + Pos = MAP_APPFONT ( POS_X_SPLINE_EXTRAS-RSC_CD_FIXEDLINE_WIDTH-RSC_SP_FLGR_SPACE_X , POS_Y_SPLINES_2 ) ; + Size = MAP_APPFONT ( RSC_CD_FIXEDLINE_WIDTH , 2*12 ) ; + Vert = TRUE ; + }; + + FixedText FT_SPLINE_RESOLUTION + { + Pos = MAP_APPFONT ( POS_X_SPLINE_EXTRAS , POS_Y_SPLINES_2 ) ; + Size = MAP_APPFONT ( SPLINES_WIDTH_METRIC_TEXT , 10 ) ; + Text [ en-US ] = "~Resolution" ; + }; + MetricField MF_SPLINE_RESOLUTION + { + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_SPLINE_EXTRAS+SPLINES_WIDTH_METRIC_TEXT+RSC_SP_FLGR_SPACE_X , POS_Y_SPLINES_2-2 ) ; + Size = MAP_APPFONT ( 25 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + }; + + FixedText FT_SPLINE_ORDER + { + Pos = MAP_APPFONT ( POS_X_SPLINE_EXTRAS , POS_Y_SPLINES_3 ) ; + Size = MAP_APPFONT ( SPLINES_WIDTH_METRIC_TEXT , 10 ) ; + Text [ en-US ] = "~Data points order" ; + }; + MetricField MF_SPLINE_ORDER + { + Border = TRUE ; + Pos = MAP_APPFONT ( POS_X_SPLINE_EXTRAS+SPLINES_WIDTH_METRIC_TEXT+RSC_SP_FLGR_SPACE_X , POS_Y_SPLINES_3-2 ) ; + Size = MAP_APPFONT ( 25 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + }; + FixedLine FL_SPLINE_DIALOGBUTTONS + { + Pos = MAP_APPFONT ( 0 , POS_Y_SPLINES_4 ) ; + Size = MAP_APPFONT ( SPLINE_DIALOG_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + }; + BUTTONS_HELP_OK_CANCEL_NEXT(POS_X_SPLINES_1,POS_Y_SPLINES_5) +}; diff --git a/chart2/source/controller/dialogs/tp_DataLabel.cxx b/chart2/source/controller/dialogs/tp_DataLabel.cxx new file mode 100644 index 000000000000..2da9778a4db8 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataLabel.cxx @@ -0,0 +1,77 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataLabel.cxx,v $ + * $Revision: 1.9.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_DataLabel.hxx" + +#include "TabPages.hrc" +#include "ResId.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +DataLabelsTabPage::DataLabelsTabPage(Window* pWindow, const SfxItemSet& rInAttrs) : + SfxTabPage(pWindow, SchResId(TP_DATA_DESCR), rInAttrs), + m_aDataLabelResources(this, rInAttrs) +{ + FreeResource(); +} + +DataLabelsTabPage::~DataLabelsTabPage() +{ +} + +SfxTabPage* DataLabelsTabPage::Create(Window* pWindow, + const SfxItemSet& rOutAttrs) +{ + return new DataLabelsTabPage(pWindow, rOutAttrs); +} + +BOOL DataLabelsTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + return m_aDataLabelResources.FillItemSet(rOutAttrs); +} + +void DataLabelsTabPage::Reset(const SfxItemSet& rInAttrs) +{ + m_aDataLabelResources.Reset(rInAttrs); +} + +void DataLabelsTabPage::SetNumberFormatter( SvNumberFormatter* pFormatter ) +{ + m_aDataLabelResources.SetNumberFormatter( pFormatter ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_DataLabel.hxx b/chart2/source/controller/dialogs/tp_DataLabel.hxx new file mode 100644 index 000000000000..9e5bd968154d --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataLabel.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataLabel.hxx,v $ + * $Revision: 1.5.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_DATALABEL_HXX +#define _CHART2_TP_DATALABEL_HXX + +#include "res_DataLabel.hxx" +#include <sfx2/tabdlg.hxx> + +class SvNumberFormatter; + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class DataLabelsTabPage : public SfxTabPage +{ +public: + DataLabelsTabPage(Window* pParent, const SfxItemSet& rInAttrs); + virtual ~DataLabelsTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + + void SetNumberFormatter( SvNumberFormatter* pFormatter ); + + virtual void Reset(const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + +private: + DataLabelResources m_aDataLabelResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/tp_DataLabel.src b/chart2/source/controller/dialogs/tp_DataLabel.src new file mode 100644 index 000000000000..32f5835295f7 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataLabel.src @@ -0,0 +1,45 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataLabel.src,v $ + * $Revision: 1.4.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" +#include "res_DataLabel.hrc" + +#ifndef _GLOBLMN_HRC +#include <svx/globlmn.hrc> +#endif + +TabPage TP_DATA_DESCR +{ + Hide = TRUE ; + HelpID = HID_SCH_DATA_DESCR ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + RESOURCE_DATALABEL( 6, 8 ) +}; diff --git a/chart2/source/controller/dialogs/tp_DataSource.cxx b/chart2/source/controller/dialogs/tp_DataSource.cxx new file mode 100644 index 000000000000..ff858c5bfdf5 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSource.cxx @@ -0,0 +1,1079 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSource.cxx,v $ + * $Revision: 1.5.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_DataSource.hxx" +#include "tp_DataSource.hrc" +#include "Strings.hrc" +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "macros.hxx" +#include "ChartTypeTemplateProvider.hxx" +#include "RangeSelectionHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "tp_DataSourceControls.hxx" +#include "ControllerLockGuard.hxx" +#include "DataSourceHelper.hxx" +#include <com/sun/star/sheet/XRangeSelection.hpp> +#include <com/sun/star/table/XCellRange.hpp> +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> +#include <com/sun/star/util/XModifiable.hpp> +#include <com/sun/star/chart2/data/XDataSink.hpp> + +// for RET_OK +#include <vcl/msgbox.hxx> +#include <rtl/ustrbuf.hxx> + +#include <functional> +#include <algorithm> +#include <map> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + +// -------------------------------------------------------------------------------- + +namespace +{ + +const OUString lcl_aLabelRole( RTL_CONSTASCII_USTRINGPARAM( "label" )); + +String lcl_GetRoleLBEntry( + const OUString & rRole, const OUString & rRange ) +{ + String aEntry( rRole ); + aEntry += '\t'; + aEntry += String( + ::chart::DialogModel::ConvertRoleFromInternalToUI( rRole )); + aEntry += '\t'; + aEntry += String( rRange ); + + return aEntry; +} + +void lcl_UpdateCurrentRange( + SvTabListBox & rOutListBox, + const OUString & rRole, const OUString & rRange ) +{ + SvLBoxEntry * pEntry = rOutListBox.FirstSelected(); + if( pEntry ) + rOutListBox.SetEntryText( lcl_GetRoleLBEntry( rRole, rRange ), pEntry ); +} + +bool lcl_UpdateCurrentSeriesName( + SvTreeListBox & rOutListBox ) +{ + bool bResult = false; + ::chart::SeriesEntry * pEntry = dynamic_cast< ::chart::SeriesEntry * >( rOutListBox.FirstSelected()); + if( pEntry && + pEntry->m_xDataSeries.is() && + pEntry->m_xChartType.is()) + { + String aLabel( ::chart::DataSeriesHelper::getDataSeriesLabel( + pEntry->m_xDataSeries, + pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel())); + if( aLabel.Len()) + { + rOutListBox.SetEntryText( pEntry, aLabel ); + bResult = true; + } + } + return bResult; +} + +OUString lcl_GetSelectedRole( const SvTabListBox & rRoleListBox, bool bUITranslated = false ) +{ + OUString aResult; + SvLBoxEntry * pEntry = rRoleListBox.FirstSelected(); + if( pEntry ) + aResult = OUString( rRoleListBox.GetEntryText( pEntry, + bUITranslated ? 1 : 0 )); + return aResult; +} + +OUString lcl_GetSelectedRolesRange( const SvTabListBox & rRoleListBox ) +{ + OUString aResult; + SvLBoxEntry * pEntry = rRoleListBox.FirstSelected(); + if( pEntry ) + aResult = OUString( rRoleListBox.GetEntryText( pEntry, 2 )); + return aResult; +} + +OUString lcl_GetSequenceNameForLabel( ::chart::SeriesEntry * pEntry ) +{ + OUString aResult( RTL_CONSTASCII_USTRINGPARAM("values-y")); + if( pEntry && + pEntry->m_xChartType.is()) + { + aResult = pEntry->m_xChartType->getRoleOfSequenceForSeriesLabel(); + } + return aResult; +} + +static long lcl_pRoleListBoxTabs[] = + { 3, // Number of Tabs + 0, 0, 75 + }; + +void lcl_ShowChooserButton( + ::chart::RangeSelectionButton & rChooserButton, + Edit & rEditField, + BOOL bShow ) +{ + if( rChooserButton.IsVisible() != bShow ) + { + rChooserButton.Show( bShow ); + sal_Int32 nWidhtDiff = 12 + 4; + if( bShow ) + nWidhtDiff = -nWidhtDiff; + Size aSize = rChooserButton.PixelToLogic( rEditField.GetSizePixel(), MAP_APPFONT ); + aSize.setWidth( aSize.getWidth() + nWidhtDiff ); + rEditField.SetSizePixel( rChooserButton.LogicToPixel( aSize, MAP_APPFONT )); + } +} + +void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) +{ + if( pDialog ) + { + pDialog->Show( bEnable ? FALSE : TRUE ); + pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + } +} + +void lcl_addLSequenceToDataSource( + const Reference< chart2::data::XLabeledDataSequence > & xLSequence, + const Reference< chart2::data::XDataSource > & xSource ) +{ + Reference< data::XDataSink > xSink( xSource, uno::UNO_QUERY ); + if( xSink.is()) + { + Sequence< Reference< chart2::data::XLabeledDataSequence > > aData( xSource->getDataSequences()); + aData.realloc( aData.getLength() + 1 ); + aData[ aData.getLength() - 1 ] = xLSequence; + xSink->setData( aData ); + } +} + +Reference< chart2::data::XLabeledDataSequence > lcl_findLSequenceWithOnlyLabel( + const Reference< chart2::data::XDataSource > & xDataSource ) +{ + Reference< chart2::data::XLabeledDataSequence > xResult; + Sequence< Reference< chart2::data::XLabeledDataSequence > > aSequences( xDataSource->getDataSequences()); + + for( sal_Int32 i=0; i<aSequences.getLength(); ++i ) + { + // no values are set but a label exists + if( ! aSequences[i]->getValues().is() && + aSequences[i]->getLabel().is()) + { + xResult.set( aSequences[i] ); + break; + } + } + + return xResult; +} + +void lcl_shiftControlY( Control & rControl, long nYOffset ) +{ + Point aPos( rControl.GetPosPixel()); + aPos.setY( aPos.getY() + nYOffset ); + rControl.SetPosPixel( aPos ); +} + +void lcl_increaseHeightOfControl( Control & rControl, long nYOffset ) +{ + Size aSize( rControl.GetSizePixel()); + aSize.setHeight( aSize.getHeight () + nYOffset ); + rControl.SetSizePixel( aSize ); +} + +} // anonymous namespace + +// -------------------------------------------------------------------------------- + +namespace chart +{ + +DataSourceTabPage::DataSourceTabPage( + Window * pParent, + DialogModel & rDialogModel, + ChartTypeTemplateProvider* pTemplateProvider, + Dialog * pParentDialog, + bool bHideDescription /* = false */ ) : + ::svt::OWizardPage( pParent, SchResId( TP_DATA_SOURCE )), + + m_aFT_CAPTION ( this, SchResId( FT_CAPTION_FOR_WIZARD )), + m_aFT_SERIES ( this, SchResId( FT_SERIES )), + m_apLB_SERIES( new SeriesListBox( this, SchResId( LB_SERIES ))), + m_aBTN_ADD ( this, SchResId( BTN_ADD )), + m_aBTN_REMOVE ( this, SchResId( BTN_REMOVE )), + m_aBTN_UP ( this, SchResId( BTN_UP )), + m_aBTN_DOWN ( this, SchResId( BTN_DOWN )), + m_aFT_ROLE ( this, SchResId( FT_ROLE )), + m_aLB_ROLE ( this, SchResId( LB_ROLE )), + m_aFT_RANGE ( this, SchResId( FT_RANGE )), + m_aEDT_RANGE ( this, SchResId( EDT_RANGE )), + m_aIMB_RANGE_MAIN ( this, SchResId( IMB_RANGE_MAIN )), + m_aFT_CATEGORIES ( this, SchResId( FT_CATEGORIES )), + m_aFT_DATALABELS ( this, SchResId( FT_DATALABELS )), + m_aEDT_CATEGORIES ( this, SchResId( EDT_CATEGORIES )), + m_aIMB_RANGE_CAT ( this, SchResId( IMB_RANGE_CAT )), + + m_pTemplateProvider( pTemplateProvider ), + m_rDialogModel( rDialogModel ), + + m_pCurrentRangeChoosingField( 0 ), + m_bIsDirty( false ), + m_pParentDialog( pParentDialog ), + m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog )) +{ + FreeResource(); + + if( bHideDescription ) + { + // note: the offset should be a negative value for shifting upwards, the + // 4 is for the offset difference between a wizard page and a tab-page + long nYOffset = - ( m_aFT_SERIES.GetPosPixel().getY() - m_aFT_CAPTION.GetPosPixel().getY() + 4 ); + long nUpShift = - 2; + long nYResize = - (nYOffset - nUpShift); + m_aFT_CAPTION.Hide(); + + // shift list boxes and enlarge them by the space saved by hiding the caption + lcl_shiftControlY( m_aFT_SERIES, nYOffset ); + lcl_shiftControlY( *(m_apLB_SERIES.get()), nYOffset ); + lcl_increaseHeightOfControl( *(m_apLB_SERIES.get()), nYResize ); + + lcl_shiftControlY( m_aFT_ROLE, nYOffset ); + lcl_shiftControlY( m_aLB_ROLE, nYOffset ); + lcl_increaseHeightOfControl( m_aLB_ROLE, nYResize ); + + lcl_shiftControlY( m_aBTN_ADD, nUpShift ); + lcl_shiftControlY( m_aBTN_REMOVE, nUpShift ); + lcl_shiftControlY( m_aBTN_UP, nUpShift ); + lcl_shiftControlY( m_aBTN_DOWN, nUpShift ); + lcl_shiftControlY( m_aFT_RANGE, nUpShift ); + lcl_shiftControlY( m_aEDT_RANGE, nUpShift ); + lcl_shiftControlY( m_aIMB_RANGE_MAIN, nUpShift ); + lcl_shiftControlY( m_aFT_CATEGORIES, nUpShift ); + lcl_shiftControlY( m_aFT_DATALABELS, nUpShift ); + lcl_shiftControlY( m_aEDT_CATEGORIES, nUpShift ); + lcl_shiftControlY( m_aIMB_RANGE_CAT, nUpShift ); + } + else + { + // make font of caption bold + Font aFont( m_aFT_CAPTION.GetControlFont() ); + aFont.SetWeight( WEIGHT_BOLD ); + m_aFT_CAPTION.SetControlFont( aFont ); + + // no mnemonic + m_aFT_CAPTION.SetStyle( m_aFT_CAPTION.GetStyle() | WB_NOLABEL ); + } + + m_aFixedTextRange = OUString( m_aFT_RANGE.GetText() ); + this->SetText( String( SchResId( STR_OBJECT_DATASERIES_PLURAL ) ) ); + + // set handlers + m_apLB_SERIES->SetSelectHdl( LINK( this, DataSourceTabPage, SeriesSelectionChangedHdl )); + + m_aLB_ROLE.SetWindowBits( WB_HSCROLL | WB_CLIPCHILDREN ); + m_aLB_ROLE.SetSelectionMode( SINGLE_SELECTION ); + m_aLB_ROLE.SetSelectHdl( LINK( this, DataSourceTabPage, RoleSelectionChangedHdl )); + + m_aEDT_RANGE.SetKeyInputHdl( LINK( this, DataSourceTabPage, MainRangeButtonClickedHdl )); + m_aEDT_CATEGORIES.SetKeyInputHdl( LINK( this, DataSourceTabPage, CategoriesRangeButtonClickedHdl )); + + m_aIMB_RANGE_MAIN.SetClickHdl( LINK( this, DataSourceTabPage, MainRangeButtonClickedHdl )); + m_aIMB_RANGE_CAT.SetClickHdl( LINK( this, DataSourceTabPage, CategoriesRangeButtonClickedHdl )); + + m_aBTN_ADD.SetClickHdl( LINK( this, DataSourceTabPage, AddButtonClickedHdl )); + m_aBTN_REMOVE.SetClickHdl( LINK( this, DataSourceTabPage, RemoveButtonClickedHdl )); + + m_aBTN_UP.SetClickHdl( LINK( this, DataSourceTabPage, UpButtonClickedHdl )); + m_aBTN_DOWN.SetClickHdl( LINK( this, DataSourceTabPage, DownButtonClickedHdl )); + + m_aEDT_RANGE.SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); + m_aEDT_CATEGORIES.SetModifyHdl( LINK( this, DataSourceTabPage, RangeModifiedHdl )); + m_aEDT_RANGE.SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); + m_aEDT_CATEGORIES.SetUpdateDataHdl( LINK( this, DataSourceTabPage, RangeUpdateDataHdl )); + + // #i75179# enable setting the background to a different color + m_aEDT_RANGE.SetStyle( m_aEDT_RANGE.GetStyle() | WB_FORCECTRLBACKGROUND ); + m_aEDT_CATEGORIES.SetStyle( m_aEDT_CATEGORIES.GetStyle() | WB_FORCECTRLBACKGROUND ); + + // set symbol font for arrows + // note: StarSymbol is substituted to OpenSymbol for OOo + Font aSymbolFont( m_aBTN_UP.GetFont()); + aSymbolFont.SetName( String( RTL_CONSTASCII_USTRINGPARAM( "StarSymbol" ))); + m_aBTN_UP.SetControlFont( aSymbolFont ); + m_aBTN_DOWN.SetControlFont( aSymbolFont ); + + // set button text + sal_Unicode cBlackUpPointingTriangle( 0x25b2 ); + sal_Unicode cBlackDownPointingTriangle( 0x25bc ); + m_aBTN_UP.SetText( String( cBlackUpPointingTriangle )); + m_aBTN_DOWN.SetText( String( cBlackDownPointingTriangle )); + + // init controls + m_aLB_ROLE.SetTabs( lcl_pRoleListBoxTabs, MAP_APPFONT ); + m_aLB_ROLE.Show(); + + updateControlsFromDialogModel(); + + // select first series + if( m_apLB_SERIES->First()) + m_apLB_SERIES->Select( m_apLB_SERIES->First()); + m_apLB_SERIES->GrabFocus(); +} + +DataSourceTabPage::~DataSourceTabPage() +{} + +void DataSourceTabPage::ActivatePage() +{ + OWizardPage::ActivatePage(); + updateControlsFromDialogModel(); +} + +void DataSourceTabPage::initializePage() +{ +} + +void DataSourceTabPage::DeactivatePage() +{ + commitPage(); + svt::OWizardPage::DeactivatePage(); +} + +void DataSourceTabPage::commitPage() +{ + commitPage(eFinish); +} + +sal_Bool DataSourceTabPage::commitPage( CommitPageReason /*eReason*/ ) +{ + //ranges may have been edited in the meanwhile (dirty is true in that case here) + if( isValid() ) + { + updateModelFromControl( 0 /*update all*/ ); + return sal_True;//return false if this page should not be left + } + else + return sal_False; +} + +bool DataSourceTabPage::isRangeFieldContentValid( Edit & rEdit ) +{ + OUString aRange( rEdit.GetText()); + bool bIsValid = ( aRange.getLength() == 0 ) || + m_rDialogModel.getRangeSelectionHelper()->verifyCellRange( aRange ); + + if( bIsValid ) + { + rEdit.SetControlForeground(); + rEdit.SetControlBackground(); + } + else + { + rEdit.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR ); + rEdit.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR ); + } + + return bIsValid; +} + +bool DataSourceTabPage::isValid() +{ + bool bRoleRangeValid = true; + bool bCategoriesRangeValid = true; + bool bHasSelectedEntry = (m_apLB_SERIES->FirstSelected() != 0); + + if( bHasSelectedEntry ) + bRoleRangeValid = isRangeFieldContentValid( m_aEDT_RANGE ); + if( m_aEDT_CATEGORIES.IsEnabled() ) + bCategoriesRangeValid = isRangeFieldContentValid( m_aEDT_CATEGORIES ); + bool bValid = ( bRoleRangeValid && bCategoriesRangeValid ); + + if( m_pTabPageNotifiable ) + { + if( bValid ) + m_pTabPageNotifiable->setValidPage( this ); + else + m_pTabPageNotifiable->setInvalidPage( this ); + } + + return bValid; +} + +void DataSourceTabPage::setDirty() +{ + m_bIsDirty = true; +} + +void DataSourceTabPage::updateControlsFromDialogModel() +{ + // series + fillSeriesListBox(); + SeriesSelectionChangedHdl( 0 ); + + // categories + m_aEDT_CATEGORIES.SetText( String( m_rDialogModel.getCategoriesRange() )); + + updateControlState(); +} + +void DataSourceTabPage::fillSeriesListBox() +{ + m_apLB_SERIES->SetUpdateMode( FALSE ); + + Reference< XDataSeries > xSelected; + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + if( pEntry ) + xSelected.set( pEntry->m_xDataSeries ); + + bool bHasSelectedEntry = (pEntry != 0); + SvLBoxEntry * pSelectedEntry = 0; + m_apLB_SERIES->Clear(); + + ::std::vector< DialogModel::tSeriesWithChartTypeByName > aSeries( + m_rDialogModel.getAllDataSeriesWithLabel() ); + + sal_Int32 nUnnamedSeriesIndex = 1; + for( ::std::vector< DialogModel::tSeriesWithChartTypeByName >::const_iterator aIt = aSeries.begin(); + aIt != aSeries.end(); ++aIt ) + { + String aLabel( (*aIt).first ); + if( !aLabel.Len()) + { + if( nUnnamedSeriesIndex > 1 ) + { + OUString aResString( String( ::chart::SchResId( STR_DATA_UNNAMED_SERIES_WITH_INDEX ))); + + // replace index of unnamed series + const OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%NUMBER" )); + sal_Int32 nIndex = aResString.indexOf( aReplacementStr ); + if( nIndex != -1 ) + aLabel = String( aResString.replaceAt( + nIndex, aReplacementStr.getLength(), + String::CreateFromInt32( nUnnamedSeriesIndex ))); + } + if( aLabel.Len() == 0 ) + aLabel = String( ::chart::SchResId( STR_DATA_UNNAMED_SERIES )); + + ++nUnnamedSeriesIndex; + } + pEntry = dynamic_cast< SeriesEntry * >( + m_apLB_SERIES->InsertEntry( aLabel )); + if( pEntry ) + { + pEntry->m_xDataSeries.set( (*aIt).second.first ); + pEntry->m_xChartType.set( (*aIt).second.second ); + if( bHasSelectedEntry && ((*aIt).second.first == xSelected)) + pSelectedEntry = pEntry; + } + } + + if( bHasSelectedEntry && pSelectedEntry ) + m_apLB_SERIES->Select( pSelectedEntry ); + + m_apLB_SERIES->SetUpdateMode( TRUE ); +} + +void DataSourceTabPage::fillRoleListBox() +{ + SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + bool bHasSelectedEntry = (pSeriesEntry != 0); + + SvLBoxEntry * pRoleEntry = m_aLB_ROLE.FirstSelected(); + ULONG nRoleIndex = SAL_MAX_UINT32; + if( pRoleEntry ) + nRoleIndex = m_aLB_ROLE.GetModel()->GetAbsPos( pRoleEntry ); + + if( bHasSelectedEntry ) + { + DialogModel::tRolesWithRanges aRoles( + m_rDialogModel.getRolesWithRanges( + pSeriesEntry->m_xDataSeries, + lcl_GetSequenceNameForLabel( pSeriesEntry ), + pSeriesEntry->m_xChartType )); + + // fill role list + m_aLB_ROLE.SetUpdateMode( FALSE ); + m_aLB_ROLE.Clear(); + m_aLB_ROLE.RemoveSelection(); + + for( DialogModel::tRolesWithRanges::const_iterator aIt( aRoles.begin()); + aIt != aRoles.end(); ++ aIt ) + { + m_aLB_ROLE.InsertEntry( lcl_GetRoleLBEntry( aIt->first, aIt->second )); + } + + // series may contain no roles, check listbox size before selecting entries + if( m_aLB_ROLE.GetEntryCount() > 0 ) + { + if( nRoleIndex >= m_aLB_ROLE.GetEntryCount()) + nRoleIndex = 0; + m_aLB_ROLE.Select( m_aLB_ROLE.GetEntry( nRoleIndex )); + } + + m_aLB_ROLE.SetUpdateMode( TRUE ); + } +} + +void DataSourceTabPage::updateControlState() +{ + SvLBoxEntry * pSeriesEntry = m_apLB_SERIES->FirstSelected(); + bool bHasSelectedSeries = (pSeriesEntry != 0); + bool bHasValidRole = false; + bool bHasRangeChooser = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); + + if( bHasSelectedSeries ) + { + SvLBoxEntry * pRoleEntry = m_aLB_ROLE.FirstSelected(); + bHasValidRole = (pRoleEntry != 0); + } + + m_aBTN_ADD.Enable( true ); + m_aBTN_REMOVE.Enable( bHasSelectedSeries ); + + m_aBTN_UP.Enable( bHasSelectedSeries && (pSeriesEntry != m_apLB_SERIES->First())); + m_aBTN_DOWN.Enable( bHasSelectedSeries && (pSeriesEntry != m_apLB_SERIES->Last())); + + bool bHasCategories = m_rDialogModel.isCategoryDiagram(); + + m_aFT_DATALABELS.Show(!bHasCategories); + m_aFT_CATEGORIES.Show( bHasCategories); + BOOL bShowIB = bHasRangeChooser; + lcl_ShowChooserButton( m_aIMB_RANGE_CAT, m_aEDT_CATEGORIES, bShowIB ); + + m_aFT_SERIES.Enable(); + m_apLB_SERIES->Enable(); + + m_aFT_ROLE.Enable( bHasSelectedSeries ); + m_aLB_ROLE.Enable( bHasSelectedSeries ); + + m_aFT_RANGE.Enable( bHasValidRole ); + m_aEDT_RANGE.Enable( bHasValidRole ); + lcl_ShowChooserButton( m_aIMB_RANGE_MAIN, m_aEDT_RANGE, bShowIB ); + isValid(); +} + +IMPL_LINK( DataSourceTabPage, SeriesSelectionChangedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + if( m_apLB_SERIES->FirstSelected()) + { + fillRoleListBox(); + RoleSelectionChangedHdl( 0 ); + } + updateControlState(); + + return 0; +} + +IMPL_LINK( DataSourceTabPage, RoleSelectionChangedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + SvLBoxEntry * pEntry = m_aLB_ROLE.FirstSelected(); + if( pEntry ) + { + OUString aRange( m_aEDT_RANGE.GetText()); + OUString aSelectedRoleUI = lcl_GetSelectedRole( m_aLB_ROLE, true ); + OUString aSelectedRange = lcl_GetSelectedRolesRange( m_aLB_ROLE ); + + // replace role in fixed text label + const OUString aReplacementStr( RTL_CONSTASCII_USTRINGPARAM( "%VALUETYPE" )); + sal_Int32 nIndex = m_aFixedTextRange.indexOf( aReplacementStr ); + if( nIndex != -1 ) + { + m_aFT_RANGE.SetText( + String( m_aFixedTextRange.replaceAt( + nIndex, aReplacementStr.getLength(), aSelectedRoleUI ))); + } + + m_aEDT_RANGE.SetText( String( aSelectedRange )); + isValid(); + } + + return 0; +} + +IMPL_LINK( DataSourceTabPage, MainRangeButtonClickedHdl, void *, EMPTYARG ) +{ + OSL_ASSERT( m_pCurrentRangeChoosingField == 0 ); + m_pCurrentRangeChoosingField = & m_aEDT_RANGE; + if( m_aEDT_RANGE.GetText().Len() > 0 && + ! updateModelFromControl( m_pCurrentRangeChoosingField )) + return 0; + + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + bool bHasSelectedEntry = (pEntry != 0); + + OUString aSelectedRolesRange = lcl_GetSelectedRolesRange( m_aLB_ROLE ); + + if( bHasSelectedEntry && (m_aLB_ROLE.FirstSelected() != 0)) + { + String aStr( SchResId( STR_DATA_SELECT_RANGE_FOR_SERIES )); + OUString aUIStr( aStr ); + + // replace role + OUString aReplacement( RTL_CONSTASCII_USTRINGPARAM( "%VALUETYPE" )); + sal_Int32 nIndex = aUIStr.indexOf( aReplacement ); + if( nIndex != -1 ) + { + aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), + lcl_GetSelectedRole( m_aLB_ROLE, true )); + } + // replace series name + aReplacement = C2U( "%SERIESNAME" ); + nIndex = aUIStr.indexOf( aReplacement ); + if( nIndex != -1 ) + { + aUIStr = aUIStr.replaceAt( nIndex, aReplacement.getLength(), + OUString( m_apLB_SERIES->GetEntryText( pEntry ))); + } + + lcl_enableRangeChoosing( true, m_pParentDialog ); + m_rDialogModel.getRangeSelectionHelper()->chooseRange( aSelectedRolesRange, aUIStr, *this ); + } + else + m_pCurrentRangeChoosingField = 0; + + return 0; +} + +IMPL_LINK( DataSourceTabPage, CategoriesRangeButtonClickedHdl, void *, EMPTYARG ) +{ + OSL_ASSERT( m_pCurrentRangeChoosingField == 0 ); + m_pCurrentRangeChoosingField = & m_aEDT_CATEGORIES; + if( m_aEDT_CATEGORIES.GetText().Len() > 0 && + ! updateModelFromControl( m_pCurrentRangeChoosingField )) + return 0; + + String aStr( SchResId( m_aFT_CATEGORIES.IsVisible() ? STR_DATA_SELECT_RANGE_FOR_CATEGORIES : STR_DATA_SELECT_RANGE_FOR_DATALABELS )); + lcl_enableRangeChoosing( true, m_pParentDialog ); + m_rDialogModel.getRangeSelectionHelper()->chooseRange( + m_rDialogModel.getCategoriesRange(), OUString( aStr ), *this ); + return 0; +} + +IMPL_LINK( DataSourceTabPage, AddButtonClickedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + Reference< XDataSeries > xSeriesToInsertAfter; + Reference< XChartType > xChartTypeForNewSeries; + if( m_pTemplateProvider ) + m_rDialogModel.setTemplate( m_pTemplateProvider->getCurrentTemplate()); + + if( pEntry ) + { + xSeriesToInsertAfter.set( pEntry->m_xDataSeries ); + xChartTypeForNewSeries.set( pEntry->m_xChartType ); + } + else + { + ::std::vector< Reference< XDataSeriesContainer > > aCntVec( + m_rDialogModel.getAllDataSeriesContainers()); + if( ! aCntVec.empty()) + xChartTypeForNewSeries.set( aCntVec.front(), uno::UNO_QUERY ); + } + OSL_ENSURE( xChartTypeForNewSeries.is(), "Cannot insert new series" ); + + m_rDialogModel.insertSeriesAfter( xSeriesToInsertAfter, xChartTypeForNewSeries ); + setDirty(); + + fillSeriesListBox(); + // note the box was cleared and refilled, so pEntry is invalid now + SvLBoxEntry * pSelEntry = m_apLB_SERIES->FirstSelected(); + if( pSelEntry ) + { + SvLBoxEntry * pNextEntry = m_apLB_SERIES->Next( pSelEntry ); + if( pNextEntry ) + m_apLB_SERIES->Select( pNextEntry ); + } + SeriesSelectionChangedHdl( 0 ); + + return 0; +} + +IMPL_LINK( DataSourceTabPage, RemoveButtonClickedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + if( pEntry ) + { + Reference< XDataSeries > xNewSelSeries; + SeriesEntry * pNewSelEntry = dynamic_cast< SeriesEntry * >( + m_apLB_SERIES->Next( pEntry )); + if( pNewSelEntry ) + xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); + else + { + pNewSelEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->Prev( pEntry )); + if( pNewSelEntry ) + xNewSelSeries.set( pNewSelEntry->m_xDataSeries ); + } + + m_rDialogModel.deleteSeries( pEntry->m_xDataSeries, pEntry->m_xChartType ); + setDirty(); + + m_apLB_SERIES->RemoveSelection(); + fillSeriesListBox(); + + // select previous or next series + //@improve: see methods GetModel()->GetAbsPos()/GetEntry() for absoulte list positions + if( xNewSelSeries.is()) + { + pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->First()); + while( pEntry ) + { + if( pEntry->m_xDataSeries == xNewSelSeries ) + { + m_apLB_SERIES->Select( pEntry ); + break; + } + pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->Next( pEntry )); + } + } + SeriesSelectionChangedHdl( 0 ); + } + + return 0; +} + +IMPL_LINK( DataSourceTabPage, UpButtonClickedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + bool bHasSelectedEntry = (pEntry != 0); + + if( bHasSelectedEntry ) + { + m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_UP ); + setDirty(); + fillSeriesListBox(); + SeriesSelectionChangedHdl(0); + } + + return 0; +} + +IMPL_LINK( DataSourceTabPage, DownButtonClickedHdl, void *, EMPTYARG ) +{ + m_rDialogModel.startControllerLockTimer(); + SeriesEntry * pEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + bool bHasSelectedEntry = (pEntry != 0); + + if( bHasSelectedEntry ) + { + m_rDialogModel.moveSeries( pEntry->m_xDataSeries, DialogModel::MOVE_DOWN ); + setDirty(); + fillSeriesListBox(); + SeriesSelectionChangedHdl(0); + } + + return 0; +} + +IMPL_LINK( DataSourceTabPage, RangeModifiedHdl, Edit*, pEdit ) +{ + if( isRangeFieldContentValid( *pEdit )) + setDirty(); + + // enable/disable OK button + isValid(); + + return 0; +} + +IMPL_LINK( DataSourceTabPage, RangeUpdateDataHdl, Edit*, pEdit ) +{ + // note: isValid sets the color of the edit field + if( isRangeFieldContentValid( *pEdit )) + { + setDirty(); + updateModelFromControl( pEdit ); + if( pEdit== &m_aEDT_RANGE ) + { + if( ! lcl_UpdateCurrentSeriesName( *m_apLB_SERIES )) + fillSeriesListBox(); + } + } + // enable/disable OK button + isValid(); + + return 0; +} + +void DataSourceTabPage::listeningFinished( + const ::rtl::OUString & rNewRange ) +{ + // rNewRange becomes invalid after removing the listener + OUString aRange( rNewRange ); + + m_rDialogModel.startControllerLockTimer(); + + // stop listening + m_rDialogModel.getRangeSelectionHelper()->stopRangeListening(); + + // change edit field + ToTop(); + GrabFocus(); + if( m_pCurrentRangeChoosingField ) + { + m_pCurrentRangeChoosingField->SetText( String( aRange )); + m_pCurrentRangeChoosingField->GrabFocus(); + } + + if( m_pCurrentRangeChoosingField == & m_aEDT_RANGE ) + { + m_aEDT_RANGE.SetText( String( aRange )); + setDirty(); + } + else if( m_pCurrentRangeChoosingField == & m_aEDT_CATEGORIES ) + { + m_aEDT_CATEGORIES.SetText( String( aRange )); + setDirty(); + } + + updateModelFromControl( m_pCurrentRangeChoosingField ); + if( ! lcl_UpdateCurrentSeriesName( *m_apLB_SERIES )) + fillSeriesListBox(); + + m_pCurrentRangeChoosingField = 0; + + updateControlState(); + lcl_enableRangeChoosing( false, m_pParentDialog ); +} + +void DataSourceTabPage::disposingRangeSelection() +{ + m_rDialogModel.getRangeSelectionHelper()->stopRangeListening( false ); +} + +bool DataSourceTabPage::updateModelFromControl( Edit * pField ) +{ + if( !m_bIsDirty ) + return true; + + ControllerLockGuard aLockedControllers( m_rDialogModel.getChartModel() ); + + // @todo: validity check of field content + bool bResult = true; + bool bAll = (pField == 0); + Reference< data::XDataProvider > xDataProvider( m_rDialogModel.getDataProvider()); + + if( bAll || (pField == & m_aEDT_CATEGORIES) ) + { + Reference< data::XLabeledDataSequence > xLabeledSeq( m_rDialogModel.getCategories() ); + if( xDataProvider.is()) + { + OUString aRange( m_aEDT_CATEGORIES.GetText()); + if( aRange.getLength()) + { + // create or change categories + if( !xLabeledSeq.is()) + { + xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); + m_rDialogModel.setCategories( xLabeledSeq ); + } + try + { + xLabeledSeq->setValues( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); + } + catch( const uno::Exception & ex ) + { + // should work as validation should have happened before + ASSERT_EXCEPTION( ex ); + } + } + else if( xLabeledSeq.is()) + { + // clear existing categories + xLabeledSeq.set(0); + m_rDialogModel.setCategories( xLabeledSeq ); + } + } + } + + SeriesEntry * pSeriesEntry = dynamic_cast< SeriesEntry * >( m_apLB_SERIES->FirstSelected()); + bool bHasSelectedEntry = (pSeriesEntry != 0); + + if( bHasSelectedEntry ) + { + if( bAll || (pField == & m_aEDT_RANGE) ) + { + try + { + OUString aSelectedRole = lcl_GetSelectedRole( m_aLB_ROLE ); + OUString aRange( m_aEDT_RANGE.GetText()); + OUString aSequenceRole( aSelectedRole ); + bool bIsLabel = aSequenceRole.equals( lcl_aLabelRole ); + OUString aSequenceNameForLabel( lcl_GetSequenceNameForLabel( pSeriesEntry )); + + if( bIsLabel ) + aSequenceRole = aSequenceNameForLabel; + + Reference< data::XDataSource > xSource( pSeriesEntry->m_xDataSeries, uno::UNO_QUERY_THROW ); + Reference< data::XLabeledDataSequence > xLabeledSeq( + DataSeriesHelper::getDataSequenceByRole( xSource, aSequenceRole )); + + if( xDataProvider.is()) + { + if( bIsLabel ) + { + if( ! xLabeledSeq.is()) + { + // check if there is already an "orphan" label sequence + xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); + if( ! xLabeledSeq.is()) + { + // no corresponding labeled data sequence for label found + xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); + lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); + } + } + if( xLabeledSeq.is()) + { + if( aRange.getLength()) + { + Reference< data::XDataSequence > xNewSeq; + try + { + xNewSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); + } + catch( const uno::Exception & ex ) + { + // should work as validation should have happened before + ASSERT_EXCEPTION( ex ); + } + if( xNewSeq.is()) + { + // update range name by the full string provided + // by the data provider. E.g. "a1" might become + // "$Sheet1.$A$1" + aRange = xNewSeq->getSourceRangeRepresentation(); + Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); + xProp->setPropertyValue( C2U("Role"), uno::makeAny( lcl_aLabelRole )); + xLabeledSeq->setLabel( xNewSeq ); + } + } + else + { + xLabeledSeq->setLabel( Reference< data::XDataSequence >()); + } + } + } + else + { + if( aRange.getLength()) + { + Reference< data::XDataSequence > xNewSeq; + try + { + xNewSeq.set( xDataProvider->createDataSequenceByRangeRepresentation( aRange )); + } + catch( const uno::Exception & ex ) + { + // should work as validation should have happened before + ASSERT_EXCEPTION( ex ); + } + if( xNewSeq.is()) + { + // update range name by the full string provided + // by the data provider. E.g. "a1:e1" might become + // "$Sheet1.$A$1:$E$1" + aRange = xNewSeq->getSourceRangeRepresentation(); + + Reference< beans::XPropertySet > xProp( xNewSeq, uno::UNO_QUERY_THROW ); + xProp->setPropertyValue( C2U("Role"), uno::makeAny( aSelectedRole )); + if( !xLabeledSeq.is()) + { + if( aSelectedRole.equals( aSequenceNameForLabel )) + xLabeledSeq.set( lcl_findLSequenceWithOnlyLabel( xSource )); + if( ! xLabeledSeq.is()) + { + xLabeledSeq.set( DataSourceHelper::createLabeledDataSequence( Reference< uno::XComponentContext >(0))); + lcl_addLSequenceToDataSource( xLabeledSeq, xSource ); + } + } + xLabeledSeq->setValues( xNewSeq ); + } + } + else if( xLabeledSeq.is()) + { + // values cannot be deleted. This would also delete the Role (for labels) +// xLabeledSeq->setValues( Reference< data::XDataSequence >()); + } + } + } + + lcl_UpdateCurrentRange( m_aLB_ROLE, aSelectedRole, aRange ); + } + catch( uno::Exception & ex ) + { + bResult = false; + ASSERT_EXCEPTION( ex ); + } + } + } + + // update View + // @todo remove this when automatic view updates from calc, writer and own data sequences are available + if( bResult ) + { + try + { + Reference< util::XModifiable > xModifiable( m_rDialogModel.getChartModel(), uno::UNO_QUERY ); + if( xModifiable.is() ) + xModifiable->setModified( sal_True ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + return bResult; +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/tp_DataSource.hrc b/chart2/source/controller/dialogs/tp_DataSource.hrc new file mode 100644 index 000000000000..53509379b1c5 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSource.hrc @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSource.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FT_CAPTION_FOR_WIZARD 1 + +#define FT_SERIES 10 +#define LB_SERIES 20 +#define BTN_ADD 30 +#define BTN_REMOVE 40 + +#define FT_ROLE 50 +#define LB_ROLE 60 + +#define FT_RANGE 70 +#define EDT_RANGE 80 +#define IMB_RANGE_MAIN 90 + +#define FT_CATEGORIES 110 +#define FT_DATALABELS 111 +#define EDT_CATEGORIES 120 +#define IMB_RANGE_CAT 130 + +#define BTN_UP 140 +#define BTN_DOWN 150 diff --git a/chart2/source/controller/dialogs/tp_DataSource.hxx b/chart2/source/controller/dialogs/tp_DataSource.hxx new file mode 100644 index 000000000000..6c42f1cb98e2 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSource.hxx @@ -0,0 +1,182 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSource.hxx,v $ + * $Revision: 1.4.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DATASOURCETABPAGE_HXX +#define CHART2_DATASOURCETABPAGE_HXX + +#include <svtools/wizardmachine.hxx> + +#include "DialogModel.hxx" +#include "TabPageNotifiable.hxx" + +// header for class Edit +#include <vcl/edit.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> +// header for class PushButton, OKButton, CancelButton, HelpButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class FixedText, FixedLine +#include <vcl/fixed.hxx> +// header for class SvTabListBox +#include <svtools/svtabbx.hxx> +// header for class SvTreeListBox +#include <svtools/svtreebx.hxx> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XDiagram.hpp> +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/sheet/XRangeSelection.hpp> + +#include <utility> +#include <vector> +#include <memory> + +#include "RangeSelectionListener.hxx" +#include "RangeSelectionButton.hxx" +#include "RangeEdit.hxx" + +namespace com { namespace sun { namespace star { + namespace chart2 { + class XChartType; +}}}} + +namespace chart +{ + +class ChartTypeTemplateProvider; +class DialogModel; + +class DataSourceTabPage : + public ::svt::OWizardPage, + public RangeSelectionListenerParent +{ +public: + explicit DataSourceTabPage( + Window * pParent, + DialogModel & rDialogModel, + ChartTypeTemplateProvider* pTemplateProvider, + Dialog * pParentDialog, + bool bHideDescription = false ); + virtual ~DataSourceTabPage(); + + void commitPage(); + +protected: + // OWizardPage + virtual void ActivatePage(); + virtual sal_Bool commitPage( CommitPageReason eReason ); + + //TabPage + virtual void DeactivatePage(); + + virtual void initializePage(); + + DECL_LINK( SeriesSelectionChangedHdl, void* ); + DECL_LINK( RoleSelectionChangedHdl, void* ); + DECL_LINK( MainRangeButtonClickedHdl, void* ); + DECL_LINK( CategoriesRangeButtonClickedHdl, void* ); + DECL_LINK( AddButtonClickedHdl, void* ); + DECL_LINK( RemoveButtonClickedHdl, void* ); + DECL_LINK( RangeModifiedHdl, Edit* ); + DECL_LINK( RangeUpdateDataHdl, Edit* ); + DECL_LINK( UpButtonClickedHdl, void* ); + DECL_LINK( DownButtonClickedHdl, void* ); + + // ____ RangeSelectionListenerParent ____ + virtual void listeningFinished( const ::rtl::OUString & rNewRange ); + virtual void disposingRangeSelection(); + + void updateControlState(); + +protected: + /** updates the internal data according to the content of the given edit + field. If pField is 0, all relevant fields are used + + @return + <TRUE/> if the text from the field is a valid format to the internal + data was valid + */ + bool updateModelFromControl( Edit * pField = 0 ); + + ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XRangeSelectionListener > + getSelectionRangeListener(); + + /** @return </TRUE>, if the edit field contains a valid range entry. if no + XCellRangesAccess can be obtained, </TRUE> is returned. + */ + bool isRangeFieldContentValid( Edit & rEdit ); + + /** @return </TRUE>, if the tab-page is in a consistent (commitable) state + */ + bool isValid(); + void setDirty(); + + void updateControlsFromDialogModel(); + + void fillSeriesListBox(); + void fillRoleListBox(); + +private: + FixedText m_aFT_CAPTION; + FixedText m_aFT_SERIES; + ::std::auto_ptr< SvTreeListBox > m_apLB_SERIES; + PushButton m_aBTN_ADD; + PushButton m_aBTN_REMOVE; + PushButton m_aBTN_UP; + PushButton m_aBTN_DOWN; + + FixedText m_aFT_ROLE; + SvTabListBox m_aLB_ROLE; + FixedText m_aFT_RANGE; + RangeEdit m_aEDT_RANGE; + RangeSelectionButton m_aIMB_RANGE_MAIN; + + FixedText m_aFT_CATEGORIES; + FixedText m_aFT_DATALABELS;//used for xy charts + RangeEdit m_aEDT_CATEGORIES; + RangeSelectionButton m_aIMB_RANGE_CAT; + + ::rtl::OUString m_aFixedTextRange; + + ChartTypeTemplateProvider * m_pTemplateProvider; + DialogModel & m_rDialogModel; + Edit * m_pCurrentRangeChoosingField; + bool m_bIsDirty; + sal_Int32 m_nLastChartTypeGroupIndex; + + Dialog * m_pParentDialog; + TabPageNotifiable * m_pTabPageNotifiable; +}; + +} // namespace chart + +// CHART2_DATASOURCETABPAGE_HXX +#endif diff --git a/chart2/source/controller/dialogs/tp_DataSource.src b/chart2/source/controller/dialogs/tp_DataSource.src new file mode 100644 index 000000000000..4d404b37f8b2 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSource.src @@ -0,0 +1,174 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSource.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "tp_DataSource.hrc" +#include "HelpIds.hrc" + +TabPage TP_DATA_SOURCE +{ + Hide = TRUE; + Size = MAP_APPFONT ( 248, 140 ); + SVLook = TRUE ; + + // ---------------------------------------- + + FixedText FT_CAPTION_FOR_WIZARD + { + Pos = MAP_APPFONT ( 5 , 8 ) ; + Size = MAP_APPFONT ( 238 , 10 ) ; + Text [ en-US ] = "Customize data ranges for individual data series" ; + }; + + FixedText FT_SERIES + { + Pos = MAP_APPFONT ( 6 , 22 ); + Size = MAP_APPFONT ( 72 , 8 ); + + Text [ en-US ] = "Data ~series"; + }; + Control LB_SERIES + { + HelpID = HID_SCH_SERIES_LIST ; + Border = TRUE; + TabStop = TRUE; + // DropDown = FALSE; + Pos = MAP_APPFONT ( 6 , 32 ); + Size = MAP_APPFONT ( 72 , 69 ); + }; + + FixedText FT_ROLE + { + Pos = MAP_APPFONT ( 82 , 22 ); + Size = MAP_APPFONT ( 160 , 8 ); + + Text [ en-US ] = "~Data ranges"; + }; + Control LB_ROLE + { + HelpID = HID_SCH_DATA_RANGES_LIST ; + Border = TRUE; + TabStop = TRUE; + Pos = MAP_APPFONT ( 82 , 32 ); + Size = MAP_APPFONT ( 160 , 43 ); + }; + + // ---------------------------------------- + + FixedText FT_RANGE + { + Pos = MAP_APPFONT ( 82 , 79 ); + Size = MAP_APPFONT ( 160 , 8 ); + + Text [ en-US ] = "Ran~ge for %VALUETYPE"; + }; + Edit EDT_RANGE + { + Border = TRUE; + TabStop = TRUE; + Pos = MAP_APPFONT ( 82 , 89 ); + Size = MAP_APPFONT ( 144 , 12 ); + }; + ImageButton IMB_RANGE_MAIN + { + TabStop = TRUE; + Pos = MAP_APPFONT ( 228 , 88 ); + Size = MAP_APPFONT ( 14 , 14 ); + }; + + // ---------------------------------------- + + FixedText FT_CATEGORIES + { + Pos = MAP_APPFONT ( 82 , 107 ); + Size = MAP_APPFONT ( 160 , 8 ); + + Text [ en-US ] = "~Categories"; + }; + + FixedText FT_DATALABELS + { + Pos = MAP_APPFONT ( 82 , 107 ); + Size = MAP_APPFONT ( 160 , 8 ); + + Text [ en-US ] = "Data ~labels" ; + }; + + Edit EDT_CATEGORIES + { + Border = TRUE; + TabStop = TRUE; + Pos = MAP_APPFONT ( 82 , 117 ); + Size = MAP_APPFONT ( 144 , 12 ); + }; + ImageButton IMB_RANGE_CAT + { + TabStop = TRUE; + Pos = MAP_APPFONT ( 228 , 116 ); + Size = MAP_APPFONT ( 14 , 14 ); + }; + + // ---------------------------------------- + + PushButton BTN_ADD + { + TabStop = TRUE; + Disable = FALSE; + Pos = MAP_APPFONT ( 6 , 105 ); + Size = MAP_APPFONT ( 54 , 14 ); + + Text [ en-US ] = "~Add"; + }; + PushButton BTN_REMOVE + { + TabStop = TRUE; + Disable = TRUE; + Pos = MAP_APPFONT ( 6 , 121 ); + Size = MAP_APPFONT ( 54 , 14 ); + + Text [ en-US ] = "~Remove"; + }; + + // Note: Text is only a black triangle symbol + PushButton BTN_UP + { + TabStop = TRUE; + Disable = TRUE; + Pos = MAP_APPFONT ( 64 , 105 ); + Size = MAP_APPFONT ( 14 , 14 ); + }; + + // Note: Text is only a black triangle symbol + PushButton BTN_DOWN + { + TabStop = TRUE; + Disable = TRUE; + Pos = MAP_APPFONT ( 64 , 121 ); + Size = MAP_APPFONT ( 14 , 14 ); + }; +}; diff --git a/chart2/source/controller/dialogs/tp_DataSourceControls.cxx b/chart2/source/controller/dialogs/tp_DataSourceControls.cxx new file mode 100644 index 000000000000..be123acacd33 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSourceControls.cxx @@ -0,0 +1,60 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSourceControls.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_DataSourceControls.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +SeriesEntry::~SeriesEntry() +{} + +SeriesListBox::SeriesListBox( Window* pParent, const ResId & rResId ) : + SvTreeListBox( pParent, rResId ) +{} + +SeriesListBox::~SeriesListBox() +{} + +SvLBoxEntry* SeriesListBox::CreateEntry() const +{ + return new SeriesEntry(); +} + +} // namespace chart diff --git a/chart2/source/controller/dialogs/tp_DataSourceControls.hxx b/chart2/source/controller/dialogs/tp_DataSourceControls.hxx new file mode 100644 index 000000000000..6e9aaac27b67 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_DataSourceControls.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_DataSourceControls.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_TP_DATASOURCECONTROLS_HXX +#define CHART2_TP_DATASOURCECONTROLS_HXX + +#include <com/sun/star/chart2/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/data/XLabeledDataSequence.hpp> + +// header for class SvTabListBox +#include <svtools/svtabbx.hxx> +// header for class SvTreeListBox +#include <svtools/svtreebx.hxx> + +namespace chart +{ + +class SeriesEntry : public ::SvLBoxEntry +{ +public: + virtual ~SeriesEntry(); + + /// the corresponding data series + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > + m_xDataSeries; + + /// the chart type that contains the series (via XDataSeriesContainer) + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartType > + m_xChartType; +}; + +class SeriesListBox : public ::SvTreeListBox +{ +public: + explicit SeriesListBox( Window* pParent, const ResId & rResId ); + ~SeriesListBox( ); + + virtual SvLBoxEntry* CreateEntry() const; +}; + +} // namespace chart + +// CHART2_TP_DATASOURCECONTROLS_HXX +#endif diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.cxx b/chart2/source/controller/dialogs/tp_ErrorBars.cxx new file mode 100644 index 000000000000..4153259e8a9f --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ErrorBars.cxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ErrorBars.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_ErrorBars.hxx" +#include "ResId.hxx" +#include "TabPages.hrc" +#include "TabPageNotifiable.hxx" + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +ErrorBarsTabPage::ErrorBarsTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : + SfxTabPage( pParent, SchResId( TP_YERRORBAR ), rInAttrs ), + m_aErrorBarResources( + this, + // the parent is the tab control, of which the parent is the dialog + dynamic_cast< Dialog * >( pParent->GetParent() ), + rInAttrs, /* bNoneAvailable = */ false ) +{ + FreeResource(); +} + +ErrorBarsTabPage::~ErrorBarsTabPage() +{ +} + +SfxTabPage* ErrorBarsTabPage::Create( + Window* pParent, const SfxItemSet& rOutAttrs ) +{ + return new ErrorBarsTabPage( pParent, rOutAttrs ); +} + +BOOL ErrorBarsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + return m_aErrorBarResources.FillItemSet( rOutAttrs ); +} + +void ErrorBarsTabPage::Reset( const SfxItemSet& rInAttrs ) +{ + m_aErrorBarResources.Reset( rInAttrs ); +} + +void ErrorBarsTabPage::DataChanged( const DataChangedEvent& rDCEvt ) +{ + SfxTabPage::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + m_aErrorBarResources.FillValueSets(); +} + +void ErrorBarsTabPage::SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ) +{ + m_aErrorBarResources.SetAxisMinorStepWidthForErrorBarDecimals( fMinorStepWidth ); +} + +void ErrorBarsTabPage::SetErrorBarType( ErrorBarResources::tErrorBarType eNewType ) +{ + m_aErrorBarResources.SetErrorBarType( eNewType ); +} + +void ErrorBarsTabPage::SetChartDocumentForRangeChoosing( + const uno::Reference< chart2::XChartDocument > & xChartDocument ) +{ + m_aErrorBarResources.SetChartDocumentForRangeChoosing( xChartDocument ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.hxx b/chart2/source/controller/dialogs/tp_ErrorBars.hxx new file mode 100644 index 000000000000..29f6b2cc10c4 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ErrorBars.hxx @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ErrorBars.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_ERRORBARS_HXX +#define _CHART2_TP_ERRORBARS_HXX + +#include "res_ErrorBar.hxx" + +#include <sfx2/tabdlg.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ErrorBarsTabPage : public SfxTabPage +{ +public: + ErrorBarsTabPage ( Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~ErrorBarsTabPage (); + + void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); + void SetErrorBarType( ErrorBarResources::tErrorBarType eNewType ); + void SetChartDocumentForRangeChoosing( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument ); + + static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); + virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual void Reset( const SfxItemSet& rInAttrs ); + + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + ErrorBarResources m_aErrorBarResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_ErrorBars.src b/chart2/source/controller/dialogs/tp_ErrorBars.src new file mode 100644 index 000000000000..6c3c250957ae --- /dev/null +++ b/chart2/source/controller/dialogs/tp_ErrorBars.src @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_ErrorBars.src,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" +#include "res_ErrorBar.hrc" + +TabPage TP_YERRORBAR +{ + Hide = TRUE ; +// HelpID = HID_SCH_STAT ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + RESOURCE_ERRORBARS( 260 - 12, 0 ) +}; diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.cxx b/chart2/source/controller/dialogs/tp_LegendPosition.cxx new file mode 100644 index 000000000000..c2c0ad7e28c4 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_LegendPosition.cxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_LegendPosition.cxx,v $ + * $Revision: 1.8.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_LegendPosition.hxx" +#include "ResId.hxx" +#include "TabPages.hrc" +#include "res_LegendPosition.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" +#include <svx/chrtitem.hxx> +#include <svx/eeitem.hxx> +#include <svx/frmdiritem.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchLegendPosTabPage::SchLegendPosTabPage(Window* pWindow, + const SfxItemSet& rInAttrs) + : SfxTabPage( pWindow, SchResId(TP_LEGEND_POS), rInAttrs ) + , aGrpLegend( this, SchResId(GRP_LEGEND) ) + , m_apLegendPositionResources( new LegendPositionResources(this) ) + , m_aFlTextOrient( this, SchResId( FL_LEGEND_TEXTORIENT ) ) + , m_aFtTextDirection( this, SchResId( FT_LEGEND_TEXTDIR ) ) + , m_aLbTextDirection( this, SchResId( LB_LEGEND_TEXTDIR ), &m_aFlTextOrient, &m_aFtTextDirection ) +{ + FreeResource(); +} + +SchLegendPosTabPage::~SchLegendPosTabPage() +{ +} + +SfxTabPage* SchLegendPosTabPage::Create(Window* pWindow, + const SfxItemSet& rOutAttrs) +{ + return new SchLegendPosTabPage(pWindow, rOutAttrs); +} + +BOOL SchLegendPosTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + m_apLegendPositionResources->writeToItemSet(rOutAttrs); + + if( m_aLbTextDirection.GetSelectEntryCount() > 0 ) + rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, m_aLbTextDirection.GetSelectEntryValue() ) ); + + return TRUE; +} + +void SchLegendPosTabPage::Reset(const SfxItemSet& rInAttrs) +{ + m_apLegendPositionResources->initFromItemSet(rInAttrs); + + const SfxPoolItem* pPoolItem = 0; + if( rInAttrs.GetItemState( EE_PARA_WRITINGDIR, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + m_aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pPoolItem)->GetValue()) ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.hxx b/chart2/source/controller/dialogs/tp_LegendPosition.hxx new file mode 100644 index 000000000000..b4dcbea9f168 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_LegendPosition.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_LegendPosition.hxx,v $ + * $Revision: 1.5.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_LEGENDPOSITION_HXX +#define _CHART2_TP_LEGENDPOSITION_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> +// header for FixedText +#include <vcl/fixed.hxx> +//for auto_ptr +#include <memory> +#include "TextDirectionListBox.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class LegendPositionResources; +class SchLegendPosTabPage : public SfxTabPage +{ +private: + FixedLine aGrpLegend; + + ::std::auto_ptr< LegendPositionResources > m_apLegendPositionResources; + + FixedLine m_aFlTextOrient; + FixedText m_aFtTextDirection; + TextDirectionListBox m_aLbTextDirection; + +public: + SchLegendPosTabPage(Window* pParent, const SfxItemSet& rInAttrs); + virtual ~SchLegendPosTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual void Reset(const SfxItemSet& rInAttrs); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/tp_LegendPosition.src b/chart2/source/controller/dialogs/tp_LegendPosition.src new file mode 100644 index 000000000000..ac1323bc5ebc --- /dev/null +++ b/chart2/source/controller/dialogs/tp_LegendPosition.src @@ -0,0 +1,68 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_LegendPosition.src,v $ + * $Revision: 1.6.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" +#include "res_LegendPosition.hrc" + +TabPage TP_LEGEND_POS +{ + Hide = TRUE ; + HelpID = HID_SCH_LEGEND_POS ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + FixedLine GRP_LEGEND + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Position" ; + }; + RESOURCE_LEGENDPOSITION( 12, 14 ) + + FixedLine FL_LEGEND_TEXTORIENT + { + Pos = MAP_APPFONT ( 6 , 14 + RESOURCE_LEGENDPOSITION_HEIGHT + 6 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Text orientation" ; + }; + FixedText FT_LEGEND_TEXTDIR + { + Pos = MAP_APPFONT ( 12 , 14 + RESOURCE_LEGENDPOSITION_HEIGHT + 19 ) ; + Size = MAP_APPFONT ( 64 , 8 ) ; + Text [ en-US ] = "Te~xt direction" ; + }; + ListBox LB_LEGEND_TEXTDIR + { + Pos = MAP_APPFONT ( 78 , 14 + RESOURCE_LEGENDPOSITION_HEIGHT + 17 ) ; + Size = MAP_APPFONT ( 170 , 100 ) ; + Border = TRUE; + TabStop = TRUE; + DropDown = TRUE; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_Location.cxx b/chart2/source/controller/dialogs/tp_Location.cxx new file mode 100644 index 000000000000..cce4cd520b12 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Location.cxx @@ -0,0 +1,74 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Location.cxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_Location.hxx" +#include "tp_Location.hrc" +#include "ResId.hxx" +#include "Strings.hrc" +#include "NoWarningThisInCTOR.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +#ifdef LOCATION_PAGE + +LocationTabPage::LocationTabPage( svt::OWizardMachine* pParent + , const uno::Reference< XChartDocument >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext ) + : OWizardPage( pParent, SchResId(TP_LOCATION) ) + , m_aFL_Table( this, SchResId( FL_TABLE ) ) + , m_aFT_Table( this, SchResId( FT_TABLE ) ) + , m_aLB_Table( this, SchResId( LB_TABLE ) ) + , m_xChartModel( xChartModel ) + , m_xCC( xContext ) +{ + FreeResource(); + this->SetText( String( SchResId( STR_PAGE_CHART_LOCATION ) ) ); +} + +LocationTabPage::~LocationTabPage() +{ +} + +bool LocationTabPage::canAdvance() const +{ + return false; +} +#endif +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Location.hrc b/chart2/source/controller/dialogs/tp_Location.hrc new file mode 100644 index 000000000000..995bcc6f9db7 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Location.hrc @@ -0,0 +1,35 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Location.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FL_TABLE 1 +#define FT_TABLE 1 +#define LB_TABLE 1 diff --git a/chart2/source/controller/dialogs/tp_Location.hxx b/chart2/source/controller/dialogs/tp_Location.hxx new file mode 100644 index 000000000000..8b472d2a6c92 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Location.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Location.hxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_TP_LOCATION_HXX +#define _CHART2_TP_LOCATION_HXX + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <svtools/wizardmachine.hxx> + +// header for class FixedText, FixedLine +#include <vcl/fixed.hxx> +// header for class ListBox +#include <vcl/lstbox.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +#ifdef LOCATION_PAGE +class LocationTabPage : public svt::OWizardPage +{ +public: + LocationTabPage( svt::OWizardMachine* pParent + , const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~LocationTabPage(); + + virtual bool canAdvance() const; + +protected: + FixedLine m_aFL_Table; + FixedText m_aFT_Table; + ListBox m_aLB_Table; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; +}; +#endif + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/tp_Location.src b/chart2/source/controller/dialogs/tp_Location.src new file mode 100644 index 000000000000..586040b11f6e --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Location.src @@ -0,0 +1,76 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Location.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "tp_Location.hrc" +#include "dlg_CreationWizard.hrc" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +#define MASKCOLOR MaskColor = Color { Red = 0xC000 ; Green = 0xC000 ; Blue = 0xC000 ; } +#define WIZ_POSX1 6 +#define WIZ_POSY1 6 +#define WIZ_POSX2 (6+4) +#define WIZ_POSY2 (WIZ_POSY1+RSC_CD_FIXEDTEXT_HEIGHT+4) +#define TEXT_WIDTH 50 +#define WIZ_POSX3 (WIZ_POSX2+TEXT_WIDTH+6) +#define WIZ_FIXEDLINE_WIDTH (CHART_WIZARD_PAGEWIDTH-WIZ_POSX1-6) +#define WIZ_LISTBOX_WIDTH (CHART_WIZARD_PAGEWIDTH-WIZ_POSX2-TEXT_WIDTH-6-6) + + +TabPage TP_LOCATION +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( CHART_WIZARD_PAGEWIDTH , CHART_WIZARD_PAGEHEIGHT ) ; + + FixedLine FL_TABLE + { + Pos = MAP_APPFONT ( WIZ_POSX1 , WIZ_POSY1 ) ; + Size = MAP_APPFONT ( WIZ_FIXEDLINE_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + + Text [ en-US ] = "Place chart" ; + }; + FixedText FT_TABLE + { + Pos = MAP_APPFONT ( WIZ_POSX2 , WIZ_POSY2 ) ; + Size = MAP_APPFONT ( TEXT_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + + Text [ en-US ] = "~Insert in sheet" ; + }; + ListBox LB_TABLE + { + Border = TRUE ; + DropDown = TRUE ; + Pos = MAP_APPFONT ( WIZ_POSX3 , WIZ_POSY2 ) ; + Size = MAP_APPFONT ( WIZ_LISTBOX_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.cxx b/chart2/source/controller/dialogs/tp_PointGeometry.cxx new file mode 100644 index 000000000000..7e2fa80dd556 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PointGeometry.cxx @@ -0,0 +1,107 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PointGeometry.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_PointGeometry.hxx" +#include "TabPages.hrc" +#include "res_BarGeometry.hxx" +#include "ResId.hxx" + +#include "chartview/ChartSfxItemIds.hxx" + +// header for SfxInt32Item +#include <svtools/intitem.hxx> +// header for class Svx3DHorizontalSegmentsItem +#include <svx/svx3ditems.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchLayoutTabPage::SchLayoutTabPage(Window* pWindow,const SfxItemSet& rInAttrs) + : SfxTabPage(pWindow, SchResId(TP_LAYOUT), rInAttrs) + , m_pGeometryResources(0) +{ + Size aPageSize( this->GetSizePixel() ); + Point aPos( this->LogicToPixel( Point(6,6), MapMode(MAP_APPFONT) ) ); + m_pGeometryResources = new BarGeometryResources( this ); + m_pGeometryResources->SetPosPixel( aPos ); +} + +SchLayoutTabPage::~SchLayoutTabPage() +{ + if( m_pGeometryResources ) + delete m_pGeometryResources; +} + +SfxTabPage* SchLayoutTabPage::Create(Window* pWindow, + const SfxItemSet& rOutAttrs) +{ + return new SchLayoutTabPage(pWindow, rOutAttrs); +} + +BOOL SchLayoutTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + + if(m_pGeometryResources && m_pGeometryResources->GetSelectEntryCount()) + { + long nShape=CHART_SHAPE3D_SQUARE; + long nSegs=32; + + nShape = m_pGeometryResources->GetSelectEntryPos(); + if(nShape==CHART_SHAPE3D_PYRAMID) + nSegs=4; + + rOutAttrs.Put(SfxInt32Item(SCHATTR_STYLE_SHAPE,nShape)); + rOutAttrs.Put(Svx3DHorizontalSegmentsItem(nSegs)); + } + return TRUE; +} + +void SchLayoutTabPage::Reset(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem *pPoolItem = NULL; + + if (rInAttrs.GetItemState(SCHATTR_STYLE_SHAPE,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); + if(m_pGeometryResources) + { + m_pGeometryResources->SelectEntryPos(static_cast<USHORT>(nVal)); + m_pGeometryResources->Show( true ); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.hxx b/chart2/source/controller/dialogs/tp_PointGeometry.hxx new file mode 100644 index 000000000000..2cb30427ba44 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PointGeometry.hxx @@ -0,0 +1,61 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PointGeometry.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_POINTGEOMETRY_HXX +#define _CHART2_TP_POINTGEOMETRY_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class BarGeometryResources; +class SchLayoutTabPage : public SfxTabPage +{ +public: + SchLayoutTabPage(Window* pParent, const SfxItemSet& rInAttrs); + virtual ~SchLayoutTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual void Reset(const SfxItemSet& rInAttrs); + +private: + BarGeometryResources* m_pGeometryResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/tp_PointGeometry.src b/chart2/source/controller/dialogs/tp_PointGeometry.src new file mode 100644 index 000000000000..ae08189b1f7d --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PointGeometry.src @@ -0,0 +1,39 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PointGeometry.src,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "ResourceIds.hrc" +#include "TabPages.hrc" + +TabPage TP_LAYOUT +{ + Hide = TRUE ; +// HelpID = HID_LAYOUT ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; +}; diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.cxx b/chart2/source/controller/dialogs/tp_PolarOptions.cxx new file mode 100644 index 000000000000..38d36d032921 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PolarOptions.cxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PolarOptions.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "precompiled_chart2.hxx" +#include "tp_PolarOptions.hxx" +#include "tp_PolarOptions.hrc" +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" + +#include <svtools/eitem.hxx> +#include <svtools/intitem.hxx> +#include <svtools/controldims.hrc> + +//............................................................................. +namespace chart +{ +//............................................................................. + +PolarOptionsTabPage::PolarOptionsTabPage( Window* pWindow,const SfxItemSet& rInAttrs ) : + SfxTabPage( pWindow, SchResId(TP_POLAROPTIONS), rInAttrs ), + m_aCB_Clockwise( this, SchResId( CB_CLOCKWISE ) ), + m_aFL_StartingAngle( this, SchResId( FL_STARTING_ANGLE ) ), + m_aAngleDial( this, SchResId( CT_ANGLE_DIAL ) ), + m_aFT_Degrees( this, SchResId( FT_ROTATION_DEGREES ) ), + m_aNF_StartingAngle( this, SchResId( NF_STARTING_ANGLE ) ), + m_aFL_PlotOptions( this, SchResId( FL_PLOT_OPTIONS_POLAR ) ), + m_aCB_IncludeHiddenCells( this, SchResId( CB_INCLUDE_HIDDEN_CELLS_POLAR ) ) +{ + FreeResource(); + + m_aAngleDial.SetLinkedField( &m_aNF_StartingAngle ); +} + +PolarOptionsTabPage::~PolarOptionsTabPage() +{ +} + +SfxTabPage* PolarOptionsTabPage::Create( Window* pWindow,const SfxItemSet& rOutAttrs ) +{ + return new PolarOptionsTabPage( pWindow, rOutAttrs ); +} + +BOOL PolarOptionsTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + if( m_aAngleDial.IsVisible() ) + { + rOutAttrs.Put(SfxInt32Item(SCHATTR_STARTING_ANGLE, + static_cast< sal_Int32 >(m_aAngleDial.GetRotation()/100))); + } + + if( m_aCB_Clockwise.IsVisible() ) + rOutAttrs.Put(SfxBoolItem(SCHATTR_CLOCKWISE,m_aCB_Clockwise.IsChecked())); + + if (m_aCB_IncludeHiddenCells.IsVisible()) + rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCB_IncludeHiddenCells.IsChecked())); + + return TRUE; +} + +void PolarOptionsTabPage::Reset(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem *pPoolItem = NULL; + + long nTmp; + if (rInAttrs.GetItemState(SCHATTR_STARTING_ANGLE, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); + + m_aAngleDial.SetRotation( nTmp*100 ); + } + else + { + m_aFL_StartingAngle.Show(FALSE); + m_aAngleDial.Show(FALSE); + m_aNF_StartingAngle.Show(FALSE); + m_aFT_Degrees.Show(FALSE); + } + if (rInAttrs.GetItemState(SCHATTR_CLOCKWISE, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + BOOL bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + m_aCB_Clockwise.Check(bCheck); + } + else + { + m_aCB_Clockwise.Show(FALSE); + } + if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + m_aCB_IncludeHiddenCells.Check(bVal); + } + else + { + m_aCB_IncludeHiddenCells.Show(FALSE); + m_aFL_PlotOptions.Show(FALSE); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.hrc b/chart2/source/controller/dialogs/tp_PolarOptions.hrc new file mode 100644 index 000000000000..680c9d126211 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PolarOptions.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PolarOptions.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define CB_CLOCKWISE 1 +#define CB_INCLUDE_HIDDEN_CELLS_POLAR 2 + +#define FL_STARTING_ANGLE 1 +#define FL_PLOT_OPTIONS_POLAR 2 + +#define CT_ANGLE_DIAL 1 + +#define NF_STARTING_ANGLE 1 + +#define FT_ROTATION_DEGREES 1 diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.hxx b/chart2/source/controller/dialogs/tp_PolarOptions.hxx new file mode 100644 index 000000000000..02a5ec5ba25b --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PolarOptions.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PolarOptions.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_POLAROPTIONS_HXX +#define _CHART2_TP_POLAROPTIONS_HXX + +#include <sfx2/tabdlg.hxx> +#include <vcl/fixed.hxx> +#include <vcl/button.hxx> +#include <vcl/field.hxx> +#include <svx/dialcontrol.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class PolarOptionsTabPage : public SfxTabPage +{ + +public: + PolarOptionsTabPage(Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~PolarOptionsTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual void Reset(const SfxItemSet& rInAttrs); + +private: + CheckBox m_aCB_Clockwise; + FixedLine m_aFL_StartingAngle; + svx::DialControl m_aAngleDial; + FixedText m_aFT_Degrees; + NumericField m_aNF_StartingAngle; + + FixedLine m_aFL_PlotOptions; + CheckBox m_aCB_IncludeHiddenCells; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_PolarOptions.src b/chart2/source/controller/dialogs/tp_PolarOptions.src new file mode 100644 index 000000000000..273c5f59dd5d --- /dev/null +++ b/chart2/source/controller/dialogs/tp_PolarOptions.src @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_PolarOptions.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "tp_PolarOptions.hrc" +#include "HelpIds.hrc" + +TabPage TP_POLAROPTIONS +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + CheckBox CB_CLOCKWISE + { + Pos = MAP_APPFONT ( 12 , 8 ); + Size = MAP_APPFONT ( 248 , 10 ); + TabStop = TRUE; + Text [ en-US ] = "~Clockwise direction"; + }; + FixedLine FL_STARTING_ANGLE + { + Pos = MAP_APPFONT ( 6 , 21 ) ; + Size = MAP_APPFONT ( 248 , 12 ) ; + Text [ en-US ] = "Starting angle" ; + }; + Control CT_ANGLE_DIAL + { + HelpId = HID_SCH_STARTING_ANGLE_DIAL ; + Pos = MAP_APPFONT ( 12 , 38 ) ; + Size = MAP_APPFONT ( 43 , 43 ) ; + }; + FixedText FT_ROTATION_DEGREES + { + Pos = MAP_APPFONT ( 93 , 55 ) ; + Size = MAP_APPFONT ( 166 , 8 ) ; + Text [ en-US ] = "~Degrees" ; + }; + NumericField NF_STARTING_ANGLE + { + Pos = MAP_APPFONT ( 61 , 53 ) ; + Size = MAP_APPFONT ( 28 , 12 ) ; + Border = TRUE ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + Maximum = 359 ; + SpinSize = 5 ; + }; + FixedLine FL_PLOT_OPTIONS_POLAR + { + Pos = MAP_APPFONT ( 6 , 90 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Plot options"; + }; + CheckBox CB_INCLUDE_HIDDEN_CELLS_POLAR + { + Pos = MAP_APPFONT ( 12 , 104 ) ; + Size = MAP_APPFONT ( 200 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Include ~values from hidden cells"; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.cxx b/chart2/source/controller/dialogs/tp_RangeChooser.cxx new file mode 100644 index 000000000000..8ba4d61a8057 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_RangeChooser.cxx @@ -0,0 +1,417 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_RangeChooser.cxx,v $ + * $Revision: 1.5.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_RangeChooser.hxx" +#include "tp_RangeChooser.hrc" +#include "Strings.hrc" +#include "ResId.hxx" +#include "macros.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "DataSourceHelper.hxx" +#include "DiagramHelper.hxx" +#include "ChartTypeTemplateProvider.hxx" +#include "DialogModel.hxx" +#include "RangeSelectionHelper.hxx" +#include <com/sun/star/awt/XTopWindow.hpp> +#include <com/sun/star/embed/EmbedStates.hpp> +#include <com/sun/star/embed/XComponentSupplier.hpp> + +namespace +{ +void lcl_ShowChooserButton( + ::chart::RangeSelectionButton & rChooserButton, + Edit & rEditField, + BOOL bShow ) +{ + if( rChooserButton.IsVisible() != bShow ) + { + rChooserButton.Show( bShow ); + sal_Int32 nWidhtDiff = 10 + 2; + if( bShow ) + nWidhtDiff = -nWidhtDiff; + Size aSize = rChooserButton.PixelToLogic( rEditField.GetSizePixel(), MAP_APPFONT ); + aSize.setWidth( aSize.getWidth() + nWidhtDiff ); + rEditField.SetSizePixel( rChooserButton.LogicToPixel( aSize, MAP_APPFONT )); + } +} +void lcl_enableRangeChoosing( bool bEnable, Dialog * pDialog ) +{ + if( pDialog ) + { + pDialog->Show( bEnable ? FALSE : TRUE ); + pDialog->SetModalInputMode( bEnable ? FALSE : TRUE ); + } +} +void lcl_shiftControlY( Control & rControl, long nYOffset ) +{ + Point aPos( rControl.GetPosPixel()); + aPos.setY( aPos.getY() + nYOffset ); + rControl.SetPosPixel( aPos ); +} +} // anonymous namespace + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + + +RangeChooserTabPage::RangeChooserTabPage( Window* pParent + , DialogModel & rDialogModel + , ChartTypeTemplateProvider* pTemplateProvider + , Dialog * pParentDialog + , bool bHideDescription /* = false */ ) + + : OWizardPage( pParent, SchResId(TP_RANGECHOOSER) ) + + , m_aFT_Caption( this, SchResId( FT_CAPTION_FOR_WIZARD ) ) + , m_aFT_Range( this, SchResId( FT_RANGE ) ) + , m_aED_Range( this, SchResId( ED_RANGE ) ) + , m_aIB_Range( this, SchResId( IB_RANGE ) ) + , m_aRB_Rows( this, SchResId( RB_DATAROWS ) ) + , m_aRB_Columns( this, SchResId( RB_DATACOLS ) ) + , m_aCB_FirstRowAsLabel( this, SchResId( CB_FIRST_ROW_ASLABELS ) ) + , m_aCB_FirstColumnAsLabel( this, SchResId( CB_FIRST_COLUMN_ASLABELS ) ) + , m_nChangingControlCalls(0) + , m_bIsDirty(false) + , m_xDataProvider( 0 ) + , m_aLastValidRangeString() + , m_xCurrentChartTypeTemplate(0) + , m_pTemplateProvider(pTemplateProvider) + , m_rDialogModel( rDialogModel ) + , m_pParentDialog( pParentDialog ) + , m_pTabPageNotifiable( dynamic_cast< TabPageNotifiable * >( pParentDialog )) +{ + FreeResource(); + + if( bHideDescription ) + { + // note: the offset should be a negative value for shifting upwards, the + // 4 is for the offset difference between a wizard page and a tab-page + long nYOffset = - ( m_aFT_Range.GetPosPixel().getY() - m_aFT_Caption.GetPosPixel().getY() + 4 ); + m_aFT_Caption.Hide(); + + // shift all controls by the offset space saved by hiding the caption + lcl_shiftControlY( m_aFT_Range, nYOffset ); + lcl_shiftControlY( m_aED_Range, nYOffset ); + lcl_shiftControlY( m_aIB_Range, nYOffset ); + lcl_shiftControlY( m_aRB_Rows, nYOffset ); + lcl_shiftControlY( m_aRB_Columns, nYOffset ); + lcl_shiftControlY( m_aCB_FirstRowAsLabel, nYOffset ); + lcl_shiftControlY( m_aCB_FirstColumnAsLabel, nYOffset ); + } + else + { + // make font of caption bold + Font aFont( m_aFT_Caption.GetControlFont() ); + aFont.SetWeight( WEIGHT_BOLD ); + m_aFT_Caption.SetControlFont( aFont ); + + // no mnemonic + m_aFT_Caption.SetStyle( m_aFT_Caption.GetStyle() | WB_NOLABEL ); + } + + this->SetText( String(SchResId(STR_PAGE_DATA_RANGE)) ); + m_aIB_Range.SetQuickHelpText( String(SchResId(STR_TIP_SELECT_RANGE)) ); + + // set defaults as long as DetectArguments does not work + m_aRB_Columns.Check(); + m_aCB_FirstColumnAsLabel.Check(); + m_aCB_FirstRowAsLabel.Check(); + + // BM: Note, that the range selection is not available, if there is no view. + // This happens for charts having their own embedded spreadsheet. If you + // force to get the range selection here, this would mean when entering this + // page the calc view would be created in this case. So, I enable the + // button here, and in the worst case nothing happens when it is pressed. + // Not nice, but I see no better solution for the moment. + m_aIB_Range.SetClickHdl( LINK( this, RangeChooserTabPage, ChooseRangeHdl )); + m_aED_Range.SetKeyInputHdl( LINK( this, RangeChooserTabPage, ChooseRangeHdl )); + + // #i75179# enable setting the background to a different color + m_aED_Range.SetStyle( m_aED_Range.GetStyle() | WB_FORCECTRLBACKGROUND ); + + m_aED_Range.SetUpdateDataHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl )); + m_aED_Range.SetModifyHdl( LINK( this, RangeChooserTabPage, ControlEditedHdl )); + m_aRB_Rows.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) ); + m_aCB_FirstRowAsLabel.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) ); + m_aCB_FirstColumnAsLabel.SetToggleHdl( LINK( this, RangeChooserTabPage, ControlChangedHdl ) ); +} + +RangeChooserTabPage::~RangeChooserTabPage() +{ +} + +void RangeChooserTabPage::ActivatePage() +{ + OWizardPage::ActivatePage(); + initControlsFromModel(); +} + +void RangeChooserTabPage::initControlsFromModel() +{ + m_nChangingControlCalls++; + + if(m_pTemplateProvider) + { + m_xCurrentChartTypeTemplate = m_pTemplateProvider->getCurrentTemplate(); + } + + bool bUseColumns = ! m_aRB_Rows.IsChecked(); + bool bFirstCellAsLabel = bUseColumns ? m_aCB_FirstRowAsLabel.IsChecked() : m_aCB_FirstColumnAsLabel.IsChecked(); + bool bHasCategories = bUseColumns ? m_aCB_FirstColumnAsLabel.IsChecked() : m_aCB_FirstRowAsLabel.IsChecked(); + + bool bIsValid = m_rDialogModel.allArgumentsForRectRangeDetected(); + if( bIsValid ) + m_rDialogModel.detectArguments( + m_aLastValidRangeString, bUseColumns, bFirstCellAsLabel, bHasCategories ); + else + m_aLastValidRangeString = String::EmptyString(); + + m_aED_Range.SetText( m_aLastValidRangeString ); + + m_aRB_Rows.Check( !bUseColumns ); + m_aRB_Columns.Check( bUseColumns ); + + m_aCB_FirstRowAsLabel.Check( m_aRB_Rows.IsChecked()?bHasCategories:bFirstCellAsLabel ); + m_aCB_FirstColumnAsLabel.Check( m_aRB_Columns.IsChecked()?bHasCategories:bFirstCellAsLabel ); + + isValid(); + + m_nChangingControlCalls--; +} + +void RangeChooserTabPage::DeactivatePage() +{ + commitPage(); + svt::OWizardPage::DeactivatePage(); +} + +void RangeChooserTabPage::commitPage() +{ + commitPage(eFinish); +} + +sal_Bool RangeChooserTabPage::commitPage( CommitPageReason /*eReason*/ ) +{ + //ranges may have been edited in the meanwhile (dirty is true in that case here) + if( isValid() ) + { + changeDialogModelAccordingToControls(); + return sal_True;//return false if this page should not be left + } + else + return sal_False; +} + +void RangeChooserTabPage::changeDialogModelAccordingToControls() +{ + if(m_nChangingControlCalls>0) + return; + + if( !m_xCurrentChartTypeTemplate.is() ) + { + if(m_pTemplateProvider) + m_xCurrentChartTypeTemplate.set( m_pTemplateProvider->getCurrentTemplate()); + if( !m_xCurrentChartTypeTemplate.is()) + { + OSL_ENSURE( false, "Need a template to change data source" ); + return; + } + } + + if( m_bIsDirty ) + { + sal_Bool bFirstCellAsLabel = ( m_aCB_FirstColumnAsLabel.IsChecked() && !m_aRB_Columns.IsChecked() ) + || ( m_aCB_FirstRowAsLabel.IsChecked() && !m_aRB_Rows.IsChecked() ); + sal_Bool bHasCategories = ( m_aCB_FirstColumnAsLabel.IsChecked() && m_aRB_Columns.IsChecked() ) + || ( m_aCB_FirstRowAsLabel.IsChecked() && m_aRB_Rows.IsChecked() ); + + Sequence< beans::PropertyValue > aArguments( + DataSourceHelper::createArguments( + m_aRB_Columns.IsChecked(), bFirstCellAsLabel, bHasCategories ) ); + + // only if range is valid + if( m_aLastValidRangeString.equals( m_aED_Range.GetText())) + { + m_rDialogModel.setTemplate( m_xCurrentChartTypeTemplate ); + aArguments.realloc( aArguments.getLength() + 1 ); + aArguments[aArguments.getLength() - 1] = + beans::PropertyValue( C2U("CellRangeRepresentation"), -1, + uno::makeAny( m_aLastValidRangeString ), + beans::PropertyState_DIRECT_VALUE ); + m_rDialogModel.setData( aArguments ); + m_bIsDirty = false; + } + + //@todo warn user that the selected range is not valid + //@todo better: disable OK-Button if range is invalid + } +} + +bool RangeChooserTabPage::isValid() +{ + ::rtl::OUString aRange( m_aED_Range.GetText()); + sal_Bool bFirstCellAsLabel = ( m_aCB_FirstColumnAsLabel.IsChecked() && !m_aRB_Columns.IsChecked() ) + || ( m_aCB_FirstRowAsLabel.IsChecked() && !m_aRB_Rows.IsChecked() ); + sal_Bool bHasCategories = ( m_aCB_FirstColumnAsLabel.IsChecked() && m_aRB_Columns.IsChecked() ) + || ( m_aCB_FirstRowAsLabel.IsChecked() && m_aRB_Rows.IsChecked() ); + bool bIsValid = ( aRange.getLength() == 0 ) || + m_rDialogModel.getRangeSelectionHelper()->verifyArguments( + DataSourceHelper::createArguments( + aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(), bFirstCellAsLabel, bHasCategories )); + + if( bIsValid ) + { + m_aED_Range.SetControlForeground(); + m_aED_Range.SetControlBackground(); + if( m_pTabPageNotifiable ) + m_pTabPageNotifiable->setValidPage( this ); + m_aLastValidRangeString = aRange; + } + else + { + m_aED_Range.SetControlBackground( RANGE_SELECTION_INVALID_RANGE_BACKGROUND_COLOR ); + m_aED_Range.SetControlForeground( RANGE_SELECTION_INVALID_RANGE_FOREGROUND_COLOR ); + if( m_pTabPageNotifiable ) + m_pTabPageNotifiable->setInvalidPage( this ); + } + + // enable/disable controls + // #i79531# if the range is valid but an action of one of these buttons + // would render it invalid, the button should be disabled + if( bIsValid ) + { + bool bDataInColumns = m_aRB_Columns.IsChecked(); + bool bIsSwappedRangeValid = m_rDialogModel.getRangeSelectionHelper()->verifyArguments( + DataSourceHelper::createArguments( + aRange, Sequence< sal_Int32 >(), ! bDataInColumns, bHasCategories, bFirstCellAsLabel )); + m_aRB_Rows.Enable( bIsSwappedRangeValid ); + m_aRB_Columns.Enable( bIsSwappedRangeValid ); + + m_aCB_FirstRowAsLabel.Enable( + m_rDialogModel.getRangeSelectionHelper()->verifyArguments( + DataSourceHelper::createArguments( + aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(), + bDataInColumns ? ! bFirstCellAsLabel : bFirstCellAsLabel, + bDataInColumns ? bHasCategories : ! bHasCategories ))); + m_aCB_FirstColumnAsLabel.Enable( + m_rDialogModel.getRangeSelectionHelper()->verifyArguments( + DataSourceHelper::createArguments( + aRange, Sequence< sal_Int32 >(), m_aRB_Columns.IsChecked(), + bDataInColumns ? bFirstCellAsLabel : ! bFirstCellAsLabel, + bDataInColumns ? ! bHasCategories : bHasCategories ))); + } + else + { + m_aRB_Rows.Enable( bIsValid ); + m_aRB_Columns.Enable( bIsValid ); + m_aCB_FirstRowAsLabel.Enable( bIsValid ); + m_aCB_FirstColumnAsLabel.Enable( bIsValid ); +} + BOOL bShowIB = m_rDialogModel.getRangeSelectionHelper()->hasRangeSelection(); + lcl_ShowChooserButton( m_aIB_Range, m_aED_Range, bShowIB ); + + return bIsValid; +} + +IMPL_LINK( RangeChooserTabPage, ControlEditedHdl, void*, EMPTYARG ) +{ + setDirty(); + isValid(); + return 0; +} + +IMPL_LINK( RangeChooserTabPage, ControlChangedHdl, void*, EMPTYARG ) +{ + setDirty(); + if( isValid()) + changeDialogModelAccordingToControls(); + return 0; +} + +IMPL_LINK( RangeChooserTabPage, ChooseRangeHdl, void *, EMPTYARG ) +{ + rtl::OUString aRange = m_aED_Range.GetText(); + // using assignment for broken gcc 3.3 + rtl::OUString aTitle = ::rtl::OUString( String( SchResId( STR_PAGE_DATA_RANGE ) )); + + lcl_enableRangeChoosing( true, m_pParentDialog ); + m_rDialogModel.getRangeSelectionHelper()->chooseRange( aRange, aTitle, *this ); + + return 0; +} + + +void RangeChooserTabPage::listeningFinished( const ::rtl::OUString & rNewRange ) +{ + //user has selected a new range + + rtl::OUString aRange( rNewRange ); + + m_rDialogModel.startControllerLockTimer(); + + // stop listening + m_rDialogModel.getRangeSelectionHelper()->stopRangeListening(); + + //update dialog state + ToTop(); + GrabFocus(); + m_aED_Range.SetText( String( aRange ) ); + m_aED_Range.GrabFocus(); + + setDirty(); + if( isValid()) + changeDialogModelAccordingToControls(); + + lcl_enableRangeChoosing( false, m_pParentDialog ); +} +void RangeChooserTabPage::disposingRangeSelection() +{ + m_rDialogModel.getRangeSelectionHelper()->stopRangeListening( false ); +} + +void RangeChooserTabPage::setDirty() +{ + if( m_nChangingControlCalls == 0 ) + m_bIsDirty = true; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.hrc b/chart2/source/controller/dialogs/tp_RangeChooser.hrc new file mode 100644 index 000000000000..7e39e7041013 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_RangeChooser.hrc @@ -0,0 +1,43 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_RangeChooser.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define FT_CAPTION_FOR_WIZARD 1 +#define FT_RANGE 2 + +#define RB_DATAROWS 1 +#define RB_DATACOLS 2 + +#define ED_RANGE 1 +#define IB_RANGE 1 + +#define CB_FIRST_ROW_ASLABELS 1 +#define CB_FIRST_COLUMN_ASLABELS 2 diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.hxx b/chart2/source/controller/dialogs/tp_RangeChooser.hxx new file mode 100644 index 000000000000..bb508da8d9a1 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_RangeChooser.hxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_RangeChooser.hxx,v $ + * $Revision: 1.5.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_TP_RANGECHOOSER_HXX +#define _CHART2_TP_RANGECHOOSER_HXX + +#include "RangeSelectionListener.hxx" +#include "RangeSelectionButton.hxx" +#include "TabPageNotifiable.hxx" +#include "RangeEdit.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/data/XDataProvider.hpp> +#include <com/sun/star/chart2/XChartTypeTemplate.hpp> +#include <svtools/wizardmachine.hxx> +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +#include <com/sun/star/sheet/XRangeSelection.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class ChartTypeTemplateProvider; +class DialogModel; + +class RangeChooserTabPage : public svt::OWizardPage, public RangeSelectionListenerParent +{ +public: + + RangeChooserTabPage( Window* pParent + , DialogModel & rDialogModel + , ChartTypeTemplateProvider* pTemplateProvider + , Dialog * pParentDialog + , bool bHideDescription = false ); +virtual ~RangeChooserTabPage(); + + //RangeSelectionListenerParent + virtual void listeningFinished( const ::rtl::OUString & rNewRange ); + virtual void disposingRangeSelection(); + + void commitPage(); + +protected: //methods + + //OWizardPage + virtual void ActivatePage(); + virtual sal_Bool commitPage( CommitPageReason eReason ); + + //TabPage + virtual void DeactivatePage(); + + void initControlsFromModel(); + void changeDialogModelAccordingToControls(); + bool isValid(); + void setDirty(); + + DECL_LINK( ChooseRangeHdl, void* ); + DECL_LINK( ControlChangedHdl, void* ); + DECL_LINK( ControlEditedHdl, void* ); + +protected: //member + + FixedText m_aFT_Caption; + FixedText m_aFT_Range; + RangeEdit m_aED_Range; + RangeSelectionButton m_aIB_Range; + + RadioButton m_aRB_Rows; + RadioButton m_aRB_Columns; + + CheckBox m_aCB_FirstRowAsLabel; + CheckBox m_aCB_FirstColumnAsLabel; + + sal_Int32 m_nChangingControlCalls; + bool m_bIsDirty; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::data::XDataProvider > m_xDataProvider; + + rtl::OUString m_aLastValidRangeString; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartTypeTemplate > m_xCurrentChartTypeTemplate; + ChartTypeTemplateProvider* m_pTemplateProvider; + + DialogModel & m_rDialogModel; + Dialog * m_pParentDialog; + TabPageNotifiable * m_pTabPageNotifiable; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/tp_RangeChooser.src b/chart2/source/controller/dialogs/tp_RangeChooser.src new file mode 100644 index 000000000000..7c88184f4559 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_RangeChooser.src @@ -0,0 +1,97 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_RangeChooser.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "tp_RangeChooser.hrc" +#include "SchSlotIds.hxx" +#include "dlg_CreationWizard.hrc" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +#define MASKCOLOR MaskColor = Color { Red = 0xC000 ; Green = 0xC000 ; Blue = 0xC000 ; } + +TabPage TP_RANGECHOOSER +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 248, 140 ) ; + + FixedText FT_CAPTION_FOR_WIZARD + { + Pos = MAP_APPFONT ( 5 , 8 ) ; + Size = MAP_APPFONT ( 238 , 10 ) ; + Text [ en-US ] = "Choose a data range" ; + }; + FixedText FT_RANGE + { + Pos = MAP_APPFONT ( 6 , 22 ) ; + Size = MAP_APPFONT ( 236 , 8 ) ; + Text [ en-US ] = "~Data range" ; + }; + Edit ED_RANGE + { + Border = TRUE ; + Pos = MAP_APPFONT ( 6 , 32 ) ; + Size = MAP_APPFONT ( 220 , 12 ) ; + }; + ImageButton IB_RANGE + { + Pos = MAP_APPFONT ( 228 , 31 ) ; + Size = MAP_APPFONT ( 14 , 14 ) ; + TabStop = FALSE ; + }; + RadioButton RB_DATAROWS + { + Pos = MAP_APPFONT ( 6 , 52 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Data series in ~rows" ; + }; + RadioButton RB_DATACOLS + { + Pos = MAP_APPFONT ( 6 , 66 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Data series in ~columns" ; + }; + CheckBox CB_FIRST_ROW_ASLABELS + { + Pos = MAP_APPFONT ( 6 , 84 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + Text [ en-US ] = "~First row as label" ; + }; + CheckBox CB_FIRST_COLUMN_ASLABELS + { + Pos = MAP_APPFONT ( 6 , 98 ) ; + Size = MAP_APPFONT ( 236 , 10 ) ; + Text [ en-US ] = "F~irst column as label" ; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_Scale.cxx b/chart2/source/controller/dialogs/tp_Scale.cxx new file mode 100644 index 000000000000..a2c3694a8469 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.cxx @@ -0,0 +1,521 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Scale.cxx,v $ + * $Revision: 1.13 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_Scale.hxx" + +#include "ResId.hxx" +#include "TabPages.hrc" +#include "Strings.hrc" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "AxisHelper.hxx" + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#include <rtl/math.hxx> +// header for class SvxDoubleItem +#include <svx/chrtitem.hxx> +// header for class SfxBoolItem +#include <svtools/eitem.hxx> +// header for SfxInt32Item +#include <svtools/intitem.hxx> + +// header for class WarningBox +#include <vcl/msgbox.hxx> + +// header for class SvNumberformat +#ifndef _ZFORMAT_HXX +#ifndef _ZFORLIST_DECLARE_TABLE +#define _ZFORLIST_DECLARE_TABLE +#endif +#include <svtools/zformat.hxx> +#endif + +#include <svtools/controldims.hrc> + +#include <com/sun/star/chart2/AxisType.hpp> + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +namespace +{ + +void lcl_shiftControls( Control& rEdit, Control& rAuto, long nNewXPos ) +{ + Point aPos( rEdit.GetPosPixel() ); + long nShift = nNewXPos - aPos.X(); + aPos.X() = nNewXPos; + rEdit.SetPosPixel(aPos); + + aPos = rAuto.GetPosPixel(); + aPos.X() += nShift; + rAuto.SetPosPixel(aPos); +} + +void lcl_placeControlsAtY( Control& rTop, Control& rBottom, long nNewYPos ) +{ + Point aPos( rTop.GetPosPixel() ); + long nShift = nNewYPos - aPos.Y(); + aPos.Y() = nNewYPos; + rTop.SetPosPixel(aPos); + + aPos = rBottom.GetPosPixel(); + aPos.Y() += nShift; + rBottom.SetPosPixel(aPos); +} + +} + +ScaleTabPage::ScaleTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : + SfxTabPage(pWindow, SchResId(TP_SCALE), rInAttrs), + + aFlScale(this, SchResId(FL_SCALE)), + aTxtMin (this, SchResId (TXT_MIN)), + aFmtFldMin(this, SchResId(EDT_MIN)), + aCbxAutoMin(this, SchResId(CBX_AUTO_MIN)), + aTxtMax(this, SchResId (TXT_MAX)), + aFmtFldMax(this, SchResId(EDT_MAX)), + aCbxAutoMax(this, SchResId(CBX_AUTO_MAX)), + aTxtMain (this, SchResId (TXT_STEP_MAIN)), + aFmtFldStepMain(this, SchResId(EDT_STEP_MAIN)), + aCbxAutoStepMain(this, SchResId(CBX_AUTO_STEP_MAIN)), + aTxtHelp (this, SchResId (TXT_STEP_HELP)), + aMtStepHelp (this, SchResId (MT_STEPHELP)), + aCbxAutoStepHelp(this, SchResId(CBX_AUTO_STEP_HELP)), + + aTxtOrigin (this, SchResId (TXT_ORIGIN)), + aFmtFldOrigin(this, SchResId(EDT_ORIGIN)), + aCbxAutoOrigin(this, SchResId(CBX_AUTO_ORIGIN)), + + aCbxLogarithm(this, SchResId(CBX_LOGARITHM)), + aCbxReverse(this, SchResId(CBX_REVERSE)), + + fMin(0.0), + fMax(0.0), + fStepMain(0.0), + nStepHelp(0), + fOrigin(0.0), + nAxisType(chart2::AxisType::REALNUMBER), + pNumFormatter(NULL), + m_bShowAxisOrigin(false) +{ + FreeResource(); + SetExchangeSupport(); + + aCbxAutoMin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + aCbxAutoMax.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + aCbxAutoStepMain.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + aCbxAutoStepHelp.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); + aCbxAutoOrigin.SetClickHdl(LINK(this, ScaleTabPage, EnableValueHdl)); +} + +void ScaleTabPage::StateChanged( StateChangedType nType ) +{ + TabPage::StateChanged( nType ); + + if( nType == STATE_CHANGE_INITSHOW ) + AdjustControlPositions(); +} + +void ScaleTabPage::AdjustControlPositions() +{ + //optimize position of the controls + long nLabelWidth = ::std::max( aTxtMin.CalcMinimumSize().Width(), aTxtMax.CalcMinimumSize().Width() ); + nLabelWidth = ::std::max( aTxtMain.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( aTxtHelp.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth = ::std::max( aTxtOrigin.CalcMinimumSize().Width(), nLabelWidth ); + nLabelWidth+=1; + + long nLabelDistance = aTxtMin.LogicToPixel( Size(RSC_SP_CTRL_DESC_X, 0), MapMode(MAP_APPFONT) ).Width(); + long nNewXPos = aTxtMin.GetPosPixel().X() + nLabelWidth + nLabelDistance; + + //ensure that the auto checkboxes are wide enough and have correct size for calculation + aCbxAutoMin.SetSizePixel( aCbxAutoMin.CalcMinimumSize() ); + aCbxAutoMax.SetSizePixel( aCbxAutoMax.CalcMinimumSize() ); + aCbxAutoStepMain.SetSizePixel( aCbxAutoStepMain.CalcMinimumSize() ); + aCbxAutoStepHelp.SetSizePixel( aCbxAutoStepHelp.CalcMinimumSize() ); + aCbxAutoOrigin.SetSizePixel( aCbxAutoOrigin.CalcMinimumSize() ); + + //ensure new pos is ok + long nWidthOfOtherControls = aCbxAutoMin.GetPosPixel().X() + aCbxAutoMin.GetSizePixel().Width() - aFmtFldMin.GetPosPixel().X(); + long nDialogWidth = GetSizePixel().Width(); + + long nLeftSpace = nDialogWidth - nNewXPos - nWidthOfOtherControls; + if(nLeftSpace>=0) + { + Size aSize( aTxtMin.GetSizePixel() ); + aSize.Width() = nLabelWidth; + aTxtMin.SetSizePixel(aSize); + aTxtMax.SetSizePixel(aSize); + aTxtMain.SetSizePixel(aSize); + aTxtHelp.SetSizePixel(aSize); + aTxtOrigin.SetSizePixel(aSize); + + lcl_shiftControls( aFmtFldMin, aCbxAutoMin, nNewXPos ); + lcl_shiftControls( aFmtFldMax, aCbxAutoMax, nNewXPos ); + lcl_shiftControls( aFmtFldStepMain, aCbxAutoStepMain, nNewXPos ); + lcl_shiftControls( aMtStepHelp, aCbxAutoStepHelp, nNewXPos ); + lcl_shiftControls( aFmtFldOrigin, aCbxAutoOrigin, nNewXPos ); + } +} + +void ScaleTabPage::EnableControls() +{ + bool bEnableForValueOrPercentAxis = chart2::AxisType::REALNUMBER == nAxisType || chart2::AxisType::PERCENT == nAxisType; + aFlScale.Enable( bEnableForValueOrPercentAxis ); + aTxtMin.Enable( bEnableForValueOrPercentAxis ); + aFmtFldMin.Enable( bEnableForValueOrPercentAxis ); + aCbxAutoMin.Enable( bEnableForValueOrPercentAxis ); + aTxtMax.Enable( bEnableForValueOrPercentAxis ); + aFmtFldMax.Enable( bEnableForValueOrPercentAxis ); + aCbxAutoMax.Enable( bEnableForValueOrPercentAxis ); + aTxtMain.Enable( bEnableForValueOrPercentAxis ); + aFmtFldStepMain.Enable( bEnableForValueOrPercentAxis ); + aCbxAutoStepMain.Enable( bEnableForValueOrPercentAxis ); + aTxtHelp.Enable( bEnableForValueOrPercentAxis ); + aMtStepHelp.Enable( bEnableForValueOrPercentAxis ); + aCbxAutoStepHelp.Enable( bEnableForValueOrPercentAxis ); + aCbxLogarithm.Enable( bEnableForValueOrPercentAxis ); + + aTxtOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); + aFmtFldOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); + aCbxAutoOrigin.Show( m_bShowAxisOrigin && bEnableForValueOrPercentAxis ); + + long nNewYPos = aTxtOrigin.GetPosPixel().Y(); + if( m_bShowAxisOrigin ) + nNewYPos += ( aTxtOrigin.GetPosPixel().Y() - aTxtHelp.GetPosPixel().Y() ); + lcl_placeControlsAtY( aCbxLogarithm, aCbxReverse, nNewYPos ); +} + + + +IMPL_LINK( ScaleTabPage, EnableValueHdl, CheckBox *, pCbx ) +{ + if (pCbx == &aCbxAutoMin) + { + aFmtFldMin.Enable(!aCbxAutoMin.IsChecked()); + } + else if (pCbx == &aCbxAutoMax) + { + aFmtFldMax.Enable(!aCbxAutoMax.IsChecked()); + } + else if (pCbx == &aCbxAutoStepMain) + { + aFmtFldStepMain.Enable(!aCbxAutoStepMain.IsChecked()); + } + else if (pCbx == &aCbxAutoStepHelp) + { + aMtStepHelp.Show (); + aMtStepHelp.Enable( ! aCbxAutoStepHelp.IsChecked() ); + } + else if (pCbx == &aCbxAutoOrigin) + { + aFmtFldOrigin.Enable(!aCbxAutoOrigin.IsChecked()); + } + return 0; +} + +SfxTabPage* ScaleTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) +{ + return new ScaleTabPage(pWindow, rOutAttrs); +} + +BOOL ScaleTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); + + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MIN ,aCbxAutoMin.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_MAX ,aCbxAutoMax.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_HELP,aCbxAutoStepHelp.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_ORIGIN ,aCbxAutoOrigin.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_LOGARITHM ,aCbxLogarithm.IsChecked())); + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_REVERSE ,aCbxReverse.IsChecked())); + rOutAttrs.Put(SvxDoubleItem(fMax , SCHATTR_AXIS_MAX)); + rOutAttrs.Put(SvxDoubleItem(fMin , SCHATTR_AXIS_MIN)); + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS_STEP_HELP, nStepHelp)); + rOutAttrs.Put(SvxDoubleItem(fOrigin , SCHATTR_AXIS_ORIGIN)); + + rOutAttrs.Put(SfxBoolItem(SCHATTR_AXIS_AUTO_STEP_MAIN,aCbxAutoStepMain.IsChecked())); + rOutAttrs.Put(SvxDoubleItem(fStepMain,SCHATTR_AXIS_STEP_MAIN)); + + return TRUE; +} + +void ScaleTabPage::Reset(const SfxItemSet& rInAttrs) +{ + DBG_ASSERT( pNumFormatter, "No NumberFormatter available" ); + if(!pNumFormatter) + return; + + const SfxPoolItem *pPoolItem = NULL; + nAxisType=chart2::AxisType::REALNUMBER; + if (rInAttrs.GetItemState(SCHATTR_AXISTYPE, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + nAxisType = (int) ((const SfxInt32Item*)pPoolItem)->GetValue(); + EnableControls(); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MIN,TRUE,&pPoolItem) == SFX_ITEM_SET) + aCbxAutoMin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + + if (rInAttrs.GetItemState(SCHATTR_AXIS_MIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + fMin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); + aFmtFldMin.SetValue( fMin ); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxAutoMax.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + + if (rInAttrs.GetItemState(SCHATTR_AXIS_MAX,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + fMax = ((const SvxDoubleItem*)pPoolItem)->GetValue(); + aFmtFldMax.SetValue( fMax ); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxAutoStepMain.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + + if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_MAIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + fStepMain = ((const SvxDoubleItem*)pPoolItem)->GetValue(); + aFmtFldStepMain.SetValue( fStepMain ); + } + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxAutoStepHelp.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_LOGARITHM,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxLogarithm.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_REVERSE,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxReverse.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_STEP_HELP,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + nStepHelp = ((const SfxInt32Item*)pPoolItem)->GetValue(); + aMtStepHelp.SetValue( nStepHelp ); + } + if (rInAttrs.GetItemState(SCHATTR_AXIS_AUTO_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + aCbxAutoOrigin.Check(((const SfxBoolItem*)pPoolItem)->GetValue()); + if (rInAttrs.GetItemState(SCHATTR_AXIS_ORIGIN,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + fOrigin = ((const SvxDoubleItem*)pPoolItem)->GetValue(); + aFmtFldOrigin.SetValue( fOrigin ); + } + + EnableValueHdl(&aCbxAutoMin); + EnableValueHdl(&aCbxAutoMax); + EnableValueHdl(&aCbxAutoStepMain); + EnableValueHdl(&aCbxAutoStepHelp); + EnableValueHdl(&aCbxAutoOrigin); +} + +int ScaleTabPage::DeactivatePage(SfxItemSet* pItemSet) +{ + if( !pNumFormatter ) + { + DBG_ERROR( "No NumberFormatter available" ); + return LEAVE_PAGE; + } + + sal_uInt32 nIndex = pNumFormatter->GetStandardIndex(LANGUAGE_SYSTEM); + const SfxPoolItem *pPoolItem = NULL; + if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + nIndex = static_cast< sal_uInt32 >( static_cast< const SfxInt32Item* >(pPoolItem)->GetValue()); + else + { + OSL_ENSURE( false, "Using Standard Language" ); + } + + Edit* pEdit = NULL; + USHORT nErrStrId = 0; + double fDummy; + + fMax = aFmtFldMax.GetValue(); + fMin = aFmtFldMin.GetValue(); + fOrigin = aFmtFldOrigin.GetValue(); + fStepMain = aFmtFldStepMain.GetValue(); + nStepHelp = static_cast< sal_Int32 >( aMtStepHelp.GetValue()); + + //do some reasonable automatic correction of user input if necessary + if (!aCbxAutoMax.IsChecked() && !aCbxAutoMin.IsChecked() && + fMin >= fMax) + { + pEdit = &aFmtFldMin; + nErrStrId = STR_MIN_GREATER_MAX; + } + // check for entries in invalid ranges + if ( aCbxLogarithm.IsChecked() && + ( ( !aCbxAutoMin.IsChecked() && fMin <= 0.0 ) + || ( !aCbxAutoMax.IsChecked() && fMax <= 0.0 ) ) ) + { + pEdit = &aFmtFldMin; + nErrStrId = STR_BAD_LOGARITHM; + } + if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0) + { + pEdit = &aFmtFldStepMain; + nErrStrId = STR_STEP_GT_ZERO; + } + + //check wich entries need user action + + // check for entries that cannot be parsed for the current number format + if ( aFmtFldMin.IsModified() + && !aCbxAutoMin.IsChecked() + && !pNumFormatter->IsNumberFormat(aFmtFldMin.GetText(), nIndex, fDummy)) + { + pEdit = &aFmtFldMin; + nErrStrId = STR_INVALID_NUMBER; + } + else if (aFmtFldMax.IsModified() && !aCbxAutoMax.IsChecked() && + !pNumFormatter->IsNumberFormat(aFmtFldMax.GetText(), + nIndex, fDummy)) + { + pEdit = &aFmtFldMax; + nErrStrId = STR_INVALID_NUMBER; + } + else if (aFmtFldStepMain.IsModified() && !aCbxAutoStepMain.IsChecked() && + !pNumFormatter->IsNumberFormat(aFmtFldStepMain.GetText(), + nIndex, fDummy)) + { + pEdit = &aFmtFldStepMain; + nErrStrId = STR_STEP_GT_ZERO; + } + else if (aFmtFldOrigin.IsModified() && !aCbxAutoOrigin.IsChecked() && + !pNumFormatter->IsNumberFormat(aFmtFldOrigin.GetText(), + nIndex, fDummy)) + { + pEdit = &aFmtFldOrigin; + nErrStrId = STR_INVALID_NUMBER; + } + else if (!aCbxAutoStepMain.IsChecked() && fStepMain <= 0.0) + { + pEdit = &aFmtFldStepMain; + nErrStrId = STR_STEP_GT_ZERO; + } + + if( ShowWarning( nErrStrId, pEdit ) ) + return KEEP_PAGE; + + if( pItemSet ) + FillItemSet( *pItemSet ); + + return LEAVE_PAGE; +} + +void ScaleTabPage::SetNumFormatter( SvNumberFormatter* pFormatter ) +{ + pNumFormatter = pFormatter; + aFmtFldMax.SetFormatter( pNumFormatter ); + aFmtFldMin.SetFormatter( pNumFormatter ); + aFmtFldStepMain.SetFormatter( pNumFormatter ); + aFmtFldOrigin.SetFormatter( pNumFormatter ); + + // #101318#, #i6278# allow more decimal places than the output format. As + // the numbers shown in the edit fields are used for input, it makes more + // sense to display the values in the input format rather than the output + // format. + aFmtFldMax.UseInputStringForFormatting(); + aFmtFldMin.UseInputStringForFormatting(); + aFmtFldStepMain.UseInputStringForFormatting(); + aFmtFldOrigin.UseInputStringForFormatting(); + + SetNumFormat(); +} + +void ScaleTabPage::SetNumFormat() +{ + const SfxPoolItem *pPoolItem = NULL; + + if( GetItemSet().GetItemState( SID_ATTR_NUMBERFORMAT_VALUE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + ULONG nFmt = (ULONG)((const SfxInt32Item*)pPoolItem)->GetValue(); + + aFmtFldMax.SetFormatKey( nFmt ); + aFmtFldMin.SetFormatKey( nFmt ); + aFmtFldOrigin.SetFormatKey( nFmt ); + + if( pNumFormatter ) + { + short eType = pNumFormatter->GetType( nFmt ); + if( eType == NUMBERFORMAT_DATE ) + { + // for intervals use standard format for dates (so you can enter a number of days) + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardIndex( pFormat->GetLanguage()); + else + nFmt = pNumFormatter->GetStandardIndex(); + } + else if( eType == NUMBERFORMAT_DATETIME ) + { + // for intervals use time format for date times + const SvNumberformat* pFormat = pNumFormatter->GetEntry( nFmt ); + if( pFormat ) + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME, pFormat->GetLanguage() ); + else + nFmt = pNumFormatter->GetStandardFormat( NUMBERFORMAT_TIME ); + } + } + + aFmtFldStepMain.SetFormatKey( nFmt ); + } +} + +void ScaleTabPage::ShowAxisOrigin( bool bShowOrigin ) +{ + m_bShowAxisOrigin = bShowOrigin; + if( !AxisHelper::isAxisPositioningEnabled() ) + m_bShowAxisOrigin = true; +} + +bool ScaleTabPage::ShowWarning( USHORT nResIdMessage, Edit * pControl /* = NULL */ ) +{ + if( nResIdMessage == 0 ) + return false; + + WarningBox( this, WinBits( WB_OK ), String( SchResId( nResIdMessage ))).Execute(); + if( pControl ) + { + pControl->GrabFocus(); + pControl->SetSelection( Selection( 0, SELECTION_MAX )); + } + return true; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Scale.hxx b/chart2/source/controller/dialogs/tp_Scale.hxx new file mode 100644 index 000000000000..2b0684854c48 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.hxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Scale.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_SCALES_HXX +#define _CHART2_TP_SCALES_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> +// header for class FormattedField +#include <svtools/fmtfield.hxx> +// header for FixedText +#include <vcl/fixed.hxx> +// header for CheckBox +#include <vcl/button.hxx> +// header for MetricField +#include <vcl/field.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ScaleTabPage : public SfxTabPage +{ +public: + ScaleTabPage( Window* pParent, const SfxItemSet& rInAttrs ); + + static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); + virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual void Reset( const SfxItemSet& rInAttrs ); + using TabPage::DeactivatePage; + virtual int DeactivatePage( SfxItemSet* pItemSet = NULL ); + + void SetNumFormatter( SvNumberFormatter* pFormatter ); + void SetNumFormat(); + + void ShowAxisOrigin( bool bShowOrigin ); + + virtual void StateChanged( StateChangedType nType ); + +private: + FixedLine aFlScale; + + FixedText aTxtMin; + FormattedField aFmtFldMin; + CheckBox aCbxAutoMin; + + FixedText aTxtMax; + FormattedField aFmtFldMax; + CheckBox aCbxAutoMax; + + FixedText aTxtMain; + FormattedField aFmtFldStepMain; + CheckBox aCbxAutoStepMain; + + FixedText aTxtHelp; + MetricField aMtStepHelp; + CheckBox aCbxAutoStepHelp; + + FixedText aTxtOrigin; + FormattedField aFmtFldOrigin; + CheckBox aCbxAutoOrigin; + + CheckBox aCbxLogarithm; + CheckBox aCbxReverse; + + double fMin; + double fMax; + double fStepMain; + sal_Int32 nStepHelp; + double fOrigin; + int nAxisType; + SvNumberFormatter* pNumFormatter; + + bool m_bShowAxisOrigin; + + void AdjustControlPositions(); + void EnableControls(); + + DECL_LINK( EnableValueHdl, CheckBox* ); + + /** shows a warning window due to an invalid input. + + @param nResIdMessage + The resource identifier that represents the localized warning text. + If this is 0, no warning is shown and false is returned. + + @param pControl + If non-NULL, contains a pointer to the control in which the + errornous value was in. This method gives this control the focus + and selects its content. + + @return false, if nResIdMessage was 0, true otherwise + */ + bool ShowWarning( USHORT nResIdMessage, Edit * pControl = NULL ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/dialogs/tp_Scale.src b/chart2/source/controller/dialogs/tp_Scale.src new file mode 100644 index 000000000000..258c92b56aaa --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Scale.src @@ -0,0 +1,193 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Scale.src,v $ + * $Revision: 1.10 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" + +#define YLine1 3 +#define Y1 (YLine1+13) +#define Y2 (Y1+16) +#define Y3 (Y2+16) +#define Y4 (Y3+16) +#define Y5 (Y4+16) +#define Y6 (Y5+17) +#define Y7 (Y6+15) + +#define LABELWIDTH 88 +#define AUTOCHECKWIDTH 88 +#define EDITWIDTH 50 +#define X1 6 +#define X2 11 +#define X3 (X2+LABELWIDTH+4) +#define X4 (X3+EDITWIDTH+5) + +TabPage TP_SCALE +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + + FixedLine FL_SCALE + { + Pos = MAP_APPFONT ( X1 , YLine1 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Scale" ; + }; + FixedText TXT_MIN + { + Pos = MAP_APPFONT ( X2 , Y1 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "~Minimum:" ; + }; + SpinField EDT_MIN + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X3 , Y1-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + }; + CheckBox CBX_AUTO_MIN + { + Pos = MAP_APPFONT ( X4 , Y1-1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Automatic" ; + }; + + FixedText TXT_MAX + { + Pos = MAP_APPFONT ( X2 , Y2 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Ma~ximum:" ; + }; + SpinField EDT_MAX + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X3 , Y2-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + }; + CheckBox CBX_AUTO_MAX + { + Pos = MAP_APPFONT ( X4 , Y2-1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "A~utomatic" ; + }; + FixedText TXT_STEP_MAIN + { + Pos = MAP_APPFONT ( X2 , Y3 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Ma~jor interval:" ; + }; + SpinField EDT_STEP_MAIN + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y3-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + }; + CheckBox CBX_AUTO_STEP_MAIN + { + Pos = MAP_APPFONT ( X4 , Y3-1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Au~tomatic" ; + }; + FixedText TXT_STEP_HELP + { + Pos = MAP_APPFONT ( X2 , Y4 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Minor interval ~count:" ; + }; + MetricField MT_STEPHELP + { + Border = TRUE ; + Pos = MAP_APPFONT ( X3 , Y4-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 1 ; + Maximum = 100 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + }; + CheckBox CBX_AUTO_STEP_HELP + { + Pos = MAP_APPFONT ( X4 , Y4-1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Aut~omatic" ; + }; + + FixedText TXT_ORIGIN + { + Pos = MAP_APPFONT ( X2 , Y5 ) ; + Size = MAP_APPFONT ( LABELWIDTH , 8 ) ; + Text [ en-US ] = "Reference ~value:" ; + }; + SpinField EDT_ORIGIN + { + Border = TRUE ; + SVLook = TRUE ; + Pos = MAP_APPFONT ( X3 , Y5-2 ) ; + Size = MAP_APPFONT ( EDITWIDTH , 12 ) ; + TabStop = TRUE ; + }; + CheckBox CBX_AUTO_ORIGIN + { + Pos = MAP_APPFONT ( X4 , Y5-1 ) ; + Size = MAP_APPFONT ( AUTOCHECKWIDTH , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Automat~ic" ; + }; + + CheckBox CBX_LOGARITHM + { + Pos = MAP_APPFONT ( X2 , Y6 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Logarithmic scale" ; + }; + + CheckBox CBX_REVERSE + { + Pos = MAP_APPFONT ( X2 , Y7 ) ; + Size = MAP_APPFONT ( 244 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Reverse direction" ; + }; + +}; diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx new file mode 100644 index 000000000000..cc8ac2139639 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.cxx @@ -0,0 +1,316 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_SeriesToAxis.cxx,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_SeriesToAxis.hxx" +#include "tp_SeriesToAxis.hrc" + +#include "ResId.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "NoWarningThisInCTOR.hxx" + +// header for class SfxBoolItem +#include <svtools/eitem.hxx> +// header for SfxInt32Item +#include <svtools/intitem.hxx> +//SfxIntegerListItem +#include <svtools/ilstitem.hxx> +#include <svtools/controldims.hrc> + +#include <com/sun/star/chart/MissingValueTreatment.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchOptionTabPage::SchOptionTabPage(Window* pWindow,const SfxItemSet& rInAttrs) : + SfxTabPage(pWindow, SchResId(TP_OPTIONS), rInAttrs), + aGrpAxis(this, SchResId(GRP_OPT_AXIS)), + aRbtAxis1(this,SchResId(RBT_OPT_AXIS_1)), + aRbtAxis2(this,SchResId(RBT_OPT_AXIS_2)), + + aGrpBar(this, SchResId(GB_BAR)), + aFTGap(this,SchResId(FT_GAP)), + aMTGap(this,SchResId(MT_GAP)), + aFTOverlap(this,SchResId(FT_OVERLAP)), + aMTOverlap(this,SchResId(MT_OVERLAP)), + aCBConnect(this,SchResId(CB_CONNECTOR)), + aCBAxisSideBySide(this,SchResId(CB_BARS_SIDE_BY_SIDE)), + m_aFL_PlotOptions(this,SchResId(FL_PLOT_OPTIONS)), + m_aFT_MissingValues(this,SchResId(FT_MISSING_VALUES)), + m_aRB_DontPaint(this,SchResId(RB_DONT_PAINT)), + m_aRB_AssumeZero(this,SchResId(RB_ASSUME_ZERO)), + m_aRB_ContinueLine(this,SchResId(RB_CONTINUE_LINE)), + m_aCBIncludeHiddenCells(this,SchResId(CB_INCLUDE_HIDDEN_CELLS)), + m_bProvidesSecondaryYAxis(true), + m_bProvidesOverlapAndGapWidth(false) +{ + FreeResource(); + + aRbtAxis1.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl )); + aRbtAxis2.SetClickHdl( LINK( this, SchOptionTabPage, EnableHdl )); +} + +SchOptionTabPage::~SchOptionTabPage() +{ +} + +IMPL_LINK( SchOptionTabPage, EnableHdl, RadioButton *, EMPTYARG ) +{ + if( m_nAllSeriesAxisIndex == 0 ) + aCBAxisSideBySide.Enable( aRbtAxis2.IsChecked()); + else if( m_nAllSeriesAxisIndex == 1 ) + aCBAxisSideBySide.Enable( aRbtAxis1.IsChecked()); + + return 0; +} + +SfxTabPage* SchOptionTabPage::Create(Window* pWindow,const SfxItemSet& rOutAttrs) +{ + return new SchOptionTabPage(pWindow, rOutAttrs); +} + +BOOL SchOptionTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + if(aRbtAxis2.IsChecked()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_SECONDARY_Y)); + else + rOutAttrs.Put(SfxInt32Item(SCHATTR_AXIS,CHART_AXIS_PRIMARY_Y)); + + if(aMTGap.IsVisible()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_GAPWIDTH,static_cast< sal_Int32 >( aMTGap.GetValue()))); + + if(aMTOverlap.IsVisible()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_BAR_OVERLAP,static_cast< sal_Int32 >( aMTOverlap.GetValue()))); + + if(aCBConnect.IsVisible()) + rOutAttrs.Put(SfxBoolItem(SCHATTR_BAR_CONNECT,aCBConnect.IsChecked())); + + // model property is "group bars per axis", UI feature is the other way + // round: "show bars side by side" + if(aCBAxisSideBySide.IsVisible()) + rOutAttrs.Put(SfxBoolItem(SCHATTR_GROUP_BARS_PER_AXIS, ! aCBAxisSideBySide.IsChecked())); + + if(m_aRB_DontPaint.IsChecked()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP)); + else if(m_aRB_AssumeZero.IsChecked()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::USE_ZERO)); + else if(m_aRB_ContinueLine.IsChecked()) + rOutAttrs.Put(SfxInt32Item(SCHATTR_MISSING_VALUE_TREATMENT,::com::sun::star::chart::MissingValueTreatment::CONTINUE)); + + if (m_aCBIncludeHiddenCells.IsVisible()) + rOutAttrs.Put(SfxBoolItem(SCHATTR_INCLUDE_HIDDEN_CELLS, m_aCBIncludeHiddenCells.IsChecked())); + + return TRUE; +} + +void SchOptionTabPage::Reset(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem *pPoolItem = NULL; + + aRbtAxis1.Check(TRUE); + aRbtAxis2.Check(FALSE); + if (rInAttrs.GetItemState(SCHATTR_AXIS,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); + if(nVal==CHART_AXIS_SECONDARY_Y) + { + aRbtAxis2.Check(TRUE); + aRbtAxis1.Check(FALSE); + } + } + + long nTmp; + if (rInAttrs.GetItemState(SCHATTR_BAR_GAPWIDTH, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); + aMTGap.SetValue(nTmp); + } + + if (rInAttrs.GetItemState(SCHATTR_BAR_OVERLAP, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + nTmp = (long)((const SfxInt32Item*)pPoolItem)->GetValue(); + aMTOverlap.SetValue(nTmp); + } + + if (rInAttrs.GetItemState(SCHATTR_BAR_CONNECT, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + BOOL bCheck = static_cast< const SfxBoolItem * >( pPoolItem )->GetValue(); + aCBConnect.Check(bCheck); + } + + if (rInAttrs.GetItemState(SCHATTR_AXIS_FOR_ALL_SERIES, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_nAllSeriesAxisIndex = static_cast< const SfxInt32Item * >( pPoolItem )->GetValue(); + aCBAxisSideBySide.Disable(); + } + if (rInAttrs.GetItemState(SCHATTR_GROUP_BARS_PER_AXIS, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + // 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(); + aCBAxisSideBySide.Check( bCheck ); + } + else + { + aCBAxisSideBySide.Show(FALSE); + } + + + //missing value treatment + { + ::com::sun::star::uno::Sequence < sal_Int32 > aMissingValueTreatments; + if( rInAttrs.GetItemState(SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, TRUE, &pPoolItem) == SFX_ITEM_SET ) + aMissingValueTreatments =((const SfxIntegerListItem*)pPoolItem)->GetConstSequence(); + + if ( aMissingValueTreatments.getLength()>1 && rInAttrs.GetItemState(SCHATTR_MISSING_VALUE_TREATMENT,TRUE, &pPoolItem) == SFX_ITEM_SET) + { + m_aRB_DontPaint.Enable(FALSE); + m_aRB_AssumeZero.Enable(FALSE); + m_aRB_ContinueLine.Enable(FALSE); + + for( sal_Int32 nN =0; nN<aMissingValueTreatments.getLength(); nN++ ) + { + sal_Int32 nVal = aMissingValueTreatments[nN]; + if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP) + m_aRB_DontPaint.Enable(TRUE); + else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO) + m_aRB_AssumeZero.Enable(TRUE); + else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE) + m_aRB_ContinueLine.Enable(TRUE); + } + + long nVal=((const SfxInt32Item*)pPoolItem)->GetValue(); + if(nVal==::com::sun::star::chart::MissingValueTreatment::LEAVE_GAP) + m_aRB_DontPaint.Check(TRUE); + else if(nVal==::com::sun::star::chart::MissingValueTreatment::USE_ZERO) + m_aRB_AssumeZero.Check(TRUE); + else if(nVal==::com::sun::star::chart::MissingValueTreatment::CONTINUE) + m_aRB_ContinueLine.Check(TRUE); + } + else + { + m_aFT_MissingValues.Show(FALSE); + m_aRB_DontPaint.Show(FALSE); + m_aRB_AssumeZero.Show(FALSE); + m_aRB_ContinueLine.Show(FALSE); + } + } + + // Include hidden cells + if (rInAttrs.GetItemState(SCHATTR_INCLUDE_HIDDEN_CELLS, TRUE, &pPoolItem) == SFX_ITEM_SET) + { + bool bVal = static_cast<const SfxBoolItem*>(pPoolItem)->GetValue(); + m_aCBIncludeHiddenCells.Check(bVal); + } + else + { + m_aCBIncludeHiddenCells.Show(FALSE); + if(!m_aFT_MissingValues.IsVisible()) + m_aFL_PlotOptions.Show(FALSE); + } + + AdaptControlPositionsAndVisibility(); +} + +void SchOptionTabPage::Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors ) +{ + m_bProvidesSecondaryYAxis = bProvidesSecondaryYAxis; + m_bProvidesOverlapAndGapWidth = bProvidesOverlapAndGapWidth; + m_bProvidesBarConnectors = bProvidesBarConnectors; + + AdaptControlPositionsAndVisibility(); +} + +void lcl_offsetControl(Control& rCtrl, long nXOffset, long nYOffset ) +{ + Point aPos = rCtrl.GetPosPixel(); + rCtrl.SetPosPixel( Point(aPos.getX() + nXOffset, aPos.getY() + nYOffset) ); +} + +void lcl_optimzeRadioButtonSize( RadioButton& rCtrl ) +{ + rCtrl.SetSizePixel( rCtrl.CalcMinimumSize() ); +} + +void SchOptionTabPage::AdaptControlPositionsAndVisibility() +{ + aRbtAxis1.Show(m_bProvidesSecondaryYAxis); + aRbtAxis2.Show(m_bProvidesSecondaryYAxis); + aGrpAxis.Show(m_bProvidesSecondaryYAxis); + + aMTGap.Show(m_bProvidesOverlapAndGapWidth); + aFTGap.Show(m_bProvidesOverlapAndGapWidth); + + aMTOverlap.Show(m_bProvidesOverlapAndGapWidth); + aFTOverlap.Show(m_bProvidesOverlapAndGapWidth); + + aCBConnect.Show(m_bProvidesBarConnectors); + + if( !aMTGap.IsVisible() && !aMTOverlap.IsVisible() ) + { + aGrpBar.Show(FALSE); + Point aPos; + if( !aRbtAxis1.IsVisible() && !aRbtAxis2.IsVisible() ) + aPos = aGrpAxis.GetPosPixel(); + else + aPos = aGrpBar.GetPosPixel(); + + long nYOffset = aPos.getY() - m_aFL_PlotOptions.GetPosPixel().getY(); + lcl_offsetControl(m_aFL_PlotOptions, 0, nYOffset); + lcl_offsetControl(m_aFT_MissingValues, 0, nYOffset); + lcl_offsetControl(m_aRB_DontPaint, 0, nYOffset); + lcl_offsetControl(m_aRB_AssumeZero, 0, nYOffset); + lcl_offsetControl(m_aRB_ContinueLine, 0, nYOffset); + lcl_offsetControl(m_aCBIncludeHiddenCells, 0, nYOffset); + } + + m_aFT_MissingValues.SetSizePixel( m_aFT_MissingValues.CalcMinimumSize() ); + lcl_optimzeRadioButtonSize( m_aRB_DontPaint ); + lcl_optimzeRadioButtonSize( m_aRB_AssumeZero ); + lcl_optimzeRadioButtonSize( m_aRB_ContinueLine ); + + Size aControlDistance( m_aFT_MissingValues.LogicToPixel( Size(RSC_SP_CTRL_DESC_X,RSC_SP_CTRL_GROUP_Y), MapMode(MAP_APPFONT) ) ); + long nXOffset = m_aFT_MissingValues.GetPosPixel().getX() + m_aFT_MissingValues.GetSizePixel().getWidth() + aControlDistance.getWidth() - m_aRB_DontPaint.GetPosPixel().getX(); + lcl_offsetControl(m_aRB_DontPaint, nXOffset, 0); + lcl_offsetControl(m_aRB_AssumeZero, nXOffset, 0); + lcl_offsetControl(m_aRB_ContinueLine, nXOffset, 0); + + if( !m_aFT_MissingValues.IsVisible() ) + { + //for example for stock charts + m_aCBIncludeHiddenCells.SetPosPixel( m_aFT_MissingValues.GetPosPixel() ); + } +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hrc b/chart2/source/controller/dialogs/tp_SeriesToAxis.hrc new file mode 100644 index 000000000000..2a39c313ca3c --- /dev/null +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hrc @@ -0,0 +1,48 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ,v $ + * $Revision: $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +#define GRP_OPT_AXIS 1 +#define RBT_OPT_AXIS_1 2 +#define RBT_OPT_AXIS_2 3 +#define MT_GAP 4 +#define MT_OVERLAP 5 +#define FT_GAP 6 +#define FT_OVERLAP 7 +#define GB_BAR 8 +#define CB_CONNECTOR 9 +#define CB_BARS_SIDE_BY_SIDE 10 +#define FL_PLOT_OPTIONS 11 +#define FT_MISSING_VALUES 12 +#define RB_DONT_PAINT 13 +#define RB_ASSUME_ZERO 14 +#define RB_CONTINUE_LINE 15 +#define CB_INCLUDE_HIDDEN_CELLS 16 diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx new file mode 100644 index 000000000000..10fcae66c1e3 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.hxx @@ -0,0 +1,98 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_SeriesToAxis.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_SERIESTOAXIS_HXX +#define _CHART2_TP_SERIESTOAXIS_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> +// header for FixedText +#include <vcl/fixed.hxx> +// header for CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for MetricField +#include <vcl/field.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class SchOptionTabPage : public SfxTabPage +{ +public: + SchOptionTabPage(Window* pParent, const SfxItemSet& rInAttrs); + virtual ~SchOptionTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual void Reset(const SfxItemSet& rInAttrs); + + void Init( bool bProvidesSecondaryYAxis, bool bProvidesOverlapAndGapWidth, bool bProvidesBarConnectors ); + +private: //methods + void AdaptControlPositionsAndVisibility(); + +private: //member + FixedLine aGrpAxis; + RadioButton aRbtAxis1; + RadioButton aRbtAxis2; + + FixedLine aGrpBar; + FixedText aFTGap; + MetricField aMTGap; + FixedText aFTOverlap; + MetricField aMTOverlap; + CheckBox aCBConnect; + CheckBox aCBAxisSideBySide; + + FixedLine m_aFL_PlotOptions; + FixedText m_aFT_MissingValues; + RadioButton m_aRB_DontPaint; + RadioButton m_aRB_AssumeZero; + RadioButton m_aRB_ContinueLine; + + CheckBox m_aCBIncludeHiddenCells; + + DECL_LINK(EnableHdl, RadioButton * ); + + sal_Int32 m_nAllSeriesAxisIndex; + + bool m_bProvidesSecondaryYAxis; + bool m_bProvidesOverlapAndGapWidth; + bool m_bProvidesBarConnectors; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_SeriesToAxis.src b/chart2/source/controller/dialogs/tp_SeriesToAxis.src new file mode 100644 index 000000000000..0686e45f25b3 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_SeriesToAxis.src @@ -0,0 +1,179 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_SeriesToAxis.src,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "tp_SeriesToAxis.hrc" + +TabPage TP_OPTIONS +{ + Hide = TRUE ; +// HelpID = HID_LAYOUT ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + FixedLine 1 + { + Pos = MAP_APPFONT ( 6 , 6 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Align data series to"; + }; + RadioButton RBT_OPT_AXIS_1 + { + Pos = MAP_APPFONT ( 12 , 20 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Primary Y axis"; + }; + RadioButton RBT_OPT_AXIS_2 + { + Pos = MAP_APPFONT ( 12 , 34 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Secondary Y axis"; + }; + + FixedLine GB_BAR + { + Pos = MAP_APPFONT ( 6 , 50 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Settings"; + }; + FixedText FT_OVERLAP + { + Pos = MAP_APPFONT ( 12 , 80 ) ; + Size = MAP_APPFONT ( 47 , 8 ) ; + Text [ en-US ] = "~Overlap"; + }; + + MetricField MT_OVERLAP + { + Border = TRUE ; + Pos = MAP_APPFONT ( 63 , 78 ) ; + Size = MAP_APPFONT ( 40 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = -100 ; + Maximum = 100 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + DecimalDigits = 0 ; + }; + + FixedText FT_GAP + { + Pos = MAP_APPFONT ( 12 , 64 ) ; + Size = MAP_APPFONT ( 47 , 8 ) ; + Text [ en-US ] = "~Spacing"; + }; + + MetricField MT_GAP + { + Border = TRUE ; + Pos = MAP_APPFONT ( 63 , 62 ) ; + Size = MAP_APPFONT ( 40 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + Minimum = 0 ; + Maximum = 600 ; + StrictFormat = TRUE ; + Unit = FUNIT_CUSTOM ; + CustomUnitText = " %" ; + First = 1 ; + Last = 100 ; + SpinSize = 1 ; + DecimalDigits = 0 ; + }; + + CheckBox CB_CONNECTOR + { + Pos = MAP_APPFONT ( 12 , 97 ) ; + Size = MAP_APPFONT ( 200 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Connection lines"; + }; + + CheckBox CB_BARS_SIDE_BY_SIDE + { + Pos = MAP_APPFONT ( 12 , 97 ) ; + Size = MAP_APPFONT ( 200 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Show ~bars side by side"; + }; + + FixedLine FL_PLOT_OPTIONS + { + Pos = MAP_APPFONT ( 6 , 113 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Plot options"; + }; + + FixedText FT_MISSING_VALUES + { + Pos = MAP_APPFONT ( 12 , 127 ) ; + Size = MAP_APPFONT ( 80 , 8 ) ; + Text [ en-US ] = "Plot missing values"; + }; + + RadioButton RB_DONT_PAINT + { + Pos = MAP_APPFONT ( 82 , 127 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Leave gap"; + }; + + RadioButton RB_ASSUME_ZERO + { + Pos = MAP_APPFONT ( 82 , 141 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Assume zero"; + }; + + RadioButton RB_CONTINUE_LINE + { + Pos = MAP_APPFONT ( 82 , 155 ) ; + Size = MAP_APPFONT ( 80 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "~Continue line"; + }; + + CheckBox CB_INCLUDE_HIDDEN_CELLS + { + Pos = MAP_APPFONT ( 12 , 172 ) ; + Size = MAP_APPFONT ( 200 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Include ~values from hidden cells"; + }; +}; diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.cxx b/chart2/source/controller/dialogs/tp_TitleRotation.cxx new file mode 100644 index 000000000000..6733d9e08c3a --- /dev/null +++ b/chart2/source/controller/dialogs/tp_TitleRotation.cxx @@ -0,0 +1,129 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_TitleRotation.cxx,v $ + * $Revision: 1.11.72.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "tp_TitleRotation.hxx" + +#include "ResId.hxx" +#include "TabPages.hrc" +#include "chartview/ChartSfxItemIds.hxx" +#include "HelpIds.hrc" +#include <svx/eeitem.hxx> +#include <svx/frmdiritem.hxx> + +// header for class SfxInt32Item +#include <svtools/intitem.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +SchAlignmentTabPage::SchAlignmentTabPage(Window* pWindow, + const SfxItemSet& rInAttrs, bool bWithRotation) : + SfxTabPage(pWindow, SchResId(TP_ALIGNMENT), rInAttrs), + aFlAlign ( this, SchResId( FL_ALIGN ) ), + aCtrlDial ( this, SchResId( CTR_DIAL ) ), + aFtRotate ( this, SchResId( FT_DEGREES ) ), + aNfRotate ( this, SchResId( NF_ORIENT ) ), + aCbStacked ( this, SchResId( BTN_TXTSTACKED ) ), + aOrientHlp ( aCtrlDial, aNfRotate, aCbStacked ), + aFtTextDirection( this, SchResId( FT_TEXTDIR ) ), + aLbTextDirection( this, SchResId( LB_TEXTDIR ), &aFtTextDirection ) +{ + FreeResource(); + + aCbStacked.EnableTriState( FALSE ); + aOrientHlp.AddDependentWindow( aFtRotate, STATE_CHECK ); + + if( !bWithRotation ) + { + aOrientHlp.Hide(); + Point aMove( 0, aCtrlDial.GetPosPixel().Y() - aFtTextDirection.GetPosPixel().Y() ); + aFtTextDirection.SetPosPixel( aFtTextDirection.GetPosPixel() + aMove ); + aLbTextDirection.SetPosPixel( aLbTextDirection.GetPosPixel() + aMove ); + + aLbTextDirection.SetHelpId( HID_SCH_TEXTDIRECTION_EQUATION ); + } +} + +SchAlignmentTabPage::~SchAlignmentTabPage() +{ +} + +SfxTabPage* SchAlignmentTabPage::Create(Window* pParent, + const SfxItemSet& rInAttrs) +{ + return new SchAlignmentTabPage(pParent, rInAttrs); +} + +SfxTabPage* SchAlignmentTabPage::CreateWithoutRotation(Window* pParent, + const SfxItemSet& rInAttrs) +{ + return new SchAlignmentTabPage(pParent, rInAttrs, false); +} + +BOOL SchAlignmentTabPage::FillItemSet(SfxItemSet& rOutAttrs) +{ + //Seit 4/1998 koennen Texte frei gedreht werden: SCHATTR_TEXT_DEGREES + bool bStacked = aOrientHlp.GetStackedState() == STATE_CHECK; + rOutAttrs.Put( SfxBoolItem( SCHATTR_TEXT_STACKED, bStacked ) ); + + sal_Int32 nDegrees = bStacked ? 0 : aCtrlDial.GetRotation(); + rOutAttrs.Put( SfxInt32Item( SCHATTR_TEXT_DEGREES, nDegrees ) ); + + SvxFrameDirection aDirection( aLbTextDirection.GetSelectEntryValue() ); + rOutAttrs.Put( SfxInt32Item( EE_PARA_WRITINGDIR, aDirection ) ); + + return TRUE; +} + +void SchAlignmentTabPage::Reset(const SfxItemSet& rInAttrs) +{ + const SfxPoolItem* pItem = GetItem( rInAttrs, SCHATTR_TEXT_DEGREES ); + + sal_Int32 nDegrees = pItem ? ((const SfxInt32Item*)pItem)->GetValue() : 0; + aCtrlDial.SetRotation( nDegrees ); + + pItem = GetItem( rInAttrs, SCHATTR_TEXT_STACKED ); + bool bStacked = pItem && ((const SfxBoolItem*)pItem)->GetValue(); + aOrientHlp.SetStackedState( bStacked ? STATE_CHECK : STATE_NOCHECK ); + + + if( rInAttrs.GetItemState(EE_PARA_WRITINGDIR, TRUE, &pItem) == SFX_ITEM_SET) + aLbTextDirection.SelectEntryValue( SvxFrameDirection(((const SvxFrameDirectionItem*)pItem)->GetValue()) ); +} + +//............................................................................. +} //namespace chart +//............................................................................. + + diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.hxx b/chart2/source/controller/dialogs/tp_TitleRotation.hxx new file mode 100644 index 000000000000..fb208196480f --- /dev/null +++ b/chart2/source/controller/dialogs/tp_TitleRotation.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_TitleRotation.hxx,v $ + * $Revision: 1.9.72.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_TITLEROTATION_HXX +#define _CHART2_TP_TITLEROTATION_HXX + +// header for SfxTabPage +#include <sfx2/tabdlg.hxx> +#include <svx/dialcontrol.hxx> +#include <svx/wrapfield.hxx> +#include <svx/orienthelper.hxx> +#include <vcl/fixed.hxx> +#include "TextDirectionListBox.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class SchAlignmentTabPage : public SfxTabPage +{ +private: + FixedLine aFlAlign; + svx::DialControl aCtrlDial; + FixedText aFtRotate; + svx::WrapField aNfRotate; + TriStateBox aCbStacked; + svx::OrientationHelper aOrientHlp; + FixedText aFtTextDirection; + TextDirectionListBox aLbTextDirection; + +public: + SchAlignmentTabPage(Window* pParent, const SfxItemSet& rInAttrs, bool bWithRotation = true); + virtual ~SchAlignmentTabPage(); + + static SfxTabPage* Create(Window* pParent, const SfxItemSet& rInAttrs); + static SfxTabPage* CreateWithoutRotation(Window* pParent, const SfxItemSet& rInAttrs); + virtual BOOL FillItemSet(SfxItemSet& rOutAttrs); + virtual void Reset(const SfxItemSet& rInAttrs); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_TitleRotation.src b/chart2/source/controller/dialogs/tp_TitleRotation.src new file mode 100644 index 000000000000..8d516c13fb0a --- /dev/null +++ b/chart2/source/controller/dialogs/tp_TitleRotation.src @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_TitleRotation.src,v $ + * $Revision: 1.10.72.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" + +TabPage TP_ALIGNMENT +{ + Hide = TRUE ; + HelpID = HID_SCH_ALIGNMENT ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + Control CTR_DIAL + { + HelpId = HID_SCH_ALIGNMENT_CTR_DIAL ; + Pos = MAP_APPFONT ( 12 , 14 ) ; + Size = MAP_APPFONT ( 43 , 43 ) ; + Text = "ABCD" ; + }; + TriStateBox BTN_TXTSTACKED + { + HelpId = HID_SCH_ALIGNMENT_STACKED ; + Pos = MAP_APPFONT ( 139 , 14 ) ; + Size = MAP_APPFONT ( 116 , 10 ) ; + TabStop = TRUE ; + Text [ en-US ] = "Ve~rtically stacked"; + }; + FixedText FT_DEGREES + { + Pos = MAP_APPFONT ( 93 , 32 ) ; + Size = MAP_APPFONT ( 162 , 8 ) ; + Text [ en-US ] = "~Degrees" ; + }; + NumericField NF_ORIENT + { + HelpId = HID_SCH_ALIGNMENT_DEGREES ; + Border = TRUE ; + Pos = MAP_APPFONT ( 61 , 30 ) ; + Size = MAP_APPFONT ( 28 , 12 ) ; + TabStop = TRUE ; + Repeat = TRUE ; + Spin = TRUE ; + StrictFormat = TRUE ; + SpinSize = 5 ; + Minimum = 0 ; + Maximum = 359 ; + }; + FixedLine FL_ALIGN + { + Pos = MAP_APPFONT ( 6 , 3 ) ; + Size = MAP_APPFONT ( 248 , 8 ) ; + Text [ en-US ] = "Text orientation" ; + }; + FixedText FT_TEXTDIR + { + Pos = MAP_APPFONT ( 12 , 65 ) ; + Size = MAP_APPFONT ( 64 , 8 ) ; + Text [ en-US ] = "Te~xt direction" ; + }; + ListBox LB_TEXTDIR + { + HelpId = HID_SCH_TEXTDIRECTION_TITLE ; + Pos = MAP_APPFONT ( 78 , 63 ) ; + Size = MAP_APPFONT ( 170 , 100 ) ; + Border = TRUE; + TabStop = TRUE; + DropDown = TRUE; + }; +}; + diff --git a/chart2/source/controller/dialogs/tp_Trendline.cxx b/chart2/source/controller/dialogs/tp_Trendline.cxx new file mode 100644 index 000000000000..a4f9056208c2 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Trendline.cxx @@ -0,0 +1,80 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Trendline.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_Trendline.hxx" +#include "ResId.hxx" +#include "TabPages.hrc" + +//............................................................................. +namespace chart +{ +//............................................................................. + +TrendlineTabPage::TrendlineTabPage( Window* pParent, const SfxItemSet& rInAttrs ) : + SfxTabPage( pParent, SchResId( TP_TRENDLINE ), rInAttrs ), + m_aTrendlineResources( this, rInAttrs, false ) +{ + FreeResource(); +} + +TrendlineTabPage::~TrendlineTabPage() +{ +} + +SfxTabPage* TrendlineTabPage::Create( + Window* pParent, const SfxItemSet& rOutAttrs ) +{ + return new TrendlineTabPage( pParent, rOutAttrs ); +} + +BOOL TrendlineTabPage::FillItemSet( SfxItemSet& rOutAttrs ) +{ + return m_aTrendlineResources.FillItemSet( rOutAttrs ); +} + +void TrendlineTabPage::Reset( const SfxItemSet& rInAttrs ) +{ + m_aTrendlineResources.Reset( rInAttrs ); +} + +void TrendlineTabPage::DataChanged( const DataChangedEvent& rDCEvt ) +{ + SfxTabPage::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + m_aTrendlineResources.FillValueSets(); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Trendline.hxx b/chart2/source/controller/dialogs/tp_Trendline.hxx new file mode 100644 index 000000000000..3c2be000e293 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Trendline.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Trendline.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TP_TRENDLINE_HXX +#define _CHART2_TP_TRENDLINE_HXX + +#include "res_Trendline.hxx" + +#include <sfx2/tabdlg.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class TrendlineTabPage : public SfxTabPage +{ +public: + TrendlineTabPage ( Window* pParent, const SfxItemSet& rInAttrs ); + virtual ~TrendlineTabPage (); + + static SfxTabPage* Create( Window* pParent, const SfxItemSet& rInAttrs ); + virtual BOOL FillItemSet( SfxItemSet& rOutAttrs ); + virtual void Reset( const SfxItemSet& rInAttrs ); + + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + TrendlineResources m_aTrendlineResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/dialogs/tp_Trendline.src b/chart2/source/controller/dialogs/tp_Trendline.src new file mode 100644 index 000000000000..2e7e8ec78c05 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Trendline.src @@ -0,0 +1,41 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Trendline.src,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "TabPages.hrc" +#include "res_Trendline.hrc" + +TabPage TP_TRENDLINE +{ + Hide = TRUE ; +// HelpID = HID_SCH_STAT ; + SVLook = TRUE ; + Size = MAP_APPFONT ( 260 , 185 ) ; + RESOURCE_TRENDLINE( 260 - 12, 0 ) +}; diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx new file mode 100644 index 000000000000..67957ae94a16 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Wizard_TitlesAndObjects.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "tp_Wizard_TitlesAndObjects.hxx" +#include "tp_Wizard_TitlesAndObjects.hrc" +#include "Strings.hrc" +#include "res_Titles.hxx" +#include "res_LegendPosition.hxx" +#include "ResId.hxx" +#include "HelpIds.hrc" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" +#include "LegendHelper.hxx" +#include "NoWarningThisInCTOR.hxx" +#include "ControllerLockGuard.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + + +TitlesAndObjectsTabPage::TitlesAndObjectsTabPage( svt::OWizardMachine* pParent + , const uno::Reference< XChartDocument >& xChartModel + , const uno::Reference< uno::XComponentContext >& xContext ) + : OWizardPage( pParent, SchResId(TP_WIZARD_TITLEANDOBJECTS) ) + , m_aFT_TitleDescription( this, SchResId( FT_TITLEDESCRIPTION ) ) + , m_aFL_Vertical( this, SchResId( FL_VERTICAL ) ) + , m_apTitleResources( new TitleResources(this,false) ) + , m_apLegendPositionResources( new LegendPositionResources(this,xContext) ) + , m_aFL_Grids( this, SchResId( FL_GRIDS ) ) + , m_aCB_Grid_X( this, SchResId( CB_X_SECONDARY ) ) + , m_aCB_Grid_Y( this, SchResId( CB_Y_SECONDARY ) ) + , m_aCB_Grid_Z( this, SchResId( CB_Z_SECONDARY ) ) + , m_xChartModel( xChartModel ) + , m_xCC( xContext ) + , m_bCommitToModel( true ) + , m_aTimerTriggeredControllerLock( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY ) ) +{ + FreeResource(); + + this->SetText( String( SchResId( STR_PAGE_CHART_ELEMENTS ) ) ); + + Font aFont( m_aFT_TitleDescription.GetControlFont() ); + aFont.SetWeight( WEIGHT_BOLD ); + m_aFT_TitleDescription.SetControlFont( aFont ); + + m_aCB_Grid_X.SetHelpId( HID_SCH_CB_XGRID ); + m_aCB_Grid_Y.SetHelpId( HID_SCH_CB_YGRID ); + m_aCB_Grid_Z.SetHelpId( HID_SCH_CB_ZGRID ); + + m_apTitleResources->SetUpdateDataHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); + m_apLegendPositionResources->SetChangeHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); + + m_aCB_Grid_X.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); + m_aCB_Grid_Y.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); + m_aCB_Grid_Z.SetToggleHdl( LINK( this, TitlesAndObjectsTabPage, ChangeHdl )); +} + +TitlesAndObjectsTabPage::~TitlesAndObjectsTabPage() +{ +} + +void TitlesAndObjectsTabPage::initializePage() +{ + m_bCommitToModel = false; + + //init titles + { + TitleDialogData aTitleInput; + aTitleInput.readFromModel( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) ); + m_apTitleResources->writeToResources( aTitleInput ); + } + + //init legend + { + m_apLegendPositionResources->writeToResources( uno::Reference< frame::XModel >( m_xChartModel, uno::UNO_QUERY) ); + } + + //init grid checkboxes + { + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_xChartModel ); + uno::Sequence< sal_Bool > aPossibilityList; + uno::Sequence< sal_Bool > aExistenceList; + AxisHelper::getAxisOrGridPossibilities( aPossibilityList, xDiagram, sal_False ); + AxisHelper::getAxisOrGridExcistence( aExistenceList, xDiagram, sal_False ); + m_aCB_Grid_X.Enable( aPossibilityList[0] ); + m_aCB_Grid_Y.Enable( aPossibilityList[1] ); + m_aCB_Grid_Z.Enable( aPossibilityList[2] ); + m_aCB_Grid_X.Check( aExistenceList[0] ); + m_aCB_Grid_Y.Check( aExistenceList[1] ); + m_aCB_Grid_Z.Check( aExistenceList[2] ); + } + + m_bCommitToModel = true; +} + +sal_Bool TitlesAndObjectsTabPage::commitPage( CommitPageReason /*eReason*/ ) +{ + if( m_apTitleResources->IsModified() ) //titles may have changed in the meanwhile + commitToModel(); + return sal_True;//return false if this page should not be left +} + +void TitlesAndObjectsTabPage::commitToModel() +{ + bool bChanged = false; + + m_aTimerTriggeredControllerLock.startTimer(); + uno::Reference< frame::XModel > xModel( m_xChartModel, uno::UNO_QUERY); + + ControllerLockGuard aLockedControllers( xModel ); + + //commit title changes to model + { + TitleDialogData aTitleOutput; + m_apTitleResources->readFromResources( aTitleOutput ); + bChanged = bChanged || aTitleOutput.writeDifferenceToModel( xModel, m_xCC ); + m_apTitleResources->ClearModifyFlag(); + } + + //commit legend changes to model + { + bChanged = true; + m_apLegendPositionResources->writeToModel( xModel ); + } + + //commit grid changes to model + { + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( xModel ); + uno::Sequence< sal_Bool > aOldExistenceList; + AxisHelper::getAxisOrGridExcistence( aOldExistenceList, xDiagram, sal_False ); + uno::Sequence< sal_Bool > aNewExistenceList(aOldExistenceList); + aNewExistenceList[0]=m_aCB_Grid_X.IsChecked(); + aNewExistenceList[1]=m_aCB_Grid_Y.IsChecked(); + aNewExistenceList[2]=m_aCB_Grid_Z.IsChecked(); + AxisHelper::changeVisibilityOfGrids( xDiagram + , aOldExistenceList, aNewExistenceList, m_xCC ); + } +} + +IMPL_LINK( TitlesAndObjectsTabPage, ChangeHdl, void *, EMPTYARG ) +{ + if( m_bCommitToModel ) + commitToModel(); + return 0; +} + +bool TitlesAndObjectsTabPage::canAdvance() const +{ + return false; +} + + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc new file mode 100644 index 000000000000..96721982bfc5 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hrc @@ -0,0 +1,53 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Wizard_TitlesAndObjects.hrc,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include "ResourceIds.hrc" + +/* +#define ED_MAINTITLE 1 +#define ED_SUBTITLE 2 +#define ED_X_AXIS 3 +#define ED_Y_AXIS 4 +#define ED_Z_AXIS 5 +#define FT_MAINTITLE 1 +#define FT_SUBTITLE 2 +#define FT_TITLE_X_AXIS 3 +#define FT_TITLE_Y_AXIS 4 +#define FT_TITLE_Z_AXIS 5 +*/ + +#define FT_TITLEDESCRIPTION 30 + +#define FL_VERTICAL 3 +#define FL_GRIDS 4 + +#define CB_X_SECONDARY 4 +#define CB_Y_SECONDARY 5 +#define CB_Z_SECONDARY 6 diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx new file mode 100644 index 000000000000..517fe301039c --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.hxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Wizard_TitlesAndObjects.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_TP_WIZARD_TITLESANDOBJECTS_HXX +#define _CHART2_TP_WIZARD_TITLESANDOBJECTS_HXX + +#include "TimerTriggeredControllerLock.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <svtools/wizardmachine.hxx> +#include <vcl/edit.hxx> +#include <vcl/fixed.hxx> +//for auto_ptr +#include <memory> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class TitleResources; +class LegendPositionResources; +class TitlesAndObjectsTabPage : public svt::OWizardPage +{ +public: + TitlesAndObjectsTabPage( svt::OWizardMachine* pParent + , const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~TitlesAndObjectsTabPage(); + + virtual void initializePage(); + virtual sal_Bool commitPage( CommitPageReason eReason ); + virtual bool canAdvance() const; + +protected: + void commitToModel(); + DECL_LINK( ChangeHdl, void* ); + +protected: + FixedText m_aFT_TitleDescription; + FixedLine m_aFL_Vertical; + + ::std::auto_ptr< TitleResources > m_apTitleResources; + ::std::auto_ptr< LegendPositionResources > m_apLegendPositionResources; + + FixedLine m_aFL_Grids; + CheckBox m_aCB_Grid_X; + CheckBox m_aCB_Grid_Y; + CheckBox m_aCB_Grid_Z; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; + + bool m_bCommitToModel; + TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.src b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.src new file mode 100644 index 000000000000..c8f9a5e49030 --- /dev/null +++ b/chart2/source/controller/dialogs/tp_Wizard_TitlesAndObjects.src @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: tp_Wizard_TitlesAndObjects.src,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "HelpIds.hrc" +#include "SchSlotIds.hxx" +#include "tp_Wizard_TitlesAndObjects.hrc" +#include "res_Titlesx.hrc" +#include "res_SecondaryAxisCheckBoxes.hrc" +#include "dlg_CreationWizard.hrc" +#include "res_LegendPosition.hrc" + +#ifndef _SVT_CONTROLDIMS_HRC_ +#include <svtools/controldims.hrc> +#endif + +#define MASKCOLOR MaskColor = Color { Red = 0xC000 ; Green = 0xC000 ; Blue = 0xC000 ; } +#define WIZ_TITLES_WIDTH 130 + +#define WIZ_POSX1 6 +#define WIZ_POSX1_A (WIZ_POSX1) +#define WIZ_POSX_VERTICAL (WIZ_POSX1+WIZ_TITLES_WIDTH+6) +#define WIZ_POSX2 (WIZ_POSX_VERTICAL+RSC_CD_FIXEDLINE_WIDTH+2) +#define WIZ_POSX2_A (WIZ_POSX2) +#define WIZ_POSX2_B (WIZ_POSX2_A+9) + +#define WIZ_SECOND_FIXEDLINE_WIDTH (CHART_WIZARD_PAGEWIDTH-10-(WIZ_POSX2)) +#define WIZ_COMPLETE_FIXEDLINE_WIDTH (CHART_WIZARD_PAGEWIDTH-10-(WIZ_POSX1)) +#define WIZ_VERTICAL_FIXEDLINE_HEIGHT ( 88 ) + +#define WIZ_POSY1 8 +#define WIZ_POSY1_A (WIZ_POSY1 + RSC_CD_FIXEDTEXT_HEIGHT +5) +#define WIZ_POSY1_B (WIZ_POSY1_A+ RSC_CD_FIXEDTEXT_HEIGHT +7) + +#define WIZ_POSY2 110 +#define WIZ_POSY_GRID (WIZ_POSY2+RSC_CD_FIXEDTEXT_HEIGHT+6) + +TabPage TP_WIZARD_TITLEANDOBJECTS +{ + Hide = TRUE ; + SVLook = TRUE ; + Size = MAP_APPFONT ( CHART_WIZARD_PAGEWIDTH , CHART_WIZARD_PAGEHEIGHT ) ; + + FixedText FT_TITLEDESCRIPTION + { + Pos = MAP_APPFONT ( WIZ_POSX1 , WIZ_POSY1 ) ; + Size = MAP_APPFONT ( WIZ_COMPLETE_FIXEDLINE_WIDTH , RSC_CD_FIXEDTEXT_HEIGHT ) ; + Text [ en-US ] = "Choose titles, legend, and grid settings"; + }; + FixedLine FL_VERTICAL + { + Pos = MAP_APPFONT ( WIZ_POSX_VERTICAL , WIZ_POSY1+3+RSC_CD_FIXEDLINE_HEIGHT ) ; + Size = MAP_APPFONT ( RSC_CD_FIXEDLINE_WIDTH, WIZ_VERTICAL_FIXEDLINE_HEIGHT ) ; + Vert = TRUE ; + }; + + TITLES(WIZ_POSX1_A,WIZ_POSY1_A,WIZ_TITLES_WIDTH,0,0) + RESOURCE_LEGENDDISPLAY( WIZ_POSX2_A, WIZ_POSY1_A ) + RESOURCE_LEGENDPOSITION( WIZ_POSX2_B, WIZ_POSY1_B ) + + + FixedLine FL_GRIDS + { + Pos = MAP_APPFONT ( WIZ_POSX1 , WIZ_POSY2 ) ; + Size = MAP_APPFONT ( WIZ_COMPLETE_FIXEDLINE_WIDTH , RSC_CD_FIXEDLINE_HEIGHT ) ; + Text [ en-US ] = "Display grids"; + }; + + SECONDARYAXISCHECKBOXES( WIZ_POSX1_A, WIZ_POSY_GRID, 43, 0 ) +}; diff --git a/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx new file mode 100644 index 000000000000..fa285f98d991 --- /dev/null +++ b/chart2/source/controller/drawinglayer/DrawViewWrapper.cxx @@ -0,0 +1,418 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DrawViewWrapper.cxx,v $ + * $Revision: 1.20.6.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DrawViewWrapper.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "ConfigurationAccess.hxx" + +// header for class SdrPage +#include <svx/svdpage.hxx> +//header for class SdrPageView +#include <svx/svdpagv.hxx> +// header for class SdrModel +#include <svx/svdmodel.hxx> +// header for class E3dScene +#include <svx/scene3d.hxx> +#include <svx/svdetc.hxx> +#include <svx/svdoutl.hxx> + +// header for class SvxForbiddenCharactersTable +#include <svx/forbiddencharacterstable.hxx> + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif + +// header for class SvxShape +#include <svx/unoshape.hxx> + +#include <com/sun/star/container/XChild.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> + +#include <sfx2/objsh.hxx> +#include <svx/helperhittest3d.hxx> + +using namespace ::com::sun::star; + +//............................................................................. +namespace chart +{ +//............................................................................. + +namespace +{ + short lcl_getHitTolerance( OutputDevice* pOutDev ) + { + const short HITPIX=2; //hit-tolerance in pixel + short nHitTolerance = 50; + if(pOutDev) + nHitTolerance = static_cast<short>(pOutDev->PixelToLogic(Size(HITPIX,0)).Width()); + return nHitTolerance; + } + +// this code is copied from sfx2/source/doc/objembed.cxx +SfxObjectShell * lcl_GetParentObjectShell( const uno::Reference< frame::XModel > & xModel ) +{ + SfxObjectShell* pResult = NULL; + + try + { + uno::Reference< container::XChild > xChildModel( xModel, uno::UNO_QUERY ); + if ( xChildModel.is() ) + { + uno::Reference< lang::XUnoTunnel > xParentTunnel( xChildModel->getParent(), uno::UNO_QUERY ); + if ( xParentTunnel.is() ) + { + SvGlobalName aSfxIdent( SFX_GLOBAL_CLASSID ); + pResult = reinterpret_cast< SfxObjectShell * >( + xParentTunnel->getSomething( uno::Sequence< sal_Int8 >( aSfxIdent.GetByteSequence() ) ) ); + } + } + } + catch( uno::Exception& ) + { + // TODO: error handling + } + + return pResult; +} + +// this code is copied from sfx2/source/doc/objembed.cxx. It is a workaround to +// get the reference device (e.g. printer) fromthe parent document +OutputDevice * lcl_GetParentRefDevice( const uno::Reference< frame::XModel > & xModel ) +{ + SfxObjectShell * pParent = lcl_GetParentObjectShell( xModel ); + if ( pParent ) + return pParent->GetDocumentRefDev(); + return NULL; +} + +} + + /* +void lcl_initOutliner( SdrOutliner* pTargetOutliner, SdrOutliner* pSourceOutliner ) +{ + //just an unsuccessful try to initialize the text edit outliner correctly + //if( bInit ) + { + pTargetOutliner->EraseVirtualDevice(); + pTargetOutliner->SetUpdateMode(FALSE); + pTargetOutliner->SetEditTextObjectPool( pSourceOutliner->GetEditTextObjectPool() ); + pTargetOutliner->SetDefTab( pSourceOutliner->GetDefTab() ); + } + + pTargetOutliner->SetRefDevice( pSourceOutliner->GetRefDevice() ); + pTargetOutliner->SetForbiddenCharsTable( pSourceOutliner->GetForbiddenCharsTable() ); + pTargetOutliner->SetAsianCompressionMode( pSourceOutliner->GetAsianCompressionMode() ); + pTargetOutliner->SetKernAsianPunctuation( pSourceOutliner->IsKernAsianPunctuation() ); + pTargetOutliner->SetStyleSheetPool( pSourceOutliner->GetStyleSheetPool() ); + pTargetOutliner->SetRefMapMode( pSourceOutliner->GetRefMapMode() ); + pTargetOutliner->SetDefaultLanguage( pSourceOutliner->GetDefaultLanguage() ); + pTargetOutliner->SetHyphenator( pSourceOutliner->GetHyphenator() ); + + USHORT nX, nY; + pSourceOutliner->GetGlobalCharStretching( nX, nY ); + pTargetOutliner->SetGlobalCharStretching( nX, nY ); + + *//* + if ( !GetRefDevice() ) + { + MapMode aMapMode(eObjUnit, Point(0,0), aObjUnit, aObjUnit); + pTargetOutliner->SetRefMapMode(aMapMode); + } + *//* +} +*/ + +DrawViewWrapper::DrawViewWrapper( SdrModel* pSdrModel, OutputDevice* pOut, bool bPaintPageForEditMode) + : E3dView(pSdrModel, pOut) + , m_pMarkHandleProvider(NULL) + , m_apOutliner( SdrMakeOutliner( OUTLINERMODE_TEXTOBJECT, pSdrModel ) ) + , m_bRestoreMapMode( false ) +{ + // #114898# + SetBufferedOutputAllowed(true); + SetBufferedOverlayAllowed(true); + + SetPagePaintingAllowed(bPaintPageForEditMode); + + ReInit(); +} + +void DrawViewWrapper::ReInit() +{ + OutputDevice* pOutDev = this->GetFirstOutputDevice(); + Size aOutputSize(100,100); + if(pOutDev) + aOutputSize = pOutDev->GetOutputSize(); + + bPageVisible = false; + bPageBorderVisible = false; + bBordVisible = false; + bGridVisible = false; + bHlplVisible = false; + + this->SetNoDragXorPolys(true);//for interactive 3D resize-dragging: paint only a single rectangle (not a simulated 3D object) + //this->SetResizeAtCenter(true);//for interactive resize-dragging: keep the object center fix + + //a correct work area is at least necessary for correct values in the position and size dialog + Rectangle aRect(Point(0,0), aOutputSize); + this->SetWorkArea(aRect); + + this->ShowSdrPage(this->GetModel()->GetPage(0)); +} + +DrawViewWrapper::~DrawViewWrapper() +{ + aComeBackTimer.Stop();//@todo this should be done in destructor of base class + UnmarkAllObj();//necessary to aavoid a paint call during the destructor hierarchy +} + +SdrPageView* DrawViewWrapper::GetPageView() const +{ + SdrPageView* pSdrPageView = this->GetSdrPageView(); + return pSdrPageView; +}; + +//virtual +void DrawViewWrapper::SetMarkHandles() +{ + if( m_pMarkHandleProvider && m_pMarkHandleProvider->getMarkHandles( aHdl ) ) + return; + else + SdrView::SetMarkHandles(); +} + +SdrObject* DrawViewWrapper::getHitObject( const Point& rPnt ) const +{ + SdrObject* pRet = NULL; + //ULONG nOptions =SDRSEARCH_DEEP|SDRSEARCH_PASS2BOUND|SDRSEARCH_PASS3NEAREST; + ULONG nOptions = SDRSEARCH_DEEP | SDRSEARCH_TESTMARKABLE; + + SdrPageView* pSdrPageView = this->GetPageView(); + this->SdrView::PickObj(rPnt, lcl_getHitTolerance( this->GetFirstOutputDevice() ), pRet, pSdrPageView, nOptions); + + if( pRet ) + { + //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); + if( pE3d ) + { + E3dScene* pScene = pE3d->GetScene(); + if( pScene ) + { + // prepare result vector and call helper + ::std::vector< const E3dCompoundObject* > aHitList; + const basegfx::B2DPoint aHitPoint(rPnt.X(), rPnt.Y()); + getAllHit3DObjectsSortedFrontToBack(aHitPoint, *pScene, aHitList); + + if(aHitList.size()) + { + // choose the frontmost hit 3D object of the scene + pRet = const_cast< E3dCompoundObject* >(aHitList[0]); + } + } + } + } + return pRet; +} + +void DrawViewWrapper::MarkObject( SdrObject* pObj ) +{ + bool bFrameDragSingles = true;//true == green == surrounding handles + if(pObj) + pObj->SetMarkProtect(false); + if( m_pMarkHandleProvider ) + bFrameDragSingles = m_pMarkHandleProvider->getFrameDragSingles(); + + this->SetFrameDragSingles(bFrameDragSingles);//decide wether each single object should get handles + this->SdrView::MarkObj( pObj, this->GetPageView() ); + this->showMarkHandles(); +} + + +void DrawViewWrapper::setMarkHandleProvider( MarkHandleProvider* pMarkHandleProvider ) +{ + m_pMarkHandleProvider = pMarkHandleProvider; +} + +void DrawViewWrapper::CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* /* pRedirector */) +{ + svtools::ColorConfig aColorConfig; + Color aFillColor = Color( aColorConfig.GetColorValue( svtools::DOCCOLOR ).nColor ); + this->SetApplicationBackgroundColor(aFillColor); + this->E3dView::CompleteRedraw( pOut, rReg ); +} + +SdrObject* DrawViewWrapper::getSelectedObject() const +{ + SdrObject* pObj(NULL); + const SdrMarkList& rMarkList = this->GetMarkedObjectList(); + if(rMarkList.GetMarkCount() == 1) + { + SdrMark* pMark = rMarkList.GetMark(0); + pObj = pMark->GetMarkedSdrObj(); + } + return pObj; +} + +SdrObject* DrawViewWrapper::getTextEditObject() const +{ + SdrObject* pObj = this->getSelectedObject(); + SdrObject* pTextObj = NULL; + if( pObj && pObj->HasTextEdit()) + pTextObj = (SdrTextObj*)pObj; + return pTextObj; +} + +void DrawViewWrapper::attachParentReferenceDevice( const uno::Reference< frame::XModel > & xChartModel ) +{ + OutputDevice * pParentRefDev( lcl_GetParentRefDevice( xChartModel )); + SdrOutliner * pOutliner( getOutliner()); + if( pParentRefDev && pOutliner ) + { + pOutliner->SetRefDevice( pParentRefDev ); + } +} + +SdrOutliner* DrawViewWrapper::getOutliner() const +{ +// lcl_initOutliner( m_apOutliner.get(), &GetModel()->GetDrawOutliner() ); + return m_apOutliner.get(); +} + +SfxItemSet DrawViewWrapper::getPositionAndSizeItemSetFromMarkedObject() const +{ + SfxItemSet aFullSet( GetModel()->GetItemPool(), + SID_ATTR_TRANSFORM_POS_X,SID_ATTR_TRANSFORM_ANGLE, + SID_ATTR_TRANSFORM_PROTECT_POS,SID_ATTR_TRANSFORM_AUTOHEIGHT, + SDRATTR_ECKENRADIUS,SDRATTR_ECKENRADIUS, + SID_ATTR_METRIC,SID_ATTR_METRIC, + 0); + SfxItemSet aGeoSet( E3dView::GetGeoAttrFromMarked() ); + aFullSet.Put( aGeoSet ); + aFullSet.Put( SfxUInt16Item(SID_ATTR_METRIC,static_cast< sal_uInt16 >( ConfigurationAccess::getFieldUnit()))); + return aFullSet; +} + +SdrObject* DrawViewWrapper::getNamedSdrObject( const rtl::OUString& rName ) const +{ + if(rName.getLength()==0) + return 0; + SdrPageView* pSdrPageView = this->GetPageView(); + if( pSdrPageView ) + { + return DrawModelWrapper::getNamedSdrObject( rName, pSdrPageView->GetObjList() ); + } + return 0; +} + +bool DrawViewWrapper::IsObjectHit( SdrObject* pObj, const Point& rPnt ) const +{ + if(pObj) + { + Rectangle aRect(pObj->GetCurrentBoundRect()); + return aRect.IsInside(rPnt); + } + return false; +} + +void DrawViewWrapper::Notify(SfxBroadcaster& rBC, const SfxHint& rHint) +{ + //prevent wrong reselection of objects + SdrModel* pSdrModel( this->GetModel() ); + if( pSdrModel && pSdrModel->isLocked() ) + return; + + const SdrHint* pSdrHint = dynamic_cast< const SdrHint* >( &rHint ); + + //#i76053# do nothing when only changes on the hidden draw page were made ( e.g. when the symbols for the dialogs are created ) + SdrPageView* pSdrPageView = this->GetPageView(); + if( pSdrHint && pSdrPageView ) + { + if( pSdrPageView->GetPage() != pSdrHint->GetPage() ) + return; + } + + E3dView::Notify(rBC, rHint); + + if( pSdrHint != 0 ) + { + SdrHintKind eKind = pSdrHint->GetKind(); + if( eKind == HINT_BEGEDIT ) + { + // #i79965# remember map mode + OSL_ASSERT( ! m_bRestoreMapMode ); + OutputDevice* pOutDev = this->GetFirstOutputDevice(); + if( pOutDev ) + { + m_aMapModeToRestore = pOutDev->GetMapMode(); + m_bRestoreMapMode = true; + } + } + else if( eKind == HINT_ENDEDIT ) + { + // #i79965# scroll back view when ending text edit + OSL_ASSERT( m_bRestoreMapMode ); + if( m_bRestoreMapMode ) + { + OutputDevice* pOutDev = this->GetFirstOutputDevice(); + if( pOutDev ) + { + pOutDev->SetMapMode( m_aMapModeToRestore ); + m_bRestoreMapMode = false; + } + } + } + } +} + +//static +SdrObject* DrawViewWrapper::getSdrObject( const uno::Reference< + drawing::XShape >& xShape ) +{ + SdrObject* pRet = 0; + uno::Reference< lang::XUnoTunnel > xUnoTunnel( xShape, uno::UNO_QUERY ); + uno::Reference< lang::XTypeProvider > xTypeProvider( xShape, uno::UNO_QUERY ); + if(xUnoTunnel.is()&&xTypeProvider.is()) + { + SvxShape* pSvxShape = reinterpret_cast<SvxShape*>(xUnoTunnel->getSomething( SvxShape::getUnoTunnelId() )); + if(pSvxShape) + pRet = pSvxShape->GetSdrObject(); + } + return pRet; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx new file mode 100644 index 000000000000..92b37e8b4195 --- /dev/null +++ b/chart2/source/controller/drawinglayer/ViewElementListProvider.cxx @@ -0,0 +1,277 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ViewElementListProvider.cxx,v $ + * $Revision: 1.13 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ViewElementListProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "chartview/DataPointSymbolSupplier.hxx" +#include "macros.hxx" +#include "DrawViewWrapper.hxx" +#include <svx/xtable.hxx> +#include <svx/XPropertyTable.hxx> +#include <svx/unofill.hxx> +#include <svx/unoapi.hxx> + +// header for class NameOrIndex +#include <svx/xit.hxx> +// header for class XFillBitmapItem +#include <svx/xbtmpit.hxx> +#include <svx/xflftrit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xflhtit.hxx> +#include <svx/xflgrit.hxx> +// header for class XLineStartItem +#include <svx/xlnstit.hxx> +// header for class XLineEndItem +#include <svx/xlnedit.hxx> + +//------------ +//oldChartModelWrapper + +// header for class SfxItemPool +#include <svtools/itempool.hxx> +// header for class FontList +#include <svtools/ctrltool.hxx> +// header for class Application +#include <vcl/svapp.hxx> +//------------ +// header for class SdrObject +#include <svx/svdobj.hxx> + + +//--------------- +//for creation of a symbol Graphic +// header for class VirtualDevice +#include <vcl/virdev.hxx> +// header for class SdrView +#include <svx/svdview.hxx> +//--------------- + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +ViewElementListProvider::ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper ) + : m_pDrawModelWrapper( pDrawModelWrapper ) + , m_pFontList(NULL) +{ +} + +ViewElementListProvider::~ViewElementListProvider() +{ + if(m_pFontList) + delete m_pFontList; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +XColorTable* ViewElementListProvider::GetColorTable() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetColorTable(); + return NULL; +} +XDashList* ViewElementListProvider::GetDashList() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetDashList(); + return NULL; +} +XLineEndList* ViewElementListProvider::GetLineEndList() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetLineEndList(); + return NULL; +} +XGradientList* ViewElementListProvider::GetGradientList() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetGradientList(); + return NULL; +} +XHatchList* ViewElementListProvider::GetHatchList() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetHatchList(); + return NULL; +} +XBitmapList* ViewElementListProvider::GetBitmapList() const +{ + if(m_pDrawModelWrapper) + return m_pDrawModelWrapper->GetBitmapList(); + return NULL; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//create chartspecific symbols for linecharts +SdrObjList* ViewElementListProvider::GetSymbolList() const +{ + SdrObjList* m_pSymbolList = NULL; + uno::Reference< drawing::XShapes > m_xSymbols(NULL);//@todo this keeps the first drawinglayer alive ... + try + { + if(!m_pSymbolList || !m_pSymbolList->GetObjCount()) + { + //@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(), uno::UNO_QUERY ); + + //create symbols via uno and convert to native sdr objects + drawing::Direction3D aSymbolSize(220,220,0); // should be 250, but 250 -> 280 ?? + m_xSymbols = DataPointSymbolSupplier::create2DSymbolList( xShapeFactory, xTarget, aSymbolSize ); + + SdrObject* pSdrObject = DrawViewWrapper::getSdrObject( uno::Reference< drawing::XShape >( m_xSymbols, uno::UNO_QUERY ) ); + if(pSdrObject) + m_pSymbolList = pSdrObject->GetSubList(); + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + return m_pSymbolList; +} + +Graphic ViewElementListProvider::GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const +{ + SdrObjList* pSymbolList = this->GetSymbolList(); + if( !pSymbolList->GetObjCount() ) + return Graphic(); + if(nStandardSymbol<0) + nStandardSymbol*=-1; + if( nStandardSymbol >= static_cast<sal_Int32>(pSymbolList->GetObjCount()) ) + nStandardSymbol %= pSymbolList->GetObjCount(); + SdrObject* pObj = pSymbolList->GetObj(nStandardSymbol); + + VirtualDevice aVDev; + aVDev.SetMapMode(MapMode(MAP_100TH_MM)); + SdrModel* pModel = new SdrModel(); + pModel->GetItemPool().FreezeIdRanges(); + SdrPage* pPage = new SdrPage( *pModel, FALSE ); + pPage->SetSize(Size(1000,1000)); + pModel->InsertPage( pPage, 0 ); + SdrView* pView = new SdrView( pModel, &aVDev ); + pView->hideMarkHandles(); + SdrPageView* pPageView = pView->ShowSdrPage(pPage); + + pObj=pObj->Clone(); + pPage->NbcInsertObject(pObj); + pView->MarkObj(pObj,pPageView); + if( pSymbolShapeProperties ) + pObj->SetMergedItemSet(*pSymbolShapeProperties); + + GDIMetaFile aMeta(pView->GetAllMarkedMetaFile()); + + Graphic aGraph(aMeta); + Size aSize = pObj->GetSnapRect().GetSize(); + aGraph.SetPrefSize(aSize); + aGraph.SetPrefMapMode(MAP_100TH_MM); + + pView->UnmarkAll(); + pObj=pPage->RemoveObject(0); + SdrObject::Free( pObj ); + delete pView; + delete pModel; + + return aGraph; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +FontList* ViewElementListProvider::getFontList() const +{ + //was old chart: + //SvxFontListItem* SfxObjectShell::.GetItem(SID_ATTR_CHAR_FONTLIST) + + if(!m_pFontList) + { + OutputDevice* pRefDev = m_pDrawModelWrapper ? m_pDrawModelWrapper->getReferenceDevice() : NULL; + OutputDevice* pDefaultOut = Application::GetDefaultDevice(); // #67730# + m_pFontList = new FontList( pRefDev ? pRefDev : pDefaultOut + , pRefDev ? pDefaultOut : NULL + , FALSE ); + } + return m_pFontList; +} + +/* +SfxPrinter* ObjectPropertiesDialogParameter::getPrinter() +{ + //was old chart: + //SfxPrinter* SchChartDocShell::GetPrinter() + + // OLE-Objekt: kein Printer anlegen ??? see old chart: :UpdateTablePointers + //@todo get printer from calc or other container + //return NULL; + + SfxPrinter* pPrinter = NULL; + bool bOwnPrinter = true; + if (!pPrinter) + { + SfxBoolItem aItem(SID_PRINTER_NOTFOUND_WARN, TRUE); + // ItemSet mit speziellem Poolbereich anlegen + SfxItemSet* pSet = new SfxItemSet(GetPool(), + SID_PRINTER_NOTFOUND_WARN, + SID_PRINTER_NOTFOUND_WARN, 0); + pSet->Put(aItem); + pPrinter = new SfxPrinter(pSet); //@todo ->need to remember and delete + bOwnPrinter = TRUE; + + MapMode aMapMode = pPrinter->GetMapMode(); + aMapMode.SetMapUnit(MAP_100TH_MM); + pPrinter->SetMapMode(aMapMode); + + if (pChDoc) + { + if (pPrinter != pChDoc->GetRefDevice()) + pChDoc->SetRefDevice(pPrinter); + + if (pPrinter != pChDoc->GetOutliner()->GetRefDevice()) + pChDoc->GetOutliner()->SetRefDevice(pPrinter); + } + } + return pPrinter; +} +*/ + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/drawinglayer/makefile.mk b/chart2/source/controller/drawinglayer/makefile.mk new file mode 100644 index 000000000000..0293bb4b460b --- /dev/null +++ b/chart2/source/controller/drawinglayer/makefile.mk @@ -0,0 +1,53 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.4 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcdrawinglayer + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES= $(SLO)$/DrawViewWrapper.obj \ + $(SLO)$/ViewElementListProvider.obj + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk + diff --git a/chart2/source/controller/inc/AccessibleBase.hxx b/chart2/source/controller/inc/AccessibleBase.hxx new file mode 100644 index 000000000000..c7101385da0d --- /dev/null +++ b/chart2/source/controller/inc/AccessibleBase.hxx @@ -0,0 +1,372 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleBase.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_ACCESSIBLEBASE_HXX_ +#define _CHART2_ACCESSIBLEBASE_HXX_ + +#include <com/sun/star/chart2/XChartDocument.hpp> +#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/document/XEventListener.hpp> +#include <com/sun/star/lang/XEventListener.hpp> +#include <com/sun/star/lang/DisposedException.hpp> +#include <com/sun/star/accessibility/XAccessibleEventBroadcaster.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <comphelper/accessibleeventnotifier.hxx> +#include <cppuhelper/compbase6.hxx> +#include <cppuhelper/interfacecontainer.hxx> +#include <unotools/accessiblestatesethelper.hxx> + +#include <vector> +#include <map> +#include <boost/shared_ptr.hpp> + +#include "MutexContainer.hxx" + +class SfxItemSet; +class SdrObject; + +namespace chart +{ + +class AccessibleBase; +class ObjectHierarchy; + +typedef rtl::OUString AccessibleUniqueId; + +struct AccessibleElementInfo +{ + AccessibleUniqueId m_aCID; + + ::com::sun::star::uno::WeakReference< + ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface > m_xView; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::awt::XWindow > m_xWindow; + + ::boost::shared_ptr< ObjectHierarchy > m_spObjectHierarchy; + + AccessibleBase * m_pParent; +}; + + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper6< + ::com::sun::star::accessibility::XAccessible, + ::com::sun::star::accessibility::XAccessibleContext, + ::com::sun::star::accessibility::XAccessibleComponent, + ::com::sun::star::accessibility::XAccessibleEventBroadcaster, + ::com::sun::star::lang::XServiceInfo, + ::com::sun::star::lang::XEventListener + > AccessibleBase_Base; +} + +/** Base class for all Chart Accessibility objects + */ +class AccessibleBase : + public MutexContainer, + public impl::AccessibleBase_Base +{ +public: + enum EventType + { + OBJECT_CHANGE, + GOT_SELECTION, + LOST_SELECTION, + PROPERTY_CHANGE + }; + + AccessibleBase( const AccessibleElementInfo & rAccInfo, + bool bMayHaveChildren, + bool bAlwaysTransparent = false ); + virtual ~AccessibleBase(); + +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 + */ + bool CheckDisposeState( bool bThrowException = true ) const throw (::com::sun::star::lang::DisposedException); + + /** 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 + this method in derived classes. + + The default implementation iterates over all children and forwards the + event until the first child returns true. + + @param nObjId contains the object id of chart objects. If the object is + no chart object, the event is not broadcast. + @return If an object is the addressee of the event it should return + true, false otherwise. + */ + virtual bool NotifyEvent( EventType eType, const AccessibleUniqueId & rId ); + + /** Adds a state to the set. + */ + void AddState( sal_Int16 aState ) throw (::com::sun::star::uno::RuntimeException); + + /** Removes a state from the set if the set contains the state, otherwise + nothing is done. + */ + void RemoveState( sal_Int16 aState ) throw (::com::sun::star::uno::RuntimeException); + + /** has to be overloaded by derived classes that support child elements. + With this method a rescan is initiated that should result in a correct + list of children. + + This method is called when access to any methods concerning children is + invoked for the first time. + */ + bool UpdateChildren(); + + /** Is called by UpdateChildren. This method is only called if an update is + really necessary. + */ + virtual bool ImplUpdateChildren(); + + /** adds a child to the end of the internal vector of children. As a + result, the child-count increases by one, but all existing children keep + their indices. + + Important: as the implementation is needed, this should remain the only + method for adding children (i.e. there mustn't be an AddChild( Reference< + XAccessible > ) or the like). + */ + void AddChild( AccessibleBase* pChild ); + + /** removes a child from the internal vector. All children with index + greater than the index of the removed element get an index one less than + before. + */ + void RemoveChildById( const ::rtl::OUString & rId ); + + /** Retrieve the pixel coordinates of logical coordinates (0,0) of the + current logic coordinate system. This can be used for + getLocationOnScreen, if the coordinates of an object are not relative to + its direct parent, but a parent higher up in hierarchy. + + @return the (x,y) pixel coordinates of the upper left corner + */ + virtual ::com::sun::star::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 ::com::sun::star::uno::Any & rNew, + const ::com::sun::star::uno::Any & rOld, + bool bSendGlobally = false ) const; + + /** Removes all children from the internal lists and broadcasts child remove + events. + + This method cares about mutex locking, and thus should be called without + the mutex locked. + */ + virtual void KillAllChildren(); + + /** Is called from getAccessibleChild(). Before this method is called, an + update of children is done if necessary. + */ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > + ImplGetAccessibleChildById( sal_Int32 i ) const + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + + /** Is called from getAccessibleChildCount(). Before this method is called, + an update of children is done if necessary. + */ + virtual sal_Int32 ImplGetAccessibleChildCount() const + throw (::com::sun::star::uno::RuntimeException); + + AccessibleElementInfo GetInfo() const; + void SetInfo( const AccessibleElementInfo & rNewInfo ); + AccessibleUniqueId GetId() const; + + // ________ WeakComponentImplHelper (XComponent::dispose) ________ + virtual void SAL_CALL disposing(); + + // ________ XAccessible ________ + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > SAL_CALL getAccessibleContext() + throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleContext ________ + virtual sal_Int32 SAL_CALL getAccessibleChildCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleChild( sal_Int32 i ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleParent() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw (::com::sun::star::uno::RuntimeException); + /// @return AccessibleRole.SHAPE + virtual sal_Int16 SAL_CALL getAccessibleRole() + throw (::com::sun::star::uno::RuntimeException); + // has to be implemented by derived classes +// virtual ::rtl::OUString SAL_CALL getAccessibleName() +// throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL + getAccessibleRelationSet() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL + getAccessibleStateSet() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() + throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, + ::com::sun::star::uno::RuntimeException); + // has to be implemented by derived classes +// virtual ::rtl::OUString SAL_CALL getAccessibleDescription() +// throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleComponent ________ + virtual sal_Bool SAL_CALL containsPoint( + const ::com::sun::star::awt::Point& aPoint ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL + getAccessibleAtPoint( const ::com::sun::star::awt::Point& aPoint ) + throw (::com::sun::star::uno::RuntimeException); + // has to be defined in derived classes + virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL getLocation() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Size SAL_CALL getSize() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL grabFocus() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getForeground() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getBackground() + throw (::com::sun::star::uno::RuntimeException); + + // ________ XServiceInfo ________ + virtual ::rtl::OUString SAL_CALL getImplementationName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL supportsService( + const ::rtl::OUString& ServiceName ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // ________ XEventListener ________ + virtual void SAL_CALL disposing( + const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + using ::cppu::WeakComponentImplHelperBase::addEventListener; + using ::cppu::WeakComponentImplHelperBase::removeEventListener; + + // ________ XAccessibleEventBroadcaster ________ + virtual void SAL_CALL addEventListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + +private: + enum eColorType + { + ACC_BASE_FOREGROUND, + ACC_BASE_BACKGROUND + }; + sal_Int32 getColor( eColorType eColType ); + +private: + typedef ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessible > tAccessible; + /** type of the vector containing the accessible children + */ + typedef ::std::vector< tAccessible > ChildListVectorType; + /** type of the hash containing a vector index for every AccessibleUniqueId + of the object in the child list + */ + typedef ::std::map< ::rtl::OUString, tAccessible > ChildCIDMap; + + bool m_bIsDisposed; + const bool m_bMayHaveChildren; + bool m_bChildrenInitialized; + ChildListVectorType m_aChildList; + + ChildCIDMap m_aChildCIDMap; + + ::comphelper::AccessibleEventNotifier::TClientId m_nEventNotifierId; + + /** Implementation helper for getAccessibleStateSet() + + Note: This member must come before m_aStateSet! + */ + ::utl::AccessibleStateSetHelper * m_pStateSetHelper; + /** this is returned in getAccessibleStateSet(). + + The implementation is an ::utl::AccessibleStateSetHelper. To access + implementation methods use m_pStateSetHelper. + + Note: Keeping this reference ensures, that the helper object is only + destroyed after this object has been disposed(). + */ + ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > + m_aStateSet; + + AccessibleElementInfo m_aAccInfo; + const bool m_bAlwaysTransparent; + /** denotes if the state-set is initialized. On initialization the selected + state is checked. + + This variable is monitored by the solar mutex! + + Note: declared volatile to enable double-check-locking + */ + volatile bool m_bStateSetInitialized; +}; + +} // namespace chart + +#endif diff --git a/chart2/source/controller/inc/AccessibleChartView.hxx b/chart2/source/controller/inc/AccessibleChartView.hxx new file mode 100644 index 000000000000..22d5f7a41252 --- /dev/null +++ b/chart2/source/controller/inc/AccessibleChartView.hxx @@ -0,0 +1,156 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleChartView.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_ACCESSIBLE_CHART_VIEW_HXX +#define _CHART2_ACCESSIBLE_CHART_VIEW_HXX + +#include "AccessibleBase.hxx" +#include "MutexContainer.hxx" +#include "ServiceMacros.hxx" +#include <cppuhelper/implbase2.hxx> +// header for class WeakReference +#include <cppuhelper/weakref.hxx> +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/view/XSelectionChangeListener.hpp> +#include <com/sun/star/awt/XWindow.hpp> + +#include <boost/shared_ptr.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ExplicitValueProvider; +class ObjectHierarchy; + +namespace impl +{ +typedef ::cppu::ImplInheritanceHelper2< + ::chart::AccessibleBase, + ::com::sun::star::lang::XInitialization, + ::com::sun::star::view::XSelectionChangeListener > + AccessibleChartView_Base; +} + +class AccessibleChartView : + public impl::AccessibleChartView_Base +{ +public: + AccessibleChartView( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~AccessibleChartView(); + + // ____ lang::XServiceInfo ____ + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER( AccessibleChartView ) + +protected: + // ____ WeakComponentHelper (called from XComponent::dispose()) ____ + virtual void SAL_CALL disposing(); + + // ____ 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) + // all arguments are only valid until next initialization - don't keep them longer + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + + // ____ view::XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException); + + // ________ XEventListener ________ + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleContext ________ + virtual ::rtl::OUString SAL_CALL getAccessibleDescription() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleName() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL getAccessibleRole() + throw (::com::sun::star::uno::RuntimeException); + + // ________ XAccessibleComponent ________ + virtual ::com::sun::star::awt::Rectangle SAL_CALL getBounds() throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::awt::Point SAL_CALL getLocationOnScreen() throw (::com::sun::star::uno::RuntimeException); + + // ________ AccessibleChartElement ________ + virtual ::com::sun::star::awt::Point GetUpperLeftOnScreen() const; + +private: // methods + /** @return the result that m_xWindow->getPosSize() _should_ return. It + returns (0,0) as upper left corner. When calling + getAccessibleParent, you get the parent's parent, which contains + a decoration. Thus you have an offset of (currently) (2,2) + which isn't taken into account. + */ + virtual ::com::sun::star::awt::Rectangle GetWindowPosSize() const; + + ExplicitValueProvider* getExplicitValueProvider(); + +private: // members + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xContext; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XModel > m_xChartModel; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::uno::XInterface > m_xChartView; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::awt::XWindow > m_xWindow; + ::com::sun::star::uno::WeakReference< + ::com::sun::star::accessibility::XAccessible > m_xParent; + + ::boost::shared_ptr< ObjectHierarchy > m_spObjectHierarchy; + AccessibleUniqueId m_aCurrentSelectionCID; + + //no default constructor + AccessibleChartView(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/AccessibleTextHelper.hxx b/chart2/source/controller/inc/AccessibleTextHelper.hxx new file mode 100644 index 000000000000..e4ee4506e2bc --- /dev/null +++ b/chart2/source/controller/inc/AccessibleTextHelper.hxx @@ -0,0 +1,116 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AccessibleTextHelper.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_ACCESSIBLETEXTHELPER_HXX +#define CHART2_ACCESSIBLETEXTHELPER_HXX + +#include "MutexContainer.hxx" +#include <cppuhelper/compbase2.hxx> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/accessibility/XAccessibleContext.hpp> + +// forward declaration of helper class from svx +namespace accessibility +{ +class AccessibleTextHelper; +} + +namespace chart +{ + +class DrawViewWrapper; + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper2< + ::com::sun::star::lang::XInitialization, + ::com::sun::star::accessibility::XAccessibleContext > + AccessibleTextHelper_Base; +} + +class AccessibleTextHelper : + public MutexContainer, + public impl::AccessibleTextHelper_Base +{ +public: + explicit AccessibleTextHelper( DrawViewWrapper * pDrawViewWrapper ); + virtual ~AccessibleTextHelper(); + + // ____ 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 + the corresponding drawing object that contains the text that should + be handled by this helper class. +1 + 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 + text currently. + */ + virtual void SAL_CALL initialize( + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + + // ____ XAccessibleContext ____ + virtual ::sal_Int32 SAL_CALL getAccessibleChildCount() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleChild( + ::sal_Int32 i ) + throw (::com::sun::star::lang::IndexOutOfBoundsException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > SAL_CALL getAccessibleParent() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int32 SAL_CALL getAccessibleIndexInParent() + throw (::com::sun::star::uno::RuntimeException); + virtual ::sal_Int16 SAL_CALL getAccessibleRole() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleDescription() + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getAccessibleName() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleRelationSet > SAL_CALL getAccessibleRelationSet() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessibleStateSet > SAL_CALL getAccessibleStateSet() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::lang::Locale SAL_CALL getLocale() + throw (::com::sun::star::accessibility::IllegalAccessibleComponentStateException, + ::com::sun::star::uno::RuntimeException); + +private: + ::accessibility::AccessibleTextHelper * m_pTextHelper; + DrawViewWrapper * m_pDrawViewWrapper; +}; + +} // namespace chart + +// CHART2_ACCESSIBLETEXTHELPER_HXX +#endif diff --git a/chart2/source/controller/inc/AxisItemConverter.hxx b/chart2/source/controller/inc/AxisItemConverter.hxx new file mode 100644 index 000000000000..f4205bf4aeed --- /dev/null +++ b/chart2/source/controller/inc/AxisItemConverter.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AxisItemConverter.hxx,v $ + * $Revision: 1.9 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_AXISITEMCONVERTER_HXX +#define CHART_AXISITEMCONVERTER_HXX + +#include <com/sun/star/chart2/ExplicitScaleData.hpp> +#include <com/sun/star/chart2/ExplicitIncrementData.hpp> +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/awt/Size.hpp> + +#include "ItemConverter.hxx" + +#include <vector> +#include <memory> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class AxisItemConverter : public ::comphelper::ItemConverter +{ +public: + AxisItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc, + ::com::sun::star::chart2::ExplicitScaleData * pScale = NULL, + ::com::sun::star::chart2::ExplicitIncrementData * pIncrement = NULL, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~AxisItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XAxis > m_xAxis; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDoc; + + ::com::sun::star::chart2::ExplicitScaleData * m_pExplicitScale; + ::com::sun::star::chart2::ExplicitIncrementData * m_pExplicitIncrement; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_AXISITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx new file mode 100644 index 000000000000..8b184f5492f2 --- /dev/null +++ b/chart2/source/controller/inc/CharacterPropertyItemConverter.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CharacterPropertyItemConverter.hxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_CHARACTERPROPERTYITEMCONVERTER_HXX +#define CHART_CHARACTERPROPERTYITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/awt/Size.hpp> + +#include <memory> + +namespace chart +{ +namespace wrapper +{ + +class CharacterPropertyItemConverter : + public ::comphelper::ItemConverter +{ +public: + CharacterPropertyItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ); + CharacterPropertyItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize, + const ::rtl::OUString & rRefSizePropertyName, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rRefSizePropSet = + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >() ); + virtual ~CharacterPropertyItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > GetRefSizePropertySet() const; + +private: + ::std::auto_ptr< ::com::sun::star::awt::Size > m_pRefSize; + ::rtl::OUString m_aRefSizePropertyName; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > m_xRefSizePropSet; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_CHARACTERPROPERTYITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/ChartDocumentWrapper.hxx b/chart2/source/controller/inc/ChartDocumentWrapper.hxx new file mode 100644 index 000000000000..603bf9982744 --- /dev/null +++ b/chart2/source/controller/inc/ChartDocumentWrapper.hxx @@ -0,0 +1,238 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDocumentWrapper.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_CHARTDOCUMENTWRAPPER_HXX +#define CHART_CHARTDOCUMENTWRAPPER_HXX + +#include "WrappedPropertySet.hxx" +//#include "OPropertySet.hxx" +#include "ServiceMacros.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart/XChartDocument.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/uno/XAggregation.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/util/XRefreshable.hpp> +#include <cppuhelper/implbase5.hxx> +#include <osl/mutex.hxx> +#include <unotools/eventlisteneradapter.hxx> +#include <comphelper/uno3.hxx> + +#include <boost/shared_ptr.hpp> + +namespace chart +{ + +namespace wrapper +{ + +class Chart2ModelContact; + +class ChartDocumentWrapper_Base : public ::cppu::ImplInheritanceHelper5 + < WrappedPropertySet + , ::com::sun::star::chart::XChartDocument + , ::com::sun::star::drawing::XDrawPageSupplier + , ::com::sun::star::lang::XMultiServiceFactory + , ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::uno::XAggregation + > +{ +}; + +class ChartDocumentWrapper : public ChartDocumentWrapper_Base + , public ::utl::OEventListenerAdapter +{ +public: + explicit ChartDocumentWrapper( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~ChartDocumentWrapper(); + + /// XServiceInfo declarations + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(ChartDocumentWrapper) + + void setAddIn( const ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable >& xAddIn ); + ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable > getAddIn() const; + + void setUpdateAddIn( sal_Bool bUpdateAddIn ); + sal_Bool getUpdateAddIn() const; + + void setBaseDiagram( const rtl::OUString& rBaseDiagram ); + rtl::OUString getBaseDiagram() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShapes > getAdditionalShapes() const; + + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPage > impl_getDrawPage() const + throw (::com::sun::star::uno::RuntimeException); + +protected: + + // ____ chart::XChartDocument ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getSubTitle() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > SAL_CALL getLegend() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > SAL_CALL getArea() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XDiagram > SAL_CALL getDiagram() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setDiagram( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XDiagram >& xDiagram ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XChartData > SAL_CALL getData() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL attachData( const ::com::sun::star::uno::Reference< + ::com::sun::star::chart::XChartData >& xData ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XModel ____ + virtual sal_Bool SAL_CALL attachResource( const ::rtl::OUString& URL, const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::rtl::OUString SAL_CALL getURL() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue > SAL_CALL getArgs() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL connectController( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController >& Controller ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL disconnectController( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController >& Controller ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL lockControllers() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL unlockControllers() + throw (::com::sun::star::uno::RuntimeException); + virtual sal_Bool SAL_CALL hasControllersLocked() + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController > SAL_CALL getCurrentController() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setCurrentController( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController >& Controller ) + throw (::com::sun::star::container::NoSuchElementException, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > SAL_CALL getCurrentSelection() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XComponent ____ + virtual void SAL_CALL dispose() + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener >& aListener ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XInterface (for new interfaces) ____ + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ ::utl::OEventListenerAdapter ____ + virtual void _disposing( const ::com::sun::star::lang::EventObject& rSource ); + + // ____ XDrawPageSupplier ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XDrawPage > SAL_CALL getDrawPage() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XMultiServiceFactory ____ + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > SAL_CALL createInstance( const ::rtl::OUString& aServiceSpecifier ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > SAL_CALL createInstanceWithArguments( + const ::rtl::OUString& ServiceSpecifier, + const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& Arguments ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< + ::rtl::OUString > SAL_CALL getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + // ____ XAggregation ____ + virtual void SAL_CALL setDelegator( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface >& rDelegator ) + throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type& aType ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ WrappedPropertySet ____ + virtual const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::Property >& getPropertySequence(); + virtual const std::vector< WrappedProperty* > createWrappedProperties(); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > getInnerPropertySet(); + +private: //methods + void impl_resetAddIn(); + +private: //member + ::boost::shared_ptr< Chart2ModelContact > m_spChart2ModelContact; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xDelegator; + + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xTitle; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xSubTitle; + ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > m_xLegend; + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XChartData > m_xChartData; + ::com::sun::star::uno::Reference< ::com::sun::star::chart::XDiagram > m_xDiagram; + ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xArea; + + ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable > m_xAddIn; + rtl::OUString m_aBaseDiagram; + sal_Bool m_bUpdateAddIn; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > m_xChartView; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory> + m_xShapeFactory; + + bool m_bIsDisposed; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_CHARTDOCUMENT_HXX +#endif diff --git a/chart2/source/controller/inc/ChartRenderer.hxx b/chart2/source/controller/inc/ChartRenderer.hxx new file mode 100644 index 000000000000..0a2ec2cde87c --- /dev/null +++ b/chart2/source/controller/inc/ChartRenderer.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartRenderer.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_RENDERER_HXX +#define CHART_RENDERER_HXX + +#include <svtools/chartprettypainter.hxx> +#include "ServiceMacros.hxx" + +#include <cppuhelper/implbase2.hxx> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/lang/XUnoTunnel.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/weakref.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//#i82893#, #i75867#: charts must be painted resolution dependent!! +class ChartRenderer : public ::cppu::WeakImplHelper2< + ::com::sun::star::lang::XServiceInfo + , ::com::sun::star::lang::XUnoTunnel + >, public ChartPrettyPainter +{ +public: + ChartRenderer( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + virtual ~ChartRenderer(); + + // ___lang::XServiceInfo___ + APPHELPER_XSERVICEINFO_DECL() + + // ____ XUnoTunnel ___ + virtual ::sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< ::sal_Int8 >& aIdentifier ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ ChartPrettyPainter ___ + virtual bool DoPaint(OutputDevice* pOutDev, const Rectangle& rLogicObjectRect) const; + +private: + ChartRenderer(); + ChartRenderer( const ChartRenderer& ); + + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xChartModel; +}; + +//............................................................................. +} // namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/ConfigurationAccess.hxx b/chart2/source/controller/inc/ConfigurationAccess.hxx new file mode 100644 index 000000000000..02bdb7da8082 --- /dev/null +++ b/chart2/source/controller/inc/ConfigurationAccess.hxx @@ -0,0 +1,62 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ConfigurationAccess.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CONFIGURATIONACCESS_HXX +#define _CHART2_CONFIGURATIONACCESS_HXX + +// header for enum FieldUnit +#include <vcl/fldunit.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +namespace 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 +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/DataPointItemConverter.hxx b/chart2/source/controller/inc/DataPointItemConverter.hxx new file mode 100644 index 000000000000..4eec81bd20b5 --- /dev/null +++ b/chart2/source/controller/inc/DataPointItemConverter.hxx @@ -0,0 +1,113 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataPointItemConverter.hxx,v $ + * $Revision: 1.13 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_DATAPOINTITEMCONVERTER_HXX +#define CHART_DATAPOINTITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "chartview/NumberFormatterWrapper.hxx" + +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> +#include <vector> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class DataPointItemConverter : + public ::comphelper::ItemConverter +{ +public: + DataPointItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XDataSeries > & xSeries, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + NumberFormatterWrapper * pNumFormatter, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::eGraphicObjectType eMapTo = + GraphicPropertyItemConverter::FILLED_DATA_POINT, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >(), + bool bDataSeries = false, + bool bUseSpecialFillColor = false, + sal_Int32 nSpecialFillColor = 0, + bool bOverwriteLabelsForAttributedDataPointsAlso=false, + sal_Int32 nNumberFormat=0, + sal_Int32 nPercentNumberFormat=0); + + virtual ~DataPointItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; + NumberFormatterWrapper * m_pNumberFormatterWrapper; + bool m_bDataSeries; + bool m_bOverwriteLabelsForAttributedDataPointsAlso; + bool m_bColorPerPoint; + bool m_bUseSpecialFillColor; + sal_Int32 m_nSpecialFillColor; + sal_Int32 m_nNumberFormat; + sal_Int32 m_nPercentNumberFormat; + ::com::sun::star::uno::Sequence< sal_Int32 > m_aAvailableLabelPlacements; + bool m_bForbidPercentValue; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_DATAPOINTITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/DrawViewWrapper.hxx b/chart2/source/controller/inc/DrawViewWrapper.hxx new file mode 100644 index 000000000000..3709145db281 --- /dev/null +++ b/chart2/source/controller/inc/DrawViewWrapper.hxx @@ -0,0 +1,115 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DrawViewWrapper.hxx,v $ + * $Revision: 1.12 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DRAW_VIEW_WRAPPER_HXX +#define _CHART2_DRAW_VIEW_WRAPPER_HXX + +#include <svx/view3d.hxx> +#include <com/sun/star/drawing/XShape.hpp> +#include <com/sun/star/frame/XModel.hpp> + +class SdrModel; + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** The DrawViewWrapper should help us to reduce effort if the underlying DrawingLayer changes. +Another task is to hide functionality we do not need, for example more than one page. +*/ + +class MarkHandleProvider +{ +public: + virtual bool getMarkHandles( SdrHdlList& rHdlList ) =0; + virtual bool getFrameDragSingles() =0; +}; + +class DrawViewWrapper : public E3dView +{ +public: + DrawViewWrapper(SdrModel* pModel, OutputDevice* pOut, bool bPaintPageForEditMode); + virtual ~DrawViewWrapper(); + + //triggers the use of an updated first page + void ReInit(); + + /// tries to get an OutputDevice from the XParent of the model to use as reference device + void attachParentReferenceDevice( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xChartModel ); + + //fill list of selection handles 'aHdl' + virtual void SetMarkHandles(); + + SdrPageView* GetPageView() const; + + SdrObject* getHitObject( const Point& rPnt ) const; + //BOOL PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions, SdrObject** ppRootObj, ULONG* pnMarkNum=NULL, USHORT* pnPassNum=NULL) const; + //BOOL PickObj(const Point& rPnt, short nTol, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions=0) const; + //BOOL PickObj(const Point& rPnt, SdrObject*& rpObj, SdrPageView*& rpPV, ULONG nOptions=0) const { return PickObj(rPnt,nHitTolLog,rpObj,rpPV,nOptions); } + + //void MarkObj(SdrObject* pObj, SdrPageView* pPV, BOOL bUnmark=FALSE, BOOL bImpNoSetMarkHdl=FALSE); + void MarkObject( SdrObject* pObj ); + + //---------------------- + //pMarkHandleProvider can be NULL; ownership is not taken + void setMarkHandleProvider( MarkHandleProvider* pMarkHandleProvider ); + void CompleteRedraw(OutputDevice* pOut, const Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0); + + SdrObject* getSelectedObject() const; + SdrObject* getTextEditObject() const; + SdrOutliner* getOutliner() const; + + SfxItemSet getPositionAndSizeItemSetFromMarkedObject() const; + + SdrObject* getNamedSdrObject( const rtl::OUString& rName ) const; + bool IsObjectHit( SdrObject* pObj, const Point& rPnt ) const; + + virtual void Notify(SfxBroadcaster& rBC, const SfxHint& rHint); + + static SdrObject* getSdrObject( const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape >& xShape ); + +private: + mutable MarkHandleProvider* m_pMarkHandleProvider; + + ::std::auto_ptr< SdrOutliner > m_apOutliner; + + // #i79965# scroll back view when ending text edit + bool m_bRestoreMapMode; + MapMode m_aMapModeToRestore; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif + diff --git a/chart2/source/controller/inc/ErrorBarItemConverter.hxx b/chart2/source/controller/inc/ErrorBarItemConverter.hxx new file mode 100755 index 000000000000..9f78b89fdb5f --- /dev/null +++ b/chart2/source/controller/inc/ErrorBarItemConverter.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ErrorBarItemConverter.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_STATISTICSITEMCONVERTER_HXX +#define CHART_STATISTICSITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "chartview/NumberFormatterWrapper.hxx" + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vector> +#include <boost/shared_ptr.hpp> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class ErrorBarItemConverter : + public ::comphelper::ItemConverter +{ +public: + ErrorBarItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ); + virtual ~ErrorBarItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::boost::shared_ptr< ItemConverter > m_spGraphicConverter; + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xModel; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_STATISTICSITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx new file mode 100644 index 000000000000..f2dde8aa7b8f --- /dev/null +++ b/chart2/source/controller/inc/GraphicPropertyItemConverter.hxx @@ -0,0 +1,88 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: GraphicPropertyItemConverter.hxx,v $ + * $Revision: 1.7.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_GRAPHICPROPERTYITEMCONVERTER_HXX +#define CHART_GRAPHICPROPERTYITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/beans/PropertyState.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class GraphicPropertyItemConverter : + public ::comphelper::ItemConverter +{ +public: + enum eGraphicObjectType + { + FILLED_DATA_POINT, + LINE_DATA_POINT, + LINE_PROPERTIES, + FILL_PROPERTIES, + LINE_AND_FILL_PROPERTIES + }; + + GraphicPropertyItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + eGraphicObjectType eObjectType = FILLED_DATA_POINT ); + virtual ~GraphicPropertyItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + eGraphicObjectType m_eGraphicObjectType; + SdrModel & m_rDrawModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > m_xNamedPropertyTableFactory; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_GRAPHICPROPERTYITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/HelpIds.hrc b/chart2/source/controller/inc/HelpIds.hrc new file mode 100644 index 000000000000..ccff9e913f97 --- /dev/null +++ b/chart2/source/controller/inc/HelpIds.hrc @@ -0,0 +1,192 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: HelpIds.hrc,v $ + * $Revision: 1.8.56.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_HELPIDS_HRC +#define CHART_HELPIDS_HRC + +#include <svtools/solar.hrc> +//next is 120 + +//see old chart: schhids.h + +/* +#define HID_SCH_DATA_ROW (HID_SCH_START + 0) +#define HID_SCH_DATA_LINE (HID_SCH_START + 1) +#define HID_SCH_DATA_POINT (HID_SCH_START + 2) +#define HID_SCH_DIAGRAM_X_AXIS (HID_SCH_START + 3) +*/ +#define HID_SCH_ALIGNMENT (HID_SCH_START + 4) +#define HID_SCH_LEGEND_POS (HID_SCH_START + 5) +#define HID_SCH_DATA_DESCR (HID_SCH_START + 6) + +#define HID_SCH_STAT (HID_SCH_START + 8) +#define HID_SCH_WIN_DOCUMENT (HID_SCH_START + 9) +#define HID_SCH_CTL_DATA (HID_SCH_START + 10) + +#define HID_SCH_CT_INDICATE (HID_SCH_START + 11) +// #define HID_SCH_CT_REGRESS (HID_SCH_START + 12) + +//for chart type dialog: +#define HID_SCH_CTL_TYPE (HID_SCH_START + 13) +#define HID_SCH_CTL_VARIANT (HID_SCH_START + 14) +#define HID_SCH_NUM_OF_LINES (HID_SCH_START + 43) +#define HID_SCH_SERIES_LIST (HID_SCH_START + 15) +#define HID_SCH_DATA_RANGES_LIST (HID_SCH_START + 16) +// + +//#define HID_SCH_CTL_LIGHT (HID_SCH_START + 17) +//#define HID_SCH_CT_INDICATE2 (HID_SCH_START + 18) +//#define HID_SCH_CT_REGRESS2 (HID_SCH_START + 19) + +//#define HID_SCH_TBI_EDIT_CANCEL (HID_SCH_START + 20) +//#define HID_SCH_TBI_EDIT_ACCEPT (HID_SCH_START + 21) +#define HID_SCH_TBI_DATA_TRANSFER (HID_SCH_START + 22) +#define HID_SCH_TBI_DATA_INSERT_ROW (HID_SCH_START + 23) +#define HID_SCH_TBI_DATA_INSERT_COL (HID_SCH_START + 24) +#define HID_SCH_TBI_DATA_DELETE_ROW (HID_SCH_START + 25) +#define HID_SCH_TBI_DATA_DELETE_COL (HID_SCH_START + 26) +#define HID_SCH_TBI_DATA_SWAP_COL (HID_SCH_START + 27) +#define HID_SCH_TBI_DATA_SWAP_ROW (HID_SCH_START + 28) +//#define HID_SCH_TBI_DATA_SORT_ROW (HID_SCH_START + 29) +//#define HID_SCH_TBI_DATA_SORT_COL (HID_SCH_START + 30) +//#define HID_SCH_TBI_DATA_SORT_TABLE_ROW (HID_SCH_START + 31) +//#define HID_SCH_TBI_DATA_SORT_TABLE_COL (HID_SCH_START + 32) + +// #define HID_SCH_TBX_EDIT (HID_SCH_START + 33) +#define HID_SCH_TBX_DATA (HID_SCH_START + 34) + +#define HID_SCH_ALIGNMENT_CTR_DIAL (HID_SCH_START + 35) +#define HID_SCH_ALIGNMENT_STACKED (HID_SCH_START + 36) +#define HID_SCH_ALIGNMENT_DEGREES (HID_SCH_START + 37) +/* +#define HID_SCH_LAYOUT (HID_SCH_START + 38) + +#define HID_SCH_TBX_EDIT_FIELD (HID_SCH_START + 39) +#define HID_SCH_DIAGRAM_Y_AXIS (HID_SCH_START + 40)//war mal 3 + +#define HID_SCH_DEF_COLOR (HID_SCH_START + 41) +*/ +#define HID_SCH_TP_AXIS_LABEL (HID_SCH_START + 42) + +#define HID_SCH_CHART_AUTO_FORMAT (HID_SCH_START + 44) +#define HID_SCH_LB_BAR_GEOMETRY (HID_SCH_START + 45) +#define HID_SCH_DLG_SPLINE_PROPERTIES (HID_SCH_START + 46) +#define HID_SCH_DLG_RANGES (HID_SCH_START + 47) + +#define HID_SCH_CB_XAXIS (HID_SCH_START + 48) +#define HID_SCH_CB_YAXIS (HID_SCH_START + 49) +#define HID_SCH_CB_ZAXIS (HID_SCH_START + 50) +#define HID_SCH_CB_SECONDARY_XAXIS (HID_SCH_START + 51) +#define HID_SCH_CB_SECONDARY_YAXIS (HID_SCH_START + 52) +#define HID_SCH_CB_SECONDARY_ZAXIS (HID_SCH_START + 53) + +#define HID_SCH_CB_XGRID (HID_SCH_START + 54) +#define HID_SCH_CB_YGRID (HID_SCH_START + 55) +#define HID_SCH_CB_ZGRID (HID_SCH_START + 56) +#define HID_SCH_CB_SECONDARY_XGRID (HID_SCH_START + 57) +#define HID_SCH_CB_SECONDARY_YGRID (HID_SCH_START + 58) +#define HID_SCH_CB_SECONDARY_ZGRID (HID_SCH_START + 59) + +#define HID_SCH_LEGEND_POS_LEFT (HID_SCH_START + 60) +#define HID_SCH_LEGEND_POS_TOP (HID_SCH_START + 61) +#define HID_SCH_LEGEND_POS_RIGHT (HID_SCH_START + 62) +#define HID_SCH_LEGEND_POS_BOTTOM (HID_SCH_START + 63) + +#define HID_SCH_STATISTIK_MEANVALUE (HID_SCH_START + 64) +#define HID_SCH_STATISTIK_NO_ERROR (HID_SCH_START + 65) +#define HID_SCH_STATISTIK_VARIANT (HID_SCH_START + 66) +#define HID_SCH_STATISTIK_SIGMA (HID_SCH_START + 67) +#define HID_SCH_STATISTIK_PERCENT (HID_SCH_START + 68) +#define HID_SCH_STATISTIK_BIGERROR (HID_SCH_START + 69) +#define HID_SCH_STATISTIK_CONSTERROR (HID_SCH_START + 70) +#define HID_SCH_STATISTIK_PERCENT_VALUE (HID_SCH_START + 71) +#define HID_SCH_STATISTIK_BIGERROR_VALUE (HID_SCH_START + 72) +#define HID_SCH_STATISTIK_PLUS_VALUE (HID_SCH_START + 73) +#define HID_SCH_STATISTIK_MINUS_VALUE (HID_SCH_START + 74) + +#define HID_SCH_DATALABEL_VALUE (HID_SCH_START + 75) +#define HID_SCH_DATALABEL_NUMBER (HID_SCH_START + 76) +#define HID_SCH_DATALABEL_PERCENT (HID_SCH_START + 77) +#define HID_SCH_DATALABEL_TEXT (HID_SCH_START + 78) +#define HID_SCH_DATALABEL_SYMBOL (HID_SCH_START + 79) +#define HID_SCH_PB_NUMBERFORMAT (HID_SCH_START + 88) +#define HID_SCH_PB_PERCENT_NUMBERFORMAT (HID_SCH_START + 89) +#define HID_SCH_DATALABEL_SEPARATOR (HID_SCH_START + 90) +#define HID_SCH_DATALABEL_PLACEMENT (HID_SCH_START + 91) +#define HID_SCH_TEXTDIRECTION (HID_SCH_START + 115) +#define HID_SCH_TEXTDIRECTION_TITLE (HID_SCH_START + 116) +#define HID_SCH_TEXTDIRECTION_EQUATION (HID_SCH_START + 117) +#define HID_SCH_DATALABEL_ROTATION_KNOB (HID_SCH_START + 118) +#define HID_SCH_DATALABEL_ROTATION_EDIT (HID_SCH_START + 119) + +#define HID_SCH_TITLE_MAIN (HID_SCH_START + 80) +#define HID_SCH_TITLE_SUB (HID_SCH_START + 81) +#define HID_SCH_TITLE_X (HID_SCH_START + 82) +#define HID_SCH_TITLE_Y (HID_SCH_START + 83) +#define HID_SCH_TITLE_Z (HID_SCH_START + 84) +#define HID_SCH_TITLE_SECONDARY_X (HID_SCH_START + 92) +#define HID_SCH_TITLE_SECONDARY_Y (HID_SCH_START + 93) + +#define HID_SCH_WIZARD_ROADMAP (HID_SCH_START + 85) +#define HID_SCH_LEGEND_SHOW (HID_SCH_START + 86) +#define HID_SCH_DATA_SERIES_LABEL (HID_SCH_START + 87) + +#define HID_SCH_STARTING_ANGLE_DIAL (HID_SCH_START + 94) + +#define HID_SCH_TRENDLINE_RB_NONE (HID_SCH_START + 95) +#define HID_SCH_TRENDLINE_RB_LINEAR (HID_SCH_START + 96) +#define HID_SCH_TRENDLINE_RB_LOGARITHMIC (HID_SCH_START + 97) +#define HID_SCH_TRENDLINE_RB_EXPONENTIAL (HID_SCH_START + 98) +#define HID_SCH_TRENDLINE_RB_POWER (HID_SCH_START + 99) +#define HID_SCH_TRENDLINE_SHOW_EQUATION (HID_SCH_START + 100) +#define HID_SCH_TRENDLINE_SHOW_R_SQUARED (HID_SCH_START + 101) + +#define HID_SCH_STATISTIK_FUNCTION (HID_SCH_START + 102) +#define HID_SCH_STATISTIK_RANGE (HID_SCH_START + 103) +#define HID_SCH_STATISTIK_FUNCTION_LB (HID_SCH_START + 104) +#define HID_SCH_STATISTIK_POSITIVE_VALUE (HID_SCH_START + 105) +#define HID_SCH_STATISTIK_POSITIVE_RANGE (HID_SCH_START + 106) +#define HID_SCH_STATISTIK_POSITIVE_RANGE_CHOOSER (HID_SCH_START + 107) +#define HID_SCH_STATISTIK_NEGATIVE_VALUE (HID_SCH_START + 108) +#define HID_SCH_STATISTIK_NEGATIVE_RANGE (HID_SCH_START + 109) +#define HID_SCH_STATISTIK_NEGATIVE_RANGE_CHOOSER (HID_SCH_START + 110) +#define HID_SCH_STATISTIK_SAME_FOR_BOTH (HID_SCH_START + 111) +#define HID_SCH_STATISTIK_SHOW_BOTH (HID_SCH_START + 112) +#define HID_SCH_STATISTIK_SHOW_POSITIVE (HID_SCH_START + 113) +#define HID_SCH_STATISTIK_SHOW_NEGATIVE (HID_SCH_START + 114) + + +// HID_SCH_START should be 63280 (checked 25.Nov 2002) + +// 453 == SCH_IF_CHARTVIEWSHELL, da SFX_INTERFACE_LIB kein +// Define sondern neuerdings ein Enum ist +//#define HID_SCH_VIEWSHELL_DOCUMENT (453) + + +#endif diff --git a/chart2/source/controller/inc/ItemConverter.hxx b/chart2/source/controller/inc/ItemConverter.hxx new file mode 100644 index 000000000000..e55456519cd1 --- /dev/null +++ b/chart2/source/controller/inc/ItemConverter.hxx @@ -0,0 +1,218 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ItemConverter.hxx,v $ + * $Revision: 1.10.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_ITEMCONVERTER_HXX +#define CHART_ITEMCONVERTER_HXX + +#include <unotools/eventlisteneradapter.hxx> +#include <svtools/itempool.hxx> +#include <svtools/itemset.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +// for pair +#include <utility> + +namespace comphelper +{ + +/** This class serves for conversion between properties of an XPropertySet and + SfxItems in SfxItemSets. + + With this helper classes, you can feed dialogs with XPropertySets and let + those modify by the dialogs. + + You must implement GetWhichPairs() such that an SfxItemSet created with + CreateEmptyItemSet() is able to hold all items that may be mapped. + + You also have to implement GetItemProperty(), in order to return the + property name for a given which-id together with the corresponding member-id + that has to be used for conversion in QueryValue/PutValue. + + FillSpecialItem and ApplySpecialItem may be used for special handling of + individual item, e.g. if you need member-ids in QueryValue/PutValue + + A typical use could be the following: + + ::comphelper::ChartTypeItemConverter aItemConverter( xPropertySet, GetItemPool() ); + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + bool bChanged = false; + + MyDialog aDlg( aItemSet ); + if( aDlg.Execute() == RET_OK ) + { + const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); + if( pOutItemSet ) + bChanged = aItemConverter.ApplyItemSet( *pOutItemSet ); + } + + if( bChanged ) + { + [ apply model changes to view ] + } + */ +class ItemConverter : + public ::utl::OEventListenerAdapter +{ +public: + /** Construct an item converter that uses the given property set for + reading/writing converted items + */ + ItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet , + SfxItemPool& rItemPool ); + virtual ~ItemConverter(); + + // typedefs ------------------------------- + + typedef USHORT tWhichIdType; + typedef ::rtl::OUString tPropertyNameType; + typedef BYTE tMemberIdType; + + typedef ::std::pair< tPropertyNameType, tMemberIdType > tPropertyNameWithMemberId; + + // ---------------------------------------- + + /** applies all properties that can be mapped to items into the given item + set. + + Call this method before opening a dialog. + + @param rOutItemSet + the SfxItemSet is filled with all items that are a result of a + conversion from a property of the internal XPropertySet. + */ + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + + /** applies all properties that are results of a conversion from all items + in rItemSet to the internal XPropertySet. + + Call this method after a dialog was closed with OK + + @return true, if any properties have been changed, false otherwise. + */ + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + + /** creates an empty item set using the given pool or a common pool if empty + (see GetItemPool) and allowing all items given in the ranges returned by + GetWhichPairs. + */ + SfxItemSet CreateEmptyItemSet() const; + + /** Invalidates all items in rDestSet, that are set (state SFX_ITEM_SET) in + both item sets (rDestSet and rSourceSet) and have differing content. + */ + static void InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItemSet &rSourceSet ); + +protected: + // ________ + + /** implement this method to provide an array of which-ranges of the form: + + const USHORT aMyPairs[] = + { + from_1, to_1, + from_2, to_2, + ... + from_n, to_n, + 0 + }; + */ + virtual const USHORT * GetWhichPairs() const = 0; + + /** implement this method to return a Property object for a given which id. + + @param rOutProperty + If true is returned, this contains the property name and the + corresponding Member-Id. + + @return true, if the item can be mapped to a property. + */ + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const = 0; + + /** for items that can not be mapped directly to a property. + + This method is called from FillItemSet(), if GetItemProperty() returns + false. + + The default implementation does nothing except showing an assertion + */ + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + + /** for items that can not be mapped directly to a property. + + This method is called from ApplyItemSet(), if GetItemProperty() returns + false. + + The default implementation returns just false and shows an assertion + + @return true if the item changed a property, false otherwise. + */ + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + + // ________ + + /// Returns the pool + SfxItemPool & GetItemPool() const; + + /** Returns the XPropertySet that was given in the CTOR and is used to apply + items in ApplyItemSet(). + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > GetPropertySet() const; + + // ____ ::utl::OEventListenerAdapter ____ + virtual void _disposing( const ::com::sun::star::lang::EventObject& rSource ); + +protected: + /** sets a new property set, that you get with GetPropertySet(). It should + not be necessary to use this method. It is introduced to allow changing + the regression type of a regression curve which changes the object + identity. + */ + void resetPropertySet( const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & xPropSet ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > m_xPropertySet; + ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySetInfo > m_xPropertySetInfo; + + SfxItemPool& m_rItemPool; + bool m_bIsValid; +}; + +} // namespace comphelper + +// CHART_ITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/ItemPropertyMap.hxx b/chart2/source/controller/inc/ItemPropertyMap.hxx new file mode 100644 index 000000000000..63d4b2ca7f87 --- /dev/null +++ b/chart2/source/controller/inc/ItemPropertyMap.hxx @@ -0,0 +1,93 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ItemPropertyMap.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_ITEMPROPERTYMAP_HXX +#define CHART_ITEMPROPERTYMAP_HXX + + +#include <comphelper/InlineContainer.hxx> +#include "ItemConverter.hxx" + + +#define IPM_MAP_ENTRY(wid,uno,mid) (wid, ::std::make_pair< ::comphelper::ItemConverter::tPropertyNameType, ::comphelper::ItemConverter::tMemberIdType >(\ + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(uno)), mid)) + +namespace comphelper +{ + +typedef ::std::map< ItemConverter::tWhichIdType, ::std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > + ItemPropertyMapType; +typedef ::comphelper::MakeMap< ItemConverter::tWhichIdType, ::std::pair< ItemConverter::tPropertyNameType, ItemConverter::tMemberIdType > > + MakeItemPropertyMap; + +class FillItemSetFunc : public ::std::unary_function< ItemConverter *, void > +{ +public: + explicit FillItemSetFunc( SfxItemSet & rOutItemSet ) : + m_rOutItemSet( rOutItemSet ) + {} + + void operator() ( ItemConverter * pConv ) + { + pConv->FillItemSet( m_rOutItemSet ); + } + +private: + SfxItemSet & m_rOutItemSet; +}; + +class ApplyItemSetFunc : public ::std::unary_function< ItemConverter *, void > +{ +public: + explicit ApplyItemSetFunc( const SfxItemSet & rItemSet, + bool & rOutResult ) : + m_rItemSet( rItemSet ), + m_rOutResult( rOutResult ) + {} + + void operator() ( ItemConverter * pConv ) + { + m_rOutResult = pConv->ApplyItemSet( m_rItemSet ) || m_rOutResult; + } + +private: + const SfxItemSet & m_rItemSet; + bool & m_rOutResult; +}; + +struct DeleteItemConverterPtr : public ::std::unary_function< ItemConverter *, void > +{ + void operator() ( ItemConverter * pConv ) + { delete pConv; } +}; + +} // namespace comphelper + +// CHART_ITEMPROPERTYMAP_HXX +#endif diff --git a/chart2/source/controller/inc/LegendItemConverter.hxx b/chart2/source/controller/inc/LegendItemConverter.hxx new file mode 100644 index 000000000000..3655ea5e6300 --- /dev/null +++ b/chart2/source/controller/inc/LegendItemConverter.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LegendItemConverter.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_LEGENDITEMCONVERTER_HXX +#define CHART_LEGENDITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vector> +#include <memory> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class LegendItemConverter : + public ::comphelper::ItemConverter +{ +public: + LegendItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~LegendItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_LEGENDITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/MultipleChartConverters.hxx b/chart2/source/controller/inc/MultipleChartConverters.hxx new file mode 100644 index 000000000000..5921ec9a35f7 --- /dev/null +++ b/chart2/source/controller/inc/MultipleChartConverters.hxx @@ -0,0 +1,133 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MultipleChartConverters.hxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_MULTIPLECHARTCONVERTERS_HXX +#define CHART2_MULTIPLECHARTCONVERTERS_HXX + +#include "MultipleItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <memory> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class AllAxisItemConverter : public ::comphelper::MultipleItemConverter +{ +public: + AllAxisItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~AllAxisItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +class AllGridItemConverter : public ::comphelper::MultipleItemConverter +{ +public: + AllGridItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ); + virtual ~AllGridItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +class AllDataLabelItemConverter : public ::comphelper::MultipleItemConverter +{ +public: + AllDataLabelItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~AllDataLabelItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +class AllTitleItemConverter : public ::comphelper::MultipleItemConverter +{ +public: + AllTitleItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~AllTitleItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +class AllSeriesStatisticsConverter : public ::comphelper::MultipleItemConverter +{ +public: + AllSeriesStatisticsConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + SfxItemPool& rItemPool ); + virtual ~AllSeriesStatisticsConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +} // namespace wrapper +} // namespace chart + +// CHART2_MULTIPLECHARTCONVERTERS_HXX +#endif diff --git a/chart2/source/controller/inc/MultipleItemConverter.hxx b/chart2/source/controller/inc/MultipleItemConverter.hxx new file mode 100644 index 000000000000..40c8a6b9b7da --- /dev/null +++ b/chart2/source/controller/inc/MultipleItemConverter.hxx @@ -0,0 +1,63 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MultipleItemConverter.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_ALLAXISITEMCONVERTER_HXX +#define CHART_ALLAXISITEMCONVERTER_HXX + +#include <com/sun/star/frame/XModel.hpp> + +#include "ItemConverter.hxx" + +#include <vector> + +namespace comphelper +{ + +/** Note: virtual const USHORT * GetWhichPairs() const; is still pure virtual + */ +class MultipleItemConverter : public ItemConverter +{ +public: + virtual ~MultipleItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + + /// implemented empty (returns always false) + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + +protected: + MultipleItemConverter( SfxItemPool& rItemPool ); + + ::std::vector< ItemConverter * > m_aConverters; +}; + +} // namespace comphelper + +#endif diff --git a/chart2/source/controller/inc/ObjectHierarchy.hxx b/chart2/source/controller/inc/ObjectHierarchy.hxx new file mode 100644 index 000000000000..3281181c5be7 --- /dev/null +++ b/chart2/source/controller/inc/ObjectHierarchy.hxx @@ -0,0 +1,121 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectHierarchy.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_OBJECTHIERARCHY_HXX +#define CHART2_OBJECTHIERARCHY_HXX + +#include <rtl/ustring.hxx> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/awt/KeyEvent.hpp> + +#include <memory> +#include <vector> + +namespace chart +{ + +class ExplicitValueProvider; + +namespace impl +{ +class ImplObjectHierarchy; +} + +class ObjectHierarchy +{ +public: + typedef ::rtl::OUString tCID; + typedef ::std::vector< tCID > tChildContainer; + + /** @param bFlattenDiagram + If <TRUE/>, the content of the diaram (data series, wall, floor, + etc.) is treated as being at the same level as the diagram. (This is + used for keyboard navigation). + */ + explicit ObjectHierarchy( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument, + ExplicitValueProvider * pExplicitValueProvider = 0, + bool bFlattenDiagram = false, + bool bOrderingForElementSelector = false ); + ~ObjectHierarchy(); + + static tCID getRootNodeCID(); + static bool isRootNode( const tCID & rCID ); + + /// equal to getChildren( getRootNodeCID()) + tChildContainer getTopLevelChildren() const; + bool hasChildren( const tCID & rParent ) const; + tChildContainer getChildren( const tCID & rParent ) const; + + tChildContainer getSiblings( const tCID & rNode ) const; + + /// The result is empty, if the node cannot be found in the tree + tCID getParent( const tCID & rNode ) const; + /// @returns -1, if no parent can be determined + sal_Int32 getIndexInParent( const tCID & rNode ) const; + +private: + + ::std::auto_ptr< impl::ImplObjectHierarchy > m_apImpl; +}; + +class ObjectKeyNavigation +{ +public: + explicit ObjectKeyNavigation( const ObjectHierarchy::tCID & rCurrentCID, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument, + ExplicitValueProvider * pExplicitValueProvider = 0 ); + + bool handleKeyEvent( const ::com::sun::star::awt::KeyEvent & rEvent ); + ObjectHierarchy::tCID getCurrentSelection() const; + +private: + void setCurrentSelection( const ObjectHierarchy::tCID & rCID ); + bool first(); + bool last(); + bool next(); + bool previous(); + bool up(); + bool down(); + bool veryFirst(); + bool veryLast(); + + ObjectHierarchy::tCID m_aCurrentCID; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDocument; + ExplicitValueProvider * m_pExplicitValueProvider; + bool m_bStepDownInDiagram; +}; + +} // namespace chart + +// CHART2_OBJECTHIERARCHY_HXX +#endif diff --git a/chart2/source/controller/inc/ObjectNameProvider.hxx b/chart2/source/controller/inc/ObjectNameProvider.hxx new file mode 100644 index 000000000000..529f253fc20a --- /dev/null +++ b/chart2/source/controller/inc/ObjectNameProvider.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectNameProvider.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_OBJECTNAME_PROVIDER_HXX +#define _CHART2_OBJECTNAME_PROVIDER_HXX + +#include "ObjectIdentifier.hxx" +#include "TitleHelper.hxx" +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** Provides localized ui strings for the userinterface. +*/ + +class ObjectNameProvider +{ +public: + static rtl::OUString getName( ObjectType eObjectType, bool bPlural=false ); + static rtl::OUString getAxisName( const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + static rtl::OUString getGridName( const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + static rtl::OUString getTitleName( const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + static rtl::OUString getTitleNameByType( TitleHelper::eTitleType eType ); + + static rtl::OUString getNameForCID( + const rtl::OUString& rObjectCID, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartDocument ); + + static rtl::OUString getName_ObjectForSeries( + ObjectType eObjectType, + const rtl::OUString& rSeriesCID, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument >& xChartDocument ); + static rtl::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 rtl::OUString getHelpText( const rtl::OUString& rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel, bool bVerbose=false ); + static rtl::OUString getHelpText( const rtl::OUString& rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument, bool bVerbose=false ); + + /** This is used for showing the currently selected object in the status bar + (command "Context") + */ + static rtl::OUString getSelectedObjectText( const rtl::OUString & rObjectCID, const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument >& xChartDocument ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/PositionAndSizeHelper.hxx b/chart2/source/controller/inc/PositionAndSizeHelper.hxx new file mode 100644 index 000000000000..180ad047a0f3 --- /dev/null +++ b/chart2/source/controller/inc/PositionAndSizeHelper.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PositionAndSizeHelper.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_POSITIONANDSIZEHELPER_HXX +#define _CHART2_POSITIONANDSIZEHELPER_HXX + +#include "ObjectIdentifier.hxx" +#include <com/sun/star/frame/XModel.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class PositionAndSizeHelper +{ +public: + static bool moveObject( ObjectType eObjectType + , const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& xObjectProp + , const ::com::sun::star::awt::Rectangle& rNewPositionAndSize + , const ::com::sun::star::awt::Rectangle& rPageRectangle ); + + static bool moveObject( const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel + , const ::com::sun::star::awt::Rectangle& rNewPositionAndSize + , const ::com::sun::star::awt::Rectangle& rPageRectangle + , ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xChartView ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/RangeEdit.hxx b/chart2/source/controller/inc/RangeEdit.hxx new file mode 100755 index 000000000000..20dd02bcf1e9 --- /dev/null +++ b/chart2/source/controller/inc/RangeEdit.hxx @@ -0,0 +1,59 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeEdit.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ +#ifndef CHART2RANGEEDIT_HXX +#define CHART2RANGEEDIT_HXX + +#include <vcl/edit.hxx> +#include <vcl/accel.hxx> +#include <tools/link.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class RangeEdit : public Edit +{ +public: + explicit RangeEdit( Window* pParent, const ResId& rResId); + virtual ~RangeEdit(); + + // KeyInput method + void SetKeyInputHdl( const Link& rKeyInputLink ); + virtual void KeyInput( const KeyEvent& rKEvt ); + +private: + Link m_aKeyInputLink; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/RangeSelectionButton.hxx b/chart2/source/controller/inc/RangeSelectionButton.hxx new file mode 100644 index 000000000000..9befd85cf0af --- /dev/null +++ b/chart2/source/controller/inc/RangeSelectionButton.hxx @@ -0,0 +1,58 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionButton.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_RANGESELECTIONBUTTON_HXX +#define _CHART2_RANGESELECTIONBUTTON_HXX + +// header for Class ImageButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +class RangeSelectionButton : public ImageButton +{ +public: + RangeSelectionButton( Window* pParent, const ResId& rResId ); + virtual ~RangeSelectionButton(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/RangeSelectionHelper.hxx b/chart2/source/controller/inc/RangeSelectionHelper.hxx new file mode 100755 index 000000000000..ec280b0da2e8 --- /dev/null +++ b/chart2/source/controller/inc/RangeSelectionHelper.hxx @@ -0,0 +1,90 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionHelper.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RANGESELECTIONHELPER_HXX +#define CHART2_RANGESELECTIONHELPER_HXX + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/beans/PropertyValue.hpp> + +namespace com { namespace sun { namespace star { + namespace sheet{ + class XRangeSelection; + class XRangeSelectionListener; + class XCellRangesAccess; + } +}}} + +namespace chart +{ + +class RangeSelectionListenerParent; + +class RangeSelectionHelper +{ +public: + explicit RangeSelectionHelper( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument ); + ~RangeSelectionHelper(); + + bool hasRangeSelection(); + ::com::sun::star::uno::Reference< + ::com::sun::star::sheet::XRangeSelection > getRangeSelection(); + void raiseRangeSelectionDocument(); + bool chooseRange( + const ::rtl::OUString & aCurrentRange, + const ::rtl::OUString & aUIString, + RangeSelectionListenerParent & rListenerParent ); + void stopRangeListening( bool bRemoveListener = true ); + bool verifyCellRange( const ::rtl::OUString & rRangeStr ); + bool verifyArguments( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArguments ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::sheet::XRangeSelection > + m_xRangeSelection; + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > + m_xChartDocument; + + ::com::sun::star::uno::Reference< + ::com::sun::star::sheet::XCellRangesAccess > + m_xCellRangesAccess; + + ::com::sun::star::uno::Reference< + ::com::sun::star::sheet::XRangeSelectionListener > + m_xRangeSelectionListener; +}; + +} // namespace chart + +// CHART2_RANGESELECTIONHELPER_HXX +#endif diff --git a/chart2/source/controller/inc/RangeSelectionListener.hxx b/chart2/source/controller/inc/RangeSelectionListener.hxx new file mode 100644 index 000000000000..55d0965e9d99 --- /dev/null +++ b/chart2/source/controller/inc/RangeSelectionListener.hxx @@ -0,0 +1,82 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RangeSelectionListener.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RANGESELECTIONLISTENER_HXX +#define CHART2_RANGESELECTIONLISTENER_HXX + +#include "ControllerLockGuard.hxx" +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/sheet/XRangeSelectionListener.hpp> + +namespace chart +{ + +class RangeSelectionListenerParent +{ +public: + virtual void listeningFinished( const ::rtl::OUString & rNewRange ) = 0; + virtual void disposingRangeSelection() = 0; +}; + +// ---------------------------------------- + +class RangeSelectionListener : public + ::cppu::WeakImplHelper1< + ::com::sun::star::sheet::XRangeSelectionListener > +{ +public: + explicit RangeSelectionListener( + RangeSelectionListenerParent & rParent, + const ::rtl::OUString & rInitialRange, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xModelToLockController ); + virtual ~RangeSelectionListener(); + +protected: + // ____ XRangeSelectionListener ____ + virtual void SAL_CALL done( const ::com::sun::star::sheet::RangeSelectionEvent& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL aborted( const ::com::sun::star::sheet::RangeSelectionEvent& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XEventListener ____ + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + +private: + RangeSelectionListenerParent & m_rParent; + ::rtl::OUString m_aRange; + ControllerLockGuard m_aControllerLockGuard; +}; + +} // namespace chart + +// CHART2_RANGESELECTIONLISTENER_HXX +#endif diff --git a/chart2/source/controller/inc/RegressionCurveItemConverter.hxx b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx new file mode 100644 index 000000000000..f613d9bdb57a --- /dev/null +++ b/chart2/source/controller/inc/RegressionCurveItemConverter.hxx @@ -0,0 +1,85 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegressionCurveItemConverter.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_REGRESSIONCURVE_ITEMCONVERTER_HXX +#define CHART_REGRESSIONCURVE_ITEMCONVERTER_HXX + +#include "ItemConverter.hxx" + +#include <com/sun/star/chart2/XRegressionCurveContainer.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vector> +#include <boost/shared_ptr.hpp> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class RegressionCurveItemConverter : + public ::comphelper::ItemConverter +{ +public: + RegressionCurveItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XRegressionCurveContainer > & xRegCurveCnt, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ); + virtual ~RegressionCurveItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::boost::shared_ptr< ItemConverter > m_spGraphicConverter; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XRegressionCurveContainer > m_xCurveContainer; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_REGRESSIONCURVE_ITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/RegressionEquationItemConverter.hxx b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx new file mode 100644 index 000000000000..09e9d1960da4 --- /dev/null +++ b/chart2/source/controller/inc/RegressionEquationItemConverter.hxx @@ -0,0 +1,86 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegressionEquationItemConverter.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_REGRESSIONEQUATION_ITEMCONVERTER_HXX +#define CHART_REGRESSIONEQUATION_ITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" + +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/awt/Size.hpp> + +#include <memory> +#include <vector> +#include <boost/shared_ptr.hpp> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class RegressionEquationItemConverter : + public ::comphelper::ItemConverter +{ +public: + RegressionEquationItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + virtual ~RegressionEquationItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_REGRESSIONEQUATION_ITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/SchSlotIds.hxx b/chart2/source/controller/inc/SchSlotIds.hxx new file mode 100644 index 000000000000..f65b2f9badcb --- /dev/null +++ b/chart2/source/controller/inc/SchSlotIds.hxx @@ -0,0 +1,237 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SchSlotIds.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef SCH_SLOTIDS_HXX +#define SCH_SLOTIDS_HXX + +// header for SID_OBJ1_START +#include <sfx2/sfxsids.hrc> + +// SID_OBJ1_START == 30000 + 512 +//not used as slot in old chart +//#define SID_COPYFORMAT SID_OBJ1_START +//not used as slot in old chart +//#define SID_PASTEFORMAT (SID_OBJ1_START + 1) + +//still used as help id +#define SID_DIAGRAM_DATA (SID_OBJ1_START + 2) +//only used as help id +#define SID_INSERT_TITLE (SID_OBJ1_START + 3) +//only used as help id +#define SID_INSERT_CHART_LEGEND (SID_OBJ1_START + 4) +//only used as help id +#define SID_INSERT_DESCRIPTION (SID_OBJ1_START + 5) +//only used as help id +#define SID_INSERT_AXIS (SID_OBJ1_START + 6) +//some how used as slot in old chart +//#define SID_DATA_ROW_POINT (SID_OBJ1_START + 7) +//menu parent id and helpid +//MENUCHANGE FORMATMENU #define SID_CHART_TITLE (SID_OBJ1_START + 8) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_LEGEND (SID_OBJ1_START + 9) +//menu parent id and helpid +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS (SID_OBJ1_START + 10) +//menu parent id and helpid +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID (SID_OBJ1_START + 11) + +/* +//MENUCHANGE +//still used as slot id +#define SID_DIAGRAM_WALL (SID_OBJ1_START + 12) +//still used as slot id +#define SID_DIAGRAM_FLOOR (SID_OBJ1_START + 13) +//still used as slot id +#define SID_DIAGRAM_AREA (SID_OBJ1_START + 14) +*/ + +//only used as help id +#define SID_3D_VIEW (SID_OBJ1_START + 15) +//still used as slot id +#define SID_DIAGRAM_TYPE (SID_OBJ1_START + 16) +//used as slot in old chart +//#define SID_TOGGLE_TITLE (SID_OBJ1_START + 17) +//used as slot in old chart +//#define SID_TOGGLE_LEGEND (SID_OBJ1_START + 18) +//used as slot in old chart +//#define SID_TOGGLE_AXIS_TITLE (SID_OBJ1_START + 19) +//used as slot in old chart +//#define SID_TOGGLE_AXIS_DESCR (SID_OBJ1_START + 20) // 30532 +//used as slot in old chart +//#define SID_TOGGLE_GRID_HORZ (SID_OBJ1_START + 21) +//used as slot in old chart +//#define SID_TOGGLE_GRID_VERT (SID_OBJ1_START + 22) +//used as slot in old chart +//#define SID_DATA_IN_ROWS (SID_OBJ1_START + 23) +//used as slot in old chart +//#define SID_DATA_IN_COLUMNS (SID_OBJ1_START + 24) +//used as slot in old chart +//#define SID_TOOL_SELECT (SID_OBJ1_START + 25) +//some how used as slot in old chart +//#define SID_CONTEXT_TYPE (SID_OBJ1_START + 26) +//used as slot in old chart +//#define SID_NEW_ARRANGEMENT (SID_OBJ1_START + 27) // 30539 +//only used as help id +#define SID_INSERT_GRIDS (SID_OBJ1_START + 28) + +//not used as slot in old chart +//#define SID_MAINTITLE (SID_OBJ1_START + 29) +//not used as slot in old chart +//#define SID_SUBTITLE (SID_OBJ1_START + 30) +//not used as slot in old chart +//#define SID_XAXIS_TITLE (SID_OBJ1_START + 31) +//not used as slot in old chart +//#define SID_YAXIS_TITLE (SID_OBJ1_START + 32) +//not used as slot in old chart +//#define SID_ZAXIS_TITLE (SID_OBJ1_START + 33) + +/* +//used as slot in old chart +#ifdef SID_UPDATE +#undef SID_UPDATE +#endif +#define SID_UPDATE (SID_OBJ1_START + 34) +*/ + +//not used as slot in old chart +//#define SID_DATA (SID_OBJ1_START + 35) +//not used as slot in old chart +//#define SID_ADD_COLUMN (SID_OBJ1_START + 36) +//not used as slot in old chart +//#define SID_ADD_ROW (SID_OBJ1_START + 37) + +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_X (SID_OBJ1_START + 40) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_Y (SID_OBJ1_START + 41) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_Z (SID_OBJ1_START + 42) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_ALL (SID_OBJ1_START + 43) +//only used as help id +#define SID_INSERT_STATISTICS (SID_OBJ1_START + 44) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_MAIN (SID_OBJ1_START + 45) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_SUB (SID_OBJ1_START + 46) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_X (SID_OBJ1_START + 47) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_Y (SID_OBJ1_START + 48) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_Z (SID_OBJ1_START + 49) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_TITLE_ALL (SID_OBJ1_START + 50) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_Y_MAIN (SID_OBJ1_START + 51) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_X_MAIN (SID_OBJ1_START + 52) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_Z_MAIN (SID_OBJ1_START + 53) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_ALL (SID_OBJ1_START + 54) + +//used as slot in old chart +//#define SID_HAS_X_DESCR (SID_OBJ1_START + 55) +//used as slot in old chart +//#define SID_HAS_Y_DESCR (SID_OBJ1_START + 56) +//used as slot in old chart +//#define SID_HAS_Z_DESCR (SID_OBJ1_START + 57) + +//#define SID_DIAGRAM_OBJECTS (SID_OBJ1_START + 60) + +//not used as slot in old chart +//#define SID_HAS_X_TITLE (SID_OBJ1_START + 61) +//not used as slot in old chart +//#define SID_HAS_Y_TITLE (SID_OBJ1_START + 62) +//not used as slot in old chart +//#define SID_HAS_Z_TITLE (SID_OBJ1_START + 63) +//not used as slot in old chart +//#define SID_HAS_MAIN_TITLE (SID_OBJ1_START + 64) +//not used as slot in old chart +//#define SID_HAS_SUB_TITLE (SID_OBJ1_START + 65) + +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_Y_HELP (SID_OBJ1_START + 66) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_X_HELP (SID_OBJ1_START + 67) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_GRID_Z_HELP (SID_OBJ1_START + 68) + +//not used as slot in old chart +//#define SID_DIAGRAM_DATA_WIN (SID_OBJ1_START + 70) + +//used as slot in old chart +//#define SID_DIAGRAM_ERROR (SID_OBJ1_START + 71) +//used as slot in old chart +//#define SID_DIAGRAM_AVERAGEVALUE (SID_OBJ1_START + 72) +//used as slot in old chart +//#define SID_DIAGRAM_REGRESSION (SID_OBJ1_START + 73) +//used as slot in old chart +//#define SID_SCALE_TEXT (SID_OBJ1_START + 74) +//not used as slot in old chart +//#define SID_TEXTBREAK (SID_OBJ1_START + 75) + +//not used as slot in old chart +//#define SID_DIAGRAM_DATADESCRIPTION (SID_OBJ1_START + 76) +//not used as slot in old chart +//#define SID_DIAGRAM_POSLEGEND (SID_OBJ1_START + 77) +//not used as slot in old chart +//#define SID_DIAGRAM_DEFAULTCOLORS (SID_OBJ1_START + 78) +//not used as slot in old chart +//#define SID_DIAGRAM_BARWIDTH (SID_OBJ1_START + 79) +//not used as slot in old chart +//#define SID_DIAGRAM_NUMLINES (SID_OBJ1_START + 80) + +//menu parent id and helpid +//#define SID_ROW_POSITION (SID_OBJ1_START + 81) +//still used as slot id +//#define SID_ROW_MOREFRONT (SID_OBJ1_START + 82) +//still used as slot id +//#define SID_ROW_MOREBACK (SID_OBJ1_START + 83) + +//not used as slot in old chart +//#define SID_TITLE_TEXT (SID_OBJ1_START + 100) +//somehow used as slot in old chart +//#define SID_DIAGRAM_STOCK_LINE (SID_OBJ1_START + 101) +//used as slot in old chart +//#define SID_DIAGRAM_STOCK_LOSS (SID_OBJ1_START + 102) +//used as slot in old chart +//#define SID_DIAGRAM_STOCK_PLUS (SID_OBJ1_START + 103) + +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_A (SID_OBJ1_START + 104) +//still used as slot id +//MENUCHANGE FORMATMENU #define SID_DIAGRAM_AXIS_B (SID_OBJ1_START + 105) +//used as slot in old chart +//#define SID_DIAGRAM_AXIS_C (SID_OBJ1_START + 106) + +// Reserved till (SID_OBJ1_START + 110) + +#endif +// SCH_SLOTIDS_HXX diff --git a/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx new file mode 100644 index 000000000000..0f4a9869fcc9 --- /dev/null +++ b/chart2/source/controller/inc/SeriesOptionsItemConverter.hxx @@ -0,0 +1,105 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SeriesOptionsItemConverter.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_SERIESOPTIONSITEMCONVERTER_HXX +#define CHART_SERIESOPTIONSITEMCONVERTER_HXX + +#include "ItemConverter.hxx" + + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/chart2/XCoordinateSystem.hpp> + +namespace chart +{ +namespace wrapper +{ + +class SeriesOptionsItemConverter : + public ::comphelper::ItemConverter +{ +public: + SeriesOptionsItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ); + virtual ~SeriesOptionsItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; + + bool m_bAttachToMainAxis; + bool m_bSupportingOverlapAndGapWidthProperties; + bool m_bSupportingBarConnectors; + + sal_Int32 m_nBarOverlap; + sal_Int32 m_nGapWidth; + sal_Bool m_bConnectBars; + + bool m_bSupportingAxisSideBySide; + bool m_bGroupBarsPerAxis; + bool m_bAllSeriesAttachedToSameAxis; + sal_Int32 m_nAllSeriesAxisIndex; + + bool m_bSupportingStartingAngle; + sal_Int32 m_nStartingAngle; + + bool m_bClockwise; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XCoordinateSystem > m_xCooSys; + + ::com::sun::star::uno::Sequence< sal_Int32 > m_aSupportedMissingValueTreatments; + sal_Int32 m_nMissingValueTreatment; + + bool m_bSupportingPlottingOfHiddenCells; + bool m_bIncludeHiddenCells; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_SERIESOPTIONSITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/StatisticsItemConverter.hxx b/chart2/source/controller/inc/StatisticsItemConverter.hxx new file mode 100644 index 000000000000..440a008e7568 --- /dev/null +++ b/chart2/source/controller/inc/StatisticsItemConverter.hxx @@ -0,0 +1,78 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StatisticsItemConverter.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_STATISTICSITEMCONVERTER_HXX +#define CHART_STATISTICSITEMCONVERTER_HXX + +#include <com/sun/star/frame/XModel.hpp> + +#include "ItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "chartview/NumberFormatterWrapper.hxx" + +#include <vector> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class StatisticsItemConverter : + public ::comphelper::ItemConverter +{ +public: + StatisticsItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xChartModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ); + virtual ~StatisticsItemConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xModel; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_STATISTICSITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/TabPageNotifiable.hxx b/chart2/source/controller/inc/TabPageNotifiable.hxx new file mode 100644 index 000000000000..2107b4c2ca78 --- /dev/null +++ b/chart2/source/controller/inc/TabPageNotifiable.hxx @@ -0,0 +1,54 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TabPageNotifiable.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_TABPAGENOTIFIABLE_HXX +#define CHART2_TABPAGENOTIFIABLE_HXX + +#include <vcl/tabpage.hxx> +#include <tools/color.hxx> + +// 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 0xff6563 + +namespace chart +{ + +class TabPageNotifiable +{ +public: + virtual void setInvalidPage( TabPage * pTabPage ) = 0; + virtual void setValidPage( TabPage * pTabPage ) = 0; +}; + +} // namespace chart + +// CHART2_TABPAGENOTIFIABLE_HXX +#endif diff --git a/chart2/source/controller/inc/TextDirectionListBox.hxx b/chart2/source/controller/inc/TextDirectionListBox.hxx new file mode 100644 index 000000000000..fdd44069c5c0 --- /dev/null +++ b/chart2/source/controller/inc/TextDirectionListBox.hxx @@ -0,0 +1,52 @@ +/************************************************************************* +* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TextDirectionListBox.hxx,v $ + * $Revision: 1.1.2.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * +************************************************************************/ + +#ifndef CHART2_TEXTDIRECTIONLISTBOX_HXX +#define CHART2_TEXTDIRECTIONLISTBOX_HXX + +#include <svx/frmdirlbox.hxx> + +class Window; + +namespace chart +{ + +class TextDirectionListBox : public svx::FrameDirectionListBox +{ +public: + explicit TextDirectionListBox( Window* pParent, const ResId& rResId, + Window* pWindow1 = 0, Window* pWindow2 = 0 ); + virtual ~TextDirectionListBox(); +}; + +} //namespace chart + +#endif + diff --git a/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx b/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx new file mode 100644 index 000000000000..d738bb408cf1 --- /dev/null +++ b/chart2/source/controller/inc/TimerTriggeredControllerLock.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TimerTriggeredControllerLock.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TIMERTRIGGEREDCONTROLLERLOCK_HXX +#define _CHART2_TIMERTRIGGEREDCONTROLLERLOCK_HXX + +#include "ControllerLockGuard.hxx" +#include <vcl/timer.hxx> +#include <com/sun/star/frame/XModel.hpp> + +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class TimerTriggeredControllerLock +{ +public: + TimerTriggeredControllerLock( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xModel ); + virtual ~TimerTriggeredControllerLock(); + + void startTimer(); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xModel; + std::auto_ptr< ControllerLockGuard > m_apControllerLockGuard; + AutoTimer m_aTimer; + + DECL_LINK( TimerTimeout, void* ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/TitleDialogData.hxx b/chart2/source/controller/inc/TitleDialogData.hxx new file mode 100644 index 000000000000..45eec951ce65 --- /dev/null +++ b/chart2/source/controller/inc/TitleDialogData.hxx @@ -0,0 +1,70 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleDialogData.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_TITLEDIALOGDATA_HXX +#define _CHART2_TITLEDIALOGDATA_HXX + +#include "ReferenceSizeProvider.hxx" +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ + +struct TitleDialogData +{ + ::com::sun::star::uno::Sequence< sal_Bool > aPossibilityList; + ::com::sun::star::uno::Sequence< sal_Bool > aExistenceList; + ::com::sun::star::uno::Sequence< rtl::OUString > aTextList; + ::std::auto_ptr< ReferenceSizeProvider > apReferenceSizeProvider; + + TitleDialogData( ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider = + ::std::auto_ptr< ReferenceSizeProvider >( 0 )); + + void readFromModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + /* return true if anything has changed; + when pOldState is NULL then all data are written to the model + */ + bool writeDifferenceToModel( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel + , const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext + , TitleDialogData* pOldState=NULL ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/TitleItemConverter.hxx b/chart2/source/controller/inc/TitleItemConverter.hxx new file mode 100644 index 000000000000..92f828a0dc13 --- /dev/null +++ b/chart2/source/controller/inc/TitleItemConverter.hxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleItemConverter.hxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_TITLEITEMCONVERTER_HXX +#define CHART_TITLEITEMCONVERTER_HXX + +#include "ItemConverter.hxx" +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> + +#include <vector> +#include <memory> + +class SdrModel; + +namespace chart +{ +namespace wrapper +{ + +class TitleItemConverter : + public ::comphelper::ItemConverter +{ +public: + TitleItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize = + ::std::auto_ptr< ::com::sun::star::awt::Size >() ); + + virtual ~TitleItemConverter(); + + virtual void FillItemSet( SfxItemSet & rOutItemSet ) const; + virtual bool ApplyItemSet( const SfxItemSet & rItemSet ); + +protected: + virtual const USHORT * GetWhichPairs() const; + virtual bool GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const; + + virtual void FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( ::com::sun::star::uno::Exception ); + virtual bool ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( ::com::sun::star::uno::Exception ); + +private: + ::std::vector< ItemConverter * > m_aConverters; +}; + +} // namespace wrapper +} // namespace chart + +// CHART_TITLEITEMCONVERTER_HXX +#endif diff --git a/chart2/source/controller/inc/ViewElementListProvider.hxx b/chart2/source/controller/inc/ViewElementListProvider.hxx new file mode 100644 index 000000000000..6558e8c3aba1 --- /dev/null +++ b/chart2/source/controller/inc/ViewElementListProvider.hxx @@ -0,0 +1,73 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ViewElementListProvider.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_VIEWELEMENTLISTPROVIDER_HXX +#define _CHART2_VIEWELEMENTLISTPROVIDER_HXX + +#include <svx/xtable.hxx> +#include <svx/svdpage.hxx> + +class FontList; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class DrawModelWrapper; + +class ViewElementListProvider +{ +public: + ViewElementListProvider( DrawModelWrapper* pDrawModelWrapper ); + virtual ~ViewElementListProvider(); + + XColorTable* GetColorTable() const; + XDashList* GetDashList() const; + XLineEndList* GetLineEndList() const; + XGradientList* GetGradientList() const; + XHatchList* GetHatchList() const; + XBitmapList* GetBitmapList() const; + + //create chartspecific symbols for linecharts + SdrObjList* GetSymbolList() const; + Graphic GetSymbolGraphic( sal_Int32 nStandardSymbol, const SfxItemSet* pSymbolShapeProperties ) const; + + FontList* getFontList() const; + //SfxPrinter* getPrinter(); + +private: + DrawModelWrapper* m_pDrawModelWrapper; + mutable FontList* m_pFontList; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/dlg_ChartType.hxx b/chart2/source/controller/inc/dlg_ChartType.hxx new file mode 100644 index 000000000000..1a567936fd79 --- /dev/null +++ b/chart2/source/controller/inc/dlg_ChartType.hxx @@ -0,0 +1,79 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType.hxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_CHARTTYPE_HXX +#define _CHART2_DLG_CHARTTYPE_HXX + +// header for class ModalDialog +#include <vcl/dialog.hxx> +// header for class FixedLine +#include <vcl/fixed.hxx> +// header for class OKButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ChartTypeTabPage; +class ChartTypeDialog : public ModalDialog +{ +public: + ChartTypeDialog( Window* pWindow + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + ~ChartTypeDialog(); + +private: + FixedLine m_aFL; + OKButton m_aBtnOK; + CancelButton m_aBtnCancel; + HelpButton m_aBtnHelp; + + ChartTypeTabPage* m_pChartTypeTabPage; + + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/inc/dlg_ChartType_UNO.hxx b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx new file mode 100644 index 000000000000..d19b01d2e2d6 --- /dev/null +++ b/chart2/source/controller/inc/dlg_ChartType_UNO.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ChartType_UNO.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CREATION_TYPE_UNO_HXX +#define _CHART2_CREATION_TYPE_UNO_HXX + +#include "ServiceMacros.hxx" +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <vcl/vclevent.hxx> + +#include <svtools/genericunodialog.hxx> +//............................................................................. +namespace chart +{ +//............................................................................. +typedef ::svt::OGenericUnoDialog ChartTypeUnoDlg_BASE; +class ChartType; +class ChartTypeUnoDlg : public ChartTypeUnoDlg_BASE + ,public ::comphelper::OPropertyArrayUsageHelper< ChartTypeUnoDlg > +{ +public: + ChartTypeUnoDlg( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& xContext ); + + // XServiceInfo - static methods + static ::com::sun::star::uno::Sequence< ::rtl::OUString > getSupportedServiceNames_Static(void); + static ::rtl::OUString getImplementationName_Static(void) throw( ::com::sun::star::uno::RuntimeException ); + static ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > + SAL_CALL Create(const ::com::sun::star::uno::Reference< com::sun::star::uno::XComponentContext >&); +private: + virtual ~ChartTypeUnoDlg(); + + // OGenericUnoDialog overridables + virtual void implInitialize(const com::sun::star::uno::Any& _rValue); + virtual Dialog* createDialog(Window* _pParent); + + // XTypeProvider + virtual com::sun::star::uno::Sequence<sal_Int8> SAL_CALL getImplementationId( ) throw(com::sun::star::uno::RuntimeException); + // XServiceInfo + virtual ::rtl::OUString SAL_CALL getImplementationName() throw(::com::sun::star::uno::RuntimeException); + virtual ::comphelper::StringSequence SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException); + + // XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo> SAL_CALL getPropertySetInfo() throw(::com::sun::star::uno::RuntimeException); + virtual ::cppu::IPropertyArrayHelper& SAL_CALL getInfoHelper(); + + // OPropertyArrayUsageHelper + virtual ::cppu::IPropertyArrayHelper* createArrayHelper( ) const; + + //no default constructor + ChartTypeUnoDlg(); + ChartTypeUnoDlg(const ChartTypeUnoDlg&); // no defined + void operator =(const ChartTypeUnoDlg&); // no defined + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xChartModel; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/dlg_CreationWizard.hxx b/chart2/source/controller/inc/dlg_CreationWizard.hxx new file mode 100644 index 000000000000..27a4a5efb9d7 --- /dev/null +++ b/chart2/source/controller/inc/dlg_CreationWizard.hxx @@ -0,0 +1,108 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CREATION_WIZARD_HXX +#define _CHART2_CREATION_WIZARD_HXX + +#include "ServiceMacros.hxx" +#include "TimerTriggeredControllerLock.hxx" +#include "TabPageNotifiable.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <svtools/roadmapwizard.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +// for auto_ptr +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class RangeChooserTabPage; +class DataSourceTabPage; +class ChartTypeTemplateProvider; +class DialogModel; + +class CreationWizard : public + svt::RoadmapWizard + , public TabPageNotifiable +{ +public: + CreationWizard( Window* pParent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel + , const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext + , sal_Int32 nOnePageOnlyIndex=-1 );//if nOnePageOnlyIndex is an index of an exsisting page starting with 0, then only this page is displayed without next/previous and roadmap + virtual ~CreationWizard(); + + bool isClosable(); + + // TabPageNotifiable + virtual void setInvalidPage( TabPage * pTabPage ); + virtual void setValidPage( TabPage * pTabPage ); + +protected: + virtual sal_Bool leaveState( WizardState _nState ); + virtual WizardState determineNextState(WizardState nCurrentState) const; + virtual void enterState(WizardState nState); + + virtual String getStateDisplayName( WizardState nState ) const; + +private: + //no default constructor + CreationWizard(); + + virtual svt::OWizardPage* createPage(WizardState nState); + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; + bool m_bIsClosable; + sal_Int32 m_nOnePageOnlyIndex;//if nOnePageOnlyIndex is an index of an exsisting page starting with 0, then only this page is displayed without next/previous and roadmap + ChartTypeTemplateProvider* m_pTemplateProvider; + ::std::auto_ptr< DialogModel > m_apDialogModel; + + WizardState m_nFirstState; + WizardState m_nLastState; + + TimerTriggeredControllerLock m_aTimerTriggeredControllerLock; + +// RangeChooserTabPage * m_pRangeChooserTabePage; +// DataSourceTabPage * m_pDataSourceTabPage; + bool m_bCanTravel; +}; +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx new file mode 100644 index 000000000000..5b92f3cb9670 --- /dev/null +++ b/chart2/source/controller/inc/dlg_CreationWizard_UNO.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_CreationWizard_UNO.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _CHART2_CREATION_WIZARD_UNO_HXX +#define _CHART2_CREATION_WIZARD_UNO_HXX + +#include "ServiceMacros.hxx" +#include "MutexContainer.hxx" +#include <cppuhelper/component.hxx> +#include <com/sun/star/awt/XWindow.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +// header for define DECL_LINK +#include <tools/link.hxx> +#include <vcl/vclevent.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class CreationWizard; +class CreationWizardUnoDlg : public MutexContainer + , public ::cppu::OComponentHelper + , public ::com::sun::star::ui::dialogs::XExecutableDialog + , public ::com::sun::star::lang::XServiceInfo + , public ::com::sun::star::lang::XInitialization + , public ::com::sun::star::frame::XTerminateListener + , public ::com::sun::star::beans::XPropertySet +{ +public: + CreationWizardUnoDlg( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext >& xContext ); + virtual ~CreationWizardUnoDlg(); + + // XInterface + virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( ::com::sun::star::uno::Type const & rType ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL acquire() throw (); + virtual void SAL_CALL release() throw (); + + // XTypeProvider + virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes( ) throw (::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< sal_Int8 > SAL_CALL getImplementationId( ) throw (::com::sun::star::uno::RuntimeException); + + // XServiceInfo + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(CreationWizardUnoDlg) + + // XExecutableDialog + virtual void SAL_CALL setTitle( const ::rtl::OUString& aTitle ) throw (::com::sun::star::uno::RuntimeException); + virtual sal_Int16 SAL_CALL execute( ) throw (::com::sun::star::uno::RuntimeException); + + // XInitialization + virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); + + // XTerminateListener + virtual void SAL_CALL queryTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::frame::TerminationVetoException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL notifyTermination( const ::com::sun::star::lang::EventObject& Event ) throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException); + + //XPropertySet + virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo( ) throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addPropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& xListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removePropertyChangeListener( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertyChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeVetoableChangeListener( const ::rtl::OUString& PropertyName, const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XVetoableChangeListener >& aListener ) throw (::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException); + + DECL_LINK( DialogEventHdl, VclWindowEvent* ); + +protected: + // ____ OComponentHelper ____ + /// Called in dispose method after the listeners were notified. + virtual void SAL_CALL disposing(); + +private: + //no default constructor + CreationWizardUnoDlg(); + void createDialogOnDemand(); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xChartModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext> m_xCC; + com::sun::star::uno::Reference< + com::sun::star::awt::XWindow > m_xParentWindow; + + CreationWizard* m_pDialog; + sal_Bool m_bUnlockControllersOnExecute; +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/inc/dlg_DataEditor.hxx b/chart2/source/controller/inc/dlg_DataEditor.hxx new file mode 100644 index 000000000000..fd565aba081b --- /dev/null +++ b/chart2/source/controller/inc/dlg_DataEditor.hxx @@ -0,0 +1,124 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataEditor.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef _SCH_DGRDATA_HXX +#define _SCH_DGRDATA_HXX + +#include <svtools/lstner.hxx> +#include <svtools/stdctrl.hxx> +#include <vcl/toolbox.hxx> +#include <comphelper/stl_types.hxx> +#include <vcl/dialog.hxx> +#include <com/sun/star/uno/XComponentContext.hpp> + +#include <memory> + +namespace com { namespace sun { namespace star { + namespace chart2 { + class XChartDocument; + } +}}} + +namespace chart +{ + +class DataBrowser; + +class DataEditor : public ModalDialog +{ +public: + DataEditor( Window* pParent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDoc, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~DataEditor(); + + // Window + virtual void Resize(); + + // Dialog + virtual BOOL Close(); + + void SetReadOnly( bool bReadOnly ); + bool ApplyChangesToModel(); + +private: + bool m_bReadOnly; + ::std::auto_ptr< DataBrowser > m_apBrwData; + ToolBox m_aTbxData; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDoc; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + m_xContext; + ImageList m_aToolboxImageList; + ImageList m_aToolboxImageListHighContrast; + + /// handles actions of the toolbox + DECL_LINK( ToolboxHdl, void* ); + /// is called, if the cursor of the table has moved + DECL_LINK( BrowserCursorMovedHdl, void*); + /// this is called if MiscOptions change, esp. High-Contrast mode + DECL_LINK( MiscHdl, void* ); + /// is called when the contents of the edit cell changes + DECL_LINK( CellModified, void* ); + /// is called when the width of any column in the edit browsebox has changed + DECL_LINK( BrowserColumnResized, void* ); + /// is called when the browser view was scrolled, @todo: only call on horizontal scroll + DECL_LINK( BrowserContentScrolled, void* ); + + void UpdateData(); + void ApplyImageList(); + /// moved and resizes the series name control etc. to fit the dimensions of the edit browsebox +// void ImplAdjustHeaderControls( bool bRefreshFromModel ); + + /** notifySystemWindow adds or remove the given window pToRegister at the Systemwindow found when search pWindow. + @param pWindow + The window which is used to search for the SystemWindow. + @param pToRegister + The window which should be added or removed on the TaskPaneList. + @param rMemFunc + The member function which should be called at the SystemWindow when found. + Possible values are: + ::comphelper::mem_fun(&TaskPaneList::AddWindow) + ::comphelper::mem_fun(&TaskPaneList::RemoveWindow) + + @note this code is taken from dbaccess/source/ui/inc/UITools.hxx + */ + void notifySystemWindow( Window* pWindow, + Window* pToRegister, + ::comphelper::mem_fun1_t< TaskPaneList, Window* > rMemFunc ); + + void AdaptBrowseBoxSize(); +}; + +} // namespace chart + +#endif // _SCH_DGRDATA_HXX diff --git a/chart2/source/controller/inc/dlg_DataSource.hxx b/chart2/source/controller/inc/dlg_DataSource.hxx new file mode 100644 index 000000000000..331136607e75 --- /dev/null +++ b/chart2/source/controller/inc/dlg_DataSource.hxx @@ -0,0 +1,103 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_DataSource.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DATASOURCEDIALOG_HXX +#define CHART2_DATASOURCEDIALOG_HXX + +// header for class TabDialog +#include <vcl/tabdlg.hxx> +// header for class TabControl +#include <vcl/tabctrl.hxx> +// header for class OKButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif + +#include "TabPageNotifiable.hxx" +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> + +// for auto_ptr +#include <memory> + +namespace chart +{ + +class DataSourceTabControl; +class RangeChooserTabPage; +class DataSourceTabPage; +class ChartTypeTemplateProvider; +class DialogModel; + +class DataSourceDialog : + public TabDialog, + public TabPageNotifiable +{ +public: + explicit DataSourceDialog( + Window * pParent, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~DataSourceDialog(); + + // from Dialog (base of TabDialog) + virtual short Execute(); + + // TabPageNotifiable + virtual void setInvalidPage( TabPage * pTabPage ); + virtual void setValidPage( TabPage * pTabPage ); + +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > + m_xChartDocument; + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > + m_xContext; + ::std::auto_ptr< ChartTypeTemplateProvider > m_apDocTemplateProvider; + ::std::auto_ptr< DialogModel > m_apDialogModel; + +private: + DataSourceTabControl* m_pTabControl; + OKButton m_aBtnOK; + CancelButton m_aBtnCancel; + HelpButton m_aBtnHelp; + + RangeChooserTabPage * m_pRangeChooserTabePage; + DataSourceTabPage * m_pDataSourceTabPage; + bool m_bRangeChooserTabIsValid; + bool m_bDataSourceTabIsValid; + + static USHORT m_nLastPageId; +}; + +} // namespace chart + +// CHART2_DATASOURCEDIALOG_HXX +#endif diff --git a/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx new file mode 100644 index 000000000000..4a322df598e5 --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertAxis_Grid.hxx @@ -0,0 +1,104 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertAxis_Grid.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_INSERT_AXIS_GRID_HXX +#define _CHART2_DLG_INSERT_AXIS_GRID_HXX + +// header for class ModalDialog +#include <vcl/dialog.hxx> +// header for class FixedLine +#include <vcl/fixed.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +#include <com/sun/star/uno/Sequence.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +struct InsertAxisOrGridDialogData +{ + ::com::sun::star::uno::Sequence< sal_Bool > aPossibilityList; + ::com::sun::star::uno::Sequence< sal_Bool > aExistenceList; + + InsertAxisOrGridDialogData(); +}; + +/************************************************************************* +|* +|* insert Axis dialog (also base for grid dialog) +|* +\************************************************************************/ +class SchAxisDlg : public ModalDialog +{ +protected: + FixedLine aFlPrimary; + FixedLine aFlPrimaryGrid; + CheckBox aCbPrimaryX; + CheckBox aCbPrimaryY; + CheckBox aCbPrimaryZ; + + FixedLine aFlSecondary; + FixedLine aFlSecondaryGrid; + CheckBox aCbSecondaryX; + CheckBox aCbSecondaryY; + CheckBox aCbSecondaryZ; + + OKButton aPbOK; + CancelButton aPbCancel; + HelpButton aPbHelp; + +public: + SchAxisDlg( Window* pParent, const InsertAxisOrGridDialogData& rInput, BOOL bAxisDlg=true ); + virtual ~SchAxisDlg(); + + void getResult( InsertAxisOrGridDialogData& rOutput ); +}; + + +/************************************************************************* +|* +|* Grid dialog +|* +\************************************************************************/ +class SchGridDlg : public SchAxisDlg +{ +public: + SchGridDlg( Window* pParent, const InsertAxisOrGridDialogData& rInput ); + virtual ~SchGridDlg(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/dlg_InsertDataLabel.hxx b/chart2/source/controller/inc/dlg_InsertDataLabel.hxx new file mode 100644 index 000000000000..d5748a3e990f --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertDataLabel.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertDataLabel.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DLG_INSERT_DATALABELS_GRID_HXX +#define CHART2_DLG_INSERT_DATALABELS_GRID_HXX + +// header for class ModalDialog +#include <vcl/dialog.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class SfxItemSet +#include <svtools/itemset.hxx> +//for auto_ptr +#include <memory> + +class SvNumberFormatter; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class DataLabelResources; +class DataLabelsDialog : public ModalDialog +{ +private: + OKButton m_aBtnOK; + CancelButton m_aBtnCancel; + HelpButton m_aBtnHelp; + ::std::auto_ptr< DataLabelResources > m_apDataLabelResources; + + const SfxItemSet& m_rInAttrs; + + void Reset(); + +public: + DataLabelsDialog(Window* pParent, const SfxItemSet& rInAttrs, SvNumberFormatter* pFormatter); + virtual ~DataLabelsDialog(); + + void FillItemSet(SfxItemSet& rOutAttrs); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/dlg_InsertErrorBars.hxx b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx new file mode 100644 index 000000000000..13382ff9bffa --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertErrorBars.hxx @@ -0,0 +1,81 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertErrorBars.hxx,v $ + * $Revision: 1.4.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_INSERT_ERRORBARS_HXX +#define _CHART2_DLG_INSERT_ERRORBARS_HXX + +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <svtools/itemset.hxx> +#include <memory> +#include <com/sun/star/frame/XModel.hpp> + +#include "res_ErrorBar.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. + +class InsertErrorBarsDialog : public ModalDialog +{ +public: + InsertErrorBarsDialog( Window* pParent, const SfxItemSet& rMyAttrs, + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument, + ErrorBarResources::tErrorBarType eType = ErrorBarResources::ERROR_BAR_Y ); + virtual ~InsertErrorBarsDialog(); + + void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); + + static double getAxisMinorStepWidthForErrorBarDecimals( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface >& xChartView, + const ::rtl::OUString& rSelectedObjectCID ); + + void FillItemSet( SfxItemSet& rOutAttrs ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + +private: + const SfxItemSet & rInAttrs; + + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + + ::std::auto_ptr< ErrorBarResources > m_apErrorBarResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/dlg_InsertLegend.hxx b/chart2/source/controller/inc/dlg_InsertLegend.hxx new file mode 100644 index 000000000000..3b8a0e8724a6 --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertLegend.hxx @@ -0,0 +1,75 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertLegend.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_INSERT_LEGEND_GRID_HXX +#define _CHART2_DLG_INSERT_LEGEND_GRID_HXX + +// header for class ModalDialog +#include <vcl/dialog.hxx> +// header for class CheckBox +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +//for auto_ptr +#include <memory> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class LegendPositionResources; +class SchLegendDlg : public ModalDialog +{ +private: + ::std::auto_ptr< LegendPositionResources > m_apLegendPositionResources; + + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + +public: + SchLegendDlg( Window* pParent, const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext>& xCC ); + virtual ~SchLegendDlg(); + + void init( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + bool writeToModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ) const; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/inc/dlg_InsertTitle.hxx b/chart2/source/controller/inc/dlg_InsertTitle.hxx new file mode 100644 index 000000000000..9accd10a7a6e --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertTitle.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTitle.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_INSERT_TITLE_GRID_HXX +#define _CHART2_DLG_INSERT_TITLE_GRID_HXX + +#include "TitleDialogData.hxx" +#include <vcl/dialog.hxx> +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +//for auto_ptr +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. +class TitleResources; +class SchTitleDlg : public ModalDialog +{ +private: + ::std::auto_ptr< TitleResources > m_apTitleResources; + + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + +public: + SchTitleDlg( Window* pParent, const TitleDialogData& rInput ); + virtual ~SchTitleDlg(); + + void getResult( TitleDialogData& rOutput ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/inc/dlg_InsertTrendline.hxx b/chart2/source/controller/inc/dlg_InsertTrendline.hxx new file mode 100644 index 000000000000..517da8fb6930 --- /dev/null +++ b/chart2/source/controller/inc/dlg_InsertTrendline.hxx @@ -0,0 +1,71 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_InsertTrendline.hxx,v $ + * $Revision: 1.3.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_INSERT_TRENDLINE_HXX +#define _CHART2_DLG_INSERT_TRENDLINE_HXX + +#include <vcl/dialog.hxx> +#include <vcl/button.hxx> +#include <svtools/itemset.hxx> +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class TrendlineResources; +class InsertTrendlineDialog : public ModalDialog +{ +public: + InsertTrendlineDialog( Window* pParent, const SfxItemSet& rMyAttrs ); + virtual ~InsertTrendlineDialog(); + + void FillItemSet( SfxItemSet& rOutAttrs ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + + // sets the size so that all control texts fit. Has to be done after + // complete construction of the dialog + void adjustSize(); + +private: + const SfxItemSet & rInAttrs; + + OKButton aBtnOK; + CancelButton aBtnCancel; + HelpButton aBtnHelp; + + ::std::auto_ptr< TrendlineResources > m_apTrendlineResources; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/dlg_ObjectProperties.hxx b/chart2/source/controller/inc/dlg_ObjectProperties.hxx new file mode 100644 index 000000000000..39a738563c50 --- /dev/null +++ b/chart2/source/controller/inc/dlg_ObjectProperties.hxx @@ -0,0 +1,158 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_ObjectProperties.hxx,v $ + * $Revision: 1.11.42.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_OBJECTPROPERTIES_HXX +#define _CHART2_DLG_OBJECTPROPERTIES_HXX + +#include "ObjectIdentifier.hxx" +#include <sfx2/tabdlg.hxx> +// header for typedef ChangeType +#include <svx/tabarea.hxx> +#include <com/sun/star/util/XNumberFormatsSupplier.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ObjectPropertiesDialogParameter +{ +public: + ObjectPropertiesDialogParameter( const rtl::OUString& rObjectCID ); + virtual ~ObjectPropertiesDialogParameter(); + + void init( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xModel ); + ObjectType getObjectType() const; + rtl::OUString getLocalizedName() const; + + bool HasGeometryProperties() const; + bool HasStatisticProperties() const; + bool ProvidesSecondaryYAxis() const; + bool ProvidesOverlapAndGapWidth() const; + bool ProvidesBarConnectors() const; + bool HasAreaProperties() const; + bool HasSymbolProperties() const; + bool HasNumberProperties() const; + bool ProvidesStartingAngle() const; + bool ProvidesMissingValueTreatments() const; + + bool HasScaleProperties() const; + bool CanAxisLabelsBeStaggered() const; + bool IsSupportingAxisPositioning() const; + bool ShowAxisOrigin() const; + bool IsCrossingAxisIsCategoryAxis() const; + const ::com::sun::star::uno::Sequence< rtl::OUString >& GetCategories() const; + + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > + getDocument() const; + +private: + rtl::OUString m_aObjectCID; + ObjectType m_eObjectType; + bool m_bAffectsMultipleObjects;//is true if more than one object of the given type will be changed (e.g. all axes or all titles) + + rtl::OUString m_aLocalizedName; + + bool m_bHasGeometryProperties; + bool m_bHasStatisticProperties; + bool m_bProvidesSecondaryYAxis; + bool m_bProvidesOverlapAndGapWidth; + bool m_bProvidesBarConnectors; + bool m_bHasAreaProperties; + bool m_bHasSymbolProperties; + bool m_bHasNumberProperties; + bool m_bProvidesStartingAngle; + bool m_bProvidesMissingValueTreatments; + + bool m_bHasScaleProperties; + bool m_bCanAxisLabelsBeStaggered; + + bool m_bSupportingAxisPositioning; + bool m_bShowAxisOrigin; + bool m_bIsCrossingAxisIsCategoryAxis; + ::com::sun::star::uno::Sequence< rtl::OUString > m_aCategories; + + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > m_xChartDocument; +}; + +/************************************************************************* +|* +|* dialog for properties of different chart object +|* +\************************************************************************/ + +class ViewElementListProvider; + +class SchAttribTabDlg : public SfxTabDialog +{ +private: + ObjectType eObjectType; + bool bAffectsMultipleObjects;//is true if more than one object of the given type will be changed (e.g. all axes or all titles) + USHORT nDlgType; + USHORT nPageType; + + const ObjectPropertiesDialogParameter * const m_pParameter; + const ViewElementListProvider* const m_pViewElementListProvider; + SvNumberFormatter* m_pNumberFormatter; + + SfxItemSet* m_pSymbolShapeProperties; + Graphic* m_pAutoSymbolGraphic; + + double m_fAxisMinorStepWidthForErrorBarDecimals; + bool m_bOKPressed; + + virtual void PageCreated(USHORT nId, SfxTabPage& rPage); + + Link m_aOriginalOKClickHdl; + DECL_LINK( OKPressed, void * ); + +public: + SchAttribTabDlg(Window* pParent, const SfxItemSet* pAttr, + const ObjectPropertiesDialogParameter* pDialogParameter, + const ViewElementListProvider* pViewElementListProvider, + const ::com::sun::star::uno::Reference< + ::com::sun::star::util::XNumberFormatsSupplier >& xNumberFormatsSupplier ); + virtual ~SchAttribTabDlg(); + + //pSymbolShapeProperties: Properties to be set on the symbollist shapes + //pAutoSymbolGraphic: Graphic to be shown if AutoSymbol gets selected + //this class takes ownership over both parameter + void setSymbolInformation( SfxItemSet* pSymbolShapeProperties, Graphic* pAutoSymbolGraphic ); + + void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); + + bool DialogWasClosedWithOK() const; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/inc/dlg_View3D.hxx b/chart2/source/controller/inc/dlg_View3D.hxx new file mode 100644 index 000000000000..c10390e45c05 --- /dev/null +++ b/chart2/source/controller/inc/dlg_View3D.hxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: dlg_View3D.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_DLG_VIEW3D_DIAGRAM_HXX +#define _CHART2_DLG_VIEW3D_DIAGRAM_HXX + +#include <com/sun/star/drawing/ShadeMode.hpp> +#include <com/sun/star/frame/XModel.hpp> + +// header for class TabDialog +#include <vcl/tabdlg.hxx> +// header for class TabControl +#include <vcl/tabctrl.hxx> +// header for class OKButton +#ifndef _SV_BUTTON_HXX +#include <vcl/button.hxx> +#endif +// header for class XColorTable +#include <svx/xtable.hxx> + +#include "ControllerLockGuard.hxx" + +//............................................................................. +namespace chart +{ +//............................................................................. +class ThreeD_SceneGeometry_TabPage; +class ThreeD_SceneAppearance_TabPage; +class ThreeD_SceneIllumination_TabPage; + +class View3DDialog : public TabDialog +{ +public: + View3DDialog( Window* pWindow, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > & xChartModel, + XColorTable* pColorTable=0 ); + ~View3DDialog(); + + // from Dialog (base of TabDialog) + virtual short Execute(); + +private: + TabControl m_aTabControl; + OKButton m_aBtnOK; + CancelButton m_aBtnCancel; + HelpButton m_aBtnHelp; + + ThreeD_SceneGeometry_TabPage* m_pGeometry; + ThreeD_SceneAppearance_TabPage* m_pAppearance; + ThreeD_SceneIllumination_TabPage* m_pIllumination; + + ControllerLockHelper m_aControllerLocker; + + static USHORT m_nLastPageId; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/inc/res_ErrorBar.hxx b/chart2/source/controller/inc/res_ErrorBar.hxx new file mode 100644 index 000000000000..e1490f5b7e50 --- /dev/null +++ b/chart2/source/controller/inc/res_ErrorBar.hxx @@ -0,0 +1,157 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: res_ErrorBar.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_RES_ERRORBAR_HXX +#define CHART2_RES_ERRORBAR_HXX + +#include <vcl/button.hxx> +#include <vcl/fixed.hxx> +#include <vcl/field.hxx> +#include <vcl/lstbox.hxx> +#include <svtools/valueset.hxx> +#include <svtools/itemset.hxx> +#include <svx/chrtitem.hxx> +#include "chartview/ChartSfxItemIds.hxx" +#include "RangeSelectionButton.hxx" +#include "RangeSelectionListener.hxx" +#include "RangeEdit.hxx" + +#include <com/sun/star/chart2/XChartDocument.hpp> + +#include <memory> + +class Dialog; + +//............................................................................. +namespace chart +{ +//............................................................................. + +class RangeSelectionHelper; + +class ErrorBarResources : public RangeSelectionListenerParent +{ +public: + enum tErrorBarType + { + ERROR_BAR_X, + ERROR_BAR_Y + }; + + ErrorBarResources( + Window* pParent, Dialog * pParentDialog, const SfxItemSet& rInAttrst, + bool bNoneAvailable, + tErrorBarType eType = ERROR_BAR_Y ); + virtual ~ErrorBarResources(); + + void SetAxisMinorStepWidthForErrorBarDecimals( double fMinorStepWidth ); + void SetErrorBarType( tErrorBarType eNewType ); + void SetChartDocumentForRangeChoosing( + const ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > & xChartDocument ); + void Reset(const SfxItemSet& rInAttrs); + BOOL FillItemSet(SfxItemSet& rOutAttrs) const; + + void FillValueSets(); + + // ____ RangeSelectionListenerParent ____ + virtual void listeningFinished( const ::rtl::OUString & rNewRange ); + virtual void disposingRangeSelection(); + +private: + // category + FixedLine m_aFlErrorCategory; + RadioButton m_aRbNone; + RadioButton m_aRbConst; + RadioButton m_aRbPercent; + RadioButton m_aRbFunction; + RadioButton m_aRbRange; + ListBox m_aLbFunction; + + // parameters + FixedLine m_aFlParameters; + FixedText m_aFtPositive; + MetricField m_aMfPositive; + RangeEdit m_aEdRangePositive; + RangeSelectionButton m_aIbRangePositive; + FixedText m_aFtNegative; + MetricField m_aMfNegative; + RangeEdit m_aEdRangeNegative; + RangeSelectionButton m_aIbRangeNegative; + CheckBox m_aCbSyncPosNeg; + + // indicator + FixedLine m_aFlIndicate; + RadioButton m_aRbBoth; + RadioButton m_aRbPositive; + RadioButton m_aRbNegative; + FixedImage m_aFiBoth; + FixedImage m_aFiPositive; + FixedImage m_aFiNegative; + + SvxChartKindError m_eErrorKind; + SvxChartIndicate m_eIndicate; + SvxChartRegress m_eTrendLineType; + + bool m_bErrorKindUnique; + bool m_bIndicatorUnique; + bool m_bPlusUnique; + bool m_bMinusUnique; + bool m_bRangePosUnique; + bool m_bRangeNegUnique; + + bool m_bNoneAvailable; + + tErrorBarType m_eErrorBarType; + sal_uInt16 m_nConstDecimalDigits; + sal_Int64 m_nConstSpinSize; + + Window * m_pParentWindow; + Dialog * m_pParentDialog; + ::std::auto_ptr< RangeSelectionHelper > + m_apRangeSelectionHelper; + Edit * m_pCurrentRangeChoosingField; + bool m_bHasInternalDataProvider; + + DECL_LINK( CategoryChosen, void * ); + DECL_LINK( SynchronizePosAndNeg, void * ); + DECL_LINK( PosValueChanged, void * ); + DECL_LINK( IndicatorChanged, void * ); + DECL_LINK( ChooseRange, RangeSelectionButton * ); + DECL_LINK( RangeChanged, Edit * ); + + void UpdateControlStates(); + bool isRangeFieldContentValid( Edit & rEdit ); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx new file mode 100644 index 000000000000..0c7ff467a91b --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/AxisItemConverter.cxx @@ -0,0 +1,838 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: AxisItemConverter.cxx,v $ + * $Revision: 1.14.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "AxisItemConverter.hxx" +#include "ItemPropertyMap.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "chartview/ChartSfxItemIds.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" +#include "CommonConverters.hxx" + +#include <com/sun/star/chart/ChartAxisLabelPosition.hpp> +#include <com/sun/star/chart/ChartAxisMarkPosition.hpp> +#include <com/sun/star/chart/ChartAxisPosition.hpp> +#include <com/sun/star/chart2/XAxis.hpp> +#include <com/sun/star/chart2/AxisOrientation.hpp> + +// for SfxBoolItem +#include <svtools/eitem.hxx> +// for SvxDoubleItem +#include <svx/chrtitem.hxx> +// for SfxInt32Item +#include <svtools/intitem.hxx> +#include <rtl/math.hxx> + +#include <algorithm> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetAxisPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aAxisPropertyMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( SCHATTR_AXIS_SHOWDESCR, "DisplayLabels", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_TICKS, "MajorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_AXIS_HELPTICKS, "MinorTickmarks", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_ORDER, "ArrangeOrder", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXTBREAK, "TextBreak", 0 ) + IPM_MAP_ENTRY( SCHATTR_TEXT_OVERLAP, "TextOverlap", 0 ) + ); + + return aAxisPropertyMap; +}; +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +AxisItemConverter::AxisItemConverter( + const Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const Reference< chart2::XChartDocument > & xChartDoc, + chart2::ExplicitScaleData * pScale /* = NULL */, + chart2::ExplicitIncrementData * pIncrement /* = NULL */, + ::std::auto_ptr< awt::Size > pRefSize /* = NULL */ ) : + ItemConverter( rPropertySet, rItemPool ), + m_xChartDoc( xChartDoc ), + m_pExplicitScale( NULL ), + m_pExplicitIncrement( NULL ) +{ + Reference< lang::XMultiServiceFactory > xNamedPropertyContainerFactory( xChartDoc, uno::UNO_QUERY ); + + if( pScale ) + m_pExplicitScale = new chart2::ExplicitScaleData( *pScale ); + if( pIncrement ) + m_pExplicitIncrement = new chart2::ExplicitIncrementData( *pIncrement ); + + m_aConverters.push_back( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_PROPERTIES )); + m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize, + C2U( "ReferencePageSize" ) )); + + m_xAxis.set( Reference< chart2::XAxis >( rPropertySet, uno::UNO_QUERY ) ); + OSL_ASSERT( m_xAxis.is()); +} + +AxisItemConverter::~AxisItemConverter() +{ + delete m_pExplicitScale; + delete m_pExplicitIncrement; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void AxisItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool AxisItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * AxisItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nAxisWhichPairs; +} + +bool AxisItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType & rMap( lcl_GetAxisPropertyMap()); + ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); + + if( aIt == rMap.end()) + return false; + + rOutProperty =(*aIt).second; + + return true; +} + +void AxisItemConverter::FillSpecialItem( USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + if( ! m_xAxis.is() ) + return; + + const chart2::ScaleData aScale( m_xAxis->getScaleData() ); + const chart2::IncrementData aInc( aScale.IncrementData ); + const uno::Sequence< chart2::SubIncrement > aSubIncs( aScale.IncrementData.SubIncrements ); + + switch( nWhichId ) + { + case SCHATTR_AXIS_AUTO_MAX: + // if the any has no value => auto is on + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Maximum) ) ); + break; + + case SCHATTR_AXIS_MAX: + { + double fMax = 10.0; + if( aScale.Maximum >>= fMax ) + { + rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); + } + else + { + if( m_pExplicitScale ) + fMax = m_pExplicitScale->Maximum; + rOutItemSet.Put( SvxDoubleItem( fMax, nWhichId ) ); + } + } + break; + + case SCHATTR_AXIS_AUTO_MIN: + // if the any has no value => auto is on + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aScale.Minimum) ) ); + break; + + case SCHATTR_AXIS_MIN: + { + double fMin = 0.0; + if( aScale.Minimum >>= fMin ) + { + rOutItemSet.Put( SvxDoubleItem( fMin, nWhichId ) ); + } + else + { + if( m_pExplicitScale ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitScale->Minimum, nWhichId )); + } + } + break; + + case SCHATTR_AXIS_LOGARITHM: + { + BOOL bValue = AxisHelper::isLogarithmic( aScale.Scaling ); + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + } + break; + + case SCHATTR_AXIS_REVERSE: + rOutItemSet.Put( SfxBoolItem( nWhichId, (AxisOrientation_REVERSE == aScale.Orientation) )); + break; + + // Increment + case SCHATTR_AXIS_AUTO_STEP_MAIN: + // if the any has no value => auto is on + rOutItemSet.Put( SfxBoolItem( nWhichId, !hasDoubleValue(aInc.Distance) ) ); + break; + + case SCHATTR_AXIS_STEP_MAIN: + { + double fDistance = 1.0; + if( aInc.Distance >>= fDistance ) + { + rOutItemSet.Put( SvxDoubleItem(fDistance, nWhichId )); + } + else + { + if( m_pExplicitIncrement ) + rOutItemSet.Put( SvxDoubleItem( m_pExplicitIncrement->Distance, nWhichId )); + } + } + break; + + // SubIncrement + case SCHATTR_AXIS_AUTO_STEP_HELP: + { + // if the any has no value => auto is on + rOutItemSet.Put( + SfxBoolItem( + nWhichId, + ! ( aSubIncs.getLength() > 0 && + aSubIncs[0].IntervalCount.hasValue() ))); + } + break; + + case SCHATTR_AXIS_STEP_HELP: + { + if( aSubIncs.getLength() > 0 && + aSubIncs[0].IntervalCount.hasValue()) + { + OSL_ASSERT( aSubIncs[0].IntervalCount.getValueTypeClass() == uno::TypeClass_LONG ); + rOutItemSet.Put( + SfxInt32Item( + nWhichId, + *reinterpret_cast< const sal_Int32 * >( + aSubIncs[0].IntervalCount.getValue()) )); + } + else + { + if( m_pExplicitIncrement && + m_pExplicitIncrement->SubIncrements.getLength() > 0 ) + { + rOutItemSet.Put( + SfxInt32Item( + nWhichId, + m_pExplicitIncrement->SubIncrements[0].IntervalCount )); + } + } + } + break; + + case SCHATTR_AXIS_AUTO_ORIGIN: + { + // if the any has no double value => auto is on + rOutItemSet.Put( SfxBoolItem( nWhichId, ( !hasDoubleValue(aScale.Origin) ))); + } + break; + + case SCHATTR_AXIS_ORIGIN: + { + double fOrigin = 0.0; + if( !(aScale.Origin >>= fOrigin) ) + { + if( m_pExplicitScale ) + fOrigin = m_pExplicitScale->Origin; + } + rOutItemSet.Put( SvxDoubleItem( fOrigin, nWhichId )); + } + break; + + case SCHATTR_AXIS_POSITION: + { + ::com::sun::star::chart::ChartAxisPosition eAxisPos( ::com::sun::star::chart::ChartAxisPosition_ZERO ); + GetPropertySet()->getPropertyValue(C2U( "CrossoverPosition" )) >>= eAxisPos; + rOutItemSet.Put( SfxInt32Item( nWhichId, eAxisPos ) ); + } + break; + + case SCHATTR_AXIS_POSITION_VALUE: + { + double fValue = 0.0; + if( GetPropertySet()->getPropertyValue(C2U( "CrossoverValue" )) >>= fValue ) + rOutItemSet.Put( SvxDoubleItem( fValue, nWhichId ) ); + } + break; + + case SCHATTR_AXIS_CROSSING_MAIN_AXIS_NUMBERFORMAT: + { + //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 ) ) ); + + Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); + + sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + xCrossingMainAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) ); + + rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); + } + break; + + case SCHATTR_AXIS_LABEL_POSITION: + { + ::com::sun::star::chart::ChartAxisLabelPosition ePos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ); + GetPropertySet()->getPropertyValue(C2U( "LabelPosition" )) >>= ePos; + rOutItemSet.Put( SfxInt32Item( nWhichId, ePos ) ); + } + break; + + case SCHATTR_AXIS_MARK_POSITION: + { + ::com::sun::star::chart::ChartAxisMarkPosition ePos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); + GetPropertySet()->getPropertyValue(C2U( "MarkPosition" )) >>= ePos; + rOutItemSet.Put( SfxInt32Item( nWhichId, ePos ) ); + } + break; + + case SCHATTR_TEXT_DEGREES: + { + // convert double to int (times 100) + double fVal = 0; + + if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fVal ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >( + ::rtl::math::round( fVal * 100.0 ) ) )); + } + } + break; + + case SID_ATTR_NUMBERFORMAT_VALUE: +// case SCHATTR_AXIS_NUMFMT: + { + if( m_pExplicitScale ) + { + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + + sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) ); + + rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); + } + } + break; + + case SID_ATTR_NUMBERFORMAT_SOURCE: + { + bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue()); + rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet )); + } + break; + + case SCHATTR_AXISTYPE: + rOutItemSet.Put( SfxInt32Item( nWhichId, aScale.AxisType )); + break; + } +} + +bool AxisItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + if( !m_xAxis.is() ) + return false; + + chart2::ScaleData aScale( m_xAxis->getScaleData() ); + + bool bSetScale = false; + bool bChangedOtherwise = false; + + uno::Any aValue; + + switch( nWhichId ) + { + case SCHATTR_AXIS_AUTO_MAX: + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.Maximum.clear(); + bSetScale = true; + } + // else SCHATTR_AXIS_MAX must have some value + break; + + case SCHATTR_AXIS_MAX: + // only if auto if false + if( ! (static_cast< const SfxBoolItem & >( + rItemSet.Get( SCHATTR_AXIS_AUTO_MAX )).GetValue() )) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + + if( aScale.Maximum != aValue ) + { + aScale.Maximum = aValue; + bSetScale = true; + } + } + break; + + case SCHATTR_AXIS_AUTO_MIN: + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.Minimum.clear(); + bSetScale = true; + } + // else SCHATTR_AXIS_MIN must have some value + break; + + case SCHATTR_AXIS_MIN: + // only if auto if false + if( ! (static_cast< const SfxBoolItem & >( + rItemSet.Get( SCHATTR_AXIS_AUTO_MIN )).GetValue() )) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + + if( aScale.Minimum != aValue ) + { + aScale.Minimum = aValue; + bSetScale = true; + } + } + break; + + case SCHATTR_AXIS_LOGARITHM: + { + bool bWasLogarithm = AxisHelper::isLogarithmic( aScale.Scaling ); + + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() )) + { + // logarithm is true + if( ! bWasLogarithm ) + { + aScale.Scaling = AxisHelper::createLogarithmicScaling( 10.0 ); + bSetScale = true; + } + } + else + { + // logarithm is false => linear scaling + if( bWasLogarithm ) + { + aScale.Scaling = AxisHelper::createLinearScaling(); + bSetScale = true; + } + } + } + break; + + case SCHATTR_AXIS_REVERSE: + { + bool bWasReverse = ( AxisOrientation_REVERSE == aScale.Orientation ); + bool bNewReverse = (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() ); + if( bWasReverse != bNewReverse ) + { + aScale.Orientation = bNewReverse ? AxisOrientation_REVERSE : AxisOrientation_MATHEMATICAL; + bSetScale = true; + } + } + break; + + // Increment + case SCHATTR_AXIS_AUTO_STEP_MAIN: + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.IncrementData.Distance.clear(); + bSetScale = true; + } + // else SCHATTR_AXIS_STEP_MAIN must have some value + break; + + case SCHATTR_AXIS_STEP_MAIN: + // only if auto if false + if( ! (static_cast< const SfxBoolItem & >( + rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_MAIN )).GetValue() )) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + + if( aScale.IncrementData.Distance != aValue ) + { + aScale.IncrementData.Distance = aValue; + bSetScale = true; + } + } + break; + + // SubIncrement + case SCHATTR_AXIS_AUTO_STEP_HELP: + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() ) && + aScale.IncrementData.SubIncrements.getLength() > 0 && + aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() ) + { + aScale.IncrementData.SubIncrements[0].IntervalCount.clear(); + bSetScale = true; + } + // else SCHATTR_AXIS_STEP_MAIN must have some value + break; + + case SCHATTR_AXIS_STEP_HELP: + // only if auto if false + if( ! (static_cast< const SfxBoolItem & >( + rItemSet.Get( SCHATTR_AXIS_AUTO_STEP_HELP )).GetValue() ) && + aScale.IncrementData.SubIncrements.getLength() > 0 ) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + + if( ! aScale.IncrementData.SubIncrements[0].IntervalCount.hasValue() || + aScale.IncrementData.SubIncrements[0].IntervalCount != aValue ) + { + OSL_ASSERT( aValue.getValueTypeClass() == uno::TypeClass_LONG ); + aScale.IncrementData.SubIncrements[0].IntervalCount = aValue; + bSetScale = true; + } + } + break; + + case SCHATTR_AXIS_AUTO_ORIGIN: + { + if( (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() )) + { + aScale.Origin.clear(); + bSetScale = true; + } + } + break; + + case SCHATTR_AXIS_ORIGIN: + { + // only if auto is false + if( ! (static_cast< const SfxBoolItem & >( + rItemSet.Get( SCHATTR_AXIS_AUTO_ORIGIN )).GetValue() )) + { + rItemSet.Get( nWhichId ).QueryValue( aValue ); + + if( aScale.Origin != aValue ) + { + aScale.Origin = aValue; + bSetScale = true; + + 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 ) ) ); + + 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 ); + if( xCrossingMainAxis.is() ) + { + double fValue = 0.0; + if( aValue >>= fValue ) + { + xCrossingMainAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_VALUE )); + xCrossingMainAxis->setPropertyValue( C2U( "CrossoverValue" ), uno::makeAny( fValue )); + } + else + xCrossingMainAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( ::com::sun::star::chart::ChartAxisPosition_START )); + } + } + } + } + } + } + break; + + case SCHATTR_AXIS_POSITION: + { + ::com::sun::star::chart::ChartAxisPosition eAxisPos = + (::com::sun::star::chart::ChartAxisPosition) + static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + + ::com::sun::star::chart::ChartAxisPosition eOldAxisPos( ::com::sun::star::chart::ChartAxisPosition_ZERO ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "CrossoverPosition" )) >>= eOldAxisPos ); + + if( !bPropExisted || ( eOldAxisPos != eAxisPos )) + { + GetPropertySet()->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( eAxisPos )); + bChangedOtherwise = true; + + //move the parallel axes to the other side if necessary + if( eAxisPos==::com::sun::star::chart::ChartAxisPosition_START || eAxisPos==::com::sun::star::chart::ChartAxisPosition_END ) + { + Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY ); + if( xParallelAxis.is() ) + { + ::com::sun::star::chart::ChartAxisPosition eOtherPos; + if( xParallelAxis->getPropertyValue( C2U( "CrossoverPosition" ) ) >>= eOtherPos ) + { + if( eOtherPos == eAxisPos ) + { + ::com::sun::star::chart::ChartAxisPosition eOppositePos = + (eAxisPos==::com::sun::star::chart::ChartAxisPosition_START) + ? ::com::sun::star::chart::ChartAxisPosition_END + : ::com::sun::star::chart::ChartAxisPosition_START; + xParallelAxis->setPropertyValue( C2U( "CrossoverPosition" ), uno::makeAny( eOppositePos )); + } + } + } + } + } + } + break; + + case SCHATTR_AXIS_POSITION_VALUE: + { + double fValue = static_cast< const SvxDoubleItem & >( rItemSet.Get( nWhichId )).GetValue(); + + double fOldValue = 0.0; + bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "CrossoverValue" )) >>= fOldValue ); + + if( !bPropExisted || ( fOldValue != fValue )) + { + GetPropertySet()->setPropertyValue( C2U( "CrossoverValue" ), uno::makeAny( 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 ) ) ); + + sal_Int32 nDimensionIndex=0; + sal_Int32 nAxisIndex=0; + if( AxisHelper::getIndicesForAxis( m_xAxis, xCooSys, nDimensionIndex, nAxisIndex ) && nAxisIndex==0 && nDimensionIndex==0 ) + { + Reference< chart2::XAxis > xCrossingMainAxis( AxisHelper::getCrossingMainAxis( m_xAxis, xCooSys ) ); + if( xCrossingMainAxis.is() ) + { + ScaleData aCrossingScale( xCrossingMainAxis->getScaleData() ); + aCrossingScale.Origin = uno::makeAny(fValue); + xCrossingMainAxis->setScaleData(aCrossingScale); + } + } + } + } + } + break; + + case SCHATTR_AXIS_LABEL_POSITION: + { + ::com::sun::star::chart::ChartAxisLabelPosition ePos = + (::com::sun::star::chart::ChartAxisLabelPosition) + static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + + ::com::sun::star::chart::ChartAxisLabelPosition eOldPos( ::com::sun::star::chart::ChartAxisLabelPosition_NEAR_AXIS ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "LabelPosition" )) >>= eOldPos ); + + if( !bPropExisted || ( eOldPos != ePos )) + { + GetPropertySet()->setPropertyValue( C2U( "LabelPosition" ), uno::makeAny( ePos )); + bChangedOtherwise = true; + + //move the parallel axes to the other side if necessary + if( ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START || ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END ) + { + Reference< beans::XPropertySet > xParallelAxis( AxisHelper::getParallelAxis( m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ), uno::UNO_QUERY ); + if( xParallelAxis.is() ) + { + ::com::sun::star::chart::ChartAxisLabelPosition eOtherPos; + if( xParallelAxis->getPropertyValue( C2U( "LabelPosition" ) ) >>= eOtherPos ) + { + if( eOtherPos == ePos ) + { + ::com::sun::star::chart::ChartAxisLabelPosition eOppositePos = + (ePos==::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START) + ? ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_END + : ::com::sun::star::chart::ChartAxisLabelPosition_OUTSIDE_START; + xParallelAxis->setPropertyValue( C2U( "LabelPosition" ), uno::makeAny( eOppositePos )); + } + } + } + } + } + } + break; + + case SCHATTR_AXIS_MARK_POSITION: + { + ::com::sun::star::chart::ChartAxisMarkPosition ePos = + (::com::sun::star::chart::ChartAxisMarkPosition) + static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + + ::com::sun::star::chart::ChartAxisMarkPosition eOldPos( ::com::sun::star::chart::ChartAxisMarkPosition_AT_LABELS_AND_AXIS ); + bool bPropExisted = ( GetPropertySet()->getPropertyValue(C2U( "MarkPosition" )) >>= eOldPos ); + + if( !bPropExisted || ( eOldPos != ePos )) + { + GetPropertySet()->setPropertyValue( C2U( "MarkPosition" ), uno::makeAny( ePos )); + bChangedOtherwise = true; + } + } + break; + + case SCHATTR_TEXT_DEGREES: + { + // convert int to double (divided by 100) + double fVal = static_cast< double >( + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()) / 100.0; + double fOldVal = 0.0; + bool bPropExisted = + ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldVal ); + + if( ! bPropExisted || + ( bPropExisted && fOldVal != fVal )) + { + GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fVal )); + bChangedOtherwise = true; + } + } + break; + + case SID_ATTR_NUMBERFORMAT_VALUE: +// case SCHATTR_AXIS_NUMFMT: + { + if( m_pExplicitScale ) + { + bool bUseSourceFormat = + (static_cast< const SfxBoolItem & >( + rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE )).GetValue() ); + + if( ! bUseSourceFormat ) + { + sal_Int32 nFmt = static_cast< sal_Int32 >( + static_cast< const SfxUInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()); + + aValue = uno::makeAny(nFmt); + if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue ) + { + GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue ); + bChangedOtherwise = true; + } + } + } + } + break; + + case SID_ATTR_NUMBERFORMAT_SOURCE: + { + bool bUseSourceFormat = + (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() ); + bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue()); + + bChangedOtherwise = (bUseSourceFormat == bNumberFormatIsSet); + if( bChangedOtherwise ) + { + if( ! bUseSourceFormat ) + { + SfxItemState aState = rItemSet.GetItemState( SID_ATTR_NUMBERFORMAT_VALUE ); + if( aState == SFX_ITEM_SET ) + { + sal_Int32 nFormatKey = static_cast< sal_Int32 >( + static_cast< const SfxUInt32Item & >( + rItemSet.Get( SID_ATTR_NUMBERFORMAT_VALUE )).GetValue()); + aValue <<= nFormatKey; + } + else + { + Reference< chart2::XCoordinateSystem > xCooSys( + AxisHelper::getCoordinateSystemOfAxis( + m_xAxis, ChartModelHelper::findDiagram( m_xChartDoc ) ) ); + + sal_Int32 nFormatKey = ExplicitValueProvider::getExplicitNumberFormatKeyForAxis( + m_xAxis, xCooSys, Reference< util::XNumberFormatsSupplier >( m_xChartDoc, uno::UNO_QUERY ) ); + + aValue <<= nFormatKey; + } + } + // else set a void Any + GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue ); + } + } + break; + + case SCHATTR_AXISTYPE: + //don't allow to change the axis type so far + break; + } + + if( bSetScale ) + m_xAxis->setScaleData( aScale ); + + return (bSetScale || bChangedOtherwise); +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx new file mode 100644 index 000000000000..ad2aab714757 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/CharacterPropertyItemConverter.cxx @@ -0,0 +1,520 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CharacterPropertyItemConverter.cxx,v $ + * $Revision: 1.14.56.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "RelativeSizeHelper.hxx" +#include <svx/eeitem.hxx> +#include <svx/udlnitem.hxx> +#include <svx/fontitem.hxx> +#include <svx/crsditem.hxx> +#include <svx/postitem.hxx> +#include <svx/wghtitem.hxx> +#include <svx/fhgtitem.hxx> +#include <svtools/stritem.hxx> + +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/chart2/XFormattedString.hpp> + +using namespace ::com::sun::star; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetCharacterPropertyPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aCharacterPropertyMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( EE_CHAR_COLOR, "CharColor", 0 ) + IPM_MAP_ENTRY( EE_CHAR_LANGUAGE, "CharLocale", MID_LANG_LOCALE ) + IPM_MAP_ENTRY( EE_CHAR_LANGUAGE_CJK, "CharLocaleAsian", MID_LANG_LOCALE ) + IPM_MAP_ENTRY( EE_CHAR_LANGUAGE_CTL, "CharLocaleComplex", MID_LANG_LOCALE ) +// IPM_MAP_ENTRY( EE_CHAR_FONTHEIGHT, "CharHeight", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_ITALIC, "CharPosture", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_WEIGHT, "CharWeight", 0 ) + + IPM_MAP_ENTRY( EE_CHAR_STRIKEOUT, "CharStrikeout", MID_CROSS_OUT ) + IPM_MAP_ENTRY( EE_CHAR_WLM, "CharWordMode", 0 ) + IPM_MAP_ENTRY( EE_CHAR_SHADOW, "CharShadowed", 0 ) + IPM_MAP_ENTRY( EE_CHAR_RELIEF, "CharRelief", 0 ) + IPM_MAP_ENTRY( EE_CHAR_OUTLINE, "CharContoured", 0 ) + IPM_MAP_ENTRY( EE_CHAR_EMPHASISMARK, "CharEmphasis", 0 ) + + IPM_MAP_ENTRY( EE_PARA_WRITINGDIR, "WritingMode", 0 ) + +// IPM_MAP_ENTRY( EE_CHAR_FONTHEIGHT_CJK, "CharHeightAsian", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_FONTHEIGHT_CTL, "CharHeightComplex", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_WEIGHT_CJK, "CharWeightAsian", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_WEIGHT_CTL, "CharWeightComplex", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_ITALIC_CJK, "CharPostureAsian", 0 ) +// IPM_MAP_ENTRY( EE_CHAR_ITALIC_CTL, "CharPostureComplex", 0 ) + IPM_MAP_ENTRY( EE_PARA_ASIANCJKSPACING, "ParaIsCharacterDistance", 0 ) + ); + + return aCharacterPropertyMap; +} +} // anonymous namespace + +// ======================================== + +namespace chart +{ +namespace wrapper +{ + +CharacterPropertyItemConverter::CharacterPropertyItemConverter( + const uno::Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ) : + ItemConverter( rPropertySet, rItemPool ) +{} + +CharacterPropertyItemConverter::CharacterPropertyItemConverter( + const uno::Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + ::std::auto_ptr< awt::Size > pRefSize, + const ::rtl::OUString & rRefSizePropertyName, + const uno::Reference< beans::XPropertySet > & rRefSizePropSet ) : + ItemConverter( rPropertySet, rItemPool ), + m_pRefSize( pRefSize ), + m_aRefSizePropertyName( rRefSizePropertyName ), + m_xRefSizePropSet( rRefSizePropSet.is() ? rRefSizePropSet : rPropertySet ) +{} + +CharacterPropertyItemConverter::~CharacterPropertyItemConverter() +{} + +const USHORT * CharacterPropertyItemConverter::GetWhichPairs() const +{ + return nCharacterPropertyWhichPairs; +} + +bool CharacterPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType & rMap( lcl_GetCharacterPropertyPropertyMap()); + ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); + + if( aIt == rMap.end()) + return false; + + rOutProperty =(*aIt).second; + return true; +} + +void CharacterPropertyItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case EE_CHAR_FONTINFO: + case EE_CHAR_FONTINFO_CJK: + case EE_CHAR_FONTINFO_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_FONTINFO_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_FONTINFO_CTL ) + aPostfix = C2U( "Complex" ); + + SvxFontItem aItem( nWhichId ); + + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontName" ) + aPostfix), + MID_FONT_FAMILY_NAME ); + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontFamily" ) + aPostfix), + MID_FONT_FAMILY ); + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontStyleName" ) + aPostfix), + MID_FONT_STYLE_NAME ); + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontCharSet" ) + aPostfix), + MID_FONT_CHAR_SET ); + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "CharFontPitch" ) + aPostfix), + MID_FONT_PITCH ); + + rOutItemSet.Put( aItem ); + } + break; + + case EE_CHAR_UNDERLINE: + { + SvxUnderlineItem aItem(UNDERLINE_NONE, EE_CHAR_UNDERLINE); + bool bModified = false; + + uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharUnderline" ))); + if( aValue.hasValue()) + { + aItem.PutValue( aValue, MID_TL_STYLE ); + bModified = true; + } + + aValue = GetPropertySet()->getPropertyValue( C2U( "CharUnderlineHasColor" )); + if( aValue.hasValue() && + ( *reinterpret_cast< const sal_Bool * >( aValue.getValue()) != sal_False )) + { + aItem.PutValue( aValue, MID_TL_HASCOLOR ); + bModified = true; + } + + aValue = GetPropertySet()->getPropertyValue( C2U( "CharUnderlineColor" )); + if( aValue.hasValue()) + { + aItem.PutValue( aValue, MID_TL_COLOR ); + bModified = true; + } + + if( bModified ) + rOutItemSet.Put( aItem ); + } + break; + + case EE_CHAR_ITALIC: + case EE_CHAR_ITALIC_CJK: + case EE_CHAR_ITALIC_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_ITALIC_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_ITALIC_CTL ) + aPostfix = C2U( "Complex" ); + + SvxPostureItem aItem( ITALIC_NONE, nWhichId ); + + uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharPosture" ) + aPostfix)); + if( aValue.hasValue()) + { + aItem.PutValue( aValue, MID_POSTURE ); + rOutItemSet.Put( aItem ); + } + } + break; + + case EE_CHAR_WEIGHT: + case EE_CHAR_WEIGHT_CJK: + case EE_CHAR_WEIGHT_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_WEIGHT_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_WEIGHT_CTL ) + aPostfix = C2U( "Complex" ); + + SvxWeightItem aItem( WEIGHT_NORMAL, nWhichId ); + + uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharWeight" ) + aPostfix)); + if( aValue.hasValue()) + { + aItem.PutValue( aValue, MID_WEIGHT ); + rOutItemSet.Put( aItem ); + } + } + break; + + case EE_CHAR_FONTHEIGHT: + case EE_CHAR_FONTHEIGHT_CJK: + case EE_CHAR_FONTHEIGHT_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_FONTHEIGHT_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_FONTHEIGHT_CTL ) + aPostfix = C2U( "Complex" ); + + SvxFontHeightItem aItem( 240, 100, nWhichId ); + + try + { + uno::Any aValue( GetPropertySet()->getPropertyValue( C2U( "CharHeight" ) + aPostfix )); + float fHeight; + if( aValue >>= fHeight ) + { + if( m_pRefSize.get()) + { + awt::Size aOldRefSize; + if( GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ) >>= aOldRefSize ) + { + // calculate font height in view + fHeight = static_cast< float >( + RelativeSizeHelper::calculate( fHeight, aOldRefSize, *m_pRefSize )); + aValue <<= fHeight; + } + } + + aItem.PutValue( aValue, MID_FONTHEIGHT ); + rOutItemSet.Put( aItem ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + break; + + case SID_CHAR_DLG_PREVIEW_STRING: + { + uno::Reference< chart2::XFormattedString > xFormattedString( GetPropertySet(), uno::UNO_QUERY ); + if( xFormattedString.is() ) + { + ::rtl::OUString aString = xFormattedString->getString(); + rOutItemSet.Put( SfxStringItem( nWhichId, aString ) ); + } + else + rOutItemSet.Put( SfxStringItem( nWhichId, C2U( "" ) ) ); + } + break; + + case EE_PARA_FORBIDDENRULES: + case EE_PARA_HANGINGPUNCTUATION: + rOutItemSet.DisableItem( nWhichId ); + break; + } +} + +bool CharacterPropertyItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + uno::Any aValue; + + switch( nWhichId ) + { + case EE_CHAR_FONTINFO: + case EE_CHAR_FONTINFO_CJK: + case EE_CHAR_FONTINFO_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_FONTINFO_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_FONTINFO_CTL ) + aPostfix = C2U( "Complex" ); + + const SvxFontItem & rItem = + static_cast< const SvxFontItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_FONT_FAMILY_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontName" ) + aPostfix )) + { + GetPropertySet()->setPropertyValue( C2U( "CharFontName" ) + aPostfix, aValue ); + bChanged = true; + } + } + if( rItem.QueryValue( aValue, MID_FONT_FAMILY )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontFamily" ) + aPostfix )) + { + GetPropertySet()->setPropertyValue( C2U( "CharFontFamily" ) + aPostfix, aValue ); + bChanged = true; + } + } + if( rItem.QueryValue( aValue, MID_FONT_STYLE_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontStyleName" ) + aPostfix )) + { + GetPropertySet()->setPropertyValue( C2U( "CharFontStyleName" ) + aPostfix, aValue ); + bChanged = true; + } + } + if( rItem.QueryValue( aValue, MID_FONT_CHAR_SET )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontCharSet" ) + aPostfix )) + { + GetPropertySet()->setPropertyValue( C2U( "CharFontCharSet" ) + aPostfix, aValue ); + bChanged = true; + } + } + if( rItem.QueryValue( aValue, MID_FONT_PITCH )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharFontPitch" ) + aPostfix )) + { + GetPropertySet()->setPropertyValue( C2U( "CharFontPitch" ) + aPostfix, aValue ); + bChanged = true; + } + } + } + break; + + case EE_CHAR_UNDERLINE: + { + const SvxUnderlineItem & rItem = + static_cast< const SvxUnderlineItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_TL_STYLE )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderline" ) )) + { + GetPropertySet()->setPropertyValue( C2U( "CharUnderline" ), aValue ); + bChanged = true; + } + } + + if( rItem.QueryValue( aValue, MID_TL_COLOR )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderlineColor" ) )) + { + GetPropertySet()->setPropertyValue( C2U( "CharUnderlineColor" ), aValue ); + bChanged = true; + } + } + + if( rItem.QueryValue( aValue, MID_TL_HASCOLOR )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharUnderlineHasColor" ) )) + { + GetPropertySet()->setPropertyValue( C2U( "CharUnderlineHasColor" ), aValue ); + bChanged = true; + } + } + } + break; + + case EE_CHAR_ITALIC: + case EE_CHAR_ITALIC_CJK: + case EE_CHAR_ITALIC_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_ITALIC_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_ITALIC_CTL ) + aPostfix = C2U( "Complex" ); + + const SvxPostureItem & rItem = + static_cast< const SvxPostureItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_POSTURE )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharPosture" ) + aPostfix)) + { + GetPropertySet()->setPropertyValue( C2U( "CharPosture" ) + aPostfix, aValue ); + bChanged = true; + } + } + } + break; + + case EE_CHAR_WEIGHT: + case EE_CHAR_WEIGHT_CJK: + case EE_CHAR_WEIGHT_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_WEIGHT_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_WEIGHT_CTL ) + aPostfix = C2U( "Complex" ); + + const SvxWeightItem & rItem = + static_cast< const SvxWeightItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_WEIGHT )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharWeight" ) + aPostfix)) + { + GetPropertySet()->setPropertyValue( C2U( "CharWeight" ) + aPostfix, aValue ); + bChanged = true; + } + } + } + break; + + case EE_CHAR_FONTHEIGHT: + case EE_CHAR_FONTHEIGHT_CJK: + case EE_CHAR_FONTHEIGHT_CTL: + { + ::rtl::OUString aPostfix; + if( nWhichId == EE_CHAR_FONTHEIGHT_CJK ) + aPostfix = C2U( "Asian" ); + else if( nWhichId == EE_CHAR_FONTHEIGHT_CTL ) + aPostfix = C2U( "Complex" ); + + const SvxFontHeightItem & rItem = + static_cast< const SvxFontHeightItem & >( + rItemSet.Get( nWhichId )); + + try + { + if( rItem.QueryValue( aValue, MID_FONTHEIGHT ) ) + { + bool bSetValue = false; + if( aValue != GetPropertySet()->getPropertyValue( C2U( "CharHeight" ) + aPostfix )) + bSetValue = true; + else + { + if( m_pRefSize.get() ) + { + awt::Size aNewRefSize = *m_pRefSize; + awt::Size aOldRefSize; + if( GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ) >>= aOldRefSize ) + { + if( aNewRefSize.Width != aOldRefSize.Width + || aNewRefSize.Height != aOldRefSize.Height ) + bSetValue = true; + } + } + } + if( bSetValue ) + { + // set new reference size only if there was a reference size before (auto-scaling on) + if( m_pRefSize.get() && + GetRefSizePropertySet()->getPropertyValue( m_aRefSizePropertyName ).hasValue()) + { + GetRefSizePropertySet()->setPropertyValue( m_aRefSizePropertyName, + uno::makeAny( *m_pRefSize )); + } + + GetPropertySet()->setPropertyValue( C2U( "CharHeight" ) + aPostfix, aValue ); + bChanged = true; + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + break; + } + + return bChanged; +} + +uno::Reference< beans::XPropertySet > + CharacterPropertyItemConverter::GetRefSizePropertySet() const +{ + return m_xRefSizePropSet; +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx new file mode 100644 index 000000000000..af062cf3b93c --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/DataPointItemConverter.cxx @@ -0,0 +1,703 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DataPointItemConverter.cxx,v $ + * $Revision: 1.19.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DataPointItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" + +#include "GraphicPropertyItemConverter.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include "StatisticsItemConverter.hxx" +#include "SeriesOptionsItemConverter.hxx" +#include "DataSeriesHelper.hxx" +#include "DiagramHelper.hxx" +#include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" +#include <svx/chrtitem.hxx> +#include <com/sun/star/chart2/DataPointLabel.hpp> +#include <com/sun/star/chart2/Symbol.hpp> + +// header for class XFillColorItem +#include <svx/xflclit.hxx> +#include <svtools/intitem.hxx> +#include <svx/sizeitem.hxx> +// header for class SfxStringItem +#include <svtools/stritem.hxx> +#include <svx/brshitem.hxx> +//SfxIntegerListItem +#include <svtools/ilstitem.hxx> +#define _SVSTDARR_ULONGS +#include <svtools/svstdarr.hxx> +#include <vcl/graph.hxx> +#include <com/sun/star/graphic/XGraphic.hpp> + +// for SVX_SYMBOLTYPE_... +#include <svx/tabline.hxx> + +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetDataPointPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aDataPointPropertyMap( + ::comphelper::MakeItemPropertyMap +// IPM_MAP_ENTRY( CHATTR_PIE_SEGMENT_OFFSET, "Offset", 0 ) + IPM_MAP_ENTRY( SCHATTR_STYLE_SHAPE, "Geometry3D", 0 ) + ); + + return aDataPointPropertyMap; +}; + +sal_Int32 lcl_getSymbolStyleForSymbol( const chart2::Symbol & rSymbol ) +{ + sal_Int32 nStyle = SVX_SYMBOLTYPE_UNKNOWN; + switch( rSymbol.Style ) + { + case chart2::SymbolStyle_NONE: + nStyle = SVX_SYMBOLTYPE_NONE; + break; + case chart2::SymbolStyle_AUTO: + nStyle = SVX_SYMBOLTYPE_AUTO; + break; + case chart2::SymbolStyle_GRAPHIC: + nStyle = SVX_SYMBOLTYPE_BRUSHITEM; + break; + case chart2::SymbolStyle_STANDARD: + nStyle = rSymbol.StandardSymbol; + break; + + case chart2::SymbolStyle_POLYGON: + // to avoid warning + case chart2::SymbolStyle_MAKE_FIXED_SIZE: + // nothing + break; + } + return nStyle; +} + +bool lcl_NumberFormatFromItemToPropertySet( USHORT nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) +{ + bool bChanged = false; + if( !xPropertySet.is() ) + return bChanged; + rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" ); + USHORT nSourceWhich = (SID_ATTR_NUMBERFORMAT_VALUE==nWhichId) ? SID_ATTR_NUMBERFORMAT_SOURCE : SCHATTR_PERCENT_NUMBERFORMAT_SOURCE; + + if( SFX_ITEM_SET != rItemSet.GetItemState( nSourceWhich ) ) + return bChanged; + + uno::Any aValue; + bool bUseSourceFormat = (static_cast< const SfxBoolItem & >( + rItemSet.Get( nSourceWhich )).GetValue() ); + if( !bUseSourceFormat ) + { + SfxItemState aState = rItemSet.GetItemState( nWhichId ); + if( aState == SFX_ITEM_SET ) + { + sal_Int32 nFmt = static_cast< sal_Int32 >( + static_cast< const SfxUInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()); + aValue = uno::makeAny(nFmt); + } + else + return bChanged; + } + + uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) ); + if( bOverwriteAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY); + if( aValue != aOldValue || + ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + { + ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aValue ); + bChanged = true; + } + } + else if( aOldValue != aValue ) + { + xPropertySet->setPropertyValue(aPropertyName, aValue ); + bChanged = true; + } + return bChanged; +} + +bool lcl_UseSourceFormatFromItemToPropertySet( USHORT nWhichId, const SfxItemSet & rItemSet, const uno::Reference< beans::XPropertySet > & xPropertySet, bool bOverwriteAttributedDataPointsAlso ) +{ + bool bChanged = false; + if( !xPropertySet.is() ) + return bChanged; + rtl::OUString aPropertyName = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? C2U( "NumberFormat" ) : C2U( "PercentageNumberFormat" ); + USHORT nFormatWhich = (SID_ATTR_NUMBERFORMAT_SOURCE==nWhichId) ? SID_ATTR_NUMBERFORMAT_VALUE : SCHATTR_PERCENT_NUMBERFORMAT_VALUE; + + if( SFX_ITEM_SET != rItemSet.GetItemState( nWhichId ) ) + return bChanged; + + uno::Any aNewValue; + bool bUseSourceFormat = (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() ); + if( !bUseSourceFormat ) + { + SfxItemState aState = rItemSet.GetItemState( nFormatWhich ); + if( aState == SFX_ITEM_SET ) + { + sal_Int32 nFormatKey = static_cast< sal_Int32 >( + static_cast< const SfxUInt32Item & >( + rItemSet.Get( nFormatWhich )).GetValue()); + aNewValue <<= nFormatKey; + } + else + return bChanged; + } + + uno::Any aOldValue( xPropertySet->getPropertyValue(aPropertyName) ); + if( bOverwriteAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( xPropertySet, uno::UNO_QUERY); + if( aNewValue != aOldValue || + ::chart::DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, aPropertyName, aOldValue ) ) + { + ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, aPropertyName, aNewValue ); + bChanged = true; + } + } + else if( aOldValue != aNewValue ) + { + xPropertySet->setPropertyValue( aPropertyName, aNewValue ); + bChanged = true; + } + + return bChanged; +} + +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +DataPointItemConverter::DataPointItemConverter( + const uno::Reference< frame::XModel > & xChartModel, + const uno::Reference< uno::XComponentContext > & xContext, + const uno::Reference< beans::XPropertySet > & rPropertySet, + const uno::Reference< XDataSeries > & xSeries, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + NumberFormatterWrapper * pNumFormatter, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::eGraphicObjectType eMapTo /* = FILL_PROPERTIES */, + ::std::auto_ptr< awt::Size > pRefSize /* = NULL */, + bool bDataSeries /* = false */, + bool bUseSpecialFillColor /* = false */, + sal_Int32 nSpecialFillColor /* =0 */, + bool bOverwriteLabelsForAttributedDataPointsAlso /*false*/, + sal_Int32 nNumberFormat, + sal_Int32 nPercentNumberFormat + ) : + ItemConverter( rPropertySet, rItemPool ), + m_pNumberFormatterWrapper( pNumFormatter ), + m_bDataSeries( bDataSeries ), + m_bOverwriteLabelsForAttributedDataPointsAlso(m_bDataSeries && bOverwriteLabelsForAttributedDataPointsAlso), + m_bUseSpecialFillColor(bUseSpecialFillColor), + m_nSpecialFillColor(nSpecialFillColor), + m_nNumberFormat(nNumberFormat), + m_nPercentNumberFormat(nPercentNumberFormat), + m_aAvailableLabelPlacements(), + m_bForbidPercentValue(true) +{ + m_aConverters.push_back( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, eMapTo )); + m_aConverters.push_back( new CharacterPropertyItemConverter( rPropertySet, rItemPool, pRefSize, + C2U( "ReferencePageSize" ))); + if( bDataSeries ) + { + m_aConverters.push_back( new StatisticsItemConverter( xChartModel, rPropertySet, rItemPool )); + m_aConverters.push_back( new SeriesOptionsItemConverter( xChartModel, xContext, rPropertySet, rItemPool )); + } + + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); + uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xSeries ) ); + bool bFound = false; + bool bAmbiguous = false; + sal_Bool bSwapXAndY = DiagramHelper::getVertical( xDiagram, bFound, bAmbiguous ); + m_aAvailableLabelPlacements = ChartTypeHelper::getSupportedLabelPlacements( xChartType, DiagramHelper::getDimension( xDiagram ), bSwapXAndY, xSeries ); + + m_bForbidPercentValue = AxisType::CATEGORY != ChartTypeHelper::getAxisType( xChartType, 0 ); +} + +DataPointItemConverter::~DataPointItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void DataPointItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); + + if( m_bUseSpecialFillColor ) + { + Color aColor(m_nSpecialFillColor); + rOutItemSet.Put( XFillColorItem( String(), aColor ) ); + } +} + +bool DataPointItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * DataPointItemConverter::GetWhichPairs() const +{ + // must span all used items! + if( m_bDataSeries ) + return nRowWhichPairs; + return nDataPointWhichPairs; +} + +bool DataPointItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType & rMap( lcl_GetDataPointPropertyMap()); + ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); + + if( aIt == rMap.end()) + return false; + + rOutProperty =(*aIt).second; + return true; +} + + +bool DataPointItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + uno::Any aValue; + + switch( nWhichId ) + { + case SCHATTR_DATADESCR_SHOW_NUMBER: + case SCHATTR_DATADESCR_SHOW_PERCENTAGE: + case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_SYMBOL: + { + const SfxBoolItem & rItem = static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )); + + uno::Any aOldValue( GetPropertySet()->getPropertyValue( C2U( "Label" ) )); + chart2::DataPointLabel aLabel; + if( aOldValue >>= aLabel ) + { + sal_Bool& rValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : ( + (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : ( + (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol )); + sal_Bool bOldValue = rValue; + rValue = static_cast< sal_Bool >( rItem.GetValue() ); + if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + if( bOldValue != rValue || + DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "Label" ), aOldValue ) ) + { + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny( aLabel ) ); + bChanged = true; + } + } + else if( bOldValue != rValue ) + { + GetPropertySet()->setPropertyValue( C2U( "Label" ), uno::makeAny( aLabel )); + bChanged = true; + } + } + } + break; + + case SID_ATTR_NUMBERFORMAT_VALUE: + case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: //fall through intended + { + bChanged = lcl_NumberFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso ); + } + break; + + case SID_ATTR_NUMBERFORMAT_SOURCE: + case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: //fall through intended + { + bChanged = lcl_UseSourceFormatFromItemToPropertySet( nWhichId, rItemSet, GetPropertySet(), m_bOverwriteLabelsForAttributedDataPointsAlso ); + } + break; + + case SCHATTR_DATADESCR_SEPARATOR: + { + rtl::OUString aNewValue = static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue(); + rtl::OUString aOldValue; + try + { + GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aOldValue; + if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + if( !aOldValue.equals(aNewValue) || + DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aOldValue ) ) ) + { + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelSeparator" ), uno::makeAny( aNewValue ) ); + bChanged = true; + } + } + else if( !aOldValue.equals(aNewValue) ) + { + GetPropertySet()->setPropertyValue( C2U( "LabelSeparator" ), uno::makeAny( aNewValue )); + bChanged = true; + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + + case SCHATTR_DATADESCR_PLACEMENT: + { + + try + { + sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + sal_Int32 nOld =0; + if( !(GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nOld) ) + { + if( m_aAvailableLabelPlacements.getLength() ) + nOld = m_aAvailableLabelPlacements[0]; + } + if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + { + Reference< chart2::XDataSeries > xSeries( GetPropertySet(), uno::UNO_QUERY); + if( nOld!=nNew || + DataSeriesHelper::hasAttributedDataPointDifferentValue( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nOld ) ) ) + { + DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "LabelPlacement" ), uno::makeAny( nNew ) ); + bChanged = true; + } + } + else if( nOld!=nNew ) + { + GetPropertySet()->setPropertyValue( C2U( "LabelPlacement" ), uno::makeAny( nNew )); + bChanged = true; + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + + case SCHATTR_STYLE_SYMBOL: + { + sal_Int32 nStyle = + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue(); + chart2::Symbol aSymbol; + + GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol; + sal_Int32 nOldStyle = lcl_getSymbolStyleForSymbol( aSymbol ); + + if( nStyle != nOldStyle ) + { + bool bDeleteSymbol = false; + switch( nStyle ) + { + case SVX_SYMBOLTYPE_NONE: + aSymbol.Style = chart2::SymbolStyle_NONE; + break; + case SVX_SYMBOLTYPE_AUTO: + aSymbol.Style = chart2::SymbolStyle_AUTO; + break; + case SVX_SYMBOLTYPE_BRUSHITEM: + aSymbol.Style = chart2::SymbolStyle_GRAPHIC; + break; + case SVX_SYMBOLTYPE_UNKNOWN: + bDeleteSymbol = true; + break; + + default: + aSymbol.Style = chart2::SymbolStyle_STANDARD; + aSymbol.StandardSymbol = nStyle; + } + + if( bDeleteSymbol ) + GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::Any()); + else + GetPropertySet()->setPropertyValue( C2U( "Symbol" ), + uno::makeAny( aSymbol )); + bChanged = true; + } + } + break; + + case SCHATTR_SYMBOL_SIZE: + { + Size aSize = static_cast< const SvxSizeItem & >( + rItemSet.Get( nWhichId )).GetSize(); + chart2::Symbol aSymbol; + + GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol; + if( aSize.getWidth() != aSymbol.Size.Width || + aSize.getHeight() != aSymbol.Size.Height ) + { + aSymbol.Size.Width = aSize.getWidth(); + aSymbol.Size.Height = aSize.getHeight(); + + GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol )); + bChanged = true; + } + } + break; + + case SCHATTR_SYMBOL_BRUSH: + { + const SvxBrushItem & rBrshItem( static_cast< const SvxBrushItem & >( + rItemSet.Get( nWhichId ))); + uno::Any aXGraphicAny; + const Graphic *pGraphic( rBrshItem.GetGraphic()); + if( pGraphic ) + { + uno::Reference< graphic::XGraphic > xGraphic( pGraphic->GetXGraphic()); + if( xGraphic.is()) + { + aXGraphicAny <<= xGraphic; + chart2::Symbol aSymbol; + GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol; + if( aSymbol.Graphic != xGraphic ) + { + aSymbol.Graphic = xGraphic; + GetPropertySet()->setPropertyValue( C2U( "Symbol" ), uno::makeAny( aSymbol )); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_TEXT_DEGREES: + { + double fValue = static_cast< double >( + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()) / 100.0; + double fOldValue = 0.0; + bool bPropExisted = + ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldValue ); + + if( ! bPropExisted || + ( bPropExisted && fOldValue != fValue )) + { + GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fValue )); + bChanged = true; + } + } + break; + } + + return bChanged; +} + +void DataPointItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_DATADESCR_SHOW_NUMBER: + case SCHATTR_DATADESCR_SHOW_PERCENTAGE: + case SCHATTR_DATADESCR_SHOW_CATEGORY: + case SCHATTR_DATADESCR_SHOW_SYMBOL: + { + chart2::DataPointLabel aLabel; + if( GetPropertySet()->getPropertyValue( C2U( "Label" )) >>= aLabel ) + { + sal_Bool bValue = (SCHATTR_DATADESCR_SHOW_NUMBER==nWhichId) ? aLabel.ShowNumber : ( + (SCHATTR_DATADESCR_SHOW_PERCENTAGE==nWhichId) ? aLabel.ShowNumberInPercent : ( + (SCHATTR_DATADESCR_SHOW_CATEGORY==nWhichId) ? aLabel.ShowCategoryName : aLabel.ShowLegendSymbol )); + + rOutItemSet.Put( SfxBoolItem( nWhichId, bValue )); + + if( m_bOverwriteLabelsForAttributedDataPointsAlso ) + { + if( DataSeriesHelper::hasAttributedDataPointDifferentValue( + Reference< chart2::XDataSeries >( GetPropertySet(), uno::UNO_QUERY), C2U( "Label" ), uno::makeAny(aLabel) ) ) + { + rOutItemSet.InvalidateItem(nWhichId); + } + } + } + } + break; + + case SID_ATTR_NUMBERFORMAT_VALUE: + { + sal_Int32 nKey = 0; + if( !(GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nKey) ) + nKey = m_nNumberFormat; + rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey )); + } + break; + + case SCHATTR_PERCENT_NUMBERFORMAT_VALUE: + { + sal_Int32 nKey = 0; + if( !(GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )) >>= nKey) ) + nKey = m_nPercentNumberFormat; + rOutItemSet.Put( SfxUInt32Item( nWhichId, nKey )); + } + break; + + case SID_ATTR_NUMBERFORMAT_SOURCE: + { + bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )).hasValue()); + rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet )); + } + break; + case SCHATTR_PERCENT_NUMBERFORMAT_SOURCE: + { + bool bNumberFormatIsSet = ( GetPropertySet()->getPropertyValue( C2U( "PercentageNumberFormat" )).hasValue()); + rOutItemSet.Put( SfxBoolItem( nWhichId, ! bNumberFormatIsSet )); + } + break; + + case SCHATTR_DATADESCR_SEPARATOR: + { + rtl::OUString aValue; + try + { + GetPropertySet()->getPropertyValue( C2U( "LabelSeparator" ) ) >>= aValue; + rOutItemSet.Put( SfxStringItem( nWhichId, aValue )); + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + + case SCHATTR_DATADESCR_PLACEMENT: + { + try + { + sal_Int32 nPlacement=0; + if( GetPropertySet()->getPropertyValue( C2U( "LabelPlacement" ) ) >>= nPlacement ) + rOutItemSet.Put( SfxInt32Item( nWhichId, nPlacement )); + else if( m_aAvailableLabelPlacements.getLength() ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_aAvailableLabelPlacements[0] )); + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + break; + + case SCHATTR_DATADESCR_AVAILABLE_PLACEMENTS: + { + SvULongs aList; + for ( sal_Int32 nN=0; nN<m_aAvailableLabelPlacements.getLength(); nN++ ) + aList.Insert( m_aAvailableLabelPlacements[nN], sal::static_int_cast< USHORT >(nN) ); + rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) ); + } + break; + + case SCHATTR_DATADESCR_NO_PERCENTVALUE: + { + rOutItemSet.Put( SfxBoolItem( nWhichId, m_bForbidPercentValue )); + } + break; + + case SCHATTR_STYLE_SYMBOL: + { + chart2::Symbol aSymbol; + if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol ) + rOutItemSet.Put( SfxInt32Item( nWhichId, lcl_getSymbolStyleForSymbol( aSymbol ) )); + } + break; + + case SCHATTR_SYMBOL_SIZE: + { + chart2::Symbol aSymbol; + if( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol ) + rOutItemSet.Put( + SvxSizeItem( nWhichId, Size( aSymbol.Size.Width, aSymbol.Size.Height ) )); + } + break; + + case SCHATTR_SYMBOL_BRUSH: + { + chart2::Symbol aSymbol; + if(( GetPropertySet()->getPropertyValue( C2U( "Symbol" )) >>= aSymbol ) + && aSymbol.Graphic.is() ) + { + rOutItemSet.Put( SvxBrushItem( Graphic( aSymbol.Graphic ), GPOS_MM, SCHATTR_SYMBOL_BRUSH )); + } + } + break; + + case SCHATTR_TEXT_DEGREES: + { + double fValue = 0; + + if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fValue ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >( + ::rtl::math::round( fValue * 100.0 ) ) )); + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx new file mode 100755 index 000000000000..fff6d87be9ab --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/ErrorBarItemConverter.cxx @@ -0,0 +1,459 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ErrorBarItemConverter.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ErrorBarItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "ErrorBar.hxx" +#include "PropertyHelper.hxx" +#include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "StatisticsHelper.hxx" + +#include "GraphicPropertyItemConverter.hxx" + +#include <svtools/stritem.hxx> +#include <svx/chrtitem.hxx> +#include <svtools/intitem.hxx> +#include <rtl/math.hxx> + +#include <com/sun/star/chart2/DataPointLabel.hpp> +#include <com/sun/star/chart2/XInternalDataProvider.hpp> +#include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/lang/XServiceName.hpp> + +#include <functional> +#include <algorithm> +#include <vector> + +using namespace ::com::sun::star; + +namespace +{ + +void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp, + double & rOutPosError, double & rOutNegError ) +{ + if( ! xErrorBarProp.is()) + return; + + try + { + xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError; + xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void lcl_getErrorIndicatorValues( + const uno::Reference< beans::XPropertySet > & xErrorBarProp, + bool & rOutShowPosError, bool & rOutShowNegError ) +{ + if( ! xErrorBarProp.is()) + return; + + try + { + xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError; + xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +ErrorBarItemConverter::ErrorBarItemConverter( + const uno::Reference< frame::XModel > & xModel, + const uno::Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) : + ItemConverter( rPropertySet, rItemPool ), + m_spGraphicConverter( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_PROPERTIES )), + m_xModel( xModel ) +{} + +ErrorBarItemConverter::~ErrorBarItemConverter() +{} + +void ErrorBarItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + m_spGraphicConverter->FillItemSet( rOutItemSet ); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool ErrorBarItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet ); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * ErrorBarItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nErrorBarWhichPairs; +} + +bool ErrorBarItemConverter::GetItemProperty( + tWhichIdType /* nWhichId */, + tPropertyNameWithMemberId & /* rOutProperty */ ) const +{ + return false; +} + +bool ErrorBarItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + uno::Any aValue; + + switch( nWhichId ) + { + // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT, + // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS, + // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE + case SCHATTR_STAT_KIND_ERROR: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); + + SvxChartKindError eErrorKind = + static_cast< const SvxChartKindErrorItem & >( + rItemSet.Get( nWhichId )).GetValue(); + + if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE) + { + //nothing to do + } + else + { + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + + switch( eErrorKind ) + { + case CHERROR_NONE: + nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break; + case CHERROR_VARIANT: + nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break; + case CHERROR_SIGMA: + nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break; + case CHERROR_PERCENT: + nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break; + case CHERROR_BIGERROR: + nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break; + case CHERROR_CONST: + nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break; + case CHERROR_STDERROR: + nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break; + case CHERROR_RANGE: + nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break; + } + + xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ), + uno::makeAny( nStyle )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_PERCENT: + case SCHATTR_STAT_BIGERROR: + { + OSL_ENSURE( false, "Deprectaed item" ); + uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); + + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + + if( ! ( ::rtl::math::approxEqual( fPos, fValue ) && + ::rtl::math::approxEqual( fNeg, fValue ))) + { + xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), + uno::makeAny( fValue )); + xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), + uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_CONSTPLUS: + { + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); + + if( ! ::rtl::math::approxEqual( fPos, fValue )) + { + GetPropertySet()->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_CONSTMINUS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); + + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + + if( ! ::rtl::math::approxEqual( fNeg, fValue )) + { + xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_INDICATE: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); + + SvxChartIndicate eIndicate = + static_cast< const SvxChartIndicateItem & >( + rItemSet.Get( nWhichId )).GetValue(); + + bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP ); + bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN ); + + bool bShowPos, bShowNeg; + lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); + + if( ( bShowPos != bNewIndPos || + bShowNeg != bNewIndNeg )) + { + xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos )); + xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_RANGE_POS: + case SCHATTR_STAT_RANGE_NEG: + { + // @todo: also be able to deal with x-error bars + const bool bYError = true; + uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), 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( xErrorBarSource.is() && xDataProvider.is()) + { + ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue()); + bool bApplyNewRange = false; + + bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS ); + if( xChartDoc->hasInternalDataProvider()) + { + if( aNewRange.getLength()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, bIsPositiveValue, bYError )); + if( ! xSeq.is()) + { + // no data range for error bars yet => create + uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY ); + OSL_ASSERT( xIntDataProvider.is()); + if( xIntDataProvider.is()) + { + xIntDataProvider->appendSequence(); + aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last")); + bApplyNewRange = true; + } + } + } + } + else + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, bIsPositiveValue, bYError )); + bApplyNewRange = + ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation())); + } + + if( bApplyNewRange ) + StatisticsHelper::setErrorDataSequence( + xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError ); + } + } + break; + } + + return bChanged; +} + +void ErrorBarItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_STAT_KIND_ERROR: + { + SvxChartKindError eErrorKind = CHERROR_NONE; + uno::Reference< beans::XPropertySet > xErrorBarProp( GetPropertySet()); + + sal_Int32 nStyle = 0; + if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle ) + { + switch( nStyle ) + { + case ::com::sun::star::chart::ErrorBarStyle::NONE: + break; + case ::com::sun::star::chart::ErrorBarStyle::VARIANCE: + eErrorKind = CHERROR_VARIANT; break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION: + eErrorKind = CHERROR_SIGMA; break; + case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE: + eErrorKind = CHERROR_CONST; break; + case ::com::sun::star::chart::ErrorBarStyle::RELATIVE: + eErrorKind = CHERROR_PERCENT; break; + case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: + eErrorKind = CHERROR_BIGERROR; break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR: + eErrorKind = CHERROR_STDERROR; break; + case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA: + eErrorKind = CHERROR_RANGE; break; + } + } + rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR )); + } + break; + + case SCHATTR_STAT_PERCENT: + { + double fPos, fNeg; + lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + } + break; + + case SCHATTR_STAT_BIGERROR: + { + double fPos, fNeg; + lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + } + break; + + case SCHATTR_STAT_CONSTPLUS: + { + double fPos, fNeg; + lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); + } + break; + + case SCHATTR_STAT_CONSTMINUS: + { + double fPos, fNeg; + lcl_getErrorValues( GetPropertySet(), fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); + } + break; + + case SCHATTR_STAT_INDICATE: + { + SvxChartIndicate eIndicate = CHINDICATE_BOTH; + bool bShowPos, bShowNeg; + lcl_getErrorIndicatorValues( GetPropertySet(), bShowPos, bShowNeg ); + + if( bShowPos ) + { + if( bShowNeg ) + eIndicate = CHINDICATE_BOTH; + else + eIndicate = CHINDICATE_UP; + } + else + { + if( bShowNeg ) + eIndicate = CHINDICATE_DOWN; + else + eIndicate = CHINDICATE_NONE; + } + rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE )); + } + break; + + case SCHATTR_STAT_RANGE_POS: + case SCHATTR_STAT_RANGE_NEG: + { + uno::Reference< chart2::data::XDataSource > xErrorBarSource( GetPropertySet(), uno::UNO_QUERY ); + if( xErrorBarSource.is()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ )); + if( xSeq.is()) + rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation()))); + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx new file mode 100644 index 000000000000..593b523316e3 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -0,0 +1,815 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: GraphicPropertyItemConverter.cxx,v $ + * $Revision: 1.13.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "PropertyHelper.hxx" +#include "CommonConverters.hxx" + +// #ifndef _SFXINTITEM_HXX +// #include <svtools/intitem.hxx> +// #endif +#include <svx/xflclit.hxx> +#include <svx/xlnclit.hxx> +#include <svx/xflbmtit.hxx> +#include <svx/xflbstit.hxx> +#include <svx/xbtmpit.hxx> +#include <svx/xflftrit.hxx> +#include <svx/xlndsit.hxx> +#include <svx/xflhtit.hxx> +#include <svx/xflgrit.hxx> +#include <svx/xfltrit.hxx> +#include <svx/xlntrit.hxx> +#include <svx/eeitem.hxx> +// for SfxBoolItem +#include <svtools/eitem.hxx> +// for XFillGradientStepCountItem +#include <svx/xgrscit.hxx> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/chart2/FillBitmap.hpp> +#include <com/sun/star/awt/Gradient.hpp> +#include <com/sun/star/container/XNameAccess.hpp> + +using namespace ::com::sun::star; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetDataPointFilledPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aDataPointPropertyFilledMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 ) + IPM_MAP_ENTRY( XATTR_FILLCOLOR, "Color", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "Transparency", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "Gradient", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLHATCH, "Hatch", 0 ) + IPM_MAP_ENTRY( XATTR_LINECOLOR, "BorderColor", 0 ) + IPM_MAP_ENTRY( XATTR_LINESTYLE, "BorderStyle", 0 ) + IPM_MAP_ENTRY( XATTR_LINEWIDTH, "BorderWidth", 0 ) +// IPM_MAP_ENTRY( XATTR_LINEDASH, "BorderDash", 0 ) +// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "BorderTransparency", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 ) + ); + + return aDataPointPropertyFilledMap; +} +::comphelper::ItemPropertyMapType & lcl_GetDataPointLinePropertyMap() +{ + static ::comphelper::ItemPropertyMapType aDataPointPropertyLineMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( XATTR_LINECOLOR, "Color", 0 ) +// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "Transparency", 0 ) + IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 ) + IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 ) +// IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 ) + ); + + return aDataPointPropertyLineMap; +} +::comphelper::ItemPropertyMapType & lcl_GetLinePropertyMap() +{ + static ::comphelper::ItemPropertyMapType aLinePropertyMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( XATTR_LINESTYLE, "LineStyle", 0 ) + IPM_MAP_ENTRY( XATTR_LINEWIDTH, "LineWidth", 0 ) +// IPM_MAP_ENTRY( XATTR_LINEDASH, "LineDash", 0 ) + IPM_MAP_ENTRY( XATTR_LINECOLOR, "LineColor", 0 ) +// IPM_MAP_ENTRY( XATTR_LINETRANSPARENCE, "LineTransparence", 0 ) + IPM_MAP_ENTRY( XATTR_LINEJOINT, "LineJoint", 0 ) + ); + + return aLinePropertyMap; +} +::comphelper::ItemPropertyMapType & lcl_GetFillPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aFillPropertyMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( XATTR_FILLSTYLE, "FillStyle", 0 ) + IPM_MAP_ENTRY( XATTR_FILLCOLOR, "FillColor", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLTRANSPARENCE, "FillTransparence", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLBITMAP, "FillBitmapName", MID_NAME ) +// IPM_MAP_ENTRY( XATTR_FILLGRADIENT, "FillGradient", 0 ) +// IPM_MAP_ENTRY( XATTR_FILLHATCH, "FillHatch", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBACKGROUND, "FillBackground", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POS, "FillBitmapRectanglePoint", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEX, "FillBitmapSizeX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZEY, "FillBitmapSizeY", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_SIZELOG, "FillBitmapLogicalSize", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETX, "FillBitmapOffsetX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_TILEOFFSETY, "FillBitmapOffsetY", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETX, "FillBitmapPositionOffsetX", 0 ) + IPM_MAP_ENTRY( XATTR_FILLBMP_POSOFFSETY, "FillBitmapPositionOffsetY", 0 ) + ); + + return aFillPropertyMap; +} + +bool lcl_supportsFillProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType ) +{ + return ( eType == ::chart::wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT || + eType == ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES || + eType == ::chart::wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); +} + +bool lcl_supportsLineProperties( ::chart::wrapper::GraphicPropertyItemConverter::eGraphicObjectType eType ) +{ + return ( eType != ::chart::wrapper::GraphicPropertyItemConverter::FILL_PROPERTIES ); +} + +bool lcl_SetContentForNamedProperty( + const uno::Reference< lang::XMultiServiceFactory > & xFactory, + const ::rtl::OUString & rTableName, + NameOrIndex & rItem, BYTE nMemberId ) +{ + bool bResult = false; + if( xFactory.is()) + { + ::rtl::OUString aPropertyValue( rItem.GetName()); + uno::Reference< container::XNameAccess > xNameAcc( + xFactory->createInstance( rTableName ), + uno::UNO_QUERY ); + if( xNameAcc.is() && + xNameAcc->hasByName( aPropertyValue )) + { + rItem.PutValue( xNameAcc->getByName( aPropertyValue ), nMemberId ); + bResult = true; + } + } + return bResult; +} + +} // anonymous namespace + +// ======================================== + +namespace chart +{ +namespace wrapper +{ + +GraphicPropertyItemConverter::GraphicPropertyItemConverter( + const uno::Reference< + beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + eGraphicObjectType eObjectType /* = FILL_PROPERTIES */ ) : + ItemConverter( rPropertySet, rItemPool ), + m_eGraphicObjectType( eObjectType ), + m_rDrawModel( rDrawModel ), + m_xNamedPropertyTableFactory( xNamedPropertyContainerFactory ) +{} + +GraphicPropertyItemConverter::~GraphicPropertyItemConverter() +{} + +const USHORT * GraphicPropertyItemConverter::GetWhichPairs() const +{ + const USHORT * pResult = NULL; + + switch( m_eGraphicObjectType ) + { + case LINE_DATA_POINT: + case FILLED_DATA_POINT: + pResult = nRowWhichPairs; break; + case LINE_PROPERTIES: + pResult = nLinePropertyWhichPairs; break; + case FILL_PROPERTIES: + pResult = nFillPropertyWhichPairs; break; + case LINE_AND_FILL_PROPERTIES: + pResult = nLineAndFillPropertyWhichPairs; break; + } + + return pResult; +} + +bool GraphicPropertyItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType::const_iterator aEndIt; + ::comphelper::ItemPropertyMapType::const_iterator aIt; + + switch( m_eGraphicObjectType ) + { + case LINE_DATA_POINT: + aEndIt = lcl_GetDataPointLinePropertyMap().end(); + aIt = lcl_GetDataPointLinePropertyMap().find( nWhichId ); + break; + case FILLED_DATA_POINT: + aEndIt = lcl_GetDataPointFilledPropertyMap().end(); + aIt = lcl_GetDataPointFilledPropertyMap().find( nWhichId ); + break; + case LINE_PROPERTIES: + aEndIt = lcl_GetLinePropertyMap().end(); + aIt = lcl_GetLinePropertyMap().find( nWhichId ); + break; + + case FILL_PROPERTIES: + aEndIt = lcl_GetFillPropertyMap().end(); + aIt = lcl_GetFillPropertyMap().find( nWhichId ); + break; + + case LINE_AND_FILL_PROPERTIES: + // line + aEndIt = lcl_GetLinePropertyMap().end(); + aIt = lcl_GetLinePropertyMap().find( nWhichId ); + + // not found => try fill + if( aIt == aEndIt ) + { + aEndIt = lcl_GetFillPropertyMap().end(); + aIt = lcl_GetFillPropertyMap().find( nWhichId ); + } + break; + } + + if( aIt == aEndIt ) + return false; + + rOutProperty =(*aIt).second; + return true; +} + +void GraphicPropertyItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ +// if( m_eGraphicObjectType == LINE_DATA_POINT || +// m_eGraphicObjectType == LINE_PROPERTIES ) +// return; + + switch( nWhichId ) + { + // bitmap property + case XATTR_FILLBMP_TILE: + case XATTR_FILLBMP_STRETCH: + { + drawing::BitmapMode aMode = drawing::BitmapMode_REPEAT; + if( GetPropertySet()->getPropertyValue( C2U("FillBitmapMode")) >>= aMode ) + { + rOutItemSet.Put( XFillBmpTileItem( aMode == drawing::BitmapMode_REPEAT )); + rOutItemSet.Put( XFillBmpStretchItem( aMode == drawing::BitmapMode_STRETCH )); + } + } + break; + + case XATTR_FILLFLOATTRANSPARENCE: + try + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "TransparencyGradientName" ) + : C2U( "FillTransparenceGradientName" ); + + uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName )); + if( aValue.hasValue()) + { + XFillFloatTransparenceItem aItem; + aItem.PutValue( aValue, MID_NAME ); + + lcl_SetContentForNamedProperty( + m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.TransparencyGradientTable"), + aItem, MID_FILLGRADIENT ); + + // this is important to enable the item + ::rtl::OUString aName; + if( (aValue >>= aName) && + aName.getLength()) + { + aItem.SetEnabled( TRUE ); + rOutItemSet.Put( aItem ); + } + } + } + } + catch( beans::UnknownPropertyException ex ) + { + ASSERT_EXCEPTION( ex ); + } + break; + + case XATTR_GRADIENTSTEPCOUNT: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "GradientStepCount" ) + : C2U( "FillGradientStepCount" ); + + sal_Int16 nStepCount = 0; + uno::Any aValue( GetPropertySet()->getPropertyValue( aPropName ) ); + if( hasLongOrShortValue(aValue) ) + { + nStepCount = getShortForLongAlso(aValue); + rOutItemSet.Put( XGradientStepCountItem( nStepCount )); + } + } + break; + + case XATTR_LINEDASH: + if( lcl_supportsLineProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "BorderDashName" ) + : C2U( "LineDashName" ); + + XLineDashItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); + + lcl_SetContentForNamedProperty( + m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.DashTable"), + 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 + XLineDashItem * pItemToPut = & aItem; + pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + + rOutItemSet.Put( * pItemToPut ); + } + break; + + case XATTR_FILLGRADIENT: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "GradientName" ) + : C2U( "FillGradientName" ); + + XFillGradientItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); + + lcl_SetContentForNamedProperty( + m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.GradientTable"), + 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 + XFillGradientItem * pItemToPut = & aItem; + pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + + rOutItemSet.Put( * pItemToPut ); + } + break; + + case XATTR_FILLHATCH: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "HatchName" ) + : C2U( "FillHatchName" ); + + XFillHatchItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ), MID_NAME ); + + lcl_SetContentForNamedProperty( + m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.HatchTable"), + 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 + XFillHatchItem * pItemToPut = & aItem; + pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + + rOutItemSet.Put( * pItemToPut ); + } + break; + + case XATTR_FILLBITMAP: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + XFillBitmapItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ) ), MID_NAME ); + + lcl_SetContentForNamedProperty( + m_xNamedPropertyTableFactory, C2U("com.sun.star.drawing.BitmapTable"), + aItem, MID_GRAFURL ); + + // translate model name to UI-name for predefined entries, so + // that the correct entry is chosen in the list of UI-names + XFillBitmapItem * pItemToPut = & aItem; + pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + + rOutItemSet.Put( * pItemToPut ); + } + break; + + // hack, because QueryValue of XLineTransparenceItem returns sal_Int32 + // instead of sal_Int16 + case XATTR_LINETRANSPARENCE: + if( lcl_supportsLineProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "BorderTransparency" ) + : (m_eGraphicObjectType == LINE_DATA_POINT) + ? C2U( "Transparency" ) + : C2U( "LineTransparence" ); + + XLineTransparenceItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) ); + + rOutItemSet.Put( aItem ); + } + break; + + // hack, because QueryValue of XFillTransparenceItem returns sal_Int32 + // instead of sal_Int16 + case XATTR_FILLTRANSPARENCE: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "Transparency" ) + : C2U( "FillTransparence" ); + + XFillTransparenceItem aItem; + aItem.PutValue( GetPropertySet()->getPropertyValue( aPropName ) ); + + rOutItemSet.Put( aItem ); + } + break; + } +} + +bool GraphicPropertyItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + uno::Any aValue; + + switch( nWhichId ) + { + // bitmap property + case XATTR_FILLBMP_STRETCH: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + const ::rtl::OUString aModePropName = C2U("FillBitmapMode"); + bool bStretched = static_cast< const XFillBmpStretchItem & >( + rItemSet.Get( XATTR_FILLBMP_STRETCH )).GetValue(); + drawing::BitmapMode aMode = + (bStretched ? drawing::BitmapMode_STRETCH : drawing::BitmapMode_NO_REPEAT); + + aValue <<= aMode; + if( aValue != GetPropertySet()->getPropertyValue( aModePropName )) + { + GetPropertySet()->setPropertyValue( aModePropName, aValue ); + bChanged = true; + } + } + break; + + case XATTR_FILLBMP_TILE: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + const ::rtl::OUString aModePropName = C2U("FillBitmapMode"); + bool bTiled = static_cast< const XFillBmpTileItem & >( + rItemSet.Get( XATTR_FILLBMP_TILE )).GetValue(); + drawing::BitmapMode aMode = + (bTiled ? drawing::BitmapMode_REPEAT : drawing::BitmapMode_NO_REPEAT); + + aValue <<= aMode; + if( aValue != GetPropertySet()->getPropertyValue( aModePropName )) + { + GetPropertySet()->setPropertyValue( aModePropName, aValue ); + bChanged = true; + } + } + break; + + case XATTR_FILLFLOATTRANSPARENCE: + try + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "TransparencyGradientName" ) + : C2U( "FillTransparenceGradientName" ); + + const XFillFloatTransparenceItem & rItem = + static_cast< const XFillFloatTransparenceItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.IsEnabled() && + rItem.QueryValue( aValue, MID_NAME )) + { + uno::Any aGradient; + rItem.QueryValue( aGradient, MID_FILLGRADIENT ); + + // add TransparencyGradient to list if it does not already exist + ::rtl::OUString aPreferredName; + aValue >>= aPreferredName; + aValue <<= PropertyHelper::addTransparencyGradientUniqueNameToTable( + aGradient, m_xNamedPropertyTableFactory, aPreferredName ); + + if( aValue != GetPropertySet()->getPropertyValue( aPropName )) + { + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + } + else + { + ::rtl::OUString aName; + if( ( GetPropertySet()->getPropertyValue( aPropName ) >>= aName ) + && aName.getLength() > 0 ) + { + uno::Reference< beans::XPropertyState > xState( GetPropertySet(), uno::UNO_QUERY ); + if( xState.is()) + xState->setPropertyToDefault( aPropName ); + bChanged = true; + } + } + } + } + catch( beans::UnknownPropertyException ex ) + { + ASSERT_EXCEPTION( ex ); + } + break; + + case XATTR_GRADIENTSTEPCOUNT: + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "GradientStepCount" ) + : C2U( "FillGradientStepCount" ); + + sal_Int16 nStepCount = ( static_cast< const XGradientStepCountItem & >( + rItemSet.Get( nWhichId ))).GetValue(); + + aValue <<= nStepCount; + if( aValue != GetPropertySet()->getPropertyValue( aPropName )) + { + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + } + } + break; + + case XATTR_LINEDASH: + { + if( lcl_supportsLineProperties( m_eGraphicObjectType )) + { + + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "BorderDashName" ) + : C2U( "LineDashName" ); + + const XLineDashItem & rItem = + static_cast< const XLineDashItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( aPropName )) + { + // add LineDash to list + uno::Any aLineDash; + rItem.QueryValue( aLineDash, MID_LINEDASH ); + ::rtl::OUString aPreferredName; + aValue >>= aPreferredName; + aValue <<= PropertyHelper::addLineDashUniqueNameToTable( + aLineDash, m_xNamedPropertyTableFactory, aPreferredName ); + + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + } + } + } + break; + + case XATTR_FILLGRADIENT: + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "GradientName" ) + : C2U( "FillGradientName" ); + + const XFillGradientItem & rItem = + static_cast< const XFillGradientItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( aPropName )) + { + // add Gradient to list + uno::Any aGradient; + rItem.QueryValue( aGradient, MID_FILLGRADIENT ); + ::rtl::OUString aPreferredName; + aValue >>= aPreferredName; + aValue <<= PropertyHelper::addGradientUniqueNameToTable( + aGradient, m_xNamedPropertyTableFactory, aPreferredName ); + + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + } + } + } + break; + + case XATTR_FILLHATCH: + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "HatchName" ) + : C2U( "FillHatchName" ); + + const XFillHatchItem & rItem = + static_cast< const XFillHatchItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( aPropName )) + { + // add Hatch to list + uno::Any aHatch; + rItem.QueryValue( aHatch, MID_FILLHATCH ); + ::rtl::OUString aPreferredName; + aValue >>= aPreferredName; + aValue <<= PropertyHelper::addHatchUniqueNameToTable( + aHatch, m_xNamedPropertyTableFactory, aPreferredName ); + + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + } + } + } + break; + + case XATTR_FILLBITMAP: + { + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + const XFillBitmapItem & rItem = + static_cast< const XFillBitmapItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue, MID_NAME )) + { + if( aValue != GetPropertySet()->getPropertyValue( C2U( "FillBitmapName" ))) + { + // add Bitmap to list + uno::Any aBitmap; + rItem.QueryValue( aBitmap, MID_GRAFURL ); + ::rtl::OUString aPreferredName; + aValue >>= aPreferredName; + aValue <<= PropertyHelper::addBitmapUniqueNameToTable( + aBitmap, m_xNamedPropertyTableFactory, aPreferredName ); + + GetPropertySet()->setPropertyValue( C2U( "FillBitmapName" ), aValue ); + bChanged = true; + } + } + } + } + break; + + // hack, because QueryValue of XLineTransparenceItem returns sal_Int32 + // instead of sal_Int16 + case XATTR_LINETRANSPARENCE: + if( lcl_supportsLineProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "BorderTransparency" ) + : (m_eGraphicObjectType == LINE_DATA_POINT) + ? C2U( "Transparency" ) + : C2U( "LineTransparence" ); + + const XLineTransparenceItem & rItem = + static_cast< const XLineTransparenceItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue )) + { + OSL_ENSURE( ! aValue.isExtractableTo( + ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))), + "TransparenceItem QueryValue bug is fixed. Remove hack." ); + sal_Int32 nValue = 0; + if( aValue >>= nValue ) + { + OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" ); + sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue )); + aValue <<= nValueToSet; + + GetPropertySet()->setPropertyValue( aPropName, aValue ); + bChanged = true; + } + else + { + OSL_ENSURE( false, "Wrong type in Transparency Any" ); + } + } + } + break; + + // hack, because QueryValue of XFillTransparenceItem returns sal_Int32 + // instead of sal_Int16 + case XATTR_FILLTRANSPARENCE: + if( lcl_supportsFillProperties( m_eGraphicObjectType )) + { + ::rtl::OUString aPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "Transparency" ) + : C2U( "FillTransparence" ); + + const XFillTransparenceItem & rItem = + static_cast< const XFillTransparenceItem & >( + rItemSet.Get( nWhichId )); + + if( rItem.QueryValue( aValue )) + { + OSL_ENSURE( ! aValue.isExtractableTo( + ::getCppuType( reinterpret_cast< const sal_Int16 * >(0))), + "TransparenceItem QueryValue bug is fixed. Remove hack." ); + sal_Int32 nValue = 0; + if( aValue >>= nValue ) + { + OSL_ENSURE( nValue < SAL_MAX_INT16, "Transparency value too large" ); + sal_Int16 nValueToSet( static_cast< sal_Int16 >( nValue )); + aValue <<= nValueToSet; + + GetPropertySet()->setPropertyValue( aPropName, aValue ); + // if linear or no transparence is set, delete the gradient + ::rtl::OUString aTransGradPropName = + (m_eGraphicObjectType == FILLED_DATA_POINT) + ? C2U( "TransparencyGradientName" ) + : C2U( "FillTransparenceGradientName" ); + GetPropertySet()->setPropertyValue( + aTransGradPropName, uno::makeAny( ::rtl::OUString() )); + + bChanged = true; + } + else + { + OSL_ENSURE( false, "Wrong type in Transparency Any" ); + } + } + } + break; + } + + return bChanged; +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/ItemConverter.cxx b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx new file mode 100644 index 000000000000..e0a7b20bfa6f --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/ItemConverter.cxx @@ -0,0 +1,272 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ItemConverter.cxx,v $ + * $Revision: 1.15.24.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ItemConverter.hxx" +#include "macros.hxx" +#include <com/sun/star/lang/XComponent.hpp> +#include <svtools/itemprop.hxx> +#include <svtools/itemiter.hxx> +// header for class SfxWhichIter +#include <svtools/whiter.hxx> +#include <svx/svxids.hrc> + +using namespace ::com::sun::star; + +namespace comphelper +{ + +ItemConverter::ItemConverter( + const uno::Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ) : + m_xPropertySet( rPropertySet ), + m_xPropertySetInfo( NULL ), + m_rItemPool( rItemPool ), + m_bIsValid( true ) +{ + resetPropertySet( m_xPropertySet ); +} + +ItemConverter::~ItemConverter() +{ + stopAllComponentListening(); +} + +void ItemConverter::resetPropertySet( + const uno::Reference< beans::XPropertySet > & xPropSet ) +{ + if( xPropSet.is()) + { + stopAllComponentListening(); + m_xPropertySet = xPropSet; + m_xPropertySetInfo = m_xPropertySet->getPropertySetInfo(); + + uno::Reference< lang::XComponent > xComp( m_xPropertySet, uno::UNO_QUERY ); + if( xComp.is()) + { + // method of base class ::utl::OEventListenerAdapter + startComponentListening( xComp ); + } + } +} + +SfxItemPool & ItemConverter::GetItemPool() const +{ + return m_rItemPool; +} + +SfxItemSet ItemConverter::CreateEmptyItemSet() const +{ + return SfxItemSet( GetItemPool(), GetWhichPairs() ); +} + +uno::Reference< beans::XPropertySet > ItemConverter::GetPropertySet() const +{ + return m_xPropertySet; +} + +void ItemConverter::_disposing( const lang::EventObject& rSource ) +{ + if( rSource.Source == m_xPropertySet ) + { + m_bIsValid = false; + } +} + +void ItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + const USHORT * pRanges = rOutItemSet.GetRanges(); + tPropertyNameWithMemberId aProperty; + SfxItemPool & rPool = GetItemPool(); + + OSL_ASSERT( pRanges != NULL ); + OSL_ASSERT( m_xPropertySetInfo.is()); + OSL_ASSERT( m_xPropertySet.is()); + + while( (*pRanges) != 0) + { + USHORT nBeg = (*pRanges); + ++pRanges; + USHORT nEnd = (*pRanges); + ++pRanges; + + OSL_ASSERT( nBeg <= nEnd ); + for( USHORT nWhich = nBeg; nWhich <= nEnd; ++nWhich ) + { + if( GetItemProperty( nWhich, aProperty )) + { + // put the Property into the itemset + SfxPoolItem * pItem = rPool.GetDefaultItem( nWhich ).Clone(); + + if( pItem ) + { + try + { + if( ! pItem->PutValue( m_xPropertySet->getPropertyValue( aProperty.first ), + aProperty.second // nMemberId + )) + { + delete pItem; + } + else + { + rOutItemSet.Put( *pItem, nWhich ); + delete pItem; + } + } + catch( beans::UnknownPropertyException ex ) + { + delete pItem; + OSL_ENSURE( false, + ::rtl::OUStringToOString( + ex.Message + + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + " - unknown Property: " )) + aProperty.first, + RTL_TEXTENCODING_ASCII_US ).getStr()); + } + catch( uno::Exception ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + else + { + try + { + FillSpecialItem( nWhich, rOutItemSet ); + } + catch( uno::Exception ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } +} + +void ItemConverter::FillSpecialItem( + USHORT /*nWhichId*/, SfxItemSet & /*rOutItemSet*/ ) const + throw( uno::Exception ) +{ + OSL_ENSURE( false, "ItemConverter: Unhandled special item found!" ); +} + +bool ItemConverter::ApplySpecialItem( + USHORT /*nWhichId*/, const SfxItemSet & /*rItemSet*/ ) + throw( uno::Exception ) +{ + OSL_ENSURE( false, "ItemConverter: Unhandled special item found!" ); + return false; +} + +bool ItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + OSL_ASSERT( m_xPropertySet.is()); + + bool bItemsChanged = false; + SfxItemIter aIter( rItemSet ); + const SfxPoolItem * pItem = aIter.FirstItem(); + tPropertyNameWithMemberId aProperty; + uno::Any aValue; + + while( pItem ) + { + if( rItemSet.GetItemState( pItem->Which(), FALSE ) == SFX_ITEM_SET ) + { + if( GetItemProperty( pItem->Which(), aProperty )) + { + pItem->QueryValue( aValue, aProperty.second /* nMemberId */ ); + + try + { + if( aValue != m_xPropertySet->getPropertyValue( aProperty.first )) + { + m_xPropertySet->setPropertyValue( aProperty.first, aValue ); + bItemsChanged = true; + } + } + catch( beans::UnknownPropertyException ex ) + { + OSL_ENSURE( false, + ::rtl::OUStringToOString( + ex.Message + + ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( + " - unknown Property: " )) + aProperty.first, + RTL_TEXTENCODING_ASCII_US).getStr()); + } + catch( uno::Exception ex ) + { + OSL_ENSURE( false, ::rtl::OUStringToOString( + ex.Message, RTL_TEXTENCODING_ASCII_US ).getStr()); + } + } + else + { + bItemsChanged = ApplySpecialItem( pItem->Which(), rItemSet ) || bItemsChanged; + } + } + pItem = aIter.NextItem(); + } + + return bItemsChanged; +} + +// -------------------------------------------------------------------------------- + +//static +void ItemConverter::InvalidateUnequalItems( SfxItemSet &rDestSet, const SfxItemSet &rSourceSet ) +{ + SfxWhichIter aIter (rSourceSet); + USHORT nWhich = aIter.FirstWhich (); + const SfxPoolItem *pPoolItem = NULL; + + while (nWhich) + { + if ((rSourceSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_SET) && + (rDestSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_SET)) + { + if (rSourceSet.Get(nWhich) != rDestSet.Get(nWhich)) + { + if( SID_CHAR_DLG_PREVIEW_STRING != nWhich ) + { + rDestSet.InvalidateItem(nWhich); + } + } + } + else if( rSourceSet.GetItemState(nWhich, TRUE, &pPoolItem) == SFX_ITEM_DONTCARE ) + rDestSet.InvalidateItem(nWhich); + + nWhich = aIter.NextWhich (); + } +} + +} // namespace comphelper diff --git a/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx new file mode 100644 index 000000000000..4e9311029c46 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/LegendItemConverter.cxx @@ -0,0 +1,239 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: LegendItemConverter.cxx,v $ + * $Revision: 1.16 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "LegendItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include <svx/chrtitem.hxx> +#include <com/sun/star/chart2/XLegend.hpp> +#include <com/sun/star/chart2/LegendPosition.hpp> +#include <com/sun/star/chart2/LegendExpansion.hpp> + +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; + +namespace chart +{ +namespace wrapper +{ + +LegendItemConverter::LegendItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) : + ItemConverter( rPropertySet, rItemPool ) +{ + m_aConverters.push_back( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES )); + m_aConverters.push_back( new CharacterPropertyItemConverter( + rPropertySet, rItemPool, pRefSize, + C2U( "ReferencePageSize" ) )); +} + +LegendItemConverter::~LegendItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void LegendItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool LegendItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * LegendItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nLegendWhichPairs; +} + +bool LegendItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const +{ + // No own (non-special) properties + return false; +} + + +bool LegendItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + + switch( nWhichId ) + { + case SCHATTR_LEGEND_POS: + { + chart2::LegendPosition eNewPos = chart2::LegendPosition_LINE_END; + chart2::LegendPosition eOldPos; + bool bIsWide = false; + sal_Bool bShow = sal_True; + + SvxChartLegendPos eItemPos = + static_cast< const SvxChartLegendPosItem & >( + rItemSet.Get( nWhichId )).GetValue(); + switch( eItemPos ) + { + case CHLEGEND_LEFT: + eNewPos = chart2::LegendPosition_LINE_START; + break; + case CHLEGEND_RIGHT: + eNewPos = chart2::LegendPosition_LINE_END; + break; + case CHLEGEND_TOP: + eNewPos = chart2::LegendPosition_PAGE_START; + bIsWide = true; + break; + case CHLEGEND_BOTTOM: + eNewPos = chart2::LegendPosition_PAGE_END; + bIsWide = true; + break; + + case CHLEGEND_NONE: + case CHLEGEND_NONE_LEFT: + case CHLEGEND_NONE_RIGHT: + case CHLEGEND_NONE_TOP: + case CHLEGEND_NONE_BOTTOM: + bShow = sal_False; + break; + } + + try + { + sal_Bool bWasShown = sal_True; + if( ! (GetPropertySet()->getPropertyValue( C2U("Show")) >>= bWasShown) || + ( bWasShown != bShow )) + { + GetPropertySet()->setPropertyValue( C2U("Show"), uno::makeAny( bShow )); + bChanged = true; + } + + if( bShow ) + { + if( ! ( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= eOldPos ) || + ( eOldPos != eNewPos )) + { + GetPropertySet()->setPropertyValue( C2U( "AnchorPosition" ), uno::makeAny( eNewPos )); + chart2::LegendExpansion eExp = bIsWide + ? chart2::LegendExpansion_WIDE + : chart2::LegendExpansion_HIGH; + GetPropertySet()->setPropertyValue( C2U( "Expansion" ), uno::makeAny( eExp )); + GetPropertySet()->setPropertyValue( C2U( "RelativePosition" ), uno::Any()); + bChanged = true; + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + break; + } + + return bChanged; +} + +void LegendItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_LEGEND_POS: + { + SvxChartLegendPos eItemPos( CHLEGEND_RIGHT ); + chart2::LegendPosition ePos; + + sal_Bool bShow = sal_True; + GetPropertySet()->getPropertyValue( C2U( "Show" )) >>= bShow; + + if( ! bShow ) + { + eItemPos = CHLEGEND_NONE; + } + else if( GetPropertySet()->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos ) + { + switch( ePos ) + { + case chart2::LegendPosition_LINE_START: + eItemPos = CHLEGEND_LEFT; + break; + case chart2::LegendPosition_LINE_END: + eItemPos = CHLEGEND_RIGHT; + break; + case chart2::LegendPosition_PAGE_START: + eItemPos = CHLEGEND_TOP; + break; + case chart2::LegendPosition_PAGE_END: + eItemPos = CHLEGEND_BOTTOM; + break; + + case chart2::LegendPosition_CUSTOM: + default: + eItemPos = CHLEGEND_RIGHT; + break; + } + } + + rOutItemSet.Put( SvxChartLegendPosItem( eItemPos, SCHATTR_LEGEND_POS ) ); + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx new file mode 100644 index 000000000000..4b626e1be839 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/MultipleChartConverters.cxx @@ -0,0 +1,236 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MultipleChartConverters.cxx,v $ + * $Revision: 1.15 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "MultipleChartConverters.hxx" + +#include "chartview/ChartSfxItemIds.hxx" +#include "SchWhichPairs.hxx" +#include "AxisItemConverter.hxx" +#include "StatisticsItemConverter.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "DataPointItemConverter.hxx" +#include "ChartModelHelper.hxx" +#include "TitleHelper.hxx" +#include "TitleItemConverter.hxx" +#include "AxisHelper.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "DiagramHelper.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 +{ +namespace wrapper +{ + +//----------------------------------------------------------------------------- + +AllAxisItemConverter::AllAxisItemConverter( + const uno::Reference< frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & /*xNamedPropertyContainerFactory*/, + ::std::auto_ptr< awt::Size > pRefSize ) + : MultipleItemConverter( rItemPool ) +{ + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Sequence< Reference< XAxis > > aElementList( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) + { + uno::Reference< beans::XPropertySet > xObjectProperties(aElementList[nA], uno::UNO_QUERY); + if( pRefSize.get()) + m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter( + xObjectProperties, rItemPool, rDrawModel, + uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0, + ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )) )); + else + m_aConverters.push_back( new ::chart::wrapper::AxisItemConverter( + xObjectProperties, rItemPool, rDrawModel, + uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), 0, 0 ) ); + } +} + +AllAxisItemConverter::~AllAxisItemConverter() +{ +} + +const USHORT * AllAxisItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nAllAxisWhichPairs; +} + +//----------------------------------------------------------------------------- + +AllGridItemConverter::AllGridItemConverter( + const uno::Reference< frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) + : MultipleItemConverter( rItemPool ) +{ + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + Sequence< Reference< beans::XPropertySet > > aElementList( AxisHelper::getAllGrids( xDiagram ) ); + for( sal_Int32 nA = 0; nA < aElementList.getLength(); nA++ ) + { + Reference< beans::XPropertySet > xObjectProperties(aElementList[nA]); + m_aConverters.push_back( new ::chart::wrapper::GraphicPropertyItemConverter( + xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, + ::chart::wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ) ); + } +} + +AllGridItemConverter::~AllGridItemConverter() +{ +} + +const USHORT * AllGridItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nGridWhichPairs; +} + +//----------------------------------------------------------------------------- + +AllDataLabelItemConverter::AllDataLabelItemConverter( + const uno::Reference< frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< awt::Size > pRefSize ) + : MultipleItemConverter( rItemPool ) +{ + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( + ::chart::ChartModelHelper::getDataSeries( xChartModel )); + + ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt; + for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt ) + { + uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY); + uno::Reference< uno::XComponentContext> xContext(0);//do not need Context for label properties + + sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, *aIt, -1/*nPointIndex*/, ChartModelHelper::findDiagram( xChartModel ) ); + sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( + xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); + + m_aConverters.push_back( new ::chart::wrapper::DataPointItemConverter( + xChartModel, xContext, + xObjectProperties, *aIt, rItemPool, rDrawModel, NULL, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::FILLED_DATA_POINT, + ::std::auto_ptr< awt::Size >( pRefSize.get() ? new awt::Size( *pRefSize ) : 0), + true, /*bDataSeries*/ + false, /*bUseSpecialFillColor*/ + 0, /*nSpecialFillColor*/ + true /*bOverwriteLabelsForAttributedDataPointsAlso*/, + nNumberFormat, nPercentNumberFormat + )); + } +} + +AllDataLabelItemConverter::~AllDataLabelItemConverter() +{ +} + +const USHORT * AllDataLabelItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nDataLabelWhichPairs; +} + +//----------------------------------------------------------------------------- + +AllTitleItemConverter::AllTitleItemConverter( + const uno::Reference< frame::XModel > & xChartModel, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< awt::Size > pRefSize ) + : 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 ) ); + if(!xTitle.is()) + continue; + uno::Reference< beans::XPropertySet > xObjectProperties( xTitle, uno::UNO_QUERY); + ::std::auto_ptr< awt::Size > pSingleRefSize(0); + if( pRefSize.get()) + pSingleRefSize = ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )); + m_aConverters.push_back( new ::chart::wrapper::TitleItemConverter( + xObjectProperties, rItemPool, rDrawModel, xNamedPropertyContainerFactory, pSingleRefSize )); + } +} + +AllTitleItemConverter::~AllTitleItemConverter() +{ +} + +const USHORT * AllTitleItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nTitleWhichPairs; +} + +//----------------------------------------------------------------------------- + +AllSeriesStatisticsConverter::AllSeriesStatisticsConverter( + const uno::Reference< frame::XModel > & xChartModel, + SfxItemPool& rItemPool ) + : MultipleItemConverter( rItemPool ) +{ + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeriesList( + ::chart::ChartModelHelper::getDataSeries( xChartModel )); + + ::std::vector< uno::Reference< chart2::XDataSeries > >::const_iterator aIt; + for( aIt = aSeriesList.begin(); aIt != aSeriesList.end(); ++aIt ) + { + uno::Reference< beans::XPropertySet > xObjectProperties( *aIt, uno::UNO_QUERY); + m_aConverters.push_back( new ::chart::wrapper::StatisticsItemConverter( + xChartModel, xObjectProperties, rItemPool )); + } +} + +AllSeriesStatisticsConverter::~AllSeriesStatisticsConverter() +{} + +const USHORT * AllSeriesStatisticsConverter::GetWhichPairs() const +{ + // must span all used items! + return nStatWhichPairs; +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx new file mode 100644 index 000000000000..4748adff879f --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/MultipleItemConverter.cxx @@ -0,0 +1,87 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: MultipleItemConverter.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "MultipleItemConverter.hxx" +#include "ItemPropertyMap.hxx" + +#include <algorithm> + +using namespace ::com::sun::star; + +namespace comphelper +{ + +MultipleItemConverter::MultipleItemConverter( SfxItemPool& rItemPool ) + : ItemConverter( NULL, rItemPool ) +{ +} +MultipleItemConverter::~MultipleItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + DeleteItemConverterPtr() ); +} + +void MultipleItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::vector< ItemConverter* >::const_iterator aIter = m_aConverters.begin(); + const ::std::vector< ItemConverter* >::const_iterator aEnd = m_aConverters.end(); + if( aIter != aEnd ) + { + (*aIter)->FillItemSet( rOutItemSet ); + aIter++; + } + for( ; aIter != aEnd; aIter++ ) + { + SfxItemSet aSet = this->CreateEmptyItemSet(); + (*aIter)->FillItemSet( aSet ); + InvalidateUnequalItems( rOutItemSet, aSet ); + } + // no own items +} + +bool MultipleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ApplyItemSetFunc( rItemSet, bResult )); + + // no own items + return bResult; +} + +bool MultipleItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const +{ + return false; +} + +} // namespace comphelper diff --git a/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx new file mode 100644 index 000000000000..c62fa6735512 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/RegressionCurveItemConverter.cxx @@ -0,0 +1,279 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegressionCurveItemConverter.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "RegressionCurveHelper.hxx" +#include "RegressionCurveItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" + +#include <com/sun/star/chart2/XRegressionCurve.hpp> + +// for SfxBoolItem +#include <svtools/eitem.hxx> +#include <svx/chrtitem.hxx> + +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; + +namespace +{ + +::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress ) +{ + ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE; + switch( eRegress ) + { + case CHREGRESS_LINEAR: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR; + break; + case CHREGRESS_LOG: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG; + break; + case CHREGRESS_EXP: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP; + break; + case CHREGRESS_POWER: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; + break; + case CHREGRESS_NONE: + break; + } + return eType; +} + +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +RegressionCurveItemConverter::RegressionCurveItemConverter( + const uno::Reference< beans::XPropertySet > & rPropertySet, + const uno::Reference< chart2::XRegressionCurveContainer > & xRegCurveCnt, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory ) : + ItemConverter( rPropertySet, rItemPool ), + m_spGraphicConverter( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_PROPERTIES )), + m_xCurveContainer( xRegCurveCnt ) +{} + +RegressionCurveItemConverter::~RegressionCurveItemConverter() +{} + +void RegressionCurveItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + m_spGraphicConverter->FillItemSet( rOutItemSet ); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool RegressionCurveItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = m_spGraphicConverter->ApplyItemSet( rItemSet ); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * RegressionCurveItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nRegressionCurveWhichPairs; +} + +bool RegressionCurveItemConverter::GetItemProperty( + tWhichIdType /* nWhichId */, tPropertyNameWithMemberId & /* rOutProperty */ ) const +{ + // No own (non-special) properties + return false; +} + + +bool RegressionCurveItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY ); + bool bChanged = false; + + switch( nWhichId ) + { + case SCHATTR_REGRESSION_TYPE: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + SvxChartRegress eRegress = static_cast< SvxChartRegress >( + static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve ))); + SvxChartRegress eNewRegress = static_cast< const SvxChartRegressItem & >( + rItemSet.Get( nWhichId )).GetValue(); + if( eRegress != eNewRegress ) + { + // note that changing the regression type changes the object + // for which this converter was created. Not optimal, but + // currently the only way to handle the type in the + // regression curve properties dialog + RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( + lcl_convertRegressionType( eNewRegress ), m_xCurveContainer, + uno::Reference< uno::XComponentContext >()); + uno::Reference< beans::XPropertySet > xNewPropSet( + RegressionCurveHelper::getFirstCurveNotMeanValueLine( m_xCurveContainer ), + uno::UNO_QUERY ); + OSL_ASSERT( xNewPropSet.is()); + if( xNewPropSet.is()) + { + resetPropertySet( xNewPropSet ); + bChanged = true; + } + } + } + } + break; + + case SCHATTR_REGRESSION_SHOW_EQUATION: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + bool bNewShow = static_cast< BOOL >( + static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); + OSL_ASSERT( xEqProp.is()); + bool bOldShow = false; + if( xEqProp.is() && + (xEqProp->getPropertyValue( C2U( "ShowEquation" )) >>= bOldShow) && + bOldShow != bNewShow ) + { + xEqProp->setPropertyValue( C2U( "ShowEquation" ), uno::makeAny( bNewShow )); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_SHOW_COEFF: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + bool bNewShow = static_cast< BOOL >( + static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue()); + + uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); + OSL_ASSERT( xEqProp.is()); + bool bOldShow = false; + if( xEqProp.is() && + (xEqProp->getPropertyValue( C2U( "ShowCorrelationCoefficient" )) >>= bOldShow) && + bOldShow != bNewShow ) + { + xEqProp->setPropertyValue( C2U( "ShowCorrelationCoefficient" ), uno::makeAny( bNewShow )); + bChanged = true; + } + } + } + break; + } + + return bChanged; +} + +void RegressionCurveItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + uno::Reference< chart2::XRegressionCurve > xCurve( GetPropertySet(), uno::UNO_QUERY ); + + switch( nWhichId ) + { + case SCHATTR_REGRESSION_TYPE: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + SvxChartRegress eRegress = static_cast< SvxChartRegress >( + static_cast< sal_Int32 >( RegressionCurveHelper::getRegressionType( xCurve ))); + rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE )); + } + } + break; + + case SCHATTR_REGRESSION_SHOW_EQUATION: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); + OSL_ASSERT( xEqProp.is()); + bool bShow = false; + if( xEqProp.is() && + (xEqProp->getPropertyValue( C2U( "ShowEquation" )) >>= bShow)) + { + rOutItemSet.Put( SfxBoolItem( nWhichId, bShow )); + } + } + } + break; + + case SCHATTR_REGRESSION_SHOW_COEFF: + { + OSL_ASSERT( xCurve.is()); + if( xCurve.is()) + { + uno::Reference< beans::XPropertySet > xEqProp( xCurve->getEquationProperties()); + OSL_ASSERT( xEqProp.is()); + bool bShow = false; + if( xEqProp.is() && + (xEqProp->getPropertyValue( C2U( "ShowCorrelationCoefficient" )) >>= bShow)) + { + rOutItemSet.Put( SfxBoolItem( nWhichId, bShow )); + } + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx new file mode 100644 index 000000000000..6ac0d87b3e5f --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/RegressionEquationItemConverter.cxx @@ -0,0 +1,190 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: RegressionEquationItemConverter.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "RegressionEquationItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include "MultipleItemConverter.hxx" + +#include <svtools/intitem.hxx> +#include <rtl/math.hxx> + +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetEquationPropertyMap() +{ + static ::comphelper::ItemPropertyMapType aEquationPropertyMap; + + return aEquationPropertyMap; +}; +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +RegressionEquationItemConverter::RegressionEquationItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) : + ItemConverter( rPropertySet, rItemPool ) +{ + m_aConverters.push_back( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES )); + + m_aConverters.push_back( new CharacterPropertyItemConverter( + rPropertySet, rItemPool, pRefSize, C2U("ReferencePageSize"))); + +// // CharacterProperties are not at the title but at its contained XFormattedString objects +// // take the first formatted string in the sequence +// uno::Reference< chart2::XTitle > xTitle( rPropertySet, uno::UNO_QUERY ); +// if( xTitle.is()) +// { +// uno::Sequence< uno::Reference< chart2::XFormattedString > > aStringSeq( xTitle->getText()); +// if( aStringSeq.getLength() > 0 ) +// { +// m_aConverters.push_back( +// new FormattedStringsConverter( aStringSeq, rItemPool, pRefSize, rPropertySet )); +// } +// } +} + +RegressionEquationItemConverter::~RegressionEquationItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void RegressionEquationItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool RegressionEquationItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * RegressionEquationItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nRegEquationWhichPairs; +} + +bool RegressionEquationItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType & rMap( lcl_GetEquationPropertyMap()); + ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); + + if( aIt == rMap.end()) + return false; + + rOutProperty =(*aIt).second; + return true; +} + +bool RegressionEquationItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + + switch( nWhichId ) + { + case SID_ATTR_NUMBERFORMAT_VALUE: + { +// bool bUseSourceFormat = +// (static_cast< const SfxBoolItem & >( +// rItemSet.Get( SID_ATTR_NUMBERFORMAT_SOURCE )).GetValue() ); + +// if( ! bUseSourceFormat ) +// { + uno::Any aValue( static_cast< sal_Int32 >( + static_cast< const SfxUInt32Item & >( + rItemSet.Get( nWhichId )).GetValue())); + if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) != aValue ) + { + GetPropertySet()->setPropertyValue( C2U( "NumberFormat" ), aValue ); + bChanged = true; + } + } + break; + } + + return bChanged; +} + +void RegressionEquationItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SID_ATTR_NUMBERFORMAT_VALUE: + { + sal_Int32 nFormatKey = 0; + if( GetPropertySet()->getPropertyValue( C2U( "NumberFormat" )) >>= nFormatKey ) + { + rOutItemSet.Put( SfxUInt32Item( nWhichId, nFormatKey )); + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx new file mode 100644 index 000000000000..dbefb0e7f025 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/SchWhichPairs.hxx @@ -0,0 +1,278 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SchWhichPairs.hxx,v $ + * $Revision: 1.11 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART_SCHWHICHPAIRS_HXX +#define CHART_SCHWHICHPAIRS_HXX + +#ifndef _SVX_SVXIDS_HRC +#include <svx/svxids.hrc> +#endif +#include <svx/xdef.hxx> +#include <svx/svddef.hxx> +#include <svx/eeitem.hxx> + +#include "chartview/ChartSfxItemIds.hxx" + +namespace +{ + +#define CHARACTER_WHICHPAIRS \ + EE_ITEMS_START, EE_ITEMS_END, \ + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING + +const USHORT nTitleWhichPairs[] = +{ + SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + 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 + CHARACTER_WHICHPAIRS, + 0 +}; + +const USHORT nAxisWhichPairs[] = +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + CHARACTER_WHICHPAIRS, + 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 + SCHATTR_AXISTYPE, SCHATTR_AXISTYPE, // 39 sch/schattr.hxx + SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx + SCHATTR_AXIS_START, SCHATTR_AXIS_END, // 70 - 95 sch/schattr.hxx + SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + 0 +}; + +const USHORT nAllAxisWhichPairs[] = +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + CHARACTER_WHICHPAIRS, + SCHATTR_TEXT_START, SCHATTR_TEXT_END, // 4 - 6 sch/schattr.hxx + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + SCHATTR_TEXT_OVERLAP, SCHATTR_TEXT_OVERLAP, // 54 sch/schattr.hxx + SCHATTR_AXIS_SHOWDESCR, SCHATTR_AXIS_SHOWDESCR, // 85 sch/schattr.hxx + SCHATTR_TEXTBREAK, SCHATTR_TEXTBREAK, // 30587 sch/schattr.hxx + 0 +}; + +const USHORT nGridWhichPairs[] = +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + 0 +}; + +const USHORT nChartWhichPairs[] = +{ + SCHATTR_STYLE_START,SCHATTR_STYLE_END, // 59 - 68 sch/schattr.hxx + 0 +}; + +const USHORT nDiagramAreaWhichPairs[] = +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx + 0 +}; + +const USHORT nAreaAndChartWhichPairs[] = // pairs for chart AND area +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1018 - 1046 svx/xdef.hxx + SCHATTR_STYLE_START,SCHATTR_STYLE_END, // 59 - 68 sch/schattr.hxx + 0 +}; + +const USHORT nLegendWhichPairs[] = +{ + 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 + CHARACTER_WHICHPAIRS, + SCHATTR_LEGEND_START, SCHATTR_LEGEND_END, // 3 - 3 sch/schattr.hxx + 0 +}; + +const USHORT nDataLabelWhichPairs[] = +{ + SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, + 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 */ \ + SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ + SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, + EE_PARA_WRITINGDIR,EE_PARA_WRITINGDIR, + 0 +}; + +#define CHART_POINT_WHICHPAIRS \ + 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, /* 3994 - 4037 svx/eeitem.hxx */ \ + SID_CHAR_DLG_PREVIEW_STRING, SID_CHAR_DLG_PREVIEW_STRING, \ + SCHATTR_DATADESCR_START, SCHATTR_DATADESCR_END, /* 1 - 2 sch/schattr.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 */ \ + SCHATTR_PERCENT_NUMBERFORMAT_VALUE, SCHATTR_PERCENT_NUMBERFORMAT_VALUE, /* 40 sch/schattr.hxx*/ \ + SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, SCHATTR_PERCENT_NUMBERFORMAT_SOURCE, /* 41 sch/schattr.hxx*/ \ + SCHATTR_TEXT_DEGREES, SCHATTR_TEXT_DEGREES, \ + SCHATTR_STYLE_START,SCHATTR_STYLE_END, /* 59 - 68 sch/schattr.hxx*/ \ + SCHATTR_SYMBOL_BRUSH,SCHATTR_SYMBOL_BRUSH, /* 94 sch/schattr.hxx*/ \ + SCHATTR_SYMBOL_SIZE,SCHATTR_SYMBOL_SIZE, /* 97 sch/schattr.hxx*/ \ + SDRATTR_3D_FIRST, SDRATTR_3D_LAST /* 1244 - 1334 svx/svddef.hxx */ + +const USHORT nDataPointWhichPairs[] = +{ + CHART_POINT_WHICHPAIRS, + 0 +}; + +#define CHART_SERIES_OPTIONS_WHICHPAIRS \ + 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, \ + SCHATTR_STARTING_ANGLE,SCHATTR_STARTING_ANGLE, \ + SCHATTR_CLOCKWISE,SCHATTR_CLOCKWISE, \ + SCHATTR_MISSING_VALUE_TREATMENT,SCHATTR_MISSING_VALUE_TREATMENT, \ + SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS,SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS, \ + SCHATTR_INCLUDE_HIDDEN_CELLS,SCHATTR_INCLUDE_HIDDEN_CELLS + +const USHORT nSeriesOptionsWhichPairs[] = +{ + CHART_SERIES_OPTIONS_WHICHPAIRS, + 0 +}; + +const USHORT nRowWhichPairs[] = +{ + CHART_POINT_WHICHPAIRS, + CHART_SERIES_OPTIONS_WHICHPAIRS, + 0 +}; + +const USHORT nAreaWhichPairs[] = +{ + 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 +}; + +const USHORT nTextWhichPairs[] = +{ + CHARACTER_WHICHPAIRS, + SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + 0 +}; + +const USHORT nTextOrientWhichPairs[] = +{ + CHARACTER_WHICHPAIRS, + SCHATTR_TEXT_STACKED, SCHATTR_TEXT_STACKED, // 4 sch/schattr.hxx + SCHATTR_TEXT_DEGREES,SCHATTR_TEXT_DEGREES, // 53 sch/schattr.hxx + 0 +}; + +const USHORT nStatWhichPairs[]= +{ + SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx + SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 + 0 +}; + +const USHORT nErrorBarWhichPairs[]= +{ + SCHATTR_STAT_START, SCHATTR_STAT_END, // 45 - 52 sch/schattr.hxx + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + 0 +}; + +// for CharacterProperties + +const USHORT nCharacterPropertyWhichPairs[] = +{ + CHARACTER_WHICHPAIRS, + 0 +}; + +const USHORT nLinePropertyWhichPairs[] = +{ + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + 0 +}; + +const USHORT nFillPropertyWhichPairs[] = +{ + XATTR_FILL_FIRST, XATTR_FILL_LAST, // 1000 - 1016 svx/xdef.hxx + SDRATTR_SHADOW_FIRST, SDRATTR_SHADOW_LAST, // 1067 - 1078 svx/svddef.hxx + 0 +}; + +const USHORT nLineAndFillPropertyWhichPairs[] = +{ + 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 +}; + +const USHORT nChartStyleWhichPairs[] = +{ + SCHATTR_DIAGRAM_STYLE, SCHATTR_DIAGRAM_STYLE, + SCHATTR_STYLE_SHAPE, SCHATTR_STYLE_SHAPE, + SCHATTR_NUM_OF_LINES_FOR_BAR, SCHATTR_NUM_OF_LINES_FOR_BAR, + SCHATTR_SPLINE_ORDER, SCHATTR_SPLINE_ORDER, + SCHATTR_SPLINE_RESOLUTION, SCHATTR_SPLINE_RESOLUTION, + 0 +}; + +const USHORT nRegressionCurveWhichPairs[] = +{ + SCHATTR_REGRESSION_START, SCHATTR_REGRESSION_END, // 108 - 109 + XATTR_LINE_FIRST, XATTR_LINE_LAST, // 1000 - 1016 svx/xdef.hxx + 0 +}; + +const USHORT nRegEquationWhichPairs[] = +{ + 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 + CHARACTER_WHICHPAIRS, + SID_ATTR_NUMBERFORMAT_VALUE, SID_ATTR_NUMBERFORMAT_VALUE, // 10585 - 10585 svx/svxids.hrc + 0 +}; + +} // anonymous namespace + +// CHART_SCHWHICHPAIRS_HXX +#endif diff --git a/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx new file mode 100644 index 000000000000..f30bb4aeda57 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/SeriesOptionsItemConverter.cxx @@ -0,0 +1,456 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SeriesOptionsItemConverter.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "SeriesOptionsItemConverter.hxx" +#include "SchWhichPairs.hxx" + +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "MultipleItemConverter.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" +#include "DiagramHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "DataSeriesHelper.hxx" + +#include <com/sun/star/chart/MissingValueTreatment.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> + +// for SfxBoolItem +#include <svtools/eitem.hxx> +#include <svtools/intitem.hxx> + +//SfxIntegerListItem +#include <svtools/ilstitem.hxx> +#define _SVSTDARR_ULONGS +#include <svtools/svstdarr.hxx> + +#include <rtl/math.hxx> +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +namespace chart +{ +namespace wrapper +{ + +// ======================================== + +SeriesOptionsItemConverter::SeriesOptionsItemConverter( + const uno::Reference< frame::XModel >& xChartModel + , const uno::Reference< uno::XComponentContext > & xContext + , const uno::Reference< beans::XPropertySet >& xPropertySet + , SfxItemPool& rItemPool ) + : ItemConverter( xPropertySet, rItemPool ) + , m_xChartModel(xChartModel) + , m_xCC(xContext) + , m_bAttachToMainAxis(true) + , m_bSupportingOverlapAndGapWidthProperties(false) + , m_bSupportingBarConnectors(false) + , m_nBarOverlap(0) + , m_nGapWidth(100) + , m_bConnectBars(false) + , m_bSupportingAxisSideBySide(false) + , m_bGroupBarsPerAxis(true) + , m_bAllSeriesAttachedToSameAxis(true) + , m_nAllSeriesAxisIndex(-1) + , m_bSupportingStartingAngle(false) + , m_nStartingAngle(90) + , m_bClockwise(false) + , m_aSupportedMissingValueTreatments() + , m_nMissingValueTreatment(0) + , m_bSupportingPlottingOfHiddenCells(false) + , m_bIncludeHiddenCells(true) +{ + try + { + uno::Reference< XDataSeries > xDataSeries( xPropertySet, uno::UNO_QUERY ); + + m_bAttachToMainAxis = DiagramHelper::isSeriesAttachedToMainAxis( xDataSeries ); + + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram(xChartModel) ); + uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); + uno::Reference< XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram , xDataSeries ) ); + + m_xCooSys = DataSeriesHelper::getCoordinateSystemOfSeries( xDataSeries, xDiagram ); + if( m_xCooSys.is() ) + { + uno::Reference< chart2::XAxis > 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 ); + + if( m_bSupportingOverlapAndGapWidthProperties ) + { + + sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + + uno::Sequence< sal_Int32 > m_aBarPositionSequence; + uno::Reference< beans::XPropertySet > xChartTypeProps( xChartType, uno::UNO_QUERY ); + if( xChartTypeProps.is() ) + { + if( xChartTypeProps->getPropertyValue( C2U( "OverlapSequence" ) ) >>= m_aBarPositionSequence ) + { + if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() ) + m_nBarOverlap = m_aBarPositionSequence[nAxisIndex]; + } + if( xChartTypeProps->getPropertyValue( C2U( "GapwidthSequence" ) ) >>= m_aBarPositionSequence ) + { + if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() ) + m_nGapWidth = m_aBarPositionSequence[nAxisIndex]; + } + } + } + + m_bSupportingBarConnectors = ChartTypeHelper::isSupportingBarConnectors( xChartType, nDimensionCount ); + if( m_bSupportingBarConnectors && xDiagramProperties.is() ) + { + xDiagramProperties->getPropertyValue( C2U("ConnectBars")) >>= m_bConnectBars; + } + + m_bSupportingAxisSideBySide = ChartTypeHelper::isSupportingAxisSideBySide( xChartType, nDimensionCount ); + if( m_bSupportingAxisSideBySide && xDiagramProperties.is() ) + { + xDiagramProperties->getPropertyValue( C2U("GroupBarsPerAxis")) >>= m_bGroupBarsPerAxis; + m_bAllSeriesAttachedToSameAxis = DataSeriesHelper::areAllSeriesAttachedToSameAxis( xChartType, m_nAllSeriesAxisIndex ); + } + + m_bSupportingStartingAngle = ChartTypeHelper::isSupportingStartingAngle( xChartType ); + if( m_bSupportingStartingAngle ) + { + xDiagramProperties->getPropertyValue( C2U( "StartingAngle" ) ) >>= m_nStartingAngle; + } + + m_aSupportedMissingValueTreatments = ChartTypeHelper::getSupportedMissingValueTreatments( xChartType ); + m_nMissingValueTreatment = DiagramHelper::getCorrectedMissingValueTreatment( + ChartModelHelper::findDiagram(m_xChartModel), xChartType ); + + uno::Reference< XChartDocument > xChartDoc( m_xChartModel, uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xProp( xChartDoc->getDataProvider(), uno::UNO_QUERY ); + if( xProp.is() ) + { + try + { + //test whether the data provider offers this property + xProp->getPropertyValue(C2U("IncludeHiddenCells")); + //if not exception is thrown the property is offered + m_bSupportingPlottingOfHiddenCells = true; + xDiagramProperties->getPropertyValue( C2U("IncludeHiddenCells") ) >>= m_bIncludeHiddenCells; + } + catch( const beans::UnknownPropertyException& ) + { + } + } + } + catch( uno::Exception ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +SeriesOptionsItemConverter::~SeriesOptionsItemConverter() +{ +} + +const USHORT * SeriesOptionsItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nSeriesOptionsWhichPairs; +} + +bool SeriesOptionsItemConverter::GetItemProperty( tWhichIdType /*nWhichId*/, tPropertyNameWithMemberId & /*rOutProperty*/ ) const +{ + return false; +} + +bool SeriesOptionsItemConverter::ApplySpecialItem( USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + switch( nWhichId ) + { + case SCHATTR_AXIS: + { + sal_Int32 nItemValue = static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue(); + bool bAttachToMainAxis = nItemValue == CHART_AXIS_PRIMARY_Y; + if( bAttachToMainAxis != m_bAttachToMainAxis ) + { + //change model: + bChanged = DiagramHelper::attachSeriesToAxis( bAttachToMainAxis, uno::Reference< XDataSeries >::query( GetPropertySet() ) + , ChartModelHelper::findDiagram(m_xChartModel), m_xCC ); + + if( bChanged ) + m_bAttachToMainAxis = bAttachToMainAxis; + } + } + break; + + case SCHATTR_BAR_OVERLAP: + case SCHATTR_BAR_GAPWIDTH: + { + if( m_bSupportingOverlapAndGapWidthProperties ) + { + sal_Int32& rBarPosition = ( SCHATTR_BAR_OVERLAP == nWhichId ) ? m_nBarOverlap : m_nGapWidth; + rBarPosition = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + + rtl::OUString aPropName( C2U( "GapwidthSequence" ) ); + if( SCHATTR_BAR_OVERLAP == nWhichId ) + aPropName = C2U( "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() ) + { + sal_Int32 nAxisIndex = DataSeriesHelper::getAttachedAxisIndex(xDataSeries); + uno::Sequence< sal_Int32 > m_aBarPositionSequence; + if( xChartTypeProps.is() ) + { + if( xChartTypeProps->getPropertyValue( aPropName ) >>= m_aBarPositionSequence ) + { + bool bGroupBarsPerAxis = static_cast< const SfxBoolItem & >(rItemSet.Get( SCHATTR_GROUP_BARS_PER_AXIS )).GetValue(); + if(!bGroupBarsPerAxis) + { + //set the same value for all axes + for( sal_Int32 nN = 0; nN < m_aBarPositionSequence.getLength(); nN++ ) + m_aBarPositionSequence[nN] = rBarPosition; + } + else if( nAxisIndex >= 0 && nAxisIndex < m_aBarPositionSequence.getLength() ) + m_aBarPositionSequence[nAxisIndex] = rBarPosition; + + xChartTypeProps->setPropertyValue( aPropName, uno::makeAny(m_aBarPositionSequence) ); + bChanged = true; + } + } + } + } + } + break; + + case SCHATTR_BAR_CONNECT: + { + sal_Bool bOldConnectBars = sal_False; + m_bConnectBars = static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue(); + if( m_bSupportingBarConnectors ) + { + uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + if( xDiagramProperties.is() && + (xDiagramProperties->getPropertyValue( C2U("ConnectBars")) >>= bOldConnectBars) && + bOldConnectBars != m_bConnectBars ) + { + xDiagramProperties->setPropertyValue( C2U("ConnectBars"), uno::makeAny(m_bConnectBars) ); + bChanged = true; + } + } + } + break; + + case SCHATTR_GROUP_BARS_PER_AXIS: + { + bool bOldGroupBarsPerAxis = true; + m_bGroupBarsPerAxis = static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue(); + if( m_bSupportingAxisSideBySide ) + { + uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + if( xDiagramProperties.is() && + (xDiagramProperties->getPropertyValue( C2U("GroupBarsPerAxis")) >>= bOldGroupBarsPerAxis) && + bOldGroupBarsPerAxis != m_bGroupBarsPerAxis ) + { + xDiagramProperties->setPropertyValue( C2U("GroupBarsPerAxis"), uno::makeAny(m_bGroupBarsPerAxis) ); + bChanged = true; + } + } + } + break; + + case SCHATTR_STARTING_ANGLE: + { + if( m_bSupportingStartingAngle ) + { + m_nStartingAngle = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + if( xDiagramProperties.is() ) + { + xDiagramProperties->setPropertyValue( C2U("StartingAngle"), uno::makeAny(m_nStartingAngle) ); + bChanged = true; + } + } + } + break; + + case SCHATTR_CLOCKWISE: + { + bool bClockwise = (static_cast< const SfxBoolItem & >( + rItemSet.Get( nWhichId )).GetValue() ); + if( m_xCooSys.is() ) + { + uno::Reference< chart2::XAxis > xAxis( AxisHelper::getAxis( 1, 0, m_xCooSys ) ); + if( xAxis.is() ) + { + chart2::ScaleData aScaleData( xAxis->getScaleData() ); + aScaleData.Orientation = bClockwise ? chart2::AxisOrientation_REVERSE : chart2::AxisOrientation_MATHEMATICAL; + xAxis->setScaleData( aScaleData ); + bChanged = true; + } + } + } + break; + + case SCHATTR_MISSING_VALUE_TREATMENT: + { + if( m_aSupportedMissingValueTreatments.getLength() ) + { + sal_Int32 nNew = static_cast< const SfxInt32Item & >( rItemSet.Get( nWhichId )).GetValue(); + if( m_nMissingValueTreatment != nNew ) + { + try + { + uno::Reference< beans::XPropertySet > xDiagramProperties( ChartModelHelper::findDiagram(m_xChartModel), uno::UNO_QUERY ); + if( xDiagramProperties.is() ) + { + xDiagramProperties->setPropertyValue( C2U( "MissingValueTreatment" ), uno::makeAny( nNew )); + bChanged = true; + } + } + catch( uno::Exception& e ) + { + ASSERT_EXCEPTION( e ); + } + } + } + } + break; + case SCHATTR_INCLUDE_HIDDEN_CELLS: + { + if( m_bSupportingPlottingOfHiddenCells ) + { + bool bIncludeHiddenCells = static_cast<const SfxBoolItem &>(rItemSet.Get(nWhichId)).GetValue(); + if (bIncludeHiddenCells != m_bIncludeHiddenCells) + bChanged = ChartModelHelper::setIncludeHiddenCells( bIncludeHiddenCells, m_xChartModel ); + } + } + break; + } + return bChanged; +} + +void SeriesOptionsItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_AXIS: + { + sal_Int32 nItemValue = m_bAttachToMainAxis ? CHART_AXIS_PRIMARY_Y : CHART_AXIS_SECONDARY_Y; + rOutItemSet.Put( SfxInt32Item(nWhichId,nItemValue ) ); + break; + } + case SCHATTR_BAR_OVERLAP: + { + if( m_bSupportingOverlapAndGapWidthProperties ) + rOutItemSet.Put( SfxInt32Item(nWhichId,m_nBarOverlap) ); + break; + } + case SCHATTR_BAR_GAPWIDTH: + { + if( m_bSupportingOverlapAndGapWidthProperties ) + rOutItemSet.Put( SfxInt32Item(nWhichId,m_nGapWidth) ); + break; + } + case SCHATTR_BAR_CONNECT: + { + if( m_bSupportingBarConnectors ) + rOutItemSet.Put( SfxBoolItem(nWhichId,m_bConnectBars)); + break; + } + case SCHATTR_GROUP_BARS_PER_AXIS: + { + if( m_bSupportingAxisSideBySide ) + rOutItemSet.Put( SfxBoolItem(nWhichId,m_bGroupBarsPerAxis) ); + break; + } + case SCHATTR_AXIS_FOR_ALL_SERIES: + { + if( m_nAllSeriesAxisIndex != - 1) + rOutItemSet.Put( SfxInt32Item(nWhichId, m_nAllSeriesAxisIndex)); + break; + } + case SCHATTR_STARTING_ANGLE: + { + if( m_bSupportingStartingAngle ) + rOutItemSet.Put( SfxInt32Item(nWhichId,m_nStartingAngle)); + break; + } + case SCHATTR_CLOCKWISE: + { + rOutItemSet.Put( SfxBoolItem(nWhichId,m_bClockwise) ); + break; + } + case SCHATTR_MISSING_VALUE_TREATMENT: + { + if( m_aSupportedMissingValueTreatments.getLength() ) + rOutItemSet.Put( SfxInt32Item( nWhichId, m_nMissingValueTreatment )); + break; + } + case SCHATTR_AVAILABLE_MISSING_VALUE_TREATMENTS: + { + SvULongs aList; + for ( sal_Int32 nN=0; nN<m_aSupportedMissingValueTreatments.getLength(); nN++ ) + aList.Insert( m_aSupportedMissingValueTreatments[nN], sal::static_int_cast< USHORT >(nN) ); + rOutItemSet.Put( SfxIntegerListItem( nWhichId, aList ) ); + break; + } + case SCHATTR_INCLUDE_HIDDEN_CELLS: + { + if( m_bSupportingPlottingOfHiddenCells ) + rOutItemSet.Put( SfxBoolItem(nWhichId, m_bIncludeHiddenCells) ); + break; + } + default: + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx new file mode 100644 index 000000000000..eed9235aff9b --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/StatisticsItemConverter.cxx @@ -0,0 +1,700 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StatisticsItemConverter.cxx,v $ + * $Revision: 1.22 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "StatisticsItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "RegressionCurveHelper.hxx" +#include "ItemPropertyMap.hxx" +#include "ErrorBar.hxx" +#include "PropertyHelper.hxx" +#include "ChartModelHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "StatisticsHelper.hxx" + +#include "GraphicPropertyItemConverter.hxx" + +#include <svtools/stritem.hxx> +#include <svx/chrtitem.hxx> +#include <svtools/intitem.hxx> +#include <rtl/math.hxx> + +#include <com/sun/star/chart2/DataPointLabel.hpp> +#include <com/sun/star/chart2/XInternalDataProvider.hpp> +#include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <com/sun/star/lang/XServiceName.hpp> + +#include <functional> +#include <algorithm> +#include <vector> + +using namespace ::com::sun::star; + +namespace +{ + +uno::Reference< beans::XPropertySet > lcl_GetYErrorBar( + const uno::Reference< beans::XPropertySet > & xProp ) +{ + uno::Reference< beans::XPropertySet > xResult; + + if( xProp.is()) + try + { + ( xProp->getPropertyValue( C2U( "ErrorBarY" )) >>= xResult ); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return xResult; +} + +::chart::RegressionCurveHelper::tRegressionType lcl_convertRegressionType( SvxChartRegress eRegress ) +{ + ::chart::RegressionCurveHelper::tRegressionType eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_NONE; + switch( eRegress ) + { + case CHREGRESS_LINEAR: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LINEAR; + break; + case CHREGRESS_LOG: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_LOG; + break; + case CHREGRESS_EXP: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_EXP; + break; + case CHREGRESS_POWER: + eType = ::chart::RegressionCurveHelper::REGRESSION_TYPE_POWER; + break; + case CHREGRESS_NONE: + break; + } + return eType; +} + + +uno::Reference< beans::XPropertySet > lcl_GetDefaultErrorBar() +{ + // todo: use a valid context + return uno::Reference< beans::XPropertySet >( + ::chart::createErrorBar( uno::Reference< uno::XComponentContext >())); +} + +void lcl_getErrorValues( const uno::Reference< beans::XPropertySet > & xErrorBarProp, + double & rOutPosError, double & rOutNegError ) +{ + if( ! xErrorBarProp.is()) + return; + + try + { + xErrorBarProp->getPropertyValue( C2U( "PositiveError" )) >>= rOutPosError; + xErrorBarProp->getPropertyValue( C2U( "NegativeError" )) >>= rOutNegError; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void lcl_getErrorIndicatorValues( + const uno::Reference< beans::XPropertySet > & xErrorBarProp, + bool & rOutShowPosError, bool & rOutShowNegError ) +{ + if( ! xErrorBarProp.is()) + return; + + try + { + xErrorBarProp->getPropertyValue( C2U( "ShowPositiveError" )) >>= rOutShowPosError; + xErrorBarProp->getPropertyValue( C2U( "ShowNegativeError" )) >>= rOutShowNegError; + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +uno::Reference< beans::XPropertySet > lcl_getEquationProperties( + const uno::Reference< beans::XPropertySet > & xSeriesPropSet, const SfxItemSet * pItemSet ) +{ + bool bEquationExists = true; + + // ensure that a trendline is on + if( pItemSet ) + { + SvxChartRegress eRegress = CHREGRESS_NONE; + const SfxPoolItem *pPoolItem = NULL; + if( pItemSet->GetItemState( SCHATTR_REGRESSION_TYPE, TRUE, &pPoolItem ) == SFX_ITEM_SET ) + { + eRegress = static_cast< const SvxChartRegressItem * >( pPoolItem )->GetValue(); + bEquationExists = ( eRegress != CHREGRESS_NONE ); + } + } + + if( bEquationExists ) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( xSeriesPropSet, uno::UNO_QUERY ); + uno::Reference< chart2::XRegressionCurve > xCurve( + ::chart::RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCnt )); + if( xCurve.is()) + { + return xCurve->getEquationProperties(); + } + } + + return uno::Reference< beans::XPropertySet >(); +} + +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +StatisticsItemConverter::StatisticsItemConverter( + const uno::Reference< frame::XModel > & xModel, + const uno::Reference< beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool ) : + ItemConverter( rPropertySet, rItemPool ), + m_xModel( xModel ) +{ + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_NONE ) == + static_cast< int >( CHREGRESS_NONE )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LINEAR ) == + static_cast< int >( CHREGRESS_LINEAR )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_LOG ) == + static_cast< int >( CHREGRESS_LOG )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_EXP ) == + static_cast< int >( CHREGRESS_EXP )); + OSL_ASSERT( static_cast< int >( RegressionCurveHelper::REGRESSION_TYPE_POWER ) == + static_cast< int >( CHREGRESS_POWER )); +} + +StatisticsItemConverter::~StatisticsItemConverter() +{} + +const USHORT * StatisticsItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nStatWhichPairs; +} + +bool StatisticsItemConverter::GetItemProperty( + tWhichIdType /* nWhichId */, + tPropertyNameWithMemberId & /* rOutProperty */ ) const +{ + return false; +} + +bool StatisticsItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + uno::Any aValue; + + switch( nWhichId ) + { + case SCHATTR_STAT_AVERAGE: + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( + GetPropertySet(), uno::UNO_QUERY ); + bool bOldHasMeanValueLine = RegressionCurveHelper::hasMeanValueLine( xRegCnt ); + + bool bNewHasMeanValueLine = + static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + + if( bOldHasMeanValueLine != bNewHasMeanValueLine ) + { + if( ! bNewHasMeanValueLine ) + RegressionCurveHelper::removeMeanValueLine( xRegCnt ); + else + RegressionCurveHelper::addMeanValueLine( + xRegCnt, uno::Reference< uno::XComponentContext >(), GetPropertySet() ); + bChanged = true; + } + } + break; + + // Attention !!! This case must be passed before SCHATTR_STAT_PERCENT, + // SCHATTR_STAT_BIGERROR, SCHATTR_STAT_CONSTPLUS, + // SCHATTR_STAT_CONSTMINUS and SCHATTR_STAT_INDICATE + case SCHATTR_STAT_KIND_ERROR: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet() )); + + SvxChartKindError eErrorKind = + static_cast< const SvxChartKindErrorItem & >( + rItemSet.Get( nWhichId )).GetValue(); + + if( !xErrorBarProp.is() && eErrorKind == CHERROR_NONE) + { + //nothing to do + } + else + { + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + + switch( eErrorKind ) + { + case CHERROR_NONE: + nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; break; + case CHERROR_VARIANT: + nStyle = ::com::sun::star::chart::ErrorBarStyle::VARIANCE; break; + case CHERROR_SIGMA: + nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION; break; + case CHERROR_PERCENT: + nStyle = ::com::sun::star::chart::ErrorBarStyle::RELATIVE; break; + case CHERROR_BIGERROR: + nStyle = ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN; break; + case CHERROR_CONST: + nStyle = ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE; break; + case CHERROR_STDERROR: + nStyle = ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR; break; + case CHERROR_RANGE: + nStyle = ::com::sun::star::chart::ErrorBarStyle::FROM_DATA; break; + } + + if( !xErrorBarProp.is() ) + { + xErrorBarProp = lcl_GetDefaultErrorBar(); + GetPropertySet()->setPropertyValue( + C2U( "ErrorBarY" ), uno::makeAny( xErrorBarProp )); + } + + xErrorBarProp->setPropertyValue( C2U( "ErrorBarStyle" ), + uno::makeAny( nStyle )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_PERCENT: + case SCHATTR_STAT_BIGERROR: + { + OSL_ENSURE( false, "Deprectaed item" ); + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet())); + bool bOldHasErrorBar = xErrorBarProp.is(); + + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + + if( bOldHasErrorBar && + ! ( ::rtl::math::approxEqual( fPos, fValue ) && + ::rtl::math::approxEqual( fNeg, fValue ))) + { + xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), + uno::makeAny( fValue )); + xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), + uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_CONSTPLUS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet())); + bool bOldHasErrorBar = xErrorBarProp.is(); + + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + + if( bOldHasErrorBar && + ! ::rtl::math::approxEqual( fPos, fValue )) + { + xErrorBarProp->setPropertyValue( C2U( "PositiveError" ), uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_CONSTMINUS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet())); + bool bOldHasErrorBar = xErrorBarProp.is(); + + double fValue = + static_cast< const SvxDoubleItem & >( + rItemSet.Get( nWhichId )).GetValue(); + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + + if( bOldHasErrorBar && + ! ::rtl::math::approxEqual( fNeg, fValue )) + { + xErrorBarProp->setPropertyValue( C2U( "NegativeError" ), uno::makeAny( fValue )); + bChanged = true; + } + } + break; + + case SCHATTR_REGRESSION_TYPE: + { + SvxChartRegress eRegress = + static_cast< const SvxChartRegressItem & >( + rItemSet.Get( nWhichId )).GetValue(); + + uno::Reference< chart2::XRegressionCurveContainer > xRegCnt( + GetPropertySet(), uno::UNO_QUERY ); + + if( eRegress == CHREGRESS_NONE ) + { + bChanged = RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCnt ); + } + else + { + SvxChartRegress eOldRegress( + static_cast< SvxChartRegress >( + static_cast< sal_Int32 >( + RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( xRegCnt )))); + if( eOldRegress != eRegress ) + { + RegressionCurveHelper::replaceOrAddCurveAndReduceToOne( + lcl_convertRegressionType( eRegress ), xRegCnt, + uno::Reference< uno::XComponentContext >()); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_SHOW_EQUATION: + { + uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); + if( xEqProp.is()) + { + bool bShowEq = false; + xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq; + bool bNewShowEq = + static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + if( bShowEq != bNewShowEq ) + { + xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( bNewShowEq )); + bChanged = true; + } + } + } + break; + + case SCHATTR_REGRESSION_SHOW_COEFF: + { + uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), &rItemSet )); + if( xEqProp.is()) + { + bool bShowCoeff = false; + xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff; + bool bNewShowCoeff = + static_cast< const SfxBoolItem & >( rItemSet.Get( nWhichId )).GetValue(); + if( bShowCoeff != bNewShowCoeff ) + { + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bNewShowCoeff )); + bChanged = true; + } + } + } + break; + + case SCHATTR_STAT_INDICATE: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet())); + bool bOldHasErrorBar = xErrorBarProp.is(); + + SvxChartIndicate eIndicate = + static_cast< const SvxChartIndicateItem & >( + rItemSet.Get( nWhichId )).GetValue(); + + bool bNewIndPos = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_UP ); + bool bNewIndNeg = (eIndicate == CHINDICATE_BOTH || eIndicate == CHINDICATE_DOWN ); + + bool bShowPos, bShowNeg; + lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); + + if( bOldHasErrorBar && + ( bShowPos != bNewIndPos || + bShowNeg != bNewIndNeg )) + { + xErrorBarProp->setPropertyValue( C2U( "ShowPositiveError" ), uno::makeAny( bNewIndPos )); + xErrorBarProp->setPropertyValue( C2U( "ShowNegativeError" ), uno::makeAny( bNewIndNeg )); + bChanged = true; + } + } + break; + + case SCHATTR_STAT_RANGE_POS: + case SCHATTR_STAT_RANGE_NEG: + { + // @todo: also be able to deal with x-error bars + const bool bYError = true; + uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), 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( xErrorBarSource.is() && xDataProvider.is()) + { + ::rtl::OUString aNewRange( static_cast< const SfxStringItem & >( rItemSet.Get( nWhichId )).GetValue()); + bool bApplyNewRange = false; + + bool bIsPositiveValue( nWhichId == SCHATTR_STAT_RANGE_POS ); + if( xChartDoc->hasInternalDataProvider()) + { + if( aNewRange.getLength()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, bIsPositiveValue, bYError )); + if( ! xSeq.is()) + { + // no data range for error bars yet => create + uno::Reference< chart2::XInternalDataProvider > xIntDataProvider( xDataProvider, uno::UNO_QUERY ); + OSL_ASSERT( xIntDataProvider.is()); + if( xIntDataProvider.is()) + { + xIntDataProvider->appendSequence(); + aNewRange = ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("last")); + bApplyNewRange = true; + } + } + } + } + else + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, bIsPositiveValue, bYError )); + bApplyNewRange = + ! ( xSeq.is() && aNewRange.equals( xSeq->getSourceRangeRepresentation())); + } + + if( bApplyNewRange ) + StatisticsHelper::setErrorDataSequence( + xErrorBarSource, xDataProvider, aNewRange, bIsPositiveValue, bYError ); + } + } + break; + } + + return bChanged; +} + +void StatisticsItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_STAT_AVERAGE: + rOutItemSet.Put( + SfxBoolItem( nWhichId, + RegressionCurveHelper::hasMeanValueLine( + uno::Reference< chart2::XRegressionCurveContainer >( + GetPropertySet(), uno::UNO_QUERY )))); + break; + + case SCHATTR_STAT_KIND_ERROR: + { + SvxChartKindError eErrorKind = CHERROR_NONE; + uno::Reference< beans::XPropertySet > xErrorBarProp( + lcl_GetYErrorBar( GetPropertySet())); + if( xErrorBarProp.is() ) + { + sal_Int32 nStyle = 0; + if( xErrorBarProp->getPropertyValue( C2U( "ErrorBarStyle" )) >>= nStyle ) + { + switch( nStyle ) + { + case ::com::sun::star::chart::ErrorBarStyle::NONE: + break; + case ::com::sun::star::chart::ErrorBarStyle::VARIANCE: + eErrorKind = CHERROR_VARIANT; break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION: + eErrorKind = CHERROR_SIGMA; break; + case ::com::sun::star::chart::ErrorBarStyle::ABSOLUTE: + eErrorKind = CHERROR_CONST; break; + case ::com::sun::star::chart::ErrorBarStyle::RELATIVE: + eErrorKind = CHERROR_PERCENT; break; + case ::com::sun::star::chart::ErrorBarStyle::ERROR_MARGIN: + eErrorKind = CHERROR_BIGERROR; break; + case ::com::sun::star::chart::ErrorBarStyle::STANDARD_ERROR: + eErrorKind = CHERROR_STDERROR; break; + case ::com::sun::star::chart::ErrorBarStyle::FROM_DATA: + eErrorKind = CHERROR_RANGE; break; + } + } + } + rOutItemSet.Put( SvxChartKindErrorItem( eErrorKind, SCHATTR_STAT_KIND_ERROR )); + } + break; + + case SCHATTR_STAT_PERCENT: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + if( xErrorBarProp.is()) + { + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + } + } + break; + + case SCHATTR_STAT_BIGERROR: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + if( xErrorBarProp.is()) + { + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( ( fPos + fNeg ) / 2.0, nWhichId )); + } + } + break; + + case SCHATTR_STAT_CONSTPLUS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + if( xErrorBarProp.is()) + { + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( fPos, nWhichId )); + } + } + break; + + case SCHATTR_STAT_CONSTMINUS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + if( xErrorBarProp.is()) + { + double fPos, fNeg; + lcl_getErrorValues( xErrorBarProp, fPos, fNeg ); + rOutItemSet.Put( SvxDoubleItem( fNeg, nWhichId )); + } + } + break; + + case SCHATTR_REGRESSION_TYPE: + { + SvxChartRegress eRegress = static_cast< SvxChartRegress >( + static_cast< sal_Int32 >( + RegressionCurveHelper::getFirstRegressTypeNotMeanValueLine( + uno::Reference< chart2::XRegressionCurveContainer >( + GetPropertySet(), uno::UNO_QUERY ) ))); + rOutItemSet.Put( SvxChartRegressItem( eRegress, SCHATTR_REGRESSION_TYPE )); + } + break; + + case SCHATTR_REGRESSION_SHOW_EQUATION: + { + bool bShowEq = false; + uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 )); + if( xEqProp.is()) + xEqProp->getPropertyValue( C2U("ShowEquation")) >>= bShowEq; + rOutItemSet.Put( SfxBoolItem( nWhichId, bShowEq )); + } + break; + + case SCHATTR_REGRESSION_SHOW_COEFF: + { + bool bShowCoeff = false; + uno::Reference< beans::XPropertySet > xEqProp( lcl_getEquationProperties( GetPropertySet(), 0 )); + if( xEqProp.is()) + xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient")) >>= bShowCoeff; + rOutItemSet.Put( SfxBoolItem( nWhichId, bShowCoeff )); + } + break; + + case SCHATTR_STAT_INDICATE: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( lcl_GetYErrorBar( GetPropertySet())); + SvxChartIndicate eIndicate = CHINDICATE_BOTH; + if( xErrorBarProp.is()) + { + bool bShowPos, bShowNeg; + lcl_getErrorIndicatorValues( xErrorBarProp, bShowPos, bShowNeg ); + + if( bShowPos ) + { + if( bShowNeg ) + eIndicate = CHINDICATE_BOTH; + else + eIndicate = CHINDICATE_UP; + } + else + { + if( bShowNeg ) + eIndicate = CHINDICATE_DOWN; + else + eIndicate = CHINDICATE_NONE; + } + } + rOutItemSet.Put( SvxChartIndicateItem( eIndicate, SCHATTR_STAT_INDICATE )); + } + break; + + case SCHATTR_STAT_RANGE_POS: + case SCHATTR_STAT_RANGE_NEG: + { + uno::Reference< chart2::data::XDataSource > xErrorBarSource( lcl_GetYErrorBar( GetPropertySet()), uno::UNO_QUERY ); + if( xErrorBarSource.is()) + { + uno::Reference< chart2::data::XDataSequence > xSeq( + StatisticsHelper::getErrorDataSequenceFromDataSource( + xErrorBarSource, (nWhichId == SCHATTR_STAT_RANGE_POS) /*, true */ /* y */ )); + if( xSeq.is()) + rOutItemSet.Put( SfxStringItem( nWhichId, String( xSeq->getSourceRangeRepresentation()))); + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx new file mode 100644 index 000000000000..96f6e01cadb5 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/TitleItemConverter.cxx @@ -0,0 +1,248 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: TitleItemConverter.cxx,v $ + * $Revision: 1.12 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "TitleItemConverter.hxx" +#include "SchWhichPairs.hxx" +#include "macros.hxx" +#include "ItemPropertyMap.hxx" +#include "GraphicPropertyItemConverter.hxx" +#include "CharacterPropertyItemConverter.hxx" +#include "MultipleItemConverter.hxx" +#include <svtools/intitem.hxx> +#include <rtl/math.hxx> + +#include <com/sun/star/chart2/XTitled.hpp> + +#include <functional> +#include <algorithm> + +using namespace ::com::sun::star; + +namespace +{ +::comphelper::ItemPropertyMapType & lcl_GetTitlePropertyMap() +{ + static ::comphelper::ItemPropertyMapType aTitlePropertyMap( + ::comphelper::MakeItemPropertyMap + IPM_MAP_ENTRY( SCHATTR_TEXT_STACKED, "StackCharacters", 0 ) + ); + + return aTitlePropertyMap; +}; +} // anonymous namespace + +namespace chart +{ +namespace wrapper +{ + +// ======================================== + +class FormattedStringsConverter : public ::comphelper::MultipleItemConverter +{ +public: + FormattedStringsConverter( + const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings, + SfxItemPool & rItemPool, + ::std::auto_ptr< awt::Size > pRefSize, + const uno::Reference< beans::XPropertySet > & xParentProp ); + virtual ~FormattedStringsConverter(); + +protected: + virtual const USHORT * GetWhichPairs() const; +}; + +// ---------------------------------------- + +FormattedStringsConverter::FormattedStringsConverter( + const uno::Sequence< uno::Reference< chart2::XFormattedString > > & aStrings, + SfxItemPool & rItemPool, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize, + const uno::Reference< beans::XPropertySet > & xParentProp ) : + MultipleItemConverter( rItemPool ) +{ + bool bHasRefSize = (pRefSize.get() && xParentProp.is()); + for( sal_Int32 i = 0; i < aStrings.getLength(); ++i ) + { + uno::Reference< beans::XPropertySet > xProp( aStrings[ i ], uno::UNO_QUERY ); + if( xProp.is()) + { + if( bHasRefSize ) + m_aConverters.push_back( new CharacterPropertyItemConverter( + xProp, rItemPool, + ::std::auto_ptr< awt::Size >( new awt::Size( *pRefSize )), + C2U( "ReferencePageSize" ), + xParentProp )); + else + m_aConverters.push_back( new CharacterPropertyItemConverter( xProp, rItemPool )); + } + } +} + +FormattedStringsConverter::~FormattedStringsConverter() +{ +} + +const USHORT * FormattedStringsConverter::GetWhichPairs() const +{ + return nCharacterPropertyWhichPairs; +} + +// ======================================== + +TitleItemConverter::TitleItemConverter( + const ::com::sun::star::uno::Reference< + ::com::sun::star::beans::XPropertySet > & rPropertySet, + SfxItemPool& rItemPool, + SdrModel& rDrawModel, + const uno::Reference< lang::XMultiServiceFactory > & xNamedPropertyContainerFactory, + ::std::auto_ptr< ::com::sun::star::awt::Size > pRefSize ) : + ItemConverter( rPropertySet, rItemPool ) +{ + m_aConverters.push_back( new GraphicPropertyItemConverter( + rPropertySet, rItemPool, rDrawModel, + xNamedPropertyContainerFactory, + GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES )); + + // CharacterProperties are not at the title but at its contained XFormattedString objects + // take the first formatted string in the sequence + uno::Reference< chart2::XTitle > xTitle( rPropertySet, uno::UNO_QUERY ); + if( xTitle.is()) + { + uno::Sequence< uno::Reference< chart2::XFormattedString > > aStringSeq( xTitle->getText()); + if( aStringSeq.getLength() > 0 ) + { + m_aConverters.push_back( + new FormattedStringsConverter( aStringSeq, rItemPool, pRefSize, rPropertySet )); + } + } +} + +TitleItemConverter::~TitleItemConverter() +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::DeleteItemConverterPtr() ); +} + +void TitleItemConverter::FillItemSet( SfxItemSet & rOutItemSet ) const +{ + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::FillItemSetFunc( rOutItemSet )); + + // own items + ItemConverter::FillItemSet( rOutItemSet ); +} + +bool TitleItemConverter::ApplyItemSet( const SfxItemSet & rItemSet ) +{ + bool bResult = false; + + ::std::for_each( m_aConverters.begin(), m_aConverters.end(), + ::comphelper::ApplyItemSetFunc( rItemSet, bResult )); + + // own items + return ItemConverter::ApplyItemSet( rItemSet ) || bResult; +} + +const USHORT * TitleItemConverter::GetWhichPairs() const +{ + // must span all used items! + return nTitleWhichPairs; +} + +bool TitleItemConverter::GetItemProperty( tWhichIdType nWhichId, tPropertyNameWithMemberId & rOutProperty ) const +{ + ::comphelper::ItemPropertyMapType & rMap( lcl_GetTitlePropertyMap()); + ::comphelper::ItemPropertyMapType::const_iterator aIt( rMap.find( nWhichId )); + + if( aIt == rMap.end()) + return false; + + rOutProperty =(*aIt).second; + return true; +} + + +bool TitleItemConverter::ApplySpecialItem( + USHORT nWhichId, const SfxItemSet & rItemSet ) + throw( uno::Exception ) +{ + bool bChanged = false; + + switch( nWhichId ) + { + case SCHATTR_TEXT_DEGREES: + { + // convert int to double (divided by 100) + double fVal = static_cast< double >( + static_cast< const SfxInt32Item & >( + rItemSet.Get( nWhichId )).GetValue()) / 100.0; + double fOldVal = 0.0; + bool bPropExisted = + ( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fOldVal ); + + if( ! bPropExisted || + ( bPropExisted && fOldVal != fVal )) + { + GetPropertySet()->setPropertyValue( C2U( "TextRotation" ), uno::makeAny( fVal )); + bChanged = true; + } + } + break; + } + + return bChanged; +} + +void TitleItemConverter::FillSpecialItem( + USHORT nWhichId, SfxItemSet & rOutItemSet ) const + throw( uno::Exception ) +{ + switch( nWhichId ) + { + case SCHATTR_TEXT_DEGREES: + { + // convert double to int (times 100) + double fVal = 0; + + if( GetPropertySet()->getPropertyValue( C2U( "TextRotation" )) >>= fVal ) + { + rOutItemSet.Put( SfxInt32Item( nWhichId, static_cast< sal_Int32 >( + ::rtl::math::round( fVal * 100.0 ) ) )); + } + } + break; + } +} + +} // namespace wrapper +} // namespace chart diff --git a/chart2/source/controller/itemsetwrapper/makefile.mk b/chart2/source/controller/itemsetwrapper/makefile.mk new file mode 100644 index 000000000000..0ab981bba643 --- /dev/null +++ b/chart2/source/controller/itemsetwrapper/makefile.mk @@ -0,0 +1,64 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.10 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcitemsetwrapper + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES= $(SLO)$/ItemConverter.obj \ + $(SLO)$/AxisItemConverter.obj \ + $(SLO)$/MultipleItemConverter.obj \ + $(SLO)$/MultipleChartConverters.obj \ + $(SLO)$/CharacterPropertyItemConverter.obj \ + $(SLO)$/SeriesOptionsItemConverter.obj \ + $(SLO)$/DataPointItemConverter.obj \ + $(SLO)$/GraphicPropertyItemConverter.obj \ + $(SLO)$/LegendItemConverter.obj \ + $(SLO)$/StatisticsItemConverter.obj \ + $(SLO)$/TitleItemConverter.obj \ + $(SLO)$/RegressionCurveItemConverter.obj \ + $(SLO)$/RegressionEquationItemConverter.obj \ + $(SLO)$/ErrorBarItemConverter.obj + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk + diff --git a/chart2/source/controller/main/ChartController.cxx b/chart2/source/controller/main/ChartController.cxx new file mode 100644 index 000000000000..bda0108c8ce8 --- /dev/null +++ b/chart2/source/controller/main/ChartController.cxx @@ -0,0 +1,1528 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController.cxx,v $ + * $Revision: 1.30.16.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" +#include "servicenames.hxx" +#include "ResId.hxx" +#include "dlg_DataSource.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerCommandDispatch.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 "macros.hxx" +#include "dlg_CreationWizard.hxx" +#include "dlg_ChartType.hxx" +//#include "svx/ActionDescriptionProvider.hxx" + +#include <comphelper/InlineContainer.hxx> + +#include <com/sun/star/awt/PosSize.hpp> +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/chart2/XUndoSupplier.hpp> +#include <com/sun/star/chart2/data/XDataReceiver.hpp> +#include <com/sun/star/frame/XLoadable.hpp> +#include <com/sun/star/util/XCloneable.hpp> +#include <com/sun/star/embed/XEmbeddedClient.hpp> +#include <com/sun/star/util/XModeChangeBroadcaster.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> +#include <com/sun/star/frame/LayoutManagerEvents.hpp> + +//------- +// header for define RET_OK +#include <vcl/msgbox.hxx> +//------- + +//------- +#include <toolkit/awt/vclxwindow.hxx> +#include <toolkit/helper/vclunohelper.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +//------- +#include <com/sun/star/frame/XLayoutManager.hpp> +#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> + +// this is needed to properly destroy the auto_ptr to the AcceleratorExecute +// object in the DTOR +#include <svtools/acceleratorexecute.hxx> +#include <svx/ActionDescriptionProvider.hxx> + +// enable the following define to let the controller listen to model changes and +// react on this by rebuilding the view +#define TEST_ENABLE_MODIFY_LISTENER + +/* +#include <vcl/svapp.hxx> +*/ + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +DBG_NAME(ChartController) +//----------------------------------------------------------------- +// ChartController Constructor and Destructor +//----------------------------------------------------------------- + +ChartController::ChartController(uno::Reference<uno::XComponentContext> const & xContext) + : m_aLifeTimeManager( NULL ) + , m_bSuspended( sal_False ) + , m_bCanClose( sal_True ) + , m_xCC(xContext) //@todo is it allowed to hold this context?? + , m_xFrame( NULL ) + , m_aModelMutex() + , m_aModel( NULL, m_aModelMutex ) + , m_pChartWindow( NULL ) + , m_xViewWindow() + , m_xChartView() + , m_pDrawModelWrapper() + , m_pDrawViewWrapper(NULL) + , m_eDragMode(SDRDRAG_MOVE) + , m_bWaitingForDoubleClick(false) + , m_bWaitingForMouseUp(false) + , m_bConnectingToView(false) + , m_xUndoManager( 0 ) + , m_aDispatchContainer( m_xCC ) +{ + DBG_CTOR(ChartController,NULL); +// m_aDispatchContainer.setUndoManager( m_xUndoManager ); + m_aDoubleClickTimer.SetTimeoutHdl( LINK( this, ChartController, DoubleClickWaitingHdl ) ); +} + +ChartController::~ChartController() +{ + DBG_DTOR(ChartController,NULL); + stopDoubleClickWaiting(); +} + +//----------------------------------------------------------------- + +ChartController::RefCountable::RefCountable() : m_nRefCount(0) +{ +} + +ChartController::RefCountable::~RefCountable() +{ +} +void ChartController::RefCountable::acquire() +{ + m_nRefCount++; +} +void ChartController::RefCountable::release() +{ + m_nRefCount--; + if(!m_nRefCount) + delete this; +} + +//----------------------------------------------------------------- + +ChartController::TheModel::TheModel( const uno::Reference< frame::XModel > & xModel ) + : m_xModel( xModel ) + , m_xCloseable( NULL ) + , m_bOwnership( sal_True ) + , m_bOwnershipIsWellKnown( sal_False ) +{ + m_xCloseable = + uno::Reference< util::XCloseable >( xModel, uno::UNO_QUERY ); +} + +ChartController::TheModel::~TheModel() +{ +} + +void ChartController::TheModel::SetOwnerShip( sal_Bool bGetsOwnership ) +{ + m_bOwnership = bGetsOwnership; + m_bOwnershipIsWellKnown = sal_True; +} + +void ChartController::TheModel::addListener( ChartController* pController ) +{ + if(m_xCloseable.is()) + { + //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( + 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( + static_cast<util::XCloseListener*>(pController) ); +} + +void ChartController::TheModel::tryTermination() +{ + if(!m_bOwnership) + return; + + try + { + if(m_xCloseable.is()) + { + try + { + //@todo ? are we allowed to use sal_True here if we have the explicit ownership? + //I think yes, because there might be other closelistners later in the list which might be interested still + //but make sure that we do not throw the CloseVetoException here ourselfs + //so stop listening before trying to terminate or check the source of queryclosing event + m_xCloseable->close(sal_True); + + m_bOwnership = false; + m_bOwnershipIsWellKnown = sal_True; + } + catch( util::CloseVetoException& ) + { + //since we have indicated to give up the ownership with paramter true in close call + //the one who has thrown the CloseVetoException is the new owner + +#if OSL_DEBUG_LEVEL > 2 + OSL_ENSURE( !m_bOwnership, + "INFO: a well known owner has catched a CloseVetoException after calling close(true)" ); +#endif + + m_bOwnership = false; + m_bOwnershipIsWellKnown = sal_True; + return; + } + + } + else if( m_xModel.is() ) + { + //@todo correct?? + m_xModel->dispose(); + return; + } + } + catch( uno::Exception& ex) + { + (void)(ex); // no warning in non-debug builds + OSL_ENSURE( sal_False, ( rtl::OString("Termination of model failed: ") + + rtl::OUStringToOString( ex.Message, RTL_TEXTENCODING_ASCII_US ) ).getStr() ); + } +} + +//----------------------------------------------------------------- + +ChartController::TheModelRef::TheModelRef( TheModel* pTheModel, ::osl::Mutex& rMutex ) + : m_pTheModel(pTheModel), m_rModelMutex(rMutex) +{ + ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex ); + if(m_pTheModel) + m_pTheModel->acquire(); +} +ChartController::TheModelRef::TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex ) + : m_rModelMutex(rMutex) +{ + ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex ); + m_pTheModel=rTheModel.operator->(); + if(m_pTheModel) + m_pTheModel->acquire(); +} +ChartController::TheModelRef& ChartController::TheModelRef::operator=(TheModel* pTheModel) +{ + ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex ); + if(m_pTheModel==pTheModel) + return *this; + if(m_pTheModel) + m_pTheModel->release(); + m_pTheModel=pTheModel; + if(m_pTheModel) + m_pTheModel->acquire(); + return *this; +} +ChartController::TheModelRef& ChartController::TheModelRef::operator=(const TheModelRef& rTheModel) +{ + ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex ); + TheModel* pNew=rTheModel.operator->(); + if(m_pTheModel==pNew) + return *this; + if(m_pTheModel) + m_pTheModel->release(); + m_pTheModel=pNew; + if(m_pTheModel) + m_pTheModel->acquire(); + return *this; +} +ChartController::TheModelRef::~TheModelRef() +{ + ::osl::Guard< ::osl::Mutex > aGuard( m_rModelMutex ); + if(m_pTheModel) + m_pTheModel->release(); +} +sal_Bool ChartController::TheModelRef::is() const +{ + return (m_pTheModel != 0); +} + + +//----------------------------------------------------------------- +// private methods +//----------------------------------------------------------------- + + sal_Bool ChartController +::impl_isDisposedOrSuspended() const +{ + if( m_aLifeTimeManager.impl_isDisposed() ) + return sal_True; + + if( m_bSuspended ) + { + OSL_ENSURE( sal_False, "This Controller is suspended" ); + return sal_True; + } + return sal_False; +} + +//----------------------------------------------------------------- +// lang::XServiceInfo +//----------------------------------------------------------------- + +APPHELPER_XSERVICEINFO_IMPL(ChartController,CHART_CONTROLLER_SERVICE_IMPLEMENTATION_NAME) + + uno::Sequence< rtl::OUString > ChartController +::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 2 ); + aSNS.getArray()[ 0 ] = CHART_CONTROLLER_SERVICE_NAME; + aSNS.getArray()[ 1 ] = ::rtl::OUString::createFromAscii("com.sun.star.frame.Controller"); + //// @todo : add additional services if you support any further + return aSNS; +} + +//----------------------------------------------------------------- +// XController +//----------------------------------------------------------------- + + void SAL_CALL ChartController +::attachFrame( const uno::Reference<frame::XFrame>& xFrame ) + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + if( impl_isDisposedOrSuspended() ) //@todo? allow attaching the frame while suspended? + return; //behave passive if already disposed or suspended + + if(m_xFrame.is()) //what happens, if we do have a Frame already?? + { + //@todo? throw exception? + OSL_ENSURE( sal_False, "there is already a frame attached to the controller" ); + return; + } + + //--attach frame + m_xFrame = xFrame; //the frameloader is responsible to call xFrame->setComponent + + //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 + //the frame or the disposer of the frame has the duty to call suspend and dispose on this object + //so we do not need to add as lang::XEventListener for DisposingEvents right? + + //@todo nothing right??? + + + + //-------------------------------------------------- + //create view @todo is this the correct place here?? + + Window* pParent = NULL; + //get the window parent from the frame to use as parent for our new window + if(xFrame.is()) + { + uno::Reference< awt::XWindow > xContainerWindow = xFrame->getContainerWindow(); + VCLXWindow* pParentComponent = VCLXWindow::GetImplementation(xContainerWindow); + pParentComponent->setVisible(sal_True); + + pParent = VCLUnoHelper::GetWindow( xContainerWindow ); + } + + if(m_pChartWindow) + { + //@todo delete ... + m_pChartWindow->clear(); + m_apDropTargetHelper.reset(); + } + { + awt::Size aPageSize( ChartModelHelper::getPageSize(m_aModel->getModel()) ); + + // calls to VCL + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + m_pChartWindow = new ChartWindow(this,pParent,pParent?pParent->GetStyle():0); + m_pChartWindow->SetBackground();//no Background + m_xViewWindow = uno::Reference< awt::XWindow >( m_pChartWindow->GetComponentInterface(), uno::UNO_QUERY ); + m_pChartWindow->Show(); + m_apDropTargetHelper.reset( + new ChartDropTargetHelper( m_pChartWindow->GetDropTarget(), + uno::Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY ))); + + impl_createDrawViewController(); + } + + //create the menu + { + uno::Reference< beans::XPropertySet > xPropSet( xFrame, uno::UNO_QUERY ); + if( xPropSet.is() ) + { + try + { + uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager; + if ( xLayoutManager.is() ) + { + xLayoutManager->lock(); + xLayoutManager->requestElement( C2U( "private:resource/menubar/menubar" ) ); + //@todo: createElement should become unnecessary, remove when #i79198# is fixed + xLayoutManager->createElement( C2U( "private:resource/toolbar/standardbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/toolbar/standardbar" ) ); + //@todo: createElement should become unnecessary, remove when #i79198# is fixed + xLayoutManager->createElement( C2U( "private:resource/toolbar/toolbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/toolbar/toolbar" ) ); + xLayoutManager->requestElement( C2U( "private:resource/statusbar/statusbar" ) ); + xLayoutManager->unlock(); + + // add as listener to get notified when + m_xLayoutManagerEventBroadcaster.set( xLayoutManager, uno::UNO_QUERY ); + if( m_xLayoutManagerEventBroadcaster.is()) + m_xLayoutManagerEventBroadcaster->addLayoutManagerEventListener( this ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } +} + +//XModeChangeListener +void SAL_CALL ChartController::modeChanged( const util::ModeChangeEvent& rEvent ) + throw ( uno::RuntimeException ) +{ + //adjust controller to view status changes + + if( rEvent.NewMode.equals(C2U("dirty")) ) + { + //the view has become dirty, we should repaint it if we have a window + if( m_pChartWindow ) + m_pChartWindow->ForceInvalidate(); + } + else if( rEvent.NewMode.equals(C2U("invalid")) ) + { + //the view is about to become invalid so end all actions on it + impl_invalidateAccessible(); + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper && m_pDrawViewWrapper->IsTextEdit() ) + this->EndTextEdit(); + if( m_pDrawViewWrapper ) + { + m_pDrawViewWrapper->UnmarkAll(); + //m_pDrawViewWrapper->hideMarkHandles(); todo?? + m_pDrawViewWrapper->HideSdrPage(); + } + } + else + { + //the view was rebuild so we can start some actions on it again + if( !m_bConnectingToView ) + { + if(m_pChartWindow && m_aModel.is() ) + { + m_bConnectingToView = true; + + GetDrawModelWrapper(); + if(m_pDrawModelWrapper) + { + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper ) + m_pDrawViewWrapper->ReInit(); + } + + //reselect object + if( m_aSelection.hasSelection() ) + this->impl_selectObjectAndNotiy(); + else + ChartModelHelper::triggerRangeHighlighting( m_aModel->getModel() ); + + impl_initializeAccessible(); + + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + } + + m_bConnectingToView = false; + } + } + } +} + + sal_Bool SAL_CALL ChartController +::attachModel( const uno::Reference< frame::XModel > & xModel ) + throw(uno::RuntimeException) +{ + impl_invalidateAccessible(); + + //is called to attach the controller to a new model. + //return true if attach was successfully, false otherwise (e.g. if you do not work with a model) + + ::vos::OClearableGuard aGuard( Application::GetSolarMutex()); + if( impl_isDisposedOrSuspended() ) //@todo? allow attaching a new model while suspended? + return sal_False; //behave passive if already disposed or suspended + aGuard.clear(); + + + TheModelRef aNewModelRef( new TheModel( xModel), 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); + m_pDrawModelWrapper.reset(); + + aOldModelRef->removeListener( this ); + //@todo?? termination correct? +// aOldModelRef->tryTermination(); +#ifdef TEST_ENABLE_MODIFY_LISTENER + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aOldModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->removeModifyListener( this ); +#endif + } + + //--handle relations to the new model + aNewModelRef->addListener( this ); + + // set new model at dispatchers + m_aDispatchContainer.setModel( aNewModelRef->getModel()); + ControllerCommandDispatch * pDispatch = new ControllerCommandDispatch( m_xCC, this ); + pDispatch->initialize(); + + // the dispatch container will return "this" for all commands returned by + // impl_getAvailableCommands(). That means, for those commands dispatch() + // is called here at the ChartController. + m_aDispatchContainer.setFallbackDispatch( pDispatch, impl_getAvailableCommands() ); + +#ifdef TEST_ENABLE_MODIFY_LISTENER + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aNewModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->addModifyListener( this ); +#endif + + //select chart area per default: + select( uno::makeAny( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) ) ); + + uno::Reference< lang::XMultiServiceFactory > xFact( m_aModel->getModel(), uno::UNO_QUERY ); + if( xFact.is()) + { + m_xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + GetDrawModelWrapper(); + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); + if( xViewBroadcaster.is() ) + xViewBroadcaster->addModeChangeListener(this); + } + + //the frameloader is responsible to call xModel->connectController + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + + uno::Reference< chart2::XUndoSupplier > xUndoSupplier( m_aModel->getModel(), uno::UNO_QUERY ); + if( xUndoSupplier.is()) + m_xUndoManager.set( xUndoSupplier->getUndoManager()); + + return sal_True; +} + + uno::Reference< frame::XFrame > SAL_CALL ChartController +::getFrame() throw(uno::RuntimeException) +{ + //provides access to owner frame of this controller + //return the frame containing this controller + + return m_xFrame; +} + + uno::Reference< frame::XModel > SAL_CALL ChartController +::getModel() throw(uno::RuntimeException) +{ + //provides access to currently attached model + //returns the currently attached model + + //return nothing, if you do not have a model + TheModelRef aModelRef( m_aModel, m_aModelMutex); + if(aModelRef.is()) + return aModelRef->getModel(); + + return uno::Reference< frame::XModel > (); +} + + uno::Any SAL_CALL ChartController +::getViewData() throw(uno::RuntimeException) +{ + //provides access to current view status + //set of data that can be used to restore the current view status at later time + // by using XController::restoreViewData() + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( impl_isDisposedOrSuspended() ) + return uno::Any(); //behave passive if already disposed or suspended //@todo? or throw an exception?? + + //-- collect current view state + uno::Any aRet; + //// @todo integrate specialized implementation + + return aRet; +} + + void SAL_CALL ChartController +::restoreViewData( const uno::Any& /* Value */ ) + throw(uno::RuntimeException) +{ + //restores the view status using the data gotten from a previous call to XController::getViewData() + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( impl_isDisposedOrSuspended() ) + return; //behave passive if already disposed or suspended //@todo? or throw an exception?? + + //// @todo integrate specialized implementation +} + + sal_Bool SAL_CALL ChartController +::suspend( sal_Bool bSuspend ) + throw(uno::RuntimeException) +{ + //is called to prepare the controller for closing the view + //bSuspend==true: force the controller to suspend his work + //bSuspend==false try to reactivate the controller + //returns true if request was accepted and of course successfully finished, false otherwise + + //we may show dialogs here to ask the user for saving changes ... @todo? + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_aLifeTimeManager.impl_isDisposed() ) + return sal_False; //behave passive if already disposed, return false because request was not accepted //@todo? correct + + if(bSuspend==m_bSuspended) + { + OSL_ENSURE( sal_False, "new suspend mode equals old suspend mode" ); + return sal_True; + } + + //change suspend mode + if(bSuspend) + { + //aGuard.clear(); + //@todo ??? try to stop all what may prevent me from becoming disposed + //aGuard.reset(); + + m_bSuspended = bSuspend; + return sal_True; + } + else + { + //aGuard.clear(); + //@todo ??? redo what was made in section bSuspend==true + //aGuard.reset(); + + m_bSuspended = bSuspend; + } + return sal_True; + + + /* + if ( bSuspend ) + getFrame()->removeFrameActionListener( pImp ); + else + getFrame()->addFrameActionListener( pImp ); + */ +} + + +void ChartController::impl_createDrawViewController() +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if(!m_pDrawViewWrapper) + { + if( m_pDrawModelWrapper ) + { + m_pDrawViewWrapper = new DrawViewWrapper(&m_pDrawModelWrapper->getSdrModel(),m_pChartWindow,true); + m_pDrawViewWrapper->attachParentReferenceDevice( m_aModel->getModel()); + } + } +} +void ChartController::impl_deleteDrawViewController() +{ + if( m_pDrawViewWrapper ) + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper->IsTextEdit() ) + this->EndTextEdit(); + DELETEZ( m_pDrawViewWrapper ); + } +} + +//----------------------------------------------------------------- +// XComponent (base of XController) +//----------------------------------------------------------------- + + void SAL_CALL ChartController +::dispose() throw(uno::RuntimeException) +{ + try + { + //This object should release all resources and references in the + //easiest possible manner + //This object must notify all registered listeners using the method + //<member>XEventListener::disposing</member> + + //hold no mutex + if( !m_aLifeTimeManager.dispose() ) + return; + +// OSL_ENSURE( m_bSuspended, "dispose was called but controller is not suspended" ); + + this->stopDoubleClickWaiting(); + + //end range highlighting + if( m_aModel.is()) + { + uno::Reference< view::XSelectionChangeListener > xSelectionChangeListener; + uno::Reference< chart2::data::XDataReceiver > xDataReceiver( m_aModel->getModel(), uno::UNO_QUERY ); + if( xDataReceiver.is() ) + xSelectionChangeListener = uno::Reference< view::XSelectionChangeListener >( xDataReceiver->getRangeHighlighter(), uno::UNO_QUERY ); + if( xSelectionChangeListener.is() ) + { + uno::Reference< frame::XController > xController( this ); + uno::Reference< lang::XComponent > xComp( xController, uno::UNO_QUERY ); + //lang::EventObject aEvent( static_cast< lang::XComponent* >( this ) ); + lang::EventObject aEvent( xComp ); + xSelectionChangeListener->disposing( aEvent ); + } + } + + //--release all resources and references + { + uno::Reference< util::XModeChangeBroadcaster > xViewBroadcaster( m_xChartView, uno::UNO_QUERY ); + if( xViewBroadcaster.is() ) + xViewBroadcaster->removeModeChangeListener(this); + // /-- + impl_invalidateAccessible(); + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + impl_deleteDrawViewController(); + m_pDrawModelWrapper.reset(); + + m_apDropTargetHelper.reset(); + + //the accessible view is disposed within window destructor of m_pChartWindow + m_pChartWindow->clear(); + m_pChartWindow = NULL;//m_pChartWindow is deleted via UNO due to dispose of m_xViewWindow (trigerred by Framework (Controller pretends to be XWindow also)) + m_xViewWindow->dispose(); + m_xChartView.clear(); + // \-- + } + + // remove as listener to layout manager events + if( m_xLayoutManagerEventBroadcaster.is()) + { + m_xLayoutManagerEventBroadcaster->removeLayoutManagerEventListener( this ); + m_xLayoutManagerEventBroadcaster.set( 0 ); + } + + m_xFrame.clear(); + m_xUndoManager.clear(); + + TheModelRef aModelRef( m_aModel, m_aModelMutex); + m_aModel = NULL; + + if( aModelRef.is()) + { + uno::Reference< frame::XModel > xModel( aModelRef->getModel() ); + if(xModel.is()) + xModel->disconnectController( uno::Reference< frame::XController >( this )); + + aModelRef->removeListener( this ); +#ifdef TEST_ENABLE_MODIFY_LISTENER + try + { + uno::Reference< util::XModifyBroadcaster > xMBroadcaster( aModelRef->getModel(),uno::UNO_QUERY ); + if( xMBroadcaster.is()) + xMBroadcaster->removeModifyListener( this ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +#endif + aModelRef->tryTermination(); + } + + //// @todo integrate specialized implementation + //e.g. release further resources and references + + m_aDispatchContainer.DisposeAndClear(); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + void SAL_CALL ChartController +::addEventListener( const uno::Reference<lang::XEventListener>& xListener ) + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + 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( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener ); +} + + void SAL_CALL ChartController +::removeEventListener( const uno::Reference< + lang::XEventListener>& xListener ) + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_aLifeTimeManager.impl_isDisposed() ) + return; //behave passive if already disposed or suspended + + //--remove listener + m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< lang::XEventListener >*)0), xListener ); +} + + +//----------------------------------------------------------------- +// util::XCloseListener +//----------------------------------------------------------------- + void SAL_CALL ChartController +::queryClosing( const lang::EventObject& rSource, sal_Bool bGetsOwnership ) + throw(util::CloseVetoException, uno::RuntimeException) +{ + //do not use the m_aControllerMutex here because this call is not allowed to block + + TheModelRef aModelRef( m_aModel, m_aModelMutex); + + if( !aModelRef.is() ) + return; + + if( !(aModelRef->getModel() == rSource.Source) ) + { + OSL_ENSURE( sal_False, "queryClosing was called on a controller from an unknown source" ); + return; + } + + if( !m_bCanClose )//@todo tryaqcuire mutex + { + if( bGetsOwnership ) + { + aModelRef->SetOwnerShip( bGetsOwnership ); + } + + throw util::CloseVetoException(); + } + else + { + //@ todo prepare to to closing model -> don't start any further hindering actions + } +} + + void SAL_CALL ChartController +::notifyClosing( const lang::EventObject& rSource ) + throw(uno::RuntimeException) +{ + //Listener should deregister himself and relaese all references to the closing object. + + TheModelRef aModelRef( m_aModel, m_aModelMutex); + if( impl_releaseThisModel( rSource.Source ) ) + { + //--stop listening to the closing model + aModelRef->removeListener( this ); + + // #i79087# If the model using this controller is closed, the frame is + // expected to be closed as well + Reference< util::XCloseable > xFrameCloseable( m_xFrame, uno::UNO_QUERY ); + if( xFrameCloseable.is()) + { + try + { + xFrameCloseable->close( sal_False /* DeliverOwnership */ ); + m_xFrame.clear(); + } + catch( util::CloseVetoException & ) + { + // closing was vetoed + } + } + } +} + +bool ChartController::impl_releaseThisModel( const uno::Reference< uno::XInterface > & xModel ) +{ + bool bReleaseModel = sal_False; + { + ::osl::Guard< ::osl::Mutex > aGuard( m_aModelMutex ); + if( m_aModel.is() && m_aModel->getModel() == xModel ) + { + m_aModel = NULL; + m_xUndoManager.clear(); + bReleaseModel = true; + } + } + return bReleaseModel; +} + +//----------------------------------------------------------------- +// util::XEventListener (base of XCloseListener) +//----------------------------------------------------------------- + void SAL_CALL ChartController +::disposing( const lang::EventObject& rSource ) + throw(uno::RuntimeException) +{ + if( !impl_releaseThisModel( rSource.Source )) + { + if( rSource.Source == m_xLayoutManagerEventBroadcaster ) + m_xLayoutManagerEventBroadcaster.set( 0 ); + } +} + +void SAL_CALL ChartController::layoutEvent( const lang::EventObject& aSource, ::sal_Int16 eLayoutEvent, const uno::Any& /* aInfo */ ) + throw (uno::RuntimeException) +{ + if( eLayoutEvent == frame::LayoutManagerEvents::MERGEDMENUBAR ) + { + Reference< frame::XLayoutManager > xLM( aSource.Source, uno::UNO_QUERY ); + if( xLM.is()) + { + xLM->createElement( C2U("private:resource/statusbar/statusbar")); + xLM->requestElement( C2U("private:resource/statusbar/statusbar")); + } + } +} + + +//----------------------------------------------------------------- +// XDispatchProvider (required interface) +//----------------------------------------------------------------- + +namespace +{ +bool lcl_isFormatObjectCommand( const rtl::OString& aCommand ) +{ + if( aCommand.equals("MainTitle") + || aCommand.equals("SubTitle") + || aCommand.equals("XTitle") + || aCommand.equals("YTitle") + || aCommand.equals("ZTitle") + || aCommand.equals("SecondaryXTitle") + || aCommand.equals("SecondaryYTitle") + || aCommand.equals("AllTitles") + || aCommand.equals("DiagramAxisX") + || aCommand.equals("DiagramAxisY") + || aCommand.equals("DiagramAxisZ") + || aCommand.equals("DiagramAxisA") + || aCommand.equals("DiagramAxisB") + || aCommand.equals("DiagramAxisAll") + || aCommand.equals("DiagramGridXMain") + || aCommand.equals("DiagramGridYMain") + || aCommand.equals("DiagramGridZMain") + || aCommand.equals("DiagramGridXHelp") + || aCommand.equals("DiagramGridYHelp") + || aCommand.equals("DiagramGridZHelp") + || aCommand.equals("DiagramGridAll") + + || aCommand.equals("DiagramWall") + || aCommand.equals("DiagramFloor") + || aCommand.equals("DiagramArea") + || aCommand.equals("Legend") + + || aCommand.equals("FormatWall") + || aCommand.equals("FormatFloor") + || aCommand.equals("FormatChartArea") + || aCommand.equals("FormatLegend") + + || aCommand.equals("FormatTitle") + || aCommand.equals("FormatAxis") + || aCommand.equals("FormatDataSeries") + || aCommand.equals("FormatDataPoint") + || aCommand.equals("FormatDataLabels") + || aCommand.equals("FormatDataLabel") + || aCommand.equals("FormatYErrorBars") + || aCommand.equals("FormatMeanValue") + || aCommand.equals("FormatTrendline") + || aCommand.equals("FormatTrendlineEquation") + || aCommand.equals("FormatStockLoss") + || aCommand.equals("FormatStockGain") + || aCommand.equals("FormatMajorGrid") + || aCommand.equals("FormatMinorGrid") + ) + return true; + + // else + return false; +} +} // anonymous namespace + + uno::Reference<frame::XDispatch> SAL_CALL ChartController +::queryDispatch( const util::URL& rURL + , const rtl::OUString& rTargetFrameName + , sal_Int32 /* nSearchFlags */) + throw(uno::RuntimeException) +{ + if ( !m_aLifeTimeManager.impl_isDisposed() ) + { + if( rTargetFrameName.getLength() && + rTargetFrameName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_self"))) + return m_aDispatchContainer.getDispatchForURL( rURL ); + } + return uno::Reference< frame::XDispatch > (); +} + + uno::Sequence<uno::Reference<frame::XDispatch > > ChartController +::queryDispatches( const uno::Sequence< + frame::DispatchDescriptor>& xDescripts) + throw(uno::RuntimeException) +{ + if ( !m_aLifeTimeManager.impl_isDisposed() ) + { + return m_aDispatchContainer.getDispatchesForURLs( xDescripts ); + } + return uno::Sequence<uno::Reference<frame::XDispatch > > (); +} + +//----------------------------------------------------------------- +// frame::XDispatch +//----------------------------------------------------------------- + + void SAL_CALL ChartController +::dispatch( const util::URL& rURL + , const uno::Sequence< beans::PropertyValue >& /* rArgs */ ) + throw (uno::RuntimeException) +{ + //@todo avoid OString (see Mathias mail on bug #104387#) + rtl::OString aCommand( rtl::OUStringToOString( rURL.Path, RTL_TEXTENCODING_ASCII_US ) ); + + if(aCommand.equals("Paste")) + this->executeDispatch_Paste(); + else if(aCommand.equals("Copy")) + this->executeDispatch_Copy(); + else if(aCommand.equals("Cut")) + this->executeDispatch_Cut(); + else if(aCommand.equals("DataRanges")) + this->executeDispatch_SourceData(); + //---------------------------------- + else if(aCommand.equals("Update")) //Update Chart + { + ChartViewHelper::setViewToDirtyState( m_aModel->getModel() ); + if( m_pChartWindow ) + m_pChartWindow->Invalidate(); + } + else if(aCommand.equals("DiagramData")) + this->executeDispatch_EditData(); + //insert objects + else if( aCommand.equals("InsertTitles") + || aCommand.equals("InsertMenuTitles") ) + this->executeDispatch_InsertTitles(); + else if( aCommand.equals("InsertMenuLegend") ) + this->executeDispatch_OpenLegendDialog(); + else if( aCommand.equals("InsertLegend") ) + this->executeDispatch_InsertLegend(); + else if( aCommand.equals("DeleteLegend") ) + this->executeDispatch_DeleteLegend(); + else if( aCommand.equals("InsertMenuDataLabels")) + this->executeDispatch_InsertMenu_DataLabels(); + else if( aCommand.equals("InsertMenuAxes") + || aCommand.equals("InsertRemoveAxes") ) + this->executeDispatch_InsertAxes(); + else if( aCommand.equals("InsertMenuGrids")) + this->executeDispatch_InsertGrid(); + else if( aCommand.equals("InsertMenuTrendlines")) + this->executeDispatch_InsertMenu_Trendlines(); + else if( aCommand.equals("InsertMenuMeanValues")) + this->executeDispatch_InsertMenu_MeanValues(); + else if( aCommand.equals("InsertMenuYErrorBars")) + this->executeDispatch_InsertMenu_YErrorBars(); + else if( aCommand.equals("InsertSymbol")) + this->executeDispatch_InsertSpecialCharacter(); + else if( aCommand.equals("InsertTrendline")) + this->executeDispatch_InsertTrendline(); + else if( aCommand.equals("DeleteTrendline")) + this->executeDispatch_DeleteTrendline(); + else if( aCommand.equals("InsertMeanValue")) + this->executeDispatch_InsertMeanValue(); + else if( aCommand.equals("DeleteMeanValue")) + this->executeDispatch_DeleteMeanValue(); + else if( aCommand.equals("InsertYErrorBars")) + this->executeDispatch_InsertYErrorBars(); + else if( aCommand.equals("DeleteYErrorBars")) + this->executeDispatch_DeleteYErrorBars(); + else if( aCommand.equals("InsertTrendlineEquation")) + this->executeDispatch_InsertTrendlineEquation(); + else if( aCommand.equals("DeleteTrendlineEquation")) + this->executeDispatch_DeleteTrendlineEquation(); + else if( aCommand.equals("InsertTrendlineEquationAndR2")) + this->executeDispatch_InsertTrendlineEquation( true ); + else if( aCommand.equals("InsertR2Value")) + this->executeDispatch_InsertR2Value(); + else if( aCommand.equals("DeleteR2Value")) + this->executeDispatch_DeleteR2Value(); + else if( aCommand.equals("InsertDataLabels") ) + this->executeDispatch_InsertDataLabels(); + else if( aCommand.equals("InsertDataLabel") ) + this->executeDispatch_InsertDataLabel(); + else if( aCommand.equals("DeleteDataLabels") ) + this->executeDispatch_DeleteDataLabels(); + else if( aCommand.equals("DeleteDataLabel") ) + this->executeDispatch_DeleteDataLabel(); + else if( aCommand.equals("ResetAllDataPoints") ) + this->executeDispatch_ResetAllDataPoints(); + else if( aCommand.equals("ResetDataPoint") ) + this->executeDispatch_ResetDataPoint(); + else if( aCommand.equals("InsertAxis") ) + this->executeDispatch_InsertAxis(); + else if( aCommand.equals("InsertMajorGrid") ) + this->executeDispatch_InsertMajorGrid(); + else if( aCommand.equals("InsertMinorGrid") ) + this->executeDispatch_InsertMinorGrid(); + else if( aCommand.equals("InsertAxisTitle") ) + this->executeDispatch_InsertAxisTitle(); + else if( aCommand.equals("DeleteAxis") ) + this->executeDispatch_DeleteAxis(); + else if( aCommand.equals("DeleteMajorGrid") ) + this->executeDispatch_DeleteMajorGrid(); + else if( aCommand.equals("DeleteMinorGrid") ) + this->executeDispatch_DeleteMinorGrid(); + //format objects + else if( aCommand.equals("FormatSelection") ) + this->executeDispatch_ObjectProperties(); + else if( aCommand.equals("TransformDialog")) + this->executeDispatch_PositionAndSize(); + else if( lcl_isFormatObjectCommand(aCommand) ) + this->executeDispatch_FormatObject(rURL.Path); + //more format +//MENUCHANGE else if(aCommand.equals("SelectSourceRanges")) +//MENUCHANGE this->executeDispatch_SourceData(); + else if( aCommand.equals("DiagramType")) + this->executeDispatch_ChartType(); + else if( aCommand.equals("View3D")) + this->executeDispatch_View3D(); + else if( aCommand.equals("Forward")) + this->executeDispatch_MoveSeries( sal_True ); + else if( aCommand.equals("Backward")) + this->executeDispatch_MoveSeries( sal_False ); + else if( aCommand.equals("NewArrangement")) + this->executeDispatch_NewArrangement(); + else if( aCommand.equals("ToggleLegend")) + this->executeDispatch_ToggleLegend(); + else if( aCommand.equals("ToggleGridHorizontal")) + this->executeDispatch_ToggleGridHorizontal(); + else if( aCommand.equals("ScaleText")) + this->executeDispatch_ScaleText(); + else if( aCommand.equals("StatusBarVisible")) + { + // workaround: this should not be necessary. + uno::Reference< beans::XPropertySet > xPropSet( m_xFrame, uno::UNO_QUERY ); + if( xPropSet.is() ) + { + uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager; + if ( xLayoutManager.is() ) + { + bool bIsVisible( xLayoutManager->isElementVisible( C2U("private:resource/statusbar/statusbar"))); + if( bIsVisible ) + { + xLayoutManager->hideElement( C2U( "private:resource/statusbar/statusbar")); + xLayoutManager->destroyElement( C2U( "private:resource/statusbar/statusbar")); + } + else + { + xLayoutManager->createElement( C2U( "private:resource/statusbar/statusbar")); + xLayoutManager->showElement( C2U( "private:resource/statusbar/statusbar")); + } + // @todo: update menu state (checkmark next to "Statusbar"). + } + } + } + + /* + case SID_TEXTEDIT: + this->executeDispatch_EditText(); + */ +} + + void SAL_CALL ChartController +::addStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */ + , const util::URL& /* aURL */ ) + throw (uno::RuntimeException) +{ +// // TODO: add listener by URL ! +// ::vos::OGuard aGuard( Application::GetSolarMutex()); +// 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( ::getCppuType( & xControl ), xControl ); +} + + void SAL_CALL ChartController +::removeStatusListener( const uno::Reference<frame::XStatusListener >& /* xControl */ + , const util::URL& /* aURL */ ) + throw (uno::RuntimeException) +{ +// // TODO: remove listener by URL ! +// ::vos::OGuard aGuard( Application::GetSolarMutex()); +// if( m_aLifeTimeManager.impl_isDisposed() ) +// return; //behave passive if already disposed or suspended + +// //--remove listener +// m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType( & xControl ), xControl ); +} + +//----------------------------------------------------------------- +// XContextMenuInterception (optional interface) +//----------------------------------------------------------------- + void SAL_CALL ChartController +::registerContextMenuInterceptor( const uno::Reference< + ui::XContextMenuInterceptor > & /* xInterceptor */) + throw(uno::RuntimeException) +{ + //@todo +} + + void SAL_CALL ChartController +::releaseContextMenuInterceptor( const uno::Reference< + ui::XContextMenuInterceptor > & /* xInterceptor */) + throw(uno::RuntimeException) +{ + //@todo +} + +// ____ XEmbeddedClient ____ +// implementation see: ChartController_EditData.cxx + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void SAL_CALL ChartController::executeDispatch_ChartType() +{ + // using assignment for broken gcc 3.3 + UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHARTTYPE ))), m_xUndoManager, m_aModel->getModel() ); + + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + //prepare and open dialog + ChartTypeDialog aDlg( m_pChartWindow, m_aModel->getModel(), m_xCC ); + if( aDlg.Execute() == RET_OK ) + { + impl_adaptDataSeriesAutoResize(); + aUndoGuard.commitAction(); + } + // \-- +} + +void SAL_CALL ChartController::executeDispatch_SourceData() +{ + //------------------------------------------------------------- + //convert properties to ItemSet + uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); + DBG_ASSERT( xChartDoc.is(), "Invalid XChartDocument" ); + if( !xChartDoc.is()) + return; + + // using assignment for broken gcc 3.3 + UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_DATA_RANGES ))), m_xUndoManager, m_aModel->getModel() ); + if( xChartDoc.is()) + { + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + ::chart::DataSourceDialog aDlg( m_pChartWindow, xChartDoc, m_xCC ); + if( aDlg.Execute() == RET_OK ) + { + impl_adaptDataSeriesAutoResize(); + aUndoGuard.commitAction(); + } + // \-- + } +} + +void SAL_CALL ChartController::executeDispatch_MoveSeries( sal_Bool bForward ) +{ + ControllerLockGuard aCLGuard( m_aModel->getModel()); + + //get selected series + ::rtl::OUString aObjectCID(m_aSelection.getSelectedCID()); + uno::Reference< XDataSeries > xGivenDataSeries( ObjectIdentifier::getDataSeriesForCID( //yyy todo also legendentries and labels? + aObjectCID, m_aModel->getModel() ) ); + + UndoGuardWithSelection aUndoGuard( + ActionDescriptionProvider::createDescription( + (bForward ? ActionDescriptionProvider::MOVE_TOTOP : ActionDescriptionProvider::MOVE_TOBOTTOM), + ::rtl::OUString( String( SchResId( STR_OBJECT_DATASERIES )))), + m_xUndoManager, m_aModel->getModel()); + + bool bChanged = DiagramHelper::moveSeries( ChartModelHelper::findDiagram( m_aModel->getModel() ), xGivenDataSeries, bForward ); + if( bChanged ) + { + m_aSelection.setSelection( ObjectIdentifier::getMovedSeriesCID( aObjectCID, bForward ) ); + aUndoGuard.commitAction(); + } +} + +// ____ XMultiServiceFactory ____ +uno::Reference< uno::XInterface > SAL_CALL + ChartController::createInstance( const ::rtl::OUString& aServiceSpecifier ) + throw (uno::Exception, + uno::RuntimeException) +{ + uno::Reference< uno::XInterface > xResult; + + if( aServiceSpecifier.equals( CHART_ACCESSIBLE_TEXT_SERVICE_NAME )) + xResult.set( impl_createAccessibleTextContext()); + return xResult; +} + +uno::Reference< uno::XInterface > SAL_CALL + ChartController::createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, + const uno::Sequence< uno::Any >& /* Arguments */ ) + throw (uno::Exception, + uno::RuntimeException) +{ + // ignore Arguments + return createInstance( ServiceSpecifier ); +} + +uno::Sequence< ::rtl::OUString > SAL_CALL + ChartController::getAvailableServiceNames() + throw (uno::RuntimeException) +{ + static uno::Sequence< ::rtl::OUString > aServiceNames; + + if( aServiceNames.getLength() == 0 ) + { + aServiceNames.realloc(1); + aServiceNames[0] = CHART_ACCESSIBLE_TEXT_SERVICE_NAME; + } + + return aServiceNames; +} + +// ____ XModifyListener ____ +void SAL_CALL ChartController::modified( const lang::EventObject& /* aEvent */ ) + throw (uno::RuntimeException) +{ + // the source can also be a subobject of the ChartModel + // @todo: change the source in ChartModel to always be the model itself ? +// if( m_aModel->getModel() == aEvent.Source ) + + + //todo? update menu states ? +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +DrawModelWrapper* ChartController::GetDrawModelWrapper() +{ + if( !m_pDrawModelWrapper.get() ) + { + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( m_xChartView ); + if( pProvider ) + m_pDrawModelWrapper = pProvider->getDrawModelWrapper(); + } + return m_pDrawModelWrapper.get(); +} + +uno::Reference< accessibility::XAccessible > ChartController::CreateAccessible() +{ + uno::Reference< accessibility::XAccessible > xResult( + m_xCC->getServiceManager()->createInstanceWithContext( + CHART2_ACCESSIBLE_SERVICE_NAME, m_xCC ), uno::UNO_QUERY ); + + impl_initializeAccessible( uno::Reference< lang::XInitialization >( xResult, uno::UNO_QUERY ) ); + return xResult; +} + +void ChartController::impl_invalidateAccessible() +{ + if( m_pChartWindow ) + { + Reference< lang::XInitialization > xInit( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ); + if(xInit.is()) + { + uno::Sequence< uno::Any > aArguments(3);//empty arguments -> invalid accessible + xInit->initialize(aArguments); + } + } +} +void ChartController::impl_initializeAccessible() +{ + if( m_pChartWindow ) + this->impl_initializeAccessible( Reference< lang::XInitialization >( m_pChartWindow->GetAccessible(false), uno::UNO_QUERY ) ); +} +void ChartController::impl_initializeAccessible( const uno::Reference< lang::XInitialization >& xInit ) +{ + if(xInit.is()) + { + uno::Sequence< uno::Any > aArguments(5); + uno::Reference<view::XSelectionSupplier> xSelectionSupplier(this); + aArguments[0]=uno::makeAny(xSelectionSupplier); + uno::Reference<frame::XModel> xModel(m_aModel->getModel()); + aArguments[1]=uno::makeAny(xModel); + aArguments[2]=uno::makeAny(m_xChartView); + uno::Reference< accessibility::XAccessible > xParent; + if( m_pChartWindow ) + { + Window* pParentWin( m_pChartWindow->GetAccessibleParentWindow()); + if( pParentWin ) + xParent.set( pParentWin->GetAccessible()); + } + aArguments[3]=uno::makeAny(xParent); + aArguments[4]=uno::makeAny(m_xViewWindow); + + xInit->initialize(aArguments); + } +} + +::std::set< ::rtl::OUString > ChartController::impl_getAvailableCommands() +{ + return ::comphelper::MakeSet< ::rtl::OUString > + // commands for container forward + ( C2U("AddDirect")) ( C2U("NewDoc")) ( C2U("Open")) + ( C2U("Save")) ( C2U("SaveAs")) ( C2U("SendMail")) + ( C2U("EditDoc")) ( C2U("ExportDirectToPDF")) ( C2U("PrintDefault")) + + // own commands + ( C2U("Cut") ) ( C2U("Copy") ) ( C2U("Paste") ) + ( C2U("DataRanges") ) ( C2U("DiagramData") ) + // insert objects + ( C2U("InsertMenuTitles") ) ( C2U("InsertTitles") ) + ( C2U("InsertMenuLegend") ) ( C2U("InsertLegend") ) ( C2U("DeleteLegend") ) + ( C2U("InsertMenuDataLabels") ) + ( C2U("InsertMenuAxes") ) ( C2U("InsertRemoveAxes") ) ( C2U("InsertMenuGrids") ) + ( C2U("InsertSymbol") ) + ( C2U("InsertTrendlineEquation") ) ( C2U("InsertTrendlineEquationAndR2") ) + ( C2U("InsertR2Value") ) ( C2U("DeleteR2Value") ) + ( C2U("InsertMenuTrendlines") ) ( C2U("InsertTrendline") ) + ( C2U("InsertMenuMeanValues") ) ( C2U("InsertMeanValue") ) + ( C2U("InsertMenuYErrorBars") ) ( C2U("InsertYErrorBars") ) + ( C2U("InsertDataLabels") ) ( C2U("InsertDataLabel") ) + ( C2U("DeleteTrendline") ) ( C2U("DeleteMeanValue") ) ( C2U("DeleteTrendlineEquation") ) + ( C2U("DeleteYErrorBars") ) + ( C2U("DeleteDataLabels") ) ( C2U("DeleteDataLabel") ) + //format objects +//MENUCHANGE ( C2U("SelectSourceRanges") ) + ( C2U("FormatSelection") ) ( C2U("TransformDialog") ) + ( C2U("DiagramType") ) ( C2U("View3D") ) + ( C2U("Forward") ) ( C2U("Backward") ) + ( C2U("MainTitle") ) ( C2U("SubTitle") ) + ( C2U("XTitle") ) ( C2U("YTitle") ) ( C2U("ZTitle") ) + ( C2U("SecondaryXTitle") ) ( C2U("SecondaryYTitle") ) + ( C2U("AllTitles") ) ( C2U("Legend") ) + ( C2U("DiagramAxisX") ) ( C2U("DiagramAxisY") ) ( C2U("DiagramAxisZ") ) + ( C2U("DiagramAxisA") ) ( C2U("DiagramAxisB") ) ( C2U("DiagramAxisAll") ) + ( C2U("DiagramGridXMain") ) ( C2U("DiagramGridYMain") ) ( C2U("DiagramGridZMain") ) + ( C2U("DiagramGridXHelp") ) ( C2U("DiagramGridYHelp") ) ( C2U("DiagramGridZHelp") ) + ( C2U("DiagramGridAll") ) + ( C2U("DiagramWall") ) ( C2U("DiagramFloor") ) ( C2U("DiagramArea") ) + + //context menu - format objects entries + ( C2U("FormatWall") ) ( C2U("FormatFloor") ) ( C2U("FormatChartArea") ) + ( C2U("FormatLegend") ) + + ( C2U("FormatAxis") ) ( C2U("FormatTitle") ) + ( C2U("FormatDataSeries") ) ( C2U("FormatDataPoint") ) + ( C2U("ResetAllDataPoints") ) ( C2U("ResetDataPoint") ) + ( C2U("FormatDataLabels") ) ( C2U("FormatDataLabel") ) + ( C2U("FormatMeanValue") ) ( C2U("FormatTrendline") ) ( C2U("FormatTrendlineEquation") ) + ( C2U("FormatYErrorBars") ) + ( C2U("FormatStockLoss") ) ( C2U("FormatStockGain") ) + + ( C2U("FormatMajorGrid") ) ( C2U("InsertMajorGrid") ) ( C2U("DeleteMajorGrid") ) + ( C2U("FormatMinorGrid") ) ( C2U("InsertMinorGrid") ) ( C2U("DeleteMinorGrid") ) + ( C2U("InsertAxis") ) ( C2U("DeleteAxis") ) ( C2U("InsertAxisTitle") ) + + // toolbar commands + ( C2U("ToggleGridHorizontal"))( C2U("ToggleLegend") ) ( C2U("ScaleText") ) + ( C2U("NewArrangement") ) ( C2U("Update") ) + ( C2U("DefaultColors") ) ( C2U("BarWidth") ) ( C2U("NumberOfLines") ) + ( C2U("ArrangeRow") ) + ( C2U("StatusBarVisible") ) + ( C2U("ChartElementSelector") ) + ; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartController.hxx b/chart2/source/controller/main/ChartController.hxx new file mode 100644 index 000000000000..edf94fb7aae8 --- /dev/null +++ b/chart2/source/controller/main/ChartController.hxx @@ -0,0 +1,717 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController.hxx,v $ + * $Revision: 1.12.44.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART_CONTROLLER_HXX +#define _CHART_CONTROLLER_HXX + +#include "LifeTime.hxx" +#include "ServiceMacros.hxx" +#include "CommandDispatchContainer.hxx" +#include "SelectionHelper.hxx" + +// header for enum SdrDragMode +#include <svx/svdtypes.hxx> +// header for class Timer +#include <vcl/timer.hxx> +// header for class MouseEvent +#include <vcl/event.hxx> + +#include <cppuhelper/implbase12.hxx> + +#include <com/sun/star/accessibility/XAccessible.hpp> +#include <com/sun/star/chart2/XUndoManager.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/frame/XDispatchProvider.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/ui/XContextMenuInterception.hpp> +#include <com/sun/star/uno/XWeak.hpp> +#include <com/sun/star/util/XCloseListener.hpp> +#include <com/sun/star/util/XCloseable.hpp> +#include <com/sun/star/lang/XInitialization.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/util/XModeChangeListener.hpp> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/frame/XLayoutManagerListener.hpp> +#include <com/sun/star/frame/XLayoutManagerEventBroadcaster.hpp> + +#include <memory> +#include <boost/shared_ptr.hpp> +#include <set> + + +class SdrModel; + +namespace svt +{ + class AcceleratorExecute; +} + +class DropTargetHelper; + +namespace com { namespace sun { namespace star { +namespace graphic { + class XGraphic; +} +}}} + + +//............................................................................. +namespace chart +{ +//............................................................................. + +class WindowController +{ +public: + virtual ~WindowController() {}; + + virtual void PrePaint()=0; + virtual void execute_Paint( const Rectangle& rRect )=0; + virtual void execute_MouseButtonDown( const MouseEvent& rMEvt )=0; + virtual void execute_MouseMove( const MouseEvent& rMEvt )=0; + virtual void execute_Tracking( const TrackingEvent& rTEvt )=0; + virtual void execute_MouseButtonUp( const MouseEvent& rMEvt )=0; + virtual void execute_Resize()=0; + virtual void execute_Activate()=0; + virtual void execute_Deactivate()=0; + virtual void execute_GetFocus()=0; + virtual void execute_LoseFocus()=0; + virtual void execute_Command( const CommandEvent& rCEvt )=0; + virtual bool execute_KeyInput( const KeyEvent& rKEvt )=0; + + /** get help text to be shown in a quick help + + @param aAtLogicPosition the position in logic coordinates (of the + window) of the mouse cursor to determine for + which object help is requested. + + @param bIsBalloonHelp determines whether to return the long text version + (balloon help) or the shorter one (quick help). + + @param rOutQuickHelpText is filled with the quick help text + + @param rOutEqualRect is filled with a rectangle that denotes the region + in which the quick help does not change. + + @return </TRUE>, if a quick help should be shown. + */ + virtual bool requestQuickHelp( + ::Point aAtLogicPosition, bool bIsBalloonHelp, + ::rtl::OUString & rOutQuickHelpText, ::com::sun::star::awt::Rectangle & rOutEqualRect ) = 0; + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() = 0; +}; + +class ChartWindow; +class DrawModelWrapper; +class DrawViewWrapper; +class ViewElementListProvider; +class ReferenceSizeProvider; + +class ChartController : public ::cppu::WeakImplHelper12 < + ::com::sun::star::frame::XController //comprehends XComponent (required interface) + ,::com::sun::star::frame::XDispatchProvider //(required interface) + ,::com::sun::star::view::XSelectionSupplier //(optional interface) + ,::com::sun::star::ui::XContextMenuInterception //(optional interface) + ,::com::sun::star::util::XCloseListener //(needed for communication with XModel) + ,::com::sun::star::lang::XServiceInfo + // ,public ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface) + // ,public ::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface) + // ,public ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper + ,::com::sun::star::frame::XDispatch + ,::com::sun::star::awt::XWindow //this is the Window Controller part of this Controller, that will be given to a Frame via setComponent + ,::com::sun::star::lang::XMultiServiceFactory + ,::com::sun::star::util::XModifyListener + ,::com::sun::star::util::XModeChangeListener + ,::com::sun::star::frame::XLayoutManagerListener + > + , public WindowController +{ +public: + //no default constructor + ChartController(::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > const & xContext); + virtual ~ChartController(); + + //----------------------------------------------------------------- + // ::com::sun::star::lang::XServiceInfo + //----------------------------------------------------------------- + + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(ChartController) + + //----------------------------------------------------------------- + // ::com::sun::star::frame::XController (required interface) + //----------------------------------------------------------------- + virtual void SAL_CALL + attachFrame( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XFrame > & xFrame ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL + attachModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > SAL_CALL + getFrame() throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > SAL_CALL + getModel() throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Any SAL_CALL + getViewData() throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + restoreViewData( const ::com::sun::star::uno::Any& rValue ) + throw (::com::sun::star::uno::RuntimeException); + + virtual sal_Bool SAL_CALL + suspend( sal_Bool bSuspend ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::lang::XComponent (base of XController) + //----------------------------------------------------------------- + virtual void SAL_CALL + dispose() throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeEventListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::lang::XEventListener > & xListener ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::frame::XDispatchProvider (required interface) + //----------------------------------------------------------------- + virtual ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch> SAL_CALL + queryDispatch( const ::com::sun::star::util::URL& rURL + , const rtl::OUString& rTargetFrameName + , sal_Int32 nSearchFlags) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > > SAL_CALL + queryDispatches( const ::com::sun::star::uno::Sequence< + ::com::sun::star::frame::DispatchDescriptor > & xDescripts) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::view::XSelectionSupplier (optional interface) + //----------------------------------------------------------------- + virtual sal_Bool SAL_CALL + select( const ::com::sun::star::uno::Any& rSelection ) + throw ( com::sun::star::lang::IllegalArgumentException ); + + virtual ::com::sun::star::uno::Any SAL_CALL + getSelection() throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addSelectionChangeListener( const ::com::sun::star::uno::Reference< + com::sun::star::view::XSelectionChangeListener > & xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeSelectionChangeListener( const ::com::sun::star::uno::Reference< + com::sun::star::view::XSelectionChangeListener > & xListener ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::ui::XContextMenuInterception (optional interface) + //----------------------------------------------------------------- + virtual void SAL_CALL + registerContextMenuInterceptor( const ::com::sun::star::uno::Reference< + ::com::sun::star::ui::XContextMenuInterceptor > & xInterceptor) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + releaseContextMenuInterceptor( const ::com::sun::star::uno::Reference< + ::com::sun::star::ui::XContextMenuInterceptor > & xInterceptor) + throw (::com::sun::star::uno::RuntimeException); + + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //additional interfaces + + //----------------------------------------------------------------- + // ::com::sun::star::util::XCloseListener + //----------------------------------------------------------------- + virtual void SAL_CALL + queryClosing( const ::com::sun::star::lang::EventObject& Source + , sal_Bool GetsOwnership ) + throw (::com::sun::star::util::CloseVetoException + , ::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + notifyClosing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + //------------------------------------------------------------------------------------- + // ::com::sun::star::util::XEventListener (base of XCloseListener and XModifyListener) + //------------------------------------------------------------------------------------- + virtual void SAL_CALL + disposing( const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::frame::XDispatch + //----------------------------------------------------------------- + + virtual void SAL_CALL + dispatch( const ::com::sun::star::util::URL& aURL + , const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& aArgs ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addStatusListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XStatusListener >& xControl + , const ::com::sun::star::util::URL& aURL ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeStatusListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XStatusListener >& xControl + , const ::com::sun::star::util::URL& aURL ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::awt::XWindow + //----------------------------------------------------------------- + virtual void SAL_CALL + setPosSize( sal_Int32 X, sal_Int32 Y + , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) + throw (::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::awt::Rectangle SAL_CALL + getPosSize() + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + setVisible( sal_Bool Visible ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + setEnable( sal_Bool Enable ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + setFocus() throw (::com::sun::star::uno::RuntimeException); + + //---------------- + virtual void SAL_CALL + addWindowListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XWindowListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeWindowListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XWindowListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addFocusListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XFocusListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeFocusListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XFocusListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addKeyListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XKeyListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeKeyListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XKeyListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addMouseListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XMouseListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeMouseListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XMouseListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addMouseMotionListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XMouseMotionListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removeMouseMotionListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XMouseMotionListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + addPaintListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XPaintListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + removePaintListener( const ::com::sun::star::uno::Reference< + ::com::sun::star::awt::XPaintListener >& xListener ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::lang XMultiServiceFactory + //----------------------------------------------------------------- + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + createInstance( const ::rtl::OUString& aServiceSpecifier ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > SAL_CALL + createInstanceWithArguments( const ::rtl::OUString& ServiceSpecifier, + const ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Any >& Arguments ) + throw (::com::sun::star::uno::Exception, + ::com::sun::star::uno::RuntimeException); + virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL + getAvailableServiceNames() + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::util::XModifyListener + //----------------------------------------------------------------- + virtual void SAL_CALL modified( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::util::XModeChangeListener + //----------------------------------------------------------------- + virtual void SAL_CALL modeChanged( + const ::com::sun::star::util::ModeChangeEvent& _rSource ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // ::com::sun::star::frame::XLayoutManagerListener + //----------------------------------------------------------------- + virtual void SAL_CALL layoutEvent( + const ::com::sun::star::lang::EventObject& aSource, + ::sal_Int16 eLayoutEvent, + const ::com::sun::star::uno::Any& aInfo ) + throw (::com::sun::star::uno::RuntimeException); + + //----------------------------------------------------------------- + // chart2::WindowController + //----------------------------------------------------------------- + virtual void PrePaint(); + virtual void execute_Paint( const Rectangle& rRect ); + virtual void execute_MouseButtonDown( const MouseEvent& rMEvt ); + virtual void execute_MouseMove( const MouseEvent& rMEvt ); + virtual void execute_Tracking( const TrackingEvent& rTEvt ); + virtual void execute_MouseButtonUp( const MouseEvent& rMEvt ); + virtual void execute_Resize(); + virtual void execute_Activate(); + virtual void execute_Deactivate(); + virtual void execute_GetFocus(); + virtual void execute_LoseFocus(); + virtual void execute_Command( const CommandEvent& rCEvt ); + virtual bool execute_KeyInput( const KeyEvent& rKEvt ); + + virtual bool requestQuickHelp( + ::Point aAtLogicPosition, bool bIsBalloonHelp, + ::rtl::OUString & rOutQuickHelpText, ::com::sun::star::awt::Rectangle & rOutEqualRect ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + + //----------------------------------------------------------------- + //----------------------------------------------------------------- + + static bool isObjectDeleteable( const ::com::sun::star::uno::Any& rSelection ); + +public: + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //private + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //----------------------------------------------------------------- + //----------------------------------------------------------------- + + +private: + DrawModelWrapper* GetDrawModelWrapper(); + +private: + class TheModelRef; + friend class ChartController::TheModelRef; + class RefCountable + { + public: + RefCountable(); + virtual ~RefCountable(); + void acquire(); + void release(); + private: + sal_Int32 volatile m_nRefCount; + }; + class TheModel : public RefCountable + { + public: + TheModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + + virtual ~TheModel(); + + void SetOwnerShip( sal_Bool bGetsOwnership ); + void addListener( ChartController* pController ); + void removeListener( ChartController* pController ); + void tryTermination(); + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > + getModel() { return m_xModel;} + + private: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XCloseable > m_xCloseable; + + //the ownership between model and controller is not clear at first + //each controller might consider himself as owner of the model first + sal_Bool volatile m_bOwnership; + //with a XCloseable::close call and during XCloseListener::queryClosing + //the ownership can be regulated more explicit, + //if so the ownership is considered to be well known + sal_Bool volatile m_bOwnershipIsWellKnown; + }; + class TheModelRef + { + public: + TheModelRef( TheModel* pTheModel, ::osl::Mutex& rMutex ); + TheModelRef( const TheModelRef& rTheModel, ::osl::Mutex& rMutex ); + TheModelRef& operator=(ChartController::TheModel* pTheModel); + TheModelRef& operator=(const TheModelRef& rTheModel); + virtual ~TheModelRef(); + sal_Bool is() const; + TheModel* operator->() const { return m_pTheModel; } + private: + TheModel* m_pTheModel; + mutable ::osl::Mutex& m_rModelMutex; + }; + +private: + mutable ::apphelper::LifeTimeManager m_aLifeTimeManager; + + mutable ::osl::Mutex m_aControllerMutex; + sal_Bool volatile m_bSuspended; + sal_Bool volatile m_bCanClose; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; + + //model + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; + mutable ::osl::Mutex m_aModelMutex; + TheModelRef m_aModel; + + //view + ChartWindow* m_pChartWindow; + ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xViewWindow; + ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > m_xChartView; + ::boost::shared_ptr< DrawModelWrapper > m_pDrawModelWrapper; + DrawViewWrapper* m_pDrawViewWrapper; + + Selection m_aSelection; + SdrDragMode m_eDragMode; + + Timer m_aDoubleClickTimer; + bool volatile m_bWaitingForDoubleClick; + bool volatile m_bWaitingForMouseUp; + + bool volatile m_bConnectingToView; + + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + /// needed for dispatching URLs in FeatureStateEvents + mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; + + ::std::auto_ptr< ::svt::AcceleratorExecute > m_apAccelExecute; + + CommandDispatchContainer m_aDispatchContainer; + + ::std::auto_ptr< DropTargetHelper > m_apDropTargetHelper; + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XLayoutManagerEventBroadcaster > + m_xLayoutManagerEventBroadcaster; + +private: + //private methods + + sal_Bool impl_isDisposedOrSuspended() const; + ::std::auto_ptr< ReferenceSizeProvider > impl_createReferenceSizeProvider() const; + void impl_adaptDataSeriesAutoResize(); + + void impl_createDrawViewController(); + void impl_deleteDrawViewController(); + + //executeDispatch methods + void SAL_CALL executeDispatch_ObjectProperties(); + void SAL_CALL executeDispatch_FormatObject( const ::rtl::OUString& rDispatchCommand ); + void SAL_CALL executeDlg_ObjectProperties( const ::rtl::OUString& rObjectCID ); + bool executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ); + + void SAL_CALL executeDispatch_ChartType(); + + void executeDispatch_InsertTitles(); + void executeDispatch_InsertLegend(); + void executeDispatch_DeleteLegend(); + void executeDispatch_OpenLegendDialog(); + void executeDispatch_InsertAxes(); + void executeDispatch_InsertGrid(); + + void executeDispatch_InsertMenu_DataLabels(); + void executeDispatch_InsertMenu_YErrorBars(); + void executeDispatch_InsertMenu_Trendlines(); + void executeDispatch_InsertMenu_MeanValues(); + + void executeDispatch_InsertMeanValue(); + void executeDispatch_InsertTrendline(); + void executeDispatch_InsertTrendlineEquation( bool bInsertR2=false ); + void executeDispatch_InsertYErrorBars(); + + void executeDispatch_InsertR2Value(); + void executeDispatch_DeleteR2Value(); + + void executeDispatch_DeleteMeanValue(); + void executeDispatch_DeleteTrendline(); + void executeDispatch_DeleteTrendlineEquation(); + void executeDispatch_DeleteYErrorBars(); + + void executeDispatch_InsertDataLabels(); + void executeDispatch_InsertDataLabel(); + void executeDispatch_DeleteDataLabels(); + void executeDispatch_DeleteDataLabel(); + + void executeDispatch_ResetAllDataPoints(); + void executeDispatch_ResetDataPoint(); + + void executeDispatch_InsertAxis(); + void executeDispatch_InsertAxisTitle(); + void executeDispatch_InsertMajorGrid(); + void executeDispatch_InsertMinorGrid(); + void executeDispatch_DeleteAxis(); + void executeDispatch_DeleteMajorGrid(); + void executeDispatch_DeleteMinorGrid(); + + void SAL_CALL executeDispatch_InsertSpecialCharacter(); + void SAL_CALL executeDispatch_EditText(); + void SAL_CALL executeDispatch_SourceData(); + void SAL_CALL executeDispatch_MoveSeries( sal_Bool bForward ); + + void StartTextEdit(); + bool EndTextEdit(); + + void SAL_CALL executeDispatch_View3D(); + void SAL_CALL executeDispatch_PositionAndSize(); + + void executeDispatch_EditData(); + + void executeDispatch_NewArrangement(); + void executeDispatch_ScaleText(); + + void executeDispatch_Paste(); + void executeDispatch_Copy(); + void executeDispatch_Cut(); + bool executeDispatch_Delete(); + void executeDispatch_ToggleLegend(); + void executeDispatch_ToggleGridHorizontal(); + + // + DECL_LINK( DoubleClickWaitingHdl, void* ); + void execute_DoubleClick(); + void startDoubleClickWaiting(); + void stopDoubleClickWaiting(); + + void impl_selectObjectAndNotiy(); + void impl_notifySelectionChangeListeners(); + void impl_invalidateAccessible(); + void impl_initializeAccessible(); + void impl_initializeAccessible( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XInitialization >& xInit ); + + //sets the model member to null if it equals the parameter + //returns true if successful + bool impl_releaseThisModel( const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XInterface > & xModel ); + + enum eMoveOrResizeType + { + MOVE_OBJECT, + CENTERED_RESIZE_OBJECT + }; + /// @return </TRUE>, if resize/move was successful + bool impl_moveOrResizeObject( + const ::rtl::OUString & rCID, eMoveOrResizeType eType, double fAmountLogicX, double fAmountLogicY ); + bool impl_DragDataPoint( const ::rtl::OUString & rCID, double fOffset ); + + ::std::set< ::rtl::OUString > impl_getAvailableCommands(); + + /** Creates a helper accesibility 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. + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::accessibility::XAccessibleContext > + impl_createAccessibleTextContext(); + + void impl_PasteGraphic( ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > & xGraphic, + const ::Point & aPosition ); + void impl_SetMousePointer( const MouseEvent & rEvent ); + + void impl_ClearSelection(); +}; + +//............................................................................. +} // namespace chart +//............................................................................. + +#endif + diff --git a/chart2/source/controller/main/ChartController_EditData.cxx b/chart2/source/controller/main/ChartController_EditData.cxx new file mode 100644 index 000000000000..976276660e8a --- /dev/null +++ b/chart2/source/controller/main/ChartController_EditData.cxx @@ -0,0 +1,83 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_EditData.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" +#include "macros.hxx" + +#include "dlg_DataEditor.hxx" +#include "DataSourceHelper.hxx" +#include "DiagramHelper.hxx" +#include "ControllerLockGuard.hxx" +#include "UndoGuard.hxx" +#include "ResId.hxx" +#include "Strings.hrc" + +// for RET_OK +#include <vcl/msgbox.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <com/sun/star/chart2/XChartDocument.hpp> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + +namespace chart +{ + +void ChartController::executeDispatch_EditData() +{ + Reference< chart2::XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); + if( xChartDoc.is()) + { + Window* pParent( NULL ); + + Reference< ::com::sun::star::chart2::data::XDataProvider > xDataProvider( xChartDoc->getDataProvider()); + + { + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + // using assignment for broken gcc 3.3 + UndoLiveUpdateGuardWithData aUndoGuard = UndoLiveUpdateGuardWithData( + ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_CHART_DATA ))), + m_xUndoManager, m_aModel->getModel()); + DataEditor aDataEditorDialog( pParent, xChartDoc, m_xCC ); + // the dialog has no OK/Cancel + aDataEditorDialog.Execute(); + aUndoGuard.commitAction(); + // \-- + } + } +} + +} // namespace chart diff --git a/chart2/source/controller/main/ChartController_Insert.cxx b/chart2/source/controller/main/ChartController_Insert.cxx new file mode 100644 index 000000000000..45213a4473dc --- /dev/null +++ b/chart2/source/controller/main/ChartController_Insert.cxx @@ -0,0 +1,949 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_Insert.cxx,v $ + * $Revision: 1.16.44.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" + +#include "dlg_InsertAxis_Grid.hxx" +#include "dlg_InsertDataLabel.hxx" +#include "dlg_InsertLegend.hxx" +#include "dlg_InsertTrendline.hxx" +#include "dlg_InsertErrorBars.hxx" +#include "dlg_InsertTitle.hxx" +#include "dlg_ObjectProperties.hxx" + +#include "ChartWindow.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" +#include "TitleHelper.hxx" +#include "DiagramHelper.hxx" +#include "macros.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "chartview/NumberFormatterWrapper.hxx" +#include "ViewElementListProvider.hxx" +#include "MultipleChartConverters.hxx" +#include "ControllerLockGuard.hxx" +#include "UndoGuard.hxx" +#include "ResId.hxx" +#include "Strings.hrc" +#include "ReferenceSizeProvider.hxx" +#include "ObjectIdentifier.hxx" +#include "RegressionCurveHelper.hxx" +#include "RegressionCurveItemConverter.hxx" +#include "StatisticsHelper.hxx" +#include "ErrorBarItemConverter.hxx" +#include "MultipleItemConverter.hxx" +#include "DataSeriesHelper.hxx" +#include "ObjectNameProvider.hxx" +#include "LegendHelper.hxx" + +#include <com/sun/star/chart2/XRegressionCurve.hpp> +#include <com/sun/star/chart/ErrorBarStyle.hpp> +#include <svx/ActionDescriptionProvider.hxx> + +//-------------------------------------- + +// header for define RET_OK +#include <vcl/msgbox.hxx> +// header for class OUStringBuffer +#include <rtl/ustrbuf.hxx> +// header for class Application +#include <vcl/svapp.hxx> +// header for class ::vos::OGuard +#include <vos/mutex.hxx> + + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +//............................................................................. + +namespace +{ +struct lcl_InsertMeanValueLine +{ +public: + lcl_InsertMeanValueLine( const uno::Reference< uno::XComponentContext > & xContext ) : + m_xContext( xContext ) + {} + + void operator()( const uno::Reference< chart2::XDataSeries > & xSeries ) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + xSeries, uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + ::chart::RegressionCurveHelper::addMeanValueLine( + xRegCurveCnt, m_xContext, uno::Reference< beans::XPropertySet >( xSeries, uno::UNO_QUERY )); + } + } + +private: + uno::Reference< uno::XComponentContext > m_xContext; +}; + +} // anonymous namespace + +//............................................................................. +namespace chart +{ +//............................................................................. + +void ChartController::executeDispatch_InsertAxes() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXES )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + InsertAxisOrGridDialogData aDialogInput; + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(m_aModel->getModel()); + AxisHelper::getAxisOrGridExcistence( aDialogInput.aExistenceList, xDiagram, sal_True ); + AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, sal_True ); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchAxisDlg aDlg( m_pChartWindow, aDialogInput ); + if( aDlg.Execute() == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + + InsertAxisOrGridDialogData aDialogOutput; + aDlg.getResult( aDialogOutput ); + ::std::auto_ptr< ReferenceSizeProvider > mpRefSizeProvider( + impl_createReferenceSizeProvider()); + bool bChanged = AxisHelper::changeVisibilityOfAxes( xDiagram + , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC + , mpRefSizeProvider.get() ); + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRIDS )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + InsertAxisOrGridDialogData aDialogInput; + uno::Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram(m_aModel->getModel()); + AxisHelper::getAxisOrGridExcistence( aDialogInput.aExistenceList, xDiagram, sal_False ); + AxisHelper::getAxisOrGridPossibilities( aDialogInput.aPossibilityList, xDiagram, sal_False ); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchGridDlg aDlg( m_pChartWindow, aDialogInput );//aItemSet, b3D, bNet, bSecondaryX, bSecondaryY ); + if( aDlg.Execute() == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + InsertAxisOrGridDialogData aDialogOutput; + aDlg.getResult( aDialogOutput ); + bool bChanged = AxisHelper::changeVisibilityOfGrids( xDiagram + , aDialogInput.aExistenceList, aDialogOutput.aExistenceList, m_xCC ); + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void ChartController::executeDispatch_InsertTitles() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLES )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + TitleDialogData aDialogInput; + aDialogInput.readFromModel( m_aModel->getModel() ); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchTitleDlg aDlg( m_pChartWindow, aDialogInput ); + if( aDlg.Execute() == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + TitleDialogData aDialogOutput( impl_createReferenceSizeProvider()); + aDlg.getResult( aDialogOutput ); + bool bChanged = aDialogOutput.writeDifferenceToModel( m_aModel->getModel(), m_xCC, &aDialogInput ); + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteLegend() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + + LegendHelper::hideLegend( m_aModel->getModel() ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertLegend() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + + Reference< chart2::XLegend > xLegend = LegendHelper::showLegend( m_aModel->getModel(), m_xCC ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_OpenLegendDialog() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + //prepare and open dialog + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchLegendDlg aDlg( m_pChartWindow, m_xCC ); + aDlg.init( m_aModel->getModel() ); + if( aDlg.Execute() == RET_OK ) + { + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel() ); + bool bChanged = aDlg.writeToModel( m_aModel->getModel() ); + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void ChartController::executeDispatch_InsertMenu_DataLabels() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel() ); + + //if a series is selected insert labels for that series only: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + // add labels + DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + + rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + rtl::OUString aObjectCID = ObjectIdentifier::createClassifiedIdentifierForParticles( + ObjectIdentifier::getSeriesParticleFromCID(m_aSelection.getSelectedCID()), aChildParticle ); + + bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, true ); + if( bSuccess ) + aUndoGuard.commitAction(); + return; + } + + try + { + wrapper::AllDataLabelItemConverter aItemConverter( + m_aModel->getModel(), + m_pDrawModelWrapper->GetItemPool(), + m_pDrawModelWrapper->getSdrModel(), + uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY )); + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + + //prepare and open dialog + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + //get number formatter + uno::Reference< util::XNumberFormatsSupplier > xNumberFormatsSupplier( m_aModel->getModel(), uno::UNO_QUERY ); + NumberFormatterWrapper aNumberFormatterWrapper( xNumberFormatsSupplier ); + SvNumberFormatter* pNumberFormatter = aNumberFormatterWrapper.getSvNumberFormatter(); + + DataLabelsDialog aDlg( m_pChartWindow, aItemSet, pNumberFormatter); + + if( aDlg.Execute() == RET_OK ) + { + SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); + aDlg.FillItemSet( aOutItemSet ); + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMenu_YErrorBars() +{ + //if a series is selected insert error bars for that series only: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is()) + { + executeDispatch_InsertYErrorBars(); + return; + } + + //if no series is selected insert error bars for all series + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_ERRORS ) ), + m_xUndoManager, m_aModel->getModel() ); + + try + { + wrapper::AllSeriesStatisticsConverter aItemConverter( + m_aModel->getModel(), m_pDrawModelWrapper->GetItemPool() ); + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + + //prepare and open dialog + ::vos::OGuard aGuard( Application::GetSolarMutex()); + InsertErrorBarsDialog aDlg( + m_pChartWindow, aItemSet, + uno::Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY )); + aDlg.SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, rtl::OUString() ) ); + + if( aDlg.Execute() == RET_OK ) + { + SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); + aDlg.FillItemSet( aOutItemSet ); + + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMeanValue() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), + m_xUndoManager, m_aModel->getModel()); + lcl_InsertMeanValueLine( m_xCC ).operator()( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel())); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertMenu_MeanValues() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), + m_xUndoManager, m_aModel->getModel() ); + + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + //if a series is selected insert mean value only for that series: + lcl_InsertMeanValueLine( m_xCC ).operator()(xSeries); + } + else + { + ::std::vector< uno::Reference< chart2::XDataSeries > > aSeries( + DiagramHelper::getDataSeriesFromDiagram( ChartModelHelper::findDiagram( m_aModel->getModel()))); + ::std::for_each( aSeries.begin(), aSeries.end(), lcl_InsertMeanValueLine( m_xCC )); + } + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertMenu_Trendlines() +{ + //if a series is selected insert only for that series: + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is()) + { + executeDispatch_InsertTrendline(); + return; + } + + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ObjectNameProvider::getName_ObjectForAllSeries( OBJECTTYPE_DATA_CURVE ) ), + m_xUndoManager, m_aModel->getModel() ); + + try + { + wrapper::AllSeriesStatisticsConverter aItemConverter( + m_aModel->getModel(), m_pDrawModelWrapper->GetItemPool() ); + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + + //prepare and open dialog + ::vos::OGuard aGuard( Application::GetSolarMutex()); + InsertTrendlineDialog aDlg( m_pChartWindow, aItemSet ); + aDlg.adjustSize(); + + if( aDlg.Execute() == RET_OK ) + { + SfxItemSet aOutItemSet = aItemConverter.CreateEmptyItemSet(); + aDlg.FillItemSet( aOutItemSet ); + + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + bool bChanged = aItemConverter.ApplyItemSet( aOutItemSet );//model should be changed now + if( bChanged ) + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertTrendline() +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + UndoLiveUpdateGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), + m_xUndoManager, m_aModel->getModel() ); + + // add a linear curve + RegressionCurveHelper::addRegressionCurve( + RegressionCurveHelper::REGRESSION_TYPE_LINEAR, xRegCurveCnt, m_xCC ); + + // get an appropriate item converter + uno::Reference< chart2::XRegressionCurve > xCurve( + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt )); + uno::Reference< beans::XPropertySet > xCurveProp( xCurve, uno::UNO_QUERY ); + if( !xCurveProp.is()) + return; + wrapper::RegressionCurveItemConverter aItemConverter( + xCurveProp, xRegCurveCnt, m_pDrawModelWrapper->getSdrModel().GetItemPool(), + m_pDrawModelWrapper->getSdrModel(), + uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY )); + + // open dialog + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( + ObjectIdentifier::createDataCurveCID( + ObjectIdentifier::getSeriesParticleFromCID( m_aSelection.getSelectedCID()), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, xCurve ), false )); + aDialogParameter.init( m_aModel->getModel() ); + ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider, + uno::Reference< util::XNumberFormatsSupplier >( m_aModel->getModel(), uno::UNO_QUERY )); + + // note: when a user pressed "OK" but didn't change any settings in the + // dialog, the SfxTabDialog returns "Cancel" + if( aDlg.Execute() == RET_OK || aDlg.DialogWasClosedWithOK()) + { + const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); + if( pOutItemSet ) + { + ControllerLockGuard aCLGuard( m_aModel->getModel()); + aItemConverter.ApplyItemSet( *pOutItemSet ); + } + aUndoGuard.commitAction(); + } + } +} + +void ChartController::executeDispatch_InsertYErrorBars() +{ + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is()) + { + UndoLiveUpdateGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), + m_xUndoManager, m_aModel->getModel() ); + + // add error bars with standard deviation + uno::Reference< beans::XPropertySet > xErrorBarProp( + StatisticsHelper::addErrorBars( xSeries, m_xCC, ::com::sun::star::chart::ErrorBarStyle::STANDARD_DEVIATION )); + + // get an appropriate item converter + wrapper::ErrorBarItemConverter aItemConverter( + m_aModel->getModel(), xErrorBarProp, m_pDrawModelWrapper->getSdrModel().GetItemPool(), + m_pDrawModelWrapper->getSdrModel(), + uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY )); + + // open dialog + SfxItemSet aItemSet = aItemConverter.CreateEmptyItemSet(); + aItemConverter.FillItemSet( aItemSet ); + ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( + ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), m_aSelection.getSelectedCID())); + aDialogParameter.init( m_aModel->getModel() ); + ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get()); + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider, + uno::Reference< util::XNumberFormatsSupplier >( m_aModel->getModel(), uno::UNO_QUERY )); + aDlg.SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), 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.Execute() == RET_OK || aDlg.DialogWasClosedWithOK()) + { + const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); + if( pOutItemSet ) + { + ControllerLockGuard aCLGuard( m_aModel->getModel()); + aItemConverter.ApplyItemSet( *pOutItemSet ); + } + aUndoGuard.commitAction(); + } + } +} + +void ChartController::executeDispatch_InsertTrendlineEquation( bool bInsertR2 ) +{ + uno::Reference< chart2::XRegressionCurve > xRegCurve( + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( !xRegCurve.is() ) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + xRegCurve.set( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); + } + if( xRegCurve.is()) + { + uno::Reference< beans::XPropertySet > xEqProp( xRegCurve->getEquationProperties()); + if( xEqProp.is()) + { + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel() ); + xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( true )); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( bInsertR2 )); + aUndoGuard.commitAction(); + } + } +} + +void ChartController::executeDispatch_InsertR2Value() +{ + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xEqProp.is()) + { + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel() ); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( true )); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteR2Value() +{ + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xEqProp.is()) + { + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel() ); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteMeanValue() +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), + m_xUndoManager, m_aModel->getModel()); + RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteTrendline() +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), + m_xUndoManager, m_aModel->getModel()); + RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteTrendlineEquation() +{ + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, m_aModel->getModel()); + RegressionCurveHelper::removeEquations( xRegCurveCnt ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteYErrorBars() +{ + uno::Reference< chart2::XDataSeries > xDataSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel())); + if( xDataSeries.is()) + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE )))), + m_xUndoManager, m_aModel->getModel()); + StatisticsHelper::removeErrorBars( xDataSeries ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_InsertDataLabels() +{ + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel() ); + DataSeriesHelper::insertDataLabelsToSeriesAndAllPoints( xSeries ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_InsertDataLabel() +{ + UndoGuard aUndoGuard = UndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::INSERT, + ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), + m_xUndoManager, m_aModel->getModel() ); + DataSeriesHelper::insertDataLabelToPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_DeleteDataLabels() +{ + uno::Reference< chart2::XDataSeries > xSeries( + ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel()); + DataSeriesHelper::deleteDataLabelsFromSeriesAndAllPoints( xSeries ); + aUndoGuard.commitAction(); + } +} + +void ChartController::executeDispatch_DeleteDataLabel() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::DELETE, + ::rtl::OUString( String( SchResId( STR_OBJECT_LABEL )))), + m_xUndoManager, m_aModel->getModel()); + DataSeriesHelper::deleteDataLabelsFromPoint( ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), m_aModel->getModel() ) ); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_ResetAllDataPoints() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINTS )))), + m_xUndoManager, m_aModel->getModel()); + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + xSeries->resetAllDataPoints(); + aUndoGuard.commitAction(); +} +void ChartController::executeDispatch_ResetDataPoint() +{ + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( ActionDescriptionProvider::FORMAT, + ::rtl::OUString( String( SchResId( STR_OBJECT_DATAPOINT )))), + m_xUndoManager, m_aModel->getModel()); + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->getModel()), uno::UNO_QUERY ); + if( xSeries.is() ) + { + sal_Int32 nPointIndex = ObjectIdentifier::getIndexFromParticleOrCID( m_aSelection.getSelectedCID() ); + xSeries->resetDataPoint( nPointIndex ); + } + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_InsertAxisTitle() +{ + try + { + uno::Reference< XTitle > xTitle; + { + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), + m_xUndoManager, m_aModel->getModel() ); + + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + sal_Int32 nDimensionIndex = -1; + sal_Int32 nCooSysIndex = -1; + sal_Int32 nAxisIndex = -1; + AxisHelper::getIndicesForAxis( xAxis, ChartModelHelper::findDiagram(m_aModel->getModel()), nCooSysIndex, nDimensionIndex, nAxisIndex ); + + TitleHelper::eTitleType eTitleType = TitleHelper::X_AXIS_TITLE; + if( nDimensionIndex==0 ) + eTitleType = nAxisIndex==0 ? TitleHelper::X_AXIS_TITLE : TitleHelper::SECONDARY_X_AXIS_TITLE; + else if( nDimensionIndex==1 ) + eTitleType = nAxisIndex==0 ? TitleHelper::Y_AXIS_TITLE : TitleHelper::SECONDARY_Y_AXIS_TITLE; + else + eTitleType = TitleHelper::Z_AXIS_TITLE; + + ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( impl_createReferenceSizeProvider()); + xTitle = TitleHelper::createTitle( eTitleType, ObjectNameProvider::getTitleNameByType(eTitleType), m_aModel->getModel(), m_xCC, apRefSizeProvider.get() ); + aUndoGuard.commitAction(); + } + + /* + if( xTitle.is() ) + { + OUString aTitleCID = ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, m_aModel->getModel() ); + select( uno::makeAny(aTitleCID) ); + executeDispatch_EditText(); + } + */ + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertAxis() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeAxisVisible( xAxis ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteAxis() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AXIS )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeAxisInvisible( xAxis ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMajorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeGridVisible( xAxis->getGridProperties() ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteMajorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + AxisHelper::makeGridInvisible( xAxis->getGridProperties() ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_InsertMinorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::INSERT, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) + AxisHelper::makeGridVisible( aSubGrids[nN] ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +void ChartController::executeDispatch_DeleteMinorGrid() +{ + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_GRID )))), + m_xUndoManager, m_aModel->getModel() ); + + try + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->getModel() ); + if( xAxis.is() ) + { + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() ); + for( sal_Int32 nN=0; nN<aSubGrids.getLength(); nN++) + AxisHelper::makeGridInvisible( aSubGrids[nN] ); + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartController_Position.cxx b/chart2/source/controller/main/ChartController_Position.cxx new file mode 100644 index 000000000000..4cf4de81480b --- /dev/null +++ b/chart2/source/controller/main/ChartController_Position.cxx @@ -0,0 +1,195 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_Position.cxx,v $ + * $Revision: 1.12 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" + +#include "macros.hxx" +#include "ChartWindow.hxx" +#include "DrawViewWrapper.hxx" +#include "PositionAndSizeHelper.hxx" +#include "ChartModelHelper.hxx" +#include "UndoGuard.hxx" +#include "Strings.hrc" +#include "ObjectNameProvider.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "CommonConverters.hxx" +#include <svx/ActionDescriptionProvider.hxx> + +// header for define RET_OK +#include <vcl/msgbox.hxx> +#include <svx/svxids.hrc> +#include <svx/rectenum.hxx> +#include <svtools/aeitem.hxx> +#include <svx/svxdlg.hxx> +#include <svx/dialogs.hrc> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void lcl_getPositionAndSizeFromItemSet( const SfxItemSet& rItemSet, Rectangle& rPosAndSize, const awt::Size aOriginalSize ) +{ + long nPosX(0); + long nPosY(0); + long nSizX(0); + long nSizY(0); + + RECT_POINT eRP = (RECT_POINT)RP_LT; + + const SfxPoolItem* pPoolItem=NULL; + //read position + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_X,TRUE,&pPoolItem)) + nPosX=((const SfxInt32Item*)pPoolItem)->GetValue(); + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_POS_Y,TRUE,&pPoolItem)) + nPosY=((const SfxInt32Item*)pPoolItem)->GetValue(); + //read size + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_WIDTH,TRUE,&pPoolItem)) + nSizX=((const SfxUInt32Item*)pPoolItem)->GetValue(); + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_HEIGHT,TRUE,&pPoolItem)) + nSizY=((const SfxUInt32Item*)pPoolItem)->GetValue(); + if (SFX_ITEM_SET==rItemSet.GetItemState(SID_ATTR_TRANSFORM_SIZE_POINT,TRUE,&pPoolItem)) + eRP=(RECT_POINT)((const SfxAllEnumItem*)pPoolItem)->GetValue(); + + switch( eRP ) + { + case RP_LT: + break; + case RP_MT: + nPosX += ( aOriginalSize.Width - nSizX ) / 2; + break; + case RP_RT: + nPosX += aOriginalSize.Width - nSizX; + break; + case RP_LM: + nPosY += ( aOriginalSize.Height - nSizY ) / 2; + break; + case RP_MM: + nPosX += ( aOriginalSize.Width - nSizX ) / 2; + nPosY += ( aOriginalSize.Height - nSizY ) / 2; + break; + case RP_RM: + nPosX += aOriginalSize.Width - nSizX; + nPosY += ( aOriginalSize.Height - nSizY ) / 2; + break; + case RP_LB: + nPosY += aOriginalSize.Height - nSizY; + break; + case RP_MB: + nPosX += ( aOriginalSize.Width - nSizX ) / 2; + nPosY += aOriginalSize.Height - nSizY; + break; + case RP_RB: + nPosX += aOriginalSize.Width - nSizX; + nPosY += aOriginalSize.Height - nSizY; + break; + default: + break; + } + + rPosAndSize = Rectangle(Point(nPosX,nPosY),Size(nSizX,nSizY)); +} + +void SAL_CALL ChartController::executeDispatch_PositionAndSize() +{ + const ::rtl::OUString aCID( m_aSelection.getSelectedCID() ); + + if( !aCID.getLength() ) + return; + + awt::Size aSelectedSize; + ExplicitValueProvider* pProvider( ExplicitValueProvider::getExplicitValueProvider( m_xChartView ) ); + if( pProvider ) + aSelectedSize = ToSize( ( pProvider->getRectangleOfObject( aCID ) ) ); + + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::POS_SIZE, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aCID ))), + m_xUndoManager, m_aModel->getModel() ); + + SfxAbstractTabDialog * pDlg = NULL; + try + { + SfxItemSet aItemSet = m_pDrawViewWrapper->getPositionAndSizeItemSetFromMarkedObject(); + + //prepare and open dialog + SdrView* pSdrView = m_pDrawViewWrapper; + bool bResizePossible = m_aSelection.isResizeableObjectSelected(); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT( pFact, "No dialog factory" ); + pDlg = pFact->CreateSchTransformTabDialog( + m_pChartWindow, &aItemSet, pSdrView, RID_SCH_TransformTabDLG_SVXPAGE_ANGLE, bResizePossible ); + DBG_ASSERT( pDlg, "Couldn't create SchTransformTabDialog" ); + + + if( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pOutItemSet = pDlg->GetOutputItemSet(); + if(pOutItemSet) + { + Rectangle aObjectRect; + aItemSet.Put(*pOutItemSet);//overwrite old values with new values (-> all items are set) + lcl_getPositionAndSizeFromItemSet( aItemSet, aObjectRect, aSelectedSize ); + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel() ) ); + Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); + + bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() + , m_aModel->getModel() + , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) + , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) + , m_xChartView ); + if( bChanged ) + aUndoGuard.commitAction(); + } + } + delete pDlg; + } + catch( uno::Exception& e) + { + delete pDlg; + ASSERT_EXCEPTION( e ); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartController_Properties.cxx b/chart2/source/controller/main/ChartController_Properties.cxx new file mode 100644 index 000000000000..754e66ec7d17 --- /dev/null +++ b/chart2/source/controller/main/ChartController_Properties.cxx @@ -0,0 +1,863 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_Properties.cxx,v $ + * $Revision: 1.33.44.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" +#include "ChartWindow.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "ObjectIdentifier.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "macros.hxx" +#include "dlg_ObjectProperties.hxx" +#include "dlg_View3D.hxx" +#include "dlg_InsertErrorBars.hxx" +#include "ViewElementListProvider.hxx" +#include "DataPointItemConverter.hxx" +#include "AxisItemConverter.hxx" +#include "MultipleChartConverters.hxx" +#include "TitleItemConverter.hxx" +#include "LegendItemConverter.hxx" +#include "RegressionCurveItemConverter.hxx" +#include "RegressionEquationItemConverter.hxx" +#include "ErrorBarItemConverter.hxx" +#include "ChartModelHelper.hxx" +#include "AxisHelper.hxx" +#include "TitleHelper.hxx" +#include "LegendHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "ColorPerPointHelper.hxx" +#include "DiagramHelper.hxx" +#include "servicenames_charttypes.hxx" +#include "ControllerLockGuard.hxx" +#include "UndoGuard.hxx" +#include "ObjectNameProvider.hxx" +#include "ResId.hxx" +#include "Strings.hrc" +#include "ReferenceSizeProvider.hxx" +#include "RegressionCurveHelper.hxx" +#include <com/sun/star/chart2/XChartDocument.hpp> + +//for auto_ptr +#include <memory> + +// header for define RET_OK +#include <vcl/msgbox.hxx> +// for SolarMutex +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <svx/ActionDescriptionProvider.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +namespace +{ + +::comphelper::ItemConverter* createItemConverter( + const ::rtl::OUString & aObjectCID + , const uno::Reference< frame::XModel > & xChartModel + , const uno::Reference< uno::XComponentContext > & xContext + , SdrModel & rDrawModel + , NumberFormatterWrapper * pNumberFormatterWrapper = NULL + , ExplicitValueProvider * pExplicitValueProvider = NULL + , ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProvider = + ::std::auto_ptr< ReferenceSizeProvider >() + ) +{ + ::comphelper::ItemConverter* pItemConverter=NULL; + + //------------------------------------------------------------- + //get type of selected object + ObjectType eObjectType = ObjectIdentifier::getObjectType( aObjectCID ); + if( OBJECTTYPE_UNKNOWN==eObjectType ) + { + DBG_ERROR("unknown ObjectType"); + return NULL; + } + //-- + rtl::OUString aParticleID = ObjectIdentifier::getParticleID( aObjectCID ); + bool bAffectsMultipleObjects = aParticleID.equals(C2U("ALLELEMENTS")); + //------------------------------------------------------------- + if( !bAffectsMultipleObjects ) + { + uno::Reference< beans::XPropertySet > xObjectProperties = + ObjectIdentifier::getObjectPropertySet( aObjectCID, xChartModel ); + if(!xObjectProperties.is()) + return NULL; + //create itemconverter for a single object + switch(eObjectType) + { + case OBJECTTYPE_PAGE: + pItemConverter = new wrapper::GraphicPropertyItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); + break; + case OBJECTTYPE_TITLE: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + pItemConverter = new wrapper::TitleItemConverter( xObjectProperties, + rDrawModel.GetItemPool(), rDrawModel, + uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + pRefSize ); + } + break; + case OBJECTTYPE_LEGEND: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + pItemConverter = new wrapper::LegendItemConverter( xObjectProperties, + rDrawModel.GetItemPool(), rDrawModel, + uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + 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::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); + break; + case OBJECTTYPE_AXIS: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + uno::Reference< beans::XPropertySet > xDiaProp; + xDiaProp.set( ChartModelHelper::findDiagram( xChartModel ), uno::UNO_QUERY ); + + // the second property set contains the property CoordinateOrigin + // nOriginIndex is the index of the corresponding index of the + // origin (x=0, y=1, z=2) + + ExplicitScaleData aExplicitScale; + ExplicitIncrementData aExplicitIncrement; + if( pExplicitValueProvider ) + pExplicitValueProvider->getExplicitValuesForAxis( + uno::Reference< XAxis >( xObjectProperties, uno::UNO_QUERY ), + aExplicitScale, aExplicitIncrement ); + + pItemConverter = new wrapper::AxisItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, + uno::Reference< chart2::XChartDocument >( xChartModel, uno::UNO_QUERY ), + &aExplicitScale, &aExplicitIncrement, + pRefSize ); + } + break; + case OBJECTTYPE_AXIS_UNITLABEL: + break; + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_SERIES: + case OBJECTTYPE_DATA_LABEL: + case OBJECTTYPE_DATA_POINT: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + wrapper::GraphicPropertyItemConverter::eGraphicObjectType eMapTo = + wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT; + + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( aObjectCID, xChartModel ); + uno::Reference< XChartType > xChartType = ChartModelHelper::getChartTypeOfSeries( xChartModel, xSeries ); + + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + if( !ChartTypeHelper::isSupportingAreaProperties( xChartType, nDimensionCount ) ) + eMapTo = wrapper::GraphicPropertyItemConverter::LINE_DATA_POINT; + /* + FILLED_DATA_POINT, + LINE_DATA_POINT, + LINE_PROPERTIES, + FILL_PROPERTIES, + LINE_AND_FILL_PROPERTIES + */ + bool bDataSeries = ( eObjectType == OBJECTTYPE_DATA_SERIES || eObjectType == OBJECTTYPE_DATA_LABELS ); + + //special color for pie chart: + bool bUseSpecialFillColor = false; + sal_Int32 nSpecialFillColor =0; + sal_Int32 nPointIndex = -1; /*-1 for whole series*/ + if(!bDataSeries) + { + nPointIndex = aParticleID.toInt32(); + uno::Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); + bool bVaryColorsByPoint = false; + if( xSeriesProp.is() && + (xSeriesProp->getPropertyValue(C2U("VaryColorsByPoint")) >>= bVaryColorsByPoint) && + bVaryColorsByPoint ) + { + if( !ColorPerPointHelper::hasPointOwnColor( xSeriesProp, nPointIndex, xObjectProperties ) ) + { + bUseSpecialFillColor = true; + OSL_ASSERT( xDiagram.is()); + uno::Reference< XColorScheme > xColorScheme( xDiagram->getDefaultColorScheme() ); + if( xColorScheme.is()) + nSpecialFillColor = xColorScheme->getColorByIndex( nPointIndex ); + } + } + } + sal_Int32 nNumberFormat=ExplicitValueProvider::getExplicitNumberFormatKeyForDataLabel( xObjectProperties, xSeries, nPointIndex, xDiagram ); + sal_Int32 nPercentNumberFormat=ExplicitValueProvider::getExplicitPercentageNumberFormatKeyForDataLabel( + xObjectProperties,uno::Reference< util::XNumberFormatsSupplier >(xChartModel, uno::UNO_QUERY)); + + pItemConverter = new wrapper::DataPointItemConverter( xChartModel, xContext, + xObjectProperties, xSeries, rDrawModel.GetItemPool(), rDrawModel, + pNumberFormatterWrapper, + uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + eMapTo, pRefSize, bDataSeries, bUseSpecialFillColor, nSpecialFillColor, false, + nNumberFormat, nPercentNumberFormat ); + break; + } + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: + case OBJECTTYPE_DATA_AVERAGE_LINE: + pItemConverter = new wrapper::GraphicPropertyItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + wrapper::GraphicPropertyItemConverter::LINE_PROPERTIES ); + break; + + case OBJECTTYPE_DATA_ERRORS: + pItemConverter = new wrapper::ErrorBarItemConverter( + xChartModel, xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + 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 )); + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + pItemConverter = new wrapper::RegressionEquationItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), rDrawModel, + uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + pRefSize ); + break; + } + case OBJECTTYPE_DATA_ERRORS_X: + break; + case OBJECTTYPE_DATA_ERRORS_Y: + break; + case OBJECTTYPE_DATA_ERRORS_Z: + break; + case OBJECTTYPE_DATA_STOCK_RANGE: + break; + case OBJECTTYPE_DATA_STOCK_LOSS: + case OBJECTTYPE_DATA_STOCK_GAIN: + pItemConverter = new wrapper::GraphicPropertyItemConverter( + xObjectProperties, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), + wrapper::GraphicPropertyItemConverter::LINE_AND_FILL_PROPERTIES ); + break; + default: //OBJECTTYPE_UNKNOWN + break; + } + } + else + { + //create itemconverter for a all objects of given type + switch(eObjectType) + { + case OBJECTTYPE_TITLE: + pItemConverter = new wrapper::AllTitleItemConverter( xChartModel, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + break; + case OBJECTTYPE_AXIS: + { + ::std::auto_ptr< awt::Size > pRefSize; + if( pRefSizeProvider.get() ) + pRefSize.reset( new awt::Size( pRefSizeProvider->getPageSize())); + + pItemConverter = new wrapper::AllAxisItemConverter( xChartModel, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY ), pRefSize ); + } + break; + case OBJECTTYPE_GRID: + case OBJECTTYPE_SUBGRID: + pItemConverter = new wrapper::AllGridItemConverter( xChartModel, rDrawModel.GetItemPool(), + rDrawModel, uno::Reference< lang::XMultiServiceFactory >( xChartModel, uno::UNO_QUERY )); + break; + default: //for this type it is not supported to change all elements at once + break; + } + + } + return pItemConverter; +} + +rtl::OUString lcl_getTitleCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel > & xChartModel ) +{ + if( rDispatchCommand.equals("AllTitles")) + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_TITLE, C2U("ALLELEMENTS") ); + + TitleHelper::eTitleType nTitleType( TitleHelper::MAIN_TITLE ); + if( rDispatchCommand.equals("SubTitle") ) + nTitleType = TitleHelper::SUB_TITLE; + else if( rDispatchCommand.equals("XTitle") ) + nTitleType = TitleHelper::X_AXIS_TITLE; + else if( rDispatchCommand.equals("YTitle") ) + nTitleType = TitleHelper::Y_AXIS_TITLE; + else if( rDispatchCommand.equals("ZTitle") ) + nTitleType = TitleHelper::Z_AXIS_TITLE; + else if( rDispatchCommand.equals("SecondaryXTitle") ) + nTitleType = TitleHelper::SECONDARY_X_AXIS_TITLE; + else if( rDispatchCommand.equals("SecondaryYTitle") ) + nTitleType = TitleHelper::SECONDARY_Y_AXIS_TITLE; + + uno::Reference< XTitle > xTitle( TitleHelper::getTitle( nTitleType, xChartModel ) ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xTitle, xChartModel ); +} + +rtl::OUString lcl_getAxisCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +{ + if( rDispatchCommand.equals("DiagramAxisAll")) + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_AXIS, C2U("ALLELEMENTS") ); + + sal_Int32 nDimensionIndex=0; + bool bMainAxis=true; + if( rDispatchCommand.equals("DiagramAxisX")) + { + nDimensionIndex=0; bMainAxis=true; + } + else if( rDispatchCommand.equals("DiagramAxisY")) + { + nDimensionIndex=1; bMainAxis=true; + } + else if( rDispatchCommand.equals("DiagramAxisZ")) + { + nDimensionIndex=2; bMainAxis=true; + } + else if( rDispatchCommand.equals("DiagramAxisA")) + { + nDimensionIndex=0; bMainAxis=false; + } + else if( rDispatchCommand.equals("DiagramAxisB")) + { + nDimensionIndex=1; bMainAxis=false; + } + + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ); +} + +rtl::OUString lcl_getGridCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< frame::XModel >& xChartModel ) +{ + uno::Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartModel ) ); + + if( rDispatchCommand.equals("DiagramGridAll")) + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_GRID, C2U("ALLELEMENTS") ); + + sal_Int32 nDimensionIndex=0; + bool bMainGrid=true; + + //x and y is swapped in the commands + + if( rDispatchCommand.equals("DiagramGridYMain")) + { + nDimensionIndex=0; bMainGrid=true; + } + else if( rDispatchCommand.equals("DiagramGridXMain")) + { + nDimensionIndex=1; bMainGrid=true; + } + else if( rDispatchCommand.equals("DiagramGridZMain")) + { + nDimensionIndex=2; bMainGrid=true; + } + else if( rDispatchCommand.equals("DiagramGridYHelp")) + { + nDimensionIndex=0; bMainGrid=false; + } + else if( rDispatchCommand.equals("DiagramGridXHelp")) + { + nDimensionIndex=1; bMainGrid=false; + } + else if( rDispatchCommand.equals("DiagramGridZHelp")) + { + nDimensionIndex=2; bMainGrid=false; + } + + bool bMainAxis = true; + uno::Reference< XAxis > xAxis( AxisHelper::getAxis( nDimensionIndex, bMainAxis, xDiagram ) ); + + sal_Int32 nSubGridIndex= bMainGrid ? (-1) : 0; + rtl::OUString aCID( ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGridIndex ) ); + return aCID; +} +rtl::OUString lcl_getObjectCIDForCommand( const ::rtl::OString& rDispatchCommand, const uno::Reference< XChartDocument > & xChartDocument, const rtl::OUString& rSelectedCID ) +{ + ObjectType eObjectType = OBJECTTYPE_UNKNOWN; + rtl::OUString aParticleID; + + uno::Reference< frame::XModel > xChartModel( xChartDocument, uno::UNO_QUERY ); + const ObjectType eSelectedType = ObjectIdentifier::getObjectType( rSelectedCID ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( rSelectedCID, xChartModel ); + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( xSeries, uno::UNO_QUERY ); + + //------------------------------------------------------------------------- + //legend + if( rDispatchCommand.equals("Legend") || rDispatchCommand.equals("FormatLegend") ) + { + eObjectType = OBJECTTYPE_LEGEND; + //@todo set particular aParticleID if we have more than one legend + } + //------------------------------------------------------------------------- + //wall floor area + else if( rDispatchCommand.equals("DiagramWall") || rDispatchCommand.equals("FormatWall") ) + { + //OBJECTTYPE_DIAGRAM; + eObjectType = OBJECTTYPE_DIAGRAM_WALL; + //@todo set particular aParticleID if we have more than one diagram + } + else if( rDispatchCommand.equals("DiagramFloor") || rDispatchCommand.equals("FormatFloor") ) + { + eObjectType = OBJECTTYPE_DIAGRAM_FLOOR; + //@todo set particular aParticleID if we have more than one diagram + } + else if( rDispatchCommand.equals("DiagramArea") || rDispatchCommand.equals("FormatChartArea") ) + { + eObjectType = OBJECTTYPE_PAGE; + } + //------------------------------------------------------------------------- + //title + else if( rDispatchCommand.equals("MainTitle") + || rDispatchCommand.equals("SubTitle") + || rDispatchCommand.equals("XTitle") + || rDispatchCommand.equals("YTitle") + || rDispatchCommand.equals("ZTitle") + || rDispatchCommand.equals("SecondaryXTitle") + || rDispatchCommand.equals("SecondaryYTitle") + || rDispatchCommand.equals("AllTitles") + ) + { + return lcl_getTitleCIDForCommand( rDispatchCommand, xChartModel ); + } + //------------------------------------------------------------------------- + //axis + else if( rDispatchCommand.equals("DiagramAxisX") + || rDispatchCommand.equals("DiagramAxisY") + || rDispatchCommand.equals("DiagramAxisZ") + || rDispatchCommand.equals("DiagramAxisA") + || rDispatchCommand.equals("DiagramAxisB") + || rDispatchCommand.equals("DiagramAxisAll") + ) + { + return lcl_getAxisCIDForCommand( rDispatchCommand, xChartModel ); + } + //------------------------------------------------------------------------- + //grid + else if( rDispatchCommand.equals("DiagramGridYMain") + || rDispatchCommand.equals("DiagramGridXMain") + || rDispatchCommand.equals("DiagramGridZMain") + || rDispatchCommand.equals("DiagramGridYHelp") + || rDispatchCommand.equals("DiagramGridXHelp") + || rDispatchCommand.equals("DiagramGridZHelp") + || rDispatchCommand.equals("DiagramGridAll") + ) + { + return lcl_getGridCIDForCommand( rDispatchCommand, xChartModel ); + } + //------------------------------------------------------------------------- + //data series + else if( rDispatchCommand.equals("FormatDataSeries") ) + { + if( eSelectedType == OBJECTTYPE_DATA_SERIES ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( + OBJECTTYPE_DATA_SERIES, ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ) ); + } + //------------------------------------------------------------------------- + //data point + else if( rDispatchCommand.equals("FormatDataPoint") ) + { + return rSelectedCID; + } + //------------------------------------------------------------------------- + //data labels + else if( rDispatchCommand.equals("FormatDataLabels") ) + { + if( eSelectedType == OBJECTTYPE_DATA_LABELS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_LABELS, ::rtl::OUString(), rSelectedCID ); + } + //------------------------------------------------------------------------- + //data labels + else if( rDispatchCommand.equals("FormatDataLabel") ) + { + if( eSelectedType == OBJECTTYPE_DATA_LABEL ) + return rSelectedCID; + else + { + sal_Int32 nPointIndex = ObjectIdentifier::getParticleID( rSelectedCID ).toInt32(); + if( nPointIndex>=0 ) + { + OUString aSeriesParticle = ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ); + OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + OUString aLabelsCID = ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle ); + OUString aLabelCID_Stub = ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_LABEL, ::rtl::OUString(), aLabelsCID ); + + return ObjectIdentifier::createPointCID( aLabelCID_Stub, nPointIndex ); + } + } + } + //------------------------------------------------------------------------- + //mean value line + else if( rDispatchCommand.equals("FormatMeanValue") ) + { + if( eSelectedType == OBJECTTYPE_DATA_AVERAGE_LINE ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getMeanValueLine( xRegCurveCnt ) ), true ); + } + //------------------------------------------------------------------------- + //trend line + else if( rDispatchCommand.equals("FormatTrendline") ) + { + if( eSelectedType == OBJECTTYPE_DATA_CURVE ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ), false ); + } + //------------------------------------------------------------------------- + //trend line equation + else if( rDispatchCommand.equals("FormatTrendlineEquation") ) + { + if( eSelectedType == OBJECTTYPE_DATA_CURVE_EQUATION ) + return rSelectedCID; + else + return ObjectIdentifier::createDataCurveEquationCID( + ObjectIdentifier::getSeriesParticleFromCID( rSelectedCID ), + RegressionCurveHelper::getRegressionCurveIndex( xRegCurveCnt, + RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ) ); + } + //------------------------------------------------------------------------- + // y error bars + else if( rDispatchCommand.equals("FormatYErrorBars") ) + { + if( eSelectedType == OBJECTTYPE_DATA_ERRORS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS, ::rtl::OUString(), rSelectedCID ); + } + //------------------------------------------------------------------------- + // axis + else if( rDispatchCommand.equals("FormatAxis") ) + { + if( eSelectedType == OBJECTTYPE_AXIS ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForObject( xAxis , xChartModel ); + } + } + //------------------------------------------------------------------------- + // major grid + else if( rDispatchCommand.equals("FormatMajorGrid") ) + { + if( eSelectedType == OBJECTTYPE_GRID ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ); + } + + } + //------------------------------------------------------------------------- + // minor grid + else if( rDispatchCommand.equals("FormatMinorGrid") ) + { + if( eSelectedType == OBJECTTYPE_SUBGRID ) + return rSelectedCID; + else + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( rSelectedCID, xChartModel ); + return ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, 0 /*sub grid index*/ ); + } + } + //------------------------------------------------------------------------- + // title + else if( rDispatchCommand.equals("FormatTitle") ) + { + if( eSelectedType == OBJECTTYPE_TITLE ) + return rSelectedCID; + } + //------------------------------------------------------------------------- + // stock loss + else if( rDispatchCommand.equals("FormatStockLoss") ) + { + if( eSelectedType == OBJECTTYPE_DATA_STOCK_LOSS ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_LOSS, rtl::OUString()); + } + //------------------------------------------------------------------------- + // stock gain + else if( rDispatchCommand.equals("FormatStockGain") ) + { + if( eSelectedType == OBJECTTYPE_DATA_STOCK_GAIN ) + return rSelectedCID; + else + return ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DATA_STOCK_GAIN, rtl::OUString() ); + } + + return ObjectIdentifier::createClassifiedIdentifier( + eObjectType, aParticleID ); +} + +} +// anonymous namespace + +void SAL_CALL ChartController::executeDispatch_FormatObject(const ::rtl::OUString& rDispatchCommand) +{ + uno::Reference< XChartDocument > xChartDocument( m_aModel->getModel(), uno::UNO_QUERY ); + rtl::OString aCommand( rtl::OUStringToOString( rDispatchCommand, RTL_TEXTENCODING_ASCII_US ) ); + rtl::OUString rObjectCID = lcl_getObjectCIDForCommand( aCommand, xChartDocument, m_aSelection.getSelectedCID() ); + executeDlg_ObjectProperties( rObjectCID ); +} + +void SAL_CALL ChartController::executeDispatch_ObjectProperties() +{ + executeDlg_ObjectProperties( m_aSelection.getSelectedCID() ); +} + +namespace +{ + +rtl::OUString lcl_getFormatCIDforSelectedCID( const ::rtl::OUString& rSelectedCID ) +{ + ::rtl::OUString aFormatCID(rSelectedCID); + + //get type of selected object + ObjectType eObjectType = ObjectIdentifier::getObjectType( aFormatCID ); + + // some legend entries are handled as if they were data series + if( OBJECTTYPE_LEGEND_ENTRY==eObjectType ) + { + rtl::OUString aParentParticle( ObjectIdentifier::getFullParentParticle( rSelectedCID ) ); + aFormatCID = ObjectIdentifier::createClassifiedIdentifierForParticle( aParentParticle ); + } + + // treat diagram as wall + if( OBJECTTYPE_DIAGRAM==eObjectType ) + aFormatCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ); + + return aFormatCID; +} + +}//end anonymous namespace + +void SAL_CALL ChartController::executeDlg_ObjectProperties( const ::rtl::OUString& rSelectedObjectCID ) +{ + rtl::OUString aObjectCID = lcl_getFormatCIDforSelectedCID( rSelectedObjectCID ); + + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::FORMAT, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( aObjectCID ))), + m_xUndoManager, m_aModel->getModel() ); + + bool bSuccess = ChartController::executeDlg_ObjectProperties_withoutUndoGuard( aObjectCID, false ); + if( bSuccess ) + aUndoGuard.commitAction(); +} + +bool ChartController::executeDlg_ObjectProperties_withoutUndoGuard( const ::rtl::OUString& rObjectCID, bool bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso ) +{ + //return true if the properties were changed successfully + bool bRet = false; + if( !rObjectCID.getLength() ) + { + //DBG_ERROR("empty ObjectID"); + return bRet; + } + try + { + NumberFormatterWrapper aNumberFormatterWrapper( uno::Reference< util::XNumberFormatsSupplier >(m_aModel->getModel(), uno::UNO_QUERY) ); + + //------------------------------------------------------------- + //get type of object + ObjectType eObjectType = ObjectIdentifier::getObjectType( rObjectCID ); + if( OBJECTTYPE_UNKNOWN==eObjectType ) + { + //DBG_ERROR("unknown ObjectType"); + return bRet; + } + if( OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType ) + { + if( !DiagramHelper::isSupportingFloorAndWall( ChartModelHelper::findDiagram( m_aModel->getModel() ) ) ) + return bRet; + } + + //------------------------------------------------------------- + //convert properties to ItemSet + + awt::Size aPageSize( ChartModelHelper::getPageSize(m_aModel->getModel()) ); + + ::std::auto_ptr< ReferenceSizeProvider > pRefSizeProv( + impl_createReferenceSizeProvider()); + ::std::auto_ptr< ::comphelper::ItemConverter > apItemConverter( + createItemConverter( rObjectCID, m_aModel->getModel(), m_xCC, + m_pDrawModelWrapper->getSdrModel(), + &aNumberFormatterWrapper, + ExplicitValueProvider::getExplicitValueProvider(m_xChartView), + pRefSizeProv )); + if(!apItemConverter.get()) + return bRet; + + SfxItemSet aItemSet = apItemConverter->CreateEmptyItemSet(); + apItemConverter->FillItemSet( aItemSet ); + + //------------------------------------------------------------- + //prepare dialog + ObjectPropertiesDialogParameter aDialogParameter = ObjectPropertiesDialogParameter( rObjectCID ); + aDialogParameter.init( m_aModel->getModel() ); + ViewElementListProvider aViewElementListProvider( m_pDrawModelWrapper.get() ); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + SchAttribTabDlg aDlg( m_pChartWindow, &aItemSet, &aDialogParameter, &aViewElementListProvider + , uno::Reference< util::XNumberFormatsSupplier >( m_aModel->getModel(), uno::UNO_QUERY ) ); + + if(aDialogParameter.HasSymbolProperties()) + { + SfxItemSet* pSymbolShapeProperties=NULL; + uno::Reference< beans::XPropertySet > xObjectProperties = + ObjectIdentifier::getObjectPropertySet( rObjectCID, m_aModel->getModel() ); + wrapper::DataPointItemConverter aSymbolItemConverter( m_aModel->getModel(), m_xCC + , xObjectProperties, ObjectIdentifier::getDataSeriesForCID( rObjectCID, m_aModel->getModel() ) + , m_pDrawModelWrapper->getSdrModel().GetItemPool() + , m_pDrawModelWrapper->getSdrModel() + , &aNumberFormatterWrapper + , uno::Reference< lang::XMultiServiceFactory >( m_aModel->getModel(), uno::UNO_QUERY ) + , wrapper::GraphicPropertyItemConverter::FILLED_DATA_POINT ); + + pSymbolShapeProperties = new SfxItemSet( aSymbolItemConverter.CreateEmptyItemSet() ); + aSymbolItemConverter.FillItemSet( *pSymbolShapeProperties ); + + sal_Int32 nStandardSymbol=0;//@todo get from somewhere + Graphic* pAutoSymbolGraphic = new Graphic( aViewElementListProvider.GetSymbolGraphic( nStandardSymbol, pSymbolShapeProperties ) ); + // note: the dialog takes the ownership of pSymbolShapeProperties and pAutoSymbolGraphic + aDlg.setSymbolInformation( pSymbolShapeProperties, pAutoSymbolGraphic ); + } + if( aDialogParameter.HasStatisticProperties() ) + { + aDlg.SetAxisMinorStepWidthForErrorBarDecimals( + InsertErrorBarsDialog::getAxisMinorStepWidthForErrorBarDecimals( m_aModel->getModel(), m_xChartView, rObjectCID ) ); + } + + //------------------------------------------------------------- + //open the dialog + if( aDlg.Execute() == RET_OK || (bOkClickOnUnchangedDialogSouldBeRatedAsSuccessAlso && aDlg.DialogWasClosedWithOK()) ) + { + const SfxItemSet* pOutItemSet = aDlg.GetOutputItemSet(); + if(pOutItemSet) + { + ControllerLockGuard aCLGuard( m_aModel->getModel()); + apItemConverter->ApplyItemSet( *pOutItemSet );//model should be changed now + bRet = true; + } + } + } + catch( util::CloseVetoException& ) + { + } + catch( uno::RuntimeException& ) + { + } + return bRet; +} + +void SAL_CALL ChartController::executeDispatch_View3D() +{ + try + { + // using assignment for broken gcc 3.3 + UndoLiveUpdateGuard aUndoGuard = UndoLiveUpdateGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_EDIT_3D_VIEW ))), + m_xUndoManager, m_aModel->getModel()); + + // /-- + //open dialog + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + View3DDialog aDlg( m_pChartWindow, m_aModel->getModel(), m_pDrawModelWrapper->GetColorTable() ); + if( aDlg.Execute() == RET_OK ) + aUndoGuard.commitAction(); + // \-- + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartController_TextEdit.cxx b/chart2/source/controller/main/ChartController_TextEdit.cxx new file mode 100644 index 000000000000..e1f83550bd5d --- /dev/null +++ b/chart2/source/controller/main/ChartController_TextEdit.cxx @@ -0,0 +1,246 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_TextEdit.cxx,v $ + * $Revision: 1.14 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" + +#include "DrawViewWrapper.hxx" +#include "ChartWindow.hxx" +#include "TitleHelper.hxx" +#include "ObjectIdentifier.hxx" +#include "macros.hxx" +#include "ControllerLockGuard.hxx" +#include "AccessibleTextHelper.hxx" +#include "chartview/DrawModelWrapper.hxx" + +#include <svx/svdotext.hxx> + +// header for define RET_OK +#include <vcl/msgbox.hxx> +// header for class SdrOutliner +#include <svx/svdoutl.hxx> +#include <svx/svxdlg.hxx> +#ifndef _SVX_DIALOGS_HRC +#include <svx/dialogs.hrc> +#endif +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <svtools/stritem.hxx> +#include <svx/fontitem.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +//using namespace ::com::sun::star::chart2; + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void SAL_CALL ChartController::executeDispatch_EditText() +{ + this->StartTextEdit(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void ChartController::StartTextEdit() +{ + //the first marked object will be edited + + SdrObject* pTextObj = m_pDrawViewWrapper->getTextEditObject(); + if(!pTextObj) + return; + + m_xUndoManager->preAction( m_aModel->getModel()); + SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + //pOutliner->SetRefDevice(m_pChartWindow); + //pOutliner->SetStyleSheetPool((SfxStyleSheetPool*)pStyleSheetPool); + //pOutliner->SetDefaultLanguage( eLang ); + //pOutliner->SetHyphenator( xHyphenator ); + + //#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( C2U("SdrViewIsInEditMode"), uno::makeAny(sal_True) ); + + sal_Bool bEdit = m_pDrawViewWrapper->SdrBeginTextEdit( pTextObj + , m_pDrawViewWrapper->GetPageView() + , m_pChartWindow + , sal_False //bIsNewObj + , pOutliner + , 0L //pOutlinerView + , sal_True //bDontDeleteOutliner + , sal_True //bOnlyOneView + ); + if(bEdit) + { + // set undo manager at topmost shell ( SdDrawTextObjectBar ) + /* + if( pViewSh ) + pViewSh->GetViewFrame()->GetDispatcher()->GetShell( 0 )-> + SetUndoManager(&pOutliner->GetUndoManager()); + */ + m_pDrawViewWrapper->SetEditMode(); + + //we invalidate the outliner region because the outliner has some + //paint problems (some characters are painted twice a little bit shifted) + m_pChartWindow->Invalidate( m_pDrawViewWrapper->GetMarkedObjBoundRect() ); + } +} + +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( C2U("SdrViewIsInEditMode"), uno::makeAny(sal_False) ); + + SdrObject* pTextObject = m_pDrawViewWrapper->getTextEditObject(); + if(!pTextObject) + return false; + + SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + OutlinerParaObject* pParaObj = pTextObject->GetOutlinerParaObject(); + if( pParaObj && pOutliner ) + { + pOutliner->SetText( *pParaObj ); + + String aString = pOutliner->GetText( + pOutliner->GetParagraph( 0 ), + pOutliner->GetParagraphCount() ); + uno::Reference< beans::XPropertySet > xPropSet = + ObjectIdentifier::getObjectPropertySet( m_aSelection.getSelectedCID(), getModel() ); + + // lock controllers till end of block + ControllerLockGuard aCLGuard( m_aModel->getModel()); + + //Paragraph* pPara = + TitleHelper::setCompleteString( aString, uno::Reference< + ::com::sun::star::chart2::XTitle >::query( xPropSet ), m_xCC ); + try + { + m_xUndoManager->postAction( C2U("Edit Text") ); + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } + } + return true; +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void SAL_CALL ChartController::executeDispatch_InsertSpecialCharacter() +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + if( m_pDrawViewWrapper && !m_pDrawViewWrapper->IsTextEdit() ) + this->StartTextEdit(); + + SvxAbstractDialogFactory * pFact = SvxAbstractDialogFactory::Create(); + DBG_ASSERT( pFact, "No dialog factory" ); + + SfxAllItemSet aSet( m_pDrawModelWrapper->GetItemPool() ); + aSet.Put( SfxBoolItem( FN_PARAM_1, FALSE ) ); + + //set fixed current font + aSet.Put( SfxBoolItem( FN_PARAM_2, TRUE ) ); //maybe not necessary in future + + Font aCurFont = m_pDrawViewWrapper->getOutliner()->GetRefDevice()->GetFont(); + aSet.Put( SvxFontItem( aCurFont.GetFamily(), aCurFont.GetName(), aCurFont.GetStyleName(), aCurFont.GetPitch(), aCurFont.GetCharSet(), SID_ATTR_CHAR_FONT ) ); + + SfxAbstractDialog * pDlg = pFact->CreateSfxDialog( m_pChartWindow, aSet, getFrame(), RID_SVXDLG_CHARMAP ); + DBG_ASSERT( pDlg, "Couldn't create SvxCharacterMap dialog" ); + if( pDlg->Execute() == RET_OK ) + { + const SfxItemSet* pSet = pDlg->GetOutputItemSet(); + const SfxPoolItem* pItem=0; + String aString; + if ( pSet && pSet->GetItemState( SID_CHARMAP, TRUE, &pItem) == SFX_ITEM_SET && + pItem->ISA(SfxStringItem) ) + aString = dynamic_cast<const SfxStringItem*>(pItem)->GetValue(); + + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + SdrOutliner* pOutliner = m_pDrawViewWrapper->getOutliner(); + + 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(String()); + + //SfxUndoManager& rUndoMgr = pOutliner->GetUndoManager(); + //rUndoMgr.EnterListAction( String( SchResId( STR_UNDO_INSERT_SPECCHAR )), String( SchResId( STR_UNDO_INSERT_SPECCHAR ))); + pOutlinerView->InsertText(aString, TRUE); + + ESelection aSel = pOutlinerView->GetSelection(); + aSel.nStartPara = aSel.nEndPara; + aSel.nStartPos = aSel.nEndPos; + pOutlinerView->SetSelection(aSel); + + //rUndoMgr.LeaveListAction(); + + // show changes + pOutliner->SetUpdateMode(TRUE); + pOutlinerView->ShowCursor(); + } + + delete pDlg; +} + +uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > + ChartController::impl_createAccessibleTextContext() +{ + uno::Reference< ::com::sun::star::accessibility::XAccessibleContext > xResult( + new AccessibleTextHelper( m_pDrawViewWrapper )); + + return xResult; +} + + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartController_Tools.cxx b/chart2/source/controller/main/ChartController_Tools.cxx new file mode 100644 index 000000000000..8dca62d93ee1 --- /dev/null +++ b/chart2/source/controller/main/ChartController_Tools.cxx @@ -0,0 +1,785 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_Tools.cxx,v $ + * $Revision: 1.9.36.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartController.hxx" +#include "ChartWindow.hxx" +#include "ChartModelHelper.hxx" +#include "TitleHelper.hxx" +#include "ThreeDHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "UndoGuard.hxx" +#include "ControllerLockGuard.hxx" +#include "macros.hxx" +#include "ResId.hxx" +#include "Strings.hrc" +#include "ObjectIdentifier.hxx" +#include "ReferenceSizeProvider.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "ChartTransferable.hxx" +#include "DrawViewWrapper.hxx" +#include "LegendHelper.hxx" +#include "AxisHelper.hxx" +#include "RegressionCurveHelper.hxx" + +#include <com/sun/star/chart2/DataPointLabel.hpp> +#include <com/sun/star/beans/XPropertyState.hpp> +#include <com/sun/star/drawing/CameraGeometry.hpp> +#include <com/sun/star/graphic/XGraphic.hpp> +#include <com/sun/star/io/XInputStream.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/drawing/XDrawPageSupplier.hpp> + +#include <svx/ActionDescriptionProvider.hxx> +// for TransferableDataHelper/TransferableHelper +#include <svtools/transfer.hxx> +// for SotStorageStreamRef +#include <sot/storage.hxx> +// for Graphic +#include <vcl/graph.hxx> +// for SvxDrawingLayerImport/SvxUnoDrawingModel +#include <svx/unomodel.hxx> +// for SdrModel +#include <svx/svdmodel.hxx> +// for OInputStreamWrapper +#include <unotools/streamwrap.hxx> +// for SolarMutex +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +// for OutlinerView +#include <svx/outliner.hxx> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ + +bool lcl_deleteDataSeries( + const OUString & rCID, + const Reference< frame::XModel > & xModel, + const Reference< chart2::XUndoManager > & xUndoManager ) +{ + bool bResult = false; + uno::Reference< chart2::XDataSeries > xSeries( ::chart::ObjectIdentifier::getDataSeriesForCID( rCID, xModel )); + uno::Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); + if( xSeries.is() && xChartDoc.is()) + { + uno::Reference< chart2::XChartType > xChartType( + ::chart::DataSeriesHelper::getChartTypeOfSeries( xSeries, xChartDoc->getFirstDiagram())); + if( xChartType.is()) + { + ::chart::UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_DATASERIES )))), + xUndoManager, xModel ); + ::chart::DataSeriesHelper::deleteSeries( xSeries, xChartType ); + bResult = true; + aUndoGuard.commitAction(); + } + } + return bResult; +} + +bool lcl_deleteDataCurve( + const OUString & rCID, + const Reference< frame::XModel > & xModel, + const Reference< chart2::XUndoManager > & xUndoManager ) +{ + bool bResult = false; + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ::chart::ObjectIdentifier::getObjectPropertySet( + ::chart::ObjectIdentifier::getSeriesParticleFromCID( rCID ), xModel ), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + ::chart::UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( ::chart::SchResId( STR_OBJECT_CURVE )))), + xUndoManager, xModel ); + ::chart::RegressionCurveHelper::removeAllExceptMeanValueLine( xRegCurveCnt ); + bResult = true; + aUndoGuard.commitAction(); + } + return bResult; +} + +// void lcl_CopyPageContentToPage( +// const Reference< drawing::XDrawPage > & xSourcePage, +// const Reference< drawing::XDrawPage > & xDestPage ) +// { +// try +// { +// Reference< container::XIndexAccess > xSourceIA( xSourcePage, uno::UNO_QUERY_THROW ); +// sal_Int32 nCount( xSourceIA->getCount()); +// for( sal_Int32 i=0; i<nCount; ++i ) +// { +// Reference< drawing::XShape > xShape; +// if( xSourceIA->getByIndex( i ) >>= xShape ) +// xDestPage->add( xShape ); +// } +// } +// catch( const uno::Exception & ex ) +// { +// ASSERT_EXCEPTION( ex ); +// } +// } + +// // copies all shapes on all pages of xSource to the only page of xDestination +// void lcl_CopyShapesToChart( +// const Reference< frame::XModel > & xSource, const Reference< frame::XModel > & xDestination ) +// { +// try +// { +// Reference< drawing::XDrawPageSupplier > xDestPGSupp( xDestination, uno::UNO_QUERY_THROW ); +// Reference< drawing::XDrawPage > xDestPage( xDestPGSupp->getDrawPage()); +// Reference< drawing::XDrawPagesSupplier > xSourcePGsSupp( xSource, uno::UNO_QUERY_THROW ); +// Reference< drawing::XDrawPages > xSourcePages( xSourcePGsSupp->getDrawPages()); + +// sal_Int32 nCount( xSourcePages->getCount()); +// for( sal_Int32 i=0; i<nCount; ++i ) +// { +// Reference< drawing::XDrawPage > xSourcePage( xSourcePages->getByIndex( i ), uno::UNO_QUERY_THROW ); +// lcl_CopyPageContentToPage( xSourcePage, xDestPage ); +// } +// } +// catch( const uno::Exception & ex ) +// { +// ASSERT_EXCEPTION( ex ); +// } +// } + +} // anonymous namespace + +namespace +{ +void lcl_InsertStringAsTextShapeIntoDrawPage( + const Reference< lang::XMultiServiceFactory > & xShapeFactory, + const Reference< drawing::XDrawPage > & xDrawPage, + OUString & rString, + const awt::Point & aPosition ) +{ + OSL_ASSERT( xShapeFactory.is() && xDrawPage.is()); + if( ! (xShapeFactory.is() && xDrawPage.is())) + return; + + try + { + Reference< drawing::XShape > xTextShape( + xShapeFactory->createInstance( C2U("com.sun.star.drawing.TextShape")), uno::UNO_QUERY_THROW ); + xDrawPage->add( xTextShape ); + + Reference< text::XTextRange > xRange( xTextShape, uno::UNO_QUERY_THROW ); + xRange->setString( rString ); + + float fCharHeight = 10.0; + Reference< beans::XPropertySet > xProperties( xTextShape, uno::UNO_QUERY_THROW ); + xProperties->setPropertyValue( C2U("TextAutoGrowHeight"), uno::makeAny( true )); + xProperties->setPropertyValue( C2U("TextAutoGrowWidth"), uno::makeAny( true )); + xProperties->setPropertyValue( C2U("CharHeight"), uno::makeAny( fCharHeight )); + xProperties->setPropertyValue( C2U("CharHeightAsian"), uno::makeAny( fCharHeight )); + xProperties->setPropertyValue( C2U("CharHeightComplex"), uno::makeAny( fCharHeight )); + xProperties->setPropertyValue( C2U("TextVerticalAdjust"), uno::makeAny( drawing::TextVerticalAdjust_CENTER )); + xProperties->setPropertyValue( C2U("TextHorizontalAdjust"), uno::makeAny( drawing::TextHorizontalAdjust_CENTER )); + xProperties->setPropertyValue( C2U("CharFontName"), uno::makeAny( C2U( "Albany" ))); + + awt::Point aAdaptedPos( aPosition ); + aAdaptedPos.Y -= (xTextShape->getSize().Height / 2); + aAdaptedPos.X -= (xTextShape->getSize().Width / 2); + xTextShape->setPosition( aAdaptedPos ); + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +} // anonymous namespace + +namespace chart +{ + +::std::auto_ptr< ReferenceSizeProvider > ChartController::impl_createReferenceSizeProvider() const +{ + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel()) ); + + return ::std::auto_ptr< ReferenceSizeProvider >( + new ReferenceSizeProvider( aPageSize, + Reference< chart2::XChartDocument >( m_aModel->getModel(), uno::UNO_QUERY ))); +} + +void ChartController::impl_adaptDataSeriesAutoResize() +{ + ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProvider( + impl_createReferenceSizeProvider()); + if( apRefSizeProvider.get()) + apRefSizeProvider->setValuesAtAllDataSeries(); +} + +void ChartController::executeDispatch_NewArrangement() +{ + // remove manual positions at titles, legend and the diagram, remove manual + // size at the diagram + + try + { + Reference< frame::XModel > xModel( m_aModel->getModel()); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + if( xDiagram.is()) + { + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_REARRANGE_CHART ))), + m_xUndoManager, xModel ); + ControllerLockGuard aCtlLockGuard( xModel ); + + // diagram + Reference< beans::XPropertyState > xState( xDiagram, uno::UNO_QUERY_THROW ); + xState->setPropertyToDefault( C2U("RelativeSize")); + xState->setPropertyToDefault( C2U("RelativePosition")); + + // 3d rotation + ThreeDHelper::set3DSettingsToDefault( uno::Reference< beans::XPropertySet >( xDiagram, uno::UNO_QUERY ) ); + + // legend + Reference< beans::XPropertyState > xLegendState( xDiagram->getLegend(), uno::UNO_QUERY ); + if( xLegendState.is()) + xLegendState->setPropertyToDefault( C2U("RelativePosition")); + + // titles + for( sal_Int32 eType = TitleHelper::TITLE_BEGIN; + eType < TitleHelper::NORMAL_TITLE_END; + ++eType ) + { + Reference< beans::XPropertyState > xTitleState( + TitleHelper::getTitle( + static_cast< TitleHelper::eTitleType >( eType ), xModel ), uno::UNO_QUERY ); + if( xTitleState.is()) + xTitleState->setPropertyToDefault( C2U("RelativePosition")); + } + + // regression curve equations + ::std::vector< Reference< chart2::XRegressionCurve > > aRegressionCurves( + RegressionCurveHelper::getAllRegressionCurvesNotMeanValueLine( xDiagram )); + ::std::for_each( aRegressionCurves.begin(), aRegressionCurves.end(), + RegressionCurveHelper::resetEquationPosition ); + + aUndoGuard.commitAction(); + } + } + catch( uno::RuntimeException & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +void ChartController::executeDispatch_ScaleText() +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_SCALE_TEXT ))), + m_xUndoManager, m_aModel->getModel()); + ControllerLockGuard aCtlLockGuard( m_aModel->getModel()); + ::std::auto_ptr< ReferenceSizeProvider > apRefSizeProv( impl_createReferenceSizeProvider()); + OSL_ASSERT( apRefSizeProv.get()); + if( apRefSizeProv.get()) + apRefSizeProv->toggleAutoResizeState(); + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_Paste() +{ + if( m_pChartWindow ) + { + Graphic aGraphic; + // paste location: center of window + Point aPos; + aPos = m_pChartWindow->PixelToLogic( Rectangle( aPos, m_pChartWindow->GetSizePixel()).Center()); + + // handle different formats + TransferableDataHelper aDataHelper( TransferableDataHelper::CreateFromSystemClipboard( m_pChartWindow )); + if( aDataHelper.GetTransferable().is()) + { +// if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_DRAWING )) +// { +// SotStorageStreamRef xStm; +// if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_DRAWING, xStm )) +// { +// xStm->Seek( 0 ); +// uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( *xStm )); +// SdrModel * pModel = new SdrModel(); +// DrawModelWrapper * pDrawModelWrapper( this->GetDrawModelWrapper()); +// if( SvxDrawingLayerImport( pModel, xInputStream )) +// lcl_CopyShapesToChart( *pModel, m_pDrawModelWrapper->getSdrModel()); +// delete pModel; +// } +// } +// else + if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_SVXB )) + { + // graphic exchange format (graphic manager bitmap format?) + SotStorageStreamRef xStm; + if( aDataHelper.GetSotStorageStream( SOT_FORMATSTR_ID_SVXB, xStm )) + (*xStm) >> aGraphic; + } + else if( aDataHelper.HasFormat( FORMAT_GDIMETAFILE )) + { + // meta file + GDIMetaFile aMetafile; + if( aDataHelper.GetGDIMetaFile( FORMAT_GDIMETAFILE, aMetafile )) + aGraphic = Graphic( aMetafile ); + } + else if( aDataHelper.HasFormat( FORMAT_BITMAP )) + { + // bitmap (non-graphic-manager) + Bitmap aBmp; + if( aDataHelper.GetBitmap( FORMAT_BITMAP, aBmp )) + aGraphic = Graphic( aBmp ); + } + else if( aDataHelper.HasFormat( FORMAT_STRING )) + { + OUString aString; + if( aDataHelper.GetString( FORMAT_STRING, aString ) && m_pDrawModelWrapper ) + { + if( m_pDrawViewWrapper ) + { + OutlinerView* pOutlinerView = m_pDrawViewWrapper->GetTextEditOutlinerView(); + if( pOutlinerView )//in case of edit mode insert into edited string + pOutlinerView->InsertText( aString ); + else + { + awt::Point aTextPos; + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel())); + aTextPos.X = (aPageSize.Width / 2); + aTextPos.Y = (aPageSize.Height / 2); + lcl_InsertStringAsTextShapeIntoDrawPage( + m_pDrawModelWrapper->getShapeFactory(), + m_pDrawModelWrapper->getMainDrawPage(), + aString, aTextPos ); + } + } + } + } + } + + if( aGraphic.GetType() != GRAPHIC_NONE ) + { + Reference< graphic::XGraphic > xGraphic( aGraphic.GetXGraphic()); + if( xGraphic.is()) + impl_PasteGraphic( xGraphic, aPos ); + } + } +} + +// note: aPosition is ignored for now. The object is always pasted centered to +// the page +void ChartController::impl_PasteGraphic( + uno::Reference< graphic::XGraphic > & xGraphic, + const ::Point & /* aPosition */ ) +{ + // note: the XPropertySet of the model is the old API. Also the property + // "AdditionalShapes" that is used there. + uno::Reference< beans::XPropertySet > xModelProp( m_aModel->getModel(), uno::UNO_QUERY ); + DrawModelWrapper * pDrawModelWrapper( this->GetDrawModelWrapper()); + if( ! (xGraphic.is() && xModelProp.is())) + return; + uno::Reference< lang::XMultiServiceFactory > xFact( pDrawModelWrapper->getShapeFactory()); + uno::Reference< drawing::XShape > xGraphicShape( + xFact->createInstance( C2U( "com.sun.star.drawing.GraphicObjectShape" )), uno::UNO_QUERY ); + uno::Reference< beans::XPropertySet > xGraphicShapeProp( xGraphicShape, uno::UNO_QUERY ); + if( xGraphicShapeProp.is() && xGraphicShape.is()) + { + uno::Reference< drawing::XShapes > xPage( pDrawModelWrapper->getMainDrawPage(), uno::UNO_QUERY ); + if( xPage.is()) + { + xPage->add( xGraphicShape ); + //need to change the model state manually + { + uno::Reference< util::XModifiable > xModifiable( m_aModel->getModel(), uno::UNO_QUERY ); + if( xModifiable.is() ) + xModifiable->setModified( true ); + } + //select new shape + m_aSelection.setSelection( xGraphicShape ); + m_aSelection.applySelection( m_pDrawViewWrapper ); + } + xGraphicShapeProp->setPropertyValue( C2U("Graphic"), uno::makeAny( xGraphic )); + uno::Reference< beans::XPropertySet > xGraphicProp( xGraphic, uno::UNO_QUERY ); + + awt::Size aGraphicSize( 1000, 1000 ); + awt::Point aShapePos( 100,100 ); + // first try size in 100th mm, then pixel size + if( ! ( xGraphicProp->getPropertyValue( C2U("Size100thMM")) >>= aGraphicSize ) && + ( ( xGraphicProp->getPropertyValue( C2U("SizePixel")) >>= aGraphicSize ) && m_pChartWindow )) + { + ::Size aVCLSize( m_pChartWindow->PixelToLogic( Size( aGraphicSize.Width, aGraphicSize.Height ))); + aGraphicSize.Width = aVCLSize.getWidth(); + aGraphicSize.Height = aVCLSize.getHeight(); + } + xGraphicShape->setSize( aGraphicSize ); + + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel())); + aShapePos.X = (aPageSize.Width / 2) - (aGraphicSize.Width / 2); + aShapePos.Y = (aPageSize.Height / 2) - (aGraphicSize.Height / 2); + xGraphicShape->setPosition( aShapePos ); + } +} + +void ChartController::executeDispatch_Copy() +{ + + Reference< datatransfer::XTransferable > xTransferable; + + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + SdrObject * pSelectedObj = 0; + if( m_pDrawViewWrapper && m_pDrawModelWrapper ) + { + if( m_aSelection.getSelectedCID().getLength() ) + pSelectedObj = m_pDrawModelWrapper->getNamedSdrObject( m_aSelection.getSelectedCID() ); + else + pSelectedObj = DrawViewWrapper::getSdrObject( m_aSelection.getSelectedAdditionalShape() ); + + if( pSelectedObj ) + { + xTransferable = Reference< datatransfer::XTransferable >( new ChartTransferable( + & m_pDrawModelWrapper->getSdrModel(), pSelectedObj )); + } + } + } + if( xTransferable.is() ) + { + Reference< datatransfer::clipboard::XClipboard > xClipboard( TransferableHelper::GetSystemClipboard()); + if( xClipboard.is()) + xClipboard->setContents( xTransferable, Reference< datatransfer::clipboard::XClipboardOwner >() ); + } +} + +void ChartController::executeDispatch_Cut() +{ + executeDispatch_Copy(); + executeDispatch_Delete(); +} + +//static +bool ChartController::isObjectDeleteable( const uno::Any& rSelection ) +{ + OUString aSelObjCID; + if( (rSelection >>= aSelObjCID) && aSelObjCID.getLength() > 0 ) + { + ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID )); + if( (OBJECTTYPE_TITLE == aObjectType) || (OBJECTTYPE_LEGEND == aObjectType) + || (OBJECTTYPE_DATA_SERIES == aObjectType) ) + return true; + if( (OBJECTTYPE_DATA_SERIES == aObjectType) || (OBJECTTYPE_LEGEND_ENTRY == aObjectType) ) + return true; + if( (OBJECTTYPE_DATA_CURVE_EQUATION == aObjectType) || (OBJECTTYPE_DATA_CURVE == aObjectType) || + (OBJECTTYPE_DATA_AVERAGE_LINE == aObjectType) || (OBJECTTYPE_DATA_ERRORS == aObjectType)) + return true; + if( (OBJECTTYPE_DATA_LABELS == aObjectType) || (OBJECTTYPE_DATA_LABEL == aObjectType) ) + return true; + } + + return false; +} + +void ChartController::impl_ClearSelection() +{ + if( m_aSelection.hasSelection()) + { + m_aSelection.clearSelection(); + impl_notifySelectionChangeListeners(); + } +} + +bool ChartController::executeDispatch_Delete() +{ + bool bReturn = false; + + // remove the selected object + // + rtl::OUString aCID( m_aSelection.getSelectedCID() ); + if( aCID.getLength() ) + { + if( !isObjectDeleteable( uno::Any( aCID ) ) ) + return false; + + //remove chart object + impl_ClearSelection(); + + uno::Reference< chart2::XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); + if( !xChartDoc.is() ) + return false; + + ObjectType aObjectType( ObjectIdentifier::getObjectType( aCID )); + switch( aObjectType ) + { + case OBJECTTYPE_TITLE: + { + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_TITLE )))), + m_xUndoManager, m_aModel->getModel() ); + TitleHelper::removeTitle( + ObjectIdentifier::getTitleTypeForCID( aCID ), m_aModel->getModel()); + bReturn = true; + aUndoGuard.commitAction(); + break; + } + case OBJECTTYPE_LEGEND: + { + uno::Reference< chart2::XDiagram > xDiagram( xChartDoc->getFirstDiagram()); + if( xDiagram.is()) + { + uno::Reference< beans::XPropertySet > xLegendProp( xDiagram->getLegend(), uno::UNO_QUERY ); + if( xLegendProp.is()) + { + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_LEGEND )))), + m_xUndoManager, m_aModel->getModel() ); + xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( false )); + bReturn = true; + aUndoGuard.commitAction(); + } + } + break; + } + + case OBJECTTYPE_DATA_SERIES: + bReturn = lcl_deleteDataSeries( aCID, m_aModel->getModel(), m_xUndoManager ); + break; + + case OBJECTTYPE_LEGEND_ENTRY: + { + ObjectType eParentObjectType = ObjectIdentifier::getObjectType( + ObjectIdentifier::getFullParentParticle( aCID )); + if( eParentObjectType == OBJECTTYPE_DATA_SERIES ) + bReturn = lcl_deleteDataSeries( aCID, m_aModel->getModel(), m_xUndoManager ); + else if( eParentObjectType == OBJECTTYPE_DATA_CURVE ) + bReturn = lcl_deleteDataCurve( aCID, m_aModel->getModel(), m_xUndoManager ); + break; + } + + case OBJECTTYPE_DATA_AVERAGE_LINE: + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + ObjectIdentifier::getObjectPropertySet( + ObjectIdentifier::getFullParentParticle( aCID ), m_aModel->getModel()), uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_AVERAGE_LINE )))), + m_xUndoManager, m_aModel->getModel() ); + RegressionCurveHelper::removeMeanValueLine( xRegCurveCnt ); + bReturn = true; + aUndoGuard.commitAction(); + } + break; + } + + case OBJECTTYPE_DATA_CURVE: + bReturn = lcl_deleteDataCurve( aCID, m_aModel->getModel(), m_xUndoManager ); + break; + + case OBJECTTYPE_DATA_CURVE_EQUATION: + { + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( aCID, m_aModel->getModel())); + if( xEqProp.is()) + { + uno::Reference< frame::XModel > xModel( m_aModel->getModel()); + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_CURVE_EQUATION )))), + m_xUndoManager, xModel ); + { + ControllerLockGuard aCtlLockGuard( xModel ); + xEqProp->setPropertyValue( C2U("ShowEquation"), uno::makeAny( false )); + xEqProp->setPropertyValue( C2U("ShowCorrelationCoefficient"), uno::makeAny( false )); + } + bReturn = true; + aUndoGuard.commitAction(); + } + break; + } + + case OBJECTTYPE_DATA_ERRORS: + { + uno::Reference< beans::XPropertySet > xErrorBarProp( + ObjectIdentifier::getObjectPropertySet( aCID, m_aModel->getModel())); + if( xErrorBarProp.is()) + { + uno::Reference< frame::XModel > xModel( m_aModel->getModel()); + // using assignment for broken gcc 3.3 + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( SchResId( STR_OBJECT_ERROR_BARS )))), + m_xUndoManager, xModel ); + { + ControllerLockGuard aCtlLockGuard( xModel ); + xErrorBarProp->setPropertyValue( + C2U("ErrorBarStyle"), + uno::makeAny( ::com::sun::star::chart::ErrorBarStyle::NONE )); + } + bReturn = true; + aUndoGuard.commitAction(); + } + break; + } + + case OBJECTTYPE_DATA_LABELS: + case OBJECTTYPE_DATA_LABEL: + { + uno::Reference< beans::XPropertySet > xObjectProperties = + ObjectIdentifier::getObjectPropertySet( aCID, m_aModel->getModel() ); + if( xObjectProperties.is() ) + { + UndoGuard aUndoGuard = UndoGuard( + ActionDescriptionProvider::createDescription( + ActionDescriptionProvider::DELETE, ::rtl::OUString( String( + SchResId( aObjectType == OBJECTTYPE_DATA_LABEL ? STR_OBJECT_LABEL : STR_OBJECT_DATALABELS )))), + m_xUndoManager, m_aModel->getModel() ); + chart2::DataPointLabel aLabel; + xObjectProperties->getPropertyValue( C2U( "Label" ) ) >>= aLabel; + aLabel.ShowNumber = false; + aLabel.ShowNumberInPercent = false; + aLabel.ShowCategoryName = false; + aLabel.ShowLegendSymbol = false; + if( aObjectType == OBJECTTYPE_DATA_LABELS ) + { + uno::Reference< chart2::XDataSeries > xSeries( ObjectIdentifier::getDataSeriesForCID( aCID, m_aModel->getModel() )); + ::chart::DataSeriesHelper::setPropertyAlsoToAllAttributedDataPoints( xSeries, C2U( "Label" ), uno::makeAny(aLabel) ); + } + else + xObjectProperties->setPropertyValue( C2U( "Label" ), uno::makeAny(aLabel) ); + bReturn = true; + aUndoGuard.commitAction(); + } + break; + } + + default: + { + break; + } + } + } + else + { + //remove additional shape + uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() ); + if( xShape.is() ) + { + impl_ClearSelection(); + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + if( m_pDrawViewWrapper ) + m_pDrawViewWrapper->UnmarkAll(); + } + bReturn = DrawModelWrapper::removeShape( xShape ); + } + } + return bReturn; +} + +void ChartController::executeDispatch_ToggleLegend() +{ + Reference< frame::XModel > xModel( m_aModel->getModel()); + UndoGuard aUndoGuard = UndoGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_LEGEND ))), m_xUndoManager, xModel ); + Reference< beans::XPropertySet > xLegendProp( LegendHelper::getLegend( xModel ), uno::UNO_QUERY ); + bool bChanged = false; + if( xLegendProp.is()) + { + try + { + bool bShow = false; + if( xLegendProp->getPropertyValue( C2U("Show")) >>= bShow ) + { + xLegendProp->setPropertyValue( C2U("Show"), uno::makeAny( ! bShow )); + bChanged = true; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + else + { + xLegendProp.set( LegendHelper::getLegend( xModel, m_xCC, true ), uno::UNO_QUERY ); + if( xLegendProp.is()) + bChanged = true; + } + + if( bChanged ) + aUndoGuard.commitAction(); +} + +void ChartController::executeDispatch_ToggleGridHorizontal() +{ + Reference< frame::XModel > xModel( m_aModel->getModel()); + UndoGuard aUndoGuard = UndoGuard( + ::rtl::OUString( String( SchResId( STR_ACTION_TOGGLE_GRID_HORZ ))), m_xUndoManager, xModel ); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( m_aModel->getModel())); + if( xDiagram.is()) + { + sal_Int32 nDimensionIndex = 1; + sal_Int32 nCooSysIndex = 0; + bool bIsMainGrid = true; + + bool bHasMainYGrid = AxisHelper::isGridShown( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram ); + + if( bHasMainYGrid ) + AxisHelper::hideGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram ); + else + AxisHelper::showGrid( nDimensionIndex, nCooSysIndex, bIsMainGrid, xDiagram, m_xCC ); + + aUndoGuard.commitAction(); + } +} + +} // namespace chart diff --git a/chart2/source/controller/main/ChartController_Window.cxx b/chart2/source/controller/main/ChartController_Window.cxx new file mode 100644 index 000000000000..951bb127f117 --- /dev/null +++ b/chart2/source/controller/main/ChartController_Window.cxx @@ -0,0 +1,1815 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartController_Window.cxx,v $ + * $Revision: 1.31.24.2 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" +#include "PositionAndSizeHelper.hxx" +#include "ObjectIdentifier.hxx" +#include "ChartWindow.hxx" +#include "ResId.hxx" +#include "CommonConverters.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "TitleHelper.hxx" +#include "UndoGuard.hxx" +#include "ControllerLockGuard.hxx" +#include "ObjectNameProvider.hxx" +#include "Strings.hrc" +#include "SchSlotIds.hxx" +#include "macros.hxx" +#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 "StatisticsHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "ContainerHelper.hxx" +#include "AxisHelper.hxx" +#include "LegendHelper.hxx" +#include "servicenames_charttypes.hxx" + +#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/frame/XDispatchHelper.hpp> +#include <com/sun/star/frame/FrameSearchFlag.hpp> +#include <com/sun/star/util/XUpdatable.hpp> +#include <comphelper/InlineContainer.hxx> + +#include <svtools/contextmenuhelper.hxx> +#include <toolkit/awt/vclxmenu.hxx> + +#include <svx/svxids.hrc> +#include <svx/ActionDescriptionProvider.hxx> + +// header for class E3dObject +#include <svx/obj3d.hxx> +// header for class E3dScene +#include <svx/scene3d.hxx> +// header for class SdrDragMethod +#include <svx/svddrgmt.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +// for InfoBox +#include <vcl/msgbox.hxx> + +#include <rtl/math.hxx> +#include <svtools/acceleratorexecute.hxx> + +#define DRGPIX 2 // Drag MinMove in Pixel + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; +using ::com::sun::star::uno::Reference; +using ::rtl::OUString; + +//............................................................................. +namespace chart +{ +//............................................................................. + +namespace +{ +bool lcl_GrowAndShiftLogic( + RelativePosition & rInOutRelPos, + RelativeSize & rInOutRelSize, + const awt::Size & rRefSize, + double fGrowLogicX, + double fGrowLogicY ) +{ + if( rRefSize.Width == 0 || + rRefSize.Height == 0 ) + return false; + + double fRelativeGrowX = fGrowLogicX / rRefSize.Width; + double fRelativeGrowY = fGrowLogicY / rRefSize.Height; + + return ::chart::RelativePositionHelper::centerGrow( + rInOutRelPos, rInOutRelSize, + fRelativeGrowX, fRelativeGrowY, + /* bCheck = */ true ); +} + +bool lcl_MoveObjectLogic( + RelativePosition & rInOutRelPos, + RelativeSize & rObjectSize, + const awt::Size & rRefSize, + double fShiftLogicX, + double fShiftLogicY ) +{ + if( rRefSize.Width == 0 || + rRefSize.Height == 0 ) + return false; + + double fRelativeShiftX = fShiftLogicX / rRefSize.Width; + double fRelativeShiftY = fShiftLogicY / rRefSize.Height; + + return ::chart::RelativePositionHelper::moveObject( + rInOutRelPos, rObjectSize, + fRelativeShiftX, fRelativeShiftY, + /* bCheck = */ true ); +} + +void lcl_insertMenuCommand( + const uno::Reference< awt::XPopupMenu > & xMenu, + const uno::Reference< awt::XMenuExtended > & xMenuEx, + sal_Int16 nId, const ::rtl::OUString & rCommand ) +{ + static ::rtl::OUString aEmptyString; + xMenu->insertItem( nId, aEmptyString, 0, -1 ); + xMenuEx->setCommand( nId, rCommand ); +} + +OUString lcl_getFormatCommandForObjectCID( const OUString& rCID ) +{ + OUString aDispatchCommand( C2U(".uno:FormatSelection") ); + + ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); + + switch(eObjectType) + { + case OBJECTTYPE_DIAGRAM: + case OBJECTTYPE_DIAGRAM_WALL: + aDispatchCommand = C2U(".uno:FormatWall"); + break; + case OBJECTTYPE_DIAGRAM_FLOOR: + aDispatchCommand = C2U(".uno:FormatFloor"); + break; + case OBJECTTYPE_PAGE: + aDispatchCommand = C2U(".uno:FormatChartArea"); + break; + case OBJECTTYPE_LEGEND: + aDispatchCommand = C2U(".uno:FormatLegend"); + break; + case OBJECTTYPE_TITLE: + aDispatchCommand = C2U(".uno:FormatTitle"); + break; + case OBJECTTYPE_LEGEND_ENTRY: + aDispatchCommand = C2U(".uno:FormatDataSeries"); + break; + case OBJECTTYPE_AXIS: + case OBJECTTYPE_AXIS_UNITLABEL: + aDispatchCommand = C2U(".uno:FormatAxis"); + break; + case OBJECTTYPE_GRID: + aDispatchCommand = C2U(".uno:FormatMajorGrid"); + break; + case OBJECTTYPE_SUBGRID: + aDispatchCommand = C2U(".uno:FormatMinorGrid"); + break; + case OBJECTTYPE_DATA_LABELS: + aDispatchCommand = C2U(".uno:FormatDataLabels"); + break; + case OBJECTTYPE_DATA_SERIES: + aDispatchCommand = C2U(".uno:FormatDataSeries"); + break; + case OBJECTTYPE_DATA_LABEL: + aDispatchCommand = C2U(".uno:FormatDataLabel"); + break; + case OBJECTTYPE_DATA_POINT: + aDispatchCommand = C2U(".uno:FormatDataPoint"); + break; + case OBJECTTYPE_DATA_AVERAGE_LINE: + aDispatchCommand = C2U(".uno:FormatMeanValue"); + break; + case OBJECTTYPE_DATA_ERRORS: + case OBJECTTYPE_DATA_ERRORS_X: + case OBJECTTYPE_DATA_ERRORS_Y: + case OBJECTTYPE_DATA_ERRORS_Z: + aDispatchCommand = C2U(".uno:FormatYErrorBars"); + break; + case OBJECTTYPE_DATA_CURVE: + aDispatchCommand = C2U(".uno:FormatTrendline"); + break; + case OBJECTTYPE_DATA_CURVE_EQUATION: + aDispatchCommand = C2U(".uno:FormatTrendlineEquation"); + break; + case OBJECTTYPE_DATA_STOCK_RANGE: + aDispatchCommand = C2U(".uno:FormatSelection"); + break; + case OBJECTTYPE_DATA_STOCK_LOSS: + aDispatchCommand = C2U(".uno:FormatStockLoss"); + break; + case OBJECTTYPE_DATA_STOCK_GAIN: + aDispatchCommand = C2U(".uno:FormatStockGain"); + break; + default: //OBJECTTYPE_UNKNOWN + break; + } + return aDispatchCommand; +} + +} // anonymous namespace + +const short HITPIX=2; //hit-tolerance in pixel + +//----------------------------------------------------------------- +// awt::XWindow +//----------------------------------------------------------------- + void SAL_CALL ChartController +::setPosSize( sal_Int32 X, sal_Int32 Y + , sal_Int32 Width, sal_Int32 Height, sal_Int16 Flags ) + throw (uno::RuntimeException) +{ + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + Window* pWindow = m_pChartWindow; + + if(xWindow.is() && pWindow) + { + Size aLogicSize = pWindow->PixelToLogic( Size( Width, Height ), MapMode( MAP_100TH_MM ) ); + + bool bIsEmbedded = true; + //todo: for standalone chart: detect wether we are standalone + if( bIsEmbedded ) + { + //change map mode to fit new size + awt::Size aModelPageSize = ChartModelHelper::getPageSize( m_aModel->getModel() ); + sal_Int32 nScaleXNumerator = aLogicSize.Width(); + sal_Int32 nScaleXDenominator = aModelPageSize.Width; + sal_Int32 nScaleYNumerator = aLogicSize.Height(); + sal_Int32 nScaleYDenominator = aModelPageSize.Height; + MapMode aNewMapMode( MAP_100TH_MM, Point(0,0) + , Fraction(nScaleXNumerator,nScaleXDenominator) + , Fraction(nScaleYNumerator,nScaleYDenominator) ); + pWindow->SetMapMode(aNewMapMode); + pWindow->SetPosSizePixel( X, Y, Width, Height, 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() ) + { + uno::Sequence< beans::PropertyValue > aZoomFactors(4); + aZoomFactors[0].Name = C2U("ScaleXNumerator"); + aZoomFactors[0].Value = uno::makeAny( nScaleXNumerator ); + aZoomFactors[1].Name = C2U("ScaleXDenominator"); + aZoomFactors[1].Value = uno::makeAny( nScaleXDenominator ); + aZoomFactors[2].Name = C2U("ScaleYNumerator"); + aZoomFactors[2].Value = uno::makeAny( nScaleYNumerator ); + aZoomFactors[3].Name = C2U("ScaleYDenominator"); + aZoomFactors[3].Value = uno::makeAny( nScaleYDenominator ); + xProp->setPropertyValue( C2U("ZoomFactors"), uno::makeAny( aZoomFactors )); + } + + //a correct work area is at least necessary for correct values in the position and size dialog and for dragging area + if(m_pDrawViewWrapper) + { + Rectangle aRect(Point(0,0), pWindow->GetOutputSize()); + m_pDrawViewWrapper->SetWorkArea( aRect ); + } + } + else + { + //change visarea + ChartModelHelper::setPageSize( awt::Size( aLogicSize.Width(), aLogicSize.Height() ), m_aModel->getModel() ); + pWindow->SetPosSizePixel( X, Y, Width, Height, Flags ); + } + pWindow->Invalidate(); + } +} + + awt::Rectangle SAL_CALL ChartController +::getPosSize() + throw (uno::RuntimeException) +{ + //@todo + awt::Rectangle aRet(0,0,0,0); + + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + if(xWindow.is()) + aRet = xWindow->getPosSize(); + + return aRet; +} + + void SAL_CALL ChartController +::setVisible( sal_Bool Visible ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->setVisible( Visible ); +} + + void SAL_CALL ChartController +::setEnable( sal_Bool Enable ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->setEnable( Enable ); +} + + void SAL_CALL ChartController +::setFocus() throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->setFocus(); +} + + void SAL_CALL ChartController +::addWindowListener( const uno::Reference< + awt::XWindowListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addWindowListener( xListener ); +} + + void SAL_CALL ChartController +::removeWindowListener( const uno::Reference< + awt::XWindowListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removeWindowListener( xListener ); +} + + void SAL_CALL ChartController +::addFocusListener( const uno::Reference< + awt::XFocusListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addFocusListener( xListener ); +} + + void SAL_CALL ChartController +::removeFocusListener( const uno::Reference< + awt::XFocusListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removeFocusListener( xListener ); +} + + void SAL_CALL ChartController +::addKeyListener( const uno::Reference< + awt::XKeyListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addKeyListener( xListener ); +} + + void SAL_CALL ChartController +::removeKeyListener( const uno::Reference< + awt::XKeyListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removeKeyListener( xListener ); +} + + void SAL_CALL ChartController +::addMouseListener( const uno::Reference< + awt::XMouseListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addMouseListener( xListener ); +} + + void SAL_CALL ChartController +::removeMouseListener( const uno::Reference< + awt::XMouseListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removeMouseListener( xListener ); +} + + void SAL_CALL ChartController +::addMouseMotionListener( const uno::Reference< + awt::XMouseMotionListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addMouseMotionListener( xListener ); +} + + void SAL_CALL ChartController +::removeMouseMotionListener( const uno::Reference< + awt::XMouseMotionListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removeMouseMotionListener( xListener ); +} + + void SAL_CALL ChartController +::addPaintListener( const uno::Reference< + awt::XPaintListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->addPaintListener( xListener ); +} + + void SAL_CALL ChartController +::removePaintListener( const uno::Reference< + awt::XPaintListener >& xListener ) + throw (uno::RuntimeException) +{ + //@todo + uno::Reference<awt::XWindow> xWindow = m_xViewWindow; + + if(xWindow.is()) + xWindow->removePaintListener( xListener ); +} + +//----------------------------------------------------------------- +// impl vcl window controller methods +//----------------------------------------------------------------- +void ChartController::PrePaint() +{ + // forward VCLs PrePaint window event to DrawingLayer + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + + if(pDrawViewWrapper) + { + pDrawViewWrapper->PrePaint(); + } +} + +void ChartController::execute_Paint( const Rectangle& rRect ) +{ + try + { + //better performance for big data + uno::Reference< beans::XPropertySet > xProp( m_xChartView, uno::UNO_QUERY ); + if( xProp.is() ) + { + awt::Size aResolution(1000,1000); + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( m_pChartWindow ) + { + aResolution.Width = m_pChartWindow->GetSizePixel().Width(); + aResolution.Height = m_pChartWindow->GetSizePixel().Height(); + } + } + xProp->setPropertyValue( C2U("Resolution"), uno::makeAny( aResolution )); + } + // + + uno::Reference< util::XUpdatable > xUpdatable( m_xChartView, uno::UNO_QUERY ); + if( xUpdatable.is() ) + xUpdatable->update(); + + Window* pWindow = m_pChartWindow; + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(pDrawViewWrapper) + pDrawViewWrapper->CompleteRedraw(pWindow, Region(rRect) ); + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + catch( ... ) + { + } +} + +bool isDoubleClick( const MouseEvent& rMEvt ) +{ + return rMEvt.GetClicks() == 2 && rMEvt.IsLeft() && + !rMEvt.IsMod1() && !rMEvt.IsMod2() && !rMEvt.IsShift(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +void ChartController::startDoubleClickWaiting() +{ + m_bWaitingForDoubleClick = true; + + ULONG nDblClkTime = 500; + if( m_pChartWindow ) + { + const MouseSettings& rMSettings = m_pChartWindow->GetSettings().GetMouseSettings(); + nDblClkTime = rMSettings.GetDoubleClickTime(); + } + m_aDoubleClickTimer.SetTimeout( nDblClkTime ); + m_aDoubleClickTimer.Start(); +} + +void ChartController::stopDoubleClickWaiting() +{ + m_aDoubleClickTimer.Stop(); + m_bWaitingForDoubleClick = false; +} + +IMPL_LINK( ChartController, DoubleClickWaitingHdl, void*, EMPTYARG ) +{ + m_bWaitingForDoubleClick = false; + + if( !m_bWaitingForMouseUp && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() ) + { + this->impl_selectObjectAndNotiy(); + if( m_pChartWindow ) + { + Window::PointerState aPointerState( m_pChartWindow->GetPointerState() ); + MouseEvent aMouseEvent( aPointerState.maPos,1/*nClicks*/, + 0/*nMode*/, static_cast< USHORT >( aPointerState.mnState )/*nButtons*/, + 0/*nModifier*/ ); + impl_SetMousePointer( aMouseEvent ); + } + } + + return 0; +} + +//------------------------------------------------------------------------ + +void ChartController::execute_MouseButtonDown( const MouseEvent& rMEvt ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + m_bWaitingForMouseUp = true; + + if( isDoubleClick(rMEvt) ) + stopDoubleClickWaiting(); + else + startDoubleClickWaiting(); + + m_aSelection.remindSelectionBeforeMouseDown(); + + Window* pWindow = m_pChartWindow; + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(!pWindow || !pDrawViewWrapper ) + return; + + Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel()); + + if ( MOUSE_LEFT == rMEvt.GetButtons() ) + { + pWindow->GrabFocus(); + pWindow->CaptureMouse(); + } + + if( pDrawViewWrapper->IsTextEdit() ) + { + if( pDrawViewWrapper->IsTextEditHit( aMPos, HITPIX) ) + { + pDrawViewWrapper->MouseButtonDown(rMEvt,m_pChartWindow); + return; + } + else + { + this->EndTextEdit(); + } + } + + //abort running action + if( pDrawViewWrapper->IsAction() ) + { + if( rMEvt.IsRight() ) + pDrawViewWrapper->BckAction(); + return; + } + + if( isDoubleClick(rMEvt) ) //do not change selection if double click + return;//double click is handled further in mousebutton up + + SdrHdl* pHitSelectionHdl = 0; + //switch from move to resize if handle is hit on a resizeable object + if( m_aSelection.isResizeableObjectSelected() ) + pHitSelectionHdl = pDrawViewWrapper->PickHandle( aMPos ); + //only change selection if no selection handles are hit + if( !pHitSelectionHdl ) + { + m_aSelection.adaptSelectionToNewPos( aMPos, pDrawViewWrapper + , rMEvt.IsRight(), m_bWaitingForDoubleClick ); + + if( !m_aSelection.isRotateableObjectSelected( m_aModel->getModel() ) ) + { + m_eDragMode = SDRDRAG_MOVE; + pDrawViewWrapper->SetDragMode(m_eDragMode); + } + + m_aSelection.applySelection(pDrawViewWrapper); + } + if( m_aSelection.isDragableObjectSelected() + && !rMEvt.IsRight() ) + { + //start drag + USHORT nDrgLog = (USHORT)pWindow->PixelToLogic(Size(DRGPIX,0)).Width(); + SdrDragMethod* pDragMethod = NULL; + + //change selection to 3D scene if rotate mode + SdrDragMode eDragMode = pDrawViewWrapper->GetDragMode(); + if( SDRDRAG_ROTATE==eDragMode ) + { + E3dScene* pScene = SelectionHelper::getSceneToRotate( pDrawViewWrapper->getNamedSdrObject( m_aSelection.getSelectedCID() ) ); + if( pScene ) + { + DragMethod_RotateDiagram::RotationDirection eRotationDirection(DragMethod_RotateDiagram::ROTATIONDIRECTION_FREE); + if(pHitSelectionHdl) + { + SdrHdlKind eKind = pHitSelectionHdl->GetKind(); + if( eKind==HDL_UPPER || eKind==HDL_LOWER ) + eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_X; + else if( eKind==HDL_LEFT || eKind==HDL_RIGHT ) + eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Y; + else if( eKind==HDL_UPLFT || eKind==HDL_UPRGT || eKind==HDL_LWLFT || eKind==HDL_LWRGT ) + eRotationDirection = DragMethod_RotateDiagram::ROTATIONDIRECTION_Z; + } + pDragMethod = new DragMethod_RotateDiagram( *pDrawViewWrapper, m_aSelection.getSelectedCID(), m_aModel->getModel(), eRotationDirection ); + } + } + else + { + rtl::OUString aDragMethodServiceName( ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ) ); + if( aDragMethodServiceName.equals( ObjectIdentifier::getPieSegmentDragMethodServiceName() ) ) + pDragMethod = new DragMethod_PieSegment( *pDrawViewWrapper, m_aSelection.getSelectedCID(), m_aModel->getModel() ); + } + pDrawViewWrapper->SdrView::BegDragObj(aMPos, NULL, pHitSelectionHdl, nDrgLog, pDragMethod); + } + + impl_SetMousePointer( rMEvt ); +} + +void ChartController::execute_MouseMove( const MouseEvent& rMEvt ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + Window* pWindow = m_pChartWindow; + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(!pWindow || !pDrawViewWrapper) + return; + + if( m_pDrawViewWrapper->IsTextEdit() ) + { + if( m_pDrawViewWrapper->MouseMove(rMEvt,m_pChartWindow) ) + return; + } + + if(pDrawViewWrapper->IsAction()) + { + pDrawViewWrapper->MovAction( pWindow->PixelToLogic( rMEvt.GetPosPixel() ) ); + } + + //?? pDrawViewWrapper->GetPageView()->DragPoly(); + + impl_SetMousePointer( rMEvt ); +} +void ChartController::execute_Tracking( const TrackingEvent& /* rTEvt */ ) +{ +} + +//----------------- + +void ChartController::execute_MouseButtonUp( const MouseEvent& rMEvt ) +{ + ControllerLockGuard aCLGuard( m_aModel->getModel()); + m_bWaitingForMouseUp = false; + bool bNotifySelectionChange = false; + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + + Window* pWindow = m_pChartWindow; + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(!pWindow || !pDrawViewWrapper) + return; + + Point aMPos = pWindow->PixelToLogic(rMEvt.GetPosPixel()); + + if(pDrawViewWrapper->IsTextEdit()) + { + if( pDrawViewWrapper->MouseButtonUp(rMEvt,m_pChartWindow) ) + return; + } + + if(pDrawViewWrapper->IsDragObj()) + { + bool bDraggingDone = false; + SdrDragMethod* pDragMethod = pDrawViewWrapper->SdrView::GetDragMethod(); + bool bIsMoveOnly = pDragMethod ? pDragMethod->getMoveOnly() : false; + DragMethod_Base* pChartDragMethod = dynamic_cast< DragMethod_Base* >(pDragMethod); + if( pChartDragMethod ) + { + UndoGuard aUndoGuard( pChartDragMethod->getUndoDescription(), + m_xUndoManager, m_aModel->getModel() ); + + if( pDrawViewWrapper->EndDragObj(false) ) + { + bDraggingDone = true; + aUndoGuard.commitAction(); + } + } + + if( !bDraggingDone && pDrawViewWrapper->EndDragObj(false) ) + { + try + { + //end move or size + SdrObject* pObj = pDrawViewWrapper->getSelectedObject(); + if( pObj ) + { + Rectangle aObjectRect = pObj->GetSnapRect(); + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel() ) ); + Rectangle aPageRect( 0,0,aPageSize.Width,aPageSize.Height ); + + const E3dObject* pE3dObject = dynamic_cast< const E3dObject*>( pObj ); + if( pE3dObject ) + aObjectRect = pE3dObject->GetScene()->GetSnapRect(); + + ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE); + if( !bIsMoveOnly && m_aSelection.isResizeableObjectSelected() ) + eActionType = ActionDescriptionProvider::RESIZE; + + UndoGuard aUndoGuard( + ActionDescriptionProvider::createDescription( + eActionType, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ))), + m_xUndoManager, m_aModel->getModel() ); + bool bChanged = PositionAndSizeHelper::moveObject( m_aSelection.getSelectedCID() + , m_aModel->getModel() + , awt::Rectangle(aObjectRect.getX(),aObjectRect.getY(),aObjectRect.getWidth(),aObjectRect.getHeight()) + , awt::Rectangle(aPageRect.getX(),aPageRect.getY(),aPageRect.getWidth(),aPageRect.getHeight()) + , m_xChartView ); + if( bChanged ) + { + bDraggingDone = true; + aUndoGuard.commitAction(); + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + //all wanted model changes will take effect + //and all unwanted view modifications are cleaned + } + + if( !bDraggingDone ) //mouse wasn't moved while dragging + { + bool bClickedTwiceOnDragableObject = SelectionHelper::isDragableObjectHitTwice( aMPos, m_aSelection.getSelectedCID(), *pDrawViewWrapper ); + bool bIsRotateable = m_aSelection.isRotateableObjectSelected( m_aModel->getModel() ); + + //toggel between move and rotate + if( bIsRotateable && bClickedTwiceOnDragableObject && SDRDRAG_MOVE==m_eDragMode ) + m_eDragMode=SDRDRAG_ROTATE; + else + m_eDragMode=SDRDRAG_MOVE; + + pDrawViewWrapper->SetDragMode(m_eDragMode); + + if( !m_bWaitingForDoubleClick && m_aSelection.maybeSwitchSelectionAfterSingleClickWasEnsured() ) + { + this->impl_selectObjectAndNotiy(); + } + } + else + m_aSelection.resetPossibleSelectionAfterSingleClickWasEnsured(); + } + else if( isDoubleClick(rMEvt) ) + execute_DoubleClick(); + + //@todo ForcePointer(&rMEvt); + pWindow->ReleaseMouse(); + + if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) + bNotifySelectionChange = true; + } + + impl_SetMousePointer( rMEvt ); + + if(bNotifySelectionChange) + impl_notifySelectionChangeListeners(); +} + +void ChartController::execute_DoubleClick() +{ + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + if( OBJECTTYPE_TITLE==eObjectType ) + executeDispatch_EditText(); + else + executeDispatch_ObjectProperties(); +} + +void ChartController::execute_Resize() +{ + m_pChartWindow->Invalidate(); +} +void ChartController::execute_Activate() +{ + ///// pDrawViewWrapper->SetEditMode(TRUE); +} +void ChartController::execute_Deactivate() +{ + /* + pDrawViewWrapper->SetEditMode(FALSE); + this->ReleaseMouse(); + */ +} +void ChartController::execute_GetFocus() +{ +} +void ChartController::execute_LoseFocus() +{ + //this->ReleaseMouse(); +} + +void ChartController::execute_Command( const CommandEvent& rCEvt ) +{ + Window* pWindow = m_pChartWindow; + + bool bIsAction = false; + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(!pWindow || !pDrawViewWrapper) + return; + bIsAction = m_pDrawViewWrapper->IsAction(); + } + + // pop-up menu + if(rCEvt.GetCommand() == COMMAND_CONTEXTMENU && !bIsAction) + { + m_pChartWindow->ReleaseMouse(); + + if( m_aSelection.isSelectionDifferentFromBeforeMouseDown() ) + impl_notifySelectionChangeListeners(); + + // todo: the context menu should be specified by an xml file in uiconfig + uno::Reference< awt::XPopupMenu > xPopupMenu( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); + uno::Reference< awt::XMenuExtended > xMenuEx( xPopupMenu, uno::UNO_QUERY ); + if( xPopupMenu.is() && xMenuEx.is()) + { + sal_Int16 nUniqueId = 1; + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + Reference< XDiagram > xDiagram = ChartModelHelper::findDiagram( m_aModel->getModel() ); + + OUString aFormatCommand( lcl_getFormatCommandForObjectCID( m_aSelection.getSelectedCID() ) ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, aFormatCommand ); + + //some commands for dataseries and points: + //----- + if( OBJECTTYPE_DATA_SERIES == eObjectType || OBJECTTYPE_DATA_POINT == eObjectType ) + { + bool bIsPoint = ( OBJECTTYPE_DATA_POINT == eObjectType ); + uno::Reference< XDataSeries > xSeries = ObjectIdentifier::getDataSeriesForCID( m_aSelection.getSelectedCID(), m_aModel->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, true ); + 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; + + Reference< beans::XPropertySet > xSeriesProperties( xSeries, uno::UNO_QUERY ); + if( xSeriesProperties.is() ) + { + uno::Sequence< sal_Int32 > aAttributedDataPointIndexList; + if( xSeriesProperties->getPropertyValue( C2U( "AttributedDataPoints" ) ) >>= aAttributedDataPointIndexList ) + { + if( aAttributedDataPointIndexList.hasElements() ) + { + if( bIsPoint ) + { + ::std::vector< sal_Int32 > aIndices( ContainerHelper::SequenceToVector( aAttributedDataPointIndexList ) ); + ::std::vector< sal_Int32 >::iterator aIt = ::std::find( aIndices.begin(), aIndices.end(), nPointIndex ); + if( aIt != aIndices.end()) + bSelectedPointIsFormatted = true; + else + bHasFormattedDataPointsOtherThanSelected = true; + } + else + bHasFormattedDataPointsOtherThanSelected = true; + } + } + } + + //const sal_Int32 nIdBeforeFormat = nUniqueId; + if( bIsPoint ) + { + if( bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabel") ); + if( !bHasDataLabelAtPoint ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabel") ); + else + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabel") ); + if( bSelectedPointIsFormatted ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetDataPoint")); + + xPopupMenu->insertSeparator( -1 ); + + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataSeries") ); + } + + Reference< chart2::XChartType > xChartType( DiagramHelper::getChartTypeOfSeries( xDiagram, xSeries ) ); + if( xChartType->getChartType().equals(CHART2_SERVICE_NAME_CHARTTYPE_CANDLESTICK) ) + { + try + { + Reference< beans::XPropertySet > xChartTypeProp( xChartType, uno::UNO_QUERY ); + if( xChartTypeProp.is() ) + { + bool bJapaneseStyle = false; + xChartTypeProp->getPropertyValue( C2U( "Japanese" ) ) >>= bJapaneseStyle; + + if( bJapaneseStyle ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") ); + } + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + if( bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatDataLabels") ); + if( xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendline") ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMeanValue") ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatYErrorBars") ); + + //if( nIdBeforeFormat != nUniqueId ) + xPopupMenu->insertSeparator( -1 ); + + //const sal_Int32 nIdBeforeInsert = nUniqueId; + + if( !bHasDataLabelsAtSeries ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertDataLabels") ); + if( !xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendline") ); + else if( !bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") ); + if( !xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMeanValue") ); + if( !bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertYErrorBars") ); + + //if( nIdBeforeInsert != nUniqueId ) + // xPopupMenu->insertSeparator( -1 ); + + //const sal_Int32 nIdBeforeDelete = nUniqueId; + + if( bHasDataLabelsAtSeries || ( bHasDataLabelsAtPoints && bHasFormattedDataPointsOtherThanSelected ) ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteDataLabels") ); + if( xTrendline.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendline") ); + if( bHasEquation ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") ); + if( xMeanValue.is() ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMeanValue") ); + if( bHasYErrorBars ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteYErrorBars") ); + + if( bHasFormattedDataPointsOtherThanSelected ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:ResetAllDataPoints")); + + //if( nIdBeforeDelete != nUniqueId ) + xPopupMenu->insertSeparator( -1 ); + + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId, C2U(".uno:ArrangeRow")); + uno::Reference< awt::XPopupMenu > xArrangePopupMenu( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.awt.PopupMenu"), m_xCC ), uno::UNO_QUERY ); + uno::Reference< awt::XMenuExtended > xArrangeMenuEx( xArrangePopupMenu, uno::UNO_QUERY ); + if( xArrangePopupMenu.is() && xArrangeMenuEx.is()) + { + sal_Int16 nSubId = nUniqueId + 1; + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId++, C2U(".uno:Forward") ); + lcl_insertMenuCommand( xArrangePopupMenu, xArrangeMenuEx, nSubId, C2U(".uno:Backward") ); + xPopupMenu->setPopupMenu( nUniqueId, xArrangePopupMenu ); + nUniqueId = nSubId; + } + ++nUniqueId; + } + else if( OBJECTTYPE_DATA_CURVE == eObjectType ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTrendlineEquationAndR2") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteTrendlineEquation") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") ); + } + else if( OBJECTTYPE_DATA_CURVE_EQUATION == eObjectType ) + { + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertR2Value") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteR2Value") ); + } + + //some commands for axes: and grids + //----- + else if( OBJECTTYPE_AXIS == eObjectType || OBJECTTYPE_GRID == eObjectType || OBJECTTYPE_SUBGRID == eObjectType ) + { + Reference< XAxis > xAxis = ObjectIdentifier::getAxisForCID( m_aSelection.getSelectedCID(), m_aModel->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() ).getLength()>0; + + if( OBJECTTYPE_AXIS != eObjectType && bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatAxis") ); + if( OBJECTTYPE_GRID != eObjectType && bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMajorGrid") ); + if( OBJECTTYPE_SUBGRID != eObjectType && bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatMinorGrid") ); + + xPopupMenu->insertSeparator( -1 ); + + if( OBJECTTYPE_AXIS != eObjectType && !bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxis") ); + if( OBJECTTYPE_GRID != eObjectType && !bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMajorGrid") ); + if( OBJECTTYPE_SUBGRID != eObjectType && !bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertMinorGrid") ); + if( !bHasTitle ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertAxisTitle") ); + + if( bIsAxisVisible ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteAxis") ); + if( bIsMajorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMajorGrid") ); + if( bIsMinorGridVisible && !bIsSecondaryAxis ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteMinorGrid") ); + } + } + + if( OBJECTTYPE_DATA_STOCK_LOSS == eObjectType ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockGain") ); + else if( OBJECTTYPE_DATA_STOCK_GAIN == eObjectType ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:FormatStockLoss") ); + + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:TransformDialog")); + + if( OBJECTTYPE_PAGE == eObjectType || OBJECTTYPE_DIAGRAM == eObjectType + || OBJECTTYPE_DIAGRAM_WALL == eObjectType + || OBJECTTYPE_DIAGRAM_FLOOR == eObjectType + || OBJECTTYPE_UNKNOWN == eObjectType ) + { + if( OBJECTTYPE_UNKNOWN != eObjectType ) + xPopupMenu->insertSeparator( -1 ); + bool bHasLegend = LegendHelper::hasLegend( xDiagram ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertTitles") ); + if( !bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertLegend") ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:InsertRemoveAxes") ); + if( bHasLegend ) + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DeleteLegend") ); + } + //----- + + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramType")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DataRanges")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:DiagramData")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:View3D")); + xPopupMenu->insertSeparator( -1 ); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Cut")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Copy")); + lcl_insertMenuCommand( xPopupMenu, xMenuEx, nUniqueId++, C2U(".uno:Paste")); + + ::svt::ContextMenuHelper aContextMenuHelper( m_xFrame ); + Point aPos( rCEvt.GetMousePosPixel() ); + if( !rCEvt.IsMouseEvent() ) + aPos = m_pChartWindow->GetPointerState().maPos; + aContextMenuHelper.completeAndExecute( aPos, xPopupMenu ); + } + } + else if( ( rCEvt.GetCommand() == COMMAND_STARTEXTTEXTINPUT ) || + ( rCEvt.GetCommand() == COMMAND_EXTTEXTINPUT ) || + ( rCEvt.GetCommand() == COMMAND_ENDEXTTEXTINPUT ) || + ( rCEvt.GetCommand() == COMMAND_INPUTCONTEXTCHANGE ) ) + { + //#i84417# enable editing with IME + if( m_pDrawViewWrapper ) + m_pDrawViewWrapper->Command( rCEvt, m_pChartWindow ); + } +} + +bool ChartController::execute_KeyInput( const KeyEvent& rKEvt ) +{ + bool bReturn=false; + + Window* pWindow = m_pChartWindow; + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if(!pWindow || !pDrawViewWrapper) + return bReturn; + + // handle accelerators + if( ! m_apAccelExecute.get() && m_xFrame.is() && m_xCC.is() && m_xCC->getServiceManager().is() ) + { + m_apAccelExecute.reset( ::svt::AcceleratorExecute::createAcceleratorHelper()); + OSL_ASSERT( m_apAccelExecute.get()); + if( m_apAccelExecute.get() ) + m_apAccelExecute->init( + uno::Reference< lang::XMultiServiceFactory >( m_xCC->getServiceManager(), uno::UNO_QUERY ), m_xFrame ); + } + + KeyCode aKeyCode( rKEvt.GetKeyCode()); + sal_uInt16 nCode = aKeyCode.GetCode(); +// bool bShift = aKeyCode.IsShift(); + bool bAlternate = aKeyCode.IsMod2(); + + if( m_apAccelExecute.get() ) + bReturn = m_apAccelExecute->execute( aKeyCode ); + if( bReturn ) + return bReturn; + + if( pDrawViewWrapper->IsTextEdit() ) + { + if( pDrawViewWrapper->KeyInput(rKEvt,pWindow) ) + { + bReturn = true; + if( nCode == KEY_ESCAPE ) + { + this->EndTextEdit(); + } + } + } + + //if( m_pDrawViewWrapper->IsAction() ); + + // keyboard accessibility + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelection.getSelectedCID() ); + if( ! bReturn ) + { + // Natvigation (Tab/F3/Home/End) + uno::Reference< XChartDocument > xChartDoc( m_aModel->getModel(), uno::UNO_QUERY ); + ObjectKeyNavigation aObjNav( m_aSelection.getSelectedCID(), xChartDoc, ExplicitValueProvider::getExplicitValueProvider( m_xChartView )); + awt::KeyEvent aKeyEvent( ::svt::AcceleratorExecute::st_VCLKey2AWTKey( aKeyCode )); + bReturn = aObjNav.handleKeyEvent( aKeyEvent ); + if( bReturn ) + { + ::rtl::OUString aNewCID = aObjNav.getCurrentSelection(); + uno::Any aNewSelection; + if( aNewCID.getLength()>0 && !ObjectHierarchy::isRootNode( aNewCID )) + aNewSelection <<= aNewCID; + if( m_eDragMode == SDRDRAG_ROTATE && !SelectionHelper::isRotateableObject( aNewCID, m_aModel->getModel() ) ) + m_eDragMode = SDRDRAG_MOVE; + bReturn = select( aNewSelection ); + } + } + + // Position and Size (+/-/arrow-keys) or pie segment dragging + if( ! bReturn ) + { + // pie segment dragging + // note: could also be done for data series + if( eObjectType == OBJECTTYPE_DATA_POINT && + ObjectIdentifier::getDragMethodServiceName( m_aSelection.getSelectedCID() ).equals( + ObjectIdentifier::getPieSegmentDragMethodServiceName())) + { + bool bDrag = false; + bool bDragInside = false; + if( nCode == KEY_ADD || + nCode == KEY_SUBTRACT ) + { + bDrag = true; + bDragInside = ( nCode == KEY_SUBTRACT ); + } + else if( + nCode == KEY_LEFT || + nCode == KEY_RIGHT || + nCode == KEY_UP || + nCode == KEY_DOWN ) + { + bDrag = true; + rtl::OUString aParameter( ObjectIdentifier::getDragParameterString( m_aSelection.getSelectedCID() )); + sal_Int32 nOffsetPercentDummy( 0 ); + awt::Point aMinimumPosition( 0, 0 ); + awt::Point aMaximumPosition( 0, 0 ); + ObjectIdentifier::parsePieSegmentDragParameterString( + aParameter, nOffsetPercentDummy, aMinimumPosition, aMaximumPosition ); + aMaximumPosition.Y -= aMinimumPosition.Y; + aMaximumPosition.X -= aMinimumPosition.X; + + bDragInside = + (nCode == KEY_RIGHT && (aMaximumPosition.X < 0)) || + (nCode == KEY_LEFT && (aMaximumPosition.X > 0)) || + (nCode == KEY_DOWN && (aMaximumPosition.Y < 0)) || + (nCode == KEY_UP && (aMaximumPosition.Y > 0)); + } + + if( bDrag ) + { + double fAmount = bAlternate ? 0.01 : 0.05; + if( bDragInside ) + fAmount *= -1.0; + + bReturn = impl_DragDataPoint( m_aSelection.getSelectedCID(), fAmount ); + } + } + else + { + // size + if( nCode == KEY_ADD || + nCode == KEY_SUBTRACT ) + { + if( eObjectType == OBJECTTYPE_DIAGRAM ) + { + // default 1 mm in each direction + double fGrowAmountX = 200.0; + double fGrowAmountY = 200.0; + if( bAlternate && pWindow ) + { + // together with Alt-key: 1 px in each direction + Size aPixelSize = pWindow->PixelToLogic( Size( 2, 2 )); + fGrowAmountX = static_cast< double >( aPixelSize.Width()); + fGrowAmountY = static_cast< double >( aPixelSize.Height()); + } + if( nCode == KEY_SUBTRACT ) + { + fGrowAmountX = -fGrowAmountX; + fGrowAmountY = -fGrowAmountY; + } + bReturn = impl_moveOrResizeObject( + m_aSelection.getSelectedCID(), CENTERED_RESIZE_OBJECT, fGrowAmountX, fGrowAmountY ); + } + } + // position + else if( nCode == KEY_LEFT || + nCode == KEY_RIGHT || + nCode == KEY_UP || + nCode == KEY_DOWN ) + { + if( m_aSelection.isDragableObjectSelected() ) + { + // default 1 mm + double fShiftAmountX = 100.0; + double fShiftAmountY = 100.0; + if( bAlternate && pWindow ) + { + // together with Alt-key: 1 px + Size aPixelSize = pWindow->PixelToLogic( Size( 1, 1 )); + fShiftAmountX = static_cast< double >( aPixelSize.Width()); + fShiftAmountY = static_cast< double >( aPixelSize.Height()); + } + switch( nCode ) + { + case KEY_LEFT: + fShiftAmountX = -fShiftAmountX; + fShiftAmountY = 0.0; + break; + case KEY_RIGHT: + fShiftAmountY = 0.0; + break; + case KEY_UP: + fShiftAmountX = 0.0; + fShiftAmountY = -fShiftAmountY; + break; + case KEY_DOWN: + fShiftAmountX = 0.0; + break; + } + if( m_aSelection.getSelectedCID().getLength() ) + { + //move chart objects + bReturn = impl_moveOrResizeObject( + m_aSelection.getSelectedCID(), MOVE_OBJECT, fShiftAmountX, fShiftAmountY ); + } + else + { + //move additional shapes + uno::Reference< drawing::XShape > xShape( m_aSelection.getSelectedAdditionalShape() ); + if( xShape.is() ) + { + awt::Point aPos( xShape->getPosition() ); + awt::Size aSize( xShape->getSize() ); + awt::Size aPageSize( ChartModelHelper::getPageSize( m_aModel->getModel() ) ); + aPos.X = static_cast< long >( static_cast< double >( aPos.X ) + fShiftAmountX ); + aPos.Y = static_cast< long >( static_cast< double >( aPos.Y ) + fShiftAmountY ); + if( aPos.X + aSize.Width > aPageSize.Width ) + aPos.X = aPageSize.Width - aSize.Width; + if( aPos.X < 0 ) + aPos.X = 0; + if( aPos.Y + aSize.Height > aPageSize.Height ) + aPos.Y = aPageSize.Height - aSize.Height; + if( aPos.Y < 0 ) + aPos.Y = 0; + + xShape->setPosition( aPos ); + } + } + } + } + } + } + + // text edit + if( ! bReturn && + nCode == KEY_F2 ) + { + if( OBJECTTYPE_TITLE == eObjectType ) + { + executeDispatch_EditText(); + bReturn = true; + } + } + + // deactivate inplace mode (this code should be unnecessary, but + // unfortunately is not) + if( ! bReturn && + nCode == KEY_ESCAPE ) + { + uno::Reference< frame::XDispatchHelper > xDispatchHelper( + m_xCC->getServiceManager()->createInstanceWithContext( + C2U("com.sun.star.frame.DispatchHelper"), m_xCC ), uno::UNO_QUERY ); + if( xDispatchHelper.is()) + { + uno::Sequence< beans::PropertyValue > aArgs; + xDispatchHelper->executeDispatch( + uno::Reference< frame::XDispatchProvider >( m_xFrame, uno::UNO_QUERY ), + C2U(".uno:TerminateInplaceActivation"), + C2U("_parent"), + frame::FrameSearchFlag::PARENT, + aArgs ); + bReturn = true; + } + } + + if( ! bReturn && + (nCode == KEY_DELETE || nCode == KEY_BACKSPACE )) + { + bReturn = executeDispatch_Delete(); + if( ! bReturn ) + { + InfoBox( m_pChartWindow, String(SchResId( STR_ACTION_NOTPOSSIBLE ))).Execute(); + } + } + + /* old chart: + // Ctrl-Shift-R: Repaint + if (!bReturn && GetWindow()) + { + KeyCode aKeyCode = rKEvt.GetKeyCode(); + + if (aKeyCode.IsMod1() && aKeyCode.IsShift() + && aKeyCode.GetCode() == KEY_R) + { + // 3D-Kontext wieder zerstoeren + GetWindow()->Invalidate(); + bReturn = TRUE; + } + } + */ + return bReturn; +} + +bool ChartController::requestQuickHelp( + ::Point aAtLogicPosition, + bool bIsBalloonHelp, + ::rtl::OUString & rOutQuickHelpText, + awt::Rectangle & rOutEqualRect ) +{ + uno::Reference< frame::XModel > xChartModel; + if( m_aModel.is()) + xChartModel.set( m_aModel->getModel()); + if( !xChartModel.is()) + return false; + + // help text + ::rtl::OUString aCID; + if( m_pDrawViewWrapper ) + { + aCID = SelectionHelper::getHitObjectCID( + aAtLogicPosition, *m_pDrawViewWrapper ); + } + bool bResult( aCID.getLength()); + + if( bResult ) + { + // get help text + rOutQuickHelpText = ObjectNameProvider::getHelpText( aCID, xChartModel, bIsBalloonHelp /* bVerbose */ ); + + // set rectangle + ExplicitValueProvider * pValueProvider( + ExplicitValueProvider::getExplicitValueProvider( m_xChartView )); + if( pValueProvider ) + rOutEqualRect = pValueProvider->getRectangleOfObject( aCID, true ); + } + + return bResult; +} + +//----------------------------------------------------------------- +// XSelectionSupplier (optional interface) +//----------------------------------------------------------------- + sal_Bool SAL_CALL ChartController +::select( const uno::Any& rSelection ) + throw( lang::IllegalArgumentException ) +{ + rtl::OUString aNewCID; + if( rSelection.hasValue() && + ! (rSelection >>= aNewCID)) + return sal_False; + + + if( m_aSelection.setSelection( aNewCID ) ) + { + this->impl_selectObjectAndNotiy(); + return sal_True; + } + return sal_False; +} + + uno::Any SAL_CALL ChartController +::getSelection() throw(uno::RuntimeException) +{ + return uno::makeAny(m_aSelection.getSelectedCID()); +} + + void SAL_CALL ChartController +::addSelectionChangeListener( const uno::Reference< + view::XSelectionChangeListener > & xListener ) + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + 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( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener ); +} + + void SAL_CALL ChartController +::removeSelectionChangeListener( const uno::Reference< + view::XSelectionChangeListener > & xListener ) + throw(uno::RuntimeException) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + if( impl_isDisposedOrSuspended() ) //@todo? allow removing of listeners in suspend mode? + return; //behave passive if already disposed or suspended + + //--remove listener + m_aLifeTimeManager.m_aListenerContainer.removeInterface( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0), xListener ); +} + + void ChartController +::impl_notifySelectionChangeListeners() +{ + ::cppu::OInterfaceContainerHelper* pIC = m_aLifeTimeManager.m_aListenerContainer + .getContainer( ::getCppuType((const uno::Reference< view::XSelectionChangeListener >*)0) ); + if( pIC ) + { + uno::Reference< view::XSelectionSupplier > xSelectionSupplier(this); + lang::EventObject aEvent( xSelectionSupplier ); + ::cppu::OInterfaceIteratorHelper aIt( *pIC ); + while( aIt.hasMoreElements() ) + (static_cast< view::XSelectionChangeListener*>(aIt.next()))->selectionChanged( aEvent ); + } +} + +void ChartController::impl_selectObjectAndNotiy() +{ + DrawViewWrapper* pDrawViewWrapper = m_pDrawViewWrapper; + if( pDrawViewWrapper ) + { + pDrawViewWrapper->SetDragMode( m_eDragMode ); + m_aSelection.applySelection( m_pDrawViewWrapper ); + } + impl_notifySelectionChangeListeners(); +} + +bool ChartController::impl_moveOrResizeObject( + const ::rtl::OUString & rCID, + eMoveOrResizeType eType, + double fAmountLogicX, + double fAmountLogicY ) +{ + bool bResult = false; + bool bNeedShift = true; + bool bNeedResize = ( eType == CENTERED_RESIZE_OBJECT ); + + uno::Reference< frame::XModel > xChartModel( m_aModel->getModel()); + uno::Reference< beans::XPropertySet > xObjProp( + ObjectIdentifier::getObjectPropertySet( rCID, xChartModel )); + if( xObjProp.is()) + { + awt::Size aRefSize = ChartModelHelper::getPageSize( xChartModel ); + + chart2::RelativePosition aRelPos; + chart2::RelativeSize aRelSize; + bool bDeterminePos = !(xObjProp->getPropertyValue( C2U("RelativePosition")) >>= aRelPos); + bool bDetermineSize = !bNeedResize || !(xObjProp->getPropertyValue( C2U("RelativeSize")) >>= aRelSize); + + if( ( bDeterminePos || bDetermineSize ) && + ( aRefSize.Width > 0 && aRefSize.Height > 0 ) ) + { + ExplicitValueProvider * pValueProvider( + ExplicitValueProvider::getExplicitValueProvider( m_xChartView )); + if( pValueProvider ) + { + awt::Rectangle aRect( pValueProvider->getRectangleOfObject( rCID )); + double fWidth = static_cast< double >( aRefSize.Width ); + double fHeight = static_cast< double >( aRefSize.Height ); + if( bDetermineSize ) + { + aRelSize.Primary = static_cast< double >( aRect.Width ) / fWidth; + aRelSize.Secondary = static_cast< double >( aRect.Height ) / fHeight; + } + if( bDeterminePos ) + { + if( bNeedResize && aRelSize.Primary > 0.0 && aRelSize.Secondary > 0.0 ) + { + aRelPos.Primary = (static_cast< double >( aRect.X ) / fWidth) + + (aRelSize.Primary / 2.0); + aRelPos.Secondary = (static_cast< double >( aRect.Y ) / fHeight) + + (aRelSize.Secondary / 2.0); + aRelPos.Anchor = drawing::Alignment_CENTER; + } + else + { + aRelPos.Primary = static_cast< double >( aRect.X ) / fWidth; + aRelPos.Secondary = static_cast< double >( aRect.Y ) / fHeight; + aRelPos.Anchor = drawing::Alignment_TOP_LEFT; + } + } + } + } + + if( eType == CENTERED_RESIZE_OBJECT ) + bResult = lcl_GrowAndShiftLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY ); + else if( eType == MOVE_OBJECT ) + bResult = lcl_MoveObjectLogic( aRelPos, aRelSize, aRefSize, fAmountLogicX, fAmountLogicY ); + + if( bResult ) + { + ActionDescriptionProvider::ActionType eActionType(ActionDescriptionProvider::MOVE); + if( bNeedResize ) + eActionType = ActionDescriptionProvider::RESIZE; + + ObjectType eObjectType = ObjectIdentifier::getObjectType( rCID ); + UndoGuard aUndoGuard( ActionDescriptionProvider::createDescription( + eActionType, ObjectNameProvider::getName( eObjectType )), m_xUndoManager, xChartModel ); + { + ControllerLockGuard aCLGuard( xChartModel ); + if( bNeedShift ) + xObjProp->setPropertyValue( C2U("RelativePosition"), uno::makeAny( aRelPos )); + if( bNeedResize || (eObjectType == OBJECTTYPE_DIAGRAM) )//Also set an explicat size at the diagram when an explicit position is set + xObjProp->setPropertyValue( C2U("RelativeSize"), uno::makeAny( aRelSize )); + } + aUndoGuard.commitAction(); + } + } + return bResult; +} + +bool ChartController::impl_DragDataPoint( const ::rtl::OUString & 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, m_aModel->getModel())); + if( xSeries.is()) + { + try + { + uno::Reference< beans::XPropertySet > xPointProp( xSeries->getDataPointByIndex( nDataPointIndex )); + double fOffset = 0.0; + if( xPointProp.is() && + (xPointProp->getPropertyValue( C2U("Offset" )) >>= fOffset ) && + (( fAdditionalOffset > 0.0 && fOffset < 1.0 ) || (fOffset > 0.0)) ) + { + fOffset += fAdditionalOffset; + if( fOffset > 1.0 ) + fOffset = 1.0; + else if( fOffset < 0.0 ) + fOffset = 0.0; + xPointProp->setPropertyValue( C2U("Offset"), uno::makeAny( fOffset )); + bResult = true; + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + + return bResult; +} + +void ChartController::impl_SetMousePointer( const MouseEvent & rEvent ) +{ + ::vos::OGuard aGuard( Application::GetSolarMutex()); + Window* pWindow = m_pChartWindow; + if( m_pDrawViewWrapper && pWindow ) + { + Point aMousePos( pWindow->PixelToLogic( rEvent.GetPosPixel())); + sal_uInt16 nModifier = rEvent.GetModifier(); + BOOL bLeftDown = rEvent.IsLeft(); + + if( m_pDrawViewWrapper->IsTextEdit() ) + { + if( m_pDrawViewWrapper->IsTextEditHit( aMousePos, HITPIX) ) + { + pWindow->SetPointer( m_pDrawViewWrapper->GetPreferedPointer( + aMousePos, pWindow, nModifier, bLeftDown ) ); + return; + } + } + else if( m_pDrawViewWrapper->IsAction() ) + { + return;//don't change pointer during running action + } + + SdrHdl* pHitSelectionHdl = 0; + if( m_aSelection.isResizeableObjectSelected() ) + pHitSelectionHdl = m_pDrawViewWrapper->PickHandle( aMousePos ); + + if( pHitSelectionHdl ) + { + + Pointer aPointer = m_pDrawViewWrapper->GetPreferedPointer( + aMousePos, pWindow, nModifier, bLeftDown ); + bool bForceArrowPointer = false; + + ::rtl::OUString aObjectCID = m_aSelection.getSelectedCID(); + + switch( aPointer.GetStyle()) + { + case POINTER_NSIZE: + case POINTER_SSIZE: + case POINTER_WSIZE: + case POINTER_ESIZE: + case POINTER_NWSIZE: + case POINTER_NESIZE: + case POINTER_SWSIZE: + case POINTER_SESIZE: + if( ! m_aSelection.isResizeableObjectSelected() ) + bForceArrowPointer = true; + break; + case POINTER_MOVE: + if( ! ObjectIdentifier::isDragableObject( aObjectCID )) + bForceArrowPointer = true; + break; + case POINTER_MOVEPOINT: + case POINTER_MOVEBEZIERWEIGHT: + // there is no point-editing in a chart + // the POINTER_MOVEBEZIERWEIGHT appears in 3d data points + bForceArrowPointer = true; + break; + default: + break; + } + + if( bForceArrowPointer ) + pWindow->SetPointer( Pointer( POINTER_ARROW )); + else + pWindow->SetPointer( aPointer ); + } + else + { + ::rtl::OUString aHitObjectCID( + SelectionHelper::getHitObjectCID( + aMousePos, *m_pDrawViewWrapper, true /*bGetDiagramInsteadOf_Wall*/ )); + + if( m_pDrawViewWrapper->IsTextEdit() ) + { + if( aHitObjectCID.equals(m_aSelection.getSelectedCID()) ) + { + pWindow->SetPointer( Pointer( POINTER_ARROW )); + return; + } + } + + if( !aHitObjectCID.getLength() ) + { + //additional shape was hit + pWindow->SetPointer( POINTER_MOVE ); + } + else if( ObjectIdentifier::isDragableObject( aHitObjectCID ) ) + { + if( (m_eDragMode == SDRDRAG_ROTATE) + && SelectionHelper::isRotateableObject( aHitObjectCID + , m_aModel->getModel() ) ) + pWindow->SetPointer( Pointer( POINTER_ROTATE ) ); + else + { + ObjectType eHitObjectType = ObjectIdentifier::getObjectType( aHitObjectCID ); + if( eHitObjectType == OBJECTTYPE_DATA_POINT ) + { + if( !ObjectIdentifier::areSiblings(aHitObjectCID,m_aSelection.getSelectedCID()) + && !ObjectIdentifier::areIdenticalObjects(aHitObjectCID,m_aSelection.getSelectedCID()) ) + { + pWindow->SetPointer( Pointer( POINTER_ARROW )); + return; + } + } + pWindow->SetPointer( POINTER_MOVE ); + } + } + else + pWindow->SetPointer( Pointer( POINTER_ARROW )); + } + } +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartDropTargetHelper.cxx b/chart2/source/controller/main/ChartDropTargetHelper.cxx new file mode 100644 index 000000000000..0a73a1734ac1 --- /dev/null +++ b/chart2/source/controller/main/ChartDropTargetHelper.cxx @@ -0,0 +1,207 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDropTargetHelper.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartDropTargetHelper.hxx" +#include "DiagramHelper.hxx" +#include "DataSourceHelper.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 <vector> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ + +::std::vector< OUString > lcl_getStringsFromByteSequence( + const Sequence< sal_Int8 > & aByteSequence ) +{ + ::std::vector< OUString > aResult; + const sal_Int32 nLength = aByteSequence.getLength(); + const sal_Char * pBytes( reinterpret_cast< const sal_Char* >( aByteSequence.getConstArray())); + sal_Int32 nStartPos = 0; + for( sal_Int32 nPos=0; nPos<nLength; ++nPos ) + { + if( pBytes[nPos] == '\0' ) + { + aResult.push_back( OUString( pBytes + nStartPos, (nPos - nStartPos), RTL_TEXTENCODING_ASCII_US )); + nStartPos = nPos + 1; + } + } + return aResult; +} + +} // anonymous namespace + +namespace chart +{ + +ChartDropTargetHelper::ChartDropTargetHelper( + const Reference< datatransfer::dnd::XDropTarget >& rxDropTarget, + const Reference< chart2::XChartDocument > & xChartDocument ) : + DropTargetHelper( rxDropTarget ), + m_xChartDocument( xChartDocument ) +{} + +ChartDropTargetHelper::~ChartDropTargetHelper() +{} + +bool ChartDropTargetHelper::satisfiesPrerequisites() const +{ + return ( m_xChartDocument.is() && + ! m_xChartDocument->hasInternalDataProvider()); +} + +sal_Int8 ChartDropTargetHelper::AcceptDrop( const AcceptDropEvent& rEvt ) +{ + sal_Int8 nResult = DND_ACTION_NONE; + + if( ( rEvt.mnAction == DND_ACTION_COPY || + rEvt.mnAction == DND_ACTION_MOVE ) && + satisfiesPrerequisites() && + IsDropFormatSupported( SOT_FORMATSTR_ID_LINK ) ) + { + // @todo: check if the data is suitable. Is this possible without XTransferable? + nResult = rEvt.mnAction; + } + + return nResult; +} + +sal_Int8 ChartDropTargetHelper::ExecuteDrop( const ExecuteDropEvent& rEvt ) +{ + sal_Int8 nResult = DND_ACTION_NONE; + + if( ( rEvt.mnAction == DND_ACTION_COPY || + rEvt.mnAction == DND_ACTION_MOVE ) && + rEvt.maDropEvent.Transferable.is() && + satisfiesPrerequisites()) + { + TransferableDataHelper aDataHelper( rEvt.maDropEvent.Transferable ); + if( aDataHelper.HasFormat( SOT_FORMATSTR_ID_LINK )) + { + Sequence< sal_Int8 > aBytes; + if( aDataHelper.GetSequence( SOT_FORMATSTR_ID_LINK, aBytes )) + { + ::std::vector< OUString > aStrings( lcl_getStringsFromByteSequence( aBytes )); + if( aStrings.size() >= 3 && + aStrings[0].equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "soffice" ))) + { + OUString aDocName( aStrings[1] ); + OUString aRangeString( aStrings[2] ); + Reference< container::XChild > xChild( m_xChartDocument, uno::UNO_QUERY ); + if( xChild.is()) + { + Reference< frame::XModel > xParentModel( xChild->getParent(), uno::UNO_QUERY ); + if( xParentModel.is() && + m_xChartDocument.is()) + { + bool bDataComesFromParent = true; + // @todo: get the title somehow and compare it to + // aDocName if successful (the document is the + // parent) + if( bDataComesFromParent ) + { + Reference< chart2::data::XDataProvider > xDataProvider( m_xChartDocument->getDataProvider()); + if( xDataProvider.is() && + DataSourceHelper::allArgumentsForRectRangeDetected( m_xChartDocument )) + { + DiagramHelper::tTemplateWithServiceName aTempWithServ( + DiagramHelper::getTemplateForDiagram( + m_xChartDocument->getFirstDiagram(), + Reference< lang::XMultiServiceFactory >( + m_xChartDocument->getChartTypeManager(), uno::UNO_QUERY ))); + if( aTempWithServ.first.is()) + { + Reference< chart2::data::XDataSource > xDataSource( + DataSourceHelper::pressUsedDataIntoRectangularFormat( m_xChartDocument )); + Sequence< beans::PropertyValue > aArguments( + xDataProvider->detectArguments( xDataSource )); + + OUString aOldRange; + beans::PropertyValue * pCellRange = 0; + for( sal_Int32 i=0; i<aArguments.getLength(); ++i ) + { + if( aArguments[i].Name.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("CellRangeRepresentation"))) + { + pCellRange = (aArguments.getArray() + i); + aArguments[i].Value >>= aOldRange; + break; + } + } + if( pCellRange ) + { + // copy means add ranges, move means replace + if( rEvt.mnAction == DND_ACTION_COPY ) + { + // @todo: using implcit knowledge that ranges can be + // merged with ";". This should be done more general + pCellRange->Value <<= (aOldRange + OUString( sal_Unicode(';')) + aRangeString ); + } + // move means replace range + else + { + pCellRange->Value <<= aRangeString; + } + + xDataSource.set( xDataProvider->createDataSource( aArguments )); + aTempWithServ.first->changeDiagramData( + m_xChartDocument->getFirstDiagram(), + xDataSource, + aArguments ); + + // always return copy state to avoid deletion of the + // dragged range + nResult = DND_ACTION_COPY; + } + } + } + } + } + } + } + } + } + } + return nResult; +} + +} // namespace chart diff --git a/chart2/source/controller/main/ChartDropTargetHelper.hxx b/chart2/source/controller/main/ChartDropTargetHelper.hxx new file mode 100644 index 000000000000..35ab584d88a8 --- /dev/null +++ b/chart2/source/controller/main/ChartDropTargetHelper.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartDropTargetHelper.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_CHARTDROPTARGETHELPER_HXX +#define CHART2_CHARTDROPTARGETHELPER_HXX + +// for DropTargetHelper +#include <svtools/transfer.hxx> + +namespace com { namespace sun { namespace star { +namespace chart2 { + class XChartDocument; +} +}}} + +namespace chart +{ + +class ChartDropTargetHelper : public DropTargetHelper +{ +public: + explicit ChartDropTargetHelper( + const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDropTarget >& rxDropTarget, + const ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XChartDocument > & xChartDocument ); + virtual ~ChartDropTargetHelper(); + +protected: + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); + +private: + // not available + ChartDropTargetHelper(); + + bool satisfiesPrerequisites() const; + + + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XChartDocument > m_xChartDocument; +}; + +} // namespace chart + +// CHART2_CHARTDROPTARGETHELPER_HXX +#endif diff --git a/chart2/source/controller/main/ChartFrameloader.cxx b/chart2/source/controller/main/ChartFrameloader.cxx new file mode 100644 index 000000000000..675c2f3ccd31 --- /dev/null +++ b/chart2/source/controller/main/ChartFrameloader.cxx @@ -0,0 +1,211 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartFrameloader.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartFrameloader.hxx" +#include "servicenames.hxx" +#include "MediaDescriptorHelper.hxx" +#include "macros.hxx" +#include <comphelper/mediadescriptor.hxx> +#include <com/sun/star/document/XImporter.hpp> +#include <com/sun/star/document/XFilter.hpp> +#include <com/sun/star/frame/XLoadable.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; + +ChartFrameLoader::ChartFrameLoader( + uno::Reference<uno::XComponentContext> const & xContext) + : m_bCancelRequired( sal_False ) +{ + m_xCC = xContext; + m_oCancelFinished.reset(); +} + +ChartFrameLoader::~ChartFrameLoader() +{ +} + + sal_Bool ChartFrameLoader +::impl_checkCancel() +{ + if(m_bCancelRequired) + { + m_oCancelFinished.set(); + return sal_True; + } + return sal_False; +} + +//----------------------------------------------------------------- +// lang::XServiceInfo +//----------------------------------------------------------------- + +APPHELPER_XSERVICEINFO_IMPL(ChartFrameLoader,CHART_FRAMELOADER_SERVICE_IMPLEMENTATION_NAME) + + uno::Sequence< rtl::OUString > ChartFrameLoader +::getSupportedServiceNames_Static() +{ + uno::Sequence< rtl::OUString > aSNS( 1 ); + aSNS.getArray()[ 0 ] = CHART_FRAMELOADER_SERVICE_NAME; + return aSNS; +} + +//----------------------------------------------------------------- +// frame::XFrameLoader +//----------------------------------------------------------------- + + sal_Bool SAL_CALL ChartFrameLoader +::load( const uno::Sequence< beans::PropertyValue >& rMediaDescriptor + , const uno::Reference<frame::XFrame >& xFrame ) + throw (uno::RuntimeException) +{ + //@todo ? need to add as terminate listener to desktop? + + uno::Reference< frame::XModel > xModel; + bool bHaveLoadedModel = false; + + comphelper::MediaDescriptor aMediaDescriptor(rMediaDescriptor); + { + comphelper::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( aMediaDescriptor.PROP_MODEL())); + if( aIt != aMediaDescriptor.end()) + { + xModel.set( (*aIt).second.get< uno::Reference< frame::XModel > >()); + bHaveLoadedModel = true; + } + } + + //create and initialize the model + 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 ); + + if( impl_checkCancel() ) + return sal_False; + } + + //create the controller(+XWindow) + uno::Reference< frame::XController > xController = NULL; + uno::Reference< awt::XWindow > xComponentWindow = NULL; + { + xController = uno::Reference< frame::XController >( + 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 simultaniously provides the XWindow controller functionality + xComponentWindow = + uno::Reference< awt::XWindow >( xController, uno::UNO_QUERY ); + + if( impl_checkCancel() ) + return sal_False; + } + + + //connect frame, controller and model one to each other: + if(xController.is()&&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); + } + + // call initNew() or load() at XLoadable + if(!bHaveLoadedModel) + try + { + comphelper::MediaDescriptor::const_iterator aIt( aMediaDescriptor.find( aMediaDescriptor.PROP_URL())); + if( aIt != aMediaDescriptor.end()) + { + ::rtl::OUString aURL( (*aIt).second.get< ::rtl::OUString >()); + if( aURL.matchAsciiL( + RTL_CONSTASCII_STRINGPARAM( "private:factory/schart" ))) + { + // create new file + uno::Reference< frame::XLoadable > xLoadable( xModel, uno::UNO_QUERY_THROW ); + xLoadable->initNew(); + } + 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( xComponentWindow.is() && aMDHelper.ISSET_FilterName && aMDHelper.FilterName.equals( C2U("StarChart 5.0")) ) + { + awt::Rectangle aRect( xComponentWindow->getPosSize() ); + sal_Int16 nFlags=0; + xComponentWindow->setPosSize( aRect.X, aRect.Y, aRect.Width, aRect.Height, nFlags ); + } + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return sal_True; +} + + void SAL_CALL ChartFrameLoader +::cancel() throw (uno::RuntimeException) +{ + m_oCancelFinished.reset(); + m_bCancelRequired = sal_True; + m_oCancelFinished.wait(); + m_bCancelRequired = sal_False; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartFrameloader.hxx b/chart2/source/controller/main/ChartFrameloader.hxx new file mode 100644 index 000000000000..b2e559e7b279 --- /dev/null +++ b/chart2/source/controller/main/ChartFrameloader.hxx @@ -0,0 +1,94 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartFrameloader.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHARTFRAMELOADER_HXX +#define _CHARTFRAMELOADER_HXX + +#include "ServiceMacros.hxx" +#include <osl/conditn.hxx> +#include <com/sun/star/frame/XSynchronousFrameLoader.hpp> +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <cppuhelper/implbase2.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +class ChartFrameLoader : public ::cppu::WeakImplHelper2< + ::com::sun::star::frame::XSynchronousFrameLoader + , ::com::sun::star::lang::XServiceInfo + //comprehends XComponent (required interface) + // ,public ::com::sun::star::uno::XWeak // implemented by WeakImplHelper(optional interface) + // ,public ::com::sun::star::uno::XInterface // implemented by WeakImplHelper(optional interface) + // ,public ::com::sun::star::lang::XTypeProvider // implemented by WeakImplHelper + > +{ +private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; + sal_Bool m_bCancelRequired; + ::osl::Condition m_oCancelFinished; + +private: + sal_Bool impl_checkCancel(); + //no default constructor + ChartFrameLoader(){} +public: + ChartFrameLoader(::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > const & xContext); + virtual ~ChartFrameLoader(); + + //----------------------------------------------------------------- + // ::com::sun::star::lang::XServiceInfo + //----------------------------------------------------------------- + + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(ChartFrameLoader) + + //----------------------------------------------------------------- + // ::com::sun::star::frame::XFrameLoader + //----------------------------------------------------------------- + + virtual sal_Bool SAL_CALL + load( const ::com::sun::star::uno::Sequence< + ::com::sun::star::beans::PropertyValue >& rMediaDescriptor + ,const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XFrame >& xFrame ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void SAL_CALL + cancel() throw (::com::sun::star::uno::RuntimeException); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/main/ChartRenderer.cxx b/chart2/source/controller/main/ChartRenderer.cxx new file mode 100644 index 000000000000..60d13981c00f --- /dev/null +++ b/chart2/source/controller/main/ChartRenderer.cxx @@ -0,0 +1,181 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartRenderer.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartRenderer.hxx" +#include "servicenames.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "chartview/DrawModelWrapper.hxx" +#include "DrawViewWrapper.hxx" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> + +#include <com/sun/star/util/XUpdatable.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using rtl::OUString; + +ChartRenderer::ChartRenderer( const Reference< frame::XModel >& xChartModel ) + : m_xChartModel( uno::WeakReference< frame::XModel >(xChartModel) ) +{ +} + +ChartRenderer::~ChartRenderer() +{ +} + +// ____ ChartPrettyPainter ___ +bool ChartRenderer::DoPaint(OutputDevice* pOutDev, const Rectangle& rLogicObjectRect /*in given output dev map units*/ ) const +{ + if(!pOutDev) + return false; + + Reference<frame::XModel> xModel(m_xChartModel); + uno::Reference< lang::XMultiServiceFactory > xFact( xModel, uno::UNO_QUERY ); + if( !xFact.is() ) + return false; + + //#i84323# ensure that the size the container has of the chart and size that chart has itself are the same + //maybe remove this workaround somewhere in future again + { + if( MAP_100TH_MM == pOutDev->GetMapMode().GetMapUnit() )//no problem for writer in issue #i84323#; but writer uses twips instead of 100thmm which causes small differences in size always when converting to 100thmm and back + { + awt::Size aChartSize( ChartModelHelper::getPageSize(xModel) ); + awt::Size aContainerChartSize( rLogicObjectRect.GetWidth(), rLogicObjectRect.GetHeight() ); + if( aContainerChartSize.Width != aChartSize.Width + || aContainerChartSize.Height != aChartSize.Height ) + { + DBG_ERROR("chart size does not equal size assumed by the container"); + //correct the state here on the fly -> let the container size win + ChartModelHelper::setPageSize( aContainerChartSize, xModel ); + } + } + } + + // get the chart view + Reference< lang::XUnoTunnel > xChartView( xFact->createInstance( CHART_VIEW_SERVICE_NAME ), uno::UNO_QUERY ); + + try + { + //better performance for big data + uno::Reference< beans::XPropertySet > xProp( xChartView, uno::UNO_QUERY ); + if( xProp.is() ) + { + awt::Size aResolution(1000,1000); + { + ::vos::OGuard aGuard( Application::GetSolarMutex()); + Rectangle aPixelRect( pOutDev->LogicToPixel( rLogicObjectRect ) ); + aResolution.Width = aPixelRect.GetWidth(); + aResolution.Height = aPixelRect.GetHeight(); + } + xProp->setPropertyValue( C2U("Resolution"), uno::makeAny( aResolution )); + } + // + + uno::Reference< util::XUpdatable > xUpdatable( xChartView, uno::UNO_QUERY ); + if( xUpdatable.is() ) + xUpdatable->update(); + + ::vos::OGuard aGuard( Application::GetSolarMutex()); + ExplicitValueProvider* pProvider = ExplicitValueProvider::getExplicitValueProvider( xChartView ); + if( !pProvider ) + return false; + ::boost::shared_ptr< DrawModelWrapper > pDrawModelWrapper = pProvider->getDrawModelWrapper(); + if( !pDrawModelWrapper.get() ) + return false; + ::boost::shared_ptr< DrawViewWrapper > pDrawViewWrapper( new DrawViewWrapper(&pDrawModelWrapper->getSdrModel(),pOutDev,false) ); + pDrawViewWrapper->attachParentReferenceDevice( xModel ); + + MapMode aOldMapMode( pOutDev->GetMapMode() ); + Point aOldOrigin( aOldMapMode.GetOrigin() ); + MapMode aMapMode( aOldMapMode ); + Point aOldOriginMM( OutputDevice::LogicToLogic( aOldOrigin, aOldMapMode.GetMapUnit(), MAP_100TH_MM ) ); + Point aObjectTopLeftMM( OutputDevice::LogicToLogic( rLogicObjectRect.TopLeft(), aOldMapMode.GetMapUnit(), MAP_100TH_MM ) ); + aMapMode.SetOrigin( aOldOriginMM + aObjectTopLeftMM ); + aMapMode.SetMapUnit( MAP_100TH_MM ); + pOutDev->SetMapMode(aMapMode); + + Rectangle aPaintRect( OutputDevice::LogicToLogic( rLogicObjectRect, aOldMapMode, aMapMode ) ); + pDrawViewWrapper->CompleteRedraw(pOutDev, Region(aPaintRect) ); + + pOutDev->SetMapMode(aOldMapMode); + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + catch( ... ) + { + } + + return true; +} + +//----------------------------------------------------------------- +// ____ XUnoTunnel ___ +::sal_Int64 SAL_CALL ChartRenderer::getSomething( const Sequence< ::sal_Int8 >& aIdentifier ) + throw( uno::RuntimeException) +{ + if( aIdentifier.getLength() == 16 && 0 == rtl_compareMemory( + ChartPrettyPainter::getUnoTunnelId().getConstArray(), + aIdentifier.getConstArray(), 16 ) ) + { + ChartPrettyPainter* pPaintableObject = this; + return reinterpret_cast<sal_Int64>(pPaintableObject); + } + return 0; +} + +//----------------------------------------------------------------- +// lang::XServiceInfo + +APPHELPER_XSERVICEINFO_IMPL(ChartRenderer,CHART_RENDERER_SERVICE_IMPLEMENTATION_NAME) + +Sequence< OUString > ChartRenderer::getSupportedServiceNames_Static() +{ + Sequence< OUString > aSNS; + return aSNS; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartTransferable.cxx b/chart2/source/controller/main/ChartTransferable.cxx new file mode 100644 index 000000000000..b1caca405dda --- /dev/null +++ b/chart2/source/controller/main/ChartTransferable.cxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartTransferable.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ChartTransferable.hxx" + +#include <vcl/graph.hxx> +#include <svx/svdmodel.hxx> + +// header for class SdrView +#include <svx/svdview.hxx> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +ChartTransferable::ChartTransferable( SdrModel * pDrawModel, SdrObject * pSelectedObj ) +{ + SdrExchangeView * pExchgView( new SdrView( pDrawModel )); + SdrPageView* pPv = pExchgView->ShowSdrPage( pDrawModel->GetPage( 0 )); + if( pSelectedObj ) + pExchgView->MarkObj( pSelectedObj, pPv ); + else + pExchgView->MarkAllObj( pPv ); + Graphic aGraphic( pExchgView->GetMarkedObjMetaFile( TRUE )); + m_xMetaFileGraphic.set( aGraphic.GetXGraphic()); + delete pExchgView; +} + +ChartTransferable::~ChartTransferable() +{} + +void ChartTransferable::AddSupportedFormats() +{ + AddFormat( SOT_FORMAT_GDIMETAFILE ); + AddFormat( SOT_FORMAT_BITMAP ); +} + +sal_Bool ChartTransferable::GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ) +{ + sal_uInt32 nFormat = SotExchange::GetFormat( rFlavor ); + sal_Bool bResult = sal_False; + + if( HasFormat( nFormat )) + { + if( nFormat == FORMAT_GDIMETAFILE ) + { + Graphic aGraphic( m_xMetaFileGraphic ); + bResult = SetGDIMetaFile( aGraphic.GetGDIMetaFile(), rFlavor ); + } + else if( nFormat == FORMAT_BITMAP ) + { + Graphic aGraphic( m_xMetaFileGraphic ); + bResult = SetBitmap( aGraphic.GetBitmap(), rFlavor ); + } + } + + return bResult; +} + + +} // namespace chart diff --git a/chart2/source/controller/main/ChartTransferable.hxx b/chart2/source/controller/main/ChartTransferable.hxx new file mode 100644 index 000000000000..114ec38896f8 --- /dev/null +++ b/chart2/source/controller/main/ChartTransferable.hxx @@ -0,0 +1,66 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartTransferable.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_CHARTTRANSFERABLE_HXX +#define CHART2_CHARTTRANSFERABLE_HXX + +#include <svtools/transfer.hxx> + +namespace com { namespace sun { namespace star { +namespace graphic { + class XGraphic; +} +}}} + +class SdrModel; +class SdrObject; + +namespace chart +{ + +class ChartTransferable : public TransferableHelper +{ +public: + explicit ChartTransferable( SdrModel * pDrawModel, SdrObject * pSelectedObj ); + virtual ~ChartTransferable(); + +protected: + + // implementation of TransferableHelper methods + virtual void AddSupportedFormats(); + virtual sal_Bool GetData( const ::com::sun::star::datatransfer::DataFlavor& rFlavor ); + +private: + ::com::sun::star::uno::Reference< ::com::sun::star::graphic::XGraphic > m_xMetaFileGraphic; +}; + +} // namespace chart + +// CHART2_CHARTTRANSFERABLE_HXX +#endif diff --git a/chart2/source/controller/main/ChartWindow.cxx b/chart2/source/controller/main/ChartWindow.cxx new file mode 100644 index 000000000000..10b999df8f43 --- /dev/null +++ b/chart2/source/controller/main/ChartWindow.cxx @@ -0,0 +1,274 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartWindow.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartWindow.hxx" +#include "ChartController.hxx" +#include "HelpIds.hrc" + +#include <vcl/help.hxx> + +using namespace ::com::sun::star; + +namespace +{ +::Rectangle lcl_AWTRectToVCLRect( const ::com::sun::star::awt::Rectangle & rAWTRect ) +{ + ::Rectangle aResult; + aResult.setX( rAWTRect.X ); + aResult.setY( rAWTRect.Y ); + aResult.setWidth( rAWTRect.Width ); + aResult.setHeight( rAWTRect.Height ); + return aResult; +} +} // anonymous namespace + + +//............................................................................. +namespace chart +{ +//............................................................................. + +ChartWindow::ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ) + : Window(pParent, nStyle) + , m_pWindowController( pWindowController ) + , m_bInPaint(false) +{ + this->SetSmartHelpId( SmartId( HID_SCH_WIN_DOCUMENT ) ); + this->SetMapMode( MapMode(MAP_100TH_MM) ); + adjustHighContrastMode(); + // chart does not depend on exact pixel painting => enable antialiased drawing + SetAntialiasing( ANTIALIASING_ENABLE_B2DDRAW | GetAntialiasing() ); + EnableRTL( FALSE ); + if( pParent ) + pParent->EnableRTL( FALSE );// #i96215# necessary for a correct position of the context menu in rtl mode +} + +ChartWindow::~ChartWindow() +{ +} + +void ChartWindow::clear() +{ + m_pWindowController=0; + this->ReleaseMouse(); +} + +void ChartWindow::PrePaint() +{ + // forward VCLs PrePaint window event to DrawingLayer + if( m_pWindowController ) + { + m_pWindowController->PrePaint(); + } +} + +void ChartWindow::Paint( const Rectangle& rRect ) +{ + m_bInPaint = true; + if( m_pWindowController ) + m_pWindowController->execute_Paint( rRect ); + else + Window::Paint( rRect ); + m_bInPaint = false; +} + +void ChartWindow::MouseButtonDown(const MouseEvent& rMEvt) +{ + if( m_pWindowController ) + m_pWindowController->execute_MouseButtonDown(rMEvt); + else + Window::MouseButtonDown(rMEvt); +} + +void ChartWindow::MouseMove( const MouseEvent& rMEvt ) +{ + if( m_pWindowController ) + m_pWindowController->execute_MouseMove( rMEvt ); + else + Window::MouseMove( rMEvt ); +} + +void ChartWindow::Tracking( const TrackingEvent& rTEvt ) +{ + if( m_pWindowController ) + m_pWindowController->execute_Tracking( rTEvt ); + else + Window::Tracking( rTEvt ); +} + +void ChartWindow::MouseButtonUp( const MouseEvent& rMEvt ) +{ + if( m_pWindowController ) + m_pWindowController->execute_MouseButtonUp( rMEvt ); + else + Window::MouseButtonUp( rMEvt ); +} + +void ChartWindow::Resize() +{ + if( m_pWindowController ) + m_pWindowController->execute_Resize(); + else + Window::Resize(); +} + +void ChartWindow::Activate() +{ + if( m_pWindowController ) + m_pWindowController->execute_Activate(); + else + Window::Activate(); +} +void ChartWindow::Deactivate() +{ + if( m_pWindowController ) + m_pWindowController->execute_Deactivate(); + else + Window::Deactivate(); +} +void ChartWindow::GetFocus() +{ + if( m_pWindowController ) + m_pWindowController->execute_GetFocus(); + else + Window::GetFocus(); +} +void ChartWindow::LoseFocus() +{ + if( m_pWindowController ) + m_pWindowController->execute_LoseFocus(); + else + Window::LoseFocus(); +} + +void ChartWindow::Command( const CommandEvent& rCEvt ) +{ + if( m_pWindowController ) + m_pWindowController->execute_Command( rCEvt ); + else + Window::Command( rCEvt ); +} + +void ChartWindow::KeyInput( const KeyEvent& rKEvt ) +{ + if( m_pWindowController ) + { + if( !m_pWindowController->execute_KeyInput(rKEvt) ) + Window::KeyInput(rKEvt); + } + else + Window::KeyInput( rKEvt ); +} + +uno::Reference< accessibility::XAccessible > ChartWindow::CreateAccessible() +{ + if( m_pWindowController ) + return m_pWindowController->CreateAccessible(); + else + return Window::CreateAccessible(); +} + +void ChartWindow::DataChanged( const DataChangedEvent& rDCEvt ) +{ + ::Window::DataChanged( rDCEvt ); + + if ( (rDCEvt.GetType() == DATACHANGED_SETTINGS) && + (rDCEvt.GetFlags() & SETTINGS_STYLE) ) + { + adjustHighContrastMode(); + } +} + +void ChartWindow::RequestHelp( const HelpEvent& rHEvt ) +{ + bool bHelpHandled = false; + if( ( rHEvt.GetMode() & HELPMODE_QUICK ) && + m_pWindowController ) + { +// Point aLogicHitPos = PixelToLogic( rHEvt.GetMousePosPixel()); // old chart: GetPointerPosPixel() + Point aLogicHitPos = PixelToLogic( GetPointerPosPixel()); + ::rtl::OUString aQuickHelpText; + awt::Rectangle aHelpRect; + bool bIsBalloonHelp( Help::IsBalloonHelpEnabled() ); + bHelpHandled = m_pWindowController->requestQuickHelp( aLogicHitPos, bIsBalloonHelp, aQuickHelpText, aHelpRect ); + + if( bHelpHandled ) + { + if( bIsBalloonHelp ) + Help::ShowBalloon( + this, rHEvt.GetMousePosPixel(), lcl_AWTRectToVCLRect( aHelpRect ), String( aQuickHelpText )); + else + Help::ShowQuickHelp( + this, lcl_AWTRectToVCLRect( aHelpRect ), String( aQuickHelpText )); + } + } + + if( !bHelpHandled ) + ::Window::RequestHelp( rHEvt ); +} + +void ChartWindow::adjustHighContrastMode() +{ + static const sal_Int32 nContrastMode = + DRAWMODE_SETTINGSLINE | DRAWMODE_SETTINGSFILL | + DRAWMODE_SETTINGSTEXT | DRAWMODE_SETTINGSGRADIENT; + + bool bUseContrast = GetSettings().GetStyleSettings().GetHighContrastMode(); + SetDrawMode( bUseContrast ? nContrastMode : DRAWMODE_DEFAULT ); +} + +void ChartWindow::ForceInvalidate() +{ + ::Window::Invalidate(); +} +void ChartWindow::Invalidate( USHORT nFlags ) +{ + if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" + return; + ::Window::Invalidate( nFlags ); +} +void ChartWindow::Invalidate( const Rectangle& rRect, USHORT nFlags ) +{ + if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" + return; + ::Window::Invalidate( rRect, nFlags ); +} +void ChartWindow::Invalidate( const Region& rRegion, USHORT nFlags ) +{ + if( m_bInPaint ) // #i101928# superfluous paint calls while entering and editing charts" + return; + ::Window::Invalidate( rRegion, nFlags ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/ChartWindow.hxx b/chart2/source/controller/main/ChartWindow.hxx new file mode 100644 index 000000000000..543c0b13ffdc --- /dev/null +++ b/chart2/source/controller/main/ChartWindow.hxx @@ -0,0 +1,91 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ChartWindow.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHARTWINDOW_HXX +#define _CHARTWINDOW_HXX + +#include <vcl/window.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + + +class WindowController; + +//----------------------------------------------------------------------------- +/** The ChartWindow collects events from the window and forwards them the to the controller +thus the controller can perform appropriate actions +*/ + +class ChartWindow : public Window +{ +public: + ChartWindow( WindowController* pWindowController, Window* pParent, WinBits nStyle ); + virtual ~ChartWindow(); + + void clear(); + + //from base class Window: + virtual void PrePaint(); + virtual void Paint( const Rectangle& rRect ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void Tracking( const TrackingEvent& rTEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + virtual void Resize(); + virtual void Activate(); + virtual void Deactivate(); + virtual void GetFocus(); + virtual void LoseFocus(); + virtual void Command( const CommandEvent& rCEvt ); + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void DataChanged( const DataChangedEvent& rDCEvt ); + virtual void RequestHelp( const HelpEvent& rHEvt ); + + void ForceInvalidate(); + virtual void Invalidate( USHORT nFlags = 0 ); + virtual void Invalidate( const Rectangle& rRect, USHORT nFlags = 0 ); + virtual void Invalidate( const Region& rRegion, USHORT nFlags = 0 ); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + +private: + WindowController* m_pWindowController; + bool m_bInPaint; + + void adjustHighContrastMode(); +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/main/CommandDispatch.cxx b/chart2/source/controller/main/CommandDispatch.cxx new file mode 100644 index 000000000000..992204c37b96 --- /dev/null +++ b/chart2/source/controller/main/CommandDispatch.cxx @@ -0,0 +1,214 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CommandDispatch.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "CommandDispatch.hxx" +#include "CommonFunctors.hxx" +#include "macros.hxx" + +#include <algorithm> +#include <functional> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ +template< class Map > + struct lcl_DisposeAndClearAndDeleteMapElement : + public ::std::unary_function< typename Map::value_type, void > + { + lcl_DisposeAndClearAndDeleteMapElement( const Reference< uno::XInterface > & xEventSource ) : + m_aEvent( xEventSource ) + {} + void operator() ( typename Map::value_type & rElement ) + { + if( rElement.second ) + { + rElement.second->disposeAndClear( m_aEvent ); + delete rElement.second; + } + } + private: + lang::EventObject m_aEvent; + }; + +template< class Map > + void lcl_DisposeAndClearAndDeleteAllMapElements( + Map & rMap, + const Reference< uno::XInterface > & xEventSource ) +{ + ::std::for_each( rMap.begin(), rMap.end(), + lcl_DisposeAndClearAndDeleteMapElement< Map >( xEventSource )); +} + +} // anonymous namespace + +namespace chart +{ + +CommandDispatch::CommandDispatch( + const Reference< uno::XComponentContext > & xContext ) : + impl::CommandDispatch_Base( m_aMutex ), + m_xContext( xContext ) +{ +} + +CommandDispatch::~CommandDispatch() +{} + +void CommandDispatch::initialize() +{} + +// ____ WeakComponentImplHelperBase ____ +/// is called when this is disposed +void SAL_CALL CommandDispatch::disposing() +{ + lcl_DisposeAndClearAndDeleteAllMapElements( m_aListeners, static_cast< cppu::OWeakObject* >( this )); + m_aListeners.clear(); +} + +// ____ XDispatch ____ +void SAL_CALL CommandDispatch::dispatch( const util::URL& /* URL */, const Sequence< beans::PropertyValue >& /* Arguments */ ) + throw (uno::RuntimeException) +{} + +void SAL_CALL CommandDispatch::addStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) + throw (uno::RuntimeException) +{ + 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 ::cppu::OInterfaceContainerHelper( m_aMutex ))); + } + OSL_ASSERT( aIt != m_aListeners.end()); + + aIt->second->addInterface( Control ); + fireStatusEvent( URL.Complete, Control ); +} + +void SAL_CALL CommandDispatch::removeStatusListener( const Reference< frame::XStatusListener >& Control, const util::URL& URL ) + throw (uno::RuntimeException) +{ + tListenerMap::iterator aIt( m_aListeners.find( URL.Complete )); + if( aIt != m_aListeners.end()) + (*aIt).second->removeInterface( Control ); +} + +// ____ XModifyListener ____ +void SAL_CALL CommandDispatch::modified( const lang::EventObject& /* aEvent */ ) + throw (uno::RuntimeException) +{ + fireAllStatusEvents( 0 ); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL CommandDispatch::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{} + +void CommandDispatch::fireAllStatusEvents( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ) +{ + fireStatusEvent( OUString(), xSingleListener ); +} + +void CommandDispatch::fireStatusEventForURL( + const OUString & rURL, + const uno::Any & rState, + bool bEnabled, + const Reference< frame::XStatusListener > & xSingleListener, /* = 0 */ + const OUString & rFeatureDescriptor /* = OUString() */ ) +{ + // prepare event to send + util::URL aURL; + aURL.Complete = rURL; + if( !m_xURLTransformer.is()) + { + m_xURLTransformer.set( + m_xContext->getServiceManager()->createInstanceWithContext( + C2U( "com.sun.star.util.URLTransformer" ), + m_xContext ), + uno::UNO_QUERY ); + } + if( m_xURLTransformer.is()) + m_xURLTransformer->parseStrict( aURL ); + + frame::FeatureStateEvent aEventToSend( + static_cast< cppu::OWeakObject* >( this ), // Source + aURL, // FeatureURL + rFeatureDescriptor, // FeatureDescriptor + bEnabled, // IsEnabled + false, // Requery + rState // State + ); + + // send event either to single listener or all registered ones + if( xSingleListener.is()) + xSingleListener->statusChanged( aEventToSend ); + else + { + tListenerMap::iterator aIt( m_aListeners.find( aURL.Complete )); + if( aIt != m_aListeners.end()) + { +// ::cppu::OInterfaceContainerHelper * pCntHlp = rBHelper.getContainer( +// ::getCppuType( reinterpret_cast< Reference< frame::XStatusListener > * >(0))); + if( aIt->second ) + { + ::cppu::OInterfaceIteratorHelper 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 & ex ) + { + ASSERT_EXCEPTION( ex ); + } + } + } + } + } +} + + + +} // namespace chart diff --git a/chart2/source/controller/main/CommandDispatch.hxx b/chart2/source/controller/main/CommandDispatch.hxx new file mode 100644 index 000000000000..85a137769268 --- /dev/null +++ b/chart2/source/controller/main/CommandDispatch.hxx @@ -0,0 +1,154 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CommandDispatch.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_COMMANDDISPATCH_HXX +#define CHART2_COMMANDDISPATCH_HXX + +#include "MutexContainer.hxx" +#include <cppuhelper/compbase2.hxx> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/util/XModifyListener.hpp> +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> + +#include <vector> +#include <map> + +namespace chart +{ + +namespace impl +{ +typedef ::cppu::WeakComponentImplHelper2< + ::com::sun::star::frame::XDispatch, + ::com::sun::star::util::XModifyListener > + CommandDispatch_Base; +} + +/** This is the base class for an XDispatch. + */ +class CommandDispatch : + public MutexContainer, + public impl::CommandDispatch_Base +{ +public: + explicit CommandDispatch( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + virtual ~CommandDispatch(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + +protected: + /** sends a status event for a specific command to all registered listeners + or only the one given when set. + + This method should be overloaded. The implementation should call + fireStatusEventForURL and pass the xSingleListener argument to this + method unchanged. + + @param rURL + If empty, all available status events must be fired, otherwise only + the one for the given command. + + @param xSingleListener + If set, the event is only sent to this listener rather than to all + registered ones. Whenever a listener adds itself, this method is + called with this parameter set to give an initial state. + */ + virtual void fireStatusEvent( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ) = 0; + + /** calls fireStatusEvent( ::rtl::OUString, xSingleListener ) + */ + void fireAllStatusEvents( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); + + /** sends a status event for a specific command to all registered listeners + or only the one given when set. + + @param xSingleListener + If set, the event is only sent to this listener rather than to all + registered ones. Whenever a listener adds itself, this method is + called with this parameter set to give an initial state. + */ + void fireStatusEventForURL( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Any & rState, + bool bEnabled, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener = + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >(), + const ::rtl::OUString & rFeatureDescriptor = ::rtl::OUString() ); + + // ____ XDispatch ____ + virtual void SAL_CALL dispatch( + const ::com::sun::star::util::URL& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL addStatusListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control, + const ::com::sun::star::util::URL& URL ) + throw (::com::sun::star::uno::RuntimeException); + virtual void SAL_CALL removeStatusListener( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& Control, + const ::com::sun::star::util::URL& URL ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ WeakComponentImplHelperBase ____ + /// is called when this is disposed + virtual void SAL_CALL disposing(); + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; + +private: + typedef ::std::map< ::rtl::OUString, ::cppu::OInterfaceContainerHelper* > + tListenerMap; + + tListenerMap m_aListeners; + +}; + +} // namespace chart + +// CHART2_COMMANDDISPATCH_HXX +#endif diff --git a/chart2/source/controller/main/CommandDispatchContainer.cxx b/chart2/source/controller/main/CommandDispatchContainer.cxx new file mode 100644 index 000000000000..72e8dcf5ed8e --- /dev/null +++ b/chart2/source/controller/main/CommandDispatchContainer.cxx @@ -0,0 +1,185 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CommandDispatchContainer.cxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "CommandDispatchContainer.hxx" +#include "UndoCommandDispatch.hxx" +#include "StatusBarCommandDispatch.hxx" +#include "DisposeHelper.hxx" +#include "macros.hxx" + +#include <comphelper/InlineContainer.hxx> + +#include <com/sun/star/frame/XDispatchProvider.hpp> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +CommandDispatchContainer::CommandDispatchContainer( + const Reference< uno::XComponentContext > & xContext ) : + m_xContext( xContext ) +{ + m_aContainerDocumentCommands = + ::comphelper::MakeSet< OUString > + ( C2U("AddDirect")) ( C2U("NewDoc")) ( C2U("Open")) + ( C2U("Save")) ( C2U("SaveAs")) ( C2U("SendMail")) + ( C2U("EditDoc")) ( C2U("ExportDirectToPDF")) ( C2U("PrintDefault")) + ; +} + +void CommandDispatchContainer::setModel( + const Reference< frame::XModel > & xModel ) +{ + // remove all existing dispatcher that base on the old model + m_aCachedDispatches.clear(); + DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); + m_aToBeDisposedDispatches.clear(); + m_xModel.set( xModel ); +} + +// void CommandDispatchContainer::setUndoManager( +// const Reference< chart2::XUndoManager > & xUndoManager ) +// { +// m_xUndoManager = xUndoManager; +// } + +void CommandDispatchContainer::setFallbackDispatch( + const Reference< frame::XDispatch > xFallbackDispatch, + const ::std::set< OUString > & rFallbackCommands ) +{ + OSL_ENSURE(xFallbackDispatch.is(),"Invalid fall back dispatcher!"); + m_xFallbackDispatcher.set( xFallbackDispatch ); + m_aFallbackCommands = rFallbackCommands; + m_aToBeDisposedDispatches.push_back( m_xFallbackDispatcher ); +} + +Reference< frame::XDispatch > CommandDispatchContainer::getDispatchForURL( + const util::URL & rURL ) +{ + Reference< frame::XDispatch > xResult; + + tDispatchMap::const_iterator aIt( m_aCachedDispatches.find( rURL.Complete )); + if( aIt != m_aCachedDispatches.end()) + { + xResult.set( (*aIt).second ); + } + else + { + if( rURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" )) + || rURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Redo" ))) + { + CommandDispatch * pDispatch = new UndoCommandDispatch( m_xContext, m_xModel ); + xResult.set( pDispatch ); + pDispatch->initialize(); + m_aCachedDispatches[ C2U(".uno:Undo") ].set( xResult ); + m_aCachedDispatches[ C2U(".uno:Redo") ].set( xResult ); + m_aToBeDisposedDispatches.push_back( xResult ); + } + else if( rURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Context" )) + || rURL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "ModifiedStatus" ))) + { + Reference< view::XSelectionSupplier > xSelSupp; + if( m_xModel.is()) + xSelSupp.set( m_xModel->getCurrentController(), uno::UNO_QUERY ); + CommandDispatch * pDispatch = new StatusBarCommandDispatch( m_xContext, m_xModel, xSelSupp ); + xResult.set( pDispatch ); + pDispatch->initialize(); + m_aCachedDispatches[ C2U(".uno:Context") ].set( xResult ); + m_aCachedDispatches[ C2U(".uno:ModifiedStatus") ].set( xResult ); + m_aToBeDisposedDispatches.push_back( xResult ); + } + else if( m_xModel.is() && + (m_aContainerDocumentCommands.find( rURL.Path ) != m_aContainerDocumentCommands.end()) ) + { + xResult.set( getContainerDispatchForURL( m_xModel->getCurrentController(), rURL )); + // ToDo: can those dispatches be cached? + m_aCachedDispatches[ rURL.Complete ].set( xResult ); + } + else if( m_xFallbackDispatcher.is() && + (m_aFallbackCommands.find( rURL.Path ) != m_aFallbackCommands.end()) ) + { + xResult.set( m_xFallbackDispatcher ); + m_aCachedDispatches[ rURL.Complete ].set( xResult ); + } + } + + return xResult; +} + +Sequence< Reference< frame::XDispatch > > CommandDispatchContainer::getDispatchesForURLs( + const Sequence< frame::DispatchDescriptor > & aDescriptors ) +{ + sal_Int32 nCount = aDescriptors.getLength(); + uno::Sequence< uno::Reference< frame::XDispatch > > aRet( nCount ); + + for( sal_Int32 nPos = 0; nPos < nCount; ++nPos ) + { + if( aDescriptors[ nPos ].FrameName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("_self"))) + aRet[ nPos ] = getDispatchForURL( aDescriptors[ nPos ].FeatureURL ); + } + return aRet; +} + +void CommandDispatchContainer::DisposeAndClear() +{ + m_aCachedDispatches.clear(); + DisposeHelper::DisposeAllElements( m_aToBeDisposedDispatches ); + m_aToBeDisposedDispatches.clear(); + m_xFallbackDispatcher.clear(); + m_aFallbackCommands.clear(); +} + +Reference< frame::XDispatch > CommandDispatchContainer::getContainerDispatchForURL( + const Reference< frame::XController > & xChartController, + const util::URL & rURL ) +{ + Reference< frame::XDispatch > xResult; + if( xChartController.is()) + { + Reference< frame::XFrame > xFrame( xChartController->getFrame()); + if( xFrame.is()) + { + Reference< frame::XDispatchProvider > xDispProv( xFrame->getCreator(), uno::UNO_QUERY ); + if( xDispProv.is()) + xResult.set( xDispProv->queryDispatch( rURL, C2U("_self"), 0 )); + } + } + return xResult; +} + +} // namespace chart diff --git a/chart2/source/controller/main/CommandDispatchContainer.hxx b/chart2/source/controller/main/CommandDispatchContainer.hxx new file mode 100644 index 000000000000..90b9c94cc5d5 --- /dev/null +++ b/chart2/source/controller/main/CommandDispatchContainer.hxx @@ -0,0 +1,148 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: CommandDispatchContainer.hxx,v $ + * $Revision: 1.5 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_COMMANDDISPATCHCONTAINER_HXX +#define CHART2_COMMANDDISPATCHCONTAINER_HXX + +#include <com/sun/star/uno/XComponentContext.hpp> +#include <com/sun/star/chart2/XUndoManager.hpp> +#include <com/sun/star/frame/XDispatch.hpp> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/DispatchDescriptor.hpp> + +#include <cppuhelper/interfacecontainer.hxx> + +#include <set> +#include <map> + +namespace chart +{ + +/** @HTML + + Helper class for implementing the <code>XDispatchProvider</code> interface + of the ChartController. This class handles all commands to queryDispatch and + queryDispatches in the following way: + + <ul> + <li>Check if there is a cached <code>XDispatch</code> for a given command. + If so, use it.</li> + <li>Check if the command is handled by this class, e.g. Undo. If so, + return a corresponding <code>XDispatch</code> implementation, and cache + this implementation for later use</li> + <li>Otherwise send the command to the fallback dispatch provider, if it + can handle this dispatch (determined by the list of commands given in + <code>setFallbackDispatch()</code>).</li> + </ul> + + <p>The <code>XDispatch</code>Provider is designed to return different + <code>XDispatch</code> implementations for each command. This class here + decides which implementation to use for which command.</p> + + <p>As most commands need much information of the controller and are + implemented there, the controller handles most of the commands itself (it + also implements <code>XDispatch</code>). Therefore it is set here as + fallback dispatch.</p> + */ +class CommandDispatchContainer +{ +public: + // note: the fallback dispatcher should be removed when all commands are + // handled by other dispatchers. (Fallback is currently the controller + // itself) + explicit CommandDispatchContainer( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext ); + + void setModel( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); +// void setUndoManager( +// const ::com::sun::star::uno::Reference< +// ::com::sun::star::chart2::XUndoManager > & xUndoManager ); + + /** Set a fallback dispatcher that is used for all commands contained in + rFallbackCommands + */ + void setFallbackDispatch( + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > xFallbackDispatch, + const ::std::set< ::rtl::OUString > & rFallbackCommands ); + + /** 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 + checked whether the command is one of the commands given as fallback via + the setFallbackDispatch() method. If so, call the fallback dispatch. + + <p>If all this fails, return an empty dispatch.</p> + */ + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > getDispatchForURL( + const ::com::sun::star::util::URL & rURL ); + + ::com::sun::star::uno::Sequence< + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > > getDispatchesForURLs( + const ::com::sun::star::uno::Sequence< + ::com::sun::star::frame::DispatchDescriptor > & aDescriptors ); + + void DisposeAndClear(); + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > + getContainerDispatchForURL( + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController > & xChartController, + const ::com::sun::star::util::URL & rURL ); + +private: + typedef + ::std::map< ::rtl::OUString, + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > > + tDispatchMap; + + typedef + ::std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > tDisposeVector; + + mutable tDispatchMap m_aCachedDispatches; + mutable tDisposeVector m_aToBeDisposedDispatches; + + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > m_xModel; + ::com::sun::star::uno::Reference< ::com::sun::star::chart2::XUndoManager > m_xUndoManager; + + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xFallbackDispatcher; + ::std::set< ::rtl::OUString > m_aFallbackCommands; + + ::std::set< ::rtl::OUString > m_aContainerDocumentCommands; +}; + +} // namespace chart + +// CHART2_COMMANDDISPATCHCONTAINER_HXX +#endif diff --git a/chart2/source/controller/main/ConfigurationAccess.cxx b/chart2/source/controller/main/ConfigurationAccess.cxx new file mode 100644 index 000000000000..f71d26b7b3c2 --- /dev/null +++ b/chart2/source/controller/main/ConfigurationAccess.cxx @@ -0,0 +1,118 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ConfigurationAccess.cxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ConfigurationAccess.hxx" +#include "macros.hxx" + +// header for class SvtSysLocale +#include <svtools/syslocale.hxx> +// header for class ConfigItem +#include <unotools/configitem.hxx> +// header for rtl::Static +#include <rtl/instance.hxx> + + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; + +namespace +{ +bool lcl_IsMetric() +{ + SvtSysLocale aSysLocale; + const LocaleDataWrapper* pLocWrapper = aSysLocale.GetLocaleDataPtr(); + MeasurementSystem eSys = pLocWrapper->getMeasurementSystemEnum(); + + return ( eSys == MEASURE_METRIC ); +} +}//end anonymous namespace + +// ---------------------------------------- + +class CalcConfigItem : public ::utl::ConfigItem +{ +public: + CalcConfigItem(); + virtual ~CalcConfigItem(); + + FieldUnit getFieldUnit(); +}; + +CalcConfigItem::CalcConfigItem() + : ConfigItem( ::rtl::OUString( C2U( "Office.Calc/Layout" ))) +{ +} + +CalcConfigItem::~CalcConfigItem() +{ +} + +FieldUnit CalcConfigItem::getFieldUnit() +{ + FieldUnit eResult( FUNIT_CM ); + + uno::Sequence< ::rtl::OUString > aNames( 1 ); + if( lcl_IsMetric() ) + aNames[ 0 ] = ::rtl::OUString( C2U( "Other/MeasureUnit/Metric" )); + else + aNames[ 0 ] = ::rtl::OUString( C2U( "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 +//............................................................................. diff --git a/chart2/source/controller/main/ControllerCommandDispatch.cxx b/chart2/source/controller/main/ControllerCommandDispatch.cxx new file mode 100644 index 000000000000..d7e0514dee08 --- /dev/null +++ b/chart2/source/controller/main/ControllerCommandDispatch.cxx @@ -0,0 +1,771 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ControllerCommandDispatch.cxx,v $ + * $Revision: 1.10 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ControllerCommandDispatch.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "AxisHelper.hxx" +#include "TitleHelper.hxx" +#include "LegendHelper.hxx" +#include "ObjectIdentifier.hxx" +#include "macros.hxx" +#include "ChartTypeHelper.hxx" +#include "DiagramHelper.hxx" +#include "ChartController.hxx" +#include "RegressionCurveHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "StatisticsHelper.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/XChartType.hpp> +#include <com/sun/star/chart2/XDataSeries.hpp> +#include <com/sun/star/chart2/XRegressionCurve.hpp> +#include <com/sun/star/chart2/data/XDatabaseDataProvider.hpp> + +// only needed until #i68864# is fixed +#include <com/sun/star/frame/XLayoutManager.hpp> + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ +bool lcl_isStatusBarVisible( const Reference< frame::XController > & xController ) +{ + bool bIsStatusBarVisible = false; + // Status-Bar visible, workaround: this should not be necessary. @todo: + // remove when Issue #i68864# is fixed + if( xController.is()) + { + Reference< beans::XPropertySet > xPropSet( xController->getFrame(), uno::UNO_QUERY ); + if( xPropSet.is() ) + { + uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager; + xPropSet->getPropertyValue( C2U( "LayoutManager" ) ) >>= xLayoutManager; + if ( xLayoutManager.is() ) + bIsStatusBarVisible = xLayoutManager->isElementVisible( C2U("private:resource/statusbar/statusbar")); + } + } + return bIsStatusBarVisible; +} + +} // anonymous namespace + +namespace chart +{ + +// ---------------------------------------- + +namespace impl +{ + +/// Constants for moving the series. +enum EnumForward{ + MOVE_SERIES_FORWARD = true, + MOVE_SERIES_BACKWARD = false +}; + +/** Represents the current state of the controller (needed for issue 63017). + + You can set the state by calling update(). After this call the state is + preserved in this class until the next call to update(). + + This is useful, not to say necessary, for enabling and disabling of menu + entries (e.g. format>arrangement). As the status requests are sent very + frequently it would be impossible, from a performance point of view, to + query the current status every time directly at the model. So this class + serves as a cache for the state. +*/ +struct ControllerState +{ + ControllerState(); + + void update( const Reference< frame::XController > & xController, + const Reference< frame::XModel > & xModel ); + + // -- State variables ------- + bool bHasSelectedObject; + bool bIsPositionableObject; + bool bIsTextObject; + bool bIsDeleteableObjectSelected; + bool bIsFormateableObjectSelected; + + // May the selected series be moved forward or backward (cf + // format>arrangement). + bool bMayMoveSeriesForward; + bool bMayMoveSeriesBackward; + + // trendlines + bool bMayAddTrendline; + bool bMayAddTrendlineEquation; + bool bMayAddR2Value; + bool bMayAddMeanValue; + bool bMayAddYErrorBars; + + bool bMayDeleteTrendline; + bool bMayDeleteTrendlineEquation; + bool bMayDeleteR2Value; + bool bMayDeleteMeanValue; + bool bMayDeleteYErrorBars; + + bool bMayFormatTrendline; + bool bMayFormatTrendlineEquation; + bool bMayFormatMeanValue; + bool bMayFormatYErrorBars; +}; + + +ControllerState::ControllerState() : + bHasSelectedObject( false ), + bIsPositionableObject( false ), + bIsTextObject(false), + bIsDeleteableObjectSelected(false), + bIsFormateableObjectSelected(false), + bMayMoveSeriesForward( false ), + bMayMoveSeriesBackward( false ), + bMayAddTrendline( false ), + bMayAddTrendlineEquation( false ), + bMayAddR2Value( false ), + bMayAddMeanValue( false ), + bMayAddYErrorBars( false ), + bMayDeleteTrendline( false ), + bMayDeleteTrendlineEquation( false ), + bMayDeleteR2Value( false ), + bMayDeleteMeanValue( false ), + bMayDeleteYErrorBars( false ), + bMayFormatTrendline( false ), + bMayFormatTrendlineEquation( false ), + bMayFormatMeanValue( false ), + bMayFormatYErrorBars( false ) +{} + +void ControllerState::update( + const Reference< frame::XController > & xController, + const Reference< frame::XModel > & xModel ) +{ + Reference< view::XSelectionSupplier > xSelectionSupplier( + xController, uno::UNO_QUERY ); + + OUString aSelObjCID; + + // Update ControllerState variables. + if( xSelectionSupplier.is()) + { + uno::Any aSelObj( xSelectionSupplier->getSelection() ); + + bHasSelectedObject = ((aSelObj >>= aSelObjCID) && aSelObjCID.getLength() > 0); + + ObjectType aObjectType(ObjectIdentifier::getObjectType( aSelObjCID )); + + bIsPositionableObject = (OBJECTTYPE_DATA_POINT != aObjectType) && ObjectIdentifier::isDragableObject( aSelObjCID ); + bIsTextObject = OBJECTTYPE_TITLE == aObjectType; + + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + bIsFormateableObjectSelected = bHasSelectedObject; + if( OBJECTTYPE_DIAGRAM==aObjectType || OBJECTTYPE_DIAGRAM_WALL==aObjectType || OBJECTTYPE_DIAGRAM_FLOOR==aObjectType ) + bIsFormateableObjectSelected = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + + uno::Reference< chart2::XDataSeries > xGivenDataSeries( + ObjectIdentifier::getDataSeriesForCID( + aSelObjCID, xModel ) ); + + bIsDeleteableObjectSelected = ChartController::isObjectDeleteable( aSelObj ); + + bMayMoveSeriesForward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_FORWARD ); + + bMayMoveSeriesBackward = (OBJECTTYPE_DATA_POINT!=aObjectType) && DiagramHelper::isSeriesMoveable( + ChartModelHelper::findDiagram( xModel ), + xGivenDataSeries, + MOVE_SERIES_BACKWARD ); + + bMayAddTrendline = false; + bMayAddTrendlineEquation = false; + bMayAddR2Value = false; + bMayAddMeanValue = false; + bMayAddYErrorBars = false; + bMayDeleteTrendline = false; + bMayDeleteTrendlineEquation = false; + bMayDeleteR2Value = false; + bMayDeleteMeanValue = false; + bMayDeleteYErrorBars = false; + bMayFormatTrendline = false; + bMayFormatTrendlineEquation = false; + bMayFormatMeanValue = false; + bMayFormatYErrorBars = false; + if( bHasSelectedObject ) + { + if( xGivenDataSeries.is()) + { + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + uno::Reference< chart2::XChartType > xFirstChartType( + DataSeriesHelper::getChartTypeOfSeries( xGivenDataSeries, xDiagram )); + + // trend lines/mean value line + if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType) + && ChartTypeHelper::isSupportingRegressionProperties( xFirstChartType, nDimensionCount )) + { + uno::Reference< chart2::XRegressionCurveContainer > xRegCurveCnt( + xGivenDataSeries, uno::UNO_QUERY ); + if( xRegCurveCnt.is()) + { + uno::Reference< chart2::XRegressionCurve > xRegCurve( RegressionCurveHelper::getFirstCurveNotMeanValueLine( xRegCurveCnt ) ); + bMayFormatTrendline = bMayDeleteTrendline = xRegCurve.is(); + bMayFormatMeanValue = bMayDeleteMeanValue = RegressionCurveHelper::hasMeanValueLine( xRegCurveCnt ); + bMayAddTrendline = ! bMayDeleteTrendline; + bMayAddMeanValue = ! bMayDeleteMeanValue; + bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); + bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; + } + } + + // error bars + if( (OBJECTTYPE_DATA_SERIES == aObjectType || OBJECTTYPE_DATA_POINT == aObjectType) + && ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount )) + { + bMayFormatYErrorBars = bMayDeleteYErrorBars = StatisticsHelper::hasErrorBars( xGivenDataSeries ); + bMayAddYErrorBars = ! bMayDeleteYErrorBars; + } + } + + if( aObjectType == OBJECTTYPE_DATA_AVERAGE_LINE ) + bMayFormatMeanValue = true; + + if( aObjectType == OBJECTTYPE_DATA_ERRORS_Y || aObjectType == OBJECTTYPE_DATA_ERRORS ) + bMayFormatYErrorBars = true; + + if( aObjectType == OBJECTTYPE_DATA_CURVE ) + { + bMayFormatTrendline = true; + uno::Reference< chart2::XRegressionCurve > xRegCurve( + ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); + bMayFormatTrendlineEquation = bMayDeleteTrendlineEquation = RegressionCurveHelper::hasEquation( xRegCurve ); + bMayAddTrendlineEquation = !bMayDeleteTrendlineEquation; + } + else if( aObjectType == OBJECTTYPE_DATA_CURVE_EQUATION ) + { + bMayFormatTrendlineEquation = true; + bool bHasR2Value = false; + try + { + uno::Reference< beans::XPropertySet > xEqProp( + ObjectIdentifier::getObjectPropertySet( aSelObjCID, xModel ), uno::UNO_QUERY ); + if( xEqProp.is()) + xEqProp->getPropertyValue( C2U("ShowCorrelationCoefficient") ) >>= bHasR2Value; + } + catch( uno::RuntimeException& e) + { + ASSERT_EXCEPTION( e ); + } + bMayAddR2Value = !bHasR2Value; + bMayDeleteR2Value = bHasR2Value; + } + } + } +} + + +/** Represents the current state of the model. + + You can set the state by calling update(). After this call the state is + preserved in this class until the next call to update(). + + This is useful, not to say necessary, for enabling and disabling of menu + entries and toolbar icons. As the status requests are sent very frequently + it would be impossible, from a performance point of view, to query the + current status every time directly at the model. So this class serves as a + cache for the state. + */ +struct ModelState +{ + ModelState(); + + void update( const Reference< frame::XModel > & xModel ); + + bool HasAnyAxis() const; + bool HasAnyGrid() const; + bool HasAnyTitle() const; + + bool bIsReadOnly; + bool bIsThreeD; + bool bHasOwnData; + + bool bHasMainTitle; + bool bHasSubTitle; + bool bHasXAxisTitle; + bool bHasYAxisTitle; + bool bHasZAxisTitle; + bool bHasSecondaryXAxisTitle; + bool bHasSecondaryYAxisTitle; + + bool bHasXAxis; + bool bHasYAxis; + bool bHasZAxis; + bool bHasAAxis; + bool bHasBAxis; + + bool bHasMainXGrid; + bool bHasMainYGrid; + bool bHasMainZGrid; + bool bHasHelpXGrid; + bool bHasHelpYGrid; + bool bHasHelpZGrid; + + bool bHasAutoScaledText; + bool bHasLegend; + bool bHasWall; + bool bHasFloor; + + bool bSupportsStatistics; + bool bSupportsAxes; +}; + +ModelState::ModelState() : + bIsReadOnly( true ), + bIsThreeD( false ), + bHasOwnData( false ), + bHasMainTitle( false ), + bHasSubTitle( false ), + bHasXAxisTitle( false ), + bHasYAxisTitle( false ), + bHasZAxisTitle( false ), + bHasSecondaryXAxisTitle( false ), + bHasSecondaryYAxisTitle( false ), + bHasXAxis( false ), + bHasYAxis( false ), + bHasZAxis( false ), + bHasAAxis( false ), + bHasBAxis( false ), + bHasMainXGrid( false ), + bHasMainYGrid( false ), + bHasMainZGrid( false ), + bHasHelpXGrid( false ), + bHasHelpYGrid( false ), + bHasHelpZGrid( false ), + bHasAutoScaledText( false ), + bHasLegend( false ), + bHasWall( false ), + bHasFloor( false ), + bSupportsStatistics( false ), + bSupportsAxes( false ) + +{} + +void ModelState::update( const Reference< frame::XModel > & xModel ) +{ + Reference< chart2::XChartDocument > xChartDoc( xModel, uno::UNO_QUERY ); + Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram( xModel )); + + bIsReadOnly = true; + Reference< frame::XStorable > xStorable( xModel, uno::UNO_QUERY ); + if( xStorable.is()) + bIsReadOnly = xStorable->isReadonly(); + + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + + uno::Reference< chart2::XChartType > xFirstChartType( DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ); + bSupportsStatistics = ChartTypeHelper::isSupportingStatisticProperties( xFirstChartType, nDimensionCount ); + bSupportsAxes = ChartTypeHelper::isSupportingMainAxis( xFirstChartType, nDimensionCount, 0 ); + + bIsThreeD = (nDimensionCount == 3); + bHasOwnData = (xChartDoc.is() && xChartDoc->hasInternalDataProvider()); + + bHasMainTitle = TitleHelper::getTitle( TitleHelper::MAIN_TITLE, xModel ).is(); + bHasSubTitle = TitleHelper::getTitle( TitleHelper::SUB_TITLE, xModel ).is(); + bHasXAxisTitle = TitleHelper::getTitle( TitleHelper::X_AXIS_TITLE, xModel ).is(); + bHasYAxisTitle = TitleHelper::getTitle( TitleHelper::Y_AXIS_TITLE, xModel ).is(); + bHasZAxisTitle = TitleHelper::getTitle( TitleHelper::Z_AXIS_TITLE, xModel ).is(); + bHasSecondaryXAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_X_AXIS_TITLE, xModel ).is(); + bHasSecondaryYAxisTitle = TitleHelper::getTitle( TitleHelper::SECONDARY_Y_AXIS_TITLE, xModel ).is(); + + bHasXAxis = bSupportsAxes && AxisHelper::getAxis( 0, true, xDiagram ).is(); + bHasYAxis = bSupportsAxes && AxisHelper::getAxis( 1, true, xDiagram ).is(); + bHasZAxis = bSupportsAxes && AxisHelper::getAxis( 2, true, xDiagram ).is(); + bHasAAxis = bSupportsAxes && AxisHelper::getAxis( 0, false, xDiagram ).is(); + bHasBAxis = bSupportsAxes && AxisHelper::getAxis( 1, false, xDiagram ).is(); + + bHasMainXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, true, xDiagram ); + bHasMainYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, true, xDiagram ); + bHasMainZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, true, xDiagram ); + bHasHelpXGrid = bSupportsAxes && AxisHelper::isGridShown( 0, 0, false, xDiagram ); + bHasHelpYGrid = bSupportsAxes && AxisHelper::isGridShown( 1, 0, false, xDiagram ); + bHasHelpZGrid = bSupportsAxes && AxisHelper::isGridShown( 2, 0, false, xDiagram ); + + bHasAutoScaledText = + (ReferenceSizeProvider::getAutoResizeState( xChartDoc ) == + ReferenceSizeProvider::AUTO_RESIZE_YES); + + bHasLegend = LegendHelper::hasLegend( xDiagram ); + bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + bHasFloor = bHasWall && bIsThreeD; +} + +bool ModelState::HasAnyAxis() const +{ + return bHasXAxis || bHasYAxis || bHasZAxis || bHasAAxis || bHasBAxis; +} + +bool ModelState::HasAnyGrid() const +{ + return bHasMainXGrid || bHasMainYGrid || bHasMainZGrid || + bHasHelpXGrid || bHasHelpYGrid || bHasHelpZGrid; +} + +bool ModelState::HasAnyTitle() const +{ + return bHasMainTitle || bHasSubTitle || bHasXAxisTitle || bHasYAxisTitle || bHasZAxisTitle || bHasSecondaryXAxisTitle || bHasSecondaryYAxisTitle; +} + +} // namespace impl + +// ---------------------------------------- +DBG_NAME(ControllerCommandDispatch) + +ControllerCommandDispatch::ControllerCommandDispatch( + const Reference< uno::XComponentContext > & xContext, + const Reference< frame::XController > & xController ) : + impl::ControllerCommandDispatch_Base( xContext ), + m_xController( xController ), + m_xSelectionSupplier( xController, uno::UNO_QUERY ), + m_xDispatch( xController, uno::UNO_QUERY ), + m_apModelState( new impl::ModelState() ), + m_apControllerState( new impl::ControllerState() ) +{ + DBG_CTOR(ControllerCommandDispatch,NULL); +} + +ControllerCommandDispatch::~ControllerCommandDispatch() +{ + + DBG_DTOR(ControllerCommandDispatch,NULL); +} + +void ControllerCommandDispatch::initialize() +{ + if( m_xController.is()) + { + Reference< frame::XModel > xModel( m_xController->getModel()); + Reference< util::XModifyBroadcaster > xModifyBroadcaster( xModel, uno::UNO_QUERY ); + OSL_ASSERT( xModifyBroadcaster.is()); + if( xModifyBroadcaster.is()) + xModifyBroadcaster->addModifyListener( this ); + + // Listen selection modifications (Arrangement feature - issue 63017). + if( m_xSelectionSupplier.is() ) + m_xSelectionSupplier->addSelectionChangeListener( this ); + + if( m_apModelState.get() && xModel.is()) + m_apModelState->update( xModel ); + + if( m_apControllerState.get() && xModel.is()) + m_apControllerState->update( m_xController, xModel ); + + updateCommandAvailability(); + } +} + +void ControllerCommandDispatch::fireStatusEventForURLImpl( + const OUString & rURL, + const Reference< frame::XStatusListener > & xSingleListener ) +{ + ::std::map< OUString, uno::Any >::const_iterator aArgIt( m_aCommandArguments.find( rURL )); + if( aArgIt != m_aCommandArguments.end()) + fireStatusEventForURL( rURL, aArgIt->second, commandAvailable( rURL ), xSingleListener ); + else + fireStatusEventForURL( rURL, uno::Any(), commandAvailable( rURL ), xSingleListener ); +} + +void ControllerCommandDispatch::updateCommandAvailability() +{ + bool bModelStateIsValid = ( m_apModelState.get() != 0 ); + bool bControllerStateIsValid = ( m_apControllerState.get() != 0 ); + // Model and controller states exist. + OSL_ASSERT( bModelStateIsValid ); + OSL_ASSERT( bControllerStateIsValid ); + + // read-only + bool bIsWritable = bModelStateIsValid && (! m_apModelState->bIsReadOnly); + // paste is available + // @todo: determine correctly + bool bHasSuitableClipboardContent = true; + + // edit commands + m_aCommandAvailability[ C2U(".uno:Cut")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsDeleteableObjectSelected; + m_aCommandAvailability[ C2U(".uno:Copy")] = bControllerStateIsValid && m_apControllerState->bHasSelectedObject; + m_aCommandAvailability[ C2U(".uno:Paste")] = bIsWritable && bHasSuitableClipboardContent; + + // toolbar commands + m_aCommandAvailability[ C2U(".uno:ToggleGridHorizontal")] = bIsWritable; + m_aCommandArguments[ C2U(".uno:ToggleGridHorizontal")] = uno::makeAny( m_apModelState->bHasMainYGrid ); + + m_aCommandAvailability[ C2U(".uno:ToggleLegend")] = bIsWritable; + m_aCommandArguments[ C2U(".uno:ToggleLegend")] = uno::makeAny( m_apModelState->bHasLegend ); + + m_aCommandAvailability[ C2U(".uno:NewArrangement")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:Update")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DefaultColors")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:BarWidth")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:NumberOfLines")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:ArrangeRow")] = m_apControllerState->bMayMoveSeriesForward || m_apControllerState->bMayMoveSeriesBackward; + + // insert objects + m_aCommandAvailability[ C2U(".uno:InsertTitles")] = m_aCommandAvailability[ C2U(".uno:InsertMenuTitles")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertLegend")] = m_aCommandAvailability[ C2U(".uno:InsertMenuLegend")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteLegend")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMenuDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertRemoveAxes")] = m_aCommandAvailability[ C2U(".uno:InsertMenuAxes")] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ C2U(".uno:InsertMenuGrids")] = bIsWritable && m_apModelState->bSupportsAxes; + m_aCommandAvailability[ C2U(".uno:InsertMenuTrendlines")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertMenuMeanValues")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertMenuYErrorBars")] = bIsWritable && m_apModelState->bSupportsStatistics; + m_aCommandAvailability[ C2U(".uno:InsertSymbol")] = bIsWritable && m_apControllerState->bIsTextObject; + + // format objects + bool bFormatObjectAvailable = bIsWritable && bControllerStateIsValid && m_apControllerState->bIsFormateableObjectSelected; + m_aCommandAvailability[ C2U(".uno:FormatSelection")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatAxis")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatTitle")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataSeries")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataPoint")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataLabels")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatDataLabel")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatYErrorBars; + m_aCommandAvailability[ C2U(".uno:FormatMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatMeanValue; + m_aCommandAvailability[ C2U(".uno:FormatTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendline; + m_aCommandAvailability[ C2U(".uno:FormatTrendlineEquation")] = bFormatObjectAvailable && bControllerStateIsValid && m_apControllerState->bMayFormatTrendlineEquation; + m_aCommandAvailability[ C2U(".uno:FormatStockLoss")] = bFormatObjectAvailable; + m_aCommandAvailability[ C2U(".uno:FormatStockGain")] = bFormatObjectAvailable; + + m_aCommandAvailability[ C2U(".uno:DiagramType")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:Legend")] = bIsWritable && m_apModelState->bHasLegend; + m_aCommandAvailability[ C2U(".uno:DiagramWall")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasWall; + m_aCommandAvailability[ C2U(".uno:DiagramArea")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:TransformDialog")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bHasSelectedObject && m_apControllerState->bIsPositionableObject; + + // 3d commands + m_aCommandAvailability[ C2U(".uno:View3D")] = bIsWritable && bModelStateIsValid && m_apModelState->bIsThreeD; + m_aCommandAvailability[ C2U(".uno:DiagramFloor")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasFloor; + + //some mor format commands with different ui text + m_aCommandAvailability[ C2U(".uno:FormatWall")] = m_aCommandAvailability[ C2U(".uno:DiagramWall")]; + m_aCommandAvailability[ C2U(".uno:FormatFloor")] = m_aCommandAvailability[ C2U(".uno:DiagramFloor")]; + m_aCommandAvailability[ C2U(".uno:FormatChartArea")] = m_aCommandAvailability[ C2U(".uno:DiagramArea")]; + m_aCommandAvailability[ C2U(".uno:FormatLegend")] = m_aCommandAvailability[ C2U(".uno:Legend")]; + + // depending on own data + m_aCommandAvailability[ C2U(".uno:DataRanges")] = bIsWritable && bModelStateIsValid && (! m_apModelState->bHasOwnData); + m_aCommandAvailability[ C2U(".uno:DiagramData")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasOwnData; + + // titles + m_aCommandAvailability[ C2U(".uno:MainTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainTitle; + m_aCommandAvailability[ C2U(".uno:SubTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSubTitle; + m_aCommandAvailability[ C2U(".uno:XTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxisTitle; + m_aCommandAvailability[ C2U(".uno:YTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxisTitle; + m_aCommandAvailability[ C2U(".uno:ZTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxisTitle; + m_aCommandAvailability[ C2U(".uno:SecondaryXTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryXAxisTitle; + m_aCommandAvailability[ C2U(".uno:SecondaryYTitle")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasSecondaryYAxisTitle; + m_aCommandAvailability[ C2U(".uno:AllTitles")] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyTitle(); + + // text + m_aCommandAvailability[ C2U(".uno:ScaleText")] = bIsWritable && bModelStateIsValid ; + m_aCommandArguments[ C2U(".uno:ScaleText")] = uno::makeAny( m_apModelState->bHasAutoScaledText ); + + // axes + m_aCommandAvailability[ C2U(".uno:DiagramAxisX")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasXAxis; + m_aCommandAvailability[ C2U(".uno:DiagramAxisY")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasYAxis; + m_aCommandAvailability[ C2U(".uno:DiagramAxisZ")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasZAxis; + m_aCommandAvailability[ C2U(".uno:DiagramAxisA")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasAAxis; + m_aCommandAvailability[ C2U(".uno:DiagramAxisB")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasBAxis; + m_aCommandAvailability[ C2U(".uno:DiagramAxisAll")] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyAxis(); + + // grids + // note: x and y are swapped in the commands! + m_aCommandAvailability[ C2U(".uno:DiagramGridYMain")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainXGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridXMain")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainYGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridZMain")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasMainZGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridYHelp")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpXGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridXHelp")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpYGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridZHelp")] = bIsWritable && bModelStateIsValid && m_apModelState->bHasHelpZGrid; + m_aCommandAvailability[ C2U(".uno:DiagramGridAll")] = bIsWritable && bModelStateIsValid && m_apModelState->HasAnyGrid(); + + // series arrangement + m_aCommandAvailability[ C2U(".uno:Forward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesForward; + m_aCommandAvailability[ C2U(".uno:Backward")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayMoveSeriesBackward; + + m_aCommandAvailability[ C2U(".uno:InsertDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertDataLabel")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMeanValue")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddMeanValue; + m_aCommandAvailability[ C2U(".uno:InsertTrendline")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendline; + m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquation")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddTrendlineEquation; + m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquationAndR2")] = m_aCommandAvailability[ C2U(".uno:InsertTrendlineEquation")]; + m_aCommandAvailability[ C2U(".uno:InsertR2Value")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddR2Value; + m_aCommandAvailability[ C2U(".uno:DeleteR2Value")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteR2Value; + + m_aCommandAvailability[ C2U(".uno:InsertYErrorBars")] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayAddYErrorBars; + + m_aCommandAvailability[ C2U(".uno:DeleteDataLabels")] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteDataLabel") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteTrendline") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendline; + m_aCommandAvailability[ C2U(".uno:DeleteTrendlineEquation") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteTrendlineEquation; + m_aCommandAvailability[ C2U(".uno:DeleteMeanValue") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteMeanValue; + m_aCommandAvailability[ C2U(".uno:DeleteYErrorBars") ] = bIsWritable && bControllerStateIsValid && m_apControllerState->bMayDeleteYErrorBars; + + m_aCommandAvailability[ C2U(".uno:ResetDataPoint") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:ResetAllDataPoints") ] = bIsWritable; + + m_aCommandAvailability[ C2U(".uno:InsertAxis") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteAxis") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertAxisTitle") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:FormatMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteMajorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:FormatMinorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:InsertMinorGrid") ] = bIsWritable; + m_aCommandAvailability[ C2U(".uno:DeleteMinorGrid") ] = bIsWritable; +} + +bool ControllerCommandDispatch::commandAvailable( const OUString & rCommand ) +{ + ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.find( rCommand )); + if( aIt != m_aCommandAvailability.end()) + return aIt->second; + OSL_ENSURE( false, "commandAvailable: command not in availability map" ); + return false; +} + +void ControllerCommandDispatch::fireStatusEvent( + const OUString & rURL, + const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) +{ + bool bIsChartSelectorURL = rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ChartElementSelector") ); + if( rURL.getLength() == 0 || bIsChartSelectorURL ) + { + uno::Any aArg; + aArg <<= m_xController; + fireStatusEventForURL( C2U(".uno:ChartElementSelector"), aArg, true, xSingleListener ); + } + + if( rURL.getLength() == 0 ) + for( ::std::map< OUString, bool >::const_iterator aIt( m_aCommandAvailability.begin()); + aIt != m_aCommandAvailability.end(); ++aIt ) + fireStatusEventForURLImpl( aIt->first, xSingleListener ); + else if( !bIsChartSelectorURL ) + fireStatusEventForURLImpl( rURL, xSingleListener ); + + // statusbar. Should be handled by base implementation + // @todo: remove if Issue 68864 is fixed + if( rURL.getLength() == 0 || + rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:StatusBarVisible"))) + { + bool bIsStatusBarVisible( lcl_isStatusBarVisible( m_xController )); + fireStatusEventForURL( C2U(".uno:StatusBarVisible"), uno::makeAny( bIsStatusBarVisible ), true, xSingleListener ); + } +} + +// ____ XDispatch ____ +void SAL_CALL ControllerCommandDispatch::dispatch( + const util::URL& URL, + const Sequence< beans::PropertyValue >& Arguments ) + throw (uno::RuntimeException) +{ + if( commandAvailable( URL.Complete )) + m_xDispatch->dispatch( URL, Arguments ); +} + +// ____ WeakComponentImplHelperBase ____ +/// is called when this is disposed +void SAL_CALL ControllerCommandDispatch::disposing() +{ + m_xController.clear(); + m_xDispatch.clear(); + m_xSelectionSupplier.clear(); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL ControllerCommandDispatch::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{ + m_xController.clear(); + m_xDispatch.clear(); + m_xSelectionSupplier.clear(); +} + +// ____ XModifyListener ____ +void SAL_CALL ControllerCommandDispatch::modified( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + bool bUpdateCommandAvailability = false; + + // Update the "ModelState" Struct. + if( m_apModelState.get() && m_xController.is()) + { + m_apModelState->update( m_xController->getModel()); + bUpdateCommandAvailability = true; + } + + // Update the "ControllerState" Struct. + if( m_apControllerState.get() && m_xController.is()) + { + m_apControllerState->update( m_xController, m_xController->getModel()); + bUpdateCommandAvailability = true; + } + + if( bUpdateCommandAvailability ) + updateCommandAvailability(); + + CommandDispatch::modified( aEvent ); +} + + +// ____ XSelectionChangeListener ____ +void SAL_CALL ControllerCommandDispatch::selectionChanged( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + // Update the "ControllerState" Struct. + if( m_apControllerState.get() && m_xController.is()) + { + m_apControllerState->update( m_xController, m_xController->getModel()); + updateCommandAvailability(); + } + + CommandDispatch::modified( aEvent ); +} + +} // namespace chart diff --git a/chart2/source/controller/main/ControllerCommandDispatch.hxx b/chart2/source/controller/main/ControllerCommandDispatch.hxx new file mode 100644 index 000000000000..16dc12b89c9b --- /dev/null +++ b/chart2/source/controller/main/ControllerCommandDispatch.hxx @@ -0,0 +1,132 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ControllerCommandDispatch.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_CONTROLLERCOMMANDDISPATCH_HXX +#define CHART2_CONTROLLERCOMMANDDISPATCH_HXX + +#include "CommandDispatch.hxx" +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/frame/XController.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <cppuhelper/implbase1.hxx> + +#include <memory> + +namespace chart +{ + +namespace impl +{ +struct ModelState; +struct ControllerState; + +// #i63017# : need to implement the XSelectionChangeListener in order +// to update the ControllerState when the selection changes. +typedef ::cppu::ImplInheritanceHelper1< + CommandDispatch, + ::com::sun::star::view::XSelectionChangeListener > + ControllerCommandDispatch_Base; +} + +/** This class is a CommandDispatch that is responsible for all commands that + the ChartController supports. + + This class determines which commands are currently available (via the model + state) and if an available command is called forwards it to the + ChartController. + */ +class ControllerCommandDispatch : public impl::ControllerCommandDispatch_Base +{ +public: + explicit ControllerCommandDispatch( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController > & xController ); + virtual ~ControllerCommandDispatch(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + +protected: + // ____ XDispatch ____ + virtual void SAL_CALL dispatch( + const ::com::sun::star::util::URL& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ WeakComponentImplHelperBase ____ + /// is called when this is disposed + virtual void SAL_CALL disposing(); + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void fireStatusEvent( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); + + // ____ XModifyListener ____ + virtual void SAL_CALL modified( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + +private: + void fireStatusEventForURLImpl( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); + + bool commandAvailable( const ::rtl::OUString & rCommand ); + void updateCommandAvailability(); + + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XController > m_xController; + ::com::sun::star::uno::Reference< + ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier; + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XDispatch > m_xDispatch; + + ::std::auto_ptr< impl::ModelState > m_apModelState; + ::std::auto_ptr< impl::ControllerState > m_apControllerState; + + mutable ::std::map< ::rtl::OUString, bool > m_aCommandAvailability; + mutable ::std::map< ::rtl::OUString, ::com::sun::star::uno::Any > m_aCommandArguments; +}; + +} // namespace chart + +// CHART2_CONTROLLERCOMMANDDISPATCH_HXX +#endif diff --git a/chart2/source/controller/main/DragMethod_Base.cxx b/chart2/source/controller/main/DragMethod_Base.cxx new file mode 100644 index 000000000000..a21e46216c45 --- /dev/null +++ b/chart2/source/controller/main/DragMethod_Base.cxx @@ -0,0 +1,96 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_Base.cxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "DragMethod_Base.hxx" + +#include "Strings.hrc" +#include "ResId.hxx" +#include "macros.hxx" +#include "ObjectNameProvider.hxx" +#include "ObjectIdentifier.hxx" +#include <rtl/math.hxx> +//header for class SdrPageView +#include <svx/svdpagv.hxx> +#include <svx/ActionDescriptionProvider.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +//............................................................................. +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 rtl::OUString& rObjectCID + , const Reference< frame::XModel >& xChartModel + , ActionDescriptionProvider::ActionType eActionType ) + : SdrDragMethod( rDrawViewWrapper ) + , m_rDrawViewWrapper(rDrawViewWrapper) + , m_aObjectCID(rObjectCID) + , m_eActionType( eActionType ) + , m_xChartModel( WeakReference< frame::XModel >(xChartModel) ) +{ + setMoveOnly(true); +} +DragMethod_Base::~DragMethod_Base() +{ +} + +Reference< frame::XModel > DragMethod_Base::getChartModel() const +{ + return Reference< frame::XModel >( m_xChartModel );; +} + +rtl::OUString DragMethod_Base::getUndoDescription() const +{ + return ActionDescriptionProvider::createDescription( + m_eActionType, + ObjectNameProvider::getName( ObjectIdentifier::getObjectType( m_aObjectCID ))); +} +void DragMethod_Base::TakeSdrDragComment(String& rStr) const +{ + rStr = String( getUndoDescription() ); +} +Pointer DragMethod_Base::GetSdrDragPointer() const +{ + if( IsDraggingPoints() || IsDraggingGluePoints() ) + return Pointer(POINTER_MOVEPOINT); + else + return Pointer(POINTER_MOVE); +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/DragMethod_Base.hxx b/chart2/source/controller/main/DragMethod_Base.hxx new file mode 100644 index 000000000000..63d88936beca --- /dev/null +++ b/chart2/source/controller/main/DragMethod_Base.hxx @@ -0,0 +1,72 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_Base.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DRAGMETHOD_BASE_HXX +#define CHART2_DRAGMETHOD_BASE_HXX + +#include "DrawViewWrapper.hxx" +#include <svx/ActionDescriptionProvider.hxx> +// header for class SdrDragMethod +#include <svx/svddrgmt.hxx> + +// header for class WeakReference +#include <cppuhelper/weakref.hxx> + +namespace chart +{ + +class DragMethod_Base : public SdrDragMethod +{ +public: + DragMethod_Base( DrawViewWrapper& rDrawViewWrapper, const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel + , ActionDescriptionProvider::ActionType eActionType = ActionDescriptionProvider::MOVE ); + virtual ~DragMethod_Base(); + + virtual rtl::OUString getUndoDescription() const; + + virtual void TakeSdrDragComment(String& rStr) const; + virtual Pointer GetSdrDragPointer() const; + +protected: + ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > getChartModel() const; + +protected: + DrawViewWrapper& m_rDrawViewWrapper; + rtl::OUString m_aObjectCID; + ActionDescriptionProvider::ActionType m_eActionType; + +private: + ::com::sun::star::uno::WeakReference< ::com::sun::star::frame::XModel > m_xChartModel; +}; + +} // namespace chart + +// CHART2_DRAGMETHOD_BASE_HXX +#endif diff --git a/chart2/source/controller/main/DragMethod_PieSegment.cxx b/chart2/source/controller/main/DragMethod_PieSegment.cxx new file mode 100644 index 000000000000..43bc637e3ef6 --- /dev/null +++ b/chart2/source/controller/main/DragMethod_PieSegment.cxx @@ -0,0 +1,166 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_PieSegment.cxx,v $ + * $Revision: 1.4.68.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "DragMethod_PieSegment.hxx" + +#include "Strings.hrc" +#include "ResId.hxx" +#include "macros.hxx" +#include "ObjectIdentifier.hxx" +#include <rtl/math.hxx> +#include <svx/svdpagv.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <basegfx/matrix/b2dhommatrix.hxx> + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; +using ::basegfx::B2DVector; + +DragMethod_PieSegment::DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper + , const rtl::OUString& rObjectCID + , const Reference< frame::XModel >& xChartModel ) + : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel ) + , m_aStartVector(100.0,100.0) + , m_fInitialOffset(0.0) + , m_fAdditionalOffset(0.0) + , m_aDragDirection(1000.0,1000.0) + , m_fDragRange( 1.0 ) +{ + rtl::OUString aParameter( ObjectIdentifier::getDragParameterString( m_aObjectCID ) ); + + sal_Int32 nOffsetPercent(0); + awt::Point aMinimumPosition(0,0); + awt::Point aMaximumPosition(0,0); + + ObjectIdentifier::parsePieSegmentDragParameterString( + aParameter, nOffsetPercent, aMinimumPosition, aMaximumPosition ); + + m_fInitialOffset = nOffsetPercent / 100.0; + if( m_fInitialOffset < 0.0 ) + m_fInitialOffset = 0.0; + if( m_fInitialOffset > 1.0 ) + m_fInitialOffset = 1.0; + B2DVector aMinVector( aMinimumPosition.X, aMinimumPosition.Y ); + B2DVector aMaxVector( aMaximumPosition.X, aMaximumPosition.Y ); + m_aDragDirection = aMaxVector - aMinVector; + m_fDragRange = m_aDragDirection.scalar( m_aDragDirection ); + if( ::rtl::math::approxEqual( m_fDragRange, 0.0 ) ) + m_fDragRange = 1.0; +} +DragMethod_PieSegment::~DragMethod_PieSegment() +{ +} +void DragMethod_PieSegment::TakeSdrDragComment(String& rStr) const +{ + rStr = String( SchResId( STR_STATUS_PIE_SEGMENT_EXPLODED ) ); + rStr.SearchAndReplaceAscii( "%PERCENTVALUE", String::CreateFromInt32( static_cast<sal_Int32>((m_fAdditionalOffset+m_fInitialOffset)*100.0) )); +} +bool DragMethod_PieSegment::BeginSdrDrag() +{ + Point aStart( DragStat().GetStart() ); + m_aStartVector = B2DVector( aStart.X(), aStart.Y() ); + Show(); + return true; +} +void DragMethod_PieSegment::MoveSdrDrag(const Point& rPnt) +{ + if( DragStat().CheckMinMoved(rPnt) ) + { + //calculate new offset + B2DVector aShiftVector(( B2DVector( rPnt.X(), rPnt.Y() ) - m_aStartVector )); + m_fAdditionalOffset = m_aDragDirection.scalar( aShiftVector )/m_fDragRange; // projection + + if( m_fAdditionalOffset < -m_fInitialOffset ) + m_fAdditionalOffset = -m_fInitialOffset; + else if( m_fAdditionalOffset > (1.0-m_fInitialOffset) ) + m_fAdditionalOffset = 1.0 - m_fInitialOffset; + + B2DVector aNewPosVector = m_aStartVector + (m_aDragDirection * m_fAdditionalOffset); + Point aNewPos = Point( (long)(aNewPosVector.getX()), (long)(aNewPosVector.getY()) ); + if( aNewPos != DragStat().GetNow() ) + { + Hide(); + DragStat().NextMove( aNewPos ); + Show(); + } + } +} +bool DragMethod_PieSegment::EndSdrDrag(bool /*bCopy*/) +{ + Hide(); + + try + { + Reference< frame::XModel > xChartModel( this->getChartModel() ); + if( xChartModel.is() ) + { + Reference< beans::XPropertySet > xPointProperties( + ObjectIdentifier::getObjectPropertySet( m_aObjectCID, xChartModel ) ); + if( xPointProperties.is() ) + xPointProperties->setPropertyValue( C2U( "Offset" ), uno::makeAny( m_fAdditionalOffset+m_fInitialOffset )); + } + } + catch( const uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } + + return true; +} +basegfx::B2DHomMatrix DragMethod_PieSegment::getCurrentTransformation() +{ + basegfx::B2DHomMatrix aRetval; + + aRetval.translate(DragStat().GetDX(), DragStat().GetDY()); + + return aRetval; +} +void DragMethod_PieSegment::createSdrDragEntries() +{ + SdrObject* pObj = m_rDrawViewWrapper.getSelectedObject(); + SdrPageView* pPV = m_rDrawViewWrapper.GetPageView(); + + if( pObj && pPV ) + { + const basegfx::B2DPolyPolygon aNewPolyPolygon(pObj->TakeXorPoly()); + addSdrDragEntry(new SdrDragEntryPolyPolygon(aNewPolyPolygon)); + } +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/DragMethod_PieSegment.hxx b/chart2/source/controller/main/DragMethod_PieSegment.hxx new file mode 100644 index 000000000000..947ee57896b1 --- /dev/null +++ b/chart2/source/controller/main/DragMethod_PieSegment.hxx @@ -0,0 +1,67 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_PieSegment.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DRAGMETHOD_PIESEGMENT_HXX +#define CHART2_DRAGMETHOD_PIESEGMENT_HXX + +#include "DragMethod_Base.hxx" +#include <basegfx/vector/b2dvector.hxx> + +namespace chart +{ + +class DragMethod_PieSegment : public DragMethod_Base +{ +public: + DragMethod_PieSegment( DrawViewWrapper& rDrawViewWrapper, const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel ); + virtual ~DragMethod_PieSegment(); + + virtual void TakeSdrDragComment(String& rStr) const; + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + + virtual basegfx::B2DHomMatrix getCurrentTransformation(); + +protected: + virtual void createSdrDragEntries(); + +private: + ::basegfx::B2DVector m_aStartVector; + double m_fInitialOffset; + double m_fAdditionalOffset; + ::basegfx::B2DVector m_aDragDirection; + double m_fDragRange; +}; + +} // namespace chart + +// CHART2_DRAGMETHOD_PIESEGMENT_HXX +#endif diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.cxx b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx new file mode 100644 index 000000000000..a949dc2436c6 --- /dev/null +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.cxx @@ -0,0 +1,240 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_RotateDiagram.cxx,v $ + * $Revision: 1.6.60.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "DragMethod_RotateDiagram.hxx" + +#include "SelectionHelper.hxx" +#include "CommonConverters.hxx" +#include "ChartModelHelper.hxx" +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include "ChartTypeHelper.hxx" +#include "ThreeDHelper.hxx" +#include <svx/sdr/overlay/overlaypolypolygon.hxx> +#include <svx/sdr/overlay/overlaymanager.hxx> + +// header for class E3dScene +#include <svx/scene3d.hxx> +#include <basegfx/matrix/b3dhommatrix.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <basegfx/polygon/b2dpolypolygontools.hxx> +#include <svx/sdr/contact/viewcontactofe3dscene.hxx> +#include <drawinglayer/geometry/viewinformation3d.hxx> + +#define FIXED_SIZE_FOR_3D_CHART_VOLUME (10000.0) + +//............................................................................. +namespace chart +{ +//............................................................................. + +using namespace ::com::sun::star; +using ::com::sun::star::uno::Reference; + +DragMethod_RotateDiagram::DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper + , const rtl::OUString& rObjectCID + , const Reference< frame::XModel >& xChartModel + , RotationDirection eRotationDirection ) + : DragMethod_Base( rDrawViewWrapper, rObjectCID, xChartModel, ActionDescriptionProvider::ROTATE ) + , m_pScene(0) + , m_aReferenceRect(100,100,100,100) + , m_aStartPos(0,0) + , m_aWireframePolyPolygon() + , m_fInitialXAngleRad(0.0) + , m_fInitialYAngleRad(0.0) + , m_fInitialZAngleRad(0.0) + , m_fAdditionalXAngleRad(0.0) + , m_fAdditionalYAngleRad(0.0) + , m_fAdditionalZAngleRad(0.0) + , m_nInitialHorizontalAngleDegree(0) + , m_nInitialVerticalAngleDegree(0) + , m_nAdditionalHorizontalAngleDegree(0) + , m_nAdditionalVerticalAngleDegree(0) + , m_eRotationDirection(eRotationDirection) + , m_bRightAngledAxes(sal_False) +{ + m_pScene = SelectionHelper::getSceneToRotate( rDrawViewWrapper.getNamedSdrObject( rObjectCID ) ); + SdrObject* pObj = rDrawViewWrapper.getSelectedObject(); + if(pObj && m_pScene) + { + m_aReferenceRect = pObj->GetLogicRect(); + Rectangle aTemp = m_pScene->GetLogicRect(); + + m_aWireframePolyPolygon = m_pScene->CreateWireframe(); + + uno::Reference< chart2::XDiagram > xDiagram( ChartModelHelper::findDiagram(this->getChartModel()) ); + uno::Reference< beans::XPropertySet > xDiagramProperties( xDiagram, uno::UNO_QUERY ); + if( xDiagramProperties.is() ) + { + ThreeDHelper::getRotationFromDiagram( xDiagramProperties + , m_nInitialHorizontalAngleDegree, m_nInitialVerticalAngleDegree ); + + ThreeDHelper::getRotationAngleFromDiagram( xDiagramProperties + , m_fInitialXAngleRad, m_fInitialYAngleRad, m_fInitialZAngleRad ); + + if( ChartTypeHelper::isSupportingRightAngledAxes( + DiagramHelper::getChartTypeByIndex( xDiagram, 0 ) ) ) + xDiagramProperties->getPropertyValue(C2U( "RightAngledAxes" )) >>= m_bRightAngledAxes; + if(m_bRightAngledAxes) + { + if( m_eRotationDirection==ROTATIONDIRECTION_Z ) + m_eRotationDirection=ROTATIONDIRECTION_FREE; + ThreeDHelper::adaptRadAnglesForRightAngledAxes( m_fInitialXAngleRad, m_fInitialYAngleRad ); + } + } + } +} +DragMethod_RotateDiagram::~DragMethod_RotateDiagram() +{ +} +void DragMethod_RotateDiagram::TakeSdrDragComment(String& /*rStr*/) const +{ +} +bool DragMethod_RotateDiagram::BeginSdrDrag() +{ + m_aStartPos = DragStat().GetStart(); + Show(); + return true; +} +void DragMethod_RotateDiagram::MoveSdrDrag(const Point& rPnt) +{ + if( DragStat().CheckMinMoved(rPnt) ) + { + Hide(); + + //calculate new angle + double fX = F_PI / 2.0 * (double)(rPnt.Y() - m_aStartPos.Y()) + / (double)m_aReferenceRect.GetHeight(); + double fY = F_PI * (double)(rPnt.X() - m_aStartPos.X()) + / (double)m_aReferenceRect.GetWidth(); + + if( m_eRotationDirection != ROTATIONDIRECTION_Y ) + m_fAdditionalYAngleRad = fY; + else + m_fAdditionalYAngleRad = 0.0; + if( m_eRotationDirection != ROTATIONDIRECTION_X ) + m_fAdditionalXAngleRad = fX; + else + m_fAdditionalXAngleRad = 0.0; + m_fAdditionalZAngleRad = 0.0; + + if( m_eRotationDirection == ROTATIONDIRECTION_Z ) + { + m_fAdditionalXAngleRad = 0.0; + m_fAdditionalYAngleRad = 0.0; + + double fCx = m_aReferenceRect.Center().X(); + double fCy = m_aReferenceRect.Center().Y(); + + m_fAdditionalZAngleRad = atan((double)(fCx - m_aStartPos.X())/(m_aStartPos.Y()-fCy)) + + atan((double)(fCx - rPnt.X())/(fCy-rPnt.Y())); + } + + m_nAdditionalHorizontalAngleDegree = static_cast<sal_Int32>(m_fAdditionalXAngleRad*180.0/F_PI); + m_nAdditionalVerticalAngleDegree = -static_cast<sal_Int32>(m_fAdditionalYAngleRad*180.0/F_PI); + + DragStat().NextMove(rPnt); + Show(); + } +} +bool DragMethod_RotateDiagram::EndSdrDrag(bool /*bCopy*/) +{ + Hide(); + + if( m_bRightAngledAxes || m_eRotationDirection==ROTATIONDIRECTION_Z ) + { + double fResultX = m_fInitialXAngleRad + m_fAdditionalXAngleRad; + double fResultY = m_fInitialYAngleRad + m_fAdditionalYAngleRad; + double fResultZ = m_fInitialZAngleRad + m_fAdditionalZAngleRad; + + if(m_bRightAngledAxes) + ThreeDHelper::adaptRadAnglesForRightAngledAxes( fResultX, fResultY ); + + ThreeDHelper::setRotationAngleToDiagram( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( this->getChartModel() ), uno::UNO_QUERY ) + , fResultX, fResultY, fResultZ ); + } + else + { + ThreeDHelper::setRotationToDiagram( ( uno::Reference< beans::XPropertySet >( ChartModelHelper::findDiagram( this->getChartModel() ), uno::UNO_QUERY ) ) + , m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree ); + } + + return true; +} +void DragMethod_RotateDiagram::CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager) +{ + ::basegfx::B3DHomMatrix aCurrentTransform; + aCurrentTransform.translate( -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0, + -FIXED_SIZE_FOR_3D_CHART_VOLUME/2.0 ); + + double fResultX = m_fInitialXAngleRad + m_fAdditionalXAngleRad; + double fResultY = m_fInitialYAngleRad + m_fAdditionalYAngleRad; + double fResultZ = m_fInitialZAngleRad + m_fAdditionalZAngleRad; + + if(!m_bRightAngledAxes) + { + if( m_eRotationDirection!=ROTATIONDIRECTION_Z ) + { + ThreeDHelper::convertElevationRotationDegToXYZAngleRad( + m_nInitialHorizontalAngleDegree+m_nAdditionalHorizontalAngleDegree, -(m_nInitialVerticalAngleDegree+m_nAdditionalVerticalAngleDegree) + , fResultX, fResultY, fResultZ ); + } + aCurrentTransform.rotate( fResultX, fResultY, fResultZ ); + } + else + { + ThreeDHelper::adaptRadAnglesForRightAngledAxes( fResultX, fResultY ); + aCurrentTransform.shearXY(fResultY,-(fResultX)); + } + + if(m_aWireframePolyPolygon.count() && m_pScene) + { + const sdr::contact::ViewContactOfE3dScene& rVCScene = static_cast< sdr::contact::ViewContactOfE3dScene& >(m_pScene->GetViewContact()); + const drawinglayer::geometry::ViewInformation3D aViewInfo3D(rVCScene.getViewInformation3D()); + const basegfx::B3DHomMatrix aWorldToView(aViewInfo3D.getDeviceToView() * aViewInfo3D.getProjection() * aViewInfo3D.getOrientation()); + const basegfx::B3DHomMatrix aTransform(aWorldToView * aCurrentTransform); + + // transform to relative scene coordinates + basegfx::B2DPolyPolygon aPolyPolygon(basegfx::tools::createB2DPolyPolygonFromB3DPolyPolygon(m_aWireframePolyPolygon, aTransform)); + + // transform to 2D view coordinates + aPolyPolygon.transform(rVCScene.getObjectTransformation()); + + sdr::overlay::OverlayPolyPolygonStriped* pNew = new ::sdr::overlay::OverlayPolyPolygonStriped(aPolyPolygon); + rOverlayManager.add(*pNew); + addToOverlayObjectList(*pNew); + } +} +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/DragMethod_RotateDiagram.hxx b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx new file mode 100644 index 000000000000..a29b65ceabba --- /dev/null +++ b/chart2/source/controller/main/DragMethod_RotateDiagram.hxx @@ -0,0 +1,95 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: DragMethod_RotateDiagram.hxx,v $ + * $Revision: 1.5.60.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_DRAGMETHOD_ROTATEDIAGRAM_HXX +#define CHART2_DRAGMETHOD_ROTATEDIAGRAM_HXX + +#include "DragMethod_Base.hxx" + +// header for class ::basegfx::B3DPolyPolygon +#include <basegfx/polygon/b3dpolypolygon.hxx> + +namespace chart +{ + +class DragMethod_RotateDiagram : public DragMethod_Base +{ +public: + enum RotationDirection + { + ROTATIONDIRECTION_FREE, + ROTATIONDIRECTION_X, + ROTATIONDIRECTION_Y, + ROTATIONDIRECTION_Z + }; + + DragMethod_RotateDiagram( DrawViewWrapper& rDrawViewWrapper + , const rtl::OUString& rObjectCID + , const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& xChartModel + , RotationDirection eRotationDirection + ); + virtual ~DragMethod_RotateDiagram(); + + virtual void TakeSdrDragComment(String& rStr) const; + + virtual bool BeginSdrDrag(); + virtual void MoveSdrDrag(const Point& rPnt); + virtual bool EndSdrDrag(bool bCopy); + + virtual void CreateOverlayGeometry(sdr::overlay::OverlayManager& rOverlayManager); + +private: + E3dScene* m_pScene; + + Rectangle m_aReferenceRect; + Point m_aStartPos; + basegfx::B3DPolyPolygon m_aWireframePolyPolygon; + + double m_fInitialXAngleRad; + double m_fInitialYAngleRad; + double m_fInitialZAngleRad; + + double m_fAdditionalXAngleRad; + double m_fAdditionalYAngleRad; + double m_fAdditionalZAngleRad; + + sal_Int32 m_nInitialHorizontalAngleDegree; + sal_Int32 m_nInitialVerticalAngleDegree; + + sal_Int32 m_nAdditionalHorizontalAngleDegree; + sal_Int32 m_nAdditionalVerticalAngleDegree; + + RotationDirection m_eRotationDirection; + sal_Bool m_bRightAngledAxes; +}; + +} // namespace chart + +// CHART2_DRAGMETHOD_ROTATEDIAGRAM_HXX +#endif diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx new file mode 100644 index 000000000000..a79a256e3e4f --- /dev/null +++ b/chart2/source/controller/main/ElementSelector.cxx @@ -0,0 +1,328 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ElementSelector.cxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ElementSelector.hxx" +#include "macros.hxx" +#include "ObjectNameProvider.hxx" +#include "ObjectHierarchy.hxx" +#include "servicenames.hxx" +#include <chartview/ExplicitValueProvider.hxx> + +#include <toolkit/helper/vclunohelper.hxx> +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +#include <com/sun/star/chart2/XChartDocument.hpp> +#include <com/sun/star/frame/XControlNotificationListener.hpp> +#include <com/sun/star/util/XURLTransformer.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> + +namespace chart +{ + +using namespace com::sun::star; +using namespace com::sun::star::uno; +using ::com::sun::star::uno::Any; +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; + +namespace +{ +static const ::rtl::OUString lcl_aServiceName( + RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.comp.chart.ElementSelectorToolbarController" )); +} + +//------------------------------------------------------------------------------ + +SelectorListBox::SelectorListBox( Window* pParent, WinBits nStyle ) + : ListBox( pParent, nStyle ) + , m_bReleaseFocus( true ) +{ +} + +SelectorListBox::~SelectorListBox() +{ +} + +void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectHierarchy::tCID & rParent, std::vector< ListBoxEntryData >& rEntries + , const sal_Int32 nHierarchyDepth, const Reference< chart2::XChartDocument >& xChartDoc ) +{ + ObjectHierarchy::tChildContainer aChildren( rHierarchy.getChildren(rParent) ); + ObjectHierarchy::tChildContainer::const_iterator aIt( aChildren.begin()); + while( aIt != aChildren.end() ) + { + ::rtl::OUString aCID = *aIt; + ListBoxEntryData aEntry; + aEntry.CID = aCID; + aEntry.UIName += ObjectNameProvider::getNameForCID( aCID, xChartDoc ); + aEntry.nHierarchyDepth = nHierarchyDepth; + rEntries.push_back(aEntry); + lcl_addObjectsToList( rHierarchy, aCID, rEntries, nHierarchyDepth+1, xChartDoc ); + ++aIt; + } +} + +void SelectorListBox::SetChartController( const Reference< frame::XController >& xChartController ) +{ + m_xChartController = xChartController; +} + +void SelectorListBox::UpdateChartElementsListAndSelection() +{ + Clear(); + m_aEntries.clear(); + + Reference< frame::XController > xChartController( m_xChartController ); + if( xChartController.is() ) + { + Reference< view::XSelectionSupplier > xSelectionSupplier( xChartController, uno::UNO_QUERY); + rtl::OUString aSelectedCID; + if( xSelectionSupplier.is() ) + xSelectionSupplier->getSelection() >>= aSelectedCID; + + Reference< chart2::XChartDocument > xChartDoc( xChartController->getModel(), uno::UNO_QUERY ); + ObjectType eType( ObjectIdentifier::getObjectType( aSelectedCID )); + bool bAddSelectionToList = false; + if( eType == OBJECTTYPE_DATA_POINT || eType == OBJECTTYPE_DATA_LABEL ) + bAddSelectionToList = true; + + Reference< uno::XInterface > xChartView; + Reference< lang::XMultiServiceFactory > xFact( xChartController->getModel(), uno::UNO_QUERY ); + if( xFact.is() ) + xChartView = xFact->createInstance( CHART_VIEW_SERVICE_NAME ); + ExplicitValueProvider* pExplicitValueProvider = 0;//ExplicitValueProvider::getExplicitValueProvider(xChartView); dies erzeugt alle sichtbaren datenpinkte, das ist zu viel + ObjectHierarchy aHierarchy( xChartDoc, pExplicitValueProvider, true /*bFlattenDiagram*/, true /*bOrderingForElementSelector*/ ); + lcl_addObjectsToList( aHierarchy, aHierarchy.getRootNodeCID(), m_aEntries, 0, xChartDoc ); + + std::vector< ListBoxEntryData >::iterator aIt( m_aEntries.begin() ); + if( bAddSelectionToList ) + { + rtl::OUString aSeriesCID = ObjectIdentifier::createClassifiedIdentifierForParticle( ObjectIdentifier::getSeriesParticleFromCID( aSelectedCID ) ); + for( aIt = m_aEntries.begin(); aIt != m_aEntries.end(); ++aIt ) + { + if( aIt->CID.match( aSeriesCID ) ) + { + ListBoxEntryData aEntry; + aEntry.UIName = ObjectNameProvider::getNameForCID( aSelectedCID, xChartDoc ); + aEntry.CID = aSelectedCID; + ++aIt; + if( aIt != m_aEntries.end() ) + m_aEntries.insert(aIt, aEntry); + else + m_aEntries.push_back( aEntry ); + break; + } + } + } + + USHORT nEntryPosToSelect = 0; bool bSelectionFound = false; + aIt = m_aEntries.begin(); + for( USHORT nN=0; aIt != m_aEntries.end(); ++aIt, ++nN ) + { + InsertEntry( aIt->UIName ); + if( !bSelectionFound && aSelectedCID.equals( aIt->CID ) ) + { + nEntryPosToSelect = nN; + bSelectionFound = true; + } + } + + if( bSelectionFound ) + SelectEntryPos(nEntryPosToSelect); + + USHORT nEntryCount = GetEntryCount(); + if( nEntryCount > 100 ) + nEntryCount = 100; + SetDropDownLineCount( nEntryCount ); + } + SaveValue();//remind current selection pos +} + +void SelectorListBox::ReleaseFocus_Impl() +{ + if ( !m_bReleaseFocus ) + { + m_bReleaseFocus = true; + return; + } + + Reference< frame::XController > xController( m_xChartController ); + Reference< frame::XFrame > xFrame( xController->getFrame() ); + if ( xFrame.is() && xFrame->getContainerWindow().is() ) + xFrame->getContainerWindow()->setFocus(); +} + +void SelectorListBox::Select() +{ + ListBox::Select(); + + if ( !IsTravelSelect() ) + { + USHORT nPos = GetSelectEntryPos(); + if( nPos < m_aEntries.size() ) + { + rtl::OUString aCID = m_aEntries[nPos].CID; + uno::Any aASelection( uno::makeAny(aCID) ); + Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY ); + if( xSelectionSupplier.is() ) + xSelectionSupplier->select(aASelection); + } + ReleaseFocus_Impl(); + } +} + +long SelectorListBox::Notify( NotifyEvent& rNEvt ) +{ + long nHandled = 0; + + if ( rNEvt.GetType() == EVENT_KEYINPUT ) + { + USHORT nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode(); + + switch ( nCode ) + { + case KEY_RETURN: + case KEY_TAB: + { + if ( KEY_TAB == nCode ) + m_bReleaseFocus = false; + else + nHandled = 1; + Select(); + break; + } + + case KEY_ESCAPE: + SelectEntryPos( GetSavedValue() ); //restore saved selection + ReleaseFocus_Impl(); + break; + } + } + else if ( EVENT_LOSEFOCUS == rNEvt.GetType() ) + { + if ( !HasFocus() ) + SelectEntryPos( GetSavedValue() ); + } + + return nHandled ? nHandled : ListBox::Notify( rNEvt ); +} + +Reference< ::com::sun::star::accessibility::XAccessible > SelectorListBox::CreateAccessible() +{ + UpdateChartElementsListAndSelection(); + return ListBox::CreateAccessible(); +} + +// implement XServiceInfo methods basing upon getSupportedServiceNames_Static +APPHELPER_XSERVICEINFO_IMPL( ElementSelectorToolbarController, lcl_aServiceName ); + +//------------------------------------------------------------------------------ +Sequence< ::rtl::OUString > ElementSelectorToolbarController::getSupportedServiceNames_Static() +{ + Sequence< ::rtl::OUString > aServices(1); + aServices[ 0 ] = C2U( "com.sun.star.frame.ToolbarController" ); + return aServices; +} +// ----------------------------------------------------------------------------- +ElementSelectorToolbarController::ElementSelectorToolbarController( const uno::Reference< uno::XComponentContext > & xContext ) + : m_xCC( xContext ) +{ +} +// ----------------------------------------------------------------------------- +ElementSelectorToolbarController::~ElementSelectorToolbarController() +{ +} +// ----------------------------------------------------------------------------- +// XInterface +Any SAL_CALL ElementSelectorToolbarController::queryInterface( const Type& _rType ) throw (RuntimeException) +{ + Any aReturn = ToolboxController::queryInterface(_rType); + if (!aReturn.hasValue()) + aReturn = ElementSelectorToolbarController_BASE::queryInterface(_rType); + return aReturn; +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::acquire() throw () +{ + ToolboxController::acquire(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::release() throw () +{ + ToolboxController::release(); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::initialize( const Sequence< Any >& rArguments ) throw (Exception, RuntimeException) +{ + ToolboxController::initialize(rArguments); +} +// ----------------------------------------------------------------------------- +void SAL_CALL ElementSelectorToolbarController::statusChanged( const frame::FeatureStateEvent& rEvent ) throw ( RuntimeException ) +{ + if( m_apSelectorListBox.get() ) + { + vos::OGuard aSolarMutexGuard( Application::GetSolarMutex() ); + if( rEvent.FeatureURL.Path.equalsAscii( "ChartElementSelector" ) ) + { + Reference< frame::XController > xChartController; + rEvent.State >>= xChartController; + m_apSelectorListBox->SetChartController( xChartController ); + m_apSelectorListBox->UpdateChartElementsListAndSelection(); + } + } +} +// ----------------------------------------------------------------------------- +uno::Reference< awt::XWindow > SAL_CALL ElementSelectorToolbarController::createItemWindow( const uno::Reference< awt::XWindow >& xParent ) + throw (uno::RuntimeException) +{ + uno::Reference< awt::XWindow > xItemWindow; + if( !m_apSelectorListBox.get() ) + { + Window* pParent = VCLUnoHelper::GetWindow( xParent ); + if( pParent ) + { + m_apSelectorListBox = ::std::auto_ptr< SelectorListBox >( new SelectorListBox( pParent, WB_DROPDOWN|WB_AUTOHSCROLL|WB_BORDER ) ); + ::Size aLogicalSize( 95, 160 ); + ::Size aPixelSize = m_apSelectorListBox->LogicToPixel( aLogicalSize, MAP_APPFONT ); + m_apSelectorListBox->SetSizePixel( aPixelSize ); + m_apSelectorListBox->SetDropDownLineCount( 5 ); + } + } + if( m_apSelectorListBox.get() ) + xItemWindow = VCLUnoHelper::GetInterface( m_apSelectorListBox.get() ); + return xItemWindow; +} + +//.......................................................................... +} // chart2 +//.......................................................................... diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx new file mode 100644 index 000000000000..3992745c9f02 --- /dev/null +++ b/chart2/source/controller/main/ElementSelector.hxx @@ -0,0 +1,125 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ElementSelector.hxx,v $ + * $Revision: 1.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART_ELEMENTSELECTOR_HXX +#define _CHART_ELEMENTSELECTOR_HXX + +#include "ServiceMacros.hxx" +#include <com/sun/star/lang/XServiceInfo.hpp> +#include <cppuhelper/implbase1.hxx> +#include <svtools/toolboxcontroller.hxx> + +#include <vcl/lstbox.hxx> +#include <cppuhelper/weakref.hxx> + +#include <memory> + +//............................................................................. +namespace chart +{ +//............................................................................. + +struct ListBoxEntryData +{ + rtl::OUString UIName; + rtl::OUString CID; + sal_Int32 nHierarchyDepth; + + ListBoxEntryData() : nHierarchyDepth(0) + { + } +}; + +class SelectorListBox : public ListBox +{ + public: + SelectorListBox( Window* pParent, WinBits nStyle ); + virtual ~SelectorListBox(); + + virtual void Select(); + virtual long Notify( NotifyEvent& rNEvt ); + virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible(); + + void ReleaseFocus_Impl(); + + void SetChartController( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XController >& xChartController ); + void UpdateChartElementsListAndSelection(); + + private: + ::com::sun::star::uno::WeakReference< + ::com::sun::star::frame::XController > m_xChartController; + + ::std::vector< ListBoxEntryData > m_aEntries; + + bool m_bReleaseFocus; +}; + +// ------------------------------------------------------------------ +// ------------------------------------------------------------------ + +typedef ::cppu::ImplHelper1 < ::com::sun::star::lang::XServiceInfo> ElementSelectorToolbarController_BASE; + +class ElementSelectorToolbarController : public ::svt::ToolboxController + , ElementSelectorToolbarController_BASE +{ +public: + ElementSelectorToolbarController( ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > const & xContext ); + virtual ~ElementSelectorToolbarController(); + + // XServiceInfo + APPHELPER_XSERVICEINFO_DECL() + APPHELPER_SERVICE_FACTORY_HELPER(ElementSelectorToolbarController) + + // XInterface
+ virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL acquire() throw ();
+ virtual void SAL_CALL release() throw ();
+
+ // XInitialization
+ virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException);
+ // XStatusListener
+ virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
+ // XToolbarController
+ virtual ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > SAL_CALL createItemWindow( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow >& Parent ) throw (::com::sun::star::uno::RuntimeException);
+ +private: + //no default constructor + ElementSelectorToolbarController(){}
+
+private: + ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xCC; + ::std::auto_ptr< SelectorListBox > m_apSelectorListBox; +}; + +//............................................................................. +} //namespace chart +//............................................................................. + +#endif diff --git a/chart2/source/controller/main/ObjectHierarchy.cxx b/chart2/source/controller/main/ObjectHierarchy.cxx new file mode 100644 index 000000000000..5912847e4bfe --- /dev/null +++ b/chart2/source/controller/main/ObjectHierarchy.cxx @@ -0,0 +1,817 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: ObjectHierarchy.cxx,v $ + * $Revision: 1.7 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "ObjectHierarchy.hxx" +#include "ObjectIdentifier.hxx" +#include "ChartModelHelper.hxx" +#include "DiagramHelper.hxx" +#include "RegressionCurveHelper.hxx" +#include "AxisHelper.hxx" +#include "chartview/ExplicitValueProvider.hxx" +#include "macros.hxx" +#include "LineProperties.hxx" +#include "ChartTypeHelper.hxx" +#include "DataSeriesHelper.hxx" +#include "LegendHelper.hxx" + +#include <map> +#include <algorithm> + +#include <com/sun/star/chart2/XTitled.hpp> +#include <com/sun/star/chart2/XCoordinateSystemContainer.hpp> +#include <com/sun/star/chart2/XChartTypeContainer.hpp> +#include <com/sun/star/chart2/XDataSeriesContainer.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/KeyModifier.hpp> + +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace +{ +struct lcl_ObjectToCID : public ::std::unary_function< Reference< uno::XInterface >, OUString > +{ + explicit lcl_ObjectToCID( const Reference< chart2::XChartDocument > & xChartDoc ) : + m_xModel( xChartDoc, uno::UNO_QUERY ) + {} + + OUString operator() ( const Reference< uno::XInterface > & xObj ) + { + return ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xObj, m_xModel ); + } + +private: + Reference< frame::XModel > m_xModel; +}; + +void lcl_getChildCIDs( + ::chart::ObjectHierarchy::tChildContainer & rOutChildren, + const Reference< container::XIndexAccess > & xShapes ) +{ + if( xShapes.is()) + { + sal_Int32 nCount = xShapes->getCount(); + for( sal_Int32 i=0; i<nCount; ++i) + { + Reference< beans::XPropertySet > xShapeProp( xShapes->getByIndex( i ), uno::UNO_QUERY ); + if( xShapeProp.is()) + { + Reference< beans::XPropertySetInfo > xInfo( xShapeProp->getPropertySetInfo()); + OUString aName; + if( xInfo.is() && + xInfo->hasPropertyByName( C2U("Name")) && + (xShapeProp->getPropertyValue( C2U("Name")) >>= aName ) && + aName.getLength() > 0 && + ::chart::ObjectIdentifier::isCID( aName )) + { + rOutChildren.push_back( aName ); + } + Reference< container::XIndexAccess > xNewShapes( xShapeProp, uno::UNO_QUERY ); + if( xNewShapes.is()) + lcl_getChildCIDs( rOutChildren, xNewShapes ); + } + } + } +} + +void lcl_addAxisTitle( const Reference< XAxis >& xAxis, ::chart::ObjectHierarchy::tChildContainer& rContainer, const Reference< frame::XModel >& xChartModel ) +{ + Reference< XTitled > xAxisTitled( xAxis, uno::UNO_QUERY ); + if( xAxisTitled.is()) + { + Reference< XTitle > xAxisTitle( xAxisTitled->getTitleObject()); + if( xAxisTitle.is()) + rContainer.push_back( + ::chart::ObjectIdentifier::createClassifiedIdentifierForObject( xAxisTitle, xChartModel )); + } +} + +} // anonymous namespace + + +namespace chart +{ + +namespace impl +{ +class ImplObjectHierarchy +{ +public: + explicit ImplObjectHierarchy( + const Reference< XChartDocument > & xChartDocument, + ExplicitValueProvider * pExplicitValueProvider, + bool bFlattenDiagram, bool bOrderingForElementSelector ); + + bool hasChildren( const OUString & rParent ); + ObjectHierarchy::tChildContainer getChildren( const OUString & rParent ); + ObjectHierarchy::tChildContainer getSiblings( const OUString & rNode ); + + ObjectHierarchy::tCID getParent( const ObjectHierarchy::tCID & rCID ); + +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 ); + void createWallAndFloor( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XDiagram > & xDiagram ); + void createLegendTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ); + + ObjectHierarchy::tCID getParentImpl( + const ObjectHierarchy::tCID & rParentCID, + const ObjectHierarchy::tCID & rCID ); + + typedef ::std::map< OUString, 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 = 0; +} + +void ImplObjectHierarchy::createTree( const Reference< XChartDocument > & xChartDocument ) +{ + if( !xChartDocument.is()) + return; + + //@todo: change ObjectIdentifier to take an XChartDocument rather than XModel + Reference< frame::XModel > xModel( xChartDocument, uno::UNO_QUERY ); + Reference< XDiagram > xDiagram( ChartModelHelper::findDiagram( xChartDocument ) ); + OUString aDiaCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram, xModel )); + ObjectHierarchy::tChildContainer aTopLevelContainer; + + // First Level + + // Chart Area + if( m_bOrderingForElementSelector ) + { + aTopLevelContainer.push_back( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ); + aTopLevelContainer.push_back( aDiaCID ); + createWallAndFloor( aTopLevelContainer, xDiagram ); + createLegendTree( aTopLevelContainer, xChartDocument, xDiagram ); + } + + // Main Title + Reference< XTitled > xDocTitled( xChartDocument, uno::UNO_QUERY ); + if( xDocTitled.is()) + { + Reference< XTitle > xMainTitle( xDocTitled->getTitleObject()); + if( xMainTitle.is()) + aTopLevelContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForObject( xMainTitle, xModel )); + } + + 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.push_back( + ObjectIdentifier::createClassifiedIdentifierForObject( xSubTitle, xModel )); + } + + if( !m_bOrderingForElementSelector ) + { + // Axis Titles. Note: These are interpreted of being top level + Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram ) ); + for( sal_Int32 i=0; i<aAxes.getLength(); ++i ) + lcl_addAxisTitle( aAxes[i], aTopLevelContainer, xModel ); + + // Diagram + aTopLevelContainer.push_back( aDiaCID ); + } + + if( m_bFlattenDiagram ) + createDiagramTree( aTopLevelContainer, xChartDocument, xDiagram ); + else + { + ObjectHierarchy::tChildContainer aSubContainer; + createDiagramTree( aSubContainer, xChartDocument, xDiagram ); + if( ! aSubContainer.empty()) + m_aChildMap[ aDiaCID ] = aSubContainer; + } + + if( !m_bOrderingForElementSelector ) + createLegendTree( aTopLevelContainer, xChartDocument, xDiagram ); + } + + // Chart Area + if( !m_bOrderingForElementSelector ) + aTopLevelContainer.push_back( + ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, OUString() ) ); + + if( ! aTopLevelContainer.empty()) + m_aChildMap[ ObjectHierarchy::getRootNodeCID() ] = aTopLevelContainer; +} + +void ImplObjectHierarchy::createLegendTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ) +{ + if( xDiagram.is() && LegendHelper::hasLegend( xDiagram ) ) + { + OUString aLegendCID( ObjectIdentifier::createClassifiedIdentifierForObject( xDiagram->getLegend(), Reference< frame::XModel >( xChartDoc, uno::UNO_QUERY ) )); + rContainer.push_back( aLegendCID ); + + // iterate over child shapes of legend and search for matching CIDs + if( m_pExplicitValueProvider ) + { + Reference< container::XIndexAccess > xLegendShapeContainer( + m_pExplicitValueProvider->getShapeForCID( aLegendCID ), uno::UNO_QUERY ); + ObjectHierarchy::tChildContainer aLegendEntryCIDs; + lcl_getChildCIDs( aLegendEntryCIDs, xLegendShapeContainer ); + + m_aChildMap[ aLegendCID ] = aLegendEntryCIDs; + } + } +} + +void ImplObjectHierarchy::createAxesTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & 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 ) + { + Sequence< Reference< XAxis > > aAxes( AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ true ) ); + if( !m_bOrderingForElementSelector ) + ::std::transform( aAxes.getConstArray(), aAxes.getConstArray() + aAxes.getLength(), + ::std::back_inserter( rContainer ), + lcl_ObjectToCID( xChartDoc )); + + // get all axes, also invisible ones + aAxes = AxisHelper::getAllAxesOfDiagram( xDiagram, /* bOnlyVisible = */ false ); + // Grids + Reference< frame::XModel > xChartModel( xChartDoc, uno::UNO_QUERY ); + for( sal_Int32 nA=0; nA<aAxes.getLength(); ++nA ) + { + Reference< XAxis > xAxis( aAxes[nA] ); + if(!xAxis.is()) + continue; + + sal_Int32 nCooSysIndex = 0; + sal_Int32 nDimensionIndex = 0; + sal_Int32 nAxisIndex = 0; + AxisHelper::getIndicesForAxis( xAxis, xDiagram, nCooSysIndex, nDimensionIndex, nAxisIndex ); + if( nAxisIndex>0 && !ChartTypeHelper::isSupportingSecondaryAxis( xChartType, nDimensionCount, nDimensionIndex ) ) + continue; + + if( m_bOrderingForElementSelector ) + { + // axis + if( AxisHelper::isAxisVisible( xAxis ) ) + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForObject( xAxis, xChartModel ) ); + + // axis title + lcl_addAxisTitle( aAxes[nA], rContainer, xChartModel ); + } + + Reference< beans::XPropertySet > xGridProperties( xAxis->getGridProperties() ); + if( AxisHelper::isGridVisible( xGridProperties ) ) + { + //main grid + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel ) ); + } + + Sequence< Reference< beans::XPropertySet > > aSubGrids( xAxis->getSubGridProperties() );; + sal_Int32 nSubGrid = 0; + for( nSubGrid = 0; nSubGrid < aSubGrids.getLength(); ++nSubGrid ) + { + Reference< beans::XPropertySet > xSubGridProperties( aSubGrids[nSubGrid] ); + if( AxisHelper::isGridVisible( xSubGridProperties ) ) + { + //sub grid + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForGrid( xAxis, xChartModel, nSubGrid ) ); + } + } + } + } +} + +void ImplObjectHierarchy::createWallAndFloor( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XDiagram > & xDiagram ) +{ + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + bool bIsThreeD = ( nDimensionCount == 3 ); + bool bHasWall = DiagramHelper::isSupportingFloorAndWall( xDiagram ); + if( bHasWall && bIsThreeD ) + { + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString())); + + Reference< beans::XPropertySet > xFloor( xDiagram->getFloor()); + if( xFloor.is()) + rContainer.push_back( + ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_FLOOR, rtl::OUString())); + } + +} + +void ImplObjectHierarchy::createDiagramTree( + ObjectHierarchy::tChildContainer & rContainer, + const Reference< XChartDocument > & xChartDoc, + const Reference< XDiagram > & xDiagram ) +{ + if( !m_bOrderingForElementSelector ) + { + createDataSeriesTree( rContainer, xDiagram ); + createAxesTree( rContainer, xChartDoc, xDiagram ); + createWallAndFloor( rContainer, xDiagram ); + } + else + { + createAxesTree( rContainer, xChartDoc, xDiagram ); + createDataSeriesTree( rContainer, xDiagram ); + } +} + +void ImplObjectHierarchy::createDataSeriesTree( + ObjectHierarchy::tChildContainer & rOutDiagramSubContainer, + const Reference< XDiagram > & xDiagram ) +{ + Reference< XCoordinateSystemContainer > xCooSysCnt( xDiagram, uno::UNO_QUERY_THROW ); + + try + { + sal_Int32 nDiagramIndex = 0; + sal_Int32 nDimensionCount = DiagramHelper::getDimension( xDiagram ); + Sequence< Reference< XCoordinateSystem > > aCooSysSeq( + xCooSysCnt->getCoordinateSystems()); + for( sal_Int32 nCooSysIdx=0; nCooSysIdx<aCooSysSeq.getLength(); ++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 ) + { + Reference< XChartType > xChartType( aChartTypeSeq[nCTIdx] ); + Reference< XDataSeriesContainer > xDSCnt( xChartType, uno::UNO_QUERY_THROW ); + Sequence< Reference< XDataSeries > > aSeriesSeq( xDSCnt->getDataSeries() ); + const sal_Int32 nNumberOfSeries = + ChartTypeHelper::getNumberOfDisplayedSeries( xChartType, aSeriesSeq.getLength()); + + for( sal_Int32 nSeriesIdx=0; nSeriesIdx<nNumberOfSeries; ++nSeriesIdx ) + { + OUString aSeriesParticle( + ObjectIdentifier::createParticleForSeries( + nDiagramIndex, nCooSysIdx, nCTIdx, nSeriesIdx )); + ObjectHierarchy::tCID aSeriesCID( + ObjectIdentifier::createClassifiedIdentifierForParticle( aSeriesParticle )); + rOutDiagramSubContainer.push_back( aSeriesCID ); + + ObjectHierarchy::tChildContainer aSeriesSubContainer; + + Reference< chart2::XDataSeries > xSeries( aSeriesSeq[nSeriesIdx], uno::UNO_QUERY ); + + // data lablels + if( DataSeriesHelper::hasDataLabelsAtSeries( xSeries ) ) + { + rtl::OUString aChildParticle( ObjectIdentifier::getStringForType( OBJECTTYPE_DATA_LABELS ) ); + aChildParticle+=(C2U("=")); + aSeriesSubContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierForParticles( aSeriesParticle, aChildParticle )); + } + + // Statistics + if( ChartTypeHelper::isSupportingStatisticProperties( xChartType, nDimensionCount ) ) + { + Reference< chart2::XRegressionCurveContainer > xCurveCnt( xSeries, uno::UNO_QUERY ); + if( xCurveCnt.is()) + { + Sequence< Reference< chart2::XRegressionCurve > > aCurves( xCurveCnt->getRegressionCurves()); + for( sal_Int32 nCurveIdx=0; nCurveIdx<aCurves.getLength(); ++nCurveIdx ) + { + bool bIsAverageLine = RegressionCurveHelper::isMeanValueLine( aCurves[nCurveIdx] ); + aSeriesSubContainer.push_back( + ObjectIdentifier::createDataCurveCID( aSeriesParticle, nCurveIdx, bIsAverageLine )); + if( RegressionCurveHelper::hasEquation( aCurves[nCurveIdx] ) ) + { + aSeriesSubContainer.push_back( + ObjectIdentifier::createDataCurveEquationCID( aSeriesParticle, nCurveIdx )); + } + } + Reference< beans::XPropertySet > xSeriesProp( xSeries, uno::UNO_QUERY ); + Reference< beans::XPropertySet > xErrorBarProp; + if( xSeriesProp.is() && + (xSeriesProp->getPropertyValue( C2U("ErrorBarY")) >>= xErrorBarProp) && + xErrorBarProp.is()) + { + sal_Int32 nStyle = ::com::sun::star::chart::ErrorBarStyle::NONE; + if( ( xErrorBarProp->getPropertyValue( C2U("ErrorBarStyle")) >>= nStyle ) && + ( nStyle != ::com::sun::star::chart::ErrorBarStyle::NONE ) ) + { + aSeriesSubContainer.push_back( + ObjectIdentifier::createClassifiedIdentifierWithParent( + OBJECTTYPE_DATA_ERRORS, OUString(), aSeriesParticle )); + } + } + } + } + + // Data Points + // iterate over child shapes of legend and search for matching CIDs + if( m_pExplicitValueProvider ) + { + Reference< container::XIndexAccess > xSeriesShapeContainer( + m_pExplicitValueProvider->getShapeForCID( aSeriesCID ), uno::UNO_QUERY ); + lcl_getChildCIDs( aSeriesSubContainer, xSeriesShapeContainer ); + } + + if( ! aSeriesSubContainer.empty()) + m_aChildMap[ aSeriesCID ] = aSeriesSubContainer; + } + } + } + } + catch( uno::Exception & ex ) + { + ASSERT_EXCEPTION( ex ); + } +} + +bool ImplObjectHierarchy::hasChildren( const OUString & rParent ) +{ + if( rParent.getLength()) + { + tChildMap::const_iterator aIt( m_aChildMap.find( rParent )); + if( aIt != m_aChildMap.end()) + return ! (aIt->second.empty()); + } + return false; +} + +ObjectHierarchy::tChildContainer ImplObjectHierarchy::getChildren( const OUString & rParent ) +{ + if( rParent.getLength()) + { + tChildMap::const_iterator aIt( m_aChildMap.find( rParent )); + if( aIt != m_aChildMap.end()) + return aIt->second; + } + return ObjectHierarchy::tChildContainer(); +} + +ObjectHierarchy::tChildContainer ImplObjectHierarchy::getSiblings( const OUString & rNode ) +{ + if( rNode.getLength() && !ObjectHierarchy::isRootNode( rNode )) + { + for( tChildMap::const_iterator aIt( m_aChildMap.begin()); + aIt != m_aChildMap.end(); ++aIt ) + { + ObjectHierarchy::tChildContainer::const_iterator aElemIt( + ::std::find( aIt->second.begin(), aIt->second.end(), rNode )); + if( aElemIt != aIt->second.end()) + return aIt->second; + } + } + return ObjectHierarchy::tChildContainer(); +} + +ObjectHierarchy::tCID ImplObjectHierarchy::getParentImpl( + const ObjectHierarchy::tCID & rParentCID, + const ObjectHierarchy::tCID & rCID ) +{ + // search children + ObjectHierarchy::tChildContainer aChildren( getChildren( rParentCID )); + ObjectHierarchy::tChildContainer::const_iterator aIt( + ::std::find( aChildren.begin(), aChildren.end(), rCID )); + // recursion end + if( aIt != aChildren.end()) + return rParentCID; + + for( aIt = aChildren.begin(); aIt != aChildren.end(); ++aIt ) + { + // recursion + ObjectHierarchy::tCID aTempParent( getParentImpl( *aIt, rCID )); + if( aTempParent.getLength()) + { + // exit on success + return aTempParent; + } + } + + // exit on fail + return ObjectHierarchy::tCID(); +} + +ObjectHierarchy::tCID ImplObjectHierarchy::getParent( + const ObjectHierarchy::tCID & rCID ) +{ + return getParentImpl( ObjectHierarchy::getRootNodeCID(), rCID ); +} + +} // namespace impl + +ObjectHierarchy::ObjectHierarchy( + const Reference< XChartDocument > & xChartDocument, + ExplicitValueProvider * pExplicitValueProvider /* = 0 */, + bool bFlattenDiagram /* = false */, + bool bOrderingForElementSelector /* = false */) : + m_apImpl( new impl::ImplObjectHierarchy( xChartDocument, pExplicitValueProvider, bFlattenDiagram, bOrderingForElementSelector )) +{} + +ObjectHierarchy::~ObjectHierarchy() +{} + +// static +ObjectHierarchy::tCID ObjectHierarchy::getRootNodeCID() +{ + return C2U("ROOT"); +} + +// static +bool ObjectHierarchy::isRootNode( const ObjectHierarchy::tCID & rCID ) +{ + return rCID.equals( ObjectHierarchy::getRootNodeCID()); +} + +ObjectHierarchy::tChildContainer ObjectHierarchy::getTopLevelChildren() const +{ + return m_apImpl->getChildren( ObjectHierarchy::getRootNodeCID()); +} + +bool ObjectHierarchy::hasChildren( const tCID & rParent ) const +{ + return m_apImpl->hasChildren( rParent ); +} + +ObjectHierarchy::tChildContainer ObjectHierarchy::getChildren( + const ObjectHierarchy::tCID & rParent ) const +{ + if( rParent.getLength()) + return m_apImpl->getChildren( rParent ); + + return ObjectHierarchy::tChildContainer(); +} + +ObjectHierarchy::tChildContainer ObjectHierarchy::getSiblings( + const ObjectHierarchy::tCID & rNode ) const +{ + if( rNode.getLength() && !isRootNode( rNode )) + return m_apImpl->getSiblings( rNode ); + + return ObjectHierarchy::tChildContainer(); +} + +ObjectHierarchy::tCID ObjectHierarchy::getParent( + const ObjectHierarchy::tCID & rNode ) const +{ + return m_apImpl->getParent( rNode ); +} + +sal_Int32 ObjectHierarchy::getIndexInParent( + const ObjectHierarchy::tCID & rNode ) const +{ + tCID aParentCID( m_apImpl->getParent( rNode )); + tChildContainer aChildren( m_apImpl->getChildren( aParentCID )); + tChildContainer::const_iterator aIt( aChildren.begin()); + for( sal_Int32 nIndex = 0; aIt != aChildren.end(); ++nIndex, ++aIt ) + { + if( aIt->equals( rNode )) + return nIndex; + } + return -1; +} + +// ================================================================================ + +ObjectKeyNavigation::ObjectKeyNavigation( + const ObjectHierarchy::tCID & rCurrentCID, + const Reference< chart2::XChartDocument > & xChartDocument, + ExplicitValueProvider * pExplicitValueProvider /* = 0 */ ) : + m_aCurrentCID( rCurrentCID ), + m_xChartDocument( xChartDocument ), + m_pExplicitValueProvider( pExplicitValueProvider ), + m_bStepDownInDiagram( true ) +{ + if( m_aCurrentCID.getLength() == 0 ) + setCurrentSelection( ObjectHierarchy::getRootNodeCID()); +} + +bool ObjectKeyNavigation::handleKeyEvent( + const awt::KeyEvent & rEvent ) +{ + bool bResult = false; + + switch( rEvent.KeyCode ) + { + case awt::Key::TAB: + if( rEvent.Modifiers & awt::KeyModifier::SHIFT ) + bResult = previous(); + else + bResult = next(); + break; + case awt::Key::HOME: + bResult = first(); + break; + case awt::Key::END: + bResult = last(); + break; + case awt::Key::F3: + if( rEvent.Modifiers & awt::KeyModifier::SHIFT ) + bResult = up(); + else + bResult = down(); + break; + case awt::Key::ESCAPE: + setCurrentSelection( OUString()); + bResult = true; + break; + default: + bResult = false; + break; + } + return bResult; +} + +void ObjectKeyNavigation::setCurrentSelection( const ObjectHierarchy::tCID & rCID ) +{ + m_aCurrentCID = rCID; +} + +ObjectHierarchy::tCID ObjectKeyNavigation::getCurrentSelection() const +{ + return m_aCurrentCID; +} + +bool ObjectKeyNavigation::first() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection())); + bool bResult = !aSiblings.empty(); + if( bResult ) + setCurrentSelection( aSiblings.front()); + else + bResult = veryFirst(); + return bResult; +} + +bool ObjectKeyNavigation::last() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection())); + bool bResult = !aSiblings.empty(); + if( bResult ) + setCurrentSelection( aSiblings.back()); + else + bResult = veryLast(); + return bResult; +} + +bool ObjectKeyNavigation::next() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection())); + bool bResult = !aSiblings.empty(); + if( bResult ) + { + ObjectHierarchy::tChildContainer::const_iterator aIt( + ::std::find( aSiblings.begin(), aSiblings.end(), getCurrentSelection())); + OSL_ASSERT( aIt != aSiblings.end()); + if( ++aIt == aSiblings.end()) + aIt = aSiblings.begin(); + setCurrentSelection( *aIt ); + } + else + bResult = veryFirst(); + + return bResult; +} + +bool ObjectKeyNavigation::previous() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aSiblings( aHierarchy.getSiblings( getCurrentSelection())); + bool bResult = !aSiblings.empty(); + if( bResult ) + { + ObjectHierarchy::tChildContainer::const_iterator aIt( + ::std::find( aSiblings.begin(), aSiblings.end(), getCurrentSelection())); + OSL_ASSERT( aIt != aSiblings.end()); + if( aIt == aSiblings.begin()) + aIt = aSiblings.end(); + --aIt; + setCurrentSelection( *aIt ); + } + else + bResult = veryLast(); + return bResult; +} + +bool ObjectKeyNavigation::up() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + bool bResult = !ObjectHierarchy::isRootNode( getCurrentSelection()); + if( bResult ) + setCurrentSelection( aHierarchy.getParent( getCurrentSelection())); + return bResult; +} + +bool ObjectKeyNavigation::down() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + bool bResult = aHierarchy.hasChildren( getCurrentSelection()); + if( bResult ) + { + ObjectHierarchy::tChildContainer aChildren = aHierarchy.getChildren( getCurrentSelection()); + OSL_ASSERT( !aChildren.empty()); + setCurrentSelection( aChildren.front()); + } + return bResult; +} + +bool ObjectKeyNavigation::veryFirst() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aChildren( aHierarchy.getTopLevelChildren()); + bool bResult = !aChildren.empty(); + if( bResult ) + setCurrentSelection( aChildren.front()); + return bResult; +} + +bool ObjectKeyNavigation::veryLast() +{ + ObjectHierarchy aHierarchy( m_xChartDocument, m_pExplicitValueProvider, m_bStepDownInDiagram ); + ObjectHierarchy::tChildContainer aChildren( aHierarchy.getTopLevelChildren()); + bool bResult = !aChildren.empty(); + if( bResult ) + setCurrentSelection( aChildren.back()); + return bResult; +} + +} // namespace chart diff --git a/chart2/source/controller/main/PositionAndSizeHelper.cxx b/chart2/source/controller/main/PositionAndSizeHelper.cxx new file mode 100644 index 000000000000..a4a50af995a9 --- /dev/null +++ b/chart2/source/controller/main/PositionAndSizeHelper.cxx @@ -0,0 +1,199 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PositionAndSizeHelper.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "PositionAndSizeHelper.hxx" +#include "macros.hxx" +#include "ChartModelHelper.hxx" +#include "ControllerLockGuard.hxx" +#include <com/sun/star/chart2/LegendPosition.hpp> +#include <com/sun/star/chart2/RelativePosition.hpp> +#include <com/sun/star/chart2/RelativeSize.hpp> +#include "chartview/ExplicitValueProvider.hxx" + +// header for class Rectangle +#include <tools/gen.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +using namespace ::com::sun::star::chart2; + +bool PositionAndSizeHelper::moveObject( ObjectType eObjectType + , const uno::Reference< beans::XPropertySet >& xObjectProp + , const awt::Rectangle& rNewPositionAndSize + , const awt::Rectangle& rPageRectangle + ) +{ + if(!xObjectProp.is()) + return false; + Rectangle aObjectRect( Point(rNewPositionAndSize.X,rNewPositionAndSize.Y), Size(rNewPositionAndSize.Width,rNewPositionAndSize.Height) ); + Rectangle aPageRect( Point(rPageRectangle.X,rPageRectangle.Y), Size(rPageRectangle.Width,rPageRectangle.Height) ); + + if( OBJECTTYPE_TITLE==eObjectType ) + { + //@todo decide wether x is primary or secondary + chart2::RelativePosition aRelativePosition; + 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( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } + else if( OBJECTTYPE_DATA_CURVE_EQUATION==eObjectType ) + { + //@todo decide wether x is primary or secondary + chart2::RelativePosition aRelativePosition; + 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( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } + else if(OBJECTTYPE_LEGEND==eObjectType) + { + LegendPosition ePos = LegendPosition_LINE_END; + xObjectProp->getPropertyValue( C2U( "AnchorPosition" )) >>= ePos; + chart2::RelativePosition aRelativePosition; + Point aAnchor = aObjectRect.TopLeft(); + + switch( ePos ) + { + case LegendPosition_LINE_START: + { + //@todo language dependent positions ... + aRelativePosition.Anchor = drawing::Alignment_LEFT; + aAnchor = aObjectRect.LeftCenter(); + } + break; + case LegendPosition_LINE_END: + { + //@todo language dependent positions ... + aRelativePosition.Anchor = drawing::Alignment_RIGHT; + aAnchor = aObjectRect.RightCenter(); + } + break; + case LegendPosition_PAGE_START: + { + //@todo language dependent positions ... + aRelativePosition.Anchor = drawing::Alignment_TOP; + aAnchor = aObjectRect.TopCenter(); + } + break; + case LegendPosition_PAGE_END: + //@todo language dependent positions ... + { + aRelativePosition.Anchor = drawing::Alignment_BOTTOM; + aAnchor = aObjectRect.BottomCenter(); + } + break; + case LegendPosition_CUSTOM: + { + //@todo language dependent positions ... + aRelativePosition.Anchor = drawing::Alignment_TOP_LEFT; + } + break; + case LegendPosition_MAKE_FIXED_SIZE: + OSL_ASSERT( false ); + break; + } + aRelativePosition.Primary = + static_cast< double >( aAnchor.X()) / + static_cast< double >( aPageRect.getWidth() ); + aRelativePosition.Secondary = + static_cast< double >( aAnchor.Y()) / + static_cast< double >( aPageRect.getHeight()); + + xObjectProp->setPropertyValue( C2U( "RelativePosition" ), uno::makeAny(aRelativePosition) ); + } + else if(OBJECTTYPE_DIAGRAM==eObjectType || OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType) + { + //@todo decide wether x is primary or secondary + + //xChartView + + //set position: + chart2::RelativePosition aRelativePosition; + 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( C2U( "RelativePosition" ), uno::makeAny(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( C2U( "RelativeSize" ), uno::makeAny(aRelativeSize) ); + } + else + return false; + return true; +} + +bool PositionAndSizeHelper::moveObject( const rtl::OUString& rObjectCID + , const uno::Reference< frame::XModel >& xChartModel + , const awt::Rectangle& rNewPositionAndSize + , const awt::Rectangle& rPageRectangle + , uno::Reference< uno::XInterface > xChartView + ) +{ + ControllerLockGuard aLockedControllers( xChartModel ); + + awt::Rectangle aNewPositionAndSize( rNewPositionAndSize ); + + uno::Reference< beans::XPropertySet > xObjectProp = ObjectIdentifier::getObjectPropertySet( rObjectCID, xChartModel ); + ObjectType eObjectType( ObjectIdentifier::getObjectType( rObjectCID ) ); + if(OBJECTTYPE_DIAGRAM==eObjectType || OBJECTTYPE_DIAGRAM_WALL==eObjectType || OBJECTTYPE_DIAGRAM_FLOOR==eObjectType) + { + xObjectProp = uno::Reference< beans::XPropertySet >( ObjectIdentifier::getDiagramForCID( rObjectCID, xChartModel ), uno::UNO_QUERY ); + if(!xObjectProp.is()) + return false; + + //add axis title sizes to the diagram size + aNewPositionAndSize = ExplicitValueProvider::calculateDiagramPositionAndSizeInclusiveTitle( + xChartModel, xChartView, rNewPositionAndSize ); + } + return moveObject( eObjectType, xObjectProp, aNewPositionAndSize, rPageRectangle ); +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/SelectionHelper.cxx b/chart2/source/controller/main/SelectionHelper.cxx new file mode 100644 index 000000000000..8e2b8911be77 --- /dev/null +++ b/chart2/source/controller/main/SelectionHelper.cxx @@ -0,0 +1,756 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SelectionHelper.cxx,v $ + * $Revision: 1.11.68.1 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "SelectionHelper.hxx" +#include "ObjectIdentifier.hxx" +//for C2U +#include "macros.hxx" +#include "DiagramHelper.hxx" +#include "ChartModelHelper.hxx" + +// header for class SdrObjList +#include <svx/svdpage.hxx> +#include <svx/svditer.hxx> +#include "svx/obj3d.hxx" +// header for class SdrPathObj +#include <svx/svdopath.hxx> +#include <vcl/svapp.hxx> +#include <vos/mutex.hxx> +#include <basegfx/point/b2dpoint.hxx> +#include <com/sun/star/beans/XPropertySet.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. +using namespace ::com::sun::star; +//using namespace ::com::sun::star::chart2; + +namespace +{ + +rtl::OUString lcl_getObjectName( SdrObject* pObj ) +{ + if(pObj) + return pObj->GetName(); + return rtl::OUString(); +} + +void impl_selectObject( SdrObject* pObjectToSelect, DrawViewWrapper& rDrawViewWrapper ) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + + if(pObjectToSelect) + { + SelectionHelper aSelectionHelper( pObjectToSelect ); + SdrObject* pMarkObj = aSelectionHelper.getObjectToMark(); + rDrawViewWrapper.setMarkHandleProvider(&aSelectionHelper); + rDrawViewWrapper.MarkObject(pMarkObj); + rDrawViewWrapper.setMarkHandleProvider(NULL); + } +} + +}//anonymous namespace + +bool Selection::hasSelection() +{ + return m_aSelectedObjectCID.getLength() || m_xSelectAdditionalShape.is(); +} + +rtl::OUString Selection::getSelectedCID() +{ + return m_aSelectedObjectCID; +} + +uno::Reference< drawing::XShape > Selection::getSelectedAdditionalShape() +{ + return m_xSelectAdditionalShape; +} + +bool Selection::setSelection( const ::rtl::OUString& rCID ) +{ + if( !rCID.equals( m_aSelectedObjectCID ) ) + { + m_aSelectedObjectCID = rCID; + m_xSelectAdditionalShape.set(0); + return true; + } + return false; +} + +bool Selection::setSelection( const uno::Reference< drawing::XShape >& xShape ) +{ + if( !(m_xSelectAdditionalShape==xShape) ) + { + clearSelection(); + m_xSelectAdditionalShape = xShape; + return true; + } + return false; +} + +void Selection::clearSelection() +{ + m_aSelectedObjectCID = m_aSelectedObjectCID_beforeMouseDown + = m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = rtl::OUString(); + m_xSelectAdditionalShape.set(0); +} + +bool Selection::maybeSwitchSelectionAfterSingleClickWasEnsured() +{ + if( m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength() + && !m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.equals(m_aSelectedObjectCID) ) + { + m_aSelectedObjectCID = m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing; + m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U(""); + return true; + } + return false; +} + +void Selection::resetPossibleSelectionAfterSingleClickWasEnsured() +{ + if( m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength() ) + m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U(""); +} + +void Selection::remindSelectionBeforeMouseDown() +{ + m_aSelectedObjectCID_beforeMouseDown = m_aSelectedObjectCID; +} + +bool Selection::isSelectionDifferentFromBeforeMouseDown() +{ + return !ObjectIdentifier::areIdenticalObjects( m_aSelectedObjectCID, m_aSelectedObjectCID_beforeMouseDown ); +} + +void Selection::applySelection( DrawViewWrapper* pDrawViewWrapper ) +{ + if( pDrawViewWrapper ) + { + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + pDrawViewWrapper->UnmarkAll(); + } + SdrObject* pObjectToSelect = 0; + if( m_aSelectedObjectCID.getLength() ) + pObjectToSelect = pDrawViewWrapper->getNamedSdrObject( m_aSelectedObjectCID ); + else if( m_xSelectAdditionalShape.is() ) + pObjectToSelect = DrawViewWrapper::getSdrObject( m_xSelectAdditionalShape ); + + impl_selectObject( pObjectToSelect, *pDrawViewWrapper ); + } +} + +void Selection::adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper* pDrawViewWrapper + , bool bIsRightMouse, bool bWaitingForDoubleClick ) +{ + if( pDrawViewWrapper ) + { + //do not toggel multiclick selection if right clicked on the selected object or waiting for double click + bool bAllowMultiClickSelectionChange = !bIsRightMouse && !bWaitingForDoubleClick; + + const rtl::OUString aNameOfLastSelectedObject( m_aSelectedObjectCID ); + + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + + //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point) + + //get object to select: + SdrObject* pNewObj = 0; + { + m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U(""); + m_xSelectAdditionalShape.set(0); + + //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree) + //further we travel along the grouping hierarchy from child to parent + pNewObj = pDrawViewWrapper->getHitObject(rMousePos); + m_aSelectedObjectCID = lcl_getObjectName( pNewObj );//name of pNewObj + rtl::OUString aTestFirstHit = m_aSelectedObjectCID; + + //ignore handle only objects for hit test + while( pNewObj && m_aSelectedObjectCID.match(C2U("HandlesOnly")) ) + { + pNewObj->SetMarkProtect(true); + pNewObj = pDrawViewWrapper->getHitObject(rMousePos); + m_aSelectedObjectCID = lcl_getObjectName( pNewObj ); + } + + //accept only named objects while searching for the object to select + //this call may change m_aSelectedObjectCID + if( SelectionHelper::findNamedParent( pNewObj, m_aSelectedObjectCID, true ) ) + { + //if the so far found object is a multi click object further steps are necessary + while( ObjectIdentifier::isMultiClickObject( m_aSelectedObjectCID ) ) + { + bool bSameObjectAsLastSelected = ObjectIdentifier::areIdenticalObjects( aNameOfLastSelectedObject, m_aSelectedObjectCID ); + if( bSameObjectAsLastSelected ) + { + //if the same child is clicked again don't go up further + break; + } + if( ObjectIdentifier::areSiblings(aNameOfLastSelectedObject,m_aSelectedObjectCID) ) + { + //if a sibling of the last selected object is clicked don't go up further + break; + } + SdrObject* pLastChild = pNewObj; + rtl::OUString aLastChildName = m_aSelectedObjectCID; + if(!SelectionHelper::findNamedParent( pNewObj, m_aSelectedObjectCID, false )) + { + //take the one found so far + break; + } + //if the last selected object is found don't go up further + //but take the last child if selection change is allowed + if( ObjectIdentifier::areIdenticalObjects( aNameOfLastSelectedObject, m_aSelectedObjectCID ) ) + { + if( bAllowMultiClickSelectionChange ) + { + pNewObj = pLastChild; + m_aSelectedObjectCID = aLastChildName; + } + else + m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = aLastChildName; + + break; + } + } + + DBG_ASSERT(pNewObj && m_aSelectedObjectCID.getLength(),"somehow lost selected object"); + } + else + { + //maybe an additional shape was hit + m_aSelectedObjectCID = rtl::OUString(); + if( pNewObj ) + { + m_xSelectAdditionalShape = uno::Reference< drawing::XShape >( pNewObj->getUnoShape(), uno::UNO_QUERY); + } + } + + if(!m_xSelectAdditionalShape.is()) + { + rtl::OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );//@todo read CID from model + + if( !m_aSelectedObjectCID.getLength() ) + m_aSelectedObjectCID = aPageCID; + + //check wether the diagram was hit but not selected (e.g. because it has no filling): + rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model + if( m_aSelectedObjectCID.equals( aPageCID ) || m_aSelectedObjectCID.equals( aWallCID ) || !m_aSelectedObjectCID.getLength() ) + { + rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ); + //todo: if more than one diagram is available in future do chack the list of all diagrams here + SdrObject* pDiagram = pDrawViewWrapper->getNamedSdrObject( aDiagramCID ); + if( pDiagram ) + { + if( pDrawViewWrapper->IsObjectHit( pDiagram, rMousePos ) ) + { + m_aSelectedObjectCID = aDiagramCID; + pNewObj = pDiagram; + } + } + } + } + } + + if( bIsRightMouse && m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing.getLength() ) + m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing = C2U(""); + } +} + +bool Selection::isResizeableObjectSelected() +{ + ObjectType eObjectType = ObjectIdentifier::getObjectType( m_aSelectedObjectCID ); + switch( eObjectType ) + { + case OBJECTTYPE_DIAGRAM: + case OBJECTTYPE_DIAGRAM_WALL: + return true; + default: + return false; + } + return false; +} + +bool Selection::isRotateableObjectSelected( const uno::Reference< frame::XModel >& xChartModel ) +{ + return SelectionHelper::isRotateableObject( m_aSelectedObjectCID, xChartModel ); +} + +bool Selection::isDragableObjectSelected() +{ + if( m_aSelectedObjectCID.getLength() ) + return ObjectIdentifier::isDragableObject( m_aSelectedObjectCID ); + return m_xSelectAdditionalShape.is(); +} + +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- +//----------------------------------------------------------------------------- + +//static +bool SelectionHelper::findNamedParent( SdrObject*& pInOutObject + , rtl::OUString& rOutName + , bool bGivenObjectMayBeResult ) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + //find the deepest named group + SdrObject* pObj = pInOutObject; + rtl::OUString aName; + if( bGivenObjectMayBeResult ) + aName = lcl_getObjectName( pObj ); + + while( pObj && !ObjectIdentifier::isCID( aName ) ) + { + SdrObjList* pObjList = pObj->GetObjList(); + if( !pObjList ) + return false;; + SdrObject* pOwner = pObjList->GetOwnerObj(); + if( !pOwner ) + return false; + pObj = pOwner; + aName = lcl_getObjectName( pObj ); + } + + if(!pObj) + return false; + if(!aName.getLength()) + return false; + + pInOutObject = pObj; + rOutName = aName; + return true; +} + +//static +bool SelectionHelper::isDragableObjectHitTwice( const Point& rMPos + , const rtl::OUString& rNameOfSelectedObject + , const DrawViewWrapper& rDrawViewWrapper ) +{ + if(!rNameOfSelectedObject.getLength()) + return false; + if( !ObjectIdentifier::isDragableObject(rNameOfSelectedObject) ) + return false; + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + SdrObject* pObj = rDrawViewWrapper.getNamedSdrObject( rNameOfSelectedObject ); + if( !rDrawViewWrapper.IsObjectHit( pObj, rMPos ) ) + return false; + return true; +} + +/* +rtl::OUString lcl_getObjectCIDToSelect( const Point& rMPos + , const rtl::OUString& rNameOfLastSelectedObject + , DrawViewWrapper& rDrawViewWrapper + , bool bAllowMultiClickSelectionChange + , rtl::OUString& rObjectToSelectIfNoDoubleClickIsFollowing //out parameter only + ) +{ + rtl::OUString aRet; + + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + + //bAllowMultiClickSelectionChange==true -> a second click on the same object can lead to a changed selection (e.g. series -> single data point) + + //get object to select: + SdrObject* pNewObj = 0; + { + rObjectToSelectIfNoDoubleClickIsFollowing = C2U(""); + + //the search for the object to select starts with the hit object deepest in the grouping hierarchy (a leaf in the tree) + //further we travel along the grouping hierarchy from child to parent + pNewObj = rDrawViewWrapper.getHitObject(rMPos); + aRet = lcl_getObjectName( pNewObj );//name of pNewObj + rtl::OUString aTestFirstHit = aRet; + + //ignore handle only objects for hit test + while( pNewObj && aRet.match(C2U("HandlesOnly")) ) + { + pNewObj->SetMarkProtect(true); + pNewObj = rDrawViewWrapper.getHitObject(rMPos); + aRet = lcl_getObjectName( pNewObj ); + } + + //accept only named objects while searching for the object to select + //this call may change aRet + if( !findNamedParent( pNewObj, aRet, true ) ) + { + return C2U(""); + } + //if the so far found object is a multi click object further steps are necessary + while( ObjectIdentifier::isMultiClickObject( aRet ) ) + { + bool bSameObjectAsLastSelected = ObjectIdentifier::areIdenticalObjects( rNameOfLastSelectedObject, aRet ); + if( bSameObjectAsLastSelected ) + { + //if the same child is clicked again don't go up further + break; + } + if( ObjectIdentifier::areSiblings(rNameOfLastSelectedObject,aRet) ) + { + //if a sibling of the last selected object is clicked don't go up further + break; + } + SdrObject* pLastChild = pNewObj; + rtl::OUString aLastChildName = aRet; + if(!findNamedParent( pNewObj, aRet, false )) + { + //take the one found so far + break; + } + //if the last selected object is found don't go up further + //but take the last child if selection change is allowed + if( ObjectIdentifier::areIdenticalObjects( rNameOfLastSelectedObject, aRet ) ) + { + if( bAllowMultiClickSelectionChange ) + { + pNewObj = pLastChild; + aRet = aLastChildName; + } + else + rObjectToSelectIfNoDoubleClickIsFollowing = aLastChildName; + + break; + } + } + + //check wether the diagram was hit but not selected: + rtl::OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );//@todo read CID from model + rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model + if( aRet.equals( aPageCID ) || aRet.equals( aWallCID ) || !aRet.getLength() ) + { + rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ); + //todo: if more than one diagram is available in future do chack the list of all diagrams here + SdrObject* pDiagram = rDrawViewWrapper.getNamedSdrObject( aDiagramCID ); + if( pDiagram ) + { + if( rDrawViewWrapper.IsObjectHit( pDiagram, rMPos ) ) + { + aRet = aDiagramCID; + pNewObj = pDiagram; + } + } + } + + DBG_ASSERT(pNewObj && aRet.getLength(),"somehow lost selected object"); + } + + return aRet; +} +*/ + +// static +::rtl::OUString SelectionHelper::getHitObjectCID( + const Point& rMPos, + DrawViewWrapper& rDrawViewWrapper, + bool bGetDiagramInsteadOf_Wall ) +{ + // //- solar mutex + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + rtl::OUString aRet; + + SdrObject* pNewObj = rDrawViewWrapper.getHitObject(rMPos); + aRet = lcl_getObjectName( pNewObj );//name of pNewObj + + //ignore handle only objects for hit test + while( pNewObj && aRet.match(C2U("HandlesOnly")) ) + { + pNewObj->SetMarkProtect(true); + pNewObj = rDrawViewWrapper.getHitObject(rMPos); + aRet = lcl_getObjectName( pNewObj ); + } + + //accept only named objects while searching for the object to select + if( !findNamedParent( pNewObj, aRet, true ) ) + { + aRet = ::rtl::OUString(); + } + + rtl::OUString aPageCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_PAGE, rtl::OUString() ) );//@todo read CID from model + //get page when nothing was hit + if( aRet.getLength() == 0 && !pNewObj ) + { + aRet = aPageCID; + } + + //get diagram instead wall or page if hit inside diagram + if( aRet.getLength() != 0 ) + { + if( aRet.equals( aPageCID ) ) + { + rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ); + //todo: if more than one diagram is available in future do chack the list of all diagrams here + SdrObject* pDiagram = rDrawViewWrapper.getNamedSdrObject( aDiagramCID ); + if( pDiagram ) + { + if( rDrawViewWrapper.IsObjectHit( pDiagram, rMPos ) ) + { + aRet = aDiagramCID; + } + } + } + else if( bGetDiagramInsteadOf_Wall ) + { + rtl::OUString aWallCID( ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM_WALL, rtl::OUString() ) );//@todo read CID from model + + if( aRet.equals( aWallCID ) ) + { + rtl::OUString aDiagramCID = ObjectIdentifier::createClassifiedIdentifier( OBJECTTYPE_DIAGRAM, rtl::OUString::valueOf( sal_Int32(0) ) ); + aRet = aDiagramCID; + } + } + } + + return aRet; + // \\- solar mutex +} + +//static +bool SelectionHelper::isRotateableObject( const ::rtl::OUString& rCID + , const uno::Reference< frame::XModel >& xChartModel ) +{ + if( !ObjectIdentifier::isRotateableObject( rCID ) ) + return false; + + sal_Int32 nDimensionCount = DiagramHelper::getDimension( ChartModelHelper::findDiagram( xChartModel ) ); + + if( nDimensionCount == 3 ) + return true; + return false; +} + +SelectionHelper::SelectionHelper( SdrObject* pSelectedObj ) + : m_pSelectedObj( pSelectedObj ) +{ + +} +SelectionHelper::~SelectionHelper() +{ +} + +//virtual +bool SelectionHelper::getFrameDragSingles() +{ + bool bFrameDragSingles = true;//true == green == surrounding handles + if( m_pSelectedObj && m_pSelectedObj->ISA(E3dObject) ) + bFrameDragSingles = false; + return bFrameDragSingles; +} + +//static +SdrObject* SelectionHelper::getMarkHandlesObject( SdrObject* pObj ) +{ + if(!pObj) + return 0; + rtl::OUString aName( lcl_getObjectName( pObj ) ); + if( aName.match(C2U("MarkHandles")) || aName.match(C2U("HandlesOnly")) ) + return pObj; + if( aName.getLength() )//dont't get the markhandles of a different object + return 0; + + //search for a child with name "MarkHandles" or "HandlesOnly" + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + SdrObjList* pSubList = pObj->GetSubList(); + if(pSubList) + { + SdrObjListIter aIterator(*pSubList, IM_FLAT); + while (aIterator.IsMore()) + { + SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() ); + if( pMarkHandles ) + return pMarkHandles; + } + } + return 0; +} + +SdrObject* SelectionHelper::getObjectToMark() +{ + //return the selected object itself + //or a specific other object if that exsists + SdrObject* pObj = m_pSelectedObj; + m_pMarkObj = pObj; + + //search for a child with name "MarkHandles" or "HandlesOnly" + if(pObj) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + SdrObjList* pSubList = pObj->GetSubList(); + if(pSubList) + { + SdrObjListIter aIterator(*pSubList, IM_FLAT); + while (aIterator.IsMore()) + { + SdrObject* pMarkHandles = SelectionHelper::getMarkHandlesObject( aIterator.Next() ); + if( pMarkHandles ) + { + m_pMarkObj = pMarkHandles; + break; + } + } + } + } + return m_pMarkObj; +} + +//static +E3dScene* SelectionHelper::getSceneToRotate( SdrObject* pObj ) +{ + //search wether the object or one of its children is a 3D object + //if so, return the accessory 3DScene + + E3dObject* pRotateable = 0; + + if(pObj) + { + pRotateable = dynamic_cast<E3dObject*>(pObj); + if( !pRotateable ) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + SdrObjList* pSubList = pObj->GetSubList(); + if(pSubList) + { + SdrObjListIter aIterator(*pSubList, IM_DEEPWITHGROUPS); + while( aIterator.IsMore() && !pRotateable ) + { + SdrObject* pSubObj = aIterator.Next(); + pRotateable = dynamic_cast<E3dObject*>(pSubObj); + } + } + } + } + + E3dScene* pScene = 0; + if(pRotateable) + { + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + pScene = pRotateable->GetScene(); + } + return pScene; + +} + +//virtual +bool SelectionHelper::getMarkHandles( SdrHdlList& rHdlList ) +{ + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + + //@todo -> more flexible handle creation + //2 scenarios possible: + //1. add an additional invisible shape as a child to the selected object + //this child needs to be named somehow and handles need to be generated therefrom ... + //or 2. offer a central service per view where renderer and so can register for handle creation for a special shape + //.. or 3. feature from drawinglayer to create handles for each shape ... (bad performance ... ?) ? + + //scenario 1 is now used: + //if a child with name MarkHandles exsists + //this child is marked instead of the logical selected object + +/* + //if a special mark object was found + //that object should be used for marking only + if( m_pMarkObj != m_pSelectedObj) + return false; +*/ + //if a special mark object was found + //that object should be used to create handles from + if( m_pMarkObj && m_pMarkObj != m_pSelectedObj) + { + rHdlList.Clear(); + if( m_pMarkObj->ISA(SdrPathObj) ) + { + //if th object is a polygon + //from each point a handle is generated + const ::basegfx::B2DPolyPolygon& rPolyPolygon = ((SdrPathObj*)m_pMarkObj)->GetPathPoly(); + for( sal_uInt32 nN = 0L; nN < rPolyPolygon.count(); nN++) + { + const ::basegfx::B2DPolygon aPolygon(rPolyPolygon.getB2DPolygon(nN)); + for( sal_uInt32 nM = 0L; nM < aPolygon.count(); nM++) + { + const ::basegfx::B2DPoint aPoint(aPolygon.getB2DPoint(nM)); + SdrHdl* pHdl = new SdrHdl(Point(basegfx::fround(aPoint.getX()), basegfx::fround(aPoint.getY())), HDL_POLY); + rHdlList.AddHdl(pHdl); + } + } + return true; + } + else + return false; //use the special MarkObject for marking + } + + //@todo: + //add and document good marking defaults ... + + rHdlList.Clear(); + + SdrObject* pObj = m_pSelectedObj; + if(!pObj) + return false; + SdrObjList* pSubList = pObj->GetSubList(); + if( !pSubList )//no group object !pObj->IsGroupObject() + return false; + + rtl::OUString aName( lcl_getObjectName( pObj ) ); + ObjectType eObjectType( ObjectIdentifier::getObjectType( aName ) ); + if( OBJECTTYPE_DATA_POINT == eObjectType + || OBJECTTYPE_DATA_LABEL == eObjectType + || OBJECTTYPE_LEGEND_ENTRY == eObjectType + || OBJECTTYPE_AXIS_UNITLABEL == eObjectType ) + { + return false; + } + + SdrObjListIter aIterator(*pSubList, IM_FLAT); + + while (aIterator.IsMore()) + { + SdrObject* pSubObj = aIterator.Next(); + if( OBJECTTYPE_DATA_SERIES == eObjectType ) + { + rtl::OUString aSubName( lcl_getObjectName( pSubObj ) ); + ObjectType eSubObjectType( ObjectIdentifier::getObjectType( aSubName ) ); + if( eSubObjectType!=OBJECTTYPE_DATA_POINT ) + return false; + } + + Point aPos = pSubObj->GetCurrentBoundRect().Center(); + SdrHdl* pHdl = new SdrHdl(aPos,HDL_POLY); + rHdlList.AddHdl(pHdl); + } + return true; +} + +//............................................................................. +} //namespace chart +//............................................................................. diff --git a/chart2/source/controller/main/SelectionHelper.hxx b/chart2/source/controller/main/SelectionHelper.hxx new file mode 100644 index 000000000000..6e01ed005978 --- /dev/null +++ b/chart2/source/controller/main/SelectionHelper.hxx @@ -0,0 +1,136 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: SelectionHelper.hxx,v $ + * $Revision: 1.6 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef _CHART2_SELECTIONHELPER_HXX +#define _CHART2_SELECTIONHELPER_HXX + +#include "DrawViewWrapper.hxx" + +class SdrObject; +// header for enum SdrDragMode +#include <svx/svdtypes.hxx> +#include <com/sun/star/drawing/XShape.hpp> + +//............................................................................. +namespace chart +{ +//............................................................................. + +//----------------------------------------------------------------------------- +/** +*/ +class Selection +{ +public: //methods + bool hasSelection(); + + rtl::OUString getSelectedCID(); + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > getSelectedAdditionalShape(); + + bool isResizeableObjectSelected(); + bool isRotateableObjectSelected( const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + bool isDragableObjectSelected(); + + //returns true if selection has changed + bool setSelection( const ::rtl::OUString& rCID ); + bool setSelection( const ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape >& xShape ); + + void clearSelection(); + + //returns true if the selection has changed + bool maybeSwitchSelectionAfterSingleClickWasEnsured(); + void resetPossibleSelectionAfterSingleClickWasEnsured(); + + void remindSelectionBeforeMouseDown(); + bool isSelectionDifferentFromBeforeMouseDown(); + + void adaptSelectionToNewPos( const Point& rMousePos, DrawViewWrapper* pDrawViewWrapper + , bool bIsRightMouse, bool bWaitingForDoubleClick ); + + void applySelection( DrawViewWrapper* pDrawViewWrapper ); + +private: //member + //the selection could be given by a CID or by a shape + //if m_aSelectedObjectCID is not empty this indicates the selection + //the content of m_xSelectedShape is ignored in that case + //the strings are used for autogenerated chart specific objects + //the shape reference is used for additional shapes + ::rtl::OUString m_aSelectedObjectCID;//only single object selection so far + ::rtl::OUString m_aSelectedObjectCID_beforeMouseDown; + ::rtl::OUString m_aSelectedObjectCID_selectOnlyIfNoDoubleClickIsFollowing; + + ::com::sun::star::uno::Reference< + ::com::sun::star::drawing::XShape > m_xSelectAdditionalShape; +}; + +class SelectionHelper : public MarkHandleProvider +{ +public: + static bool findNamedParent( SdrObject*& pInOutObject + , rtl::OUString& rOutName + , bool bGivenObjectMayBeResult ); + static SdrObject* getMarkHandlesObject( SdrObject* pObj ); + static E3dScene* getSceneToRotate( SdrObject* pObj ); + static bool isDragableObjectHitTwice( const Point& rMPos + , const rtl::OUString& rNameOfSelectedObject + , const DrawViewWrapper& rDrawViewWrapper ); + + static ::rtl::OUString getHitObjectCID( + const Point& rMPos, + DrawViewWrapper& rDrawViewWrapper, + bool bGetDiagramInsteadOf_Wall=false ); + + static bool isRotateableObject( const ::rtl::OUString& rCID + , const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel >& xChartModel ); + + + SelectionHelper( SdrObject* pSelectedObj ); + virtual ~SelectionHelper(); + + + //MarkHandleProvider: + virtual bool getMarkHandles( SdrHdlList& rHdlList ); + virtual bool getFrameDragSingles(); + + SdrObject* getObjectToMark();//sets also internally the mark object + //-> getMarkHandles will behave different if this method has found a Mark Object different from m_pSelectedObj + +private: + SdrObject* m_pSelectedObj;//hit and logically selected object + SdrObject* m_pMarkObj;//object that is marked instead to have more pretty handles +}; + +//............................................................................. +} //namespace chart +//............................................................................. +#endif diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.cxx b/chart2/source/controller/main/StatusBarCommandDispatch.cxx new file mode 100644 index 000000000000..7960e2493fd2 --- /dev/null +++ b/chart2/source/controller/main/StatusBarCommandDispatch.cxx @@ -0,0 +1,159 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StatusBarCommandDispatch.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "StatusBarCommandDispatch.hxx" +#include "ObjectNameProvider.hxx" +#include "macros.hxx" +#include <com/sun/star/util/XModifyBroadcaster.hpp> + +// #ifndef _VOS_MUTEX_HXX_ +// #include <vos/mutex.hxx> +// #endif +// #ifndef _SV_SVAPP_HXX +// #include <vcl/svapp.hxx> +// #endif + +// for ressource strings STR_UNDO and STR_REDO +#include <sfx2/sfx.hrc> + +#include "ResId.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +StatusBarCommandDispatch::StatusBarCommandDispatch( + const Reference< uno::XComponentContext > & xContext, + const Reference< frame::XModel > & xModel, + const Reference< view::XSelectionSupplier > & xSelSupp ) : + impl::StatusBarCommandDispatch_Base( xContext ), + m_xModifiable( xModel, uno::UNO_QUERY ), + m_xSelectionSupplier( xSelSupp ), + m_bIsModified( false ) +{} + +StatusBarCommandDispatch::~StatusBarCommandDispatch() +{} + +void StatusBarCommandDispatch::initialize() +{ + if( m_xModifiable.is()) + { + Reference< util::XModifyBroadcaster > xModifyBroadcaster( m_xModifiable, uno::UNO_QUERY ); + OSL_ASSERT( xModifyBroadcaster.is()); + if( xModifyBroadcaster.is()) + xModifyBroadcaster->addModifyListener( this ); + } + + if( m_xSelectionSupplier.is()) + { + m_xSelectionSupplier->addSelectionChangeListener( this ); + } +} + +void StatusBarCommandDispatch::fireStatusEvent( + const OUString & rURL, + const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) +{ + bool bFireAll(rURL.getLength() == 0); + bool bFireContext( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Context"))); + bool bFireModified( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:ModifiedStatus"))); + + if( bFireContext ) + { + uno::Any aArg; + Reference< chart2::XChartDocument > xDoc( m_xModifiable, uno::UNO_QUERY ); + aArg <<= ObjectNameProvider::getSelectedObjectText( m_aSelectedCID, xDoc ); + fireStatusEventForURL( C2U(".uno:Context"), aArg, true, xSingleListener ); + } + if( bFireModified ) + { + uno::Any aArg; + if( m_bIsModified ) + aArg <<= C2U("*"); + fireStatusEventForURL( C2U(".uno:ModifiedStatus"), aArg, true, xSingleListener ); + } +} + +// ____ XDispatch ____ +void SAL_CALL StatusBarCommandDispatch::dispatch( + const util::URL& /* URL */, + const Sequence< beans::PropertyValue >& /* Arguments */ ) + throw (uno::RuntimeException) +{ + // nothing to do here +} + +// ____ WeakComponentImplHelperBase ____ +/// is called when this is disposed +void SAL_CALL StatusBarCommandDispatch::disposing() +{ + m_xModifiable.clear(); + m_xSelectionSupplier.clear(); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL StatusBarCommandDispatch::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{ + m_xModifiable.clear(); + m_xSelectionSupplier.clear(); +} + +// ____ XModifyListener ____ +void SAL_CALL StatusBarCommandDispatch::modified( const lang::EventObject& aEvent ) + throw (uno::RuntimeException) +{ + if( m_xModifiable.is()) + m_bIsModified = m_xModifiable->isModified(); + + CommandDispatch::modified( aEvent ); +} + +// ____ XSelectionChangeListener ____ +void SAL_CALL StatusBarCommandDispatch::selectionChanged( const lang::EventObject& /* aEvent */ ) + throw (uno::RuntimeException) +{ + if( m_xSelectionSupplier.is()) + m_xSelectionSupplier->getSelection() >>= m_aSelectedCID; + else + m_aSelectedCID = OUString(); + fireAllStatusEvents( 0 ); +} + +} // namespace chart diff --git a/chart2/source/controller/main/StatusBarCommandDispatch.hxx b/chart2/source/controller/main/StatusBarCommandDispatch.hxx new file mode 100644 index 000000000000..f1d0808cac6b --- /dev/null +++ b/chart2/source/controller/main/StatusBarCommandDispatch.hxx @@ -0,0 +1,112 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: StatusBarCommandDispatch.hxx,v $ + * $Revision: 1.3 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_STATUSBARCOMMANDDISPATCH_HXX +#define CHART2_STATUSBARCOMMANDDISPATCH_HXX + +#include "CommandDispatch.hxx" +#include <cppuhelper/implbase1.hxx> +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/view/XSelectionSupplier.hpp> +#include <com/sun/star/util/XModifiable.hpp> + +namespace chart +{ + +/** This is a CommandDispatch implementation for all commands the status bar offers + + This class reads the information needed from the XModel passed here. + */ + +namespace impl +{ +typedef ::cppu::ImplInheritanceHelper1< + CommandDispatch, + ::com::sun::star::view::XSelectionChangeListener > + StatusBarCommandDispatch_Base; +} + +class StatusBarCommandDispatch : public impl::StatusBarCommandDispatch_Base +{ +public: + explicit StatusBarCommandDispatch( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel, + const ::com::sun::star::uno::Reference< + ::com::sun::star::view::XSelectionSupplier > & xSelSupp ); + virtual ~StatusBarCommandDispatch(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + +protected: + // ____ XDispatch ____ + virtual void SAL_CALL dispatch( + const ::com::sun::star::util::URL& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ WeakComponentImplHelperBase ____ + /// is called when this is disposed + virtual void SAL_CALL disposing(); + + // ____ XModifyListener (override from CommandDispatch) ____ + virtual void SAL_CALL modified( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void fireStatusEvent( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); + + // ____ XSelectionChangeListener ____ + virtual void SAL_CALL selectionChanged( + const ::com::sun::star::lang::EventObject& aEvent ) + throw (::com::sun::star::uno::RuntimeException); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::util::XModifiable > m_xModifiable; + ::com::sun::star::uno::Reference< + ::com::sun::star::view::XSelectionSupplier > m_xSelectionSupplier; + bool m_bIsModified; + ::rtl::OUString m_aSelectedCID; +}; + +} // namespace chart + +// CHART2_STATUSBARCOMMANDDISPATCH_HXX +#endif diff --git a/chart2/source/controller/main/UndoCommandDispatch.cxx b/chart2/source/controller/main/UndoCommandDispatch.cxx new file mode 100644 index 000000000000..14aedcdbae46 --- /dev/null +++ b/chart2/source/controller/main/UndoCommandDispatch.cxx @@ -0,0 +1,150 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: UndoCommandDispatch.cxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" + +#include "UndoCommandDispatch.hxx" +#include "macros.hxx" + +#include <com/sun/star/chart2/XUndoSupplier.hpp> +#include <com/sun/star/util/XModifyBroadcaster.hpp> + +#include <vos/mutex.hxx> +#include <vcl/svapp.hxx> + +// for ressource strings STR_UNDO and STR_REDO +#include <sfx2/sfx.hrc> + +#include "ResId.hxx" + +using namespace ::com::sun::star; + +using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::Sequence; +using ::rtl::OUString; + +namespace chart +{ + +UndoCommandDispatch::UndoCommandDispatch( + const Reference< uno::XComponentContext > & xContext, + const Reference< frame::XModel > & xModel ) : + CommandDispatch( xContext ), + m_xModel( xModel ) +{ + Reference< chart2::XUndoSupplier > xUndoSupplier( xModel, uno::UNO_QUERY ); + OSL_ASSERT( xUndoSupplier.is()); + if( xUndoSupplier.is()) + m_xUndoManager.set( xUndoSupplier->getUndoManager()); +} + +UndoCommandDispatch::~UndoCommandDispatch() +{} + +void UndoCommandDispatch::initialize() +{ + Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + if( xBroadcaster.is() ) + { + xBroadcaster->addModifyListener( this ); + } +} + +void UndoCommandDispatch::fireStatusEvent( + const OUString & rURL, + const Reference< frame::XStatusListener > & xSingleListener /* = 0 */ ) +{ + if( m_xUndoManager.is() ) + { + bool bFireAll = (rURL.getLength() == 0); + uno::Any aUndoState, aRedoState; + if( m_xUndoManager->undoPossible()) + { + // using assignment for broken gcc 3.3 + OUString aUndo = OUString( String( SchResId( STR_UNDO ))); + aUndoState <<= ( aUndo + m_xUndoManager->getCurrentUndoString()); + } + if( m_xUndoManager->redoPossible()) + { + // using assignment for broken gcc 3.3 + OUString aRedo = OUString( String( SchResId( STR_REDO ))); + aRedoState <<= ( aRedo + m_xUndoManager->getCurrentRedoString()); + } + + if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Undo"))) + fireStatusEventForURL( C2U(".uno:Undo"), aUndoState, m_xUndoManager->undoPossible(), xSingleListener ); + if( bFireAll || rURL.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM(".uno:Redo"))) + fireStatusEventForURL( C2U(".uno:Redo"), aRedoState, m_xUndoManager->redoPossible(), xSingleListener ); + } +} + +// ____ XDispatch ____ +void SAL_CALL UndoCommandDispatch::dispatch( + const util::URL& URL, + const Sequence< beans::PropertyValue >& /* Arguments */ ) + throw (uno::RuntimeException) +{ + if( m_xUndoManager.is() ) + { + // why is it necessary to lock the solar mutex here? + // /-- + ::vos::OGuard aSolarGuard( Application::GetSolarMutex()); + if( URL.Path.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "Undo" ))) + m_xUndoManager->undo( m_xModel ); + else + m_xUndoManager->redo( m_xModel ); + // \-- + } +} + +// ____ WeakComponentImplHelperBase ____ +/// is called when this is disposed +void SAL_CALL UndoCommandDispatch::disposing() +{ + Reference< util::XModifyBroadcaster > xBroadcaster( m_xUndoManager, uno::UNO_QUERY ); + if( xBroadcaster.is() ) + { + xBroadcaster->removeModifyListener( this ); + } + + m_xUndoManager.clear(); + m_xModel.clear(); +} + +// ____ XEventListener (base of XModifyListener) ____ +void SAL_CALL UndoCommandDispatch::disposing( const lang::EventObject& /* Source */ ) + throw (uno::RuntimeException) +{ + m_xUndoManager.clear(); + m_xModel.clear(); +} + +} // namespace chart diff --git a/chart2/source/controller/main/UndoCommandDispatch.hxx b/chart2/source/controller/main/UndoCommandDispatch.hxx new file mode 100644 index 000000000000..9efafd1685ed --- /dev/null +++ b/chart2/source/controller/main/UndoCommandDispatch.hxx @@ -0,0 +1,89 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: UndoCommandDispatch.hxx,v $ + * $Revision: 1.4 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef CHART2_UNDOCOMMANDDISPATCH_HXX +#define CHART2_UNDOCOMMANDDISPATCH_HXX + +#include "CommandDispatch.hxx" + +#include <com/sun/star/frame/XModel.hpp> +#include <com/sun/star/chart2/XUndoManager.hpp> + +namespace chart +{ + +/** This is a CommandDispatch implementation for Undo and Redo. + + You need to pass an UndoManager to this class that is then used for Undo and + Redo. The changes are applied to the given XModel. + */ +class UndoCommandDispatch : public CommandDispatch +{ +public: + explicit UndoCommandDispatch( + const ::com::sun::star::uno::Reference< + ::com::sun::star::uno::XComponentContext > & xContext, + const ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > & xModel ); + virtual ~UndoCommandDispatch(); + + // late initialisation, especially for adding as listener + virtual void initialize(); + +protected: + // ____ XDispatch ____ + virtual void SAL_CALL dispatch( + const ::com::sun::star::util::URL& URL, + const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& Arguments ) + throw (::com::sun::star::uno::RuntimeException); + + // ____ WeakComponentImplHelperBase ____ + /// is called when this is disposed + virtual void SAL_CALL disposing(); + + // ____ XEventListener (base of XModifyListener) ____ + virtual void SAL_CALL disposing( + const ::com::sun::star::lang::EventObject& Source ) + throw (::com::sun::star::uno::RuntimeException); + + virtual void fireStatusEvent( + const ::rtl::OUString & rURL, + const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener > & xSingleListener ); + +private: + ::com::sun::star::uno::Reference< + ::com::sun::star::frame::XModel > m_xModel; + ::com::sun::star::uno::Reference< + ::com::sun::star::chart2::XUndoManager > m_xUndoManager; +}; + +} // namespace chart + +// CHART2_UNDOCOMMANDDISPATCH_HXX +#endif diff --git a/chart2/source/controller/main/_serviceregistration_controller.cxx b/chart2/source/controller/main/_serviceregistration_controller.cxx new file mode 100644 index 000000000000..7de2e8fa8588 --- /dev/null +++ b/chart2/source/controller/main/_serviceregistration_controller.cxx @@ -0,0 +1,127 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: _serviceregistration_controller.cxx,v $ + * $Revision: 1.8 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +// MARKER(update_precomp.py): autogen include statement, do not remove +#include "precompiled_chart2.hxx" +#include "ChartController.hxx" +#include "ChartFrameloader.hxx" +#include "dlg_CreationWizard_UNO.hxx" +#include "dlg_ChartType_UNO.hxx" +#include "ChartDocumentWrapper.hxx" +#include "AccessibleChartView.hxx" +#include "ElementSelector.hxx" +#include <cppuhelper/implementationentry.hxx> + +static struct ::cppu::ImplementationEntry g_entries_chart2_controller[] = +{ + { + ::chart::ChartController::create + , ::chart::ChartController::getImplementationName_Static + , ::chart::ChartController::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::ChartFrameLoader::create + , ::chart::ChartFrameLoader::getImplementationName_Static + , ::chart::ChartFrameLoader::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::CreationWizardUnoDlg::create + , ::chart::CreationWizardUnoDlg::getImplementationName_Static + , ::chart::CreationWizardUnoDlg::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::ChartTypeUnoDlg::Create + , ::chart::ChartTypeUnoDlg::getImplementationName_Static + , ::chart::ChartTypeUnoDlg::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::wrapper::ChartDocumentWrapper::create + , ::chart::wrapper::ChartDocumentWrapper::getImplementationName_Static + , ::chart::wrapper::ChartDocumentWrapper::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::AccessibleChartView::create + , ::chart::AccessibleChartView::getImplementationName_Static + , ::chart::AccessibleChartView::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ + ::chart::ElementSelectorToolbarController::create + , ::chart::ElementSelectorToolbarController::getImplementationName_Static + , ::chart::ElementSelectorToolbarController::getSupportedServiceNames_Static + , ::cppu::createSingleComponentFactory + , 0 + , 0 + } + ,{ 0, 0, 0, 0, 0, 0 } +}; + +// component exports +extern "C" +{ +//================================================================================================== +SAL_DLLPUBLIC_EXPORT void SAL_CALL component_getImplementationEnvironment( + const sal_Char ** ppEnvTypeName, uno_Environment ** /* ppEnv */ ) +{ + *ppEnvTypeName = CPPU_CURRENT_LANGUAGE_BINDING_NAME; +} +//================================================================================================== +SAL_DLLPUBLIC_EXPORT sal_Bool SAL_CALL component_writeInfo( + void * pServiceManager, void * pRegistryKey ) +{ + return ::cppu::component_writeInfoHelper( + pServiceManager, pRegistryKey, g_entries_chart2_controller ); +} +//================================================================================================== +SAL_DLLPUBLIC_EXPORT void * SAL_CALL component_getFactory( + const sal_Char * pImplName, void * pServiceManager, void * pRegistryKey ) +{ + return ::cppu::component_getFactoryHelper( + pImplName, pServiceManager, pRegistryKey , g_entries_chart2_controller ); +} +} +//========================================================================= diff --git a/chart2/source/controller/main/makefile.mk b/chart2/source/controller/main/makefile.mk new file mode 100644 index 000000000000..5d0ecadc0ae0 --- /dev/null +++ b/chart2/source/controller/main/makefile.mk @@ -0,0 +1,81 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.9 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/..$/.. +PRJINC= $(PRJ)$/source +PRJNAME= chart2 +TARGET= chcontroller + +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: settings.mk + +# --- export library ------------------------------------------------- + +#object files to build and link together to lib $(SLB)$/$(TARGET).lib +SLOFILES = \ + $(SLO)$/ConfigurationAccess.obj \ + $(SLO)$/ElementSelector.obj \ + $(SLO)$/SelectionHelper.obj \ + $(SLO)$/PositionAndSizeHelper.obj \ + $(SLO)$/ChartWindow.obj \ + $(SLO)$/ChartController.obj \ + $(SLO)$/ChartController_EditData.obj \ + $(SLO)$/ChartController_Window.obj \ + $(SLO)$/ChartController_Properties.obj \ + $(SLO)$/ChartController_Insert.obj \ + $(SLO)$/ChartController_TextEdit.obj \ + $(SLO)$/ChartController_Position.obj \ + $(SLO)$/ChartController_Tools.obj \ + $(SLO)$/ChartFrameloader.obj \ + $(SLO)$/ChartRenderer.obj \ + $(SLO)$/CommandDispatchContainer.obj \ + $(SLO)$/CommandDispatch.obj \ + $(SLO)$/ControllerCommandDispatch.obj \ + $(SLO)$/UndoCommandDispatch.obj \ + $(SLO)$/DragMethod_Base.obj \ + $(SLO)$/DragMethod_RotateDiagram.obj \ + $(SLO)$/DragMethod_PieSegment.obj \ + $(SLO)$/ObjectHierarchy.obj \ + $(SLO)$/_serviceregistration_controller.obj \ + $(SLO)$/ChartDropTargetHelper.obj \ + $(SLO)$/StatusBarCommandDispatch.obj \ + $(SLO)$/ChartTransferable.obj + +# $(SLO)$/CommonConverters.obj \ +# $(SLO)$/Scaling.obj \ + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk diff --git a/chart2/source/controller/makefile.mk b/chart2/source/controller/makefile.mk new file mode 100644 index 000000000000..45060a60d297 --- /dev/null +++ b/chart2/source/controller/makefile.mk @@ -0,0 +1,131 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2008 by Sun Microsystems, Inc. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# $RCSfile: makefile.mk,v $ +# +# $Revision: 1.12.68.1 $ +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ= ..$/.. +PRJNAME= chart2 +TARGET= chartcontroller + +USE_DEFFILE= TRUE +ENABLE_EXCEPTIONS= TRUE +VISIBILITY_HIDDEN=TRUE + +# --- Settings ----------------------------------------------------- + +.INCLUDE: $(PRJ)$/util$/makefile.pmk + +# --- export library ------------------------------------------------- + +#You can use several library macros of this form to build libraries that +#do not consist of all object files in a directory or to merge different libraries. +LIB1TARGET= $(SLB)$/$(TARGET).lib + +LIB1FILES= \ + $(SLB)$/chcontroller.lib \ + $(SLB)$/chcdrawinglayer.lib \ + $(SLB)$/chcitemsetwrapper.lib \ + $(SLB)$/chcdialogs.lib \ + $(SLB)$/chchartapiwrapper.lib \ + $(SLB)$/chcaccessibility.lib + +#-------- + +#Indicates the filename of the shared library. +SHL1TARGET= $(TARGET)$(DLLPOSTFIX) + +#indicates dependencies: +.IF "$(COM)" == "MSC" +SHL1DEPN = \ + $(LB)$/icharttools.lib \ + $(LB)$/ichartview.lib +.ELSE +SHL1DEPN = +.ENDIF + +#Specifies an import library to create. For Win32 only. +SHL1IMPLIB= i$(TARGET) + +#Specifies libraries from the same module to put into the shared library. +#was created above +SHL1LIBS= $(LIB1TARGET) + +#Links import libraries. + +SHL1STDLIBS= $(CHARTTOOLS) \ + $(CHARTVIEW) \ + $(CPPULIB) \ + $(CPPUHELPERLIB) \ + $(COMPHELPERLIB) \ + $(BASEGFXLIB) \ + $(DRAWINGLAYERLIB) \ + $(GOODIESLIB) \ + $(BASEGFXLIB) \ + $(SALLIB) \ + $(SVLLIB) \ + $(SVTOOLLIB) \ + $(SVXCORELIB) \ + $(SVXLIB) \ + $(TKLIB) \ + $(TOOLSLIB) \ + $(VCLLIB) \ + $(SFXLIB) \ + $(UNOTOOLSLIB) \ + $(SOTLIB) + +#--------exports + +#specifies the exported symbols for Windows only: +SHL1DEF= $(MISC)$/$(SHL1TARGET).def + +SHL1VERSIONMAP = controller.map + +#--------definition file + +#name of the definition file: +DEF1NAME= $(SHL1TARGET) + +# --- Resources --------------------------------------------------------------- + +# sfx.srs is needed for the strings for UNDO and REDO in the UndoCommandDispatch +RESLIB1LIST=\ + $(SRS)$/chcdialogs.srs \ + $(SOLARCOMMONRESDIR)$/sfx.srs + +RESLIB1NAME= $(TARGET) +RESLIB1IMAGES=$(PRJ)$/res +RESLIB1SRSFILES=$(RESLIB1LIST) +RESLIB1DEPN=$(RESLIB1LIST) + +#RESLIB1SRSFILES=$(SRS)$/$(TARGET).srs +#RESLIB1DEPN= SRCFILES + +# --- Targets ----------------------------------------------------------------- + +.INCLUDE: target.mk |