summaryrefslogtreecommitdiff
path: root/svx/source/tbxctrls/Palette.cxx
diff options
context:
space:
mode:
authorKrisztian Pinter <pin.terminator@gmail.com>2014-07-10 16:14:29 +0200
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2014-09-17 10:19:38 +0200
commitecbbf4c7cf26d4d38e3be10ec99eb941f6f7a16d (patch)
tree0c535566e5ae14ecbd7a44492fa59912ece3322f /svx/source/tbxctrls/Palette.cxx
parent9ca7c5014c9a432f9182c80c3e42f1d76e30df67 (diff)
Change SvxColorWindow_Impl to use ComboBox for palette selection
Change-Id: I0fb9b46298f45bbdf9ae9198c145b9ea5e403bbf
Diffstat (limited to 'svx/source/tbxctrls/Palette.cxx')
-rw-r--r--svx/source/tbxctrls/Palette.cxx66
1 files changed, 47 insertions, 19 deletions
diff --git a/svx/source/tbxctrls/Palette.cxx b/svx/source/tbxctrls/Palette.cxx
index aebb7f0fa48d..f84f2d523e7a 100644
--- a/svx/source/tbxctrls/Palette.cxx
+++ b/svx/source/tbxctrls/Palette.cxx
@@ -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 OString& Palette::GetPaletteName()
+const OUString& Palette::GetName()
{
- 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: ", &maName) )
+ 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')
{