Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
core
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
LibreOffice
core
Commits
62b36e80
Kaydet (Commit)
62b36e80
authored
Kas 15, 2013
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Handle sheet-local range names too.
Change-Id: Ib1503c3b69d77946b4437bdc0e1bfa5ebacbb602
üst
24ddf0d9
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
109 additions
and
36 deletions
+109
-36
tokenstringcontext.hxx
sc/inc/tokenstringcontext.hxx
+2
-0
ucalc_formula.cxx
sc/qa/unit/ucalc_formula.cxx
+19
-5
documen3.cxx
sc/source/core/data/documen3.cxx
+1
-1
token.cxx
sc/source/core/tool/token.cxx
+34
-3
tokenstringcontext.cxx
sc/source/core/tool/tokenstringcontext.cxx
+53
-27
No files found.
sc/inc/tokenstringcontext.hxx
Dosyayı görüntüle @
62b36e80
...
...
@@ -27,6 +27,7 @@ namespace sc {
struct
SC_DLLPUBLIC
TokenStringContext
{
typedef
boost
::
unordered_map
<
sal_uInt16
,
OUString
>
IndexNameMapType
;
typedef
boost
::
unordered_map
<
SCTAB
,
IndexNameMapType
>
TabIndexMapType
;
formula
::
FormulaGrammar
::
Grammar
meGram
;
formula
::
FormulaCompiler
::
OpCodeMapPtr
mxOpCodeMap
;
...
...
@@ -35,6 +36,7 @@ struct SC_DLLPUBLIC TokenStringContext
std
::
vector
<
OUString
>
maTabNames
;
IndexNameMapType
maGlobalRangeNames
;
TabIndexMapType
maSheetRangeNames
;
IndexNameMapType
maNamedDBs
;
TokenStringContext
(
const
ScDocument
*
pDoc
,
formula
::
FormulaGrammar
::
Grammar
eGram
);
...
...
sc/qa/unit/ucalc_formula.cxx
Dosyayı görüntüle @
62b36e80
...
...
@@ -45,16 +45,21 @@ void Test::testFormulaCreateStringFromTokens()
// Insert named ranges.
struct
{
bool
bGlobal
;
const
char
*
pName
;
const
char
*
pExpr
;
}
aNames
[]
=
{
{
"x"
,
"Test.H1"
},
{
"y"
,
"Test.H2"
},
{
"z"
,
"Test.H3"
}
{
true
,
"x"
,
"Test.H1"
},
{
true
,
"y"
,
"Test.H2"
},
{
true
,
"z"
,
"Test.H3"
},
{
false
,
"sheetx"
,
"Test.J1"
}
};
ScRangeName
*
pGlobalNames
=
m_pDoc
->
GetRangeName
();
ScRangeName
*
pSheetNames
=
m_pDoc
->
GetRangeName
(
0
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to obtain global named expression object."
,
pGlobalNames
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to obtain sheet-local named expression object."
,
pSheetNames
);
for
(
size_t
i
=
0
,
n
=
SAL_N_ELEMENTS
(
aNames
);
i
<
n
;
++
i
)
{
...
...
@@ -62,8 +67,16 @@ void Test::testFormulaCreateStringFromTokens()
m_pDoc
,
OUString
::
createFromAscii
(
aNames
[
i
].
pName
),
OUString
::
createFromAscii
(
aNames
[
i
].
pExpr
),
ScAddress
(
0
,
0
,
0
),
RT_NAME
,
formula
::
FormulaGrammar
::
GRAM_NATIVE
);
bool
bInserted
=
pGlobalNames
->
insert
(
pName
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to insert a new name."
,
bInserted
);
if
(
aNames
[
i
].
bGlobal
)
{
bool
bInserted
=
pGlobalNames
->
insert
(
pName
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to insert a new name."
,
bInserted
);
}
else
{
bool
bInserted
=
pSheetNames
->
insert
(
pName
);
CPPUNIT_ASSERT_MESSAGE
(
"Failed to insert a new name."
,
bInserted
);
}
}
// Insert DB ranges.
...
...
@@ -99,6 +112,7 @@ void Test::testFormulaCreateStringFromTokens()
"'Kevin''s Data'.B10"
,
"'Past Data'.B1+'2013'.B2*(1+'Kevin''s Data'.C10)"
,
"x+y*z"
,
// named ranges
"SUM(sheetx;x;y;z)"
,
// sheet local and global named ranges mixed
"MAX(Table1)+MIN(Table2)*SUM(Table3)"
// database ranges
};
...
...
sc/source/core/data/documen3.cxx
Dosyayı görüntüle @
62b36e80
...
...
@@ -109,7 +109,7 @@ void ScDocument::GetAllTabRangeNames(ScRangeName::TabNameCopyMap& rNames) const
// no more tables to iterate through.
break
;
const
ScRangeName
*
p
=
maTabs
[
i
]
->
GetRangeName
()
;
const
ScRangeName
*
p
=
maTabs
[
i
]
->
mpRangeName
;
if
(
!
p
||
p
->
empty
())
// ignore empty ones.
continue
;
...
...
sc/source/core/tool/token.cxx
Dosyayı görüntüle @
62b36e80
...
...
@@ -3264,19 +3264,50 @@ void appendTokenByType( sc::TokenStringContext& rCxt, OUStringBuffer& rBuf, cons
break
;
case
svIndex
:
{
typedef
sc
::
TokenStringContext
::
IndexNameMapType
NameType
;
sal_uInt16
nIndex
=
rToken
.
GetIndex
();
switch
(
eOp
)
{
case
ocName
:
{
sc
::
TokenStringContext
::
IndexNameMapType
::
const_iterator
it
=
rCxt
.
maGlobalRangeNames
.
find
(
nIndex
);
if
(
it
!=
rCxt
.
maGlobalRangeNames
.
end
())
if
(
rToken
.
IsGlobal
())
{
// global named range
NameType
::
const_iterator
it
=
rCxt
.
maGlobalRangeNames
.
find
(
nIndex
);
if
(
it
==
rCxt
.
maGlobalRangeNames
.
end
())
{
rBuf
.
append
(
ScGlobal
::
GetRscString
(
STR_NO_NAME_REF
));
break
;
}
rBuf
.
append
(
it
->
second
);
}
else
{
// sheet-local named range
sc
::
TokenStringContext
::
TabIndexMapType
::
const_iterator
itTab
=
rCxt
.
maSheetRangeNames
.
find
(
rPos
.
Tab
());
if
(
itTab
==
rCxt
.
maSheetRangeNames
.
end
())
{
rBuf
.
append
(
ScGlobal
::
GetRscString
(
STR_NO_NAME_REF
));
break
;
}
const
NameType
&
rNames
=
itTab
->
second
;
NameType
::
const_iterator
it
=
rNames
.
find
(
nIndex
);
if
(
it
==
rNames
.
end
())
{
rBuf
.
append
(
ScGlobal
::
GetRscString
(
STR_NO_NAME_REF
));
break
;
}
rBuf
.
append
(
it
->
second
);
}
}
break
;
case
ocDBArea
:
{
sc
::
TokenStringContext
::
IndexNameMap
Type
::
const_iterator
it
=
rCxt
.
maNamedDBs
.
find
(
nIndex
);
Name
Type
::
const_iterator
it
=
rCxt
.
maNamedDBs
.
find
(
nIndex
);
if
(
it
!=
rCxt
.
maNamedDBs
.
end
())
rBuf
.
append
(
it
->
second
);
}
...
...
sc/source/core/tool/tokenstringcontext.cxx
Dosyayı görüntüle @
62b36e80
...
...
@@ -16,6 +16,21 @@ using namespace com::sun::star;
namespace
sc
{
namespace
{
void
insertAllNames
(
TokenStringContext
::
IndexNameMapType
&
rMap
,
const
ScRangeName
&
rNames
)
{
ScRangeName
::
const_iterator
it
=
rNames
.
begin
(),
itEnd
=
rNames
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
ScRangeData
*
pData
=
it
->
second
;
rMap
.
insert
(
TokenStringContext
::
IndexNameMapType
::
value_type
(
pData
->
GetIndex
(),
pData
->
GetName
()));
}
}
}
TokenStringContext
::
TokenStringContext
(
const
ScDocument
*
pDoc
,
formula
::
FormulaGrammar
::
Grammar
eGram
)
:
meGram
(
eGram
),
mpRefConv
(
ScCompiler
::
GetRefConvention
(
formula
::
FormulaGrammar
::
extractRefConvention
(
eGram
)))
...
...
@@ -25,39 +40,50 @@ TokenStringContext::TokenStringContext( const ScDocument* pDoc, formula::Formula
if
(
mxOpCodeMap
)
maErrRef
=
mxOpCodeMap
->
getSymbol
(
ocErrRef
);
if
(
pDoc
)
if
(
!
pDoc
)
return
;
// Fetch all sheet names.
maTabNames
=
pDoc
->
GetAllTableNames
();
{
// Fetch all sheet names.
maTabNames
=
pDoc
->
GetAllTableNames
();
{
std
::
vector
<
OUString
>::
iterator
it
=
maTabNames
.
begin
(),
itEnd
=
maTabNames
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
ScCompiler
::
CheckTabQuotes
(
*
it
,
formula
::
FormulaGrammar
::
extractRefConvention
(
eGram
));
}
std
::
vector
<
OUString
>::
iterator
it
=
maTabNames
.
begin
(),
itEnd
=
maTabNames
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
ScCompiler
::
CheckTabQuotes
(
*
it
,
formula
::
FormulaGrammar
::
extractRefConvention
(
eGram
));
}
// Fetch all named range names.
const
ScRangeName
*
pNames
=
pDoc
->
GetRangeName
();
if
(
pNames
)
// global names
insertAllNames
(
maGlobalRangeNames
,
*
pNames
);
// Fetch all named range names.
const
ScRangeName
*
pNames
=
pDoc
->
GetRangeName
();
if
(
pNames
)
{
ScRangeName
::
TabNameCopyMap
aTabRangeNames
;
pDoc
->
GetAllTabRangeNames
(
aTabRangeNames
);
ScRangeName
::
TabNameCopyMap
::
const_iterator
it
=
aTabRangeNames
.
begin
(),
itEnd
=
aTabRangeNames
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
ScRangeName
::
const_iterator
it
=
pNames
->
begin
(),
itEnd
=
pNames
->
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
ScRangeData
*
pData
=
it
->
second
;
maGlobalRangeNames
.
insert
(
IndexNameMapType
::
value_type
(
pData
->
GetIndex
(),
pData
->
GetName
()));
}
const
ScRangeName
*
pSheetNames
=
it
->
second
;
if
(
!
pSheetNames
)
continue
;
SCTAB
nTab
=
it
->
first
;
IndexNameMapType
aNames
;
insertAllNames
(
aNames
,
*
pSheetNames
);
maSheetRangeNames
.
insert
(
TabIndexMapType
::
value_type
(
nTab
,
aNames
));
}
}
// Fetch all named database ranges names.
const
ScDBCollection
*
pDBs
=
pDoc
->
GetDBCollection
();
if
(
pDBs
)
// Fetch all named database ranges names.
const
ScDBCollection
*
pDBs
=
pDoc
->
GetDBCollection
();
if
(
pDBs
)
{
const
ScDBCollection
::
NamedDBs
&
rNamedDBs
=
pDBs
->
getNamedDBs
();
ScDBCollection
::
NamedDBs
::
const_iterator
it
=
rNamedDBs
.
begin
(),
itEnd
=
rNamedDBs
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
ScDBCollection
::
NamedDBs
&
rNamedDBs
=
pDBs
->
getNamedDBs
();
ScDBCollection
::
NamedDBs
::
const_iterator
it
=
rNamedDBs
.
begin
(),
itEnd
=
rNamedDBs
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
ScDBData
&
rData
=
*
it
;
maNamedDBs
.
insert
(
IndexNameMapType
::
value_type
(
rData
.
GetIndex
(),
rData
.
GetName
()));
}
const
ScDBData
&
rData
=
*
it
;
maNamedDBs
.
insert
(
IndexNameMapType
::
value_type
(
rData
.
GetIndex
(),
rData
.
GetName
()));
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment