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
c516a4f4
Kaydet (Commit)
c516a4f4
authored
Mar 05, 2012
tarafından
Kohei Yoshida
Kaydeden (comit)
Kohei Yoshida
Mar 09, 2012
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Scope reduction.
üst
8720c874
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
316 additions
and
316 deletions
+316
-316
dbfunc3.cxx
sc/source/ui/view/dbfunc3.cxx
+316
-316
No files found.
sc/source/ui/view/dbfunc3.cxx
Dosyayı görüntüle @
c516a4f4
...
...
@@ -976,397 +976,397 @@ void ScDBFunc::DateGroupDataPilot( const ScDPNumGroupInfo& rInfo, sal_Int32 nPar
{
ScDPObject
*
pDPObj
=
GetViewData
()
->
GetDocument
()
->
GetDPAtCursor
(
GetViewData
()
->
GetCurX
(),
GetViewData
()
->
GetCurY
(),
GetViewData
()
->
GetTabNo
()
);
if
(
pDPObj
)
{
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
if
(
!
aEntries
.
empty
())
{
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
if
(
!
pDPObj
)
return
;
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
// find original base
String
aBaseDimName
=
aDimName
;
if
(
const
ScDPSaveGroupDimension
*
pBaseGroupDim
=
pDimData
->
GetNamedGroupDim
(
aDimName
)
)
aBaseDimName
=
pBaseGroupDim
->
GetSourceDimName
();
if
(
aEntries
.
empty
())
return
;
// remove all existing parts (the grouping is built completely new)
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
/* Remove numeric group dimension (exists once at most). No need
to delete anything in save data (grouping was done inplace in
an existing base dimension). */
pDimData
->
RemoveNumGroupDimension
(
aBaseDimName
);
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
// find original base
String
aBaseDimName
=
aDimName
;
if
(
const
ScDPSaveGroupDimension
*
pBaseGroupDim
=
pDimData
->
GetNamedGroupDim
(
aDimName
)
)
aBaseDimName
=
pBaseGroupDim
->
GetSourceDimName
();
// remove all existing parts (the grouping is built completely new)
/* Remove numeric group dimension (exists once at most). No need
to delete anything in save data (grouping was done inplace in
an existing base dimension). */
pDimData
->
RemoveNumGroupDimension
(
aBaseDimName
);
/* Remove named group dimension(s). Collect deleted dimension
names which may be reused while recreating the groups.
Dimensions have to be removed from dimension save data and from
save data too. */
std
::
vector
<
rtl
::
OUString
>
aDeletedNames
;
const
ScDPSaveGroupDimension
*
pExistingGroup
=
pDimData
->
GetGroupDimForBase
(
aBaseDimName
);
while
(
pExistingGroup
)
{
const
rtl
::
OUString
&
aGroupDimName
=
pExistingGroup
->
GetGroupDimName
();
pDimData
->
RemoveGroupDimension
(
aGroupDimName
);
// pExistingGroup is deleted
/* Remove named group dimension(s). Collect deleted dimension
names which may be reused while recreating the groups.
Dimensions have to be removed from dimension save data and from
save data too. */
std
::
vector
<
rtl
::
OUString
>
aDeletedNames
;
const
ScDPSaveGroupDimension
*
pExistingGroup
=
pDimData
->
GetGroupDimForBase
(
aBaseDimName
);
while
(
pExistingGroup
)
{
const
rtl
::
OUString
&
aGroupDimName
=
pExistingGroup
->
GetGroupDimName
();
pDimData
->
RemoveGroupDimension
(
aGroupDimName
);
// pExistingGroup is deleted
// also remove SaveData settings for the dimension that no longer exists
aData
.
RemoveDimensionByName
(
aGroupDimName
);
// also remove SaveData settings for the dimension that no longer exists
aData
.
RemoveDimensionByName
(
aGroupDimName
);
/* The name can be used for the new group dimensions, although
it is still in use with the DataPilotSource. */
aDeletedNames
.
push_back
(
aGroupDimName
);
/* The name can be used for the new group dimensions, although
it is still in use with the DataPilotSource. */
aDeletedNames
.
push_back
(
aGroupDimName
);
// see if there are more group dimensions
pExistingGroup
=
pDimData
->
GetGroupDimForBase
(
aBaseDimName
);
// see if there are more group dimensions
pExistingGroup
=
pDimData
->
GetGroupDimForBase
(
aBaseDimName
);
if
(
pExistingGroup
&&
pExistingGroup
->
GetGroupDimName
()
==
aGroupDimName
)
{
// still get the same group dimension?
OSL_FAIL
(
"couldn't remove group dimension"
);
pExistingGroup
=
NULL
;
// avoid endless loop
}
}
if
(
pExistingGroup
&&
pExistingGroup
->
GetGroupDimName
()
==
aGroupDimName
)
{
// still get the same group dimension?
OSL_FAIL
(
"couldn't remove group dimension"
);
pExistingGroup
=
NULL
;
// avoid endless loop
}
}
if
(
nParts
)
{
// create date group dimensions
if
(
nParts
)
ScDPNumGroupInfo
aEmpty
;
bool
bFirst
=
true
;
sal_Int32
nMask
=
1
;
for
(
sal_uInt16
nBit
=
0
;
nBit
<
32
;
nBit
++
)
{
if
(
nParts
&
nMask
)
{
// create date group dimensions
ScDPNumGroupInfo
aEmpty
;
bool
bFirst
=
true
;
sal_Int32
nMask
=
1
;
for
(
sal_uInt16
nBit
=
0
;
nBit
<
32
;
nBit
++
)
if
(
bFirst
)
{
if
(
nParts
&
nMask
)
{
if
(
bFirst
)
{
// innermost part: create NumGroupDimension (replacing original values)
// Dimension name is left unchanged
// innermost part: create NumGroupDimension (replacing original values)
// Dimension name is left unchanged
if
(
(
nParts
==
sheet
::
DataPilotFieldGroupBy
::
DAYS
)
&&
(
rInfo
.
mfStep
>=
1.0
)
)
{
// only days, and a step value specified: use numerical grouping
// with DateValues flag, not date grouping
if
(
(
nParts
==
sheet
::
DataPilotFieldGroupBy
::
DAYS
)
&&
(
rInfo
.
mfStep
>=
1.0
)
)
{
// only days, and a step value specified: use numerical grouping
// with DateValues flag, not date grouping
ScDPNumGroupInfo
aNumInfo
(
rInfo
);
aNumInfo
.
mbDateValues
=
true
;
ScDPNumGroupInfo
aNumInfo
(
rInfo
);
aNumInfo
.
mbDateValues
=
true
;
ScDPSaveNumGroupDimension
aNumGroupDim
(
aBaseDimName
,
aNumInfo
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
else
{
ScDPSaveNumGroupDimension
aNumGroupDim
(
aBaseDimName
,
rInfo
,
nMask
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
ScDPSaveNumGroupDimension
aNumGroupDim
(
aBaseDimName
,
aNumInfo
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
else
{
ScDPSaveNumGroupDimension
aNumGroupDim
(
aBaseDimName
,
rInfo
,
nMask
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
bFirst
=
false
;
}
else
{
// additional parts: create GroupDimension (shown as additional dimensions)
String
aGroupDimName
=
pDimData
->
CreateDateGroupDimName
(
nMask
,
*
pDPObj
,
true
,
&
aDeletedNames
);
ScDPSaveGroupDimension
aGroupDim
(
aBaseDimName
,
aGroupDimName
);
aGroupDim
.
SetDateInfo
(
rInfo
,
nMask
);
pDimData
->
AddGroupDimension
(
aGroupDim
);
// set orientation
ScDPSaveDimension
*
pSaveDimension
=
aData
.
GetDimensionByName
(
aGroupDimName
);
if
(
pSaveDimension
->
GetOrientation
()
==
sheet
::
DataPilotFieldOrientation_HIDDEN
)
{
ScDPSaveDimension
*
pOldDimension
=
aData
.
GetDimensionByName
(
aBaseDimName
);
pSaveDimension
->
SetOrientation
(
pOldDimension
->
GetOrientation
()
);
long
nPosition
=
0
;
//! before (immediate) base
aData
.
SetPosition
(
pSaveDimension
,
nPosition
);
}
}
bFirst
=
false
;
}
else
{
// additional parts: create GroupDimension (shown as additional dimensions)
String
aGroupDimName
=
pDimData
->
CreateDateGroupDimName
(
nMask
,
*
pDPObj
,
true
,
&
aDeletedNames
);
ScDPSaveGroupDimension
aGroupDim
(
aBaseDimName
,
aGroupDimName
);
aGroupDim
.
SetDateInfo
(
rInfo
,
nMask
);
pDimData
->
AddGroupDimension
(
aGroupDim
);
// set orientation
ScDPSaveDimension
*
pSaveDimension
=
aData
.
GetDimensionByName
(
aGroupDimName
);
if
(
pSaveDimension
->
GetOrientation
()
==
sheet
::
DataPilotFieldOrientation_HIDDEN
)
{
ScDPSaveDimension
*
pOldDimension
=
aData
.
GetDimensionByName
(
aBaseDimName
);
pSaveDimension
->
SetOrientation
(
pOldDimension
->
GetOrientation
()
);
long
nPosition
=
0
;
//! before (immediate) base
aData
.
SetPosition
(
pSaveDimension
,
nPosition
);
}
nMask
*=
2
;
}
}
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// unmark cell selection
Unmark
();
nMask
*=
2
;
}
}
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// unmark cell selection
Unmark
();
}
void
ScDBFunc
::
NumGroupDataPilot
(
const
ScDPNumGroupInfo
&
rInfo
)
{
ScDPObject
*
pDPObj
=
GetViewData
()
->
GetDocument
()
->
GetDPAtCursor
(
GetViewData
()
->
GetCurX
(),
GetViewData
()
->
GetCurY
(),
GetViewData
()
->
GetTabNo
()
);
if
(
pDPObj
)
{
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
if
(
!
pDPObj
)
return
;
if
(
!
aEntries
.
empty
())
{
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
if
(
aEntries
.
empty
())
return
;
ScDPSaveNumGroupDimension
*
pExisting
=
pDimData
->
GetNumGroupDimAcc
(
aDimName
);
if
(
pExisting
)
{
// modify existing group dimension
pExisting
->
SetGroupInfo
(
rInfo
);
}
else
{
// create new group dimension
ScDPSaveNumGroupDimension
aNumGroupDim
(
aDimName
,
rInfo
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
// unmark cell selection
Unmark
();
}
ScDPSaveNumGroupDimension
*
pExisting
=
pDimData
->
GetNumGroupDimAcc
(
aDimName
);
if
(
pExisting
)
{
// modify existing group dimension
pExisting
->
SetGroupInfo
(
rInfo
);
}
else
{
// create new group dimension
ScDPSaveNumGroupDimension
aNumGroupDim
(
aDimName
,
rInfo
);
pDimData
->
AddNumGroupDimension
(
aNumGroupDim
);
}
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// unmark cell selection
Unmark
();
}
void
ScDBFunc
::
GroupDataPilot
()
{
ScDPObject
*
pDPObj
=
GetViewData
()
->
GetDocument
()
->
GetDPAtCursor
(
GetViewData
()
->
GetCurX
(),
GetViewData
()
->
GetCurY
(),
GetViewData
()
->
GetTabNo
()
);
if
(
pDPObj
)
{
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
if
(
!
pDPObj
)
return
;
if
(
!
aEntries
.
empty
())
{
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
if
(
aEntries
.
empty
())
return
;
// find original base
String
aBaseDimName
(
aDimName
);
const
ScDPSaveGroupDimension
*
pBaseGroupDim
=
pDimData
->
GetNamedGroupDim
(
aDimName
);
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
// find original base
String
aBaseDimName
(
aDimName
);
const
ScDPSaveGroupDimension
*
pBaseGroupDim
=
pDimData
->
GetNamedGroupDim
(
aDimName
);
if
(
pBaseGroupDim
)
{
// any entry's SourceDimName is the original base
aBaseDimName
=
pBaseGroupDim
->
GetSourceDimName
();
}
// find existing group dimension
// (using the selected dim, can be intermediate group dim)
ScDPSaveGroupDimension
*
pGroupDimension
=
pDimData
->
GetGroupDimAccForBase
(
aDimName
);
// remove the selected items from their groups
// (empty groups are removed, too)
if
(
pGroupDimension
)
{
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
rtl
::
OUString
&
aEntryName
=
*
it
;
if
(
pBaseGroupDim
)
{
// any entry's SourceDimName is the original base
aBaseDimName
=
pBaseGroupDim
->
GetSourceDimName
();
// for each selected (intermediate) group, remove all its items
// (same logic as for adding, below)
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetNamedGroup
(
aEntryName
);
if
(
pBaseGroup
)
pBaseGroup
->
RemoveElementsFromGroups
(
*
pGroupDimension
);
// remove all elements
else
pGroupDimension
->
RemoveFromGroups
(
aEntryName
);
}
else
pGroupDimension
->
RemoveFromGroups
(
aEntryName
);
}
}
// find existing group dimension
// (using the selected dim, can be intermediate group dim)
ScDPSaveGroupDimension
*
pGroupDimension
=
pDimData
->
GetGroupDimAccForBase
(
aDimName
);
ScDPSaveGroupDimension
*
pNewGroupDim
=
NULL
;
if
(
!
pGroupDimension
)
{
// create a new group dimension
String
aGroupDimName
=
pDimData
->
CreateGroupDimName
(
aBaseDimName
,
*
pDPObj
,
false
,
NULL
);
pNewGroupDim
=
new
ScDPSaveGroupDimension
(
aBaseDimName
,
aGroupDimName
);
// remove the selected items from their groups
// (empty groups are removed, too)
if
(
pGroupDimension
)
{
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
rtl
::
OUString
&
aEntryName
=
*
it
;
if
(
pBaseGroupDim
)
{
// for each selected (intermediate) group, remove all its items
// (same logic as for adding, below)
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetNamedGroup
(
aEntryName
);
if
(
pBaseGroup
)
pBaseGroup
->
RemoveElementsFromGroups
(
*
pGroupDimension
);
// remove all elements
else
pGroupDimension
->
RemoveFromGroups
(
aEntryName
);
}
else
pGroupDimension
->
RemoveFromGroups
(
aEntryName
);
}
}
pGroupDimension
=
pNewGroupDim
;
// make changes to the new dim if none existed
ScDPSaveGroupDimension
*
pNewGroupDim
=
NULL
;
if
(
!
pGroupDimension
)
if
(
pBaseGroupDim
)
{
// If it's a higher-order group dimension, pre-allocate groups for all
// non-selected original groups, so the individual base members aren't
// used for automatic groups (this would make the original groups hard
// to find).
//! Also do this when removing groups?
//! Handle this case dynamically with automatic groups?
long
nGroupCount
=
pBaseGroupDim
->
GetGroupCount
();
for
(
long
nGroup
=
0
;
nGroup
<
nGroupCount
;
nGroup
++
)
{
// create a new group dimension
String
aGroupDimName
=
pDimData
->
CreateGroupDimName
(
aBaseDimName
,
*
pDPObj
,
false
,
NULL
);
pNewGroupDim
=
new
ScDPSaveGroupDimension
(
aBaseDimName
,
aGroupDimName
);
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetGroupByIndex
(
nGroup
);
pGroupDimension
=
pNewGroupDim
;
// make changes to the new dim if none existed
if
(
pBaseGroupDim
)
if
(
!
aEntries
.
count
(
pBaseGroup
->
GetGroupName
()))
{
// If it's a higher-order group dimension, pre-allocate groups for all
// non-selected original groups, so the individual base members aren't
// used for automatic groups (this would make the original groups hard
// to find).
//! Also do this when removing groups?
//! Handle this case dynamically with automatic groups?
long
nGroupCount
=
pBaseGroupDim
->
GetGroupCount
();
for
(
long
nGroup
=
0
;
nGroup
<
nGroupCount
;
nGroup
++
)
{
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetGroupByIndex
(
nGroup
);
if
(
!
aEntries
.
count
(
pBaseGroup
->
GetGroupName
()))
{
// add an additional group for each item that is not in the selection
ScDPSaveGroupItem
aGroup
(
pBaseGroup
->
GetGroupName
()
);
aGroup
.
AddElementsFromGroup
(
*
pBaseGroup
);
pGroupDimension
->
AddGroupItem
(
aGroup
);
}
}
// add an additional group for each item that is not in the selection
ScDPSaveGroupItem
aGroup
(
pBaseGroup
->
GetGroupName
()
);
aGroup
.
AddElementsFromGroup
(
*
pBaseGroup
);
pGroupDimension
->
AddGroupItem
(
aGroup
);
}
}
String
aGroupDimName
=
pGroupDimension
->
GetGroupDimName
();
}
}
String
aGroupDimName
=
pGroupDimension
->
GetGroupDimName
();
//! localized prefix string
String
aGroupName
=
pGroupDimension
->
CreateGroupName
(
String
::
CreateFromAscii
(
"Group"
)
);
ScDPSaveGroupItem
aGroup
(
aGroupName
);
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
rtl
::
OUString
&
aEntryName
=
*
it
;
if
(
pBaseGroupDim
)
{
// for each selected (intermediate) group, add all its items
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetNamedGroup
(
aEntryName
);
if
(
pBaseGroup
)
aGroup
.
AddElementsFromGroup
(
*
pBaseGroup
);
else
aGroup
.
AddElement
(
aEntryName
);
// no group found -> automatic group, add the item itself
}
else
aGroup
.
AddElement
(
aEntryName
);
// no group dimension, add all items directly
}
//! localized prefix string
String
aGroupName
=
pGroupDimension
->
CreateGroupName
(
String
::
CreateFromAscii
(
"Group"
)
);
ScDPSaveGroupItem
aGroup
(
aGroupName
);
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
{
const
rtl
::
OUString
&
aEntryName
=
*
it
;
if
(
pBaseGroupDim
)
{
// for each selected (intermediate) group, add all its items
const
ScDPSaveGroupItem
*
pBaseGroup
=
pBaseGroupDim
->
GetNamedGroup
(
aEntryName
);
if
(
pBaseGroup
)
aGroup
.
AddElementsFromGroup
(
*
pBaseGroup
);
else
aGroup
.
AddElement
(
aEntryName
);
// no group found -> automatic group, add the item itself
}
else
aGroup
.
AddElement
(
aEntryName
);
// no group dimension, add all items directly
}
pGroupDimension
->
AddGroupItem
(
aGroup
);
pGroupDimension
->
AddGroupItem
(
aGroup
);
if
(
pNewGroupDim
)
{
pDimData
->
AddGroupDimension
(
*
pNewGroupDim
);
delete
pNewGroupDim
;
// AddGroupDimension copies the object
// don't access pGroupDimension after here
}
pGroupDimension
=
pNewGroupDim
=
NULL
;
if
(
pNewGroupDim
)
{
pDimData
->
AddGroupDimension
(
*
pNewGroupDim
);
delete
pNewGroupDim
;
// AddGroupDimension copies the object
// don't access pGroupDimension after here
}
pGroupDimension
=
pNewGroupDim
=
NULL
;
// set orientation
ScDPSaveDimension
*
pSaveDimension
=
aData
.
GetDimensionByName
(
aGroupDimName
);
if
(
pSaveDimension
->
GetOrientation
()
==
sheet
::
DataPilotFieldOrientation_HIDDEN
)
{
ScDPSaveDimension
*
pOldDimension
=
aData
.
GetDimensionByName
(
aDimName
);
pSaveDimension
->
SetOrientation
(
pOldDimension
->
GetOrientation
()
);
long
nPosition
=
0
;
//! before (immediate) base
aData
.
SetPosition
(
pSaveDimension
,
nPosition
);
}
// set orientation
ScDPSaveDimension
*
pSaveDimension
=
aData
.
GetDimensionByName
(
aGroupDimName
);
if
(
pSaveDimension
->
GetOrientation
()
==
sheet
::
DataPilotFieldOrientation_HIDDEN
)
{
ScDPSaveDimension
*
pOldDimension
=
aData
.
GetDimensionByName
(
aDimName
);
pSaveDimension
->
SetOrientation
(
pOldDimension
->
GetOrientation
()
);
long
nPosition
=
0
;
//! before (immediate) base
aData
.
SetPosition
(
pSaveDimension
,
nPosition
);
}
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// unmark cell selection
Unmark
();
}
}
// unmark cell selection
Unmark
();
}
void
ScDBFunc
::
UngroupDataPilot
()
{
ScDPObject
*
pDPObj
=
GetViewData
()
->
GetDocument
()
->
GetDPAtCursor
(
GetViewData
()
->
GetCurX
(),
GetViewData
()
->
GetCurY
(),
GetViewData
()
->
GetTabNo
()
);
if
(
pDPObj
)
{
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
if
(
!
pDPObj
)
return
;
if
(
!
aEntries
.
empty
())
{
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
ScDPUniqueStringSet
aEntries
;
long
nSelectDimension
=
-
1
;
GetSelectedMemberList
(
aEntries
,
nSelectDimension
);
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
//! test first if DimensionData exists?
if
(
aEntries
.
empty
())
return
;
sal_Bool
bApply
=
false
;
bool
bIsDataLayout
;
OUString
aDimName
=
pDPObj
->
GetDimName
(
nSelectDimension
,
bIsDataLayout
);
ScDPSaveGroupDimension
*
pGroupDim
=
pDimData
->
GetNamedGroupDimAcc
(
aDimName
);
const
ScDPSaveNumGroupDimension
*
pNumGroupDim
=
pDimData
->
GetNumGroupDim
(
aDimName
);
if
(
(
pGroupDim
&&
pGroupDim
->
GetDatePart
()
!=
0
)
||
(
pNumGroupDim
&&
pNumGroupDim
->
GetDatePart
()
!=
0
)
)
{
// Date grouping: need to remove all affected group dimensions.
// This is done using DateGroupDataPilot with nParts=0.
ScDPSaveData
aData
(
*
pDPObj
->
GetSaveData
()
);
ScDPDimensionSaveData
*
pDimData
=
aData
.
GetDimensionData
();
// created if not there
//! test first if DimensionData exists?
DateGroupDataPilot
(
ScDPNumGroupInfo
(),
0
);
// bApply remains FALSE
// dimension pointers become invalid
}
else
if
(
pGroupDim
)
{
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
pGroupDim
->
RemoveGroup
(
*
it
);
sal_Bool
bApply
=
false
;
// remove group dimension if empty
bool
bEmptyDim
=
pGroupDim
->
IsEmpty
();
if
(
!
bEmptyDim
)
{
// If all remaining groups in the dimension aren't shown, remove
// the dimension too, as if it was completely empty.
ScDPUniqueStringSet
aVisibleEntries
;
pDPObj
->
GetMemberResultNames
(
aVisibleEntries
,
nSelectDimension
);
bEmptyDim
=
pGroupDim
->
HasOnlyHidden
(
aVisibleEntries
);
}
if
(
bEmptyDim
)
{
pDimData
->
RemoveGroupDimension
(
aDimName
);
// pGroupDim is deleted
ScDPSaveGroupDimension
*
pGroupDim
=
pDimData
->
GetNamedGroupDimAcc
(
aDimName
);
const
ScDPSaveNumGroupDimension
*
pNumGroupDim
=
pDimData
->
GetNumGroupDim
(
aDimName
);
if
(
(
pGroupDim
&&
pGroupDim
->
GetDatePart
()
!=
0
)
||
(
pNumGroupDim
&&
pNumGroupDim
->
GetDatePart
()
!=
0
)
)
{
// Date grouping: need to remove all affected group dimensions.
// This is done using DateGroupDataPilot with nParts=0.
// also remove SaveData settings for the dimension that no longer exists
aData
.
RemoveDimensionByName
(
aDimName
);
}
bApply
=
sal_True
;
}
else
if
(
pNumGroupDim
)
{
// remove the numerical grouping
pDimData
->
RemoveNumGroupDimension
(
aDimName
);
// SaveData settings can remain unchanged - the same dimension still exists
bApply
=
sal_True
;
}
DateGroupDataPilot
(
ScDPNumGroupInfo
(),
0
);
// bApply remains FALSE
// dimension pointers become invalid
}
else
if
(
pGroupDim
)
{
ScDPUniqueStringSet
::
const_iterator
it
=
aEntries
.
begin
(),
itEnd
=
aEntries
.
end
();
for
(;
it
!=
itEnd
;
++
it
)
pGroupDim
->
RemoveGroup
(
*
it
);
if
(
bApply
)
{
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// remove group dimension if empty
bool
bEmptyDim
=
pGroupDim
->
IsEmpty
();
if
(
!
bEmptyDim
)
{
// If all remaining groups in the dimension aren't shown, remove
// the dimension too, as if it was completely empty.
ScDPUniqueStringSet
aVisibleEntries
;
pDPObj
->
GetMemberResultNames
(
aVisibleEntries
,
nSelectDimension
);
bEmptyDim
=
pGroupDim
->
HasOnlyHidden
(
aVisibleEntries
);
}
if
(
bEmptyDim
)
{
pDimData
->
RemoveGroupDimension
(
aDimName
);
// pGroupDim is deleted
// unmark cell selection
Unmark
();
}
// also remove SaveData settings for the dimension that no longer exists
aData
.
RemoveDimensionByName
(
aDimName
);
}
bApply
=
sal_True
;
}
else
if
(
pNumGroupDim
)
{
// remove the numerical grouping
pDimData
->
RemoveNumGroupDimension
(
aDimName
);
// SaveData settings can remain unchanged - the same dimension still exists
bApply
=
sal_True
;
}
if
(
bApply
)
{
// apply changes
ScDBDocFunc
aFunc
(
*
GetViewData
()
->
GetDocShell
()
);
ScDPObject
*
pNewObj
=
new
ScDPObject
(
*
pDPObj
);
pNewObj
->
SetSaveData
(
aData
);
aFunc
.
DataPilotUpdate
(
pDPObj
,
pNewObj
,
sal_True
,
false
);
delete
pNewObj
;
// unmark cell selection
Unmark
();
}
}
...
...
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