summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 85e191c)
raw | patch | inline | side by side (parent: 85e191c)
author | joncruz <joncruz@users.sourceforge.net> | |
Wed, 18 Mar 2009 09:56:47 +0000 (09:56 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Wed, 18 Mar 2009 09:56:47 +0000 (09:56 +0000) |
src/interface.cpp | patch | blob | history | |
src/widgets/eek-color-def.cpp | patch | blob | history |
diff --git a/src/interface.cpp b/src/interface.cpp
index 164b66f3388213c7e8eaf2960bd9870c82d84942..c162ea6d68fef6b384672db7f72c72f1f335465f 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
#include "widgets/desktop-widget.h"
#include "sp-item-group.h"
#include "sp-text.h"
+#include "sp-gradient-fns.h"
+#include "sp-gradient.h"
#include "sp-flowtext.h"
#include "sp-namedview.h"
#include "ui/view/view.h"
} else if ( color.getType() == eek::ColorDef::NONE ) {
colorspec = "none";
} else {
- gchar* tmp = g_strdup_printf("#%02x%02x%02x", color.getR(), color.getG(), color.getB());
- colorspec = tmp;
- g_free(tmp);
+ unsigned int r = color.getR();
+ unsigned int g = color.getG();
+ unsigned int b = color.getB();
+
+ SPGradient* matches = 0;
+ const GSList *gradients = sp_document_get_resource_list(doc, "gradient");
+ for (const GSList *item = gradients; item; item = item->next) {
+ SPGradient* grad = SP_GRADIENT(item->data);
+ if ( color.descr == grad->id ) {
+ if ( grad->has_stops ) {
+ matches = grad;
+ break;
+ }
+ }
+ }
+ if (matches) {
+ colorspec = "url(#";
+ colorspec += matches->id;
+ colorspec += ")";
+ } else {
+ gchar* tmp = g_strdup_printf("#%02x%02x%02x", r, g, b);
+ colorspec = tmp;
+ g_free(tmp);
+ }
}
}
}
index fb0eeeb5e5d5d656ed44ef5a2fade9cec4a38664..8542e55932b1abc5d7dce571f929ce8fbe15b4d4 100644 (file)
@@ -248,6 +248,19 @@ bool ColorDef::fromMIMEData(std::string const & type, char const * data, int len
double dbl = strtod(srgb.c_str() + numPos + 3, &endPtr);
this->b = static_cast<int>(255 * dbl);
}
+
+ size_t pos = xml.find("<color ");
+ if ( pos != std::string::npos ) {
+ size_t endPos = xml.find(">", pos);
+ std::string colorTag = xml.substr(pos, endPos);
+
+ size_t namePos = colorTag.find("name=");
+ if (namePos != std::string::npos) {
+ char quote = colorTag[namePos + 5];
+ endPos = colorTag.find(quote, namePos + 6);
+ descr = colorTag.substr(namePos + 6, endPos - (namePos + 6));
+ }
+ }
changed = true;
worked = true;
}