summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Vogelheim <dvo@openoffice.org>2001-01-02 13:29:24 +0000
committerDaniel Vogelheim <dvo@openoffice.org>2001-01-02 13:29:24 +0000
commit9fba2179673b58e6335dfc17618bb42595ce1b92 (patch)
treea20065f67fe893f263d9460d5d00aa2ad2c1604d
parent8218e11fc092b9f505ed9d083860655db52cfaed (diff)
- added: HyperLinkEvents property for Hyperlink-TextPortion/Cursor
-rw-r--r--sw/inc/unomid.h5
-rw-r--r--sw/inc/unoprnms.hxx5
-rw-r--r--sw/source/core/txtnode/fmtatr2.cxx98
-rw-r--r--sw/source/core/unocore/unoevent.cxx521
-rw-r--r--sw/source/core/unocore/unomap.cxx6
-rw-r--r--sw/source/core/unocore/unoprnms.cxx5
6 files changed, 477 insertions, 163 deletions
diff --git a/sw/inc/unomid.h b/sw/inc/unomid.h
index e348e5730534..c1f23c36e570 100644
--- a/sw/inc/unomid.h
+++ b/sw/inc/unomid.h
@@ -2,9 +2,9 @@
*
* $RCSfile: unomid.h,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: os $ $Date: 2000-11-08 12:19:40 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:21 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -94,6 +94,7 @@
#define MID_URL_TARGET 5
#define MID_URL_VISITED_FMT 6
#define MID_URL_UNVISITED_FMT 7
+#define MID_URL_HYPERLINKEVENTS 8
#define MID_CHAIN_PREVNAME 0
#define MID_CHAIN_NEXTNAME 1
diff --git a/sw/inc/unoprnms.hxx b/sw/inc/unoprnms.hxx
index a304eef616e9..e37465b03b7b 100644
--- a/sw/inc/unoprnms.hxx
+++ b/sw/inc/unoprnms.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoprnms.hxx,v $
*
- * $Revision: 1.28 $
+ * $Revision: 1.29 $
*
- * last change: $Author: os $ $Date: 2000-12-19 15:45:21 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:22 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -351,6 +351,7 @@ extern const SwPropNameLen __FAR_DATA UNO_NAME_HORI_ORIENT_POSITION
extern const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_U_R_L ;
extern const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_TARGET ;
extern const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_NAME ;
+extern const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_EVENTS;
extern const SwPropNameLen __FAR_DATA UNO_NAME_INFO_TYPE ;
extern const SwPropNameLen __FAR_DATA UNO_NAME_INFO_FORMAT ;
extern const SwPropNameLen __FAR_DATA UNO_NAME_IS_INPUT ;
diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx
index 6395ce0f33e8..17284a83d019 100644
--- a/sw/source/core/txtnode/fmtatr2.cxx
+++ b/sw/source/core/txtnode/fmtatr2.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: fmtatr2.cxx,v $
*
- * $Revision: 1.6 $
+ * $Revision: 1.7 $
*
- * last change: $Author: jp $ $Date: 2000-11-16 21:31:21 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:23 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -102,6 +102,9 @@
#ifndef _UNOSTYLE_HXX
#include <unostyle.hxx>
#endif
+#ifndef _UNOEVENT_HXX
+#include <unoevent.hxx> // SwHyperlinkEventDescriptor
+#endif
#ifndef _CMDID_H
#include <cmdid.h>
@@ -354,6 +357,19 @@ BOOL SwFmtINetFmt::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
sVal = SwXStyleFamilies::GetProgrammaticName( aINetFmt,
SFX_STYLE_FAMILY_CHAR );
break;
+ case MID_URL_HYPERLINKEVENTS:
+ {
+ // create (and return) event descriptor
+ SwHyperlinkEventDescriptor* pEvents =
+ new SwHyperlinkEventDescriptor();
+ pEvents->copyMacrosFromINetFmt(*this);
+ uno::Reference<container::XNameReplace> xNameReplace(pEvents);
+
+ // all others return a string; so we just set rVal here and exit
+ rVal <<= xNameReplace;
+ return bRet;
+ }
+ break;
default:
bRet = FALSE;
}
@@ -363,37 +379,63 @@ BOOL SwFmtINetFmt::QueryValue( uno::Any& rVal, BYTE nMemberId ) const
BOOL SwFmtINetFmt::PutValue( const uno::Any& rVal, BYTE nMemberId )
{
BOOL bRet = TRUE;
- if(rVal.getValueType() != ::getCppuType((rtl::OUString*)0))
- return FALSE;
- XubString sVal = *(rtl::OUString*)rVal.getValue();
- switch(nMemberId)
+
+ // all properties except HyperlinkEvents are of type string, hence
+ // we treat HyperlinkEvents specially
+ if (MID_URL_HYPERLINKEVENTS == nMemberId)
{
- case MID_URL_URL:
- aURL = sVal;
- break;
- case MID_URL_TARGET:
- aTargetFrame = sVal;
- break;
- case MID_URL_HYPERLINKNAME:
- aName = sVal;
- break;
- case MID_URL_VISITED_FMT:
+ uno::Reference<container::XNameReplace> xReplace;
+ rVal >>= xReplace;
+ if (xReplace.is())
{
- aVisitedFmt = SwXStyleFamilies::GetUIName( sVal,
- SFX_STYLE_FAMILY_CHAR );
- nVisitedId = SwDoc::GetPoolId( aVisitedFmt, GET_POOLID_CHRFMT );
-
+ // Create hyperlink event descriptor. Then copy events
+ // from argument into descriptor. Then copy events from
+ // the descriptor into the format.
+ SwHyperlinkEventDescriptor aEvents;
+ aEvents.copyMacrosFromNameReplace(xReplace);
+ aEvents.copyMacrosIntoINetFmt(*this);
}
- break;
- case MID_URL_UNVISITED_FMT:
+ else
{
- aINetFmt = SwXStyleFamilies::GetUIName( sVal,
- SFX_STYLE_FAMILY_CHAR );
- nINetId = SwDoc::GetPoolId( aINetFmt, GET_POOLID_CHRFMT );
- }
- break;
- default:
+ // wrong type!
bRet = FALSE;
+ }
+ }
+ else
+ {
+ // all string properties:
+ if(rVal.getValueType() != ::getCppuType((rtl::OUString*)0))
+ return FALSE;
+ XubString sVal = *(rtl::OUString*)rVal.getValue();
+ switch(nMemberId)
+ {
+ case MID_URL_URL:
+ aURL = sVal;
+ break;
+ case MID_URL_TARGET:
+ aTargetFrame = sVal;
+ break;
+ case MID_URL_HYPERLINKNAME:
+ aName = sVal;
+ break;
+ case MID_URL_VISITED_FMT:
+ {
+ aVisitedFmt = SwXStyleFamilies::GetUIName(
+ sVal, SFX_STYLE_FAMILY_CHAR );
+ nVisitedId = SwDoc::GetPoolId( aVisitedFmt,
+ GET_POOLID_CHRFMT );
+ }
+ break;
+ case MID_URL_UNVISITED_FMT:
+ {
+ aINetFmt = SwXStyleFamilies::GetUIName(
+ sVal, SFX_STYLE_FAMILY_CHAR );
+ nINetId = SwDoc::GetPoolId( aINetFmt, GET_POOLID_CHRFMT );
+ }
+ break;
+ default:
+ bRet = FALSE;
+ }
}
return bRet;
}
diff --git a/sw/source/core/unocore/unoevent.cxx b/sw/source/core/unocore/unoevent.cxx
index 836a7bc55c3e..15b518977857 100644
--- a/sw/source/core/unocore/unoevent.cxx
+++ b/sw/source/core/unocore/unoevent.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoevent.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: os $ $Date: 2000-12-22 09:52:39 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -91,7 +91,11 @@
#endif
#ifndef _SFX_HRC
-#include "sfx2/sfx.hrc"
+#include <sfx2/sfx.hrc>
+#endif
+
+#ifndef _FMTINFMT_HXX
+#include "fmtinfmt.hxx"
#endif
#ifndef _SFXMACITEM_HXX
@@ -120,9 +124,13 @@ using ::rtl::OUString;
using ::rtl::OUStringBuffer;
-const sal_Char sServiceName[] = "com.sun.star.container.XNameReplace";
-const sal_Char sImplementationName[] = "SwEventDescriptor";
-
+const sal_Char sAPI_ServiceName[] = "com.sun.star.container.XNameReplace";
+const sal_Char sAPI_SwFrameEventDescriptor[] = "SwFrameEventDescriptor";
+const sal_Char sAPI_SwFrameStyleEventDescriptor[] =
+ "SwFrameStyleEventDescriptor";
+const sal_Char sAPI_SwDetachedEventDescriptor[] = "SwDetachedEventDescriptor";
+const sal_Char sAPI_SwHyperlinkEventDescriptor[] =
+ "SwHyperlinkEventDescriptor";
//
// tables of all known events handled by this class
@@ -311,10 +319,15 @@ const USHORT aTest[] =
};
-SwEventDescriptor::SwEventDescriptor(
- XInterface& rParent,
+
+
+//
+// SwEventDescriptor
+//
+
+SwBaseEventDescriptor::SwBaseEventDescriptor(
const USHORT* aSupportedEvents) :
- xParentRef(&rParent),
+ sServiceName(RTL_CONSTASCII_USTRINGPARAM(sAPI_ServiceName)),
aSupportedMacroItemIDs(aSupportedEvents),
sEventType(RTL_CONSTASCII_USTRINGPARAM("EventType")),
sMacroName(RTL_CONSTASCII_USTRINGPARAM("MacroName")),
@@ -322,23 +335,26 @@ SwEventDescriptor::SwEventDescriptor(
sStarBasic(RTL_CONSTASCII_USTRINGPARAM("StarBasic")),
sJavaScript(RTL_CONSTASCII_USTRINGPARAM("JavaScript")),
sScript(RTL_CONSTASCII_USTRINGPARAM("Script")),
- sNone(RTL_CONSTASCII_USTRINGPARAM("None"))
+ sNone(RTL_CONSTASCII_USTRINGPARAM("None")),
+ sEmpty(),
+ aEmptyMacro(sEmpty, sEmpty)
{
DBG_ASSERT(aSupportedEvents != NULL, "Need a list of supported events!");
}
-SwEventDescriptor::~SwEventDescriptor()
+SwBaseEventDescriptor::~SwBaseEventDescriptor()
{
- // automatically release xParentRef !
}
-void SwEventDescriptor::replaceByName(
+void SwBaseEventDescriptor::replaceByName(
const OUString& rName,
const Any& rElement )
throw(
IllegalArgumentException,
- NoSuchElementException)
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
{
USHORT nMacroID = getMacroID(rName);
@@ -352,71 +368,11 @@ void SwEventDescriptor::replaceByName(
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(RES_FRMMACRO);
- 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);
+ // perform replace (in subclass)
+ replaceByName(nMacroID, getMacroFromAny(rElement));
}
-Any SwEventDescriptor::getByName(
+Any SwBaseEventDescriptor::getByName(
const OUString& rName )
throw(NoSuchElementException)
{
@@ -426,24 +382,11 @@ Any SwEventDescriptor::getByName(
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;
+ // perform get (in subclass)
+ return getAnyFromMacro(getByName(nMacroID));
}
-Sequence<OUString> SwEventDescriptor::getElementNames() throw()
+Sequence<OUString> SwBaseEventDescriptor::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...
@@ -462,7 +405,7 @@ Sequence<OUString> SwEventDescriptor::getElementNames() throw()
return aSequence;
}
-sal_Bool SwEventDescriptor::hasByName(
+sal_Bool SwBaseEventDescriptor::hasByName(
const OUString& rName )
throw()
{
@@ -470,44 +413,36 @@ sal_Bool SwEventDescriptor::hasByName(
return (nMacroID != 0);
}
-Type SwEventDescriptor::getElementType() throw()
+Type SwBaseEventDescriptor::getElementType() throw()
{
return ::getCppuType((Sequence<PropertyValue> *)0);
}
-sal_Bool SwEventDescriptor::hasElements() throw()
+sal_Bool SwBaseEventDescriptor::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)
+sal_Bool SwBaseEventDescriptor::supportsService(const OUString& rServiceName)
throw( )
{
- return rServiceName.equalsAsciiL(sServiceName, sizeof(sServiceName)-1);
+ return sServiceName.equals(rServiceName);
}
-Sequence<OUString> SwEventDescriptor::getSupportedServiceNames(void)
+Sequence<OUString> SwBaseEventDescriptor::getSupportedServiceNames(void)
throw()
{
- OUString sService(RTL_CONSTASCII_USTRINGPARAM(sServiceName));
-
Sequence<OUString> aSequence(1);
- aSequence[0] = sService;
+ aSequence[0] = sServiceName;
return aSequence;
}
-USHORT SwEventDescriptor::mapNameToEventID(const OUString& rName) const
+USHORT SwBaseEventDescriptor::mapNameToEventID(const OUString& rName) const
{
+ // iterate over known event names
for(sal_Int16 i = 0; aKnownEventNames[i] != NULL; i++)
{
if (0 == rName.compareToAscii(aKnownEventNames[i]))
@@ -520,8 +455,9 @@ USHORT SwEventDescriptor::mapNameToEventID(const OUString& rName) const
return 0;
}
-OUString SwEventDescriptor::mapEventIDToName(USHORT nPoolID) const
+OUString SwBaseEventDescriptor::mapEventIDToName(USHORT nPoolID) const
{
+ // iterate over known event IDs
for(sal_Int16 i = 0; aKnownEventIDs[i] != 0; i++)
{
if (nPoolID == aKnownEventIDs[i])
@@ -535,7 +471,7 @@ OUString SwEventDescriptor::mapEventIDToName(USHORT nPoolID) const
return sEmpty;
}
-USHORT SwEventDescriptor::getMacroID(const OUString& rName) const
+USHORT SwBaseEventDescriptor::getMacroID(const OUString& rName) const
{
USHORT nID = mapNameToEventID(rName);
if (nID != 0)
@@ -554,19 +490,19 @@ USHORT SwEventDescriptor::getMacroID(const OUString& rName) const
return 0;
}
-Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
+Any SwBaseEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
{
Any aRetValue;
+ sal_Bool bRetValueOK = sal_False; // do we have a ret value?
if (rMacro.HasMacro())
{
- enum ScriptType eType = rMacro.GetScriptType();
- switch (eType)
+ switch (rMacro.GetScriptType())
{
case STARBASIC:
{
// create sequence
- Sequence<PropertyValue> aSequence(2);
+ Sequence<PropertyValue> aSequence(3);
Any aTmp;
// create type
@@ -576,17 +512,24 @@ Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
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;
+ // macro name
+ PropertyValue aNameValue;
+ aNameValue.Name = sMacroName;
+ OUString sNameTmp(rMacro.GetMacName());
+ aTmp <<= sNameTmp;
+ aNameValue.Value = aTmp;
+ aSequence[1] = aNameValue;
+
+ // library name
+ PropertyValue aLibValue;
+ aLibValue.Name = sLibrary;
+ OUString sLibTmp(rMacro.GetLibName());
+ aTmp <<= sLibTmp;
+ aLibValue.Value = aTmp;
+ aSequence[2] = aLibValue;
aRetValue <<= aSequence;
+ bRetValueOK = sal_True;
break;
}
@@ -594,10 +537,12 @@ Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
case EXTENDED_STYPE:
default:
DBG_ERROR("not implemented");
- break;
}
}
- else
+ // else: bRetValueOK not set
+
+ // if we don't have a return value, make an empty one
+ if (! bRetValueOK)
{
// create "None" macro
Sequence<PropertyValue> aSequence(1);
@@ -610,12 +555,318 @@ Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
aSequence[0] = aKindValue;
aRetValue <<= aSequence;
+ bRetValueOK = sal_True;
}
return aRetValue;
}
+const SvxMacro SwBaseEventDescriptor::getMacroFromAny(
+ const Any& rAny)
+ throw ( IllegalArgumentException )
+{
+ // get sequence
+ Sequence<PropertyValue> aSequence;
+ rAny >>= aSequence;
+
+ // process ...
+ sal_Bool bTypeOK = sal_False;
+ sal_Bool bNone = sal_False; // true if EventType=="None"
+ 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 if (sTmp.equals(sNone))
+ {
+ bNone = sal_True;
+ 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
+ }
+
+ if (bTypeOK)
+ {
+ if (bNone)
+ {
+ // create empty macro
+ OUString sEmpty;
+ SvxMacro aMacro(sEmpty, sEmpty, STARBASIC);
+ return aMacro;
+ }
+ else
+ {
+ if (eType == STARBASIC)
+ {
+ // create macro and return
+ SvxMacro aMacro(sMacroVal, sLibVal, eType);
+ return aMacro;
+ }
+ else
+ {
+ // we can't process type: abort
+ // TODO: JavaScript macros
+ throw new IllegalArgumentException();
+ }
+ }
+ }
+ else
+ {
+ // no valid type: abort
+ throw new IllegalArgumentException();
+ }
+}
+
+
+
+
+//
+// SwEventDescriptor
+//
+
+
+SwEventDescriptor::SwEventDescriptor(
+ XInterface& rParent,
+ const USHORT* aSupportedEvents) :
+ SwBaseEventDescriptor(aSupportedEvents),
+ xParentRef(&rParent)
+{
+}
+
+
+SwEventDescriptor::~SwEventDescriptor()
+{
+ // automatically release xParentRef !
+}
+
+void SwEventDescriptor::replaceByName(
+ const USHORT nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ IllegalArgumentException,
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ SvxMacroItem aItem(RES_FRMMACRO);
+ aItem.SetMacroTable(getMacroItem().GetMacroTable());
+ aItem.SetMacro(nEvent, rMacro);
+ setMacroItem(aItem);
+}
+
+const SvxMacro& SwEventDescriptor::getByName(
+ const USHORT nEvent )
+ throw(
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ const SvxMacroItem& rItem = getMacroItem();
+ if (rItem.HasMacro(nEvent))
+ {
+ return rItem.GetMacro(nEvent);
+ }
+ else
+ {
+ return aEmptyMacro;
+ }
+}
+
+
+
+
+//
+// SwDetachedEventDescriptor
+//
+
+SwDetachedEventDescriptor::SwDetachedEventDescriptor(
+ const USHORT* aMacroItems) :
+ SwBaseEventDescriptor(aMacroItems),
+ sImplName(RTL_CONSTASCII_USTRINGPARAM(sAPI_SwDetachedEventDescriptor))
+{
+ // allocate aMacros
+ sal_Int16 nCount = getIndex(0);
+ aMacros = new SvxMacro*[nCount];
+
+ // ... and initialize
+ for(sal_Int16 i = 0; i < nCount; i++)
+ {
+ aMacros[i] = NULL;
+ }
+}
+
+SwDetachedEventDescriptor::~SwDetachedEventDescriptor()
+{
+ // delete contents of aMacros
+ sal_Int16 nCount = getIndex(0);
+ for(sal_Int16 i = 0; i < nCount; i++)
+ {
+ if (NULL != aMacros[i])
+ delete aMacros[i];
+ }
+
+ delete aMacros;
+}
+
+sal_Int16 SwDetachedEventDescriptor::getIndex(const USHORT nID)
+{
+ // iterate over supported events
+ sal_Int16 nIndex = 0;
+ while ( (aSupportedMacroItemIDs[nIndex] != nID) &&
+ (aSupportedMacroItemIDs[nIndex] != 0) )
+ {
+ nIndex++;
+ }
+ return (aSupportedMacroItemIDs[nIndex] == nID) ? nIndex : -1;
+}
+
+
+OUString SwDetachedEventDescriptor::getImplementationName()
+ throw( ::com::sun::star::uno::RuntimeException )
+{
+ return sImplName;
+}
+
+
+void SwDetachedEventDescriptor::replaceByName(
+ const USHORT nEvent,
+ const SvxMacro& rMacro)
+ throw(
+ IllegalArgumentException,
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex)
+ throw new IllegalArgumentException();
+
+ aMacros[nIndex] = new SvxMacro(rMacro.GetMacName(), rMacro.GetLibName(),
+ rMacro.GetScriptType() );
+}
+
+
+const SvxMacro& SwDetachedEventDescriptor::getByName(
+ const USHORT nEvent )
+ throw(
+ NoSuchElementException,
+ WrappedTargetException,
+ RuntimeException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex)
+ throw new IllegalArgumentException();
+
+ return (NULL == aMacros[nIndex]) ? aEmptyMacro : (*aMacros[nIndex]);
+}
+
+const sal_Bool SwDetachedEventDescriptor::hasByName(
+ const USHORT nEvent ) /// item ID of event
+ throw(IllegalArgumentException)
+{
+ sal_Int16 nIndex = getIndex(nEvent);
+ if (-1 == nIndex)
+ throw new IllegalArgumentException();
+
+ return (NULL == aMacros[nIndex]) ? sal_False : aMacros[nIndex]->HasMacro();
+}
+
+
+//
+// SwHyperlinkEventDescriptor
+//
+
+SwHyperlinkEventDescriptor::SwHyperlinkEventDescriptor() :
+ SwDetachedEventDescriptor(aHyperlinkEvents),
+ sImplName(RTL_CONSTASCII_USTRINGPARAM(sAPI_SwHyperlinkEventDescriptor))
+{
+}
+
+SwHyperlinkEventDescriptor::~SwHyperlinkEventDescriptor()
+{
+}
+
+OUString SwHyperlinkEventDescriptor::getImplementationName(void)
+ throw( RuntimeException )
+{
+ return sImplName;
+}
+
+void SwHyperlinkEventDescriptor::copyMacrosFromINetFmt(
+ const SwFmtINetFmt& aFmt)
+{
+ for(sal_Int16 i = 0; aSupportedMacroItemIDs[i] != NULL; i++)
+ {
+ USHORT nEvent = aSupportedMacroItemIDs[i];
+ const SvxMacro* aMacro = aFmt.GetMacro(nEvent);
+ if (NULL != aMacro)
+ replaceByName(nEvent, *aMacro);
+ }
+}
+
+void SwHyperlinkEventDescriptor::copyMacrosIntoINetFmt(
+ SwFmtINetFmt& aFmt)
+{
+ for(sal_Int16 i = 0; aSupportedMacroItemIDs[i] != NULL; i++)
+ {
+ USHORT nEvent = aSupportedMacroItemIDs[i];
+ if (hasByName(nEvent))
+ aFmt.SetMacro(nEvent, getByName(nEvent));
+ }
+}
+
+
+void SwHyperlinkEventDescriptor::copyMacrosFromNameReplace(
+ ::com::sun::star::uno::Reference<
+ ::com::sun::star::container::XNameReplace> & xReplace)
+{
+ // iterate over all names (all names that *we* support)
+ Sequence<OUString> aNames = getElementNames();
+ sal_Int32 nCount = aNames.getLength();
+ for(sal_Int32 i = 0; i < nCount; i++)
+ {
+ // copy element for that name
+ const OUString& rName = aNames[i];
+ if (xReplace->hasByName(rName))
+ {
+ SwBaseEventDescriptor::replaceByName(rName,
+ xReplace->getByName(rName));
+ }
+ }
+}
+
//
// SwFrameEventDescriptor
@@ -625,6 +876,8 @@ Any SwEventDescriptor::getAnyFromMacro(const SvxMacro& rMacro)
SwFrameEventDescriptor::SwFrameEventDescriptor(
SwXTextFrame& rFrameRef ) :
SwEventDescriptor((text::XTextFrame&)rFrameRef, aFrameEvents),
+ sSwFrameEventDescriptor(RTL_CONSTASCII_USTRINGPARAM(
+ sAPI_SwFrameEventDescriptor)),
rFrame(rFrameRef)
{
}
@@ -657,6 +910,12 @@ const SvxMacroItem& SwFrameEventDescriptor::getMacroItem()
return (const SvxMacroItem&)rFrame.GetFrmFmt()->GetAttr(RES_FRMMACRO);
}
+OUString SwFrameEventDescriptor::getImplementationName()
+ throw( RuntimeException )
+{
+ return sSwFrameEventDescriptor;
+}
+
//
// SwFrameStyleEventDescriptor
@@ -666,6 +925,8 @@ SwFrameStyleEventDescriptor::SwFrameStyleEventDescriptor(
SwXFrameStyle& rStyleRef ) :
SwEventDescriptor((document::XEventSupplier&)rStyleRef,
aFrameStyleEvents),
+ sSwFrameStyleEventDescriptor(RTL_CONSTASCII_USTRINGPARAM(
+ sAPI_SwFrameStyleEventDescriptor)),
rStyle(rStyleRef)
{
}
@@ -714,3 +975,9 @@ const SvxMacroItem& SwFrameStyleEventDescriptor::getMacroItem()
else
return aEmptyMacroItem;
}
+
+OUString SwFrameStyleEventDescriptor::getImplementationName()
+ throw( RuntimeException )
+{
+ return sSwFrameStyleEventDescriptor;
+}
diff --git a/sw/source/core/unocore/unomap.cxx b/sw/source/core/unocore/unomap.cxx
index 20c07d48dd38..e581ea664854 100644
--- a/sw/source/core/unocore/unomap.cxx
+++ b/sw/source/core/unocore/unomap.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unomap.cxx,v $
*
- * $Revision: 1.36 $
+ * $Revision: 1.37 $
*
- * last change: $Author: os $ $Date: 2000-12-22 09:51:06 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -688,6 +688,8 @@ const SfxItemPropertyMap* SwUnoPropertyMapProvider::GetPropertyMap(sal_uInt16
{ SW_PROP_NAME(UNO_NAME_TABSTOPS), RES_PARATR_TABSTOP, new uno::Type(::getCppuType((uno::Sequence<style::TabStop>*)0)), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS},
#else
{ SW_PROP_NAME(UNO_NAME_TABSTOPS), RES_PARATR_TABSTOP, &::getCppuType((const uno::Sequence<style::TabStop>*)0), PropertyAttribute::MAYBEVOID, CONVERT_TWIPS},
+ { SW_PROP_NAME(UNO_NAME_HYPER_LINK_EVENTS ), RES_TXTATR_INETFMT, &::getCppuType((uno::Reference<container::XNameReplace>*)0), PropertyAttribute::MAYBEVOID, MID_URL_HYPERLINKEVENTS},
+
#endif
{0,0,0,0}
};
diff --git a/sw/source/core/unocore/unoprnms.cxx b/sw/source/core/unocore/unoprnms.cxx
index d711f5bf5c1b..0e5be8a8e951 100644
--- a/sw/source/core/unocore/unoprnms.cxx
+++ b/sw/source/core/unocore/unoprnms.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: unoprnms.cxx,v $
*
- * $Revision: 1.30 $
+ * $Revision: 1.31 $
*
- * last change: $Author: os $ $Date: 2000-12-19 15:50:31 $
+ * last change: $Author: dvo $ $Date: 2001-01-02 14:29:24 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -344,6 +344,7 @@ const SwPropNameLen __FAR_DATA UNO_NAME_HORI_ORIENT_POSITION
const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_U_R_L (MAP_CHAR_LEN("HyperLinkURL"));
const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_TARGET (MAP_CHAR_LEN("HyperLinkTarget"));
const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_NAME (MAP_CHAR_LEN("HyperLinkName"));
+const SwPropNameLen __FAR_DATA UNO_NAME_HYPER_LINK_EVENTS (MAP_CHAR_LEN("HyperLinkEvents"));
const SwPropNameLen __FAR_DATA UNO_NAME_INFO_TYPE (MAP_CHAR_LEN("InfoType"));
const SwPropNameLen __FAR_DATA UNO_NAME_INFO_FORMAT (MAP_CHAR_LEN("InfoFormat"));
const SwPropNameLen __FAR_DATA UNO_NAME_IS_INPUT (MAP_CHAR_LEN("Input"));