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
ecbbf4c7
Kaydet (Commit)
ecbbf4c7
authored
Tem 10, 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
Change SvxColorWindow_Impl to use ComboBox for palette selection
Change-Id: I0fb9b46298f45bbdf9ae9198c145b9ea5e403bbf
üst
9ca7c501
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
129 additions
and
82 deletions
+129
-82
Palette.hxx
include/svx/Palette.hxx
+13
-6
PaletteManager.hxx
include/svx/PaletteManager.hxx
+4
-2
Palette.cxx
svx/source/tbxctrls/Palette.cxx
+47
-19
PaletteManager.cxx
svx/source/tbxctrls/PaletteManager.cxx
+38
-13
colorwindow.hxx
svx/source/tbxctrls/colorwindow.hxx
+5
-7
tbcontrl.cxx
svx/source/tbxctrls/tbcontrl.cxx
+22
-35
No files found.
include/svx/Palette.hxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -21,6 +21,7 @@
#include <rtl/ustring.hxx>
#include <tools/color.hxx>
#include <tools/stream.hxx>
class
Palette
{
...
...
@@ -28,17 +29,23 @@ public:
typedef
std
::
pair
<
Color
,
OString
>
NamedColor
;
typedef
std
::
vector
<
NamedColor
>
ColorList
;
private
:
bool
mbLoaded
;
OUString
maFname
;
OString
maName
;
bool
mbLoadedPalette
;
bool
mbValidPalette
;
OUString
maFName
;
OUString
maFPath
;
OUString
maName
;
ColorList
maColors
;
void
LoadPalette
();
bool
ReadPaletteHeader
(
SvFileStream
&
rFileStream
);
void
LoadPaletteHeader
();
void
LoadPalette
();
public
:
Palette
(
const
OUString
&
rFname
);
Palette
(
const
OUString
&
rFPath
,
const
OUString
&
rFName
);
const
O
String
&
GetPalette
Name
();
const
O
UString
&
Get
Name
();
const
ColorList
&
GetPaletteColors
();
bool
IsValid
();
};
#endif // INCLUDED_SVX_PALETTE_HXX
...
...
include/svx/PaletteManager.hxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -37,8 +37,10 @@ public:
PaletteManager
();
void
LoadPalettes
();
void
ReloadColorSet
(
SvxColorValueSet
&
rColorSet
);
void
PrevPalette
();
void
NextPalette
();
std
::
vector
<
OUString
>
GetPaletteList
();
void
SetPalette
(
sal_Int32
nPos
);
sal_Int32
GetPalette
();
long
GetColorCount
();
OUString
GetPaletteName
();
const
Color
&
GetLastColor
();
...
...
svx/source/tbxctrls/Palette.cxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -18,7 +18,6 @@
*/
#include <svx/Palette.hxx>
#include <tools/stream.hxx>
// finds first token in rStr from index, separated by whitespace
// returns position of next token in index
...
...
@@ -52,13 +51,17 @@ OString lcl_getToken(const OString& rStr, sal_Int32& index)
return
rStr
.
copy
(
substart
,
toklen
);
}
Palette
::
Palette
(
const
OUString
&
rFname
)
:
mbLoaded
(
false
),
maFname
(
rFname
){}
Palette
::
Palette
(
const
OUString
&
rFPath
,
const
OUString
&
rFName
)
:
mbLoadedPalette
(
false
),
mbValidPalette
(
false
),
maFName
(
rFName
),
maFPath
(
rFPath
)
{
LoadPaletteHeader
();
}
const
O
String
&
Palette
::
GetPalette
Name
()
const
O
UString
&
Palette
::
Get
Name
()
{
LoadPalette
();
return
maName
;
}
...
...
@@ -68,27 +71,52 @@ const Palette::ColorList& Palette::GetPaletteColors()
return
maColors
;
}
void
Palette
::
LoadPalette
()
bool
Palette
::
IsValid
()
{
if
(
mbLoaded
)
return
;
mbLoaded
=
true
;
// TODO add error handling!!!
SvFileStream
aFile
(
maFname
,
STREAM_READ
);
return
mbValidPalette
;
}
bool
Palette
::
ReadPaletteHeader
(
SvFileStream
&
rFileStream
)
{
OString
aLine
;
OString
aName
;
aFile
.
ReadLine
(
aLine
);
if
(
!
aLine
.
startsWith
(
"GIMP Palette"
)
)
return
;
aFile
.
ReadLine
(
aLine
);
if
(
aLine
.
startsWith
(
"Name: "
,
&
m
aName
)
)
rFileStream
.
ReadLine
(
aLine
);
if
(
!
aLine
.
startsWith
(
"GIMP Palette"
)
)
return
false
;
rFileStream
.
ReadLine
(
aLine
);
if
(
aLine
.
startsWith
(
"Name: "
,
&
aName
)
)
{
aFile
.
ReadLine
(
aLine
);
maName
=
OStringToOUString
(
aName
,
RTL_TEXTENCODING_ASCII_US
);
rFileStream
.
ReadLine
(
aLine
);
if
(
aLine
.
startsWith
(
"Columns: "
))
aFile
.
ReadLine
(
aLine
);
// we can ignore this
rFileStream
.
ReadLine
(
aLine
);
// we can ignore this
}
else
{
maName
=
maFName
;
}
return
true
;
}
//TODO make this LoadPaletteHeader and set a bool if palette is incorrect
void
Palette
::
LoadPaletteHeader
()
{
SvFileStream
aFile
(
maFPath
,
STREAM_READ
);
mbValidPalette
=
ReadPaletteHeader
(
aFile
);
}
void
Palette
::
LoadPalette
()
{
if
(
mbLoadedPalette
)
return
;
mbLoadedPalette
=
true
;
// TODO add error handling!!!
SvFileStream
aFile
(
maFPath
,
STREAM_READ
);
mbValidPalette
=
ReadPaletteHeader
(
aFile
);
if
(
!
mbValidPalette
)
return
;
OString
aLine
;
do
{
if
(
aLine
[
0
]
!=
'#'
&&
aLine
[
0
]
!=
'\n'
)
{
...
...
svx/source/tbxctrls/PaletteManager.cxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -25,6 +25,10 @@
#include <svx/dialogs.hrc>
#include <svtools/colrdlg.hxx>
#define STR_DEFAULT_PAL "Default palette"
#define STR_DOC_COLORS "Document colors"
#define STR_DOC_COLOR_PREFIX "Document Color "
PaletteManager
::
PaletteManager
()
:
mnNumOfPalettes
(
2
),
mnCurrentPalette
(
0
),
...
...
@@ -42,7 +46,9 @@ void PaletteManager::LoadPalettes()
osl
::
Directory
aDir
(
aPalPath
);
maPalettes
.
clear
();
osl
::
DirectoryItem
aDirItem
;
osl
::
FileStatus
aFileStat
(
osl_FileStatus_Mask_FileURL
|
osl_FileStatus_Mask_Type
);
osl
::
FileStatus
aFileStat
(
osl_FileStatus_Mask_FileName
|
osl_FileStatus_Mask_FileURL
|
osl_FileStatus_Mask_Type
);
if
(
aDir
.
open
()
==
osl
::
FileBase
::
E_None
)
{
while
(
aDir
.
getNextItem
(
aDirItem
)
==
osl
::
FileBase
::
E_None
)
...
...
@@ -50,11 +56,12 @@ void PaletteManager::LoadPalettes()
aDirItem
.
getFileStatus
(
aFileStat
);
if
(
aFileStat
.
isRegular
()
||
aFileStat
.
isLink
())
{
OUString
aPath
=
aFileStat
.
getFileURL
();
if
(
aPath
.
getLength
()
>
4
&&
aPath
.
copy
(
aPath
.
getLength
()
-
4
).
toAsciiLowerCase
()
==
".gpl"
)
OUString
aFName
=
aFileStat
.
getFileName
();
if
(
aFName
.
endsWithIgnoreAsciiCase
(
".gpl"
)
)
{
maPalettes
.
push_back
(
Palette
(
aPath
));
Palette
aPalette
(
aFileStat
.
getFileURL
(),
aFName
);
if
(
aPalette
.
IsValid
()
)
maPalettes
.
push_back
(
aPalette
);
}
}
}
...
...
@@ -93,7 +100,7 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
std
::
vector
<
Color
>
aColors
=
pDocSh
->
GetDocColors
();
mnColorCount
=
aColors
.
size
();
rColorSet
.
Clear
();
rColorSet
.
loadColorVector
(
aColors
,
"Document Color "
);
rColorSet
.
loadColorVector
(
aColors
,
STR_DOC_COLOR_PREFIX
);
}
else
{
...
...
@@ -104,14 +111,32 @@ void PaletteManager::ReloadColorSet(SvxColorValueSet &rColorSet)
}
}
void
PaletteManager
::
PrevPalette
()
std
::
vector
<
OUString
>
PaletteManager
::
GetPaletteList
()
{
std
::
vector
<
OUString
>
aPaletteNames
;
aPaletteNames
.
push_back
(
STR_DEFAULT_PAL
);
for
(
std
::
vector
<
Palette
>::
iterator
it
=
maPalettes
.
begin
();
it
!=
maPalettes
.
end
();
++
it
)
{
aPaletteNames
.
push_back
(
it
->
GetName
()
);
}
aPaletteNames
.
push_back
(
STR_DOC_COLORS
);
return
aPaletteNames
;
}
void
PaletteManager
::
SetPalette
(
sal_Int32
nPos
)
{
mnCurrentPalette
=
mnCurrentPalette
==
0
?
mnNumOfPalettes
-
1
:
mnCurrentPalette
-
1
;
mnCurrentPalette
=
nPos
;
}
void
PaletteManager
::
Nex
tPalette
()
sal_Int32
PaletteManager
::
Ge
tPalette
()
{
mnCurrentPalette
=
mnCurrentPalette
==
mnNumOfPalettes
-
1
?
0
:
mnCurrentPalette
+
1
;
return
mnCurrentPalette
;
}
long
PaletteManager
::
GetColorCount
()
...
...
@@ -122,11 +147,11 @@ long PaletteManager::GetColorCount()
OUString
PaletteManager
::
GetPaletteName
()
{
if
(
mnCurrentPalette
==
0
)
return
OUString
(
"Default palette"
);
return
OUString
(
STR_DEFAULT_PAL
);
else
if
(
mnCurrentPalette
==
mnNumOfPalettes
-
1
)
return
OUString
(
"Document colors"
);
return
OUString
(
STR_DOC_COLORS
);
else
return
OStringToOUString
(
maPalettes
[
mnCurrentPalette
-
1
].
GetPaletteName
(),
RTL_TEXTENCODING_ASCII_US
);
return
maPalettes
[
mnCurrentPalette
-
1
].
GetName
(
);
}
const
Color
&
PaletteManager
::
GetLastColor
()
...
...
svx/source/tbxctrls/colorwindow.hxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -27,6 +27,7 @@
#include <com/sun/star/frame/XFrame.hpp>
#include <svx/SvxColorValueSet.hxx>
#include <svx/PaletteManager.hxx>
#include <vcl/combobox.hxx>
class
SvxColorWindow_Impl
:
public
SfxPopupWindow
{
...
...
@@ -35,22 +36,19 @@ class SvxColorWindow_Impl : public SfxPopupWindow
private
:
const
sal_uInt16
theSlotId
;
SvxColorValueSet
aColorSet
;
PushButton
aButtonLeft
;
PushButton
aButtonRight
;
ComboBox
aPaletteComboBox
;
PushButton
aButtonPicker
;
FixedText
aPaletteName
;
OUString
maCommand
;
Link
maSelectedLink
;
const
sal_uInt16
n
Nav
ButtonWidth
;
const
sal_uInt16
n
Nav
ButtonHeight
;
const
sal_uInt16
nButtonWidth
;
const
sal_uInt16
nButtonHeight
;
PaletteManager
&
mrPaletteManager
;
void
UpdateGUI
();
DECL_LINK
(
SelectHdl
,
void
*
);
DECL_LINK
(
StepLeftClickHdl
,
void
*
);
DECL_LINK
(
StepRightClickHdl
,
void
*
);
DECL_LINK
(
SelectPaletteHdl
,
void
*
);
DECL_LINK
(
OpenPickerClickHdl
,
void
*
);
protected
:
...
...
svx/source/tbxctrls/tbcontrl.cxx
Dosyayı görüntüle @
ecbbf4c7
...
...
@@ -1009,13 +1009,11 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
SfxPopupWindow
(
nSlotId
,
rFrame
,
pParentWindow
,
WinBits
(
WB_STDPOPUP
|
WB_OWNERDRAWDECORATION
)
),
theSlotId
(
nSlotId
),
aColorSet
(
this
,
WinBits
(
WB_ITEMBORDER
|
WB_NAMEFIELD
|
WB_3DLOOK
|
WB_NO_DIRECTSELECT
)
),
aButtonLeft
(
this
),
aButtonRight
(
this
),
aPaletteComboBox
(
this
,
WinBits
(
WB_BORDER
|
WB_DROPDOWN
|
WB_AUTOSIZE
)
),
aButtonPicker
(
this
),
aPaletteName
(
this
),
maCommand
(
rCommand
),
n
NavButtonWidth
(
20
),
n
NavButtonHeight
(
20
),
n
ButtonWidth
(
28
),
n
ButtonHeight
(
28
),
mrPaletteManager
(
rPaletteManager
)
{
...
...
@@ -1050,22 +1048,21 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
aColorSet
.
SetAccessibleName
(
SVX_RESSTR
(
RID_SVXSTR_LINECOLOR
)
);
}
a
ButtonLeft
.
SetText
(
"<"
);
a
ButtonLeft
.
SetSizePixel
(
Size
(
nNavButtonWidth
,
nNavButtonHeight
)
);
a
ButtonLeft
.
SetClickHdl
(
LINK
(
this
,
SvxColorWindow_Impl
,
StepLeftClickHdl
)
);
aButtonLeft
.
Show
();
aButtonRight
.
SetText
(
">"
);
aButtonRight
.
SetSizePixel
(
Size
(
nNavButtonWidth
,
nNavButtonHeight
)
);
aButtonRight
.
SetClickHdl
(
LINK
(
this
,
SvxColorWindow_Impl
,
StepRightClickHdl
)
);
a
ButtonRight
.
Show
(
);
a
PaletteComboBox
.
SetSelectHdl
(
LINK
(
this
,
SvxColorWindow_Impl
,
SelectPaletteHdl
)
);
a
PaletteComboBox
.
AdaptDropDownLineCountToMaximum
(
);
a
PaletteComboBox
.
Show
(
);
std
::
vector
<
OUString
>
aPaletteList
=
mrPaletteManager
.
GetPaletteList
();
for
(
std
::
vector
<
OUString
>::
iterator
it
=
aPaletteList
.
begin
();
it
!=
aPaletteList
.
end
();
++
it
)
{
aPaletteComboBox
.
InsertEntry
(
*
it
);
}
a
PaletteComboBox
.
SetText
(
aPaletteList
[
mrPaletteManager
.
GetPalette
()
]
);
aButtonPicker
.
SetText
(
"P"
);
aButtonPicker
.
SetSizePixel
(
Size
(
n
NavButtonWidth
,
nNav
ButtonHeight
));
aButtonPicker
.
SetSizePixel
(
Size
(
n
ButtonWidth
,
n
ButtonHeight
));
aButtonPicker
.
SetClickHdl
(
LINK
(
this
,
SvxColorWindow_Impl
,
OpenPickerClickHdl
)
);
aButtonPicker
.
Show
();
aPaletteName
.
SetSizePixel
(
Size
(
150
,
nNavButtonHeight
));
aColorSet
.
Show
();
aColorSet
.
SetSelectHdl
(
LINK
(
this
,
SvxColorWindow_Impl
,
SelectHdl
)
);
...
...
@@ -1073,8 +1070,6 @@ SvxColorWindow_Impl::SvxColorWindow_Impl( const OUString& rCommand,
aColorSet
.
SetHelpId
(
HID_POPUP_COLOR_CTRL
);
SetText
(
rWndTitle
);
aPaletteName
.
Show
();
AddStatusListener
(
OUString
(
".uno:ColorTableState"
));
AddStatusListener
(
maCommand
);
...
...
@@ -1091,16 +1086,13 @@ void SvxColorWindow_Impl::UpdateGUI()
static
sal_Int32
nAdd
=
4
;
//TODO: Move left/right buttons above the colors
SetOutputSizePixel
(
Size
(
aNewSize
.
Width
()
+
nAdd
,
aNewSize
.
Height
()
+
nAdd
+
nNavButtonHeight
));
aButtonLeft
.
SetPosPixel
(
Point
(
0
,
aNewSize
.
Height
()
+
nAdd
+
1
));
SetOutputSizePixel
(
Size
(
aNewSize
.
Width
()
+
nAdd
,
aNewSize
.
Height
()
+
nAdd
+
nButtonHeight
));
a
ButtonRight
.
SetPosPixel
(
Point
(
aNewSize
.
Width
()
+
nAdd
-
nNavButtonWidth
,
aNewSize
.
Height
()
+
nAdd
+
1
));
a
PaletteComboBox
.
SetPosPixel
(
Point
(
0
,
aNewSize
.
Height
()
+
nAdd
+
1
));
aButtonPicker
.
SetPosPixel
(
Point
(
aNewSize
.
Width
()
+
nAdd
-
2
*
nNav
ButtonWidth
,
aNewSize
.
Height
()
+
nAdd
+
1
));
aButtonPicker
.
SetPosPixel
(
Point
(
aNewSize
.
Width
()
+
nAdd
-
n
ButtonWidth
,
aNewSize
.
Height
()
+
nAdd
+
1
));
aPaletteName
.
SetPosPixel
(
Point
(
nNavButtonWidth
,
aNewSize
.
Height
()
+
nAdd
+
1
));
aPaletteName
.
SetText
(
mrPaletteManager
.
GetPaletteName
());
aPaletteComboBox
.
SetSizePixel
(
Size
(
aNewSize
.
Width
()
-
nButtonWidth
,
nButtonHeight
));
}
SvxColorWindow_Impl
::~
SvxColorWindow_Impl
()
...
...
@@ -1154,16 +1146,11 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, SelectHdl)
return
0
;
}
IMPL_LINK_NOARG
(
SvxColorWindow_Impl
,
StepLeftClickHdl
)
{
mrPaletteManager
.
PrevPalette
();
UpdateGUI
();
return
0
;
}
IMPL_LINK_NOARG
(
SvxColorWindow_Impl
,
StepRightClickHdl
)
IMPL_LINK_NOARG
(
SvxColorWindow_Impl
,
SelectPaletteHdl
)
{
mrPaletteManager
.
NextPalette
();
OUString
sSrchTxt
=
aPaletteComboBox
.
GetText
();
sal_Int32
nPos
=
aPaletteComboBox
.
GetEntryPos
(
sSrchTxt
);
mrPaletteManager
.
SetPalette
(
nPos
);
UpdateGUI
();
return
0
;
}
...
...
@@ -1176,7 +1163,7 @@ IMPL_LINK_NOARG(SvxColorWindow_Impl, OpenPickerClickHdl)
void
SvxColorWindow_Impl
::
Resize
()
{
lcl_ResizeValueSet
(
*
this
,
aColorSet
,
n
Nav
ButtonHeight
+
2
);
lcl_ResizeValueSet
(
*
this
,
aColorSet
,
nButtonHeight
+
2
);
}
void
SvxColorWindow_Impl
::
StartSelection
()
...
...
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