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
24933a3c
Kaydet (Commit)
24933a3c
authored
Tem 01, 2014
tarafından
Krisztian Pinter
Kaydeden (comit)
Tomaž Vajngerl
Eyl 17, 2014
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Add GIMP palette loading code
Change-Id: Ie0d0787342bc806a1848cb904114f0ca16c9df69
üst
9b37819a
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
118 additions
and
5 deletions
+118
-5
SvxColorValueSet.hxx
include/svx/SvxColorValueSet.hxx
+12
-1
SvxColorValueSet.cxx
svx/source/tbxctrls/SvxColorValueSet.cxx
+106
-4
No files found.
include/svx/SvxColorValueSet.hxx
Dosyayı görüntüle @
24933a3c
...
...
@@ -24,6 +24,16 @@
class
XColorList
;
struct
Palette
{
typedef
std
::
pair
<
Color
,
OString
>
NamedColor
;
typedef
std
::
vector
<
NamedColor
>
ColorList
;
Palette
(){};
Palette
(
const
OUString
&
rFname
);
OString
maName
;
ColorList
maColors
;
};
class
SVX_DLLPUBLIC
SvxColorValueSet
:
public
ValueSet
{
private
:
...
...
@@ -39,7 +49,8 @@ public:
sal_uInt32
getColumnCount
()
const
;
void
addEntriesForXColorList
(
const
XColorList
&
rXColorList
,
sal_uInt32
nStartIndex
=
1
);
void
addEntriesForColorVector
(
const
std
::
vector
<
Color
>&
rColorVector
,
sal_uInt32
nStartIndex
=
1
);
void
loadColorVector
(
const
std
::
vector
<
Color
>&
rColorVector
,
const
OUString
&
rNamePrefix
,
sal_uInt32
nStartIndex
=
1
);
void
loadPalette
(
const
Palette
&
rPalette
);
Size
layoutAllVisible
(
sal_uInt32
nEntryCount
);
Size
layoutToGivenHeight
(
sal_uInt32
nHeight
,
sal_uInt32
nEntryCount
);
};
...
...
svx/source/tbxctrls/SvxColorValueSet.cxx
Dosyayı görüntüle @
24933a3c
...
...
@@ -24,6 +24,83 @@
#include <vcl/settings.hxx>
// finds first token in rStr from index, separated by whitespace
// returns position of next token in index
OString
lcl_getToken
(
const
OString
&
rStr
,
sal_Int32
&
index
)
{
sal_Int32
substart
,
toklen
=
0
;
while
(
index
<
rStr
.
getLength
()
&&
(
rStr
[
index
]
==
' '
||
rStr
[
index
]
==
'\n'
||
rStr
[
index
]
==
'\t'
))
++
index
;
if
(
index
==
rStr
.
getLength
())
{
index
=
-
1
;
return
OString
();
}
substart
=
index
;
while
(
index
<
rStr
.
getLength
()
&&
!
(
rStr
[
index
]
==
' '
||
rStr
[
index
]
==
'\n'
||
rStr
[
index
]
==
'\t'
))
{
++
index
;
++
toklen
;
}
while
(
index
<
rStr
.
getLength
()
&&
(
rStr
[
index
]
==
' '
||
rStr
[
index
]
==
'\n'
||
rStr
[
index
]
==
'\t'
))
++
index
;
if
(
index
==
rStr
.
getLength
())
index
=
-
1
;
return
rStr
.
copy
(
substart
,
toklen
);
}
Palette
::
Palette
(
const
OUString
&
rFname
)
{
// TODO add error handling!!!
SvFileStream
aFile
(
rFname
,
STREAM_READ
);
OString
aPaletteName
;
OString
aLine
;
aFile
.
ReadLine
(
aLine
);
if
(
!
aLine
.
startsWith
(
"GIMP Palette"
)
)
return
;
aFile
.
ReadLine
(
aLine
);
if
(
aLine
.
startsWith
(
"Name: "
,
&
aPaletteName
)
)
{
aFile
.
ReadLine
(
aLine
);
if
(
aLine
.
startsWith
(
"Columns: "
))
aFile
.
ReadLine
(
aLine
);
// we can ignore this
}
do
{
if
(
aLine
[
0
]
!=
'#'
&&
aLine
[
0
]
!=
'\n'
)
{
// TODO check if r,g,b are 0<= x <=255, or just clamp?
sal_Int32
nIndex
=
0
;
OString
token
;
token
=
lcl_getToken
(
aLine
,
nIndex
);
if
(
token
==
""
||
nIndex
==
-
1
)
continue
;
sal_Int32
r
=
token
.
toInt32
();
token
=
lcl_getToken
(
aLine
,
nIndex
);
if
(
token
==
""
||
nIndex
==
-
1
)
continue
;
sal_Int32
g
=
token
.
toInt32
();
token
=
lcl_getToken
(
aLine
,
nIndex
);
if
(
token
==
""
)
continue
;
sal_Int32
b
=
token
.
toInt32
();
OString
name
;
if
(
nIndex
!=
-
1
)
name
=
aLine
.
copy
(
nIndex
);
maColors
.
push_back
(
std
::
make_pair
(
Color
(
r
,
g
,
b
),
name
));
}
}
while
(
aFile
.
ReadLine
(
aLine
));
}
SvxColorValueSet
::
SvxColorValueSet
(
Window
*
_pParent
,
WinBits
nWinStyle
)
:
ValueSet
(
_pParent
,
nWinStyle
)
...
...
@@ -88,12 +165,37 @@ void SvxColorValueSet::addEntriesForXColorList(const XColorList& rXColorList, sa
}
}
void
SvxColorValueSet
::
addEntriesForColorVector
(
const
std
::
vector
<
Color
>&
rColorVector
,
sal_uInt32
nStartIndex
)
void
SvxColorValueSet
::
loadColorVector
(
const
std
::
vector
<
Color
>&
rColorVector
,
const
OUString
&
rNamePrefix
,
sal_uInt32
nStartIndex
)
{
if
(
rNamePrefix
.
getLength
()
!=
0
)
{
for
(
std
::
vector
<
Color
>::
const_iterator
it
=
rColorVector
.
begin
();
it
!=
rColorVector
.
end
();
it
++
,
nStartIndex
++
)
{
InsertItem
(
nStartIndex
,
*
it
,
rNamePrefix
+
OUString
::
number
(
nStartIndex
));
}
}
else
{
for
(
std
::
vector
<
Color
>::
const_iterator
it
=
rColorVector
.
begin
();
it
!=
rColorVector
.
end
();
it
++
,
nStartIndex
++
)
{
InsertItem
(
nStartIndex
,
*
it
,
""
);
}
}
}
void
SvxColorValueSet
::
loadPalette
(
const
Palette
&
rPalette
)
{
for
(
std
::
vector
<
Color
>::
const_iterator
it
=
rColorVector
.
begin
();
it
!=
rColorVector
.
end
();
it
++
,
nStartIndex
++
)
const
Palette
::
ColorList
&
rColors
=
rPalette
.
maColors
;
Clear
();
int
nIx
=
1
;
for
(
Palette
::
ColorList
::
const_iterator
it
=
rColors
.
begin
();
it
!=
rColors
.
end
();
++
it
)
{
InsertItem
(
nStartIndex
,
*
it
,
""
);
InsertItem
(
nIx
,
it
->
first
,
OStringToOUString
(
it
->
second
,
RTL_TEXTENCODING_ASCII_US
));
++
nIx
;
}
}
...
...
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