[Libreoffice-commits] .: Branch 'libreoffice-3-3' - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Thu Nov 18 07:17:42 PST 2010


 sc/inc/document.hxx               |    1 
 sc/inc/nameuno.hxx                |   56 +++++++++++-
 sc/inc/unonames.hxx               |    5 -
 sc/source/core/data/documen9.cxx  |    5 +
 sc/source/filter/xml/xmlimprt.cxx |  171 +++++++++++++++++++++++---------------
 sc/source/ui/app/inputwin.cxx     |    4 
 sc/source/ui/docshell/docfunc.cxx |   17 ++-
 sc/source/ui/docshell/docsh.cxx   |    2 
 sc/source/ui/inc/docfunc.hxx      |    4 
 sc/source/ui/namedlg/namedlg.cxx  |    2 
 sc/source/ui/unoobj/nameuno.cxx   |   68 +++++++++++++--
 11 files changed, 244 insertions(+), 91 deletions(-)

New commits:
commit 88fb06d76f75c2b907d3ed024dec53cf11a382e0
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Nov 10 15:51:56 2010 -0500

    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.

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index ddbb1e8..3dc346c 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 bc92f98..f691c9f 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 2b90cf0..473697e 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 af7e762..c036f4d 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 0c98142..5600150 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 fbc480f..ae77794 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 ac22335..be84aa5 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 1a2c424..671b261 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 030b2dc..422a716 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 4f1c0df..6130f1c 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 686cad9..d85f24f 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)


More information about the Libreoffice-commits mailing list