[Libreoffice-commits] .: 32 commits - officecfg/registry sc/AllLangResTarget_sc.mk sc/inc sc/Library_sc.mk sc/Library_scui.mk sc/qa sc/sdi sc/source sc/uiconfig

Markus Mohrhard mmohrhard at kemper.freedesktop.org
Tue Nov 22 23:05:31 PST 2011


 officecfg/registry/data/org/openoffice/Office/UI/CalcCommands.xcu |    8 
 sc/AllLangResTarget_sc.mk                                         |    1 
 sc/Library_sc.mk                                                  |    2 
 sc/Library_scui.mk                                                |    2 
 sc/inc/document.hxx                                               |    4 
 sc/inc/globalnames.hxx                                            |    2 
 sc/inc/globstr.hrc                                                |    7 
 sc/inc/rangenam.hxx                                               |   10 
 sc/inc/sc.hrc                                                     |    2 
 sc/inc/scabstdlg.hxx                                              |    8 
 sc/inc/sccommands.h                                               |    1 
 sc/inc/undorangename.hxx                                          |   34 
 sc/qa/unit/filters-test.cxx                                       |    6 
 sc/qa/unit/ucalc.cxx                                              |    4 
 sc/sdi/cellsh.sdi                                                 |    1 
 sc/sdi/drawsh.sdi                                                 |    1 
 sc/sdi/drtxtob.sdi                                                |    1 
 sc/sdi/scalc.sdi                                                  |   25 
 sc/source/core/data/documen2.cxx                                  |    2 
 sc/source/core/data/documen3.cxx                                  |   40 
 sc/source/core/data/document.cxx                                  |    2 
 sc/source/core/tool/rangenam.cxx                                  |   25 
 sc/source/core/tool/rangeutl.cxx                                  |    9 
 sc/source/filter/html/htmlimp.cxx                                 |    4 
 sc/source/filter/rtf/eeimpars.cxx                                 |    2 
 sc/source/ui/app/inputwin.cxx                                     |    2 
 sc/source/ui/app/scdll.cxx                                        |    1 
 sc/source/ui/attrdlg/scdlgfact.cxx                                |   15 
 sc/source/ui/attrdlg/scdlgfact.hxx                                |    7 
 sc/source/ui/docshell/arealink.cxx                                |    2 
 sc/source/ui/docshell/docfunc.cxx                                 |   31 
 sc/source/ui/docshell/docsh4.cxx                                  |    2 
 sc/source/ui/docshell/impex.cxx                                   |    2 
 sc/source/ui/docshell/servobj.cxx                                 |    2 
 sc/source/ui/inc/docfunc.hxx                                      |    7 
 sc/source/ui/inc/miscdlgs.hrc                                     |    6 
 sc/source/ui/inc/namedefdlg.hrc                                   |   52 
 sc/source/ui/inc/namedefdlg.hxx                                   |  110 +
 sc/source/ui/inc/namedlg.hrc                                      |   19 
 sc/source/ui/inc/namedlg.hxx                                      |  117 -
 sc/source/ui/inc/namemgrtable.hxx                                 |   82 +
 sc/source/ui/inc/namepast.hxx                                     |   34 
 sc/source/ui/inc/reffact.hxx                                      |    1 
 sc/source/ui/inc/scui_def.hxx                                     |    1 
 sc/source/ui/miscdlgs/namepast.cxx                                |  131 --
 sc/source/ui/namedlg/namedefdlg.cxx                               |  384 ++++++
 sc/source/ui/namedlg/namedlg.cxx                                  |  603 +++-------
 sc/source/ui/namedlg/namemgrtable.cxx                             |  172 ++
 sc/source/ui/namedlg/namepast.cxx                                 |  119 +
 sc/source/ui/navipi/content.cxx                                   |    4 
 sc/source/ui/navipi/navipi.src                                    |    2 
 sc/source/ui/src/globstr.src                                      |   16 
 sc/source/ui/src/miscdlgs.src                                     |   53 
 sc/source/ui/src/namedefdlg.src                                   |  169 ++
 sc/source/ui/src/namedlg.src                                      |   82 -
 sc/source/ui/undo/undorangename.cxx                               |   99 +
 sc/source/ui/unoobj/nameuno.cxx                                   |   10 
 sc/source/ui/vba/vbarange.cxx                                     |    2 
 sc/source/ui/view/cellsh.cxx                                      |    1 
 sc/source/ui/view/cellsh1.cxx                                     |   29 
 sc/source/ui/view/editsh.cxx                                      |   23 
 sc/source/ui/view/formatsh.cxx                                    |    1 
 sc/source/ui/view/pfuncache.cxx                                   |    2 
 sc/source/ui/view/reffact.cxx                                     |    7 
 sc/source/ui/view/tabvwsh.cxx                                     |    1 
 sc/source/ui/view/tabvwshc.cxx                                    |   21 
 sc/source/ui/view/viewfunc.cxx                                    |    2 
 sc/uiconfig/scalc/menubar/menubar.xml                             |    1 
 68 files changed, 1776 insertions(+), 854 deletions(-)

New commits:
commit c35bd5f3c42786f0fde4aebebc20422ab85bf099
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 08:05:07 2011 +0100

    ManageNames: handle formula errors in Define Names dialog correctly

diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 35555ce..94d9ada 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -83,6 +83,7 @@ private:
     void MorePushed();
 
     bool IsNameValid();
+    bool IsFormulaValid();
 
     DECL_LINK( CancelBtnHdl, void * );
     DECL_LINK( AddBtnHdl, void* );
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 508ee7a..f7afe22 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -125,6 +125,24 @@ void ScNameDefDlg::CancelPushed()
     Close();
 }
 
+bool ScNameDefDlg::IsFormulaValid()
+{
+    ScCompiler aComp( mpDoc, maCursorPos);
+    aComp.SetGrammar( mpDoc->GetGrammar() );
+    ScTokenArray* pCode = aComp.CompileString(maEdRange.GetText());
+    if (pCode->GetCodeError())
+    {
+        //TODO: info message
+        delete pCode;
+        return false;
+    }
+    else
+    {
+        delete pCode;
+        return true;
+    }
+}
+
 bool ScNameDefDlg::IsNameValid()
 {
     rtl::OUString aScope = maLbScope.GetSelectEntry();
@@ -152,6 +170,13 @@ bool ScNameDefDlg::IsNameValid()
         maBtnAdd.Disable();
         return false;
     }
+
+    if (!IsFormulaValid())
+    {
+        maBtnAdd.Disable();
+        return false;
+    }
+
     maFtInfo.SetText(maStrInfoDefault);
     maBtnAdd.Enable();
     return true;
commit ab63c12395ed3771b1df6822eaa8572c06db0765
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 06:20:06 2011 +0100

    ManageNames: make pasting of multiple names working and fix crash

diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index a72e765..dc894a0 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -140,7 +140,8 @@ void ScRangeManagerTable::Init(const boost::ptr_map<rtl::OUString, ScRangeName>&
 
 void ScRangeManagerTable::DeleteSelectedEntries()
 {
-    RemoveSelection();
+    if (GetSelectionCount())
+        RemoveSelection();
 }
 
 bool ScRangeManagerTable::IsMultiSelection()
@@ -151,16 +152,19 @@ bool ScRangeManagerTable::IsMultiSelection()
 std::vector<ScRangeNameLine> ScRangeManagerTable::GetSelectedEntries()
 {
     std::vector<ScRangeNameLine> aSelectedEntries;
-    for (SvLBoxEntry* pEntry = FirstSelected(); pEntry != LastSelected(); pEntry = NextSelected(pEntry))
+    if (GetSelectionCount())
     {
+        for (SvLBoxEntry* pEntry = FirstSelected(); pEntry != LastSelected(); pEntry = NextSelected(pEntry))
+        {
+            ScRangeNameLine aLine;
+            GetLine( aLine, pEntry );
+            aSelectedEntries.push_back(aLine);
+        }
+        SvLBoxEntry* pEntry = LastSelected();
         ScRangeNameLine aLine;
         GetLine( aLine, pEntry );
         aSelectedEntries.push_back(aLine);
     }
-    SvLBoxEntry* pEntry = LastSelected();
-    ScRangeNameLine aLine;
-    GetLine( aLine, pEntry );
-    aSelectedEntries.push_back(aLine);
     return aSelectedEntries;
 }
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index a8f5cba..0aab1e5 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1838,7 +1838,16 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
                                 pScMod->InputKeyEvent( KeyEvent('=',KeyCode()) );
 
                                 std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames();
-                                pHdl->InsertFunction( aNames.at(0), false );       // without "()"
+                                if (aNames.size())
+                                {
+                                    rtl::OUStringBuffer aBuffer;
+                                    for (std::vector<rtl::OUString>::const_iterator itr = aNames.begin();
+                                            itr != aNames.end(); ++itr)
+                                    {
+                                        aBuffer.append(*itr).append(' ');
+                                    }
+                                    pHdl->InsertFunction( aBuffer.makeStringAndClear(), false );       // without "()"
+                                }
                             }
                         }
                         break;
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index 15bc31e..9a1eff3 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -440,9 +440,18 @@ void ScEditShell::Execute( SfxRequest& rReq )
                 if ( nRet == BTN_PASTE_NAME )
                 {
                     std::vector<rtl::OUString> aNames = pDlg->GetSelectedNames();
-                    pTableView->InsertText(aNames.at(0));
-                    if (pTopView)
-                        pTopView->InsertText(aNames.at(0));
+                    if (aNames.size())
+                    {
+                        rtl::OUStringBuffer aBuffer;
+                        for (std::vector<rtl::OUString>::const_iterator itr = aNames.begin();
+                                itr != aNames.end(); ++itr)
+                        {
+                            aBuffer.append(*itr).append(' ');
+                        }
+                        pTableView->InsertText(aBuffer.toString());
+                        if (pTopView)
+                            pTopView->InsertText(aBuffer.makeStringAndClear());
+                    }
                 }
                 delete pDlg;
 
commit e58dfb62106fc047d73ad0d62595ebc805ece5e1
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 06:03:24 2011 +0100

    ManageNames: move some strings to globstr.[sh]rc

diff --git a/sc/inc/globstr.hrc b/sc/inc/globstr.hrc
index 4e88a8e..39ca0b2 100644
--- a/sc/inc/globstr.hrc
+++ b/sc/inc/globstr.hrc
@@ -592,7 +592,12 @@
 
 #define STR_MANAGE_NAMES            458
 
-#define STR_COUNT                   459
+#define STR_HEADER_NAME             459
+#define STR_HEADER_RANGE            460
+#define STR_HEADER_SCOPE            461
+#define STR_GLOBAL_SCOPE            462
+
+#define STR_COUNT                   463
 
 
 #endif
diff --git a/sc/source/ui/inc/namedefdlg.hrc b/sc/source/ui/inc/namedefdlg.hrc
index b7ee8ca..657795f 100644
--- a/sc/source/ui/inc/namedefdlg.hrc
+++ b/sc/source/ui/inc/namedefdlg.hrc
@@ -41,7 +41,6 @@
 #define BTN_CRITERIA 11
 #define BTN_ROWHEADER 12
 #define BTN_COLHEADER 13
-#define STR_GLOBAL_SCOPE 14
 #define FL_DIV 15
 #define STR_INVALIDSYMBOL 16
 #define STR_ERR_NAME_EXISTS 17
diff --git a/sc/source/ui/inc/namedlg.hrc b/sc/source/ui/inc/namedlg.hrc
index cc23d1f..db5c08c 100644
--- a/sc/source/ui/inc/namedlg.hrc
+++ b/sc/source/ui/inc/namedlg.hrc
@@ -45,7 +45,6 @@
 #define RB_ASSIGN       16
 
 #define STR_INVALIDSYMBOL 23
-#define STR_GLOBAL_SCOPE 24
 #define STR_MODIFYFAILED 72
 
 #define BTN_CRITERIA    31
@@ -54,9 +53,6 @@
 #define BTN_ROWHEADER   34
 
 #define CTRL_MANAGENAMES    66
-#define STR_HEADER_NAME     69
-#define STR_HEADER_RANGE    70
-#define STR_HEADER_SCOPE    71
 #define STR_ERR_NAME_EXISTS 73
 #define STR_ERR_NAME_INVALID 74
 #define STR_DEFAULT_INFO    75
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index c9ca227..508ee7a 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -32,6 +32,7 @@
 #include <sfx2/app.hxx>
 
 #include "document.hxx"
+#include "globstr.hrc"
 #include "globalnames.hxx"
 #include "rangenam.hxx"
 #include "reffact.hxx"
@@ -72,7 +73,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     maCursorPos( aCursorPos ),
 
     mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
-    maGlobalNameStr  ( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ),
+    maGlobalNameStr  ( ScGlobal::GetRscString(STR_GLOBAL_SCOPE) ),
     maErrInvalidNameStr( ResId::toString(ScResId(STR_ERR_NAME_INVALID))),
     maErrNameInUse   ( ResId::toString(ScResId(STR_ERR_NAME_EXISTS))),
     maStrInfoDefault ( ResId::toString(ScResId(STR_DEFAULT_INFO))),
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index ef567e5..1f2060b 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -102,7 +102,7 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     //
     mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
     maErrMsgModifiedFailed( ResId::toString(ScResId( STR_MODIFYFAILED ) ) ),
-    maGlobalNameStr  ( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ),
+    maGlobalNameStr  ( ScGlobal::GetRscString(STR_GLOBAL_SCOPE) ),
     maErrInvalidNameStr( ResId::toString(ScResId(STR_ERR_NAME_INVALID))),
     maErrNameInUse   ( ResId::toString(ScResId(STR_ERR_NAME_EXISTS))),
     maStrInfoDefault ( ResId::toString(ScResId(STR_DEFAULT_INFO))),
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 538791f..a72e765 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -59,15 +59,15 @@ String createEntryString(const ScRangeNameLine& rLine)
 ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap ):
     SvTabListBox( pWindow, WB_SORT | WB_HSCROLL | WB_CLIPCHILDREN | WB_TABSTOP ),
     maHeaderBar( pWindow, WB_BUTTONSTYLE | WB_BOTTOMBORDER ),
-    maGlobalString( ResId::toString(ScResId(STR_GLOBAL_SCOPE)))
+    maGlobalString( ScGlobal::GetRscString(STR_GLOBAL_SCOPE))
 {
     Size aBoxSize( pWindow->GetOutputSizePixel() );
 
     maHeaderBar.SetPosSizePixel( Point(0, 0), Size( aBoxSize.Width(), 16 ) );
 
-    String aNameStr(ScResId(STR_HEADER_NAME));
-    String aRangeStr(ScResId(STR_HEADER_RANGE));
-    String aScopeStr(ScResId(STR_HEADER_SCOPE));
+    String aNameStr(ScGlobal::GetRscString(STR_HEADER_NAME));
+    String aRangeStr(ScGlobal::GetRscString(STR_HEADER_RANGE));
+    String aScopeStr(ScGlobal::GetRscString(STR_HEADER_SCOPE));
 
     long nTabSize = aBoxSize.Width()/3;
     maHeaderBar.InsertItem( ITEMID_NAME, aNameStr, nTabSize, HIB_LEFT| HIB_VCENTER );
diff --git a/sc/source/ui/namedlg/namepast.cxx b/sc/source/ui/namedlg/namepast.cxx
index 7db6abf..9c57061 100644
--- a/sc/source/ui/namedlg/namepast.cxx
+++ b/sc/source/ui/namedlg/namepast.cxx
@@ -44,7 +44,7 @@
 
 //==================================================================
 
-ScNamePasteDlg::ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool bInsList )
+ScNamePasteDlg::ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool )
     : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
     maHelpButton     ( this, ScResId( BTN_HELP ) ),
     maBtnClose       ( this, ScResId( BTN_CLOSE ) ),
diff --git a/sc/source/ui/src/globstr.src b/sc/source/ui/src/globstr.src
index 9a1a42f..5462b51 100644
--- a/sc/source/ui/src/globstr.src
+++ b/sc/source/ui/src/globstr.src
@@ -1827,5 +1827,21 @@ Resource RID_GLOBSTR
     {
         Text [ en-US ] = "Manage Names...";
     };
+    String STR_HEADER_NAME
+    {
+        Text [en-US] = "Name";
+    };
+    String STR_HEADER_RANGE
+    {
+        Text [en-US] = "Range";
+    };
+    String STR_HEADER_SCOPE
+    {
+        Text [en-US] = "Scope";
+    };
+    String STR_GLOBAL_SCOPE
+    {
+        Text [ en-US ] = "Document (Global)" ;
+    };
 };
 
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index 722d309..f93bab2 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -1453,7 +1453,7 @@ ModalDialog RID_SCDLG_NAMES_PASTE
     FixedLine FL_DIV
     {
         Pos = MAP_APPFONT( 0, 132 );
-        Size = MAP_APPFONT( 228, 132 );
+        Size = MAP_APPFONT( 228, 3 );
     };
     Text [ en-US ] = "Paste Names" ;
 };
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index a700596..67f7b43 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -148,10 +148,6 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
         Size = MAP_APPFONT(200, 3 );
     };
 
-    String STR_GLOBAL_SCOPE
-    {
-        Text [ en-US ] = "Document (Global)" ;
-    };
     String STR_INVALIDSYMBOL
     {
         Text [ en-US ] = "Invalid expression" ;
diff --git a/sc/source/ui/src/namedlg.src b/sc/source/ui/src/namedlg.src
index b97ab9f..71225ca 100644
--- a/sc/source/ui/src/namedlg.src
+++ b/sc/source/ui/src/namedlg.src
@@ -184,10 +184,7 @@ ModelessDialog RID_SCDLG_NAMES
     {
         Text [en-US ] = "Modifying range name failed" ;
     };
-    String STR_GLOBAL_SCOPE
-    {
-        Text [ en-US ] = "Document (Global)" ;
-    };
+
 
     FixedText FT_INFO
     {
@@ -203,18 +200,6 @@ ModelessDialog RID_SCDLG_NAMES
         Border = TRUE;
         DialogControl = TRUE;
     };
-    String STR_HEADER_NAME
-    {
-        Text [en-US] = "Name";
-    };
-    String STR_HEADER_RANGE
-    {
-        Text [en-US] = "Range";
-    };
-    String STR_HEADER_SCOPE
-    {
-        Text [en-US] = "Scope";
-    };
     String STR_ERR_NAME_EXISTS
     {
         Text [ en-US ] = "Invalid name. Already in use for the selected scope.";
commit 9e8ae1d56076474e4673a953d8ebd726cb5daa18
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 03:41:26 2011 +0100

    remove ScRangeName::findByName
    
    this method was mmisused and is the source for some "bugs"
    
    we don't allow case sensitive storage of range names and therefore it
    does not amke sense to search by case sensitive names, use
    ScRangeName::findByUpperName instead
    Especially the uno implementation did behave wrongly and allowed to
    create two names that were identicall for the model

diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index df161a1..4214af3 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -202,8 +202,6 @@ public:
     SC_DLLPUBLIC ScRangeName(const ScRangeName& r);
 
     SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const;
-    SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString& rName);
-    SC_DLLPUBLIC const ScRangeData* findByName(const rtl::OUString& rName) const;
     SC_DLLPUBLIC ScRangeData* findByUpperName(const rtl::OUString& rName);
     SC_DLLPUBLIC const ScRangeData* findByUpperName(const rtl::OUString& rName) const;
     SC_DLLPUBLIC ScRangeData* findByIndex(sal_uInt16 i);
diff --git a/sc/qa/unit/filters-test.cxx b/sc/qa/unit/filters-test.cxx
index cb99cd1..587b71e 100644
--- a/sc/qa/unit/filters-test.cxx
+++ b/sc/qa/unit/filters-test.cxx
@@ -341,16 +341,16 @@ void testRangeNameImpl(ScDocument* pDoc)
 {
     //check one range data per sheet and one global more detailed
     //add some more checks here
-    ScRangeData* pRangeData = pDoc->GetRangeName()->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Global1")));
+    ScRangeData* pRangeData = pDoc->GetRangeName()->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GLOBAL1")));
     CPPUNIT_ASSERT_MESSAGE("range name Global1 not found", pRangeData);
     double aValue;
     pDoc->GetValue(1,0,0,aValue);
     CPPUNIT_ASSERT_MESSAGE("range name Global1 should reference Sheet1.A1", aValue == 1);
-    pRangeData = pDoc->GetRangeName(0)->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local1")));
+    pRangeData = pDoc->GetRangeName(0)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1")));
     CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 not found", pRangeData);
     pDoc->GetValue(1,2,0,aValue);
     CPPUNIT_ASSERT_MESSAGE("range name Sheet1.Local1 should reference Sheet1.A3", aValue == 3);
-    pRangeData = pDoc->GetRangeName(1)->findByName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Local2")));
+    pRangeData = pDoc->GetRangeName(1)->findByUpperName(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2")));
     CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 not found", pRangeData);
     pDoc->GetValue(1,1,1,aValue);
     CPPUNIT_ASSERT_MESSAGE("range name Sheet2.Local2 should reference Sheet2.A2", aValue == 7);
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx
index d5111b2..9b0cbcc 100644
--- a/sc/qa/unit/ucalc.cxx
+++ b/sc/qa/unit/ucalc.cxx
@@ -2709,12 +2709,12 @@ void Test::testCopyPaste()
     CPPUNIT_ASSERT_MESSAGE("copied value should be 1", aValue == 1);
 
     //chack local range name after copying
-    pLocal1 = m_pDoc->GetRangeName(1)->findByName(OUString(RTL_CONSTASCII_USTRINGPARAM("local1")));
+    pLocal1 = m_pDoc->GetRangeName(1)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL1")));
     CPPUNIT_ASSERT_MESSAGE("local range name 1 should be copied", pLocal1);
     ScRange aRangeLocal1;
     pLocal1->IsValidReference(aRangeLocal1);
     CPPUNIT_ASSERT_MESSAGE("local range 1 should still point to Sheet1.A1",aRangeLocal1 == ScRange(0,0,0,0,0,0));
-    pLocal2 = m_pDoc->GetRangeName(1)->findByName(OUString(RTL_CONSTASCII_USTRINGPARAM("local2")));
+    pLocal2 = m_pDoc->GetRangeName(1)->findByUpperName(OUString(RTL_CONSTASCII_USTRINGPARAM("LOCAL2")));
     CPPUNIT_ASSERT_MESSAGE("local2 should not be copied", pLocal2 == NULL);
 
 
diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index 5798f4d..94754e7 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -996,7 +996,7 @@ sal_uLong ScDocument::TransferTab( ScDocument* pSrcDoc, SCTAB nSrcPos,
                     bool bInUse = ( aUsedNames.find(nOldIndex) != aUsedNames.end() );
                     if (bInUse)
                     {
-                        const ScRangeData* pExistingData = GetRangeName()->findByName(itr->GetName());
+                        const ScRangeData* pExistingData = GetRangeName()->findByUpperName(itr->GetUpperName());
                         if (pExistingData)
                         {
                             // the name exists already in the destination document
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index de225f4..5a50aef 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -2121,7 +2121,7 @@ void ScDocument::CopyRangeNamesFromClip(ScDocument* pClipDoc, ScClipRangeNameDat
             A proper solution would ask the user how to proceed.
             The adjustment of the indices in the formulas is done later.
         */
-        const ScRangeData* pExistingData = GetRangeName()->findByName(itr->GetName());
+        const ScRangeData* pExistingData = GetRangeName()->findByUpperName(itr->GetUpperName());
         if (pExistingData)
         {
             sal_uInt16 nOldIndex = itr->GetIndex();
diff --git a/sc/source/core/tool/rangenam.cxx b/sc/source/core/tool/rangenam.cxx
index 6984984..1d2d99c 100644
--- a/sc/source/core/tool/rangenam.cxx
+++ b/sc/source/core/tool/rangenam.cxx
@@ -735,17 +735,6 @@ public:
     }
 };
 
-class MatchByName : public unary_function<ScRangeData, bool>
-{
-    const OUString& mrName;
-public:
-    MatchByName(const OUString& rName) : mrName(rName) {}
-    bool operator() (const ScRangeData& r) const
-    {
-        return mrName.equals(r.GetName());
-    }
-};
-
 class MatchByUpperName : public unary_function<ScRangeData, bool>
 {
     const OUString& mrName;
@@ -813,20 +802,6 @@ const ScRangeData* ScRangeName::findByRange(const ScRange& rRange) const
     return itr == maData.end() ? NULL : &(*itr);
 }
 
-ScRangeData* ScRangeName::findByName(const OUString& rName)
-{
-    DataType::iterator itr = std::find_if(
-        maData.begin(), maData.end(), MatchByName(rName));
-    return itr == maData.end() ? NULL : &(*itr);
-}
-
-const ScRangeData* ScRangeName::findByName(const OUString& rName) const
-{
-    DataType::const_iterator itr = std::find_if(
-        maData.begin(), maData.end(), MatchByName(rName));
-    return itr == maData.end() ? NULL : &(*itr);
-}
-
 ScRangeData* ScRangeName::findByUpperName(const OUString& rName)
 {
     DataType::iterator itr = std::find_if(
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 2ced67b..ab9ebcf 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -307,9 +307,9 @@ sal_Bool ScRangeUtil::MakeRangeFromName (
         ScRangeName* pRangeNames = pDoc->GetRangeName( nTable );
         ScRangeData* pData = NULL;
         if ( pRangeNames )
-            pData = pRangeNames->findByName(aName);
+            pData = pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
         if (!pData)
-            pData = pDoc->GetRangeName()->findByName(aName);
+            pData = pDoc->GetRangeName()->findByUpperName(ScGlobal::pCharClass->upper(aName));
         if (pData)
         {
             String       aStrArea;
@@ -1021,16 +1021,17 @@ ScRangeData* ScRangeStringConverter::GetRangeDataFromString(const rtl::OUString&
 {
     ScRangeName* pLocalRangeName = pDoc->GetRangeName(nTab);
     ScRangeData* pData = NULL;
+    rtl::OUString aUpperName = ScGlobal::pCharClass->upper(rString);
     if(pLocalRangeName)
     {
-        pData = pLocalRangeName->findByName(rString);
+        pData = pLocalRangeName->findByUpperName(aUpperName);
     }
     if (!pData)
     {
         ScRangeName* pGlobalRangeName = pDoc->GetRangeName();
         if (pGlobalRangeName)
         {
-            pData = pGlobalRangeName->findByName(rString);
+            pData = pGlobalRangeName->findByUpperName(aUpperName);
         }
     }
     return pData;
diff --git a/sc/source/filter/html/htmlimp.cxx b/sc/source/filter/html/htmlimp.cxx
index 52eb9de..86ed840 100644
--- a/sc/source/filter/html/htmlimp.cxx
+++ b/sc/source/filter/html/htmlimp.cxx
@@ -208,7 +208,7 @@ void ScHTMLImport::WriteToDocument(
         if (!pTable->GetTableName().isEmpty())
         {
             String aName( ScfTools::GetNameFromHTMLName( pTable->GetTableName() ) );
-            if (!mpDoc->GetRangeName()->findByName(aName))
+            if (!mpDoc->GetRangeName()->findByUpperName(ScGlobal::pCharClass->upper(aName)))
                 InsertRangeName( mpDoc, aName, aNewRange );
         }
     }
@@ -238,7 +238,7 @@ String ScHTMLImport::GetHTMLRangeNameList( ScDocument* pDoc, const String& rOrig
             while( bLoop )
             {
                 aToken = ScfTools::GetNameFromHTMLIndex( nIndex++ );
-                const ScRangeData* pRangeData = pRangeNames->findByName(aToken);
+                const ScRangeData* pRangeData = pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(aToken));
                 if (pRangeData)
                 {
                     ScRange aRange;
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index e849138..983e88c 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -420,7 +420,7 @@ void ScEEImport::WriteToDocument( sal_Bool bSizeColsRows, double nOutputFactor,
                 bHasGraphics |= GraphicSize( nCol, nRow, nTab, pE );
             if ( pE->pName )
             {   // Anchor Name => RangeName
-                if (!pRangeNames->findByName(*pE->pName))
+                if (!pRangeNames->findByUpperName(ScGlobal::pCharClass->upper(*pE->pName)))
                 {
                     ScRangeData* pData = new ScRangeData( mpDoc, *pE->pName,
                         ScAddress( nCol, nRow, nTab ) );
diff --git a/sc/source/ui/app/inputwin.cxx b/sc/source/ui/app/inputwin.cxx
index 5782611..82d9253 100644
--- a/sc/source/ui/app/inputwin.cxx
+++ b/sc/source/ui/app/inputwin.cxx
@@ -2240,7 +2240,7 @@ void ScPosWnd::DoEnter()
                 {
                     ScRangeName* pNames = pDoc->GetRangeName();
                     ScRange aSelection;
-                    if ( pNames && !pNames->findByName(aText) &&
+                    if ( pNames && !pNames->findByUpperName(ScGlobal::pCharClass->upper(aText)) &&
                             (pViewData->GetSimpleArea( aSelection ) == SC_MARK_SIMPLE) )
                     {
                         ScRangeName aNewRanges( *pNames );
diff --git a/sc/source/ui/docshell/arealink.cxx b/sc/source/ui/docshell/arealink.cxx
index 1fe0b98..df2f9b6 100644
--- a/sc/source/ui/docshell/arealink.cxx
+++ b/sc/source/ui/docshell/arealink.cxx
@@ -216,7 +216,7 @@ bool ScAreaLink::FindExtRange( ScRange& rRange, ScDocument* pSrcDoc, const Strin
     ScRangeName* pNames = pSrcDoc->GetRangeName();
     if (pNames)         // benannte Bereiche
     {
-        const ScRangeData* p = pNames->findByName(rAreaName);
+        const ScRangeData* p = pNames->findByUpperName(ScGlobal::pCharClass->upper(rAreaName));
         if (p && p->IsValidReference(rRange))
             bFound = true;
     }
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 739b973..0d8a406 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -4575,7 +4575,7 @@ void ScDocFunc::CreateOneName( ScRangeName& rList,
             ScRange( nX1, nY1, nTab, nX2, nY2, nTab ).Format( aContent, SCR_ABS_3D, pDoc );
 
             bool bInsert = false;
-            ScRangeData* pOld = rList.findByName(aName);
+            ScRangeData* pOld = rList.findByUpperName(ScGlobal::pCharClass->upper(aName));
             if (pOld)
             {
                 String aOldStr;
@@ -4738,7 +4738,7 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
     for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
     {
         const ScRangeData& r = *itr;
-        if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByName(r.GetName()))
+        if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(r.GetUpperName()))
             ++nValidCount;
     }
 
@@ -4773,7 +4773,7 @@ sal_Bool ScDocFunc::InsertNameList( const ScAddress& rStartPos, sal_Bool bApi )
             for (ScRangeName::iterator itr = itrBeg; itr != itrEnd; ++itr)
             {
                 ScRangeData& r = *itr;
-                if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByName(r.GetName()))
+                if (!r.HasType(RT_DATABASE) && !r.HasType(RT_SHARED) && !pLocalList->findByUpperName(r.GetUpperName()))
                     ppSortArray[j++] = &r;
             }
 #ifndef ICC
diff --git a/sc/source/ui/docshell/docsh4.cxx b/sc/source/ui/docshell/docsh4.cxx
index 8bd4782..9f6186a 100644
--- a/sc/source/ui/docshell/docsh4.cxx
+++ b/sc/source/ui/docshell/docsh4.cxx
@@ -2107,7 +2107,7 @@ long ScDocShell::DdeSetData( const String& rItem,
     ScRangeName* pRange = aDocument.GetRangeName();
     if( pRange )
     {
-        const ScRangeData* pData = pRange->findByName(aPos);
+        const ScRangeData* pData = pRange->findByUpperName(ScGlobal::pCharClass->upper(aPos));
         if (pData)
         {
             if( pData->HasType( RT_REFAREA )
diff --git a/sc/source/ui/docshell/impex.cxx b/sc/source/ui/docshell/impex.cxx
index 712f696..a10affc 100644
--- a/sc/source/ui/docshell/impex.cxx
+++ b/sc/source/ui/docshell/impex.cxx
@@ -173,7 +173,7 @@ ScImportExport::ScImportExport( ScDocument* p, const String& rPos )
     ScRangeName* pRange = pDoc->GetRangeName();
     if( pRange )
     {
-        const ScRangeData* pData = pRange->findByName(aPos);
+        const ScRangeData* pData = pRange->findByUpperName(ScGlobal::pCharClass->upper(aPos));
         if (pData)
         {
             if( pData->HasType( RT_REFAREA )
diff --git a/sc/source/ui/docshell/servobj.cxx b/sc/source/ui/docshell/servobj.cxx
index d542254..90c497e 100644
--- a/sc/source/ui/docshell/servobj.cxx
+++ b/sc/source/ui/docshell/servobj.cxx
@@ -54,7 +54,7 @@ sal_Bool lcl_FillRangeFromName( ScRange& rRange, ScDocShell* pDocSh, const Strin
         ScRangeName* pNames = pDoc->GetRangeName();
         if (pNames)
         {
-            const ScRangeData* pData = pNames->findByName(rName);
+            const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(rName));
             if (pData)
             {
                 if ( pData->IsValidReference( rRange ) )
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 202eb82..ef567e5 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -317,7 +317,7 @@ void ScNameDlg::CalcCurTableAssign( String& aAssign, ScRangeData* pRangeData )
 void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
 {
     ScRangeName* pRangeName = GetRangeName(rLine.aScope);
-    ScRangeData* pData = pRangeName->findByName(rLine.aName);
+    ScRangeData* pData = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(rLine.aName));
     if (pData)
     {
         UpdateChecks(pData);
diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index bd32d1c..bc9280a 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -1017,7 +1017,7 @@ bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRa
         ScRangeName* pList = pDoc->GetRangeName();
         if (pList)
         {
-            const ScRangeData* p = pList->findByName(rName);
+            const ScRangeData* p = pList->findByUpperName(ScGlobal::pCharClass->upper(rName));
             if (p && p->IsValidReference(rRange))
                 bFound = true;
         }
@@ -1027,7 +1027,7 @@ bool lcl_GetRange( ScDocument* pDoc, sal_uInt16 nType, const String& rName, ScRa
         ScDBCollection* pList = pDoc->GetDBCollection();
         if (pList)
         {
-            const ScDBData* p = pList->getNamedDBs().findByName(rName);
+            const ScDBData* p = pList->getNamedDBs().findByUpperName(ScGlobal::pCharClass->upper(rName));
             if (p)
             {
                 SCTAB nTab;
diff --git a/sc/source/ui/unoobj/nameuno.cxx b/sc/source/ui/unoobj/nameuno.cxx
index ab23b19..3210c81 100644
--- a/sc/source/ui/unoobj/nameuno.cxx
+++ b/sc/source/ui/unoobj/nameuno.cxx
@@ -137,7 +137,7 @@ ScRangeData* ScNamedRangeObj::GetRangeData_Impl()
             pNames = pDocShell->GetDocument()->GetRangeName();
         if (pNames)
         {
-            pRet = pNames->findByName(aName);
+            pRet = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
             if (pRet)
                 pRet->ValidateTabRefs();        // adjust relative tab refs to valid tables
         }
@@ -180,7 +180,7 @@ void ScNamedRangeObj::Modify_Impl( const String* pNewName, const ScTokenArray* p
     if (!pNames)
         return;
 
-    const ScRangeData* pOld = pNames->findByName(aName);
+    const ScRangeData* pOld = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
     if (!pOld)
         return;
 
@@ -556,7 +556,7 @@ void SAL_CALL ScNamedRangesObj::addNewByName( const rtl::OUString& aName,
     {
         ScDocument* pDoc = pDocShell->GetDocument();
         ScRangeName* pNames = GetRangeName_Impl();
-        if (pNames && !pNames->findByName(aName))
+        if (pNames && !pNames->findByUpperName(ScGlobal::pCharClass->upper(aName)))
         {
             ScRangeName* pNewRanges = new ScRangeName( *pNames );
             // GRAM_PODF_A1 for API compatibility.
@@ -617,7 +617,7 @@ void SAL_CALL ScNamedRangesObj::removeByName( const rtl::OUString& aName )
         ScRangeName* pNames = GetRangeName_Impl();
         if (pNames)
         {
-            const ScRangeData* pData = pNames->findByName(aName);
+            const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
             if (pData && lcl_UserVisibleName(*pData))
             {
                 ScRangeName* pNewRanges = new ScRangeName(*pNames);
@@ -779,7 +779,7 @@ sal_Bool SAL_CALL ScNamedRangesObj::hasByName( const rtl::OUString& aName )
         ScRangeName* pNames = GetRangeName_Impl();
         if (pNames)
         {
-            const ScRangeData* pData = pNames->findByName(aName);
+            const ScRangeData* pData = pNames->findByUpperName(ScGlobal::pCharClass->upper(aName));
             if (pData && lcl_UserVisibleName(*pData))
                 return sal_True;
         }
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index 5851826..35df42a 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1184,7 +1184,7 @@ bool getScRangeListForAddress( const rtl::OUString& sName, ScDocShell* pDocSh, S
                 ScRangeName* pRangeName = pDoc->GetRangeName(nCurTab);
                 if (pRangeName)
                 {
-                    bLocalName = pRangeName->findByName(sAddress) != NULL;
+                    bLocalName = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(sAddress)) != NULL;
                     // TODO: Handle local names correctly.
                     (void)bLocalName;
                 }
diff --git a/sc/source/ui/view/viewfunc.cxx b/sc/source/ui/view/viewfunc.cxx
index cb767b7..9cc13af 100644
--- a/sc/source/ui/view/viewfunc.cxx
+++ b/sc/source/ui/view/viewfunc.cxx
@@ -2928,7 +2928,7 @@ sal_Bool ScViewFunc::InsertName( const String& rName, const String& rSymbol,
         pDoc->CompileNameFormula( sal_True );   // CreateFormulaString
 
         // input available yet? Then remove beforehand (=change)
-        ScRangeData* pData = pList->findByName(rName);
+        ScRangeData* pData = pList->findByUpperName(ScGlobal::pCharClass->upper(rName));
         if (pData)
         {                                   // take old Index
             pNewEntry->SetIndex(pData->GetIndex());
commit f3c7c1e4ceddc6f778de89c1e75dbb126247c787
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 03:08:42 2011 +0100

    ManageNames: add missing licence headers

diff --git a/sc/source/ui/inc/namedefdlg.hrc b/sc/source/ui/inc/namedefdlg.hrc
index b3602c6..b7ee8ca 100644
--- a/sc/source/ui/inc/namedefdlg.hrc
+++ b/sc/source/ui/inc/namedefdlg.hrc
@@ -1,3 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *  Copyright (C) 2011 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include "sc.hrc"
 
 #define BTN_ADD 1
@@ -21,3 +49,5 @@
 #define STR_DEFAULT_INFO 19
 #define RB_RANGE 20
 #define BTN_MORE 21
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index a379976..2795a7e 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -25,6 +25,7 @@
  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
  * instead of those above.
  */
+
 #include <svtools/headbar.hxx>
 #include <svtools/svtabbx.hxx>
 #include <vcl/ctrl.hxx>
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 1e60c61..c9ca227 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -1,3 +1,31 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *  Copyright (C) 2011 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer) ]
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
 #include "namedefdlg.hxx"
 
 #include <vcl/msgbox.hxx>
@@ -326,3 +354,5 @@ IMPL_LINK( ScNameDefDlg, MoreBtnHdl, void*, EMPTYARG)
     MorePushed();
     return 0;
 }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 535e1b8..538791f 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -25,6 +25,7 @@
  * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
  * instead of those above.
  */
+
 //ScRangeManagerTable
 #include "global.hxx"
 #include "reffact.hxx"
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index ac69133..a700596 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -1,3 +1,30 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ *  Copyright (C) 2011 Markus Mohrhard <markus.mohrhard at googlemail.com> (initial developer)
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
 
 #include "namedefdlg.hrc"
 
@@ -142,3 +169,5 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
         Text [en-US] = "Define the name and range or formula expression.";
     };
 };
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit 1ca05c949702bc0fcaf8fce8c29c2ca7b8d42c6a
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 03:02:01 2011 +0100

    ManageNames: remove Add Button and debug output

diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 5d436d3..202eb82 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -135,7 +135,6 @@ void ScNameDlg::Init()
     {
         rtl::OUString aTemp(itr->first);
         maRangeMap.insert(aTemp, new ScRangeName(*itr->second));
-        std::cout << "RangeName: " << rtl::OUStringToOString(aTemp, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
     }
 
     mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap);
@@ -178,6 +177,9 @@ void ScNameDlg::Init()
     {
         SelectionChanged();
     }
+
+    //TODO: fix the Add Button
+    maBtnAdd.Disable();
 }
 
 sal_Bool ScNameDlg::IsRefInputMode() const
@@ -206,7 +208,6 @@ void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 
 sal_Bool ScNameDlg::Close()
 {
-    std::cout << "Ok Pushed!" << std::endl;
     ScDocFunc aFunc(*mpViewData->GetDocShell());
     aFunc.ModifyAllRangeNames(maRangeMap);
     return DoClose( ScNameDlgWrapper::GetChildWindowId() );
@@ -326,52 +327,7 @@ void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
 
 bool ScNameDlg::AddPushed()
 {
-    if (!mpDoc)
-        return false;
-
-    rtl::OUString aName = maEdName.GetText();
-    aName = aName.trim();
-    if (!aName.getLength())
-        return false;
-
-    if (!ScRangeData::IsNameValid( aName, mpDoc ))
-    {
-        ERRORBOX( ScGlobal::GetRscString(STR_INVALIDNAME));
-        return false;
-    }
-
-    rtl::OUString aScope = maLbScope.GetSelectEntry();
-    rtl::OUString aExpr = maEdAssign.GetText();
-    ScRangeName* pRangeName = GetRangeName(aScope);
-
-    RangeType nType = RT_NAME |
-         (maBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
-        |(maBtnColHeader.IsChecked() ? RT_COLHEADER : RangeType(0))
-        |(maBtnPrintArea.IsChecked() ? RT_PRINTAREA : RangeType(0))
-        |(maBtnCriteria.IsChecked()  ? RT_CRITERIA  : RangeType(0));
-
-    ScRangeData* pNewEntry = new ScRangeData( mpDoc, aName, aExpr,
-                                            maCursorPos, nType);
-    if ( 0 == pNewEntry->GetErrCode() )
-    {
-        if (!pRangeName->insert( pNewEntry))
-        {
-            pNewEntry = NULL;
-        }
-        else
-        {
-            maEdName.SetText(EMPTY_STRING);
-            maBtnAdd.Disable();
-            UpdateNames();
-            SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
-        }
-    }
-    else
-    {
-        delete pNewEntry;
-        ERRORBOX( mErrMsgInvalidSym );
-    }
-    return true;
+    return false;
 }
 
 void ScNameDlg::RemovePushed()
@@ -381,8 +337,6 @@ void ScNameDlg::RemovePushed()
     for (std::vector<ScRangeNameLine>::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
         ScRangeName* pRangeName = GetRangeName(itr->aScope);
-        std::cout << rtl::OUStringToOString(itr->aName, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
-        std::cout << rtl::OUStringToOString(ScGlobal::pCharClass->upper(itr->aName), RTL_TEXTENCODING_UTF8).getStr() << std::endl;;
         ScRangeData* pData = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(itr->aName));
         OSL_ENSURE(pData, "table and model should be in sync");
         // be safe and check for possible problems
commit 6f92d874d4273d6570631c929600777251782ffc
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 02:53:12 2011 +0100

    Manage Names: fix an initialization problem

diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 594c73b..35555ce 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -38,6 +38,7 @@
 class ScRangeName;
 class ScDocument;
 class ScDocShell;
+class ScViewData;
 
 class ScNameDefDlg : public ScAnyRefDlg
 {
@@ -95,7 +96,7 @@ protected:
 
 public:
     ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
-                    ScDocShell* pDocShell, std::map<rtl::OUString, ScRangeName*> aRangeMap,
+                    ScViewData* pViewData, std::map<rtl::OUString, ScRangeName*> aRangeMap,
                     const ScAddress& aCursorPos, const bool bUndo);
 
     virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc );
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index 036627c..a379976 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -68,7 +68,7 @@ private:
 
 public:
     ScRangeManagerTable( Window* pParent, boost::ptr_map<rtl::OUString, ScRangeName>& aTabRangeNames );
-    ~ScRangeManagerTable() {};
+    virtual ~ScRangeManagerTable();
 
     void addEntry( const ScRangeNameLine& rLine );
     void DeleteSelectedEntries();
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 1fcf93e..1e60c61 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -19,7 +19,7 @@
 #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
 
 ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
-        ScDocShell* pDocShell, std::map<rtl::OUString, ScRangeName*> aRangeMap,
+        ScViewData* pViewData, std::map<rtl::OUString, ScRangeName*> aRangeMap,
         const ScAddress& aCursorPos, const bool bUndo ) :
     ScAnyRefDlg( pB, pCW, pParent, RID_SCDLG_NAMES_DEFINE ),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
@@ -39,8 +39,8 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     maBtnPrintArea( this, ScResId( BTN_PRINTAREA ) ),
     maBtnCriteria( this, ScResId( BTN_CRITERIA ) ),
     mbUndo( bUndo ),
-    mpDoc( pDocShell->GetDocument() ),
-    mpDocShell ( pDocShell ),
+    mpDoc( pViewData->GetDocument() ),
+    mpDocShell ( pViewData->GetDocShell() ),
     maCursorPos( aCursorPos ),
 
     mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
@@ -77,6 +77,18 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     maBtnPrintArea.Hide();
 
     FreeResource();
+
+    String aAreaStr;
+    ScRange aRange;
+
+    pViewData->GetSimpleArea( aRange );
+    aRange.Format( aAreaStr, ABS_DREF3D, mpDoc,
+            ScAddress::Details(mpDoc->GetAddressConvention(), 0, 0) );
+
+    Selection aCurSel = Selection( 0, SELECTION_MAX );
+    maEdRange.GrabFocus();
+    maEdRange.SetText( aAreaStr );
+    maEdRange.SetSelection( aCurSel );
 }
 
 void ScNameDefDlg::CancelPushed()
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 3345e03..5d436d3 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -123,7 +123,6 @@ ScNameDlg::~ScNameDlg()
 
 void ScNameDlg::Init()
 {
-    String  aAreaStr;
     ScRange aRange;
 
     OSL_ENSURE( mpViewData && mpDoc, "ViewData oder Document nicht gefunden!" );
@@ -173,20 +172,12 @@ void ScNameDlg::Init()
         maLbScope.InsertEntry(aTabName);
     }
 
-    UpdateNames();
-    IsNameValid();
 
-    mpViewData->GetSimpleArea( aRange );
-    aRange.Format( aAreaStr, ABS_DREF3D, mpDoc,
-            ScAddress::Details(mpDoc->GetAddressConvention(), 0, 0) );
-
-    maCurSel = Selection( 0, SELECTION_MAX );
-    maEdAssign.GrabFocus();
-    maEdAssign.SetText( aAreaStr );
-    maEdAssign.SetSelection( maCurSel );
-
-    EdModifyHdl( 0 );
 
+    if (mpRangeManagerTable->GetSelectionCount())
+    {
+        SelectionChanged();
+    }
 }
 
 sal_Bool ScNameDlg::IsRefInputMode() const
diff --git a/sc/source/ui/namedlg/namemgrtable.cxx b/sc/source/ui/namedlg/namemgrtable.cxx
index 70621a9..535e1b8 100644
--- a/sc/source/ui/namedlg/namemgrtable.cxx
+++ b/sc/source/ui/namedlg/namemgrtable.cxx
@@ -84,6 +84,13 @@ ScRangeManagerTable::ScRangeManagerTable( Window* pWindow, boost::ptr_map<rtl::O
     maHeaderBar.Show();
     SetSelectionMode(MULTIPLE_SELECTION);
     Init(rRangeMap);
+    if (GetEntryCount())
+        SetCurEntry(GetEntryOnPos(0));
+}
+
+ScRangeManagerTable::~ScRangeManagerTable()
+{
+    Clear();
 }
 
 void ScRangeManagerTable::addEntry(const ScRangeNameLine& rLine)
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 5f648fb..0c1f007 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -122,7 +122,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
             std::cout << "tabvwsh" << std::endl;
             std::map<rtl::OUString, ScRangeName*> aRangeMap;
             pDoc->GetRangeNameMap(aRangeMap);
-            pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData()->GetDocShell(), aRangeMap,
+            pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData(), aRangeMap,
                             ScAddress( GetViewData()->GetCurX(),
                                         GetViewData()->GetCurY(),
                                         GetViewData()->GetTabNo() ), true );
commit 648a9a48b635e7dd19c109f7289448d359dacf12
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Wed Nov 23 01:41:43 2011 +0100

    ManageNames: update range data also if checkboxes are toggled

diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 400a1d5..3345e03 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -152,6 +152,10 @@ void ScNameDlg::Init()
     maLbScope.SetSelectHdl( LINK(this, ScNameDlg, ScopeChangedHdl) );
     maBtnDelete.SetClickHdl ( LINK( this, ScNameDlg, RemoveBtnHdl ) );
     maBtnMore.SetClickHdl   ( LINK( this, ScNameDlg, MoreBtnHdl ) );
+    maBtnPrintArea.SetToggleHdl( LINK(this, ScNameDlg, EdModifyHdl ) );
+    maBtnCriteria.SetToggleHdl( LINK(this, ScNameDlg, EdModifyHdl ) );
+    maBtnRowHeader.SetToggleHdl( LINK(this, ScNameDlg, EdModifyHdl ) );
+    maBtnColHeader.SetToggleHdl( LINK(this, ScNameDlg, EdModifyHdl ) );
 
     maBtnCriteria .Hide();
     maBtnPrintArea.Hide();
commit 7b761d244e2c25a68427eb99f3e6bd5a97742501
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 08:01:10 2011 +0100

    ManageNames: implement ScNameDlg::IsFormulaValid

diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 46970a4..400a1d5 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -266,7 +266,19 @@ bool ScNameDlg::IsNameValid()
 
 bool ScNameDlg::IsFormulaValid()
 {
-    return true;
+    ScCompiler aComp( mpDoc, maCursorPos);
+    aComp.SetGrammar( mpDoc->GetGrammar() );
+    ScTokenArray* pCode = aComp.CompileString(maEdAssign.GetText());
+    if (pCode->GetCodeError())
+    {
+        delete pCode;
+        return false;
+    }
+    else
+    {
+        delete pCode;
+        return true;
+    }
 }
 
 ScRangeName* ScNameDlg::GetRangeName(const rtl::OUString& rScope)
@@ -387,7 +399,11 @@ void ScNameDlg::RemovePushed()
 void ScNameDlg::NameModified()
 {
     if (!IsFormulaValid())
+    {
+        //TODO: implement an info text
         return;
+    }
+
     ScRangeNameLine aLine;
     mpRangeManagerTable->GetCurrentLine(aLine);
     rtl::OUString aOldName = aLine.aName;
commit 100052237a83ff0e0c5fb726fc6ea79f6375dfa8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 07:10:38 2011 +0100

    ManageNames: need to store the strings in variables

diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 1a25c2b..594c73b 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -68,7 +68,12 @@ private:
     ScDocShell* mpDocShell;
 
     ScAddress maCursorPos;
-    rtl::OUString maGlobalNameStr;
+    const String    mErrMsgInvalidSym;
+    const rtl::OUString maErrMsgModifiedFailed;
+    const rtl::OUString maGlobalNameStr;
+    const rtl::OUString maErrInvalidNameStr;
+    const rtl::OUString maErrNameInUse;
+    const rtl::OUString maStrInfoDefault;
 
     std::map<rtl::OUString, ScRangeName*> maRangeMap;
 
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index 209e056..1fcf93e 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -42,7 +42,12 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     mpDoc( pDocShell->GetDocument() ),
     mpDocShell ( pDocShell ),
     maCursorPos( aCursorPos ),
-    maGlobalNameStr( ResId::toString( ScResId( STR_GLOBAL_SCOPE ) ) ),
+
+    mErrMsgInvalidSym( ScResId( STR_INVALIDSYMBOL ) ),
+    maGlobalNameStr  ( ResId::toString(ScResId(STR_GLOBAL_SCOPE)) ),
+    maErrInvalidNameStr( ResId::toString(ScResId(STR_ERR_NAME_INVALID))),
+    maErrNameInUse   ( ResId::toString(ScResId(STR_ERR_NAME_EXISTS))),
+    maStrInfoDefault ( ResId::toString(ScResId(STR_DEFAULT_INFO))),
     maRangeMap( aRangeMap )
 {
     // Initialize scope list.
@@ -62,7 +67,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     maEdName.SetModifyHdl( LINK( this, ScNameDefDlg, NameModifyHdl ));
     maEdRange.SetGetFocusHdl( LINK( this, ScNameDefDlg, AssignGetFocusHdl ) );
 
-    maFtInfo.SetText(ResId::toString( ScResId( STR_DEFAULT_INFO ) ));
+    maFtInfo.SetText(maStrInfoDefault);
 
     maBtnAdd.Disable(); // empty name is invalid
 
@@ -96,17 +101,17 @@ bool ScNameDefDlg::IsNameValid()
 
     if (!ScRangeData::IsNameValid( aName, mpDoc ))
     {
-        maFtInfo.SetText(ResId::toString(ScResId( STR_ERR_NAME_INVALID )));
+        maFtInfo.SetText(maErrInvalidNameStr);
         maBtnAdd.Disable();
         return false;
     }
     else if (pRangeName->findByUpperName(ScGlobal::pCharClass->upper(aName)))
     {
-        maFtInfo.SetText(ResId::toString(ScResId( STR_ERR_NAME_EXISTS )));
+        maFtInfo.SetText(maErrNameInUse);
         maBtnAdd.Disable();
         return false;
     }
-    maFtInfo.SetText(ResId::toString( ScResId( STR_DEFAULT_INFO ) ));
+    maFtInfo.SetText(maStrInfoDefault);
     maBtnAdd.Enable();
     return true;
 }
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index 8022a4e..ac69133 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -135,7 +135,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     };
     String STR_ERR_NAME_INVALID
     {
-        Text [ en-US ] = "Invalid name. Only use letters, numbers and underscore and don't use names like cell addresses";
+        Text [ en-US ] = "Invalid name. Only use letters, numbers and underscore.";
     };
     String STR_DEFAULT_INFO
     {
commit 23da9369ae622e61b75a4cb72f60667cd4ff9fa5
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 06:58:29 2011 +0100

    ManageNames: add RangeOptions button to Define Name dialog

diff --git a/sc/source/ui/inc/namedefdlg.hrc b/sc/source/ui/inc/namedefdlg.hrc
index 865487a..b3602c6 100644
--- a/sc/source/ui/inc/namedefdlg.hrc
+++ b/sc/source/ui/inc/namedefdlg.hrc
@@ -20,3 +20,4 @@
 #define STR_ERR_NAME_INVALID 18
 #define STR_DEFAULT_INFO 19
 #define RB_RANGE 20
+#define BTN_MORE 21
diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 14ba919..1a25c2b 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -44,6 +44,7 @@ class ScNameDefDlg : public ScAnyRefDlg
 private:
     PushButton maBtnAdd;
     PushButton maBtnCancel;
+    DisclosureButton maBtnMore;
     FixedText maFtInfo;
     FixedText maFtName;
     FixedText maFtRange;
@@ -73,6 +74,7 @@ private:
 
     void CancelPushed();
     void AddPushed();
+    void MorePushed();
 
     bool IsNameValid();
 
@@ -81,6 +83,7 @@ private:
     DECL_LINK( NameModifyHdl, void* );
     DECL_LINK( EdModifyHdl, void * );
     DECL_LINK( AssignGetFocusHdl, void * );
+    DECL_LINK( MoreBtnHdl, void* );
 
 protected:
     virtual void    RefInputDone( sal_Bool bForced = sal_False );
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index e1b2883..209e056 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -24,6 +24,7 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     ScAnyRefDlg( pB, pCW, pParent, RID_SCDLG_NAMES_DEFINE ),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
     maBtnCancel( this, ScResId( BTN_CANCEL ) ),
+    maBtnMore( this, ScResId( BTN_MORE ) ),
     maFtInfo( this, ScResId( FT_INFO ) ),
     maFtName( this, ScResId( FT_NAME ) ),
     maFtRange( this, ScResId( FT_RANGE ) ),
@@ -57,12 +58,20 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
 
     maBtnCancel.SetClickHdl( LINK( this, ScNameDefDlg, CancelBtnHdl));
     maBtnAdd.SetClickHdl( LINK( this, ScNameDefDlg, AddBtnHdl ));
+    maBtnMore.SetClickHdl( LINK( this, ScNameDefDlg, MoreBtnHdl ));
     maEdName.SetModifyHdl( LINK( this, ScNameDefDlg, NameModifyHdl ));
     maEdRange.SetGetFocusHdl( LINK( this, ScNameDefDlg, AssignGetFocusHdl ) );
 
     maFtInfo.SetText(ResId::toString( ScResId( STR_DEFAULT_INFO ) ));
 
     maBtnAdd.Disable(); // empty name is invalid
+
+    maBtnRowHeader.Hide();
+    maBtnColHeader.Hide();
+    maBtnCriteria.Hide();
+    maBtnPrintArea.Hide();
+
+    FreeResource();
 }
 
 void ScNameDefDlg::CancelPushed()
@@ -226,6 +235,45 @@ void ScNameDefDlg::SetActive()
     RefInputDone();
 }
 
+namespace {
+
+void MoveWindow( Window& rButton, long nPixel)
+{
+    Point aPoint = rButton.GetPosPixel();
+    aPoint.Y() += nPixel;
+    rButton.SetPosPixel(aPoint);
+}
+
+}
+
+void ScNameDefDlg::MorePushed()
+{
+    Size nSize = GetSizePixel();
+
+    //depending on the state of the button, move all elements below up/down
+    long nPixel = 85;
+    if (!maBtnMore.GetState())
+    {
+        nPixel *= -1;
+        maBtnRowHeader.Hide();
+        maBtnColHeader.Hide();
+        maBtnPrintArea.Hide();
+        maBtnCriteria.Hide();
+    }
+    else
+    {
+        maBtnRowHeader.Show();
+        maBtnColHeader.Show();
+        maBtnPrintArea.Show();
+        maBtnCriteria.Show();
+    }
+    nSize.Height() += nPixel;
+    SetSizePixel(nSize);
+    MoveWindow(maBtnAdd, nPixel);
+    MoveWindow(maBtnCancel, nPixel);
+    MoveWindow(maFlDiv, nPixel);
+}
+
 IMPL_LINK( ScNameDefDlg, CancelBtnHdl, void*, EMPTYARG)
 {
     CancelPushed();
@@ -255,3 +303,9 @@ IMPL_LINK( ScNameDefDlg, AssignGetFocusHdl, void *, EMPTYARG )
     EdModifyHdl( &maEdRange );
     return 0;
 }
+
+IMPL_LINK( ScNameDefDlg, MoreBtnHdl, void*, EMPTYARG)
+{
+    MorePushed();
+    return 0;
+}
diff --git a/sc/source/ui/src/namedefdlg.src b/sc/source/ui/src/namedefdlg.src
index 1e432cd..8022a4e 100644
--- a/sc/source/ui/src/namedefdlg.src
+++ b/sc/source/ui/src/namedefdlg.src
@@ -7,24 +7,30 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     HelpId = CMD_FID_ADD_NAME ;
     Hide = TRUE ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 200 , 100 ) ;
+    Size = MAP_APPFONT ( 200 , 120 ) ;
     Text [ en-US ] = "Define Name" ;
     Moveable = TRUE ;
     Closeable = TRUE;
     PushButton BTN_ADD
     {
-        Pos = MAP_APPFONT( 110, 80 );
+        Pos = MAP_APPFONT( 110, 100 );
         Size = MAP_APPFONT( 40, 14 );
         TabStop = TRUE;
         Text [en-US] = "Add";
     };
     PushButton BTN_CANCEL
     {
-        Pos = MAP_APPFONT( 155, 80 );
+        Pos = MAP_APPFONT( 155, 100 );
         Size = MAP_APPFONT ( 40, 14 );
         TabStop = TRUE;
         Text [en-US] = "Cancel";
     };
+    CheckBox BTN_MORE
+    {
+        Pos = MAP_APPFONT( 6, 82 );
+        Size = MAP_APPFONT( 60, 14 );
+        Text [en-US] = "RangeOptions";
+    };
     FixedText FT_INFO
     {
         Pos = MAP_APPFONT( 6, 6 );
@@ -72,7 +78,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     CheckBox BTN_PRINTAREA
     {
         HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_PRINTAREA";
-        Pos = MAP_APPFONT ( 6 , 208 ) ;
+        Pos = MAP_APPFONT ( 6 , 100 ) ;
         Size = MAP_APPFONT ( 80 , 14 ) ;
         Text [ en-US ] = "~Print range" ;
         TabStop = TRUE ;
@@ -80,7 +86,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     CheckBox BTN_CRITERIA
     {
         HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_CRITERIA";
-        Pos = MAP_APPFONT ( 6 , 223 ) ;
+        Pos = MAP_APPFONT ( 6 , 118 ) ;
         Size = MAP_APPFONT ( 60 , 14 ) ;
         Text [ en-US ] = "~Filter" ;
         TabStop = TRUE ;
@@ -88,7 +94,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     CheckBox BTN_ROWHEADER
     {
         HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_ROWHEADER";
-        Pos = MAP_APPFONT ( 110, 223 ) ;
+        Pos = MAP_APPFONT ( 110, 118 ) ;
         Size = MAP_APPFONT ( 82 , 14 ) ;
         Text [ en-US ] = "Repeat ~row" ;
         TabStop = TRUE ;
@@ -96,7 +102,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     CheckBox BTN_COLHEADER
     {
         HelpID = "sc:CheckBox:RID_SCDLG_NAMES:BTN_COLHEADER";
-        Pos = MAP_APPFONT ( 110 , 208 ) ;
+        Pos = MAP_APPFONT ( 110 , 100 ) ;
         Size = MAP_APPFONT ( 82 , 14 ) ;
         Text [ en-US ] = "Repeat ~column" ;
         TabStop = TRUE ;
@@ -111,7 +117,7 @@ ModelessDialog RID_SCDLG_NAMES_DEFINE
     };
     FixedLine FL_DIV
     {
-        Pos = MAP_APPFONT( 0, 75 );
+        Pos = MAP_APPFONT( 0, 95 );
         Size = MAP_APPFONT(200, 3 );
     };
 
commit 684b53cfcfa7ec9978426a13714471d2b8af6ce7
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 06:35:24 2011 +0100

    ManageNames: use a more modern looking button for RangeOptions

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 1751dfb..6a9523f 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -78,8 +78,8 @@ private:
     PushButton      maBtnDelete;
     PushButton      maBtnSelect;
     PushButton      maBtnOk;
-    PushButton    maBtnCancel;
-    MoreButton      maBtnMore;
+    PushButton      maBtnCancel;
+    DisclosureButton maBtnMore;
     FixedText       maFtInfo;
 
     const String    mErrMsgInvalidSym;
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 272b9cb..46970a4 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -158,11 +158,6 @@ void ScNameDlg::Init()
     maBtnColHeader.Hide();
     maBtnRowHeader.Hide();
 
-    maBtnMore.AddWindow( &maBtnCriteria );
-    maBtnMore.AddWindow( &maBtnPrintArea );
-    maBtnMore.AddWindow( &maBtnColHeader );
-    maBtnMore.AddWindow( &maBtnRowHeader );
-
     // Initialize scope list.
     maLbScope.InsertEntry(maGlobalNameStr);
     maLbScope.SelectEntryPos(0);
@@ -495,12 +490,27 @@ void MoveWindow( Window& rButton, long nPixel)
 
 void ScNameDlg::MorePushed()
 {
+    Size nSize = GetSizePixel();
+
     //depending on the state of the button, move all elements below up/down
     long nPixel = 85;
     if (!maBtnMore.GetState())
     {
         nPixel *= -1;
+        maBtnRowHeader.Hide();
+        maBtnColHeader.Hide();
+        maBtnPrintArea.Hide();
+        maBtnCriteria.Hide();
+    }
+    else
+    {
+        maBtnRowHeader.Show();
+        maBtnColHeader.Show();
+        maBtnPrintArea.Show();
+        maBtnCriteria.Show();
     }
+    nSize.Height() += nPixel;
+    SetSizePixel(nSize);
     MoveWindow(maBtnAdd, nPixel);
     MoveWindow(maBtnDelete, nPixel);
     MoveWindow(maBtnHelp, nPixel);
diff --git a/sc/source/ui/src/namedlg.src b/sc/source/ui/src/namedlg.src
index ce79e48..b97ab9f 100644
--- a/sc/source/ui/src/namedlg.src
+++ b/sc/source/ui/src/namedlg.src
@@ -131,14 +131,12 @@ ModelessDialog RID_SCDLG_NAMES
         TabStop = TRUE ;
         QuickHelpText [ en-US ] = "Shrink" ;
     };
-    MoreButton BTN_MORE
+    CheckBox BTN_MORE
     {
         HelpID = "sc:MoreButton:RID_SCDLG_NAMES:BTN_MORE";
         Pos = MAP_APPFONT ( 6 , 185 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
-        TabStop = TRUE ;
-        MapUnit = MAP_APPFONT ;
-        Delta = 41 ;
+        Text [en-US] = "Range Options";
     };
     FixedLine FL_DIV
     {
commit c0d8d83b9d03f3c6b902221062047096544c99a3
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 06:07:34 2011 +0100

    fix out of bounds access in printfunc.cxx

diff --git a/sc/source/ui/view/pfuncache.cxx b/sc/source/ui/view/pfuncache.cxx
index 28c099e..1ddedff 100644
--- a/sc/source/ui/view/pfuncache.cxx
+++ b/sc/source/ui/view/pfuncache.cxx
@@ -170,6 +170,8 @@ SCTAB ScPrintFuncCache::GetTabForPage( long nPage ) const
     SCTAB nTab = 0;
     while ( nTab < nTabCount && nPage >= nPages[nTab] )
         nPage -= nPages[nTab++];
+    if (nTab >= nTabCount)
+        nTab = nTabCount - 1;
     return nTab;
 }
 
commit 1d2142fb962e7ff0b3f638fb90c1ea63372fe13c
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 05:03:51 2011 +0100

    ManageNames: add table to "Paste Names" dialog

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 9f29bfe..8157929 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -467,8 +467,8 @@ public:
     SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
     SC_DLLPUBLIC void SetAllTabRangeNames(const ScRangeName::TabNameCopyMap& rRangeNames);
     SC_DLLPUBLIC void SetAllRangeNames( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap);
-    void GetTabRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
-    void GetRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
+    SC_DLLPUBLIC void GetTabRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
+    SC_DLLPUBLIC void GetRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
     SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
     SC_DLLPUBLIC ScRangeName* GetRangeName() const;
     void SetRangeName(SCTAB nTab, ScRangeName* pNew);
diff --git a/sc/inc/rangenam.hxx b/sc/inc/rangenam.hxx
index 04a77c4..df161a1 100644
--- a/sc/inc/rangenam.hxx
+++ b/sc/inc/rangenam.hxx
@@ -199,7 +199,7 @@ public:
     typedef DataType::iterator iterator;
 
     ScRangeName();
-    ScRangeName(const ScRangeName& r);
+    SC_DLLPUBLIC ScRangeName(const ScRangeName& r);
 
     SC_DLLPUBLIC const ScRangeData* findByRange(const ScRange& rRange) const;
     SC_DLLPUBLIC ScRangeData* findByName(const rtl::OUString& rName);
diff --git a/sc/inc/scabstdlg.hxx b/sc/inc/scabstdlg.hxx
index 43e674e..1476982 100644
--- a/sc/inc/scabstdlg.hxx
+++ b/sc/inc/scabstdlg.hxx
@@ -417,8 +417,7 @@ public:
 
     virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, sal_uInt16 nFlags, int nId ) = 0; //add for ScNameCreateDlg
 
-    virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
-                                                            const ScRangeName* pLocalList, int nId , bool bInsList=true ) = 0;
+    virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, ScDocShell* pShell, int nId , bool bInsList=true ) = 0; // add for ScNamePasteDlg
 
     virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
                                                                 const SfxItemSet&   rArgSet, sal_uInt16 nSourceTab , int nId ) = 0;
diff --git a/sc/source/ui/attrdlg/scdlgfact.cxx b/sc/source/ui/attrdlg/scdlgfact.cxx
index 11ba373..66e773d 100644
--- a/sc/source/ui/attrdlg/scdlgfact.cxx
+++ b/sc/source/ui/attrdlg/scdlgfact.cxx
@@ -1136,14 +1136,13 @@ AbstractScNameCreateDlg * ScAbstractDialogFactory_Impl::CreateScNameCreateDlg (
 
 
 
-AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList,
-                                                            const ScRangeName* pLocalList, int nId , bool bInsList )
+AbstractScNamePasteDlg * ScAbstractDialogFactory_Impl::CreateScNamePasteDlg ( Window * pParent, ScDocShell* pShell, int nId , bool bInsList )
 {
     ScNamePasteDlg * pDlg=NULL;
     switch ( nId )
     {
         case RID_SCDLG_NAMES_PASTE :
-            pDlg = new ScNamePasteDlg( pParent, pList, pLocalList, bInsList );
+            pDlg = new ScNamePasteDlg( pParent, pShell, bInsList );
             break;
         default:
             break;
diff --git a/sc/source/ui/attrdlg/scdlgfact.hxx b/sc/source/ui/attrdlg/scdlgfact.hxx
index 33a6a56..f864840 100644
--- a/sc/source/ui/attrdlg/scdlgfact.hxx
+++ b/sc/source/ui/attrdlg/scdlgfact.hxx
@@ -485,8 +485,7 @@ public:
 
     virtual AbstractScNameCreateDlg * CreateScNameCreateDlg ( Window * pParent, sal_uInt16 nFlags, int nId ); //add for ScNameCreateDlg
 
-    virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, const ScRangeName* pList, //add for ScNamePasteDlg
-                                                            const ScRangeName* pLocalList, int nId , bool bInsList=true );
+    virtual AbstractScNamePasteDlg * CreateScNamePasteDlg ( Window * pParent, ScDocShell* pShell, int nId , bool bInsList=true ); //add for ScNamePasteDlg
 
     virtual AbstractScPivotFilterDlg * CreateScPivotFilterDlg ( Window* pParent, //add for ScPivotFilterDlg
                                                                 const SfxItemSet&   rArgSet, sal_uInt16 nSourceTab , int nId );
diff --git a/sc/source/ui/inc/miscdlgs.hrc b/sc/source/ui/inc/miscdlgs.hrc
index a281ae9..420e0fa 100644
--- a/sc/source/ui/inc/miscdlgs.hrc
+++ b/sc/source/ui/inc/miscdlgs.hrc
@@ -94,6 +94,8 @@
 #define BTN_CLOSE       60
 #define BTN_PASTE       61
 #define BTN_PASTE_ALL   62
+#define CTRL_TABLE      63
+#define FL_DIV          64
 
 // Tabelle einfuegen/loeschen
 #define FT_DEST         1
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index c672068..1751dfb 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -34,7 +34,6 @@
 #include <vcl/group.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/lstbox.hxx>
-#include <vcl/ctrl.hxx>
 
 #include "rangenam.hxx"
 #include "anyrefdg.hxx"
@@ -50,14 +49,6 @@ class ScViewData;
 class ScDocument;
 
 
-
-class ScRangeManagerCtrl : public Control
-{
-public:
-    ScRangeManagerCtrl(Window* pParent, const ScResId& rResId):
-        Control( pParent, rResId) {}
-};
-
 //==================================================================
 
 //logic behind the manage names dialog
diff --git a/sc/source/ui/inc/namemgrtable.hxx b/sc/source/ui/inc/namemgrtable.hxx
index a7beab0..036627c 100644
--- a/sc/source/ui/inc/namemgrtable.hxx
+++ b/sc/source/ui/inc/namemgrtable.hxx
@@ -27,8 +27,14 @@
  */
 #include <svtools/headbar.hxx>
 #include <svtools/svtabbx.hxx>
+#include <vcl/ctrl.hxx>
+
+#include "scresid.hxx"
 
 #include <vector>
+#include <boost/ptr_container/ptr_map.hpp>
+
+class ScRangeName;
 
 struct ScRangeNameLine
 {
@@ -37,6 +43,16 @@ struct ScRangeNameLine
     rtl::OUString aScope;
 };
 
+/** Implements the Control behind the table
+ *  It controls the size of the table
+ */
+class ScRangeManagerCtrl : public Control
+{
+public:
+    ScRangeManagerCtrl(Window* pParent, const ScResId& rResId):
+        Control( pParent, rResId) {}
+};
+
 //Implements the table for the manage names dialog
 //TODO: cache the lines for performance improvements
 //otherwise handling of a large set of range names might get extremely slow
diff --git a/sc/source/ui/inc/namepast.hxx b/sc/source/ui/inc/namepast.hxx
index c94e3dc..1da0790 100644
--- a/sc/source/ui/inc/namepast.hxx
+++ b/sc/source/ui/inc/namepast.hxx
@@ -33,23 +33,34 @@
 #include <vcl/button.hxx>
 #include <vcl/fixed.hxx>
 #include <vcl/lstbox.hxx>
+#include "namemgrtable.hxx"
 
 #include <vector>
 
 #include "scui_def.hxx"
 class ScRangeName;
+class ScDocShell;
 
 class ScNamePasteDlg : public ModalDialog
 {
     DECL_LINK( ButtonHdl, Button * );
 
-protected:
+private:
     HelpButton      maHelpButton;
     PushButton      maBtnClose;
     PushButton      maBtnPaste;
     PushButton      maBtnPasteAll;
+    FixedLine       maFlDiv;
+
+    ScRangeManagerCtrl maCtrl;
+
+    ScRangeManagerTable* mpTable;
+
+    std::vector<rtl::OUString> maSelectedNames;
 public:
-    ScNamePasteDlg( Window * pParent, const ScRangeName* pList, const ScRangeName* pLocalList, bool bInsList=true );
+    ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool bInsList=true );
+
+    virtual ~ScNamePasteDlg();
 
     std::vector<rtl::OUString> GetSelectedNames() const;
     bool            IsAllSelected() const;
diff --git a/sc/source/ui/namedlg/namepast.cxx b/sc/source/ui/namedlg/namepast.cxx
index d0e1b3e..7db6abf 100644
--- a/sc/source/ui/namedlg/namepast.cxx
+++ b/sc/source/ui/namedlg/namepast.cxx
@@ -37,19 +37,34 @@
 
 #include "namepast.hxx"
 #include "scresid.hxx"
+#include "docsh.hxx"
 #include "miscdlgs.hrc"
 #include "rangenam.hxx"
 
 
 //==================================================================
 
-ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, const ScRangeName* pLocalList, bool bInsList )
+ScNamePasteDlg::ScNamePasteDlg( Window * pParent, ScDocShell* pShell, bool bInsList )
     : ModalDialog( pParent, ScResId( RID_SCDLG_NAMES_PASTE ) ),
     maHelpButton     ( this, ScResId( BTN_HELP ) ),
     maBtnClose       ( this, ScResId( BTN_CLOSE ) ),
     maBtnPaste       ( this, ScResId( BTN_PASTE ) ),
-    maBtnPasteAll    ( this, ScResId( BTN_PASTE_ALL ) )
+    maBtnPasteAll    ( this, ScResId( BTN_PASTE_ALL ) ),
+    maFlDiv          ( this, ScResId( FL_DIV ) ),
+    maCtrl           ( this, ScResId( CTRL_TABLE ) )
 {
+    ScDocument* pDoc = pShell->GetDocument();
+    std::map<rtl::OUString, ScRangeName*> aCopyMap;
+    boost::ptr_map<rtl::OUString, ScRangeName> aRangeMap;
+    pDoc->GetRangeNameMap(aCopyMap);
+    std::map<rtl::OUString, ScRangeName*>::iterator itr = aCopyMap.begin(), itrEnd = aCopyMap.end();
+    for (; itr != itrEnd; ++itr)
+    {
+        rtl::OUString aTemp(itr->first);
+        aRangeMap.insert(aTemp, new ScRangeName(*itr->second));
+    }
+
+    mpTable = new ScRangeManagerTable(&maCtrl, aRangeMap);
 
     maBtnPaste.SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl) );
     maBtnPasteAll.SetClickHdl( LINK( this, ScNamePasteDlg, ButtonHdl));
@@ -58,6 +73,11 @@ ScNamePasteDlg::ScNamePasteDlg( Window * pParent, const ScRangeName* pList, cons
     FreeResource();
 }
 
+ScNamePasteDlg::~ScNamePasteDlg()
+{
+    delete mpTable;
+}
+
 //------------------------------------------------------------------
 
 IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
@@ -68,6 +88,12 @@ IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
     }
     else if( pButton == &maBtnPaste )
     {
+        std::vector<ScRangeNameLine> aSelectedLines = mpTable->GetSelectedEntries();
+        for (std::vector<ScRangeNameLine>::const_iterator itr = aSelectedLines.begin();
+                itr != aSelectedLines.end(); ++itr)
+        {
+            maSelectedNames.push_back(itr->aName);
+        }
         EndDialog( BTN_PASTE_NAME );
     }
     else if( pButton == &maBtnClose )
@@ -81,9 +107,7 @@ IMPL_LINK( ScNamePasteDlg, ButtonHdl, Button *, pButton )
 
 std::vector<rtl::OUString> ScNamePasteDlg::GetSelectedNames() const
 {
-    std::vector<rtl::OUString> aSelectedNames;
-    //aSelectedNames.push_back(aNameList.GetSelectEntry());
-    return aSelectedNames;
+    return maSelectedNames;
 }
 
 bool ScNamePasteDlg::IsAllSelected() const
diff --git a/sc/source/ui/src/miscdlgs.src b/sc/source/ui/src/miscdlgs.src
index 16e0a47..722d309 100644
--- a/sc/source/ui/src/miscdlgs.src
+++ b/sc/source/ui/src/miscdlgs.src
@@ -1413,35 +1413,48 @@ ModalDialog RID_SCDLG_NAMES_PASTE
     OutputSize = TRUE ;
     HelpId = CMD_FID_INSERT_NAME ;
     SVLook = TRUE ;
-    Size = MAP_APPFONT ( 228 , 140 ) ;
+    Size = MAP_APPFONT ( 228 , 160 ) ;
     Moveable = TRUE ;
+    Closeable = TRUE;
     HelpButton BTN_HELP
     {
-        Pos = MAP_APPFONT ( 6, 120 ) ;
+        Pos = MAP_APPFONT ( 6, 140 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
     };
     PushButton BTN_PASTE
     {
-        Pos = MAP_APPFONT ( 172 , 90 ) ;
+        Pos = MAP_APPFONT ( 172 , 110 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [en-US] = "Paste";
     };
     PushButton BTN_PASTE_ALL
     {
-        Pos = MAP_APPFONT ( 6 , 90 ) ;
+        Pos = MAP_APPFONT ( 6 , 110 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [en-US] = "Paste All";
     };
     PushButton BTN_CLOSE
     {
-        Pos = MAP_APPFONT ( 172 , 120 ) ;
+        Pos = MAP_APPFONT ( 172 , 140 ) ;
         Size = MAP_APPFONT ( 50 , 14 ) ;
         TabStop = TRUE ;
         Text [en-US] = "Close";
     };
+    Control CTRL_TABLE
+    {
+        Pos = MAP_APPFONT( 6, 6 );
+        Size = MAP_APPFONT( 210, 100 );
+        Border = TRUE;
+        DialogControl = TRUE;
+    };
+    FixedLine FL_DIV
+    {
+        Pos = MAP_APPFONT( 0, 132 );
+        Size = MAP_APPFONT( 228, 132 );
+    };
     Text [ en-US ] = "Paste Names" ;
 };
 
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index a9ca03b..a8f5cba 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -1819,12 +1819,10 @@ void ScCellShell::ExecuteEdit( SfxRequest& rReq )
 
         case FID_INSERT_NAME:
             {
-                ScDocument*     pDoc = GetViewData()->GetDocument();
-                SCTAB nTab = GetViewData()->GetTabNo();
                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
-                AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), pDoc->GetRangeName(), pDoc->GetRangeName(nTab), RID_SCDLG_NAMES_PASTE );
+                AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pTabViewShell->GetDialogParent(), GetViewData()->GetDocShell(), RID_SCDLG_NAMES_PASTE );
                 OSL_ENSURE(pDlg, "Dialog create fail!");
                 switch( pDlg->Execute() )
                 {
diff --git a/sc/source/ui/view/editsh.cxx b/sc/source/ui/view/editsh.cxx
index c6fd63c..15bc31e 100644
--- a/sc/source/ui/view/editsh.cxx
+++ b/sc/source/ui/view/editsh.cxx
@@ -421,12 +421,10 @@ void ScEditShell::Execute( SfxRequest& rReq )
 
         case FID_INSERT_NAME:
             {
-                ScDocument*     pDoc = pViewData->GetDocument();
-                SCTAB nTab = pViewData->GetTabNo();
                 ScAbstractDialogFactory* pFact = ScAbstractDialogFactory::Create();
                 OSL_ENSURE(pFact, "ScAbstractFactory create fail!");
 
-                AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pDoc->GetRangeName(), pDoc->GetRangeName(nTab), RID_SCDLG_NAMES_PASTE, false );
+                AbstractScNamePasteDlg* pDlg = pFact->CreateScNamePasteDlg( pViewData->GetDialogParent(), pViewData->GetDocShell(), RID_SCDLG_NAMES_PASTE, false );
                 OSL_ENSURE(pDlg, "Dialog create fail!");
                 short nRet = pDlg->Execute();
                 // pDlg is needed below
commit 7acefae208e815f4abcb19fdd034e52f6f4da9b8
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 01:46:48 2011 +0100

    ManageNames: need a virtual destructor here

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index d9bd344..c672068 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -151,7 +151,7 @@ public:
                     ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
                                ScViewData*      ptrViewData,
                                const ScAddress& aCursorPos );
-                    ~ScNameDlg();
+    virtual         ~ScNameDlg();
 
     virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc );
     virtual sal_Bool    IsRefInputMode() const;
commit 332ea906f34f2693d19d8bd9bdc2fecc11b1dd3e
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Tue Nov 22 00:41:07 2011 +0100

    ManageNames: don't change selection after user input

diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index 85a7ac9..d9bd344 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -103,6 +103,8 @@ private:
     const ScAddress maCursorPos;
     Selection       maCurSel;
 
+    bool mbNeedUpdate;
+
     typedef boost::ptr_map<rtl::OUString, ScRangeName> RangeNameContainer;
 
     RangeNameContainer maRangeMap;
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index 449fc8f..272b9cb 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -109,7 +109,8 @@ ScNameDlg::ScNameDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
     //
     mpViewData       ( ptrViewData ),
     mpDoc            ( ptrViewData->GetDocument() ),
-    maCursorPos      ( aCursorPos )
+    maCursorPos      ( aCursorPos ),
+    mbNeedUpdate     ( true )
 {
     Init();
     FreeResource();
@@ -418,6 +419,7 @@ void ScNameDlg::NameModified()
     if (pData)
     {
         pOldRangeName->erase(*pData);
+        mbNeedUpdate = false;
         mpRangeManagerTable->DeleteSelectedEntries();
         RangeType nType = RT_NAME |
             (maBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
@@ -432,11 +434,18 @@ void ScNameDlg::NameModified()
         aLine.aExpression = aExpr;
         aLine.aScope = aNewScope;
         mpRangeManagerTable->addEntry(aLine);
+        mbNeedUpdate = true;
     }
 }
 
 void ScNameDlg::SelectionChanged()
 {
+    //don't update if we have just modified due to user input
+    if (!mbNeedUpdate)
+    {
+        return;
+    }
+
     if (mpRangeManagerTable->IsMultiSelection())
     {
         maEdName.Disable();
commit b1097c47695210f8824dcc4fc456b95897fc3972
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 21 11:19:38 2011 +0100

    ManageNames: add undo to Define Names dialog

diff --git a/sc/inc/undorangename.hxx b/sc/inc/undorangename.hxx
index f1c1668..df6ff23 100644
--- a/sc/inc/undorangename.hxx
+++ b/sc/inc/undorangename.hxx
@@ -61,6 +61,25 @@ private:
     boost::ptr_map<rtl::OUString, ScRangeName> maNewNames;
 };
 
+class ScUndoAddRangeData : public ScSimpleUndo
+{
+public:
+    // nTab = -1 for global range names
+    ScUndoAddRangeData(ScDocShell* pDocSh, ScRangeData* pRangeData, SCTAB nTab);
+
+    virtual ~ScUndoAddRangeData();
+
+    virtual void Undo();
+    virtual void Redo();
+    virtual void Repeat(SfxRepeatTarget& rTarget);
+    virtual sal_Bool CanRepeat(SfxRepeatTarget& rTarget) const;
+    virtual String GetComment() const;
+
+private:
+    ScRangeData* mpRangeData;
+    SCTAB mnTab;
+};
+
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/inc/namedefdlg.hxx b/sc/source/ui/inc/namedefdlg.hxx
index 5cbf555..14ba919 100644
--- a/sc/source/ui/inc/namedefdlg.hxx
+++ b/sc/source/ui/inc/namedefdlg.hxx
@@ -37,6 +37,7 @@
 
 class ScRangeName;
 class ScDocument;
+class ScDocShell;
 
 class ScNameDefDlg : public ScAnyRefDlg
 {
@@ -63,6 +64,7 @@ private:
 
     bool mbUndo; //if true we need to add an undo action after creating a range name
     ScDocument* mpDoc;
+    ScDocShell* mpDocShell;
 
     ScAddress maCursorPos;
     rtl::OUString maGlobalNameStr;
@@ -85,7 +87,7 @@ protected:
 
 public:
     ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
-                    ScDocument* pDoc, std::map<rtl::OUString, ScRangeName*> aRangeMap,
+                    ScDocShell* pDocShell, std::map<rtl::OUString, ScRangeName*> aRangeMap,
                     const ScAddress& aCursorPos, const bool bUndo);
 
     virtual void    SetReference( const ScRange& rRef, ScDocument* pDoc );
diff --git a/sc/source/ui/inc/namedlg.hxx b/sc/source/ui/inc/namedlg.hxx
index a5b5461..85a7ac9 100644
--- a/sc/source/ui/inc/namedlg.hxx
+++ b/sc/source/ui/inc/namedlg.hxx
@@ -117,6 +117,7 @@ private:
     bool IsNameValid();
     bool IsFormulaValid();
 
+    ScRangeName* GetRangeName(const rtl::OUString& rScope);
 
     bool AddPushed();
     void RemovePushed();
diff --git a/sc/source/ui/namedlg/namedefdlg.cxx b/sc/source/ui/namedlg/namedefdlg.cxx
index bc08852..e1b2883 100644
--- a/sc/source/ui/namedlg/namedefdlg.cxx
+++ b/sc/source/ui/namedlg/namedefdlg.cxx
@@ -7,6 +7,7 @@
 #include "globalnames.hxx"
 #include "rangenam.hxx"
 #include "reffact.hxx"
+#include "undorangename.hxx"
 
 // defines -------------------------------------------------------------------
 
@@ -18,7 +19,7 @@
 #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
 
 ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParent,
-        ScDocument* pDoc, std::map<rtl::OUString, ScRangeName*> aRangeMap,
+        ScDocShell* pDocShell, std::map<rtl::OUString, ScRangeName*> aRangeMap,
         const ScAddress& aCursorPos, const bool bUndo ) :
     ScAnyRefDlg( pB, pCW, pParent, RID_SCDLG_NAMES_DEFINE ),
     maBtnAdd( this, ScResId( BTN_ADD ) ),
@@ -37,7 +38,8 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     maBtnPrintArea( this, ScResId( BTN_PRINTAREA ) ),
     maBtnCriteria( this, ScResId( BTN_CRITERIA ) ),
     mbUndo( bUndo ),
-    mpDoc( pDoc ),
+    mpDoc( pDocShell->GetDocument() ),
+    mpDocShell ( pDocShell ),
     maCursorPos( aCursorPos ),
     maGlobalNameStr( ResId::toString( ScResId( STR_GLOBAL_SCOPE ) ) ),
     maRangeMap( aRangeMap )
@@ -45,11 +47,11 @@ ScNameDefDlg::ScNameDefDlg( SfxBindings* pB, SfxChildWindow* pCW, Window* pParen
     // Initialize scope list.
     maLbScope.InsertEntry(maGlobalNameStr);
     maLbScope.SelectEntryPos(0);
-    SCTAB n = pDoc->GetTableCount();
+    SCTAB n = mpDoc->GetTableCount();
     for (SCTAB i = 0; i < n; ++i)
     {
         rtl::OUString aTabName;
-        pDoc->GetName(i, aTabName);
+        mpDoc->GetName(i, aTabName);
         maLbScope.InsertEntry(aTabName);
     }
 
@@ -159,11 +161,23 @@ void ScNameDefDlg::AddPushed()
 
                 if (mbUndo)
                 {
-                    //this means we called directly through the menu
-                    //add a new ScUndoInsertName entry to undo
-                    //
-                    //TODO:FIXME need to add the undo code here
+                    // this means we called directly through the menu
+
+                    SCTAB nTab;
+                    // if no table with that name is found, assume global range name
+                    if (!mpDoc->GetTable(aScope, nTab))
+                        nTab = -1;
+
+                    mpDocShell->GetUndoManager()->AddUndoAction(
+                            new ScUndoAddRangeData( mpDocShell, pNewEntry, nTab) );
+
+                    // set table stream invalid, otherwise RangeName won't be saved if no other
+                    // call invalidates the stream
+                    if (nTab != -1)
+                        mpDoc->SetStreamValid(nTab, false);
                 }
+                SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+                Close();
             }
             else
             {
@@ -175,8 +189,6 @@ void ScNameDefDlg::AddPushed()
             }
         }
     }
-    SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
-    Close();
 }
 
 sal_Bool ScNameDefDlg::IsRefInputMode() const
diff --git a/sc/source/ui/namedlg/namedlg.cxx b/sc/source/ui/namedlg/namedlg.cxx
index c64e034..449fc8f 100644
--- a/sc/source/ui/namedlg/namedlg.cxx
+++ b/sc/source/ui/namedlg/namedlg.cxx
@@ -55,8 +55,6 @@
 #include <memory>
 #include <iostream>
 
-using ::std::auto_ptr;
-
 // defines -------------------------------------------------------------------
 
 #define ABS_SREF          SCA_VALID \
@@ -66,27 +64,6 @@ using ::std::auto_ptr;
 #define ABS_SREF3D      ABS_SREF | SCA_TAB_3D
 #define ABS_DREF3D      ABS_DREF | SCA_TAB_3D
 
-//helper
-
-namespace {
-
-ScRangeName* GetRangeName(const rtl::OUString& rTableName, ScDocument* pDoc)
-{
-    ScRangeName* pRangeName;
-    SCTAB nTab;
-    if ( pDoc->GetTable(rTableName, nTab))
-    {
-        pRangeName = pDoc->GetRangeName(nTab);
-    }
-    else
-    {
-        pRangeName = pDoc->GetRangeName();
-    }
-    return pRangeName;
-}
-
-}
-
 //logic
 
 #define ERRORBOX(s) ErrorBox(this,WinBits(WB_OK|WB_DEF_OK),s).Execute();
@@ -153,11 +130,12 @@ void ScNameDlg::Init()
     //init UI
     std::map<rtl::OUString, ScRangeName*> aRangeMap;
     mpDoc->GetRangeNameMap(aRangeMap);
-    RangeNameContainer::iterator itr = maRangeMap.begin(), itrEnd = maRangeMap.end();
+    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));
+        std::cout << "RangeName: " << rtl::OUStringToOString(aTemp, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
     }
 
     mpRangeManagerTable = new ScRangeManagerTable(&maNameMgrCtrl, maRangeMap);
@@ -237,6 +215,7 @@ void ScNameDlg::SetReference( const ScRange& rRef, ScDocument* pDocP )
 
 sal_Bool ScNameDlg::Close()
 {
+    std::cout << "Ok Pushed!" << std::endl;
     ScDocFunc aFunc(*mpViewData->GetDocShell());
     aFunc.ModifyAllRangeNames(maRangeMap);
     return DoClose( ScNameDlgWrapper::GetChildWindowId() );
@@ -265,16 +244,12 @@ bool ScNameDlg::IsNameValid()
 {
     rtl::OUString aScope = maLbScope.GetSelectEntry();
     rtl::OUString aName = maEdName.GetText();
+    aName = aName.trim();
 
-    ScRangeName* pRangeName = NULL;
-    if(aScope == maGlobalNameStr)
-    {
-        pRangeName = maRangeMap.find(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME)))->second;
-    }
-    else
-    {
-        pRangeName = maRangeMap.find(aScope)->second;
-    }
+    if (!aName.getLength())
+        return false;
+
+    ScRangeName* pRangeName = GetRangeName( aScope );
 
     if (!ScRangeData::IsNameValid( aName, mpDoc ))
     {
@@ -298,6 +273,14 @@ bool ScNameDlg::IsFormulaValid()
     return true;
 }
 
+ScRangeName* ScNameDlg::GetRangeName(const rtl::OUString& rScope)
+{
+    if (rScope == maGlobalNameStr)
+        return maRangeMap.find(rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME)))->second;
+    else
+        return maRangeMap.find(rScope)->second;
+}
+
 //updates the table and the buttons
 void ScNameDlg::UpdateNames()
 {
@@ -329,7 +312,7 @@ void ScNameDlg::CalcCurTableAssign( String& aAssign, ScRangeData* pRangeData )
 
 void ScNameDlg::ShowOptions(const ScRangeNameLine& rLine)
 {
-    ScRangeName* pRangeName = GetRangeName(rLine.aScope, mpDoc);
+    ScRangeName* pRangeName = GetRangeName(rLine.aScope);
     ScRangeData* pData = pRangeName->findByName(rLine.aName);
     if (pData)
     {
@@ -356,7 +339,7 @@ bool ScNameDlg::AddPushed()
 
     rtl::OUString aScope = maLbScope.GetSelectEntry();
     rtl::OUString aExpr = maEdAssign.GetText();
-    ScRangeName* pRangeName = GetRangeName(aScope, mpDoc);
+    ScRangeName* pRangeName = GetRangeName(aScope);
 
     RangeType nType = RT_NAME |
          (maBtnRowHeader.IsChecked() ? RT_ROWHEADER : RangeType(0))
@@ -394,7 +377,7 @@ void ScNameDlg::RemovePushed()
     mpRangeManagerTable->DeleteSelectedEntries();
     for (std::vector<ScRangeNameLine>::iterator itr = maEntries.begin(); itr != maEntries.end(); ++itr)
     {
-        ScRangeName* pRangeName = GetRangeName( itr->aScope, mpDoc );
+        ScRangeName* pRangeName = GetRangeName(itr->aScope);
         std::cout << rtl::OUStringToOString(itr->aName, RTL_TEXTENCODING_UTF8).getStr() << std::endl;
         std::cout << rtl::OUStringToOString(ScGlobal::pCharClass->upper(itr->aName), RTL_TEXTENCODING_UTF8).getStr() << std::endl;;
         ScRangeData* pData = pRangeName->findByUpperName(ScGlobal::pCharClass->upper(itr->aName));
@@ -421,12 +404,15 @@ void ScNameDlg::NameModified()
     }
 
     rtl::OUString aOldScope = aLine.aScope;
+    //empty table
+    if (aOldScope.isEmpty())
+        return;
     rtl::OUString aExpr = maEdAssign.GetText();
     rtl::OUString aNewScope = maLbScope.GetSelectEntry();
 
-    ScRangeName* pOldRangeName = GetRangeName( aOldScope, mpDoc );
+    ScRangeName* pOldRangeName = GetRangeName( aOldScope );
     ScRangeData* pData = pOldRangeName->findByUpperName( ScGlobal::pCharClass->upper(aOldName) );
-    ScRangeName* pNewRangeName = GetRangeName( aNewScope, mpDoc );
+    ScRangeName* pNewRangeName = GetRangeName( aNewScope );
     OSL_ENSURE(pData, "model and table should be in sync");
     // be safe and check for range data
     if (pData)
diff --git a/sc/source/ui/undo/undorangename.cxx b/sc/source/ui/undo/undorangename.cxx
index b7b1e2c..28d6043 100644
--- a/sc/source/ui/undo/undorangename.cxx
+++ b/sc/source/ui/undo/undorangename.cxx
@@ -47,7 +47,6 @@ ScUndoAllRangeNames::ScUndoAllRangeNames(
     const boost::ptr_map<rtl::OUString, ScRangeName>& rNewNames) :
     ScSimpleUndo(pDocSh)
 {
-    // Copy sheet-local names.
     std::map<rtl::OUString, ScRangeName*>::const_iterator itr, itrEnd;
     for (itr = rOldNames.begin(), itrEnd = rOldNames.end(); itr != itrEnd; ++itr)
     {
@@ -108,4 +107,64 @@ void ScUndoAllRangeNames::DoChange(const boost::ptr_map<rtl::OUString, ScRangeNa
     SFX_APP()->Broadcast(SfxSimpleHint(SC_HINT_AREAS_CHANGED));
 }
 
+ScUndoAddRangeData::ScUndoAddRangeData(ScDocShell* pDocSh, ScRangeData* pRangeData, SCTAB nTab) :
+    ScSimpleUndo(pDocSh),
+    mpRangeData(new ScRangeData(*pRangeData)),
+    mnTab(nTab)
+{
+
+}
+
+ScUndoAddRangeData::~ScUndoAddRangeData()
+{
+    delete mpRangeData;
+}
+
+void ScUndoAddRangeData::Undo()
+{
+    ScDocument* pDoc = pDocShell->GetDocument();
+    ScRangeName* pRangeName = NULL;
+    if (mnTab == -1)
+    {
+        pRangeName = pDoc->GetRangeName();
+    }
+    else
+    {
+        pRangeName = pDoc->GetRangeName( mnTab );
+    }
+    pRangeName->erase(*mpRangeData);
+    SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+
+}
+
+void ScUndoAddRangeData::Redo()
+{
+    ScDocument* pDoc = pDocShell->GetDocument();
+    ScRangeName* pRangeName = NULL;
+    if (mnTab == -1)
+    {
+        pRangeName = pDoc->GetRangeName();
+    }
+    else
+    {
+        pRangeName = pDoc->GetRangeName( mnTab );
+    }
+    pRangeName->insert(new ScRangeData(*mpRangeData));
+    SFX_APP()->Broadcast( SfxSimpleHint( SC_HINT_AREAS_CHANGED ) );
+}
+
+void ScUndoAddRangeData::Repeat(SfxRepeatTarget& /*rTarget*/)
+{
+}
+
+sal_Bool ScUndoAddRangeData::CanRepeat(SfxRepeatTarget& /*rTarget*/) const
+{
+    return sal_False;
+}
+
+String ScUndoAddRangeData::GetComment() const
+{
+    return ScGlobal::GetRscString(STR_UNDO_RANGENAMES);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/view/tabvwshc.cxx b/sc/source/ui/view/tabvwshc.cxx
index 2dca976..5f648fb 100644
--- a/sc/source/ui/view/tabvwshc.cxx
+++ b/sc/source/ui/view/tabvwshc.cxx
@@ -122,7 +122,7 @@ SfxModelessDialog* ScTabViewShell::CreateRefDialog(
             std::cout << "tabvwsh" << std::endl;
             std::map<rtl::OUString, ScRangeName*> aRangeMap;
             pDoc->GetRangeNameMap(aRangeMap);
-            pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData()->GetDocument(), aRangeMap,
+            pResult = new ScNameDefDlg( pB, pCW, pParent, GetViewData()->GetDocShell(), aRangeMap,
                             ScAddress( GetViewData()->GetCurX(),
                                         GetViewData()->GetCurY(),
                                         GetViewData()->GetTabNo() ), true );
commit 106f128f359deb1c9553c105eff4bf829fdd9736
Author: Markus Mohrhard <markus.mohrhard at googlemail.com>
Date:   Mon Nov 21 05:09:10 2011 +0100

    ManageNames: make global undo work again with dialog

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 3095f0c..9f29bfe 100644
--- a/sc/inc/document.hxx
+++ b/sc/inc/document.hxx
@@ -466,6 +466,7 @@ public:
      */
     SC_DLLPUBLIC void GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rRangeNames) const;
     SC_DLLPUBLIC void SetAllTabRangeNames(const ScRangeName::TabNameCopyMap& rRangeNames);
+    SC_DLLPUBLIC void SetAllRangeNames( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap);
     void GetTabRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
     void GetRangeNameMap(std::map<rtl::OUString, ScRangeName*>& rRangeName);
     SC_DLLPUBLIC ScRangeName* GetRangeName(SCTAB nTab) const;
diff --git a/sc/inc/undorangename.hxx b/sc/inc/undorangename.hxx
index 131a404..f1c1668 100644
--- a/sc/inc/undorangename.hxx
+++ b/sc/inc/undorangename.hxx
@@ -31,6 +31,7 @@
 
 #include "undobase.hxx"
 #include "rangenam.hxx"
+#include <boost/ptr_container/ptr_map.hpp>
 
 class ScDocShell;
 
@@ -41,10 +42,8 @@ class ScUndoAllRangeNames : public ScSimpleUndo
 {
 public:
     ScUndoAllRangeNames(ScDocShell* pDocSh,
-                        const ScRangeName* pOldGlobal,
-                        const ScRangeName* pNewGlobal,
-                        const ScRangeName::TabNameCopyMap& rOldLocal,
-                        const ScRangeName::TabNameCopyMap& rNewLocal);
+                        const std::map<rtl::OUString, ScRangeName*>& rOldNames,
+                        const boost::ptr_map<rtl::OUString, ScRangeName>& rNewNames);
 
     virtual ~ScUndoAllRangeNames();
 
@@ -55,13 +54,11 @@ public:
     virtual String GetComment() const;
 
 private:
-    void DoChange(const ScRangeName& rGlobal, const ScRangeName::TabNameMap& rLocal);
+    void DoChange(const boost::ptr_map<rtl::OUString, ScRangeName*>& rNames);
 
 private:
-    ScRangeName maOldGlobalNames;
-    ScRangeName maNewGlobalNames;
-    ScRangeName::TabNameMap maOldLocalNames;
-    ScRangeName::TabNameMap maNewLocalNames;
+    boost::ptr_map<rtl::OUString, ScRangeName> maOldNames;
+    boost::ptr_map<rtl::OUString, ScRangeName> maNewNames;
 };
 
 #endif
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 1aabd9f..d225f11 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -126,6 +126,34 @@ void ScDocument::SetAllTabRangeNames(const ScRangeName::TabNameCopyMap& rNames)
         SetRangeName(itr->first, new ScRangeName(*itr->second));
 }
 
+void ScDocument::SetAllRangeNames( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap)
+{
+    rtl::OUString aGlobalStr(RTL_CONSTASCII_USTRINGPARAM(STR_GLOBAL_RANGE_NAME));
+    boost::ptr_map<rtl::OUString,ScRangeName>::const_iterator itr = rRangeMap.begin(), itrEnd = rRangeMap.end();
+    for (; itr!=itrEnd; ++itr)
+    {
+        if (itr->first == aGlobalStr)
+        {
+            delete pRangeName;
+            const ScRangeName* pName = itr->second;
+            if (pName->empty())
+                pRangeName = NULL;
+            else
+                pRangeName = new ScRangeName( *pName );
+        }
+        else
+        {
+            const ScRangeName* pName = itr->second;
+            SCTAB nTab;
+            GetTable(itr->first, nTab);
+            if (pName->empty())
+                SetRangeName( nTab, NULL );
+            else
+                SetRangeName( nTab, new ScRangeName( *pName ) );
+        }
+    }
+}
+
 void ScDocument::GetTabRangeNameMap(std::map<rtl::OUString, ScRangeName*>& aRangeNameMap)
 {
     for (SCTAB i = 0; i < static_cast<SCTAB>(maTabs.size()); ++i)
diff --git a/sc/source/ui/docshell/docfunc.cxx b/sc/source/ui/docshell/docfunc.cxx
index 39600bd..739b973 100644
--- a/sc/source/ui/docshell/docfunc.cxx
+++ b/sc/source/ui/docshell/docfunc.cxx
@@ -74,6 +74,7 @@
 #include "drwlayer.hxx"
 #include "editutil.hxx"
 #include "globstr.hrc"
+#include "globalnames.hxx"
 #include "olinetab.hxx"
 #include "patattr.hxx"
 #include "rangenam.hxx"
@@ -4528,6 +4529,30 @@ bool ScDocFunc::SetNewRangeNames( ScRangeName* pNewRanges, bool bModifyDoc, SCTA
     return true;
 }
 
+void ScDocFunc::ModifyAllRangeNames( const boost::ptr_map<rtl::OUString, ScRangeName>& rRangeMap )
+{
+    ScDocShellModificator aModificator(rDocShell);

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list