summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kyoshida@novell.com>2010-11-10 15:51:56 -0500
committerKohei Yoshida <kyoshida@novell.com>2010-11-18 10:15:17 -0500
commit5f35a43d8405ef3bff6b841ccdaf5a256f6f554a (patch)
tree5343e62b845429113d4f5879e748a79c2b3e758d /sc
parent1bd5254e971ded24daa8aed0c636be3450ee71b9 (diff)
Disable document modify and broadcasting of changes on range names.
We don't need to set document status modified & broadcast changes on every single addition of range names during document import. Doing so would make the document import painfully slow esp with docs with lots of range names defined. (n#634257) Note: this is a backport of the same fix from master. Please don't merge this back into master.
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/document.hxx1
-rw-r--r--sc/inc/nameuno.hxx56
-rw-r--r--sc/inc/unonames.hxx5
-rw-r--r--sc/source/core/data/documen9.cxx5
-rw-r--r--sc/source/filter/xml/xmlimprt.cxx171
-rw-r--r--sc/source/ui/app/inputwin.cxx4
-rw-r--r--sc/source/ui/docshell/docfunc.cxx17
-rw-r--r--sc/source/ui/docshell/docsh.cxx2
-rw-r--r--sc/source/ui/inc/docfunc.hxx4
-rw-r--r--sc/source/ui/namedlg/namedlg.cxx2
-rw-r--r--sc/source/ui/unoobj/nameuno.cxx68
11 files changed, 244 insertions, 91 deletions
diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 117ae0be99ca..3acdf3bfd383 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -1561,6 +1561,7 @@ public:
BOOL GetNoSetDirty() const { return bNoSetDirty; }
void SetInsertingFromOtherDoc( BOOL bVal ) { bInsertingFromOtherDoc = bVal; }
BOOL IsInsertingFromOtherDoc() const { return bInsertingFromOtherDoc; }
+ bool IsLoadingMedium() const;
void SetLoadingMedium( bool bVal );
void SetImportingXML( bool bVal );
bool IsImportingXML() const { return bImportingXML; }
diff --git a/sc/inc/nameuno.hxx b/sc/inc/nameuno.hxx
index 27d149b3d816..2583546e463e 100644
--- a/sc/inc/nameuno.hxx
+++ b/sc/inc/nameuno.hxx
@@ -52,7 +52,7 @@
class ScDocShell;
class ScRangeData;
class ScTokenArray;
-
+class ScNamedRangesObj;
class ScNamedRangeObj : public ::cppu::WeakImplHelper6<
::com::sun::star::sheet::XNamedRange,
@@ -64,6 +64,7 @@ class ScNamedRangeObj : public ::cppu::WeakImplHelper6<
public SfxListener
{
private:
+ ScNamedRangesObj* mpParent;
ScDocShell* pDocShell;
String aName;
@@ -75,7 +76,7 @@ private:
const formula::FormulaGrammar::Grammar eGrammar );
public:
- ScNamedRangeObj(ScDocShell* pDocSh, const String& rNm);
+ ScNamedRangeObj(ScNamedRangesObj* pParent, ScDocShell* pDocSh, const String& rNm);
virtual ~ScNamedRangeObj();
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
@@ -173,10 +174,11 @@ public:
};
-class ScNamedRangesObj : public ::cppu::WeakImplHelper5<
+class ScNamedRangesObj : public ::cppu::WeakImplHelper6<
::com::sun::star::sheet::XNamedRanges,
::com::sun::star::container::XEnumerationAccess,
::com::sun::star::container::XIndexAccess,
+ ::com::sun::star::beans::XPropertySet,
::com::sun::star::document::XActionLockable,
::com::sun::star::lang::XServiceInfo >,
public SfxListener
@@ -184,6 +186,11 @@ class ScNamedRangesObj : public ::cppu::WeakImplHelper5<
private:
ScDocShell* pDocShell;
+ // if true, adding new name or modifying existing one will set the
+ // document 'modified' and broadcast the change. We turn this off during
+ // import.
+ sal_Bool mbModifyAndBroadcast;
+
ScNamedRangeObj* GetObjectByIndex_Impl(sal_uInt16 nIndex);
ScNamedRangeObj* GetObjectByName_Impl(const ::rtl::OUString& aName);
@@ -200,6 +207,8 @@ public:
virtual void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
+ bool IsModifyAndBroadcast() const;
+
// XNamedRanges
virtual void SAL_CALL addNewByName( const ::rtl::OUString& aName, const ::rtl::OUString& aContent,
const ::com::sun::star::table::CellAddress& aPosition, sal_Int32 nType )
@@ -238,6 +247,47 @@ public:
throw(::com::sun::star::uno::RuntimeException);
virtual sal_Bool SAL_CALL hasElements() 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);
+
// XActionLockable
virtual sal_Bool SAL_CALL isActionLocked() throw(::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL addActionLock() throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/inc/unonames.hxx b/sc/inc/unonames.hxx
index 556c62416b62..2d828a1b6c6d 100644
--- a/sc/inc/unonames.hxx
+++ b/sc/inc/unonames.hxx
@@ -643,14 +643,15 @@
// Solver
#define SC_UNONAME_TIMEOUT "Timeout"
-
#define SC_UNO_SHAREDOC "IsDocumentShared"
// EventDescriptor
-
#define SC_UNO_EVENTTYPE "EventType"
#define SC_UNO_SCRIPT "Script"
+// Named ranges
+#define SC_UNO_MODIFY_BROADCAST "ModifyAndBroadcast"
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index 039103e189f0..528db06b79e0 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -675,6 +675,11 @@ void ScDocument::UpdateFontCharSet()
}
}
+bool ScDocument::IsLoadingMedium() const
+{
+ return bLoadingMedium;
+}
+
void ScDocument::SetLoadingMedium( bool bVal )
{
bLoadingMedium = bVal;
diff --git a/sc/source/filter/xml/xmlimprt.cxx b/sc/source/filter/xml/xmlimprt.cxx
index c1a984dbf080..b14b71f72540 100644
--- a/sc/source/filter/xml/xmlimprt.cxx
+++ b/sc/source/filter/xml/xmlimprt.cxx
@@ -93,6 +93,7 @@
#include <com/sun/star/sheet/XNamedRange.hpp>
#include <com/sun/star/sheet/XLabelRanges.hpp>
#include <com/sun/star/io/XSeekable.hpp>
+#include <com/sun/star/beans/XPropertySet.hpp>
#define SC_LOCALE "Locale"
#define SC_STANDARDFORMAT "StandardFormat"
@@ -106,9 +107,10 @@
using namespace com::sun::star;
using namespace ::xmloff::token;
using namespace ::formula;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::UNO_QUERY;
using ::rtl::OUString;
-
-using rtl::OUString;
+using ::rtl::OUStringBuffer;
OUString SAL_CALL ScXMLImport_getImplementationName() throw()
{
@@ -2742,89 +2744,126 @@ void ScXMLImport::SetLabelRanges()
}
}
+namespace {
+
+/**
+ * Used to switch off document modify and broadcast while populating named
+ * ranges during import.
+ */
+class NamedRangesSwitch
+{
+public:
+ NamedRangesSwitch(Reference<beans::XPropertySet>& xPropSet) :
+ mxPropSet(xPropSet), maPropName(RTL_CONSTASCII_USTRINGPARAM(SC_UNO_MODIFY_BROADCAST))
+ {
+ uno::Any any;
+ any <<= sal_False;
+ mxPropSet->setPropertyValue(maPropName, any);
+ }
+
+ ~NamedRangesSwitch()
+ {
+ uno::Any any;
+ any <<= sal_True;
+ mxPropSet->setPropertyValue(maPropName, any);
+ }
+
+private:
+ Reference<beans::XPropertySet>& mxPropSet;
+ OUString maPropName;
+};
+
+}
+
void ScXMLImport::SetNamedRanges()
{
- ScMyNamedExpressions* pNamedExpressions(GetNamedExpressions());
- if (pNamedExpressions)
+ ScMyNamedExpressions* pNamedExpressions = GetNamedExpressions();
+ if (!pNamedExpressions)
+ return;
+
+ uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), uno::UNO_QUERY);
+ if (!xPropertySet.is())
+ return;
+
+ uno::Reference <sheet::XNamedRanges> xNamedRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NAMEDRANGES))), uno::UNO_QUERY);
+ if (!xNamedRanges.is())
+ return;
+
+ Reference<beans::XPropertySet> xPropSet(xNamedRanges, UNO_QUERY);
+ if (!xPropSet.is())
+ return;
+
+ NamedRangesSwitch aSwitch(xPropSet);
+
+ ScMyNamedExpressions::iterator aItr(pNamedExpressions->begin());
+ ScMyNamedExpressions::const_iterator aEndItr(pNamedExpressions->end());
+ table::CellAddress aCellAddress;
+ rtl::OUString sTempContent(RTL_CONSTASCII_USTRINGPARAM("0"));
+ while (aItr != aEndItr)
{
- uno::Reference <beans::XPropertySet> xPropertySet (GetModel(), uno::UNO_QUERY);
- if (xPropertySet.is())
+ sal_Int32 nOffset(0);
+ if (ScRangeStringConverter::GetAddressFromString(
+ aCellAddress, (*aItr)->sBaseCellAddress, GetDocument(), FormulaGrammar::CONV_OOO, nOffset ))
{
- uno::Reference <sheet::XNamedRanges> xNamedRanges(xPropertySet->getPropertyValue(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(SC_NAMEDRANGES))), uno::UNO_QUERY);
- if (xNamedRanges.is())
+ try
+ {
+ xNamedRanges->addNewByName((*aItr)->sName, sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType));
+ }
+ catch( uno::RuntimeException& )
{
- ScMyNamedExpressions::iterator aItr(pNamedExpressions->begin());
- ScMyNamedExpressions::const_iterator aEndItr(pNamedExpressions->end());
- table::CellAddress aCellAddress;
- rtl::OUString sTempContent(RTL_CONSTASCII_USTRINGPARAM("0"));
- while (aItr != aEndItr)
+ DBG_ERROR("here are some Named Ranges with the same name");
+ uno::Reference < container::XIndexAccess > xIndex(xNamedRanges, uno::UNO_QUERY);
+ if (xIndex.is())
{
- sal_Int32 nOffset(0);
- if (ScRangeStringConverter::GetAddressFromString(
- aCellAddress, (*aItr)->sBaseCellAddress, GetDocument(), FormulaGrammar::CONV_OOO, nOffset ))
+ sal_Int32 nMax(xIndex->getCount());
+ sal_Bool bInserted(sal_False);
+ sal_Int32 nCount(1);
+ rtl::OUStringBuffer sName((*aItr)->sName);
+ sName.append(sal_Unicode('_'));
+ while (!bInserted && nCount <= nMax)
{
+ rtl::OUStringBuffer sTemp(sName);
+ sTemp.append(rtl::OUString::valueOf(nCount));
try
{
- xNamedRanges->addNewByName((*aItr)->sName, sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType));
+ xNamedRanges->addNewByName(sTemp.makeStringAndClear(), sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType));
+ bInserted = sal_True;
}
catch( uno::RuntimeException& )
{
- DBG_ERROR("here are some Named Ranges with the same name");
- uno::Reference < container::XIndexAccess > xIndex(xNamedRanges, uno::UNO_QUERY);
- if (xIndex.is())
- {
- sal_Int32 nMax(xIndex->getCount());
- sal_Bool bInserted(sal_False);
- sal_Int32 nCount(1);
- rtl::OUStringBuffer sName((*aItr)->sName);
- sName.append(sal_Unicode('_'));
- while (!bInserted && nCount <= nMax)
- {
- rtl::OUStringBuffer sTemp(sName);
- sTemp.append(rtl::OUString::valueOf(nCount));
- try
- {
- xNamedRanges->addNewByName(sTemp.makeStringAndClear(), sTempContent, aCellAddress, GetRangeType((*aItr)->sRangeType));
- bInserted = sal_True;
- }
- catch( uno::RuntimeException& )
- {
- ++nCount;
- }
- }
- }
+ ++nCount;
}
}
- ++aItr;
}
- aItr = pNamedExpressions->begin();
- while (aItr != aEndItr)
+ }
+ }
+ ++aItr;
+ }
+ aItr = pNamedExpressions->begin();
+ while (aItr != aEndItr)
+ {
+ sal_Int32 nOffset(0);
+ if (ScRangeStringConverter::GetAddressFromString(
+ aCellAddress, (*aItr)->sBaseCellAddress, GetDocument(), FormulaGrammar::CONV_OOO, nOffset ))
+ {
+ uno::Reference <sheet::XNamedRange> xNamedRange(xNamedRanges->getByName((*aItr)->sName), uno::UNO_QUERY);
+ if (xNamedRange.is())
+ {
+ LockSolarMutex();
+ ScNamedRangeObj* pNamedRangeObj = ScNamedRangeObj::getImplementation( xNamedRange);
+ if (pNamedRangeObj)
{
- sal_Int32 nOffset(0);
- if (ScRangeStringConverter::GetAddressFromString(
- aCellAddress, (*aItr)->sBaseCellAddress, GetDocument(), FormulaGrammar::CONV_OOO, nOffset ))
- {
- uno::Reference <sheet::XNamedRange> xNamedRange(xNamedRanges->getByName((*aItr)->sName), uno::UNO_QUERY);
- if (xNamedRange.is())
- {
- LockSolarMutex();
- ScNamedRangeObj* pNamedRangeObj = ScNamedRangeObj::getImplementation( xNamedRange);
- if (pNamedRangeObj)
- {
- sTempContent = (*aItr)->sContent;
- // Get rid of leading sheet dots in simple ranges.
- if (!(*aItr)->bIsExpression)
- ScXMLConverter::ParseFormula( sTempContent, false);
- pNamedRangeObj->SetContentWithGrammar( sTempContent, (*aItr)->eGrammar);
- }
- UnlockSolarMutex();
- }
- }
- delete *aItr;
- aItr = pNamedExpressions->erase(aItr);
+ sTempContent = (*aItr)->sContent;
+ // Get rid of leading sheet dots in simple ranges.
+ if (!(*aItr)->bIsExpression)
+ ScXMLConverter::ParseFormula( sTempContent, false);
+ pNamedRangeObj->SetContentWithGrammar( sTempContent, (*aItr)->eGrammar);
}
+ UnlockSolarMutex();
}
}
+ delete *aItr;
+ aItr = pNamedExpressions->erase(aItr);
}
}
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index e2c865e7d5b9..c49345f3672b 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -1502,7 +1502,7 @@ void ScPosWnd::FillFunctions()
SetText(aFirstName);
}
-void __EXPORT ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
+void ScPosWnd::Notify( SfxBroadcaster&, const SfxHint& rHint )
{
if ( !bFormulaMode )
{
@@ -1707,7 +1707,7 @@ void ScPosWnd::DoEnter()
if ( aNewRanges.Insert(pNew) )
{
ScDocFunc aFunc(*pDocShell);
- aFunc.ModifyRangeNames( aNewRanges, FALSE );
+ aFunc.ModifyRangeNames( aNewRanges );
pViewSh->UpdateInputHandler(TRUE);
}
else
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index d4cff7090706..a962c72913b9 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4506,12 +4506,12 @@ bool ScDocFunc::UnmergeCells( const ScCellMergeOption& rOption, BOOL bRecord, BO
//------------------------------------------------------------------------
-BOOL ScDocFunc::ModifyRangeNames( const ScRangeName& rNewRanges, BOOL bApi )
+bool ScDocFunc::ModifyRangeNames( const ScRangeName& rNewRanges )
{
- return SetNewRangeNames( new ScRangeName( rNewRanges ), bApi );
+ return SetNewRangeNames( new ScRangeName(rNewRanges) );
}
-BOOL ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, BOOL /* bApi */ ) // takes ownership of pNewRanges
+bool ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc ) // takes ownership of pNewRanges
{
ScDocShellModificator aModificator( rDocShell );
@@ -4539,10 +4539,13 @@ BOOL ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, BOOL /* bApi */ )
if ( bCompile )
pDoc->CompileNameFormula( FALSE ); // CompileFormulaString
- aModificator.SetDocumentModified();
- SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+ if (bModifyDoc)
+ {
+ aModificator.SetDocumentModified();
+ SFX_APP()->Broadcast( SfxSimpleHint(SC_HINT_AREAS_CHANGED) );
+ }
- return TRUE;
+ return true;
}
//------------------------------------------------------------------------
@@ -4691,7 +4694,7 @@ BOOL ScDocFunc::CreateNames( const ScRange& rRange, USHORT nFlags, BOOL bApi )
if ( bBottom && bRight )
CreateOneName( aNewRanges, nEndCol,nEndRow,nTab, nContX1,nContY1,nContX2,nContY2, bCancel, bApi );
- bDone = ModifyRangeNames( aNewRanges, bApi );
+ bDone = ModifyRangeNames( aNewRanges );
aModificator.SetDocumentModified();
SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 902a1994f3b4..a777de7888e2 100644
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -433,7 +433,7 @@ private:
BOOL ScDocShell::LoadXML( SfxMedium* pLoadMedium, const ::com::sun::star::uno::Reference< ::com::sun::star::embed::XStorage >& xStor )
{
- RTL_LOGFILE_CONTEXT_AUTHOR ( aLog, "sc", "sb99857", "ScDocShell::LoadXML" );
+ LoadMediumGuard aLoadGuard(&aDocument);
// MacroCallMode is no longer needed, state is kept in SfxObjectShell now
diff --git a/sc/source/ui/inc/docfunc.hxx b/sc/source/ui/inc/docfunc.hxx
index e36c521ee5b5..d360750f1bbb 100644
--- a/sc/source/ui/inc/docfunc.hxx
+++ b/sc/source/ui/inc/docfunc.hxx
@@ -180,8 +180,8 @@ public:
BOOL UnmergeCells( const ScRange& rRange, BOOL bRecord, BOOL bApi );
bool UnmergeCells( const ScCellMergeOption& rOption, BOOL bRecord, BOOL bApi );
- BOOL SetNewRangeNames( ScRangeName* pNewRanges, BOOL bApi ); // takes ownership of pNewRanges
- BOOL ModifyRangeNames( const ScRangeName& rNewRanges, BOOL bApi );
+ bool SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc = true ); // takes ownership of pNewRanges
+ bool ModifyRangeNames( const ScRangeName& rNewRanges );
BOOL CreateNames( const ScRange& rRange, USHORT nFlags, BOOL bApi );
BOOL InsertNameList( const ScAddress& rStartPos, BOOL bApi );
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 728fefae1443..f0eea3a665ed 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -389,7 +389,7 @@ IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
{
ScDocShell* pDocSh = pViewData->GetDocShell();
ScDocFunc aFunc(*pDocSh);
- aFunc.ModifyRangeNames( aLocalRangeName, FALSE );
+ aFunc.ModifyRangeNames( aLocalRangeName );
Close();
}
return 0;
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index 55f03a3bec4a..abc2eaef0514 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -39,6 +39,8 @@
#include <com/sun/star/beans/PropertyAttribute.hpp>
using namespace ::com::sun::star;
+using ::com::sun::star::uno::Reference;
+using ::com::sun::star::uno::Any;
#include "nameuno.hxx"
@@ -70,6 +72,16 @@ const SfxItemPropertyMapEntry* lcl_GetNamedRangeMap()
return aNamedRangeMap_Impl;
}
+const SfxItemPropertyMapEntry* lcl_GetNamedRangesMap()
+{
+ static SfxItemPropertyMapEntry aNamedRangesMap_Impl[] =
+ {
+ {MAP_CHAR_LEN(SC_UNO_MODIFY_BROADCAST), 0, &getBooleanCppuType(), 0, 0 },
+ {0,0,0,0,0,0}
+ };
+ return aNamedRangesMap_Impl;
+}
+
//------------------------------------------------------------------------
#define SCNAMEDRANGEOBJ_SERVICE "com.sun.star.sheet.NamedRange"
@@ -89,7 +101,8 @@ sal_Bool lcl_UserVisibleName( const ScRangeData* pData )
//------------------------------------------------------------------------
-ScNamedRangeObj::ScNamedRangeObj(ScDocShell* pDocSh, const String& rNm) :
+ScNamedRangeObj::ScNamedRangeObj(ScNamedRangesObj* pParent, ScDocShell* pDocSh, const String& rNm) :
+ mpParent(pParent),
pDocShell( pDocSh ),
aName( rNm )
{
@@ -174,7 +187,7 @@ void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* p
if ( pNewRanges->Insert(pNew) )
{
ScDocFunc aFunc(*pDocShell);
- aFunc.SetNewRangeNames( pNewRanges, sal_True );
+ aFunc.SetNewRangeNames( pNewRanges, mpParent->IsModifyAndBroadcast());
aName = aInsName; //! broadcast?
}
@@ -478,7 +491,8 @@ ScNamedRangeObj* ScNamedRangeObj::getImplementation( const uno::Reference<uno::X
//------------------------------------------------------------------------
ScNamedRangesObj::ScNamedRangesObj(ScDocShell* pDocSh) :
- pDocShell( pDocSh )
+ pDocShell( pDocSh ),
+ mbModifyAndBroadcast(true)
{
pDocShell->GetDocument()->AddUnoObject(*this);
}
@@ -500,6 +514,11 @@ void ScNamedRangesObj::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
}
+bool ScNamedRangesObj::IsModifyAndBroadcast() const
+{
+ return mbModifyAndBroadcast;
+}
+
// sheet::XNamedRanges
ScNamedRangeObj* ScNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
@@ -517,7 +536,7 @@ ScNamedRangeObj* ScNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
if (lcl_UserVisibleName(pData)) // interne weglassen
{
if ( nPos == nIndex )
- return new ScNamedRangeObj( pDocShell, pData->GetName() );
+ return new ScNamedRangeObj(this, pDocShell, pData->GetName());
++nPos;
}
}
@@ -529,7 +548,7 @@ ScNamedRangeObj* ScNamedRangesObj::GetObjectByIndex_Impl(sal_uInt16 nIndex)
ScNamedRangeObj* ScNamedRangesObj::GetObjectByName_Impl(const rtl::OUString& aName)
{
if ( pDocShell && hasByName(aName) )
- return new ScNamedRangeObj( pDocShell, String(aName) );
+ return new ScNamedRangeObj(this, pDocShell, String(aName));
return NULL;
}
@@ -563,7 +582,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
if ( pNewRanges->Insert(pNew) )
{
ScDocFunc aFunc(*pDocShell);
- aFunc.SetNewRangeNames( pNewRanges, sal_True );
+ aFunc.SetNewRangeNames(pNewRanges, mbModifyAndBroadcast);
bDone = TRUE;
}
else
@@ -623,7 +642,7 @@ void SAL_CALL ScNamedRangesObj::removeByName( const rtl::OUString& aName )
ScRangeName* pNewRanges = new ScRangeName(*pNames);
pNewRanges->AtFree(nPos);
ScDocFunc aFunc(*pDocShell);
- aFunc.SetNewRangeNames( pNewRanges, sal_True );
+ aFunc.SetNewRangeNames( pNewRanges, mbModifyAndBroadcast);
bDone = TRUE;
}
}
@@ -699,6 +718,41 @@ sal_Bool SAL_CALL ScNamedRangesObj::hasElements() throw(uno::RuntimeException)
return ( getCount() != 0 );
}
+Reference<beans::XPropertySetInfo> SAL_CALL ScNamedRangesObj::getPropertySetInfo()
+ throw(uno::RuntimeException)
+{
+ static Reference<beans::XPropertySetInfo> aRef(
+ new SfxItemPropertySetInfo(lcl_GetNamedRangesMap()));
+ return aRef;
+}
+
+void SAL_CALL ScNamedRangesObj::setPropertyValue(
+ const rtl::OUString& rPropertyName, const uno::Any& aValue )
+ throw(beans::UnknownPropertyException, beans::PropertyVetoException,
+ lang::IllegalArgumentException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ if (rPropertyName.equalsAscii(SC_UNO_MODIFY_BROADCAST))
+ {
+ aValue >>= mbModifyAndBroadcast;
+ }
+}
+
+Any SAL_CALL ScNamedRangesObj::getPropertyValue( const rtl::OUString& rPropertyName )
+ throw(beans::UnknownPropertyException, lang::WrappedTargetException,
+ uno::RuntimeException)
+{
+ Any aRet;
+ if (rPropertyName.equalsAscii(SC_UNO_MODIFY_BROADCAST))
+ {
+ aRet <<= mbModifyAndBroadcast;
+ }
+
+ return aRet;
+}
+
+SC_IMPL_DUMMY_PROPERTY_LISTENER( ScNamedRangesObj )
+
uno::Any SAL_CALL ScNamedRangesObj::getByName( const rtl::OUString& aName )
throw(container::NoSuchElementException,
lang::WrappedTargetException, uno::RuntimeException)