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
d71e44e7
Kaydet (Commit)
d71e44e7
authored
Mar 15, 2013
tarafından
Kohei Yoshida
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Move some of the code to local functions to make it easier to read.
Change-Id: Ib7ca5c04ec057dbce958d580ad3b7d52d19ed21f
üst
7b6d3e8f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
46 deletions
+63
-46
column3.cxx
sc/source/core/data/column3.cxx
+63
-46
No files found.
sc/source/core/data/column3.cxx
Dosyayı görüntüle @
d71e44e7
...
@@ -303,6 +303,53 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
...
@@ -303,6 +303,53 @@ void ScColumn::DeleteRow( SCROW nStartRow, SCSIZE nSize )
pDocument
->
SetAutoCalc
(
bOldAutoCalc
);
pDocument
->
SetAutoCalc
(
bOldAutoCalc
);
}
}
namespace
{
bool
isDate
(
const
ScDocument
&
rDoc
,
const
ScColumn
&
rCol
,
SCROW
nRow
)
{
sal_uLong
nIndex
=
(
sal_uLong
)((
SfxUInt32Item
*
)
rCol
.
GetAttr
(
nRow
,
ATTR_VALUE_FORMAT
))
->
GetValue
();
short
nType
=
rDoc
.
GetFormatTable
()
->
GetType
(
nIndex
);
return
(
nType
==
NUMBERFORMAT_DATE
)
||
(
nType
==
NUMBERFORMAT_TIME
)
||
(
nType
==
NUMBERFORMAT_DATETIME
);
}
bool
checkDeleteCellByFlag
(
CellType
eCellType
,
sal_uInt16
nDelFlag
,
const
ScDocument
&
rDoc
,
const
ScColumn
&
rCol
,
const
ColEntry
&
rEntry
)
{
bool
bDelete
=
false
;
switch
(
eCellType
)
{
case
CELLTYPE_VALUE
:
{
sal_uInt16
nValFlags
=
nDelFlag
&
(
IDF_DATETIME
|
IDF_VALUE
);
// delete values and dates?
bDelete
=
nValFlags
==
(
IDF_DATETIME
|
IDF_VALUE
);
// if not, decide according to cell number format
if
(
!
bDelete
&&
(
nValFlags
!=
0
))
{
bool
bIsDate
=
isDate
(
rDoc
,
rCol
,
rEntry
.
nRow
);
bDelete
=
nValFlags
==
(
bIsDate
?
IDF_DATETIME
:
IDF_VALUE
);
}
}
break
;
case
CELLTYPE_STRING
:
case
CELLTYPE_EDIT
:
bDelete
=
(
nDelFlag
&
IDF_STRING
)
!=
0
;
break
;
case
CELLTYPE_FORMULA
:
bDelete
=
(
nDelFlag
&
IDF_FORMULA
)
!=
0
;
break
;
case
CELLTYPE_NOTE
:
// do note delete note cell with broadcaster
bDelete
=
!
rEntry
.
pCell
->
GetBroadcaster
();
break
;
default
:
;
// added to avoid warnings
}
return
bDelete
;
}
}
void
ScColumn
::
DeleteRange
(
SCSIZE
nStartIndex
,
SCSIZE
nEndIndex
,
sal_uInt16
nDelFlag
)
void
ScColumn
::
DeleteRange
(
SCSIZE
nStartIndex
,
SCSIZE
nEndIndex
,
sal_uInt16
nDelFlag
)
{
{
...
@@ -323,7 +370,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
...
@@ -323,7 +370,7 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
typedef
mdds
::
flat_segment_tree
<
SCSIZE
,
bool
>
RemovedSegments_t
;
typedef
mdds
::
flat_segment_tree
<
SCSIZE
,
bool
>
RemovedSegments_t
;
RemovedSegments_t
aRemovedSegments
(
nStartIndex
,
maItems
.
size
(),
false
);
RemovedSegments_t
aRemovedSegments
(
nStartIndex
,
maItems
.
size
(),
false
);
SCSIZE
nFirst
(
nStartIndex
)
;
SCSIZE
nFirst
=
nStartIndex
;
// dummy replacement for old cells, to prevent that interpreter uses old cell
// dummy replacement for old cells, to prevent that interpreter uses old cell
boost
::
scoped_ptr
<
ScNoteCell
>
pDummyCell
(
new
ScNoteCell
);
boost
::
scoped_ptr
<
ScNoteCell
>
pDummyCell
(
new
ScNoteCell
);
...
@@ -357,57 +404,27 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
...
@@ -357,57 +404,27 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
ScBaseCell
*
pOldCell
=
maItems
[
nIdx
].
pCell
;
ScBaseCell
*
pOldCell
=
maItems
[
nIdx
].
pCell
;
CellType
eCellType
=
pOldCell
->
GetCellType
();
CellType
eCellType
=
pOldCell
->
GetCellType
();
if
((
nDelFlag
&
IDF_CONTENTS
)
==
IDF_CONTENTS
)
if
((
nDelFlag
&
IDF_CONTENTS
)
==
IDF_CONTENTS
)
// All cell types to be deleted.
bDelete
=
true
;
bDelete
=
true
;
else
else
{
{
// decide whether to delete the cell object according to passed
// Decide whether to delete the cell object according to passed
// flags
// flags.
switch
(
eCellType
)
bDelete
=
checkDeleteCellByFlag
(
eCellType
,
nDelFlag
,
*
pDocument
,
*
this
,
maItems
[
nIdx
]);
{
case
CELLTYPE_VALUE
:
{
sal_uInt16
nValFlags
=
nDelFlag
&
(
IDF_DATETIME
|
IDF_VALUE
);
// delete values and dates?
bDelete
=
nValFlags
==
(
IDF_DATETIME
|
IDF_VALUE
);
// if not, decide according to cell number format
if
(
!
bDelete
&&
(
nValFlags
!=
0
))
{
sal_uLong
nIndex
=
(
sal_uLong
)((
SfxUInt32Item
*
)
GetAttr
(
maItems
[
nIdx
].
nRow
,
ATTR_VALUE_FORMAT
))
->
GetValue
();
short
nType
=
pDocument
->
GetFormatTable
()
->
GetType
(
nIndex
);
bool
bIsDate
=
(
nType
==
NUMBERFORMAT_DATE
)
||
(
nType
==
NUMBERFORMAT_TIME
)
||
(
nType
==
NUMBERFORMAT_DATETIME
);
bDelete
=
nValFlags
==
(
bIsDate
?
IDF_DATETIME
:
IDF_VALUE
);
}
}
break
;
case
CELLTYPE_STRING
:
case
CELLTYPE_EDIT
:
bDelete
=
(
nDelFlag
&
IDF_STRING
)
!=
0
;
break
;
case
CELLTYPE_FORMULA
:
bDelete
=
(
nDelFlag
&
IDF_FORMULA
)
!=
0
;
break
;
case
CELLTYPE_NOTE
:
// do note delete note cell with broadcaster
bDelete
=
!
pOldCell
->
GetBroadcaster
();
break
;
default
:
;
// added to avoid warnings
}
}
}
if
(
bDelete
)
if
(
bDelete
)
{
{
//
try to create a replacement note cell, if note or broadcaster exists
//
Try to create a replacement "note" cell if broadcaster exists.
ScNoteCell
*
pNoteCell
=
NULL
;
ScNoteCell
*
pNoteCell
=
NULL
;
SvtBroadcaster
*
pBC
=
pOldCell
->
GetBroadcaster
();
SvtBroadcaster
*
pBC
=
pOldCell
->
GetBroadcaster
();
if
(
pBC
&&
pBC
->
HasListeners
())
if
(
pBC
&&
pBC
->
HasListeners
())
{
{
pNoteCell
=
new
ScNoteCell
(
pBC
);
// NOTE: the broadcaster here is transferred and released only
//
NOTE: the broadcaster here is transferred and released
//
if it has listeners! If it does not, it will simply be
//
only if it has listeners! If it does not, it will simply
//
deleted when the cell is deleted and no replacement cell is
//
be deleted when the cell is deleted and no replacement
//
created.
// cell is created.
pNoteCell
=
new
ScNoteCell
(
pBC
);
pOldCell
->
ReleaseBroadcaster
();
pOldCell
->
ReleaseBroadcaster
();
}
}
...
@@ -423,16 +440,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
...
@@ -423,16 +440,16 @@ void ScColumn::DeleteRange( SCSIZE nStartIndex, SCSIZE nEndIndex, sal_uInt16 nDe
else
else
maItems
[
nIdx
].
pCell
=
pDummyCell
.
get
();
maItems
[
nIdx
].
pCell
=
pDummyCell
.
get
();
// cache formula cells (will be deleted later), delete cell of other type
if
(
eCellType
==
CELLTYPE_FORMULA
)
if
(
eCellType
==
CELLTYPE_FORMULA
)
{
{
aDelCells
.
push_back
(
static_cast
<
ScFormulaCell
*
>
(
pOldCell
)
);
// Cache formula cells (will be deleted later), delete cell of other type.
aDelCells
.
push_back
(
static_cast
<
ScFormulaCell
*>
(
pOldCell
));
}
}
else
else
{
{
aHint
.
GetAddress
().
SetRow
(
nOldRow
);
aHint
.
GetAddress
().
SetRow
(
nOldRow
);
aHint
.
SetCell
(
pNoteCell
?
pNoteCell
:
pOldCell
);
aHint
.
SetCell
(
pNoteCell
?
pNoteCell
:
pOldCell
);
pDocument
->
Broadcast
(
aHint
);
pDocument
->
Broadcast
(
aHint
);
if
(
pNoteCell
!=
pOldCell
)
if
(
pNoteCell
!=
pOldCell
)
{
{
pOldCell
->
Delete
();
pOldCell
->
Delete
();
...
...
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