View | Details | Raw Unified | Return to issue 124293
Collapse All | Expand All

(-)a/main/sc/inc/rangenam.hxx (-1 / +28 lines)
Lines 31-36 Link Here
31
#include "scdllapi.h"
31
#include "scdllapi.h"
32
32
33
#include <map>
33
#include <map>
34
#include <vector>
35
#include <boost/shared_ptr.hpp>
34
36
35
//------------------------------------------------------------------------
37
//------------------------------------------------------------------------
36
38
Lines 40-46 namespace rtl { Link Here
40
	class OUStringBuffer;
42
	class OUStringBuffer;
41
}
43
}
42
44
43
44
//------------------------------------------------------------------------
45
//------------------------------------------------------------------------
45
46
46
typedef sal_uInt16 RangeType;
47
typedef sal_uInt16 RangeType;
Lines 161-166 public: Link Here
161
    SCROW GetMaxRow() const;
162
    SCROW GetMaxRow() const;
162
    SC_DLLPUBLIC void SetMaxCol(SCCOL nCol);
163
    SC_DLLPUBLIC void SetMaxCol(SCCOL nCol);
163
    SCCOL GetMaxCol() const;
164
    SCCOL GetMaxCol() const;
165
166
    /** Return a string that encodes the given range name and sheet
167
        so that it can be used as argument in a SID_CURRENTCELL slot
168
        call.
169
    */
170
    static String GetScopedInternalName (const String& rsName, const SCTAB nSheet);
171
172
    /** Return a string that encodes the given range name and sheet
173
        so that it can be used as display name.
174
    */
175
    static String GetScopedDisplayName (const String& rsName, const SCTAB nSheet);
176
177
    /** Decode a string that is returned by GetScopedInternalName back
178
        into range name and sheet.
179
    */
180
    static void ParseScopedInternalName (const String& rsInternalName, String& rsOutName, SCTAB& rOutSheet);
181
182
    /** Decode a string that is returned by GetScopedDisplayName back
183
        into range name and sheet.
184
    */
185
    static void ParseScopedDisplayName (const String& rsDisplayName, String& rsOutName, SCTAB& rOutSheet);
164
};
186
};
165
187
166
inline sal_Bool ScRangeData::HasType( RangeType nType ) const
188
inline sal_Bool ScRangeData::HasType( RangeType nType ) const
Lines 223-228 public: Link Here
223
	sal_uInt16 					GetSharedMaxIndex()				{ return nSharedMaxIndex; }
245
	sal_uInt16 					GetSharedMaxIndex()				{ return nSharedMaxIndex; }
224
	void 					SetSharedMaxIndex(sal_uInt16 nInd)	{ nSharedMaxIndex = nInd; }
246
	void 					SetSharedMaxIndex(sal_uInt16 nInd)	{ nSharedMaxIndex = nInd; }
225
	sal_uInt16 					GetEntryIndex();
247
	sal_uInt16 					GetEntryIndex();
248
249
    /** Return a shared poitner to a vector whose content are the sorted
250
        display names of all valid ranges.
251
    */
252
    ::boost::shared_ptr<std::vector<String> > GetSortedRangeDisplayNames (void) const;
226
};
253
};
227
254
228
#endif
255
#endif
(-)a/main/sc/source/core/data/documen3.cxx (-1 / +3 lines)
Lines 116-122 ScRangeData* ScDocument::GetRangeAtBlock( const ScRange& rBlock, String* pName ) Link Here
116
	{
116
	{
117
		pData = pRangeName->GetRangeAtBlock( rBlock );
117
		pData = pRangeName->GetRangeAtBlock( rBlock );
118
		if (pData && pName)
118
		if (pData && pName)
119
			*pName = pData->GetName();
119
		{
120
			*pName = ScRangeData::GetScopedDisplayName(pData->GetName(), pData->GetRangeScope());
121
		}
120
	}
122
	}
121
	return pData;
123
	return pData;
122
}
124
}
(-)a/main/sc/source/core/tool/rangenam.cxx (+118 lines)
Lines 49-54 using namespace formula; Link Here
49
// ScRangeData
49
// ScRangeData
50
//========================================================================
50
//========================================================================
51
51
52
namespace
53
{
54
    static const String gsScopedDisplayNameHead = String(" (", 2);
55
    static const String gsScopedDisplayNameTail = String(")", 1);
56
}
57
58
52
// Interner ctor fuer das Suchen nach einem Index
59
// Interner ctor fuer das Suchen nach einem Index
53
60
54
ScRangeData::ScRangeData( sal_uInt16 n )
61
ScRangeData::ScRangeData( sal_uInt16 n )
Lines 732-737 ScRangeData_QsortNameCompare( const void* p1, const void* p2 ) Link Here
732
			(*(const ScRangeData**)p2)->GetName() );
739
			(*(const ScRangeData**)p2)->GetName() );
733
}
740
}
734
741
742
String ScRangeData::GetScopedInternalName (const String& rsName, const SCTAB nSheet)
743
{
744
    if (nSheet == MAXTABCOUNT)
745
        return rsName;
746
    else
747
    {
748
        String sScopedName (rsName);
749
        sScopedName.Append('_');
750
        sScopedName.Append(String::CreateFromInt32(static_cast<sal_Int32>(nSheet)));
751
        return sScopedName;
752
    }
753
}
754
755
756
757
758
String ScRangeData::GetScopedDisplayName (const String& rsName, const SCTAB nSheet)
759
{
760
    if (nSheet == MAXTABCOUNT)
761
        return rsName;
762
    else
763
    {
764
        String sScopedName (rsName);
765
        sScopedName.Append(gsScopedDisplayNameHead);
766
        sScopedName.Append(String::CreateFromInt32(static_cast<sal_Int32>(nSheet)));
767
        sScopedName.Append(gsScopedDisplayNameTail);
768
        return sScopedName;
769
    }
770
}
771
772
void ScRangeData::ParseScopedInternalName (const String& rsInternalName, String& rsOutName, SCTAB& rOutSheet)
773
{
774
    rsOutName = rsInternalName;
775
    const xub_StrLen nSeparatorIndex (rsOutName.Search('_'));
776
    rOutSheet = MAXTABCOUNT;
777
    if (nSeparatorIndex != STRING_LEN)
778
    {
779
        rOutSheet = static_cast<const SCTAB>(rsOutName.Copy(nSeparatorIndex+1).ToInt32());
780
        rsOutName = rsOutName.Copy(0, nSeparatorIndex);
781
    }
782
}
783
784
void ScRangeData::ParseScopedDisplayName (const String& rsDisplayName, String& rsOutName, SCTAB& rOutSheet)
785
{
786
    rsOutName = rsDisplayName;
787
    rOutSheet = MAXTABCOUNT;
788
789
    const xub_StrLen nScopeStart (rsOutName.Search(gsScopedDisplayNameHead));
790
    if (nScopeStart != STRING_LEN)
791
    {
792
        const xub_StrLen nTailStart (rsOutName.Len()-gsScopedDisplayNameTail.Len());
793
        if (rsOutName.Search(gsScopedDisplayNameTail, nTailStart) == nTailStart)
794
        {
795
            const String sScopeName (rsOutName.Copy(
796
                    nScopeStart+gsScopedDisplayNameHead.Len(),
797
                    nTailStart-nScopeStart-gsScopedDisplayNameHead.Len()));
798
            rOutSheet = static_cast<SCTAB>(sScopeName.ToInt32());
799
            rsOutName = rsOutName.Copy(0, nScopeStart);
800
        }
801
    }
802
}
803
804
735
805
736
//========================================================================
806
//========================================================================
737
// ScRangeName
807
// ScRangeName
Lines 939-941 void ScRangeName::UpdateTabRef(SCTAB nOldTable, sal_uInt16 nFlag, SCTAB nNewTabl Link Here
939
1009
940
1010
941
1011
1012
1013
namespace
1014
{
1015
    int compareString (const void*a, const void*b)
1016
    {
1017
        return reinterpret_cast<const String*>(a)->CompareTo(*reinterpret_cast<const String*>(b));
1018
    }
1019
}
1020
1021
::boost::shared_ptr<std::vector<String> > ScRangeName::GetSortedRangeDisplayNames (void) const
1022
{
1023
    ::boost::shared_ptr<std::vector<String> > pResult;
1024
1025
    const sal_uInt16 nCount (GetCount());
1026
    if (nCount > 0)
1027
    {
1028
        sal_uInt16 nValidCount (0);
1029
        ScRange aDummy;
1030
        for (sal_uInt16 nIndex=0; nIndex<nCount; ++nIndex)
1031
        {
1032
            const ScRangeData* pData = (*this)[nIndex];
1033
            if (pData->IsValidReference(aDummy))
1034
                ++nValidCount;
1035
        }
1036
        if (nValidCount > 0)
1037
        {
1038
            pResult.reset(new std::vector<String>());
1039
            pResult->reserve(nValidCount);
1040
            for (sal_uInt16 nReadIndex=0,nWriteIndex=0; nReadIndex<nCount; ++nReadIndex)
1041
            {
1042
                const ScRangeData* pData = (*this)[nReadIndex];
1043
                if (pData->IsValidReference(aDummy))
1044
                    pResult->push_back(
1045
                        ScRangeData::GetScopedDisplayName(pData->GetName(), pData->GetRangeScope()));
1046
            }
1047
1048
            qsort(
1049
                (void*)&pResult->front(),
1050
                pResult->size(),
1051
                sizeof(String),
1052
                compareString);
1053
        }
1054
    }
1055
1056
    return pResult;
1057
}
1058
1059
(-)a/main/sc/source/core/tool/rangeutl.cxx (-1 / +5 lines)
Lines 286-292 sal_Bool ScRangeUtil::MakeRangeFromName ( Link Here
286
		ScRangeName& rRangeNames = *(pDoc->GetRangeName());
286
		ScRangeName& rRangeNames = *(pDoc->GetRangeName());
287
		sal_uInt16		 nAt		 = 0;
287
		sal_uInt16		 nAt		 = 0;
288
288
289
		if ( rRangeNames.SearchName( rName, nAt ) )
289
        String sName;
290
        SCTAB nSheet;
291
        ScRangeData::ParseScopedInternalName(rName, sName, nSheet);
292
293
        if ( rRangeNames.SearchName( sName, nAt, nSheet ) )
290
		{
294
		{
291
			ScRangeData* pData = rRangeNames[nAt];
295
			ScRangeData* pData = rRangeNames[nAt];
292
			String		 aStrArea;
296
			String		 aStrArea;
(-)a/main/sc/source/ui/app/inputwin.cxx (-34 / +26 lines)
Lines 1470-1507 void ScPosWnd::FillRangeNames() Link Here
1470
		//	per Hand sortieren, weil Funktionen nicht sortiert werden:
1470
		//	per Hand sortieren, weil Funktionen nicht sortiert werden:
1471
1471
1472
		ScRangeName* pRangeNames = pDoc->GetRangeName();
1472
		ScRangeName* pRangeNames = pDoc->GetRangeName();
1473
		sal_uInt16 nCount = pRangeNames->GetCount();
1473
        ::boost::shared_ptr<std::vector<String> > pSortedRanges (
1474
		if ( nCount > 0 )
1474
            pDoc->GetRangeName()->GetSortedRangeDisplayNames());
1475
		{
1475
        if (pSortedRanges)
1476
			sal_uInt16 nValidCount = 0;
1476
        {
1477
			ScRange aDummy;
1477
            for (::std::vector<String>::const_iterator iName(pSortedRanges->begin()),iEnd(pSortedRanges->end());
1478
			sal_uInt16 i;
1478
                 iName!=iEnd;
1479
			for ( i=0; i<nCount; i++ )
1479
                 ++iName)
1480
			{
1480
            {
1481
				ScRangeData* pData = (*pRangeNames)[i];
1481
                InsertEntry(*iName);
1482
				if (pData->IsValidReference(aDummy))
1483
					nValidCount++;
1484
			}
1485
			if ( nValidCount )
1486
			{
1487
				ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
1488
				sal_uInt16 j;
1489
				for ( i=0, j=0; i<nCount; i++ )
1490
				{
1491
					ScRangeData* pData = (*pRangeNames)[i];
1492
					if (pData->IsValidReference(aDummy))
1493
						ppSortArray[j++] = pData;
1494
				}
1495
#ifndef ICC
1496
				qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
1497
					&ScRangeData_QsortNameCompare );
1498
#else
1499
				qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
1500
					ICCQsortNameCompare );
1501
#endif
1502
				for ( j=0; j<nValidCount; j++ )
1503
					InsertEntry( ppSortArray[j]->GetName() );
1504
				delete [] ppSortArray;
1505
			}
1482
			}
1506
		}
1483
		}
1507
	}
1484
	}
Lines 1595-1605 ScNameInputType lcl_GetInputType( const String& rText ) Link Here
1595
        SCTAB nNameTab;
1572
        SCTAB nNameTab;
1596
        sal_Int32 nNumeric;
1573
        sal_Int32 nNumeric;
1597
1574
1575
        String sRangeName;
1576
        SCTAB nSheet;
1577
        ScRangeData::ParseScopedDisplayName(rText, sRangeName, nSheet);
1578
        const String sScopedInternalName (ScRangeData::GetScopedInternalName(sRangeName, nSheet));
1579
        
1598
        if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID )
1580
        if ( aRange.Parse( rText, pDoc, eConv ) & SCA_VALID )
1599
            eRet = SC_NAME_INPUT_NAMEDRANGE;
1581
            eRet = SC_NAME_INPUT_NAMEDRANGE;
1600
        else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID )
1582
        else if ( aAddress.Parse( rText, pDoc, eConv ) & SCA_VALID )
1601
            eRet = SC_NAME_INPUT_CELL;
1583
            eRet = SC_NAME_INPUT_CELL;
1602
        else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_NAMES, eConv ) )
1584
        else if ( aRangeUtil.MakeRangeFromName( sScopedInternalName, pDoc, nTab, aRange, RUTL_NAMES, eConv ) )
1603
            eRet = SC_NAME_INPUT_NAMEDRANGE;
1585
            eRet = SC_NAME_INPUT_NAMEDRANGE;
1604
        else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) )
1586
        else if ( aRangeUtil.MakeRangeFromName( rText, pDoc, nTab, aRange, RUTL_DBASE, eConv ) )
1605
            eRet = SC_NAME_INPUT_DATABASE;
1587
            eRet = SC_NAME_INPUT_DATABASE;
Lines 1761-1767 void ScPosWnd::DoEnter() Link Here
1761
                {
1743
                {
1762
                    // for all selection types, excecute the SID_CURRENTCELL slot
1744
                    // for all selection types, excecute the SID_CURRENTCELL slot
1763
1745
1764
                    SfxStringItem aPosItem( SID_CURRENTCELL, aText );
1746
                    String sName (aText);
1747
                    if (eType == SC_NAME_INPUT_NAMEDRANGE)
1748
                    {
1749
                        // Convert display name of range to internal
1750
                        // name.
1751
                        String sRangeName;
1752
                        SCTAB nSheet;
1753
                        ScRangeData::ParseScopedDisplayName(sName, sRangeName, nSheet);
1754
                        sName = ScRangeData::GetScopedInternalName(sRangeName, nSheet);
1755
                    }
1756
                    SfxStringItem aPosItem( SID_CURRENTCELL, sName);
1765
                    SfxBoolItem aUnmarkItem( FN_PARAM_1, sal_True );        // remove existing selection
1757
                    SfxBoolItem aUnmarkItem( FN_PARAM_1, sal_True );        // remove existing selection
1766
1758
1767
                    pViewSh->GetViewData()->GetDispatcher().Execute( SID_CURRENTCELL,
1759
                    pViewSh->GetViewData()->GetDispatcher().Execute( SID_CURRENTCELL,
(-)a/main/sc/source/ui/navipi/content.cxx (-35 / +11 lines)
Lines 67-72 Link Here
67
#include "tabvwsh.hxx"
67
#include "tabvwsh.hxx"
68
#include "drawview.hxx"
68
#include "drawview.hxx"
69
#include "clipparam.hxx"
69
#include "clipparam.hxx"
70
#include "rangeutl.hxx"
70
71
71
using namespace com::sun::star;
72
using namespace com::sun::star;
72
73
Lines 863-869 void ScContentTree::GetTableNames() Link Here
863
		InsertContent( SC_CONTENT_TABLE, aName );
864
		InsertContent( SC_CONTENT_TABLE, aName );
864
	}
865
	}
865
}
866
}
866
867
void ScContentTree::GetAreaNames()
867
void ScContentTree::GetAreaNames()
868
{
868
{
869
	if ( nRootType && nRootType != SC_CONTENT_RANGENAME )		// ausgeblendet ?
869
	if ( nRootType && nRootType != SC_CONTENT_RANGENAME )		// ausgeblendet ?
Lines 873-912 void ScContentTree::GetAreaNames() Link Here
873
	if (!pDoc)
873
	if (!pDoc)
874
		return;
874
		return;
875
875
876
	ScRangeName* pRangeNames = pDoc->GetRangeName();
876
    ::boost::shared_ptr<std::vector<String> > pSortedRanges (
877
	sal_uInt16 nCount = pRangeNames->GetCount();
877
        pDoc->GetRangeName()->GetSortedRangeDisplayNames());
878
	if ( nCount > 0 )
878
    if (pSortedRanges)
879
	{
879
    {
880
		sal_uInt16 nValidCount = 0;
880
        for (::std::vector<String>::const_iterator iName(pSortedRanges->begin()),iEnd(pSortedRanges->end());
881
		ScRange aDummy;
881
             iName!=iEnd;
882
		sal_uInt16 i;
882
             ++iName)
883
		for ( i=0; i<nCount; i++ )
883
        {
884
		{
884
            InsertContent(SC_CONTENT_RANGENAME, *iName);
885
			ScRangeData* pData = (*pRangeNames)[i];
885
        }
886
			if (pData->IsValidReference(aDummy))
887
				nValidCount++;
888
		}
889
		if ( nValidCount )
890
		{
891
			ScRangeData** ppSortArray = new ScRangeData* [ nValidCount ];
892
			sal_uInt16 j;
893
			for ( i=0, j=0; i<nCount; i++ )
894
			{
895
				ScRangeData* pData = (*pRangeNames)[i];
896
				if (pData->IsValidReference(aDummy))
897
					ppSortArray[j++] = pData;
898
			}
899
#ifndef ICC
900
			qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
901
				&ScRangeData_QsortNameCompare );
902
#else
903
			qsort( (void*)ppSortArray, nValidCount, sizeof(ScRangeData*),
904
				ICCQsortNameCompare );
905
#endif
906
			for ( j=0; j<nValidCount; j++ )
907
				InsertContent( SC_CONTENT_RANGENAME, ppSortArray[j]->GetName() );
908
			delete [] ppSortArray;
909
		}
910
	}
886
	}
911
}
887
}
912
888
(-)a/main/sc/source/ui/navipi/navipi.cxx (-2 / +8 lines)
Lines 651-656 void __EXPORT ScNavigatorDialogWrapper::Resizing( Size& rSize ) Link Here
651
651
652
#define CTRL_ITEMS 4
652
#define CTRL_ITEMS 4
653
653
654
654
#define REGISTER_SLOT(i,id) \
655
#define REGISTER_SLOT(i,id) \
655
	ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
656
	ppBoundItems[i]=new ScNavigatorControllerItem(id,*this,rBindings);
656
657
Lines 1064-1073 void ScNavigatorDlg::SetCurrentCell( SCCOL nColNo, SCROW nRowNo ) Link Here
1064
	}
1065
	}
1065
}
1066
}
1066
1067
1067
void ScNavigatorDlg::SetCurrentCellStr( const String rName )
1068
void ScNavigatorDlg::SetCurrentCellStr( const String sScopedDisplayName )
1068
{
1069
{
1070
    String sName;
1071
    SCTAB nSheet;
1072
    ScRangeData::ParseScopedDisplayName(sScopedDisplayName, sName, nSheet);
1073
    const String sScopedInternalName (ScRangeData::GetScopedInternalName(sName, nSheet));
1074
1069
	ppBoundItems[0]->ClearCache();
1075
	ppBoundItems[0]->ClearCache();
1070
	SfxStringItem	aNameItem( SID_CURRENTCELL, rName );
1076
	SfxStringItem	aNameItem( SID_CURRENTCELL, sScopedInternalName );
1071
1077
1072
	rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1078
	rBindings.GetDispatcher()->Execute( SID_CURRENTCELL,
1073
							  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,
1079
							  SFX_CALLMODE_SYNCHRON | SFX_CALLMODE_RECORD,

Return to issue 124293