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
committerKrisztian Pinter <pin.terminator@gmail.com>2014-07-25 17:16:40 +0200
commit1830d50c01fd871ce3a44d9b6cb72a062bc23181 (patch)
tree9cda6b4a03af34736f12800dd0df974f1c766cb4 /svx/source/tbxctrls/Palette.cxx
parentb44ab86f66c4d405984b676760f28f35f0bf9cf7 (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')
{