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
fbc389bf
Kaydet (Commit)
fbc389bf
authored
Ock 12, 2013
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove more duplicated code blocks.
Change-Id: I4b392a10b324ba082764df92a8640edb3e225666
üst
7eca12e3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
85 deletions
+50
-85
dbdocfun.cxx
sc/source/ui/docshell/dbdocfun.cxx
+50
-85
No files found.
sc/source/ui/docshell/dbdocfun.cxx
Dosyayı görüntüle @
fbc389bf
...
...
@@ -1231,6 +1231,49 @@ SAL_WNODEPRECATED_DECLARATIONS_POP
pDoc
->
CopyToDocument
(
rRange
,
IDF_ALL
,
false
,
pUndoDoc
.
get
());
}
bool
checkNewOutputRange
(
ScDPObject
&
rDPObj
,
ScDocShell
&
rDocShell
,
ScRange
&
rNewOut
,
bool
bApi
)
{
ScDocument
*
pDoc
=
rDocShell
.
GetDocument
();
bool
bOverflow
=
false
;
rNewOut
=
rDPObj
.
GetNewOutputRange
(
bOverflow
);
// Test for overlap with source data range.
// TODO: Check with other pivot tables as well.
const
ScSheetSourceDesc
*
pSheetDesc
=
rDPObj
.
GetSheetDesc
();
if
(
pSheetDesc
&&
pSheetDesc
->
GetSourceRange
().
Intersects
(
rNewOut
))
{
// New output range intersepts with the source data. Move it up to
// where the old range is and see if that works.
ScRange
aOldRange
=
rDPObj
.
GetOutRange
();
SCsROW
nDiff
=
aOldRange
.
aStart
.
Row
()
-
rNewOut
.
aStart
.
Row
();
rNewOut
.
aStart
.
SetRow
(
aOldRange
.
aStart
.
Row
());
rNewOut
.
aEnd
.
IncRow
(
nDiff
);
if
(
!
ValidRow
(
rNewOut
.
aStart
.
Row
())
||
!
ValidRow
(
rNewOut
.
aEnd
.
Row
()))
bOverflow
=
true
;
}
if
(
bOverflow
)
{
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
STR_PIVOT_ERROR
);
return
false
;
}
ScEditableTester
aTester
(
pDoc
,
rNewOut
);
if
(
!
aTester
.
IsEditable
())
{
// destination area isn't editable
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
aTester
.
GetMessageId
());
return
false
;
}
return
true
;
}
}
bool
ScDBDocFunc
::
DataPilotUpdate
(
ScDPObject
*
pOldObj
,
const
ScDPObject
*
pNewObj
,
...
...
@@ -1294,44 +1337,13 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
if
(
pOldObj
->
GetName
().
isEmpty
())
pOldObj
->
SetName
(
pDoc
->
GetDPCollection
()
->
CreateNewName
()
);
bool
bOverflow
=
false
;
ScRange
aNewOut
=
pOldObj
->
GetNewOutputRange
(
bOverflow
);
//! test for overlap with other data pilot tables
const
ScSheetSourceDesc
*
pSheetDesc
=
pOldObj
->
GetSheetDesc
();
if
(
pSheetDesc
&&
pSheetDesc
->
GetSourceRange
().
Intersects
(
aNewOut
))
{
ScRange
aOldRange
=
pOldObj
->
GetOutRange
();
SCsROW
nDiff
=
aOldRange
.
aStart
.
Row
()
-
aNewOut
.
aStart
.
Row
();
aNewOut
.
aStart
.
SetRow
(
aOldRange
.
aStart
.
Row
());
aNewOut
.
aEnd
.
SetRow
(
aNewOut
.
aEnd
.
Row
()
+
nDiff
);
if
(
!
ValidRow
(
aNewOut
.
aStart
.
Row
())
||
!
ValidRow
(
aNewOut
.
aEnd
.
Row
()))
bOverflow
=
true
;
}
if
(
bOverflow
)
ScRange
aNewOut
;
if
(
!
checkNewOutputRange
(
*
pOldObj
,
rDocShell
,
aNewOut
,
bApi
))
{
*
pOldObj
=
aUndoDPObj
;
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
STR_PIVOT_ERROR
);
return
false
;
}
{
ScEditableTester
aTester
(
pDoc
,
aNewOut
);
if
(
!
aTester
.
IsEditable
())
{
// destination area isn't editable
//! reverse everything done so far, don't proceed
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
aTester
.
GetMessageId
());
return
false
;
}
}
// test if new output area is empty except for old area
if
(
!
bApi
)
{
...
...
@@ -1350,12 +1362,7 @@ bool ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
}
if
(
bRecord
)
{
SCTAB
nTab
=
aNewOut
.
aStart
.
Tab
();
pNewUndoDoc
.
reset
(
new
ScDocument
(
SCDOCMODE_UNDO
));
pNewUndoDoc
->
InitUndo
(
pDoc
,
nTab
,
nTab
);
pDoc
->
CopyToDocument
(
aNewOut
,
IDF_ALL
,
false
,
pNewUndoDoc
.
get
());
}
createUndoDoc
(
pNewUndoDoc
,
pDoc
,
aNewOut
);
pOldObj
->
Output
(
aNewOut
.
aStart
);
rDocShell
.
PostPaintGridAll
();
//! only necessary parts
...
...
@@ -1514,12 +1521,7 @@ bool ScDBDocFunc::CreatePivotTable(const ScDPObject& rDPObj, bool bRecord, bool
}
if
(
bRecord
)
{
SCTAB
nTab
=
aNewOut
.
aStart
.
Tab
();
pNewUndoDoc
.
reset
(
new
ScDocument
(
SCDOCMODE_UNDO
));
pNewUndoDoc
->
InitUndo
(
pDoc
,
nTab
,
nTab
);
pDoc
->
CopyToDocument
(
aNewOut
,
IDF_ALL
,
false
,
pNewUndoDoc
.
get
());
}
createUndoDoc
(
pNewUndoDoc
,
pDoc
,
aNewOut
);
rDestObj
.
Output
(
aNewOut
.
aStart
);
rDocShell
.
PostPaintGridAll
();
//! only necessary parts
...
...
@@ -1570,45 +1572,13 @@ bool ScDBDocFunc::UpdatePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi)
if
(
rDPObj
.
GetName
().
isEmpty
())
rDPObj
.
SetName
(
pDoc
->
GetDPCollection
()
->
CreateNewName
()
);
bool
bOverflow
=
false
;
ScRange
aNewOut
=
rDPObj
.
GetNewOutputRange
(
bOverflow
);
//! test for overlap with other data pilot tables
const
ScSheetSourceDesc
*
pSheetDesc
=
rDPObj
.
GetSheetDesc
();
if
(
pSheetDesc
&&
pSheetDesc
->
GetSourceRange
().
Intersects
(
aNewOut
))
{
ScRange
aOldRange
=
rDPObj
.
GetOutRange
();
SCsROW
nDiff
=
aOldRange
.
aStart
.
Row
()
-
aNewOut
.
aStart
.
Row
();
aNewOut
.
aStart
.
SetRow
(
aOldRange
.
aStart
.
Row
()
);
aNewOut
.
aEnd
.
SetRow
(
aNewOut
.
aEnd
.
Row
()
+
nDiff
);
if
(
!
ValidRow
(
aNewOut
.
aStart
.
Row
())
||
!
ValidRow
(
aNewOut
.
aEnd
.
Row
()))
bOverflow
=
true
;
}
if
(
bOverflow
)
ScRange
aNewOut
;
if
(
!
checkNewOutputRange
(
rDPObj
,
rDocShell
,
aNewOut
,
bApi
))
{
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
STR_PIVOT_ERROR
);
rDPObj
=
aUndoDPObj
;
return
false
;
}
{
ScEditableTester
aTester
(
pDoc
,
aNewOut
);
if
(
!
aTester
.
IsEditable
())
{
// destination area isn't editable
//! reverse everything done so far, don't proceed
if
(
!
bApi
)
rDocShell
.
ErrorMessage
(
aTester
.
GetMessageId
());
rDPObj
=
aUndoDPObj
;
return
false
;
}
}
// test if new output area is empty except for old area
if
(
!
bApi
)
{
...
...
@@ -1625,12 +1595,7 @@ bool ScDBDocFunc::UpdatePivotTable(ScDPObject& rDPObj, bool bRecord, bool bApi)
}
if
(
bRecord
)
{
SCTAB
nTab
=
aNewOut
.
aStart
.
Tab
();
pNewUndoDoc
.
reset
(
new
ScDocument
(
SCDOCMODE_UNDO
));
pNewUndoDoc
->
InitUndo
(
pDoc
,
nTab
,
nTab
);
pDoc
->
CopyToDocument
(
aNewOut
,
IDF_ALL
,
false
,
pNewUndoDoc
.
get
());
}
createUndoDoc
(
pNewUndoDoc
,
pDoc
,
aNewOut
);
rDPObj
.
Output
(
aNewOut
.
aStart
);
rDocShell
.
PostPaintGridAll
();
//! only necessary parts
...
...
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