summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-03-10 17:15:46 +0100
committerVladimir Glazunov <vg@openoffice.org>2010-03-10 17:15:46 +0100
commit5f1c72ae4e8a5d32a30e2ad9f4b2d9ec29701a63 (patch)
treeca4d986a1cdf6ad132dacc62b160c67fdb1ebe89 /sc
parent0430258177b43f9586c654a532bbbf8f77faee5e (diff)
parentd795240234770c3c3a8ce14d4c722b660604d573 (diff)
CWS-TOOLING: integrate CWS datapilotapi
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/dapiuno.hxx19
-rw-r--r--sc/inc/dpsdbtab.hxx2
-rw-r--r--sc/inc/hints.hxx12
-rw-r--r--sc/inc/unonames.hxx9
-rw-r--r--sc/source/core/data/dpobject.cxx11
-rw-r--r--sc/source/core/data/dpoutput.cxx12
-rw-r--r--sc/source/core/tool/hints.cxx10
-rw-r--r--sc/source/filter/xml/xmldpimp.cxx2
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx6
-rw-r--r--sc/source/ui/undo/undodat.cxx7
-rw-r--r--sc/source/ui/unoobj/dapiuno.cxx247
11 files changed, 309 insertions, 28 deletions
diff --git a/sc/inc/dapiuno.hxx b/sc/inc/dapiuno.hxx
index ba695d8784bc..c9a5305a05ca 100644
--- a/sc/inc/dapiuno.hxx
+++ b/sc/inc/dapiuno.hxx
@@ -31,6 +31,8 @@
#include "global.hxx"
#include "dpobject.hxx"
#include "rangeutl.hxx" // ScArea
+#include "cellsuno.hxx" // for XModifyListenerArr_Impl
+
#include <svl/lstner.hxx>
#include <svl/itemprop.hxx>
@@ -39,6 +41,7 @@
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XEnumerationAccess.hpp>
#include <com/sun/star/container/XNameContainer.hpp>
+#include <com/sun/star/util/XModifyBroadcaster.hpp>
#include <com/sun/star/sheet/DataPilotFieldAutoShowInfo.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupInfo.hpp>
@@ -313,11 +316,15 @@ public:
// ============================================================================
class ScDataPilotTableObj : public ScDataPilotDescriptorBase,
- public com::sun::star::sheet::XDataPilotTable2
+ public com::sun::star::sheet::XDataPilotTable2,
+ public com::sun::star::util::XModifyBroadcaster
{
private:
SCTAB nTab;
String aName;
+ XModifyListenerArr_Impl aModifyListeners;
+
+ void Refreshed_Impl();
public:
ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, const String& rN);
@@ -329,6 +336,8 @@ public:
virtual void SAL_CALL acquire() throw();
virtual void SAL_CALL release() throw();
+ virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+
virtual ScDPObject* GetDPObject() const;
virtual void SetDPObject(ScDPObject* pDPObj);
@@ -361,6 +370,14 @@ public:
throw(::com::sun::star::lang::IllegalArgumentException,
::com::sun::star::uno::RuntimeException);
+ // XModifyBroadcaster
+ virtual void SAL_CALL addModifyListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XModifyListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL removeModifyListener( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::util::XModifyListener >& aListener )
+ throw (::com::sun::star::uno::RuntimeException);
+
// XTypeProvider (overloaded)
virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes()
throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/inc/dpsdbtab.hxx b/sc/inc/dpsdbtab.hxx
index 1f980bdec3bf..21e23e883da9 100644
--- a/sc/inc/dpsdbtab.hxx
+++ b/sc/inc/dpsdbtab.hxx
@@ -50,6 +50,8 @@ struct ScImportSourceDesc
USHORT nType; // enum DataImportMode
BOOL bNative;
+ ScImportSourceDesc() : nType(0), bNative(FALSE) {}
+
BOOL operator== ( const ScImportSourceDesc& rOther ) const
{ return aDBName == rOther.aDBName &&
aObject == rOther.aObject &&
diff --git a/sc/inc/hints.hxx b/sc/inc/hints.hxx
index 00791921527d..fca3d184a4a2 100644
--- a/sc/inc/hints.hxx
+++ b/sc/inc/hints.hxx
@@ -170,4 +170,16 @@ public:
const ScImportParam& GetImportParam() const { return aParam; }
};
+class ScDataPilotModifiedHint : public SfxHint
+{
+ String maName;
+
+public:
+ TYPEINFO();
+ ScDataPilotModifiedHint( const String& rName );
+ ~ScDataPilotModifiedHint();
+
+ const String& GetName() const { return maName; }
+};
+
#endif
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 84e5c4b11cb1..f5de35c9d033 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -574,6 +574,15 @@
#define SC_UNO_RPTEMPTY "RepeatIfEmpty"
#define SC_UNO_DRILLDOWN "DrillDownOnDoubleClick"
#define SC_UNO_SHOWFILT "ShowFilterButton"
+#define SC_UNO_IMPORTDESC "ImportDescriptor"
+#define SC_UNO_SOURCESERV "SourceServiceName"
+#define SC_UNO_SERVICEARG "ServiceArguments"
+
+// properties in data pilot descriptor ServiceArguments
+#define SC_UNO_SOURCENAME "SourceName"
+#define SC_UNO_OBJECTNAME "ObjectName"
+#define SC_UNO_USERNAME "UserName"
+#define SC_UNO_PASSWORD "Password"
// range selection
#define SC_UNONAME_INITVAL "InitialValue"
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 66ac3a4bedbb..7d1dd85c0a25 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -784,13 +784,10 @@ bool ScDPObject::IsDimNameInUse(const OUString& rName) const
if (!xPropSet.is())
continue;
- Any any = xPropSet->getPropertyValue(OUString::createFromAscii(SC_UNO_LAYOUTNAME));
- OUString aLayoutName;
- if (any >>= aLayoutName)
- {
- if (aLayoutName.equalsIgnoreAsciiCase(rName))
- return true;
- }
+ OUString aLayoutName = ScUnoHelpFunctions::GetStringProperty(
+ xPropSet, OUString::createFromAscii(SC_UNO_LAYOUTNAME), OUString());
+ if (aLayoutName.equalsIgnoreAsciiCase(rName))
+ return true;
}
return false;
}
diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx
index 7ecdc3d34702..401d9b396bc0 100644
--- a/sc/source/core/data/dpoutput.cxx
+++ b/sc/source/core/data/dpoutput.cxx
@@ -451,14 +451,12 @@ ScDPOutput::ScDPOutput( ScDocument* pD, const uno::Reference<sheet::XDimensionsS
if ( xLevNam.is() && xLevRes.is() )
{
String aName = xLevNam->getName();
- OUString aCaption = aName; // Caption equals the field name by default.
Reference<XPropertySet> xPropSet(xLevel, UNO_QUERY);
- if (xPropSet.is())
- {
- Any any = xPropSet->getPropertyValue(
- OUString::createFromAscii(SC_UNO_LAYOUTNAME));
- any >>= aCaption;
- }
+ // Caption equals the field name by default.
+ // #i108948# use ScUnoHelpFunctions::GetStringProperty, because
+ // LayoutName is new and may not be present in external implementation
+ OUString aCaption = ScUnoHelpFunctions::GetStringProperty( xPropSet,
+ OUString::createFromAscii(SC_UNO_LAYOUTNAME), aName );
bool bRowFieldHasMember = false;
switch ( eDimOrient )
diff --git a/sc/source/core/tool/hints.cxx b/sc/source/core/tool/hints.cxx
index e2bcb11fc573..b2a8266705c7 100644
--- a/sc/source/core/tool/hints.cxx
+++ b/sc/source/core/tool/hints.cxx
@@ -40,6 +40,7 @@ TYPEINIT1(ScPointerChangedHint, SfxHint);
TYPEINIT1(ScLinkRefreshedHint, SfxHint);
TYPEINIT1(ScAutoStyleHint, SfxHint);
TYPEINIT1(ScDBRangeRefreshedHint, SfxHint);
+TYPEINIT1(ScDataPilotModifiedHint, SfxHint);
// -----------------------------------------------------------------------
// ScPaintHint - Angabe, was neu gezeichnet werden muss
@@ -150,3 +151,12 @@ ScDBRangeRefreshedHint::~ScDBRangeRefreshedHint()
}
+ScDataPilotModifiedHint::ScDataPilotModifiedHint( const String& rName )
+ : maName(rName)
+{
+}
+ScDataPilotModifiedHint::~ScDataPilotModifiedHint()
+{
+}
+
+
diff --git a/sc/source/filter/xml/xmldpimp.cxx b/sc/source/filter/xml/xmldpimp.cxx
index 580dd2ee0791..01dae48f6d84 100644
--- a/sc/source/filter/xml/xmldpimp.cxx
+++ b/sc/source/filter/xml/xmldpimp.cxx
@@ -428,7 +428,7 @@ void ScXMLDataPilotTableContext::EndElement()
break;
case SERVICE :
{
- ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceObject, sServiceSourceName,
+ ScDPServiceDesc aServiceDesk(sServiceName, sServiceSourceName, sServiceSourceObject,
sServiceUsername, sServicePassword);
pDPObject->SetServiceData(aServiceDesk);
}
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 1633af000b51..2053cebc8ce5 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -56,6 +56,7 @@
#include "attrib.hxx"
#include "drwlayer.hxx"
#include "dpshttab.hxx"
+#include "hints.hxx"
// -----------------------------------------------------------------
@@ -1403,7 +1404,12 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
delete pUndoDPObj;
if (bDone)
+ {
+ // notify API objects
+ if (pDestObj)
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pDestObj->GetName() ) );
aModificator.SetDocumentModified();
+ }
if ( nErrId && !bApi )
rDocShell.ErrorMessage( nErrId );
diff --git a/sc/source/ui/undo/undodat.cxx b/sc/source/ui/undo/undodat.cxx
index 2ed65d5db6f5..d550d54f1aea 100644
--- a/sc/source/ui/undo/undodat.cxx
+++ b/sc/source/ui/undo/undodat.cxx
@@ -50,6 +50,7 @@
#include "olinefun.hxx"
#include "dpobject.hxx"
#include "attrib.hxx"
+#include "hints.hxx"
#include "sc.hrc"
// -----------------------------------------------------------------------
@@ -1902,6 +1903,12 @@ void __EXPORT ScUndoDataPilot::Undo()
//! set current sheet
}
+ if (pNewDPObject)
+ {
+ // notify API objects
+ pDoc->BroadcastUno( ScDataPilotModifiedHint( pNewDPObject->GetName() ) );
+ }
+
EndUndo();
}
diff --git a/sc/source/ui/unoobj/dapiuno.cxx b/sc/source/ui/unoobj/dapiuno.cxx
index a921d1e125f2..ab94be3052e0 100644
--- a/sc/source/ui/unoobj/dapiuno.cxx
+++ b/sc/source/ui/unoobj/dapiuno.cxx
@@ -43,15 +43,19 @@
#include "unoguard.hxx"
#include "dpobject.hxx"
#include "dpshttab.hxx"
+#include "dpsdbtab.hxx"
#include "dpsave.hxx"
#include "dbdocfun.hxx"
#include "unonames.hxx"
#include "dpgroup.hxx"
#include "dpdimsave.hxx"
+#include "hints.hxx"
+
#include <com/sun/star/sheet/XHierarchiesSupplier.hpp>
#include <com/sun/star/sheet/XLevelsSupplier.hpp>
#include <com/sun/star/sheet/XMembersSupplier.hpp>
#include <com/sun/star/beans/PropertyAttribute.hpp>
+#include <com/sun/star/sheet/DataImportMode.hpp>
#include <com/sun/star/sheet/DataPilotFieldGroupBy.hpp>
#include <com/sun/star/sheet/DataPilotFieldFilter.hpp>
#include <com/sun/star/sheet/DataPilotOutputRangeType.hpp>
@@ -105,9 +109,12 @@ const SfxItemPropertyMapEntry* lcl_GetDataPilotDescriptorBaseMap()
{MAP_CHAR_LEN(SC_UNO_COLGRAND), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_DRILLDOWN), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_IGNEMPROWS), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_IMPORTDESC), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_RPTEMPTY), 0, &getBooleanCppuType(), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_ROWGRAND), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SERVICEARG), 0, &getCppuType((uno::Sequence<beans::PropertyValue>*)0), 0, 0 },
{MAP_CHAR_LEN(SC_UNO_SHOWFILT), 0, &getBooleanCppuType(), 0, 0 },
+ {MAP_CHAR_LEN(SC_UNO_SOURCESERV), 0, &getCppuType((rtl::OUString*)0), 0, 0 },
{0,0,0,0,0,0}
};
return aDataPilotDescriptorBaseMap_Impl;
@@ -261,8 +268,7 @@ ScDPObject* lcl_GetDPObject( ScDocShell* pDocShell, SCTAB nTab, const String& rN
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() &&
- pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
pDPObj->GetName() == rName )
return pDPObj;
}
@@ -344,7 +350,7 @@ ScDataPilotTableObj* ScDataPilotTablesObj::GetObjectByIndex_Impl( sal_Int32 nInd
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
{
if ( nFound == nIndex )
{
@@ -496,7 +502,7 @@ sal_Int32 SAL_CALL ScDataPilotTablesObj::getCount() throw(RuntimeException)
for (USHORT i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
++nFound;
}
return nFound;
@@ -560,7 +566,7 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
for (i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
++nFound;
}
@@ -570,7 +576,7 @@ Sequence<OUString> SAL_CALL ScDataPilotTablesObj::getElementNames()
for (i=0; i<nCount; i++)
{
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() && pDPObj->GetOutRange().aStart.Tab() == nTab )
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab )
pAry[nPos++] = pDPObj->GetName();
}
@@ -598,8 +604,7 @@ sal_Bool SAL_CALL ScDataPilotTablesObj::hasByName( const OUString& aName )
//! allow all data sources!!!
ScDPObject* pDPObj = (*pColl)[i];
- if ( pDPObj->IsSheetData() &&
- pDPObj->GetOutRange().aStart.Tab() == nTab &&
+ if ( pDPObj->GetOutRange().aStart.Tab() == nTab &&
pDPObj->GetName() == aNamStr )
return TRUE;
}
@@ -696,11 +701,12 @@ CellRangeAddress SAL_CALL ScDataPilotDescriptorBase::getSourceRange()
ScUnoGuard aGuard;
ScDPObject* pDPObject(GetDPObject());
- if (!pDPObject || !pDPObject->IsSheetData())
+ if (!pDPObject)
throw RuntimeException();
CellRangeAddress aRet;
- ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
+ if (pDPObject->IsSheetData())
+ ScUnoConversion::FillApiRange( aRet, pDPObject->GetSheetDesc()->aSourceRange );
return aRet;
}
@@ -818,6 +824,99 @@ void SAL_CALL ScDataPilotDescriptorBase::setPropertyValue( const OUString& aProp
{
aNewData.SetDrillDown(::cppu::any2bool( aValue ));
}
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ ScImportSourceDesc aImportDesc;
+
+ const ScImportSourceDesc* pOldDesc = pDPObject->GetImportSourceDesc();
+ if (pOldDesc)
+ aImportDesc = *pOldDesc;
+
+ ScImportParam aParam;
+ ScImportDescriptor::FillImportParam( aParam, aArgSeq );
+
+ USHORT nNewType = sheet::DataImportMode_NONE;
+ if ( aParam.bImport )
+ {
+ if ( aParam.bSql )
+ nNewType = sheet::DataImportMode_SQL;
+ else if ( aParam.nType == ScDbQuery )
+ nNewType = sheet::DataImportMode_QUERY;
+ else
+ nNewType = sheet::DataImportMode_TABLE;
+ }
+ aImportDesc.nType = nNewType;
+ aImportDesc.aDBName = aParam.aDBName;
+ aImportDesc.aObject = aParam.aStatement;
+ aImportDesc.bNative = aParam.bNative;
+
+ pDPObject->SetImportDesc( aImportDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aStrVal;
+ if ( aValue >>= aStrVal )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ aServiceDesc.aServiceName = aStrVal;
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ uno::Sequence<beans::PropertyValue> aArgSeq;
+ if ( aValue >>= aArgSeq )
+ {
+ String aEmpty;
+ ScDPServiceDesc aServiceDesc(aEmpty, aEmpty, aEmpty, aEmpty, aEmpty);
+
+ const ScDPServiceDesc* pOldDesc = pDPObject->GetDPServiceDesc();
+ if (pOldDesc)
+ aServiceDesc = *pOldDesc;
+
+ rtl::OUString aStrVal;
+ sal_Int32 nArgs = aArgSeq.getLength();
+ for (sal_Int32 nArgPos=0; nArgPos<nArgs; ++nArgPos)
+ {
+ const beans::PropertyValue& rProp = aArgSeq[nArgPos];
+ String aPropName(rProp.Name);
+
+ if (aPropName.EqualsAscii( SC_UNO_SOURCENAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParSource = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_OBJECTNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParName = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_USERNAME ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParUser = aStrVal;
+ }
+ else if (aPropName.EqualsAscii( SC_UNO_PASSWORD ))
+ {
+ if ( rProp.Value >>= aStrVal )
+ aServiceDesc.aParPass = aStrVal;
+ }
+ }
+
+ pDPObject->SetServiceData( aServiceDesc );
+ }
+ }
else
throw UnknownPropertyException();
@@ -868,6 +967,63 @@ Any SAL_CALL ScDataPilotDescriptorBase::getPropertyValue( const OUString& aPrope
{
aRet = ::cppu::bool2any( aNewData.GetDrillDown() );
}
+ else if ( aNameString.EqualsAscii( SC_UNO_IMPORTDESC ) )
+ {
+ const ScImportSourceDesc* pImportDesc = pDPObject->GetImportSourceDesc();
+ if ( pImportDesc )
+ {
+ // fill ScImportParam so ScImportDescriptor::FillProperties can be used
+ ScImportParam aParam;
+ aParam.bImport = ( pImportDesc->nType != sheet::DataImportMode_NONE );
+ aParam.aDBName = pImportDesc->aDBName;
+ aParam.aStatement = pImportDesc->aObject;
+ aParam.bNative = pImportDesc->bNative;
+ aParam.bSql = ( pImportDesc->nType == sheet::DataImportMode_SQL );
+ aParam.nType = static_cast<BYTE>(( pImportDesc->nType == sheet::DataImportMode_QUERY ) ? ScDbQuery : ScDbTable);
+
+ uno::Sequence<beans::PropertyValue> aSeq( ScImportDescriptor::GetPropertyCount() );
+ ScImportDescriptor::FillProperties( aSeq, aParam );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SOURCESERV ) )
+ {
+ rtl::OUString aServiceName;
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ aServiceName = pServiceDesc->aServiceName;
+ aRet <<= aServiceName; // empty string if no ServiceDesc set
+ }
+ else if ( aNameString.EqualsAscii( SC_UNO_SERVICEARG ) )
+ {
+ const ScDPServiceDesc* pServiceDesc = pDPObject->GetDPServiceDesc();
+ if (pServiceDesc)
+ {
+ uno::Sequence<beans::PropertyValue> aSeq( 4 );
+ beans::PropertyValue* pArray = aSeq.getArray();
+ pArray[0].Name = rtl::OUString::createFromAscii( SC_UNO_SOURCENAME );
+ pArray[0].Value <<= rtl::OUString( pServiceDesc->aParSource );
+ pArray[1].Name = rtl::OUString::createFromAscii( SC_UNO_OBJECTNAME );
+ pArray[1].Value <<= rtl::OUString( pServiceDesc->aParName );
+ pArray[2].Name = rtl::OUString::createFromAscii( SC_UNO_USERNAME );
+ pArray[2].Value <<= rtl::OUString( pServiceDesc->aParUser );
+ pArray[3].Name = rtl::OUString::createFromAscii( SC_UNO_PASSWORD );
+ pArray[3].Value <<= rtl::OUString( pServiceDesc->aParPass );
+ aRet <<= aSeq;
+ }
+ else
+ {
+ // empty sequence
+ uno::Sequence<beans::PropertyValue> aEmpty(0);
+ aRet <<= aEmpty;
+ }
+ }
else
throw UnknownPropertyException();
}
@@ -966,7 +1122,8 @@ ScDataPilotDescriptorBase* ScDataPilotDescriptorBase::getImplementation(
ScDataPilotTableObj::ScDataPilotTableObj(ScDocShell* pDocSh, SCTAB nT, const String& rN) :
ScDataPilotDescriptorBase( pDocSh ),
nTab( nT ),
- aName( rN )
+ aName( rN ),
+ aModifyListeners( 0 )
{
}
@@ -981,6 +1138,7 @@ Any SAL_CALL ScDataPilotTableObj::queryInterface( const uno::Type& rType )
// we also need to do the same for XDataPilotTable
SC_QUERYINTERFACE( XDataPilotTable )
SC_QUERYINTERFACE( XDataPilotTable2 )
+ SC_QUERYINTERFACE( XModifyBroadcaster )
return ScDataPilotDescriptorBase::queryInterface( rType );
}
@@ -1004,12 +1162,13 @@ Sequence< uno::Type > SAL_CALL ScDataPilotTableObj::getTypes() throw(RuntimeExce
sal_Int32 nParentLen = aParentTypes.getLength();
const uno::Type* pParentPtr = aParentTypes.getConstArray();
- aTypes.realloc( nParentLen + 1 );
+ aTypes.realloc( nParentLen + 2 );
uno::Type* pPtr = aTypes.getArray();
for (sal_Int32 i = 0; i < nParentLen; ++i)
pPtr[ i ] = pParentPtr[ i ]; // parent types first
pPtr[ nParentLen ] = getCppuType( (const Reference< XDataPilotTable2 >*)0 );
+ pPtr[ nParentLen+1 ] = getCppuType( (const Reference< XModifyBroadcaster >*)0 );
}
return aTypes;
}
@@ -1183,6 +1342,70 @@ CellRangeAddress SAL_CALL ScDataPilotTableObj::getOutputRangeByType( sal_Int32 n
return aRet;
}
+void SAL_CALL ScDataPilotTableObj::addModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ uno::Reference<util::XModifyListener> *pObj = new uno::Reference<util::XModifyListener>( aListener );
+ aModifyListeners.Insert( pObj, aModifyListeners.Count() );
+
+ if ( aModifyListeners.Count() == 1 )
+ {
+ acquire(); // don't lose this object (one ref for all listeners)
+ }
+}
+
+void SAL_CALL ScDataPilotTableObj::removeModifyListener( const uno::Reference<util::XModifyListener>& aListener )
+ throw (uno::RuntimeException)
+{
+ ScUnoGuard aGuard;
+
+ acquire(); // in case the listeners have the last ref - released below
+
+ USHORT nCount = aModifyListeners.Count();
+ for ( USHORT n=nCount; n--; )
+ {
+ uno::Reference<util::XModifyListener> *pObj = aModifyListeners[n];
+ if ( *pObj == aListener )
+ {
+ aModifyListeners.DeleteAndDestroy( n );
+
+ if ( aModifyListeners.Count() == 0 )
+ {
+ release(); // release the ref for the listeners
+ }
+
+ break;
+ }
+ }
+
+ release(); // might delete this object
+}
+
+void ScDataPilotTableObj::Notify( SfxBroadcaster& rBC, const SfxHint& rHint )
+{
+ if ( rHint.ISA(ScDataPilotModifiedHint) &&
+ static_cast<const ScDataPilotModifiedHint&>(rHint).GetName() == aName )
+ {
+ Refreshed_Impl();
+ }
+
+ ScDataPilotDescriptorBase::Notify( rBC, rHint );
+}
+
+void ScDataPilotTableObj::Refreshed_Impl()
+{
+ lang::EventObject aEvent;
+ aEvent.Source.set((cppu::OWeakObject*)this);
+
+ // the EventObject holds a Ref to this object until after the listener calls
+
+ ScDocument* pDoc = GetDocShell()->GetDocument();
+ for ( USHORT n=0; n<aModifyListeners.Count(); n++ )
+ pDoc->AddUnoListenerCall( *aModifyListeners[n], aEvent );
+}
+
// ============================================================================
ScDataPilotDescriptor::ScDataPilotDescriptor(ScDocShell* pDocSh) :