[Libreoffice-commits] .: 6 commits - sc/inc sc/qa sc/source

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Sat Dec 3 11:14:06 PST 2011


 sc/inc/undorangename.hxx              |    2 
 sc/qa/unit/ucalc.cxx                  |   14 +++--
 sc/source/filter/xml/xmlcelli.cxx     |   66 +++++++++++++++++++++++----
 sc/source/ui/inc/namedefdlg.hxx       |    6 ++
 sc/source/ui/inc/namedlg.hxx          |    7 ++
 sc/source/ui/inc/namemgrtable.hxx     |    1 
 sc/source/ui/inc/tabvwsh.hxx          |   12 ++++
 sc/source/ui/namedlg/namedefdlg.cxx   |   26 +++++++++-
 sc/source/ui/namedlg/namedlg.cxx      |   54 +++++++++++++++++-----
 sc/source/ui/namedlg/namemgrtable.cxx |   12 ++++
 sc/source/ui/undo/undorangename.cxx   |    2 
 sc/source/ui/view/tabvwsh4.cxx        |    3 -
 sc/source/ui/view/tabvwshc.cxx        |   83 +++++++++++++++++++++++++++++-----
 13 files changed, 245 insertions(+), 43 deletions(-)

New commits:
commit 3e3f729cd668aa241345166f1046a8f0dd9ac83b
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Dec 3 19:58:27 2011 +0100

    correctly select new entry after returning from Define Names

diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index bbbcab6..69bc102 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -83,6 +83,7 @@ public:
 
     void addEntry( const ScRangeNameLine& rLine );
     void DeleteSelectedEntries();
+    void SetEntry( const ScRangeNameLine& rLine );
 
     void GetCurrentLine(ScRangeNameLine& rLine);
     bool IsMultiSelection();
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 93456b5..a3a2714 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -364,7 +364,13 @@ bool ScNameDlg::AddPushed()
 void ScNameDlg::SetEntry(const rtl::OUString& rName, const rtl::OUString& rScope)
 {
     if (!rName.isEmpty())
+    {
         mbDataChanged = true;
+        ScRangeNameLine aLine;
+        aLine.aName = rName;
+        aLine.aScope = rScope;
+        mpRangeManagerTable->SetEntry(aLine);
+    }
 }
 
 void ScNameDlg::RemovePushed()
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 40bd5aa..99b1ea0 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -209,6 +209,18 @@ std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries()
     return aSelectedEntries;
 }
 
+void ScRangeManagerTable::SetEntry(const ScRangeNameLine& rLine)
+{
+    for (SvLBoxEntry* pEntry = First(); pEntry; pEntry = Next(pEntry))
+    {
+        if (rLine.aName == rtl::OUString(GetEntryText(pEntry, 0))
+                && rLine.aScope == rtl::OUString(GetEntryText(pEntry, 2)))
+        {
+            SetCurEntry(pEntry);
+        }
+    }
+}
+
 namespace {
 
 //ensure that the minimum column size is respected
commit 62ec7f9e824ed1c17f01beaf8f4cec3b76b3aae9
Author: Laurent Godard <lgodard.libre at laposte.net>
Date:   Fri Dec 2 12:28:40 2011 +0100

    cells creation : do not use uno calls at loading time

diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index e16a262..8fd3de4 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -1078,16 +1078,66 @@ void ScXMLTableRowCellContext::EndElement()
                         if (!bIsMatrix)
                         {
                             LockSolarMutex();
-                            ScCellObj* pCellObj =
-                                static_cast<ScCellObj*>(ScCellRangesBase::getImplementation(
-                                            xCell));
-                            if (pCellObj)
+
+                            ScAddress aScAddress;
+                            ScUnoConversion::FillScAddress( aScAddress, aCellPos );
+
+                            ScDocument* pDoc = rXMLImport.GetDocument();
+
+                            rtl::OUString aText = pOUFormula->first;
+                            rtl::OUString aFormulaNmsp = pOUFormula->second;
+
+                            ::boost::scoped_ptr<ScExternalRefManager::ApiGuard> pExtRefGuard;
+                            pExtRefGuard.reset(new ScExternalRefManager::ApiGuard(pDoc));
+
+                            ScBaseCell* pNewCell = NULL;
+
+                            if ( !aText.isEmpty() )
                             {
-                                pCellObj->SetFormulaWithGrammar( pOUFormula->first, pOUFormula->second, eGrammar);
-                                if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength())
-                                    pCellObj->SetFormulaResultString( *pOUTextValue);
+                                if ( aText[0] == '=' && aText.getLength() > 1 )
+                                {
+                                    // temporary formula string as string tokens
+                                    ScTokenArray* pCode = new ScTokenArray;
+                                    pCode->AddStringXML( aText );
+                                    if( (eGrammar == formula::FormulaGrammar::GRAM_EXTERNAL) && (aFormulaNmsp.getLength() > 0) )
+                                        pCode->AddStringXML( aFormulaNmsp );
+
+                                    pDoc->IncXMLImportedFormulaCount( aText.getLength() );
+                                    pNewCell = new ScFormulaCell( pDoc, aScAddress, pCode, eGrammar, MM_NONE );
+                                    delete pCode;
+                                }
+                                else if ( aText[0] == '\'' )
+                                {
+                                    //  for bEnglish, "'" at the beginning is always interpreted as text
+                                    //  marker and stripped
+                                    pNewCell = ScBaseCell::CreateTextCell( aText.copy( 1 ), pDoc );
+                                }
                                 else
-                                    pCellObj->SetFormulaResultDouble( fValue);
+                                {
+                                    SvNumberFormatter* pFormatter = pDoc->GetFormatTable();
+                                    sal_uInt32 nEnglish = pFormatter->GetStandardIndex(LANGUAGE_ENGLISH_US);
+                                    double fVal;
+                                    if ( pFormatter->IsNumberFormat( aText, nEnglish, fVal ) )
+                                    {
+                                        pNewCell = new ScValueCell( fVal );
+                                    }
+                                    else
+                                        pNewCell = ScBaseCell::CreateTextCell( aText, pDoc );
+                                    //  das (englische) Zahlformat wird nicht gesetzt
+                                    //! passendes lokales Format suchen und setzen???
+                                }
+
+                                if (pNewCell)
+                                    pDoc->PutCell( aScAddress, pNewCell );
+
+                                ScBaseCell* pCell = rXMLImport.GetDocument()->GetCell( aScAddress );
+                                if ( pCell && pCell->GetCellType() == CELLTYPE_FORMULA )
+                                {
+                                    if (bFormulaTextResult && pOUTextValue && pOUTextValue->getLength())
+                                        static_cast<ScFormulaCell*>(pCell)->SetHybridString( *pOUTextValue );
+                                    else
+                                        static_cast<ScFormulaCell*>(pCell)->SetHybridDouble( fValue );
+                                }
                             }
                         }
                         else
commit 3b0d01a8cb6f9230db400c92a59bf805bcd5bc05
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Dec 3 18:42:04 2011 +0100

    ManageNames: make the add button usable
    
    the concept is not perfect and the code looks ugly but we have no way at
    the moment to open two Refdialogs at the same time
    
    REVERT this hack as soon as this is possible!

diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index c08de89..ddccd37 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -75,6 +75,10 @@ private:
     const rtl::OUString maErrNameInUse;
     const rtl::OUString maStrInfoDefault;
 
+    //hack to call this dialog from Manage Names
+    rtl::OUString maName;
+    rtl::OUString maScope;
+
     std::map<rtl::OUString, ScRangeName*> maRangeMap;
 
     void CancelPushed();
@@ -106,6 +110,8 @@ public:
 
     virtual void    SetActive();
     virtual sal_Bool    Close();
+
+    void GetNewData( rtl::OUString& rName, rtl::OUString& rScope );
 };
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 90252c5..cd2af4c 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -94,6 +94,8 @@ private:
 
     bool mbNeedUpdate;
     bool mbDataChanged;
+    //ugly hack to call DefineNames from ManageNames
+    bool mbCloseWithoutUndo;
 
     typedef boost::ptr_map<rtl::OUString, ScRangeName> RangeNameContainer;
 
@@ -141,7 +143,7 @@ protected:
 public:
                     ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
                                ScViewData*      ptrViewData,
-                               const ScAddress& aCursorPos );
+                               const ScAddress& aCursorPos, boost::ptr_map<rtl::OUString, ScRangeName>* pRangeMap = NULL );
     virtual         ~ScNameDlg();
 
     virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc );
@@ -150,6 +152,9 @@ public:
     virtual void    SetActive();
     virtual sal_Bool    Close();
 
+    void GetRangeNames(boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap);
+    void SetEntry(const rtl::OUString& rName, const rtl::OUString& rScope);
+
 };
 
 
diff --git a/sc/source/ui/inc/tabvwsh.hxx b/sc/source/ui/inc/tabvwsh.hxx
index e03ab7a..791bbc3 100644
--- a/sc/source/ui/inc/tabvwsh.hxx
+++ b/sc/source/ui/inc/tabvwsh.hxx
@@ -40,6 +40,8 @@
 #include "shellids.hxx"
 #include "tabprotection.hxx" // for ScPasswordHash
 
+#include <boost/ptr_container/ptr_map.hpp>
+
 class FmFormShell;
 class SbxObject;
 class SdrOle2Obj;
@@ -66,6 +68,7 @@ class ScChartShell;
 class ScPageBreakShell;
 class ScDPObject;
 class ScNavigatorSettings;
+class ScRangeName;
 
 struct ScHeaderFieldData;
 
@@ -182,6 +185,12 @@ private:
     static const int        MASTERENUMCOMMANDS = 6;
     String                  aCurrShapeEnumCommand[ MASTERENUMCOMMANDS ];
 
+    // ugly hack for Add button in ScNameDlg
+    boost::ptr_map<rtl::OUString, ScRangeName> maRangeMap;
+    bool    mbInSwitch;
+    rtl::OUString   maName;
+    rtl::OUString   maScope;
+
 private:
     void    Construct( sal_uInt8 nForceDesignMode = SC_FORCEMODE_NONE );
 
@@ -416,6 +425,9 @@ public:
     bool    ExecuteRetypePassDlg(ScPasswordHash eDesiredHash);
 
     using ScTabView::ShowCursor;
+
+    // ugly hack to call Define Names from Manage Names
+    void    SwitchBetweenRefDialogs(SfxModelessDialog* pDialog);
 };
 
 //==================================================================
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 90473fd..b373a1b 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -37,6 +37,7 @@
 #include "rangenam.hxx"
 #include "reffact.hxx"
 #include "undorangename.hxx"
+#include "tabvwsh.hxx"
 
 // defines -------------------------------------------------------------------
 
@@ -121,7 +122,13 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
 
 void ScNameDefDlg::CancelPushed()
 {
-    Close();
+    if (mbUndo)
+        Close();
+    else
+    {
+        ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+        pViewSh->SwitchBetweenRefDialogs(this);
+    }
 }
 
 bool ScNameDefDlg::IsFormulaValid()
@@ -254,9 +261,16 @@ void ScNameDefDlg::AddPushed()
                     // call invalidates the stream
                     if (nTab != -1)
                         mpDoc->SetStreamValid(nTab, false);
+                    SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+                    Close();
+                }
+                else
+                {
+                    maName = aName;
+                    maScope = aScope;
+                    ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+                    pViewSh->SwitchBetweenRefDialogs(this);
                 }
-                SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
-                Close();
             }
             else
             {
@@ -269,6 +283,12 @@ void ScNameDefDlg::AddPushed()
     }
 }
 
+void ScNameDefDlg::GetNewData(rtl::OUString& rName, rtl::OUString& rScope)
+{
+    rName = maName;
+    rScope = maScope;
+}
+
 sal_Bool ScNameDefDlg::IsRefInputMode() const
 {
     return maEdRange.IsEnabled();
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 19eb169..93456b5 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -42,6 +42,7 @@
 #include "namedlg.hrc"
 #include "namedlg.hxx"
 #include "viewdata.hxx"
+#include "tabvwsh.hxx"
 
 #include "globalnames.hxx"
 
@@ -68,7 +69,7 @@
 
 ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
         ScViewData*       ptrViewData,
-        const ScAddress&  aCursorPos )
+        const ScAddress&  aCursorPos, boost::ptr_map<rtl::OUString, ScRangeName>* pRangeMap  )
 
 :   ScAnyRefDlg ( pB, pCW, pParent, RID_SCDLG_NAMES ),
     //
@@ -107,8 +108,24 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     mpDoc            ( ptrViewData->GetDocument() ),
     maCursorPos      ( aCursorPos ),
     mbNeedUpdate     ( true ),
-    mbDataChanged    ( false )
+    mbDataChanged    ( false ),
+    mbCloseWithoutUndo( false )
 {
+    if (!pRangeMap)
+    {
+        std::map<rtl::OUString, ScRangeName*> aRangeMap;
+        mpDoc->GetRangeNameMap(aRangeMap);
+        std::map<rtl::OUString, ScRangeName*>::iterator itr = aRangeMap.begin(), itrEnd = aRangeMap.end();
+        for (; itr != itrEnd; ++itr)
+        {
+            rtl::OUString aTemp(itr->first);
+            maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
+        }
+    }
+    else
+    {
+        maRangeMap.swap(*pRangeMap);
+    }
     Init();
     FreeResource();
 }
@@ -125,14 +142,7 @@ void ScNameDlg::Init()
     OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
 
     //init UI
-    std::map<rtl::OUString, ScRangeName*> aRangeMap;
-    mpDoc->GetRangeNameMap(aRangeMap);
-    std::map<rtl::OUString, ScRangeName*>::iterator itr = aRangeMap.begin(), itrEnd = aRangeMap.end();
-    for (; itr != itrEnd; ++itr)
-    {
-        rtl::OUString aTemp(itr->first);
-        maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
-    }
+
 
     mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap);
     mpRangeManagerTable->SetSelectHdl( LINK( this, ScNameDlg, SelectionChangedHdl_Impl ) );
@@ -178,7 +188,7 @@ void ScNameDlg::Init()
     CheckForEmptyTable();
 
     //TODO: fix the Add Button
-    maBtnAdd.Disable();
+    //maBtnAdd.Disable();
 }
 
 sal_Bool ScNameDlg::IsRefInputMode() const
@@ -207,7 +217,7 @@ void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 
 sal_Bool ScNameDlg::Close()
 {
-    if (mbDataChanged)
+    if (mbDataChanged && !mbCloseWithoutUndo)
     {
         ScDocFunc aFunc(*mpViewData->GetDocShell());
         aFunc.ModifyAllRangeNames(maRangeMap);
@@ -345,9 +355,18 @@ void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
 
 bool ScNameDlg::AddPushed()
 {
+    mbCloseWithoutUndo = true;
+    ScTabViewShell* pViewSh = ScTabViewShell::GetActiveViewShell();
+    pViewSh->SwitchBetweenRefDialogs(this);
     return false;
 }
 
+void ScNameDlg::SetEntry(const rtl::OUString& rName, const rtl::OUString& rScope)
+{
+    if (!rName.isEmpty())
+        mbDataChanged = true;
+}
+
 void ScNameDlg::RemovePushed()
 {
     std::vector<ScRangeNameLine> maEntries = mpRangeManagerTable->GetSelectedEntries();
@@ -511,6 +530,11 @@ void ScNameDlg::MorePushed()
     MoveWindow(maFlDiv, nPixel);
 }
 
+void ScNameDlg::GetRangeNames(boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap)
+{
+    maRangeMap.swap(rRangeMap);
+}
+
 IMPL_LINK( ScNameDlg, OkBtnHdl, void *, EMPTYARG )
 {
     Close();
diff --git a/sc/source/ui/view/tabvwsh4.cxx b/sc/source/ui/view/tabvwsh4.cxx
index 5dc459d..f8e2ab8 100644
--- a/sc/source/ui/view/tabvwsh4.cxx
+++ b/sc/source/ui/view/tabvwsh4.cxx
@@ -1495,7 +1495,8 @@ bool ScTabViewShell::KeyInput( const KeyEvent &rKeyEvent )
     pScSbxObject(NULL),         \
     bChartAreaValid(false),     \
     nCurRefDlgId(0),            \
-    pAccessibilityBroadcaster(NULL)
+    pAccessibilityBroadcaster(NULL), \
+    mbInSwitch(false)
 
 
 //------------------------------------------------------------------
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index e9a50ad..2430225 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -69,6 +69,7 @@
 #include "funcdesc.hxx"
 #include "dpobject.hxx"
 #include "markdata.hxx"
+#include "reffact.hxx"
 
 #include <iostream>
 
@@ -81,6 +82,37 @@ void ScTabViewShell::SetCurRefDlgId( sal_uInt16 nNew )
     nCurRefDlgId = nNew;
 }
 
+//ugly hack to call Define Name from Manage Names
+void ScTabViewShell::SwitchBetweenRefDialogs(SfxModelessDialog* pDialog)
+{
+   sal_uInt16 nSlotId = SC_MOD()->GetCurRefDlgId();
+   if (nSlotId == FID_DEFINE_NAME)
+   {
+        mbInSwitch = true;
+        static_cast<ScNameDlg*>(pDialog)->GetRangeNames(maRangeMap);
+        static_cast<ScNameDlg*>(pDialog)->Close();
+        sal_uInt16 nId  = ScNameDefDlgWrapper::GetChildWindowId();
+        SfxViewFrame* pViewFrm = GetViewFrame();
+        SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+        SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
+   }
+   else if( nSlotId == FID_ADD_NAME )
+   {
+        static_cast<ScNameDefDlg*>(pDialog)->GetNewData(maName, maScope);
+        static_cast<ScNameDlg*>(pDialog)->Close();
+        sal_uInt16 nId  = ScNameDlgWrapper::GetChildWindowId();
+        SfxViewFrame* pViewFrm = GetViewFrame();
+        SfxChildWindow* pWnd = pViewFrm->GetChildWindow( nId );
+
+        SC_MOD()->SetRefDialog( nId, pWnd ? false : sal_True );
+   }
+   else
+   {
+
+   }
+}
+
 SfxModelessDialog* ScTabViewShell::CreateRefDialog(
                         SfxBindings* pB, SfxChildWindow* pCW, SfxChildWinInfo* pInfo,
                         Window* pParent, sal_uInt16 nSlotId )
@@ -110,21 +142,50 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
     switch( nSlotId )
     {
         case FID_DEFINE_NAME:
-        pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
-                             ScAddress( GetViewData()->GetCurX(),
-                                        GetViewData()->GetCurY(),
-                                        GetViewData()->GetTabNo() ) );
+        {
+            if (!mbInSwitch)
+            {
+                pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
+                                     ScAddress( GetViewData()->GetCurX(),
+                                                GetViewData()->GetCurY(),
+                                                GetViewData()->GetTabNo() ) );
+            }
+            else
+            {
+                pResult = new ScNameDlg( pB, pCW, pParent, GetViewData(),
+                                     ScAddress( GetViewData()->GetCurX(),
+                                                GetViewData()->GetCurY(),
+                                                GetViewData()->GetTabNo() ), &maRangeMap);
+                static_cast<ScNameDlg*>(pResult)->SetEntry( maName, maScope);
+                mbInSwitch = false;
+            }
+        }
         break;
 
         case FID_ADD_NAME:
         {
-            std::cout << "tabvwsh" << std::endl;
-            std::map<rtl::OUString, ScRangeName*> aRangeMap;
-            pDoc->GetRangeNameMap(aRangeMap);
-            pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
-                            ScAddress( GetViewData()->GetCurX(),
-                                        GetViewData()->GetCurY(),
-                                        GetViewData()->GetTabNo() ), true );
+            if (!mbInSwitch)
+            {
+                std::map<rtl::OUString, ScRangeName*> aRangeMap;
+                pDoc->GetRangeNameMap(aRangeMap);
+                pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
+                                ScAddress( GetViewData()->GetCurX(),
+                                            GetViewData()->GetCurY(),
+                                            GetViewData()->GetTabNo() ), true );
+            }
+            else
+            {
+                std::map<rtl::OUString, ScRangeName*> aRangeMap;
+                for (boost::ptr_map<rtl::OUString, ScRangeName>::iterator itr = maRangeMap.begin();
+                        itr != maRangeMap.end(); ++itr)
+                {
+                    aRangeMap.insert(std::pair<rtl::OUString, ScRangeName*>(itr->first, itr->second));
+                }
+                pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
+                                ScAddress( GetViewData()->GetCurX(),
+                                            GetViewData()->GetCurY(),
+                                            GetViewData()->GetTabNo() ), false );
+            }
         }
         break;
 
commit c8fd64a7d909036c4b701d3aaee11b37f378bcce
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Sat Dec 3 18:40:35 2011 +0100

    ptr_map does not need a pointer as template argument
    
    I don't understand why c++ did not complain about it but it resulted in
    really strange crashs

diff --git a/sc/inc/undorangename.hxx b/sc/inc/undorangename.hxx
index df6ff23..8a252c2 100644
--- a/sc/inc/undorangename.hxx
+++ b/sc/inc/undorangename.hxx
@@ -54,7 +54,7 @@ public:
     virtual String GetComment() const;
 
 private:
-    void DoChange(const boost::ptr_map<rtl::OUString, ScRangeName*>& rNames);
+    void DoChange(const boost::ptr_map<rtl::OUString, ScRangeName>& rNames);
 
 private:
     boost::ptr_map<rtl::OUString, ScRangeName> maOldNames;
diff --git a/sc/source/ui/undo/undorangename.cxx b/sc/source/ui/undo/undorangename.cxx
index 7bc565a..9bf31b2 100644
--- a/sc/source/ui/undo/undorangename.cxx
+++ b/sc/source/ui/undo/undorangename.cxx
@@ -92,7 +92,7 @@ String ScUndoAllRangeNames::GetComment() const
     return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
 }
 
-void ScUndoAllRangeNames::DoChange(const boost::ptr_map<rtl::OUString, ScRangeName*>& rNames)
+void ScUndoAllRangeNames::DoChange(const boost::ptr_map<rtl::OUString, ScRangeName>& rNames)
 {
     ScDocument& rDoc = *pDocShell->GetDocument();
 
commit 377bc06165f4a5cad8f67d69e021c51cb2a64180
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 2 18:53:18 2011 +0100

    add test for removing sheets to testPostIt
    
    fixes also the problem that one sheet has not been deleted

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 0808c35..d6d9484 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2466,6 +2466,10 @@ void Test::testPostIts()
     CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
 
     m_pDoc->DeleteTab(0);
+    rAddr.IncTab(-1);
+    CPPUNIT_ASSERT_MESSAGE("note not there", m_pDoc->GetNote(rAddr) == pNote);
+
+    m_pDoc->DeleteTab(0);
 }
 
 void Test::testToggleRefFlag()
commit f131ccd53bd93495855d571ecbcf00aa79b4d9b3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Fri Dec 2 18:59:05 2011 +0100

    some String->rtl::OUString cleanup in ucalc

diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index 4ff4cd0..0808c35 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2694,11 +2694,11 @@ void Test::testCopyPaste()
     m_pDoc->CopyFromClip(aRange, aMarkData2, nFlags, NULL, pClipDoc);
 
     //check values after copying
-    String aString;
+    rtl::OUString aString;
     m_pDoc->GetValue(1,1,1, aValue);
     CPPUNIT_ASSERT_MESSAGE("copied formula should return 2", aValue == 2);
     m_pDoc->GetFormula(1,1,1, aString);
-    CPPUNIT_ASSERT_MESSAGE("formula string was not copied correctly", rtl::OUString(aString) == aFormulaString);
+    CPPUNIT_ASSERT_MESSAGE("formula string was not copied correctly", aString == aFormulaString);
     m_pDoc->GetValue(0,1,1, aValue);
     CPPUNIT_ASSERT_MESSAGE("copied value should be 1", aValue == 1);
 
@@ -2717,15 +2717,15 @@ void Test::testCopyPaste()
     m_pDoc->GetValue(1,1,1, aValue);
     CPPUNIT_ASSERT_MESSAGE("after undo formula should return nothing", aValue == 0);
     m_pDoc->GetString(2,1,1, aString);
-    CPPUNIT_ASSERT_MESSAGE("after undo string should be removed", rtl::OUString(aString) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")));
+    CPPUNIT_ASSERT_MESSAGE("after undo string should be removed", aString.equalsAscii(""));
 
     pUndo->Redo();
     m_pDoc->GetValue(1,1,1, aValue);
     CPPUNIT_ASSERT_MESSAGE("formula should return 2 after redo", aValue == 2);
     m_pDoc->GetString(2,1,1, aString);
-    CPPUNIT_ASSERT_MESSAGE("Cell Sheet2.C2 should contain: test", rtl::OUString(aString) == rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("test")));
+    CPPUNIT_ASSERT_MESSAGE("Cell Sheet2.C2 should contain: test", aString.equalsAscii("test"));
     m_pDoc->GetFormula(1,1,1, aString);
-    CPPUNIT_ASSERT_MESSAGE("Formula should be correct again", rtl::OUString(aString) == aFormulaString);
+    CPPUNIT_ASSERT_MESSAGE("Formula should be correct again", aString == aFormulaString);
 
     //clear all variables
     delete pClipDoc;


More information about the Libreoffice-commits mailing list