35 mbValidPalette( false ),
36 maFPath (
std::move( aFPath )),
37 maASEPaletteName (
std::move( aFName ))
48 rColorSet.
InsertItem(nIx, rColor.m_aColor, rColor.m_aName);
70static void lcl_CMYKtoRGB(
float fCyan,
float fMagenta,
float fYellow,
float fKey,
float& dR,
float& dG,
float& dB )
72 fCyan = (fCyan * ( 1.0 - fKey )) + fKey;
73 fMagenta = (fMagenta * ( 1.0 - fKey )) + fKey;
74 fYellow = (fYellow * ( 1.0 - fKey )) + fKey;
76 dR = std::clamp( 1.0 - fCyan, 0.0, 1.0 );
77 dG = std::clamp( 1.0 - fMagenta, 0.0, 1.0 );
78 dB = std::clamp( 1.0 - fYellow, 0.0, 1.0 );
88 if ((aFile.
ReadBytes(cMagic, 4) != 4) || (strncmp(cMagic,
"ASEF", 4) != 0))
97 sal_uInt32 nBlocks = 0;
99 for (sal_uInt32 nI = 0; nI < nBlocks; nI++) {
100 sal_uInt32 nChunkType = 0;
107 sal_uInt16 nChunkSize = 0;
108 sal_uInt16 nChars = 0;
112 OUString aPaletteName(
"");
118 if (nChunkType == 0xC0010000)
123 if (nChunkSize > ((nChars * 2) + 2))
124 aPaletteName.clear();
129 char cColorModel[5] = {0};
131 OString aColorModel(cColorModel);
133 float r = 0, g = 0, b = 0;
135 if (aColorModel.equalsIgnoreAsciiCase(
"cmyk"))
137 float c = 0,
m = 0,
y = 0, k = 0;
144 else if (aColorModel.equalsIgnoreAsciiCase(
"rgb "))
150 else if (aColorModel.equalsIgnoreAsciiCase(
"gray"))
158 float nL = 0, nA = 0, nB = 0;
168 maColors.emplace_back(
Color(r * 255, g * 255, b * 255), aPaletteName);
181static OString
lcl_getToken(OStringBuffer& rStr, sal_Int32& index);
184 mbLoadedPalette( false ),
185 mbValidPalette( false ),
186 maFName(
std::move( aFName )),
187 maFPath(
std::move( aFPath ))
214 rColorSet.
InsertItem(nIx, rColor.m_aColor, rColor.m_aName);
227 OString aPaletteName;
230 if( !aLine.startsWith(
"GIMP Palette") )
return false;
232 if( aLine.startsWith(
"Name: ", &aPaletteName) )
234 maGPLPaletteName = OStringToOUString(aPaletteName, RTL_TEXTENCODING_ASCII_US);
236 if( aLine.startsWith(
"Columns: "))
265 if (aLine[0] !=
'#' && aLine[0] !=
'\n')
272 if(token.isEmpty() ||
nIndex == -1)
continue;
273 sal_Int32 r = token.toInt32();
276 if(token.isEmpty() ||
nIndex == -1)
continue;
277 sal_Int32 g = token.toInt32();
280 if(token.isEmpty())
continue;
281 sal_Int32 b = token.toInt32();
283 std::string_view
name;
285 name = std::string_view(aLine).substr(
nIndex);
289 OStringToOUString(
name, RTL_TEXTENCODING_ASCII_US));
303 sal_Int32 substart, toklen = 0;
304 OUString aWhitespaceChars(
" \n\t" );
306 while(
index < rStr.getLength() &&
307 aWhitespaceChars.indexOf( rStr[
index] ) != -1)
309 if(
index == rStr.getLength())
317 while(
index < rStr.getLength() &&
318 aWhitespaceChars.indexOf( rStr[
index] ) == -1 )
325 while(
index < rStr.getLength() &&
326 aWhitespaceChars.indexOf( rStr[
index] ) != -1 )
328 if(
index == rStr.getLength())
331 return OString(std::string_view(rStr).substr(substart, toklen));
337 mbLoadedPalette( false ),
338 maFPath(
std::move( aFPath )),
339 maSOCPaletteName(
std::move( aFName ))
static OString lcl_getToken(OStringBuffer &rStr, sal_Int32 &index)
static void lcl_CMYKtoRGB(float fCyan, float fMagenta, float fYellow, float fKey, float &dR, float &dG, float &dB)
PaletteASE(const PaletteASE &)=default
virtual ~PaletteASE() override
virtual const OUString & GetName() override
OUString maASEPaletteName
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
virtual Palette * Clone() const override
virtual const OUString & GetPath() override
virtual bool IsValid() override
bool ReadPaletteHeader(SvFileStream &rFileStream)
virtual Palette * Clone() const override
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
virtual bool IsValid() override
virtual const OUString & GetPath() override
virtual const OUString & GetName() override
virtual ~PaletteGPL() override
PaletteGPL(const PaletteGPL &)=default
OUString maGPLPaletteName
virtual ~PaletteSOC() override
virtual bool IsValid() override
virtual const OUString & GetPath() override
virtual Palette * Clone() const override
XColorListRef mpColorList
PaletteSOC(const PaletteSOC &)=default
virtual const OUString & GetName() override
OUString maSOCPaletteName
virtual void LoadColorSet(SvxColorValueSet &rColorSet) override
void SetEndian(SvStreamEndian SvStreamEndian)
SvStream & ReadFloat(float &rFloat)
bool ReadLine(OStringBuffer &rStr, sal_Int32 nMaxBytesToRead=0xFFFE)
SvStream & ReadUInt32(sal_uInt32 &rUInt32)
std::size_t ReadBytes(void *pData, std::size_t nSize)
sal_uInt64 SeekRel(sal_Int64 nPos)
SvStream & ReadUInt16(sal_uInt16 &rUInt16)
void addEntriesForXColorList(const XColorList &rXColorList, sal_uInt32 nStartIndex=1)
void InsertItem(sal_uInt16 nItemId, const Image &rImage)
static XColorListRef AsColorList(rtl::Reference< XPropertyList > const &plist)
static XPropertyListRef CreatePropertyListFromURL(XPropertyListType t, std::u16string_view rUrl)
TOOLS_DLLPUBLIC OUString read_uInt16s_ToOUString(SvStream &rStrm, std::size_t nUnits)