diff options
Diffstat (limited to 'sc')
-rw-r--r-- | sc/inc/fielduno.hxx | 132 | ||||
-rw-r--r-- | sc/source/ui/unoobj/fielduno.cxx | 425 |
2 files changed, 1 insertions, 556 deletions
diff --git a/sc/inc/fielduno.hxx b/sc/inc/fielduno.hxx index d87f11f2e9c4..7acff6c940ce 100644 --- a/sc/inc/fielduno.hxx +++ b/sc/inc/fielduno.hxx @@ -131,138 +131,6 @@ public: throw(::com::sun::star::uno::RuntimeException); }; - -class ScCellFieldObj : public ScMutexHelper, - public ::cppu::OComponentHelper, - public ::com::sun::star::text::XTextField, - public ::com::sun::star::beans::XPropertySet, - public ::com::sun::star::lang::XUnoTunnel, - public ::com::sun::star::lang::XServiceInfo, - public SfxListener -{ -private: - const SfxItemPropertySet* pPropSet; - ScDocShell* pDocShell; - ScAddress aCellPos; - SvxEditSource* pEditSource; - ESelection aSelection; - - String aUrl; // content, only iff not already inserted - String aRepresentation; - String aTarget; - - ScCellFieldObj(); // disabled -public: - ScCellFieldObj(ScDocShell* pDocSh, const ScAddress& rPos, - const ESelection& rSel); - virtual ~ScCellFieldObj(); - - virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); - - // called by getImplementation: - void DeleteField(); - sal_Bool IsInserted() const { return pEditSource != NULL; } - SvxFieldItem CreateFieldItem(); - void InitDoc( ScDocShell* pDocSh, const ScAddress& rPos, - const ESelection& rSel ); - - virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( - const ::com::sun::star::uno::Type & rType ) - throw(::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( - const ::com::sun::star::uno::Type & rType ) - throw(::com::sun::star::uno::RuntimeException); - virtual void SAL_CALL acquire() throw(); - virtual void SAL_CALL release() throw(); - - // XTextField - virtual ::rtl::OUString SAL_CALL getPresentation( sal_Bool bShowCommand ) - throw(::com::sun::star::uno::RuntimeException); - - // XTextContent - virtual void SAL_CALL attach( const ::com::sun::star::uno::Reference< - ::com::sun::star::text::XTextRange >& xTextRange ) - throw(::com::sun::star::lang::IllegalArgumentException, - ::com::sun::star::uno::RuntimeException); - virtual ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > SAL_CALL - getAnchor() 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); - - // 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); - - // XUnoTunnel - virtual sal_Int64 SAL_CALL getSomething( const ::com::sun::star::uno::Sequence< - sal_Int8 >& aIdentifier ) - throw(::com::sun::star::uno::RuntimeException); - - static const com::sun::star::uno::Sequence<sal_Int8>& getUnoTunnelId(); - static ScCellFieldObj* getImplementation( const com::sun::star::uno::Reference< - com::sun::star::text::XTextContent> xObj ); - - // 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); - - // 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); -}; - -//------------------------------------------------------------------ - class ScHeaderFieldsObj : public cppu::WeakImplHelper5< com::sun::star::container::XEnumerationAccess, com::sun::star::container::XIndexAccess, diff --git a/sc/source/ui/unoobj/fielduno.cxx b/sc/source/ui/unoobj/fielduno.cxx index d88770dd7971..eacf867de6b4 100644 --- a/sc/source/ui/unoobj/fielduno.cxx +++ b/sc/source/ui/unoobj/fielduno.cxx @@ -425,429 +425,6 @@ void SAL_CALL ScCellFieldsObj::removeRefreshListener( const uno::Reference<util: } } -//------------------------------------------------------------------------ - -// Default-ctor wird fuer SMART_REFLECTION_IMPLEMENTATION gebraucht - - -ScCellFieldObj::ScCellFieldObj(ScDocShell* pDocSh, const ScAddress& rPos, - const ESelection& rSel) : - OComponentHelper( getMutex() ), - pPropSet( lcl_GetURLPropertySet() ), - pDocShell( pDocSh ), - aCellPos( rPos ), - aSelection( rSel ) -{ - // pDocShell ist Null, wenn per ServiceProvider erzeugt - - if (pDocShell) - { - pDocShell->GetDocument()->AddUnoObject(*this); - pEditSource = new ScCellEditSource( pDocShell, aCellPos ); - } - else - pEditSource = NULL; -} - -uno::Any SAL_CALL ScCellFieldObj::queryAggregation( const uno::Type& rType ) - throw(uno::RuntimeException) -{ - SC_QUERYINTERFACE( text::XTextField ) - SC_QUERYINTERFACE( text::XTextContent ) // parent of XTextField - SC_QUERYINTERFACE( beans::XPropertySet ) - SC_QUERYINTERFACE( lang::XUnoTunnel ) - SC_QUERYINTERFACE( lang::XServiceInfo ) - - return OComponentHelper::queryAggregation( rType ); // XComponent -} - -uno::Sequence<uno::Type> SAL_CALL ScCellFieldObj::getTypes() throw(uno::RuntimeException) -{ - static uno::Sequence<uno::Type> aTypes; - if ( aTypes.getLength() == 0 ) - { - uno::Sequence<uno::Type> aParentTypes(OComponentHelper::getTypes()); - long nParentLen = aParentTypes.getLength(); - const uno::Type* pParentPtr = aParentTypes.getConstArray(); - - aTypes.realloc( nParentLen + 4 ); - uno::Type* pPtr = aTypes.getArray(); - pPtr[nParentLen + 0] = getCppuType((const uno::Reference<text::XTextField>*)0); - pPtr[nParentLen + 1] = getCppuType((const uno::Reference<beans::XPropertySet>*)0); - pPtr[nParentLen + 2] = getCppuType((const uno::Reference<lang::XUnoTunnel>*)0); - pPtr[nParentLen + 3] = getCppuType((const uno::Reference<lang::XServiceInfo>*)0); - - for (long i=0; i<nParentLen; i++) - pPtr[i] = pParentPtr[i]; // parent types first - } - return aTypes; -} - -namespace -{ - class theScCellFieldObjImplementationId : public rtl::Static< UnoTunnelIdInit, theScCellFieldObjImplementationId > {}; -} - -uno::Sequence<sal_Int8> SAL_CALL ScCellFieldObj::getImplementationId() - throw(uno::RuntimeException) -{ - return theScCellFieldObjImplementationId::get().getSeq(); -} - -uno::Any SAL_CALL ScCellFieldObj::queryInterface( const uno::Type& rType ) - throw(uno::RuntimeException) -{ - return OComponentHelper::queryInterface( rType ); -} - -void SAL_CALL ScCellFieldObj::acquire() throw() -{ - OComponentHelper::acquire(); -} - -void SAL_CALL ScCellFieldObj::release() throw() -{ - OComponentHelper::release(); -} - -void ScCellFieldObj::InitDoc( ScDocShell* pDocSh, const ScAddress& rPos, - const ESelection& rSel ) -{ - if ( pDocSh && !pEditSource ) - { - aCellPos = rPos; - aSelection = rSel; - pDocShell = pDocSh; - - pDocShell->GetDocument()->AddUnoObject(*this); - pEditSource = new ScCellEditSource( pDocShell, aCellPos ); - } -} - -ScCellFieldObj::~ScCellFieldObj() -{ - if (pDocShell) - pDocShell->GetDocument()->RemoveUnoObject(*this); - - delete pEditSource; -} - -void ScCellFieldObj::Notify( SfxBroadcaster&, const SfxHint& rHint ) -{ - //! Updates fuer aSelection (muessen erst noch erzeugt werden) !!!!!! - - if ( rHint.ISA( ScUpdateRefHint ) ) - { - //! Ref-Update - } - else if ( rHint.ISA( SfxSimpleHint ) && - ((const SfxSimpleHint&)rHint).GetId() == SFX_HINT_DYING ) - { - pDocShell = NULL; // ungueltig geworden - } - - // EditSource hat sich selber als Listener angemeldet -} - -// per getImplementation gerufen: - -SvxFieldItem ScCellFieldObj::CreateFieldItem() -{ - OSL_ENSURE( !pEditSource, "CreateFieldItem mit eingefuegtem Feld" ); - - SvxURLField aField; - aField.SetFormat(SVXURLFORMAT_APPDEFAULT); - aField.SetURL( aUrl ); - aField.SetRepresentation( aRepresentation ); - aField.SetTargetFrame( aTarget ); - return SvxFieldItem( aField, EE_FEATURE_FIELD ); -} - -void ScCellFieldObj::DeleteField() -{ - if (pEditSource) - { - SvxTextForwarder* pForwarder = pEditSource->GetTextForwarder(); - pForwarder->QuickInsertText( String(), aSelection ); - pEditSource->UpdateData(); - - aSelection.nEndPara = aSelection.nStartPara; - aSelection.nEndPos = aSelection.nStartPos; - - //! Broadcast, um Selektion in anderen Objekten anzupassen - //! (auch bei anderen Aktionen) - } -} - -// XTextField - -rtl::OUString SAL_CALL ScCellFieldObj::getPresentation( sal_Bool bShowCommand ) - throw(uno::RuntimeException) -{ - SolarMutexGuard aGuard; - String aRet; - - if (pEditSource) - { - //! Feld-Funktionen muessen an den Forwarder !!! - ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine(); - ScUnoEditEngine aTempEngine(pEditEngine); - - // Typ egal (in Zellen gibts nur URLs) - SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 ); - OSL_ENSURE(pField,"getPresentation: Feld nicht gefunden"); - if (pField) - { - SvxURLField* pURL = (SvxURLField*)pField; - if (bShowCommand) - aRet = pURL->GetURL(); - else - aRet = pURL->GetRepresentation(); - } - } - - return aRet; -} - -// XTextContent - -void SAL_CALL ScCellFieldObj::attach( const uno::Reference<text::XTextRange>& xTextRange ) - throw(lang::IllegalArgumentException, uno::RuntimeException) -{ - SolarMutexGuard aGuard; - if (xTextRange.is()) - { - uno::Reference<text::XText> xText(xTextRange->getText()); - if (xText.is()) - { - xText->insertTextContent( xTextRange, this, sal_True ); - } - } -} - -uno::Reference<text::XTextRange> SAL_CALL ScCellFieldObj::getAnchor() throw(uno::RuntimeException) -{ - SolarMutexGuard aGuard; - if (pDocShell) - return new ScCellObj( pDocShell, aCellPos ); - return NULL; -} - -// XComponent - -void SAL_CALL ScCellFieldObj::dispose() throw(uno::RuntimeException) -{ - OComponentHelper::dispose(); -} - -void SAL_CALL ScCellFieldObj::addEventListener( - const uno::Reference<lang::XEventListener>& xListener ) - throw(uno::RuntimeException) -{ - OComponentHelper::addEventListener( xListener ); -} - -void SAL_CALL ScCellFieldObj::removeEventListener( - const uno::Reference<lang::XEventListener>& xListener ) - throw(uno::RuntimeException) -{ - OComponentHelper::removeEventListener( xListener ); -} - -// XPropertySet - -uno::Reference<beans::XPropertySetInfo> SAL_CALL ScCellFieldObj::getPropertySetInfo() - throw(uno::RuntimeException) -{ - SolarMutexGuard aGuard; - static uno::Reference<beans::XPropertySetInfo> aRef = pPropSet->getPropertySetInfo(); - return aRef; -} - -void SAL_CALL ScCellFieldObj::setPropertyValue( - const rtl::OUString& aPropertyName, const uno::Any& aValue ) - throw(beans::UnknownPropertyException, beans::PropertyVetoException, - lang::IllegalArgumentException, lang::WrappedTargetException, - uno::RuntimeException) -{ - SolarMutexGuard aGuard; - String aNameString(aPropertyName); - rtl::OUString aStrVal; - if (pEditSource) - { - //! Feld-Funktionen muessen an den Forwarder !!! - ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine(); - ScUnoEditEngine aTempEngine(pEditEngine); - - // Typ egal (in Zellen gibts nur URLs) - SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 ); - OSL_ENSURE(pField,"setPropertyValue: Feld nicht gefunden"); - if (pField) - { - SvxURLField* pURL = (SvxURLField*)pField; // ist eine Kopie in der ScUnoEditEngine - - sal_Bool bOk = sal_True; - if ( aNameString.EqualsAscii( SC_UNONAME_URL ) ) - { - if (aValue >>= aStrVal) - pURL->SetURL( aStrVal ); - } - else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) ) - { - if (aValue >>= aStrVal) - pURL->SetRepresentation( aStrVal ); - } - else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) ) - { - if (aValue >>= aStrVal) - pURL->SetTargetFrame( aStrVal ); - } - else - bOk = false; - - if (bOk) - { - pEditEngine->QuickInsertField( SvxFieldItem(*pField, EE_FEATURE_FIELD), aSelection ); - pEditSource->UpdateData(); - } - } - } - else // noch nicht eingefuegt - { - if ( aNameString.EqualsAscii( SC_UNONAME_URL ) ) - { - if (aValue >>= aStrVal) - aUrl = String( aStrVal ); - } - else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) ) - { - if (aValue >>= aStrVal) - aRepresentation = String( aStrVal ); - } - else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) ) - { - if (aValue >>= aStrVal) - aTarget = String( aStrVal ); - } - } -} - -uno::Any SAL_CALL ScCellFieldObj::getPropertyValue( const rtl::OUString& aPropertyName ) - throw(beans::UnknownPropertyException, lang::WrappedTargetException, - uno::RuntimeException) -{ - SolarMutexGuard aGuard; - uno::Any aRet; - String aNameString(aPropertyName); - - // anchor type is always "as character", text wrap always "none" - - if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPE ) ) - aRet <<= text::TextContentAnchorType_AS_CHARACTER; - else if ( aNameString.EqualsAscii( SC_UNONAME_ANCTYPES ) ) - { - uno::Sequence<text::TextContentAnchorType> aSeq(1); - aSeq[0] = text::TextContentAnchorType_AS_CHARACTER; - aRet <<= aSeq; - } - else if ( aNameString.EqualsAscii( SC_UNONAME_TEXTWRAP ) ) - aRet <<= text::WrapTextMode_NONE; - else if (pEditSource) - { - //! Feld-Funktionen muessen an den Forwarder !!! - ScEditEngineDefaulter* pEditEngine = ((ScCellEditSource*)pEditSource)->GetEditEngine(); - ScUnoEditEngine aTempEngine(pEditEngine); - - // Typ egal (in Zellen gibts nur URLs) - SvxFieldData* pField = aTempEngine.FindByPos( aSelection.nStartPara, aSelection.nStartPos, 0 ); - OSL_ENSURE(pField,"getPropertyValue: Feld nicht gefunden"); - if (pField) - { - SvxURLField* pURL = (SvxURLField*)pField; - - if ( aNameString.EqualsAscii( SC_UNONAME_URL ) ) - aRet <<= rtl::OUString( pURL->GetURL() ); - else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) ) - aRet <<= rtl::OUString( pURL->GetRepresentation() ); - else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) ) - aRet <<= rtl::OUString( pURL->GetTargetFrame() ); - } - } - else // noch nicht eingefuegt - { - if ( aNameString.EqualsAscii( SC_UNONAME_URL ) ) - aRet <<= rtl::OUString( aUrl ); - else if ( aNameString.EqualsAscii( SC_UNONAME_REPR ) ) - aRet <<= rtl::OUString( aRepresentation ); - else if ( aNameString.EqualsAscii( SC_UNONAME_TARGET ) ) - aRet <<= rtl::OUString( aTarget ); - } - return aRet; -} - -SC_IMPL_DUMMY_PROPERTY_LISTENER( ScCellFieldObj ) - -// XUnoTunnel - -sal_Int64 SAL_CALL ScCellFieldObj::getSomething( - const uno::Sequence<sal_Int8 >& rId ) throw(uno::RuntimeException) -{ - if ( rId.getLength() == 16 && - 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), - rId.getConstArray(), 16 ) ) - { - return sal::static_int_cast<sal_Int64>(reinterpret_cast<sal_IntPtr>(this)); - } - return 0; -} - -namespace -{ - class theScCellFieldObjUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theScCellFieldObjUnoTunnelId> {}; -} - -const uno::Sequence<sal_Int8>& ScCellFieldObj::getUnoTunnelId() -{ - return theScCellFieldObjUnoTunnelId::get().getSeq(); -} - -ScCellFieldObj* ScCellFieldObj::getImplementation( - const uno::Reference<text::XTextContent> xObj ) -{ - ScCellFieldObj* pRet = NULL; - uno::Reference<lang::XUnoTunnel> xUT( xObj, uno::UNO_QUERY ); - if (xUT.is()) - pRet = reinterpret_cast<ScCellFieldObj*>(sal::static_int_cast<sal_IntPtr>(xUT->getSomething(getUnoTunnelId()))); - return pRet; -} - -// XServiceInfo - -rtl::OUString SAL_CALL ScCellFieldObj::getImplementationName() throw(uno::RuntimeException) -{ - return rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( "ScCellFieldObj" )); -} - -sal_Bool SAL_CALL ScCellFieldObj::supportsService( const rtl::OUString& rServiceName ) - throw(uno::RuntimeException) -{ - String aServiceStr( rServiceName ); - return aServiceStr.EqualsAscii( SCTEXTFIELD_SERVICE ) || - aServiceStr.EqualsAscii( SCTEXTCONTENT_SERVICE ); -} - -uno::Sequence<rtl::OUString> SAL_CALL ScCellFieldObj::getSupportedServiceNames() - throw(uno::RuntimeException) -{ - uno::Sequence<rtl::OUString> aRet(2); - rtl::OUString* pArray = aRet.getArray(); - pArray[0] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCTEXTFIELD_SERVICE )); - pArray[1] = rtl::OUString(RTL_CONSTASCII_USTRINGPARAM( SCTEXTCONTENT_SERVICE )); - return aRet; -} - -//------------------------------------------------------------------------ - ScHeaderFieldsObj::ScHeaderFieldsObj(ScHeaderFooterTextData& rData) : mrData(rData), nType(SC_SERVICE_INVALID), @@ -1824,7 +1401,7 @@ namespace const uno::Sequence<sal_Int8>& ScEditFieldObj::getUnoTunnelId() { - return theScCellFieldObjUnoTunnelId::get().getSeq(); + return theScEditFieldObjUnoTunnelId::get().getSeq(); } ScEditFieldObj* ScEditFieldObj::getImplementation(const uno::Reference<text::XTextContent>& xObj) |