diff options
author | Daniel Vogelheim <dvo@openoffice.org> | 2000-12-19 16:28:58 +0000 |
---|---|---|
committer | Daniel Vogelheim <dvo@openoffice.org> | 2000-12-19 16:28:58 +0000 |
commit | 27bd20c19fa052d3e533da8ad415b23393c79daf (patch) | |
tree | cb9d4615d0c40050e2ac1681ec304b73964a7a45 | |
parent | 07a35b5e0625e1780e88577113ed165707f5f39b (diff) |
- added: support for XEventSupplier interface for frame, graphics, OLE, and frame style
-rw-r--r-- | sw/inc/unoframe.hxx | 29 | ||||
-rw-r--r-- | sw/inc/unostyle.hxx | 32 | ||||
-rw-r--r-- | sw/source/core/unocore/makefile.mk | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unocoll.cxx | 8 | ||||
-rw-r--r-- | sw/source/core/unocore/unoevent.cxx | 690 | ||||
-rw-r--r-- | sw/source/core/unocore/unoframe.cxx | 33 | ||||
-rw-r--r-- | sw/source/core/unocore/unostyle.cxx | 55 |
7 files changed, 832 insertions, 23 deletions
diff --git a/sw/inc/unoframe.hxx b/sw/inc/unoframe.hxx index ff682c11d671..1303984f194c 100644 --- a/sw/inc/unoframe.hxx +++ b/sw/inc/unoframe.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unoframe.hxx,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: os $ $Date: 2000-11-22 12:03:37 $ + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:57 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -82,6 +82,9 @@ #ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_ #include <com/sun/star/frame/XModel.hpp> #endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSUPPLIER_HPP_ +#include <com/sun/star/document/XEventSupplier.hpp> +#endif /*-----------------12.02.98 11:21------------------- @@ -179,10 +182,11 @@ public: /*-----------------20.02.98 11:28------------------- --------------------------------------------------*/ -typedef cppu::WeakImplHelper2 +typedef cppu::WeakImplHelper3 < ::com::sun::star::text::XTextFrame, - ::com::sun::star::container::XEnumerationAccess + ::com::sun::star::container::XEnumerationAccess, + ::com::sun::star::document::XEventSupplier > SwXTextFrameBaseClass; @@ -235,15 +239,19 @@ public: virtual 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(void) throw( ::com::sun::star::uno::RuntimeException ); + // XEventSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); + void * SAL_CALL operator new( size_t ) throw(); void SAL_CALL operator delete( void * ) throw(); }; /*-----------------20.02.98 11:28------------------- --------------------------------------------------*/ -typedef cppu::WeakImplHelper1 +typedef cppu::WeakImplHelper2 < - ::com::sun::star::text::XTextContent + ::com::sun::star::text::XTextContent, + ::com::sun::star::document::XEventSupplier > SwXTextGraphicObjectBaseClass; class SwXTextGraphicObject : public SwXTextGraphicObjectBaseClass, @@ -276,16 +284,19 @@ public: virtual 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(void) throw( ::com::sun::star::uno::RuntimeException ); + // XEventSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); void * SAL_CALL operator new( size_t ) throw(); void SAL_CALL operator delete( void * ) throw(); }; /*-----------------20.02.98 11:28------------------- --------------------------------------------------*/ -typedef cppu::WeakImplHelper2 +typedef cppu::WeakImplHelper3 < ::com::sun::star::text::XTextContent, - ::com::sun::star::document::XEmbeddedObjectSupplier + ::com::sun::star::document::XEmbeddedObjectSupplier, + ::com::sun::star::document::XEventSupplier >SwXTextEmbeddedObjectBaseClass; class SwXTextEmbeddedObject : public SwXTextEmbeddedObjectBaseClass, @@ -321,6 +332,8 @@ public: virtual 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(void) throw( ::com::sun::star::uno::RuntimeException ); + // XEventSupplier + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); void * SAL_CALL operator new( size_t ) throw(); void SAL_CALL operator delete( void * ) throw(); }; diff --git a/sw/inc/unostyle.hxx b/sw/inc/unostyle.hxx index ed42c00b7d3e..b94cbf4c516f 100644 --- a/sw/inc/unostyle.hxx +++ b/sw/inc/unostyle.hxx @@ -2,9 +2,9 @@ * * $RCSfile: unostyle.hxx,v $ * - * $Revision: 1.2 $ + * $Revision: 1.3 $ * - * last change: $Author: mib $ $Date: 2000-10-06 06:36:02 $ + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:58 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -94,6 +94,9 @@ #ifndef _CPPUHELPER_IMPLBASE5_HXX_ #include <cppuhelper/implbase5.hxx> // helper for implementations #endif +#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSUPPLIER_HPP_ +#include <com/sun/star/document/XEventSupplier.hpp> +#endif class SwDocShell; struct SfxItemPropertyMap; @@ -301,7 +304,32 @@ public: } const SwDoc* GetDoc() const { return m_pDoc; } }; +/* -----------------------------15.12.00 14:25-------------------------------- + + ---------------------------------------------------------------------------*/ +class SwXFrameStyle : public SwXStyle, + public com::sun::star::document::XEventSupplier +{ +public: + SwXFrameStyle(SfxStyleSheetBasePool& rPool, + SwDoc* pDoc, + const String& rStyleName) : + SwXStyle(rPool, SFX_STYLE_FAMILY_FRAME, pDoc, rStyleName){} + SwXFrameStyle() : + SwXStyle(SFX_STYLE_FAMILY_FRAME, FALSE){} + ~SwXFrameStyle(); + + virtual void SAL_CALL acquire( ) throw(){SwXStyle::acquire();} + virtual void SAL_CALL release( ) throw(){SwXStyle::release();} + + 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::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw(::com::sun::star::uno::RuntimeException); + + virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents( ) throw(::com::sun::star::uno::RuntimeException); + + friend class SwFrameStyleEventDescriptor; +}; /* -----------------24.08.98 16:04------------------- * * --------------------------------------------------*/ diff --git a/sw/source/core/unocore/makefile.mk b/sw/source/core/unocore/makefile.mk index ed1b1b729bdb..015bfe7343e6 100644 --- a/sw/source/core/unocore/makefile.mk +++ b/sw/source/core/unocore/makefile.mk @@ -2,9 +2,9 @@ # # $RCSfile: makefile.mk,v $ # -# $Revision: 1.5 $ +# $Revision: 1.6 $ # -# last change: $Author: os $ $Date: 2000-12-19 16:00:01 $ +# last change: $Author: dvo $ $Date: 2000-12-19 17:28:54 $ # # The Contents of this file are made available subject to the terms of # either of the following licenses @@ -93,6 +93,7 @@ CXXFILES = \ unocoll.cxx \ unoevtlstnr.cxx \ unodraw.cxx \ + unoevent.cxx \ unofield.cxx \ unoframe.cxx \ unoidx.cxx \ @@ -109,12 +110,13 @@ CXXFILES = \ unosrch.cxx \ unostyle.cxx \ unotbl.cxx \ - unotext.cxx + unotext.cxx SLOFILES = \ $(SLO)$/unobkm.obj\ $(SLO)$/unoclbck.obj\ + $(SLO)$/unoevent.obj\ $(SLO)$/unocrsrhelper.obj\ $(SLO)$/unoevtlstnr.obj\ $(SLO)$/unoftn.obj\ diff --git a/sw/source/core/unocore/unocoll.cxx b/sw/source/core/unocore/unocoll.cxx index 5bd97e8da7b0..f8a71eaedcb0 100644 --- a/sw/source/core/unocore/unocoll.cxx +++ b/sw/source/core/unocore/unocoll.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unocoll.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: dvo $ $Date: 2000-12-02 20:26:32 $ + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -448,7 +448,9 @@ uno::Reference< uno::XInterface > SwXServiceProvider::MakeInstance(sal_uInt16 } SwXStyle* pNewStyle = SFX_STYLE_FAMILY_PAGE == eFamily ? new SwXPageStyle(pDoc->GetDocShell()) : - new SwXStyle(eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE); + eFamily == SFX_STYLE_FAMILY_FRAME ? + new SwXFrameStyle: + new SwXStyle(eFamily, nObjectType == SW_SERVICE_STYLE_CONDITIONAL_PARAGRAPH_STYLE); xRet = (cppu::OWeakObject*)pNewStyle; } break; diff --git a/sw/source/core/unocore/unoevent.cxx b/sw/source/core/unocore/unoevent.cxx new file mode 100644 index 000000000000..ab7cfed7fae0 --- /dev/null +++ b/sw/source/core/unocore/unoevent.cxx @@ -0,0 +1,690 @@ +/************************************************************************* + * + * $RCSfile: unoevent.cxx,v $ + * + * $Revision: 1.1 $ + * + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:55 $ + * + * The Contents of this file are made available subject to the terms of + * either of the following licenses + * + * - GNU Lesser General Public License Version 2.1 + * - Sun Industry Standards Source License Version 1.1 + * + * Sun Microsystems Inc., October, 2000 + * + * GNU Lesser General Public License Version 2.1 + * ============================================= + * Copyright 2000 by Sun Microsystems, Inc. + * 901 San Antonio Road, Palo Alto, CA 94303, USA + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + * + * + * Sun Industry Standards Source License Version 1.1 + * ================================================= + * The contents of this file are subject to the Sun Industry Standards + * Source License Version 1.1 (the "License"); You may not use this file + * except in compliance with the License. You may obtain a copy of the + * License at http://www.openoffice.org/license.html. + * + * Software provided under this License is provided on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, + * WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS, + * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. + * See the License for the specific provisions governing your rights and + * obligations concerning the Software. + * + * The Initial Developer of the Original Code is: Sun Microsystems, Inc. + * + * Copyright: 2000 by Sun Microsystems, Inc. + * + * All Rights Reserved. + * + * Contributor(s): _______________________________________ + * + * + ************************************************************************/ + +// HINTIDs must be on top; it is required for the macitem.hxx header +#ifndef _HINTIDS_HXX +#include "hintids.hxx" +#endif + +#ifndef _UNOEVENT_HXX +#include "unoevent.hxx" +#endif + +#ifndef _UNOFRAME_HXX +#include "unoframe.hxx" +#endif + +#ifndef _UNOSTYLE_HXX +#include "unostyle.hxx" +#endif + +#ifndef _SWEVENT_HXX +#include "swevent.hxx" +#endif + +#ifndef _SFX_HRC +#include "sfx2/sfx.hrc" +#endif + +#ifndef _SFXMACITEM_HXX +#include <svtools/macitem.hxx> +#endif + +#ifndef _RTL_USTRBUF_HXX_ +#include <rtl/ustrbuf.hxx> +#endif + +#ifndef _COM_SUN_STAR_BEANS_PROPERTYVALUE_HPP +#include <com/sun/star/beans/PropertyValue.hpp> +#endif + +using namespace ::com::sun::star; +using namespace ::com::sun::star::uno; + +using ::com::sun::star::container::NoSuchElementException; +using ::com::sun::star::container::XNameReplace; +using ::com::sun::star::lang::IllegalArgumentException; +using ::com::sun::star::lang::WrappedTargetException; +using ::com::sun::star::lang::XServiceInfo; +using ::com::sun::star::beans::PropertyValue; +using ::cppu::WeakImplHelper2; +using ::rtl::OUString; +using ::rtl::OUStringBuffer; + + +const sal_Char sServiceName[] = "com.sun.star.container.XNameReplace"; +const sal_Char sImplementationName[] = "SwEventDescriptor"; + + +// +// tables of all known events handled by this class +// + +// careful: keep aKnownEventIDs and aKnownEventNames in sync! + +const USHORT aKnownEventIDs[] = +{ + SW_EVENT_OBJECT_SELECT, + SW_EVENT_START_INS_GLOSSARY, + SW_EVENT_END_INS_GLOSSARY, + SW_EVENT_MAIL_MERGE, + SW_EVENT_FRM_KEYINPUT_ALPHA, + SW_EVENT_FRM_KEYINPUT_NOALPHA, + SW_EVENT_FRM_RESIZE, + SW_EVENT_FRM_MOVE, + SW_EVENT_PAGE_COUNT, + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, + SFX_EVENT_OPENDOC, + SFX_EVENT_CLOSEDOC, + SFX_EVENT_STARTAPP, + SFX_EVENT_CLOSEAPP, + SFX_EVENT_CREATEDOC, + SFX_EVENT_SAVEDOC, + SFX_EVENT_SAVEASDOC, + SFX_EVENT_ACTIVATEDOC, + SFX_EVENT_DEACTIVATEDOC, + SFX_EVENT_PRINTDOC, + SFX_EVENT_ONERROR, + SFX_EVENT_LOADFINISHED, + SFX_EVENT_SAVEFINISHED, + SFX_EVENT_MODIFYCHANGED, + SFX_EVENT_PREPARECLOSEDOC, + SFX_EVENT_NEWMESSAGE, + SFX_EVENT_TOGGLEFULLSCREENMODE, + SFX_EVENT_SAVEDOCDONE, + SFX_EVENT_SAVEASDOCDONE, + +// ??? graphics load faulty, terminated, success + 0 +}; + +const sal_Char* aKnownEventNames[] = +{ + "OnSelect", + "OnInsertStart", + "OnInsertDone", + "OnMailMerge", + "OnAlphaCharInput", + "OnNonAlphaCharInput", + "OnResize", + "OnMove", + "PageCountChange", + "OnMouseOver", + "OnClick", + "OnMouseOut", + "OnLoadError", + "OnLoadCancel", + "OnLoadDone", + "OnLoad", + "OnUnload", + "OnStartApp", + "OnCloseApp", + "OnNew", + "OnSave", + "OnSaveAs", + "OnFocus", + "OnUnfocus", + "OnPrint", + "OnError", + "OnLoadFinished", + "OnSaveFinished", + "OnModifyChanged", + "OnPrepareUnload", + "OnNewMail", + "OnToggleFullscreen", + "OnSaveDone", + "OnSaveAsDone", + + NULL +}; + + +// +// tables of allowed events for specific objects +// + +const USHORT aGraphicEvents[] = +{ + SW_EVENT_OBJECT_SELECT, + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, +// graphics load (faulty|terminated|successful) + 0 +}; + +const USHORT aFrameEvents[] = +{ + SW_EVENT_OBJECT_SELECT, + SW_EVENT_FRM_KEYINPUT_ALPHA, + SW_EVENT_FRM_KEYINPUT_NOALPHA, + SW_EVENT_FRM_RESIZE, + SW_EVENT_FRM_MOVE, + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, + 0 +}; + +const USHORT aOLEEvents[] = +{ + SW_EVENT_OBJECT_SELECT, + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, + 0 +}; + +const USHORT aHyperlinkEvents[] = +{ + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, + 0 +}; + +const USHORT aAutotextEvents[] = +{ + SW_EVENT_START_INS_GLOSSARY, + SW_EVENT_END_INS_GLOSSARY, + 0 +}; + +const USHORT aFrameStyleEvents[] = +{ + SW_EVENT_OBJECT_SELECT, + SW_EVENT_FRM_KEYINPUT_ALPHA, + SW_EVENT_FRM_KEYINPUT_NOALPHA, + SW_EVENT_FRM_RESIZE, + SW_EVENT_FRM_MOVE, + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, +// graphics load (faulty|terminated|successful) + 0 +}; + +const USHORT aDocumentEvents[] = +{ + SFX_EVENT_STARTAPP, + SFX_EVENT_CLOSEAPP, + SFX_EVENT_CREATEDOC, + SFX_EVENT_OPENDOC, + SFX_EVENT_SAVEDOC, + SFX_EVENT_SAVEASDOC, +// ??? cf. SAVEDOCDONE, SAVEASDOCDONE + SFX_EVENT_SAVEFINISHED, + SFX_EVENT_CLOSEDOC, + SFX_EVENT_ACTIVATEDOC, + SFX_EVENT_DEACTIVATEDOC, + SFX_EVENT_ONERROR, + SFX_EVENT_NEWMESSAGE, + SFX_EVENT_PRINTDOC, + SW_EVENT_MAIL_MERGE, + SW_EVENT_PAGE_COUNT, +// SFX_EVENT_LOADFINISHED, +// SFX_EVENT_MODIFYCHANGED, +// SFX_EVENT_PREPARECLOSEDOC, +// SFX_EVENT_TOGGLEFULLSCREENMODE, +// SFX_EVENT_SAVEDOCDONE, +// SFX_EVENT_SAVEASDOCDONE, + + 0 +}; + +const USHORT aTest[] = +{ + SFX_EVENT_MOUSEOVER_OBJECT, + SFX_EVENT_MOUSECLICK_OBJECT, + SFX_EVENT_MOUSEOUT_OBJECT, + 0 +}; + + +SwEventDescriptor::SwEventDescriptor( + XInterface& rParent, + const USHORT* aSupportedEvents) : + xParentRef(&rParent), + aSupportedMacroItemIDs(aSupportedEvents), + sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")), + sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")), + sLibrary(RTL_CONSTASCII_USTRINGPARAM("Library")), + sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")), + sJavaScript(RTL_CONSTASCII_USTRINGPARAM("JavaScript")), + sScript(RTL_CONSTASCII_USTRINGPARAM("Script")), + sNone(RTL_CONSTASCII_USTRINGPARAM("None")) +{ + DBG_ASSERT(aSupportedEvents != NULL, "Need a list of supported events!"); +} + + +SwEventDescriptor::~SwEventDescriptor() +{ + // automatically release xParentRef ! +} + +void SwEventDescriptor::replaceByName( + const OUString& rName, + const Any& rElement ) + throw( + IllegalArgumentException, + NoSuchElementException) +{ + USHORT nMacroID = getMacroID(rName); + + // error checking + if (0 == nMacroID) + throw new NoSuchElementException(); + if (rElement.getValueType() != getElementType()) + throw new IllegalArgumentException(); + + // get sequence + Sequence<PropertyValue> aSequence; + rElement >>= aSequence; + + // process ... + sal_Bool bTypeOK = sal_False; + enum ScriptType eType; + OUString sScriptVal; + OUString sMacroVal; + OUString sLibVal; + sal_Int32 nCount = aSequence.getLength(); + for (sal_Int32 i = 0; i < nCount; i++) + { + PropertyValue& aValue = aSequence[i]; + if (aValue.Name.equals(sEventType)) + { + OUString sTmp; + aValue.Value >>= sTmp; + if (sTmp.equals(sStarBasic)) + { + eType = STARBASIC; + bTypeOK = sal_True; + } + else if (sTmp.equals(sJavaScript)) + { + eType = JAVASCRIPT; + bTypeOK = sal_True; + } + // else: unknown script type + } + else if (aValue.Name.equals(sMacroName)) + { + aValue.Value >>= sMacroVal; + } + else if (aValue.Name.equals(sLibrary)) + { + aValue.Value >>= sLibVal; + } + else if (aValue.Name.equals(sScript)) + { + aValue.Value >>= sScriptVal; + } + // else: unknown PropertyValue -> ignore + } + + SvxMacroItem aItem(ITEMID_MACRO); + aItem.SetMacroTable(getMacroItem().GetMacroTable()); + if (bTypeOK) + { + if (eType == STARBASIC) + { + SvxMacro aMacro(sMacroVal, sLibVal, eType); + aItem.SetMacro(nMacroID, aMacro); + } + else + { + // TODO: JavaScript macros + } + } + else + { + // no valid type -> no valid macro -> delete if present + if (aItem.HasMacro(nMacroID)) + aItem.DelMacro(nMacroID); + } + setMacroItem(aItem); +} + +Any SwEventDescriptor::getByName( + const OUString& rName ) + throw(NoSuchElementException) +{ + USHORT nMacroID = getMacroID(rName); + + // error checking + if (0 == nMacroID) + throw new NoSuchElementException(); + + Any aAny; + const SvxMacroItem& rItem = getMacroItem(); + if (rItem.HasMacro(nMacroID)) + { + aAny = getAnyFromMacro(rItem.GetMacro(nMacroID)); + } + else + { + // create empty macro + String sEmpty; + SvxMacro aMacro(sEmpty, sEmpty); + aAny = getAnyFromMacro(aMacro); + } + + return aAny; +} + +Sequence<OUString> SwEventDescriptor::getElementNames() throw() +{ + // this implementation is somewhat slower than it needs to be, but + // I don't think it's worth the effort to speed it up... + + // 1) count the supported macro IDs + sal_Int16 nCount = 0; + for( ; aSupportedMacroItemIDs[nCount] != 0; nCount++) ; + + // 2) create and fill sequence + Sequence<OUString> aSequence(nCount); + for( sal_Int16 i = 0; i < nCount; i++) + { + aSequence[i] = mapEventIDToName( aSupportedMacroItemIDs[i] ); + } + + return aSequence; +} + +sal_Bool SwEventDescriptor::hasByName( + const OUString& rName ) + throw() +{ + USHORT nMacroID = getMacroID(rName); + return (nMacroID != 0); +} + +Type SwEventDescriptor::getElementType() throw() +{ + return ::getCppuType((Sequence<PropertyValue> *)0); +} + +sal_Bool SwEventDescriptor::hasElements() throw() +{ + // check if the first element of aSupportedMacroItemIDs is already + // the delimiter + return aSupportedMacroItemIDs[0] == 0; +} + +rtl::OUString SwEventDescriptor::getImplementationName(void) + throw(RuntimeException) +{ + OUString sName(RTL_CONSTASCII_USTRINGPARAM(sImplementationName)); + return sName; +} + +sal_Bool SwEventDescriptor::supportsService(const OUString& rServiceName) + throw( ) +{ + return rServiceName.equalsAsciiL(sServiceName, sizeof(sServiceName)-1); +} + +Sequence<OUString> SwEventDescriptor::getSupportedServiceNames(void) + throw() +{ + OUString sService(RTL_CONSTASCII_USTRINGPARAM(sServiceName)); + + Sequence<OUString> aSequence(1); + aSequence[0] = sService; + + return aSequence; +} + +USHORT SwEventDescriptor::mapNameToEventID(const OUString& rName) const +{ + for(sal_Int16 i = 0; aKnownEventNames[i] != NULL; i++) + { + if (0 == rName.compareToAscii(aKnownEventNames[i])) + { + return aKnownEventIDs[i]; + } + } + + // not found -> return zero + return 0; +} + +OUString SwEventDescriptor::mapEventIDToName(USHORT nPoolID) const +{ + for(sal_Int16 i = 0; aKnownEventIDs[i] != 0; i++) + { + if (nPoolID == aKnownEventIDs[i]) + { + return OUString::createFromAscii(aKnownEventNames[i]); + } + } + + // not found -> return empty string + OUString sEmpty; + return sEmpty; +} + +USHORT SwEventDescriptor::getMacroID(const OUString& rName) const +{ + USHORT nID = mapNameToEventID(rName); + if (nID != 0) + { + for (sal_Int16 i=0; aSupportedMacroItemIDs[i] != 0; i++) + { + if (aSupportedMacroItemIDs[i] == nID) + { + // found! return nID + return nID; + } + } + } + + // not found -> return 0 + return 0; +} + +Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro) +{ + Any aRetValue; + + if (rMacro.HasMacro()) + { + enum ScriptType eType = rMacro.GetScriptType(); + switch (eType) + { + case STARBASIC: + { + // create sequence + Sequence<PropertyValue> aSequence(2); + Any aTmp; + + // create type + PropertyValue aTypeValue; + aTypeValue.Name = sEventType; + aTmp <<= sStarBasic; + aTypeValue.Value = aTmp; + aSequence[0] = aTypeValue; + + PropertyValue aStringValue; + aStringValue.Name = sMacroName; + OUStringBuffer sBuf; + sBuf.append(rMacro.GetLibName()); + sBuf.append(sal_Unicode('.')); + sBuf.append(rMacro.GetMacName()); + aTmp <<= sBuf.makeStringAndClear(); + aStringValue.Value = aTmp; + aSequence[1] = aStringValue; + + aRetValue <<= aSequence; + break; + } + + case JAVASCRIPT: + case EXTENDED_STYPE: + default: + DBG_ERROR("not implemented"); + break; + } + } + else + { + // create "None" macro + Sequence<PropertyValue> aSequence(1); + + PropertyValue aKindValue; + aKindValue.Name = sEventType; + Any aTmp; + aTmp <<= sNone; + aKindValue.Value = aTmp; + aSequence[0] = aKindValue; + + aRetValue <<= aSequence; + } + + return aRetValue; +} + + + +// +// SwFrameEventDescriptor +// + +// use double cast in superclass constructor to avoid ambigous cast +SwFrameEventDescriptor::SwFrameEventDescriptor( + SwXTextFrame& rFrameRef ) : + SwEventDescriptor((text::XTextFrame&)rFrameRef, aFrameEvents), + rFrame(rFrameRef) +{ +} + +SwFrameEventDescriptor::SwFrameEventDescriptor( + SwXTextGraphicObject& rGraphicRef ) : + SwEventDescriptor((text::XTextContent&)rGraphicRef, aGraphicEvents), + rFrame((SwXFrame&)rGraphicRef) +{ +} + +SwFrameEventDescriptor::SwFrameEventDescriptor( + SwXTextEmbeddedObject& rObjectRef ) : + SwEventDescriptor((text::XTextContent&)rObjectRef, aOLEEvents), + rFrame((SwXFrame&)rObjectRef) +{ +} + +SwFrameEventDescriptor::~SwFrameEventDescriptor() +{ +} + +void SwFrameEventDescriptor::setMacroItem(const SvxMacroItem& rItem) +{ + rFrame.GetFrmFmt()->SetAttr(rItem); +} + +const SvxMacroItem& SwFrameEventDescriptor::getMacroItem() +{ + return (const SvxMacroItem&)rFrame.GetFrmFmt()->GetAttr(ITEMID_MACRO); +} + + +// +// SwFrameStyleEventDescriptor +// + +SwFrameStyleEventDescriptor::SwFrameStyleEventDescriptor( + SwXFrameStyle& rStyleRef ) : + SwEventDescriptor((document::XEventSupplier&)rStyleRef, + aFrameStyleEvents), + rStyle(rStyleRef) +{ +} + +SwFrameStyleEventDescriptor::~SwFrameStyleEventDescriptor() +{ +} + +void SwFrameStyleEventDescriptor::setMacroItem(const SvxMacroItem& rItem) +{ + rStyle.GetBasePool()->Find(rStyle.GetStyleName())-> + GetItemSet().Put(rItem); +} + +const SvxMacroItem& SwFrameStyleEventDescriptor::getMacroItem() +{ + return (const SvxMacroItem&)rStyle.GetBasePool()-> + Find(rStyle.GetStyleName())->GetItemSet().Get(ITEMID_MACRO); + +// SfxStyleSheetBasePool* pBasePool = rStyle.GetBasePool(); +// if(pBasePool) +// { +// SfxStyleSheetBase* pBase = pBasePool->Find(sStyleName); +// if(pBase) +// { +// const SfxPoolItem& aItem = pBase->GetItemSet()->Get(ITEMID_MACRO); +// return (const SvxMacroItem&)aItem; +// } +// } +// // no macro item found? +// ??? +} diff --git a/sw/source/core/unocore/unoframe.cxx b/sw/source/core/unocore/unoframe.cxx index 6d666958cd33..d97e1b6812fd 100644 --- a/sw/source/core/unocore/unoframe.cxx +++ b/sw/source/core/unocore/unoframe.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unoframe.cxx,v $ * - * $Revision: 1.23 $ + * $Revision: 1.24 $ * - * last change: $Author: mib $ $Date: 2000-12-18 13:32:58 $ + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -113,6 +113,9 @@ #ifndef _UNOPRNMS_HXX #include <unoprnms.hxx> #endif +#ifndef _UNOEVENT_HXX +#include <unoevent.hxx> +#endif #ifndef _COM_SUN_STAR_TABLE_BORDERLINE_HPP_ #include <com/sun/star/table/BorderLine.hpp> #endif @@ -2026,6 +2029,7 @@ OUString SwXFrame::getShapeType(void) throw( RuntimeException ) return C2U("FrameShape"); } + /****************************************************************** * SwXTextFrame ******************************************************************/ @@ -2311,6 +2315,13 @@ void SAL_CALL SwXTextFrame::operator delete( void * p) throw() { SwXTextFrameBaseClass::operator delete(p); } + +uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents() + throw(RuntimeException) +{ + return new SwFrameEventDescriptor( *this ); +} + /****************************************************************** * SwXTextGraphicObject ******************************************************************/ @@ -2476,6 +2487,15 @@ void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw() { SwXTextGraphicObjectBaseClass::operator delete(p); } +/* -----------------------------15.12.00 12:45-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference<container::XNameReplace> SAL_CALL + SwXTextGraphicObject::getEvents() + throw(RuntimeException) +{ + return new SwFrameEventDescriptor( *this ); +} /****************************************************************** * @@ -2693,6 +2713,15 @@ void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw() { SwXTextEmbeddedObjectBaseClass::operator delete(p); } +/* -----------------------------15.12.00 12:45-------------------------------- + + ---------------------------------------------------------------------------*/ +uno::Reference<container::XNameReplace> SAL_CALL + SwXTextEmbeddedObject::getEvents() + throw(RuntimeException) +{ + return new SwFrameEventDescriptor( *this ); +} /****************************************************************** diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx index 6a79e95effa3..1d5dc6276c44 100644 --- a/sw/source/core/unocore/unostyle.cxx +++ b/sw/source/core/unocore/unostyle.cxx @@ -2,9 +2,9 @@ * * $RCSfile: unostyle.cxx,v $ * - * $Revision: 1.12 $ + * $Revision: 1.13 $ * - * last change: $Author: os $ $Date: 2000-11-15 15:00:48 $ + * last change: $Author: dvo $ $Date: 2000-12-19 17:28:55 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -179,6 +179,9 @@ #ifndef _POOLFMT_HXX #include <poolfmt.hxx> #endif +#ifndef _UNOEVENT_HXX +#include "unoevent.hxx" +#endif #ifndef _COM_SUN_STAR_STYLE_PARAGRAPHSTYLECATEGORY_HPP_ #include <com/sun/star/style/ParagraphStyleCategory.hpp> @@ -200,6 +203,8 @@ using namespace ::com::sun::star::lang; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::style; using namespace ::com::sun::star::beans; +using namespace ::com::sun::star::document; +using namespace ::com::sun::star::container; using namespace ::rtl; /****************************************************************************** * @@ -795,7 +800,9 @@ Any SwXStyleFamily::getByIndex(sal_Int32 nIndex) xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ? new SwXPageStyle(*pBasePool, pDocShell, eFamily, pBase->GetName()): - new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), pBase->GetName()); + eFamily == SFX_STYLE_FAMILY_FRAME ? + new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()): + new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), pBase->GetName()); } aRet.setValue(&xStyle, ::getCppuType((Reference<style::XStyle>*)0)); } @@ -828,8 +835,10 @@ Any SwXStyleFamily::getByName(const OUString& rName) if(!xStyle.is()) { xStyle = eFamily == SFX_STYLE_FAMILY_PAGE ? - new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) ://, _pPropMap) : - new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName);//, _pPropMap); + new SwXPageStyle(*pBasePool, pDocShell, eFamily, sStyleName) : + eFamily == SFX_STYLE_FAMILY_FRAME ? + new SwXFrameStyle(*pBasePool, pDocShell->GetDoc(), pBase->GetName()): + new SwXStyle(*pBasePool, eFamily, pDocShell->GetDoc(), sStyleName); } aRet.setValue(&xStyle, ::getCppuType((Reference<style::XStyle>*)0)); } @@ -2637,4 +2646,40 @@ const SwStartNode* SwXPageStyle::GetStartNode(sal_Bool bHeader, sal_Bool bLeft) } return pRet; } +/* -----------------------------15.12.00 15:45-------------------------------- + + ---------------------------------------------------------------------------*/ +SwXFrameStyle::~SwXFrameStyle() +{ +} +/* -----------------------------15.12.00 14:30-------------------------------- + + ---------------------------------------------------------------------------*/ +Sequence< uno::Type > SwXFrameStyle::getTypes( ) throw(RuntimeException) +{ + Sequence< uno::Type > aTypes = SwXStyle::getTypes(); + sal_Int32 nLen = aTypes.getLength(); + aTypes.realloc(nLen + 1); + aTypes.getArray()[nLen] = ::getCppuType((Reference<XEventSupplier>*)0); + return aTypes; +} +/* -----------------------------15.12.00 14:30-------------------------------- + + ---------------------------------------------------------------------------*/ +Any SwXFrameStyle::queryInterface( const uno::Type& rType ) throw(RuntimeException) +{ + Any aRet; + if(rType == ::getCppuType((Reference<XEventSupplier>*)0)) + aRet <<= Reference<XEventSupplier>(this); + else + aRet = SwXStyle::queryInterface(rType); + return aRet; +} +/* -----------------------------15.12.00 14:30-------------------------------- + + ---------------------------------------------------------------------------*/ +Reference< XNameReplace > SwXFrameStyle::getEvents( ) throw(RuntimeException) +{ + return new SwFrameStyleEventDescriptor( *this ); +} |