summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRichard Nelson <none@none>2010-05-24 18:29:29 -0700
committerRichard Nelson <none@none>2010-05-24 18:29:29 -0700
commitf682c996d28c3841b6709f8fc67ba443bfcd1926 (patch)
tree2be85feed4fe3cd32204f19504626420ad9dd556 /indra
parent4ea7d2de9fcab4dd4694fcbbd2fece1c57f41d2c (diff)
DEV-50271 FIX SLURL support for non-clickable display names
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/lltextbase.cpp33
-rw-r--r--indra/llui/llurlentry.cpp64
-rw-r--r--indra/llui/llurlentry.h11
-rw-r--r--indra/llui/llurlmatch.cpp8
-rw-r--r--indra/llui/llurlmatch.h6
-rw-r--r--indra/llui/llurlregistry.cpp6
-rw-r--r--indra/llui/tests/llurlmatch_test.cpp30
7 files changed, 81 insertions, 77 deletions
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index c93e6c7257..9a07712757 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1582,9 +1582,8 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
start = match.getStart();
end = match.getEnd()+1;
- LLStyle::Params link_params = style_params;
+ LLStyle::Params link_params(style_params);
link_params.overwriteFrom(match.getStyle());
- link_params.link_href = match.getUrl();
// output the text before the Url
if (start > 0)
@@ -1622,26 +1621,20 @@ void LLTextBase::appendText(const std::string &new_text, bool prepend_newline, c
}
}
- // output the styled Url (unless we've been asked to suppress hyperlinking)
- if (match.isLinkDisabled())
- {
- appendAndHighlightText(match.getLabel(), prepend_newline, part, style_params);
- }
- else
- {
- appendAndHighlightText(match.getLabel(), prepend_newline, part, link_params);
+ // output the styled Url
+ appendAndHighlightText(match.getLabel(), prepend_newline, part, link_params);
- // set the tooltip for the Url label
- if (! match.getTooltip().empty())
- {
- segment_set_t::iterator it = getSegIterContaining(getLength()-1);
- if (it != mSegments.end())
- {
- LLTextSegmentPtr segment = *it;
- segment->setToolTip(match.getTooltip());
- }
- }
+ // set the tooltip for the Url label
+ if (! match.getTooltip().empty())
+ {
+ segment_set_t::iterator it = getSegIterContaining(getLength()-1);
+ if (it != mSegments.end())
+ {
+ LLTextSegmentPtr segment = *it;
+ segment->setToolTip(match.getTooltip());
+ }
}
+
prepend_newline = false;
// move on to the rest of the text after the Url
diff --git a/indra/llui/llurlentry.cpp b/indra/llui/llurlentry.cpp
index 7ba569408a..2dda64c434 100644
--- a/indra/llui/llurlentry.cpp
+++ b/indra/llui/llurlentry.cpp
@@ -48,13 +48,8 @@
std::string localize_slapp_label(const std::string& url, const std::string& full_name);
-LLUrlEntryBase::LLUrlEntryBase() :
- mDisabledLink(false)
-{
- mStyle.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
- mStyle.readonly_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
- mStyle.font.style("UNDERLINE");
-}
+LLUrlEntryBase::LLUrlEntryBase()
+{}
LLUrlEntryBase::~LLUrlEntryBase()
{
@@ -71,6 +66,16 @@ std::string LLUrlEntryBase::getIcon(const std::string &url)
return mIcon;
}
+LLStyle::Params LLUrlEntryBase::getStyle() const
+{
+ LLStyle::Params style_params;
+ style_params.color = LLUIColorTable::instance().getColor("HTMLLinkColor");
+ style_params.readonly_color = LLUIColorTable::instance().getColor("HTMLLinkColor");
+ style_params.font.style = "UNDERLINE";
+ return style_params;
+}
+
+
std::string LLUrlEntryBase::getIDStringFromUrl(const std::string &url) const
{
// return the id from a SLURL in the format /app/{cmd}/{id}/about
@@ -329,8 +334,6 @@ LLUrlEntryAgent::LLUrlEntryAgent()
boost::regex::perl|boost::regex::icase);
mMenuName = "menu_url_agent.xml";
mIcon = "Generic_Person";
- mStyle.color = LLUIColorTable::instance().getColor("AgentLinkColor");
- mStyle.readonly_color = LLUIColorTable::instance().getColor("AgentLinkColor");
}
// virtual
@@ -355,11 +358,8 @@ void LLUrlEntryAgent::callObservers(const std::string &id,
void LLUrlEntryAgent::onAvatarNameCache(const LLUUID& id,
const LLAvatarName& av_name)
{
- std::string label = av_name.mDisplayName;
- if (!av_name.mUsername.empty())
- {
- label += " (" + av_name.mUsername + ")";
- }
+ std::string label = av_name.getCompleteName();
+
// received the agent name from the server - tell our observers
callObservers(id.asString(), label, mIcon);
}
@@ -440,6 +440,14 @@ std::string LLUrlEntryAgent::getLabel(const std::string &url, const LLUrlLabelCa
}
}
+LLStyle::Params LLUrlEntryAgent::getStyle() const
+{
+ LLStyle::Params style_params = LLUrlEntryBase::getStyle();
+ style_params.color = LLUIColorTable::instance().getColor("AgentLinkColor");
+ style_params.readonly_color = LLUIColorTable::instance().getColor("AgentLinkColor");
+ return style_params;
+}
+
std::string localize_slapp_label(const std::string& url, const std::string& full_name)
{
// customize label string based on agent SLapp suffix
@@ -485,10 +493,6 @@ std::string LLUrlEntryAgent::getIcon(const std::string &url)
//
LLUrlEntryAgentName::LLUrlEntryAgentName()
{
- mDisabledLink = true;
- mStyle.color.setProvided(false);
- mStyle.readonly_color.setProvided(false);
- mStyle.font.setProvided(false);
}
// virtual
@@ -558,6 +562,11 @@ std::string LLUrlEntryAgentName::getUrl(const std::string &url) const
return LLStringUtil::null;
}
+LLStyle::Params LLUrlEntryAgentName::getStyle() const
+{
+ return LLStyle::Params();
+}
+
//
// LLUrlEntryAgentCompleteName describes a Second Life agent complete name Url, e.g.,
// secondlife:///app/agent/0e346d8b-4433-4d66-a6b0-fd37083abc4c/completename
@@ -619,8 +628,6 @@ LLUrlEntryGroup::LLUrlEntryGroup()
mMenuName = "menu_url_group.xml";
mIcon = "Generic_Group";
mTooltip = LLTrans::getString("TooltipGroupUrl");
- mStyle.color = LLUIColorTable::instance().getColor("GroupLinkColor");
- mStyle.readonly_color = LLUIColorTable::instance().getColor("GroupLinkColor");
}
void LLUrlEntryGroup::onGroupNameReceived(const LLUUID& id,
@@ -666,6 +673,15 @@ std::string LLUrlEntryGroup::getLabel(const std::string &url, const LLUrlLabelCa
}
}
+LLStyle::Params LLUrlEntryGroup::getStyle() const
+{
+ LLStyle::Params style_params = LLUrlEntryBase::getStyle();
+ style_params.color = LLUIColorTable::instance().getColor("GroupLinkColor");
+ style_params.readonly_color = LLUIColorTable::instance().getColor("GroupLinkColor");
+ return style_params;
+}
+
+
//
// LLUrlEntryInventory Describes a Second Life inventory Url, e.g.,
// secondlife:///app/inventory/0e346d8b-4433-4d66-a6b0-fd37083abc4c/select
@@ -953,7 +969,6 @@ LLUrlEntryNoLink::LLUrlEntryNoLink()
{
mPattern = boost::regex("<nolink>[^<]*</nolink>",
boost::regex::perl|boost::regex::icase);
- mDisabledLink = true;
}
std::string LLUrlEntryNoLink::getUrl(const std::string &url) const
@@ -967,6 +982,12 @@ std::string LLUrlEntryNoLink::getLabel(const std::string &url, const LLUrlLabelC
return getUrl(url);
}
+LLStyle::Params LLUrlEntryNoLink::getStyle() const
+{
+ return LLStyle::Params();
+}
+
+
//
// LLUrlEntryIcon describes an icon with <icon>...</icon> tags
//
@@ -974,7 +995,6 @@ LLUrlEntryIcon::LLUrlEntryIcon()
{
mPattern = boost::regex("<icon\\s*>\\s*([^<]*)?\\s*</icon\\s*>",
boost::regex::perl|boost::regex::icase);
- mDisabledLink = true;
}
std::string LLUrlEntryIcon::getUrl(const std::string &url) const
diff --git a/indra/llui/llurlentry.h b/indra/llui/llurlentry.h
index 21d4c29b2b..cd93d1ac41 100644
--- a/indra/llui/llurlentry.h
+++ b/indra/llui/llurlentry.h
@@ -84,7 +84,7 @@ public:
virtual std::string getIcon(const std::string &url);
/// Return the style to render the displayed text
- LLStyle::Params getStyle() const { return mStyle; }
+ virtual LLStyle::Params getStyle() const;
/// Given a matched Url, return a tooltip string for the hyperlink
virtual std::string getTooltip(const std::string &string) const { return mTooltip; }
@@ -95,9 +95,6 @@ public:
/// Return the name of a SL location described by this Url, if any
virtual std::string getLocation(const std::string &url) const { return ""; }
- /// is this a match for a URL that should not be hyperlinked?
- bool isLinkDisabled() const { return mDisabledLink; }
-
protected:
std::string getIDStringFromUrl(const std::string &url) const;
std::string escapeUrl(const std::string &url) const;
@@ -116,9 +113,7 @@ protected:
std::string mIcon;
std::string mMenuName;
std::string mTooltip;
- LLStyle::Params mStyle;
std::multimap<std::string, LLUrlEntryObserver> mObservers;
- bool mDisabledLink;
};
///
@@ -174,6 +169,7 @@ public:
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getIcon(const std::string &url);
/*virtual*/ std::string getTooltip(const std::string &string) const;
+ /*virtual*/ LLStyle::Params getStyle() const;
protected:
/*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon);
private:
@@ -191,6 +187,7 @@ public:
LLUrlEntryAgentName();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getUrl(const std::string &string) const;
+ /*virtual*/ LLStyle::Params getStyle() const;
protected:
/*virtual*/ void callObservers(const std::string &id, const std::string &label, const std::string& icon);
// override this to pull out relevant name fields
@@ -248,6 +245,7 @@ class LLUrlEntryGroup : public LLUrlEntryBase
public:
LLUrlEntryGroup();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
+ /*virtual*/ LLStyle::Params getStyle() const;
private:
void onGroupNameReceived(const LLUUID& id, const std::string& name, bool is_group);
};
@@ -357,6 +355,7 @@ public:
LLUrlEntryNoLink();
/*virtual*/ std::string getLabel(const std::string &url, const LLUrlLabelCallback &cb);
/*virtual*/ std::string getUrl(const std::string &string) const;
+ /*virtual*/ LLStyle::Params getStyle() const;
};
///
diff --git a/indra/llui/llurlmatch.cpp b/indra/llui/llurlmatch.cpp
index 8a7e2e162b..51fca6d7c0 100644
--- a/indra/llui/llurlmatch.cpp
+++ b/indra/llui/llurlmatch.cpp
@@ -42,16 +42,14 @@ LLUrlMatch::LLUrlMatch() :
mTooltip(""),
mIcon(""),
mMenuName(""),
- mLocation(""),
- mDisabledLink(false)
+ mLocation("")
{
}
void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
const std::string &label, const std::string &tooltip,
const std::string &icon, const LLStyle::Params& style,
- const std::string &menu, const std::string &location,
- bool disabled_link)
+ const std::string &menu, const std::string &location)
{
mStart = start;
mEnd = end;
@@ -60,7 +58,7 @@ void LLUrlMatch::setValues(U32 start, U32 end, const std::string &url,
mTooltip = tooltip;
mIcon = icon;
mStyle = style;
+ mStyle.link_href = url;
mMenuName = menu;
mLocation = location;
- mDisabledLink = disabled_link;
}
diff --git a/indra/llui/llurlmatch.h b/indra/llui/llurlmatch.h
index 92a87c3d4c..43bd9da14a 100644
--- a/indra/llui/llurlmatch.h
+++ b/indra/llui/llurlmatch.h
@@ -83,14 +83,11 @@ public:
/// return the SL location that this Url describes, or "" if none.
std::string getLocation() const { return mLocation; }
- /// is this a match for a URL that should not be hyperlinked?
- bool isLinkDisabled() const { return mDisabledLink; }
-
/// Change the contents of this match object (used by LLUrlRegistry)
void setValues(U32 start, U32 end, const std::string &url, const std::string &label,
const std::string &tooltip, const std::string &icon,
const LLStyle::Params& style, const std::string &menu,
- const std::string &location, bool disabled_link);
+ const std::string &location);
private:
U32 mStart;
@@ -102,7 +99,6 @@ private:
std::string mMenuName;
std::string mLocation;
LLStyle::Params mStyle;
- bool mDisabledLink;
};
#endif
diff --git a/indra/llui/llurlregistry.cpp b/indra/llui/llurlregistry.cpp
index f61603545f..f119233f8f 100644
--- a/indra/llui/llurlregistry.cpp
+++ b/indra/llui/llurlregistry.cpp
@@ -192,8 +192,7 @@ bool LLUrlRegistry::findUrl(const std::string &text, LLUrlMatch &match, const LL
match_entry->getIcon(url),
match_entry->getStyle(),
match_entry->getMenuName(),
- match_entry->getLocation(url),
- match_entry->isLinkDisabled());
+ match_entry->getLocation(url));
return true;
}
@@ -226,8 +225,7 @@ bool LLUrlRegistry::findUrl(const LLWString &text, LLUrlMatch &match, const LLUr
match.getIcon(),
match.getStyle(),
match.getMenuName(),
- match.getLocation(),
- match.isLinkDisabled());
+ match.getLocation());
return true;
}
return false;
diff --git a/indra/llui/tests/llurlmatch_test.cpp b/indra/llui/tests/llurlmatch_test.cpp
index ab5770dbf2..85318196e0 100644
--- a/indra/llui/tests/llurlmatch_test.cpp
+++ b/indra/llui/tests/llurlmatch_test.cpp
@@ -154,7 +154,7 @@ namespace tut
LLUrlMatch match;
ensure("empty()", match.empty());
- match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(0, 1, "http://secondlife.com", "Second Life", "", "", LLStyle::Params(), "", "");
ensure("! empty()", ! match.empty());
}
@@ -167,7 +167,7 @@ namespace tut
LLUrlMatch match;
ensure_equals("getStart() == 0", match.getStart(), 0);
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getStart() == 10", match.getStart(), 10);
}
@@ -180,7 +180,7 @@ namespace tut
LLUrlMatch match;
ensure_equals("getEnd() == 0", match.getEnd(), 0);
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getEnd() == 20", match.getEnd(), 20);
}
@@ -193,10 +193,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getUrl() == ''", match.getUrl(), "");
- match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "http://slurl.com/", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getUrl() == 'http://slurl.com/'", match.getUrl(), "http://slurl.com/");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getUrl() == '' (2)", match.getUrl(), "");
}
@@ -209,10 +209,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getLabel() == ''", match.getLabel(), "");
- match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "Label", "", "", LLStyle::Params(), "", "");
ensure_equals("getLabel() == 'Label'", match.getLabel(), "Label");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getLabel() == '' (2)", match.getLabel(), "");
}
@@ -225,10 +225,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getTooltip() == ''", match.getTooltip(), "");
- match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "Info", "", LLStyle::Params(), "", "");
ensure_equals("getTooltip() == 'Info'", match.getTooltip(), "Info");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getTooltip() == '' (2)", match.getTooltip(), "");
}
@@ -241,10 +241,10 @@ namespace tut
LLUrlMatch match;
ensure_equals("getIcon() == ''", match.getIcon(), "");
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "", "");
ensure_equals("getIcon() == 'Icon'", match.getIcon(), "Icon");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure_equals("getIcon() == '' (2)", match.getIcon(), "");
}
@@ -257,10 +257,10 @@ namespace tut
LLUrlMatch match;
ensure("getMenuName() empty", match.getMenuName().empty());
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "");
ensure_equals("getMenuName() == \"xui_file.xml\"", match.getMenuName(), "xui_file.xml");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure("getMenuName() empty (2)", match.getMenuName().empty());
}
@@ -273,10 +273,10 @@ namespace tut
LLUrlMatch match;
ensure("getLocation() empty", match.getLocation().empty());
- match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris", false);
+ match.setValues(10, 20, "", "", "", "Icon", LLStyle::Params(), "xui_file.xml", "Paris");
ensure_equals("getLocation() == \"Paris\"", match.getLocation(), "Paris");
- match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "", false);
+ match.setValues(10, 20, "", "", "", "", LLStyle::Params(), "", "");
ensure("getLocation() empty (2)", match.getLocation().empty());
}
}