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
d961b694
Kaydet (Commit)
d961b694
authored
May 18, 2012
tarafından
Markus Mohrhard
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
implement databar import from oox
Change-Id: Id510acbc7291b94610e0e2c769d8cee582baa9a7
üst
862f56d1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
203 additions
and
10 deletions
+203
-10
condformatbuffer.hxx
sc/source/filter/inc/condformatbuffer.hxx
+21
-0
condformatcontext.hxx
sc/source/filter/inc/condformatcontext.hxx
+11
-2
condformatbuffer.cxx
sc/source/filter/oox/condformatbuffer.cxx
+136
-6
condformatcontext.cxx
sc/source/filter/oox/condformatcontext.cxx
+35
-2
No files found.
sc/source/filter/inc/condformatbuffer.hxx
Dosyayı görüntüle @
d961b694
...
...
@@ -39,6 +39,8 @@ namespace com { namespace sun { namespace star {
namespace
sheet
{
class
XSheetConditionalEntries
;
}
}
}
}
class
ScColorScaleFormat
;
class
ScDataBarFormat
;
struct
ScDataBarFormatData
;
namespace
oox
{
namespace
xls
{
...
...
@@ -112,6 +114,23 @@ private:
sal_uInt32
mnCol
;
};
class
DataBarRule
:
public
WorksheetHelper
{
public
:
DataBarRule
(
const
CondFormat
&
rFormat
);
void
importCfvo
(
const
AttributeList
&
rAttribs
);
void
importColor
(
const
AttributeList
&
rAttribs
);
void
SetData
(
ScDataBarFormat
*
pFormat
,
ScDocument
*
pDoc
,
const
ScAddress
&
rAddr
);
private
:
const
CondFormat
&
mrCondFormat
;
ScDataBarFormatData
*
mpFormat
;
boost
::
scoped_ptr
<
ColorScaleRuleModelEntry
>
mpUpperLimit
;
boost
::
scoped_ptr
<
ColorScaleRuleModelEntry
>
mpLowerLimit
;
};
// ============================================================================
...
...
@@ -138,11 +157,13 @@ public:
inline
sal_Int32
getPriority
()
const
{
return
maModel
.
mnPriority
;
}
ColorScaleRule
*
getColorScale
();
DataBarRule
*
getDataBar
();
private
:
const
CondFormat
&
mrCondFormat
;
CondFormatRuleModel
maModel
;
boost
::
scoped_ptr
<
ColorScaleRule
>
mpColor
;
boost
::
scoped_ptr
<
DataBarRule
>
mpDataBar
;
};
typedef
::
boost
::
shared_ptr
<
CondFormatRule
>
CondFormatRuleRef
;
...
...
sc/source/filter/inc/condformatcontext.hxx
Dosyayı görüntüle @
d961b694
...
...
@@ -48,8 +48,17 @@ public:
virtual
void
onStartElement
(
const
AttributeList
&
rAttribs
);
virtual
void
onCharacters
(
const
::
rtl
::
OUString
&
rChars
);
virtual
::
oox
::
core
::
ContextHandlerRef
onCreateRecordContext
(
sal_Int32
nRecId
,
SequenceInputStream
&
rStrm
);
virtual
void
onStartRecord
(
SequenceInputStream
&
rStrm
);
private
:
CondFormatRuleRef
mxRule
;
};
class
DataBarContext
:
public
WorksheetContextBase
{
public
:
explicit
DataBarContext
(
CondFormatContext
&
rFormat
,
CondFormatRuleRef
xRule
);
virtual
::
oox
::
core
::
ContextHandlerRef
onCreateContext
(
sal_Int32
nElement
,
const
AttributeList
&
rAttribs
);
virtual
void
onStartElement
(
const
AttributeList
&
rAttribs
);
private
:
CondFormatRuleRef
mxRule
;
...
...
sc/source/filter/oox/condformatbuffer.cxx
Dosyayı görüntüle @
d961b694
...
...
@@ -224,12 +224,11 @@ void ColorScaleRule::importColor( const AttributeList& rAttribs )
++
mnCol
;
}
void
ColorScaleRule
::
AddEntries
(
ScColorScaleFormat
*
pFormat
,
ScDocument
*
pDoc
,
const
ScAddress
&
rAddr
)
namespace
{
ScColorScaleEntry
*
ConvertToModel
(
const
ColorScaleRuleModelEntry
&
rEntry
,
ScDocument
*
pDoc
,
const
ScAddress
&
rAddr
)
{
for
(
size_t
i
=
0
;
i
<
maColorScaleRuleEntries
.
size
();
++
i
)
{
ScColorScaleEntry
*
pEntry
=
new
ScColorScaleEntry
(
maColorScaleRuleEntries
[
i
].
mnVal
,
maColorScaleRuleEntries
[
i
].
maColor
);
const
ColorScaleRuleModelEntry
&
rEntry
=
maColorScaleRuleEntries
[
i
];
ScColorScaleEntry
*
pEntry
=
new
ScColorScaleEntry
(
rEntry
.
mnVal
,
rEntry
.
maColor
);
if
(
rEntry
.
mbMin
)
pEntry
->
SetMin
(
true
);
...
...
@@ -241,10 +240,104 @@ void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc,
if
(
!
rEntry
.
maFormula
.
isEmpty
())
pEntry
->
SetFormula
(
rEntry
.
maFormula
,
pDoc
,
rAddr
,
formula
::
FormulaGrammar
::
GRAM_ENGLISH_XL_A1
);
return
pEntry
;
}
}
void
ColorScaleRule
::
AddEntries
(
ScColorScaleFormat
*
pFormat
,
ScDocument
*
pDoc
,
const
ScAddress
&
rAddr
)
{
for
(
size_t
i
=
0
;
i
<
maColorScaleRuleEntries
.
size
();
++
i
)
{
const
ColorScaleRuleModelEntry
&
rEntry
=
maColorScaleRuleEntries
[
i
];
ScColorScaleEntry
*
pEntry
=
ConvertToModel
(
rEntry
,
pDoc
,
rAddr
);
pFormat
->
AddEntry
(
pEntry
);
}
}
// ============================================================================
//
DataBarRule
::
DataBarRule
(
const
CondFormat
&
rFormat
)
:
WorksheetHelper
(
rFormat
),
mrCondFormat
(
rFormat
),
mpFormat
(
new
ScDataBarFormatData
)
{
}
void
DataBarRule
::
importColor
(
const
AttributeList
&
rAttribs
)
{
sal_Int32
nColor
=
0
;
if
(
rAttribs
.
hasAttribute
(
XML_rgb
)
)
nColor
=
rAttribs
.
getIntegerHex
(
XML_rgb
,
API_RGB_TRANSPARENT
);
else
if
(
rAttribs
.
hasAttribute
(
XML_theme
)
)
{
sal_uInt32
nThemeIndex
=
rAttribs
.
getUnsigned
(
XML_theme
,
0
);
nColor
=
getTheme
().
getColorByToken
(
nThemeIndex
);
}
::
Color
aColor
=
RgbToRgbComponents
(
nColor
);
mpFormat
->
maPositiveColor
=
aColor
;
}
void
DataBarRule
::
importCfvo
(
const
AttributeList
&
rAttribs
)
{
ColorScaleRuleModelEntry
*
pEntry
;
if
(
!
mpLowerLimit
)
{
mpLowerLimit
.
reset
(
new
ColorScaleRuleModelEntry
);
pEntry
=
mpLowerLimit
.
get
();
}
else
{
mpUpperLimit
.
reset
(
new
ColorScaleRuleModelEntry
);
pEntry
=
mpUpperLimit
.
get
();
}
rtl
::
OUString
aType
=
rAttribs
.
getString
(
XML_type
,
rtl
::
OUString
()
);
double
nVal
=
rAttribs
.
getDouble
(
XML_val
,
0.0
);
pEntry
->
mnVal
=
nVal
;
if
(
aType
==
"num"
)
{
// nothing to do
}
else
if
(
aType
==
"min"
)
{
pEntry
->
mbMin
=
true
;
}
else
if
(
aType
==
"max"
)
{
pEntry
->
mbMax
=
true
;
}
else
if
(
aType
==
"percent"
)
{
pEntry
->
mbPercent
=
true
;
}
else
if
(
aType
==
"percentile"
)
{
// this is most likely wrong but I have no idea what the difference
// between percent and percentile should be when calculating colors
pEntry
->
mbPercent
=
true
;
}
else
if
(
aType
==
"formula"
)
{
rtl
::
OUString
aFormula
=
rAttribs
.
getString
(
XML_val
,
rtl
::
OUString
()
);
pEntry
->
maFormula
=
aFormula
;
}
}
void
DataBarRule
::
SetData
(
ScDataBarFormat
*
pFormat
,
ScDocument
*
pDoc
,
const
ScAddress
&
rAddr
)
{
ScColorScaleEntry
*
pUpperEntry
=
ConvertToModel
(
*
mpUpperLimit
.
get
(),
pDoc
,
rAddr
);
ScColorScaleEntry
*
pLowerEntry
=
ConvertToModel
(
*
mpLowerLimit
.
get
(),
pDoc
,
rAddr
);
mpFormat
->
mpUpperLimit
.
reset
(
pUpperEntry
);
mpFormat
->
mpLowerLimit
.
reset
(
pLowerEntry
);
pFormat
->
SetDataBarData
(
mpFormat
);
}
// ============================================================================
CondFormatRuleModel
::
CondFormatRuleModel
()
:
...
...
@@ -712,7 +805,7 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
ScDocument
&
rDoc
=
getScDocument
();
ScColorScaleFormat
*
pFormat
=
new
ScColorScaleFormat
(
&
rDoc
);
sal_Int32
nIndex
=
rDoc
.
AddColor
Scale
Format
(
pFormat
);
sal_Int32
nIndex
=
rDoc
.
AddColorFormat
(
pFormat
);
ScRangeList
aList
;
// apply attributes to cells
...
...
@@ -736,15 +829,52 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
else
mpColor
->
AddEntries
(
pFormat
,
&
rDoc
,
ScAddress
()
);
}
else
if
(
mpDataBar
)
{
ScRangeList
aList
;
ScDocument
&
rDoc
=
getScDocument
();
ScDataBarFormat
*
pFormat
=
new
ScDataBarFormat
(
&
rDoc
);
sal_Int32
nIndex
=
rDoc
.
AddColorFormat
(
pFormat
);
// apply attributes to cells
//
const
ApiCellRangeList
&
rRanges
=
mrCondFormat
.
getRanges
();
for
(
ApiCellRangeList
::
const_iterator
itr
=
rRanges
.
begin
();
itr
!=
rRanges
.
end
();
++
itr
)
{
ScRange
aRange
;
ScUnoConversion
::
FillScRange
(
aRange
,
*
itr
);
ScPatternAttr
aPattern
(
rDoc
.
GetPool
()
);
aPattern
.
GetItemSet
().
Put
(
SfxUInt32Item
(
ATTR_COLORSCALE
,
nIndex
)
);
ScMarkData
aMarkData
;
aMarkData
.
SetMarkArea
(
aRange
);
rDoc
.
ApplySelectionPattern
(
aPattern
,
aMarkData
);
aList
.
Append
(
aRange
);
}
pFormat
->
SetRange
(
aList
);
mpDataBar
->
SetData
(
pFormat
,
&
rDoc
,
aList
.
front
()
->
aStart
);
}
}
ColorScaleRule
*
CondFormatRule
::
getColorScale
()
{
if
(
!
mpColor
)
mpColor
.
reset
(
new
ColorScaleRule
(
mrCondFormat
)
);
return
mpColor
.
get
();
}
DataBarRule
*
CondFormatRule
::
getDataBar
()
{
if
(
!
mpDataBar
)
mpDataBar
.
reset
(
new
DataBarRule
(
mrCondFormat
)
);
return
mpDataBar
.
get
();
}
// ============================================================================
CondFormatModel
::
CondFormatModel
()
:
...
...
sc/source/filter/oox/condformatcontext.cxx
Dosyayı görüntüle @
d961b694
...
...
@@ -79,15 +79,46 @@ void ColorScaleContext::onCharacters( const OUString& )
}
ContextHandlerRef
ColorScaleContext
::
onCreateRecordContext
(
sal_Int32
,
SequenceInputStream
&
)
// ============================================================================
DataBarContext
::
DataBarContext
(
CondFormatContext
&
rFragment
,
CondFormatRuleRef
xRule
)
:
WorksheetContextBase
(
rFragment
),
mxRule
(
xRule
)
{
}
ContextHandlerRef
DataBarContext
::
onCreateContext
(
sal_Int32
nElement
,
const
AttributeList
&
)
{
switch
(
getCurrentElement
()
)
{
case
XLS_TOKEN
(
cfRule
):
return
(
nElement
==
XLS_TOKEN
(
colorScale
))
?
this
:
0
;
case
XLS_TOKEN
(
dataBar
):
if
(
nElement
==
XLS_TOKEN
(
cfvo
))
return
this
;
else
if
(
nElement
==
XLS_TOKEN
(
color
))
return
this
;
else
return
0
;
}
return
0
;
}
void
ColorScaleContext
::
onStartRecord
(
SequenceInputStream
&
)
void
DataBarContext
::
onStartElement
(
const
AttributeList
&
rAttribs
)
{
switch
(
getCurrentElement
()
)
{
case
XLS_TOKEN
(
cfvo
):
mxRule
->
getDataBar
()
->
importCfvo
(
rAttribs
);
break
;
case
XLS_TOKEN
(
color
):
mxRule
->
getDataBar
()
->
importColor
(
rAttribs
);
break
;
}
}
// ============================================================================
CondFormatContext
::
CondFormatContext
(
WorksheetFragmentBase
&
rFragment
)
:
WorksheetContextBase
(
rFragment
)
{
...
...
@@ -104,6 +135,8 @@ ContextHandlerRef CondFormatContext::onCreateContext( sal_Int32 nElement, const
return
this
;
else
if
(
nElement
==
XLS_TOKEN
(
colorScale
)
)
return
new
ColorScaleContext
(
*
this
,
mxRule
);
else
if
(
nElement
==
XLS_TOKEN
(
dataBar
)
)
return
new
DataBarContext
(
*
this
,
mxRule
);
else
return
0
;
}
...
...
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