summaryrefslogtreecommitdiff
path: root/indra/llui/llclipboard.cpp
diff options
context:
space:
mode:
authorMerov Linden <merov@lindenlab.com>2012-02-07 22:46:04 -0800
committerMerov Linden <merov@lindenlab.com>2012-02-07 22:46:04 -0800
commitee3c3c15b714f8f68e98a2d4064afaec665bd64a (patch)
treea75780d299d9cff782186107bebc7e193046de11 /indra/llui/llclipboard.cpp
parentc744603af9b53c6bc73fefbd56de68cf2778ed70 (diff)
EXP-1841 : Final deep scrub on LLClipboard API, clean up the use of copy and cut everywhere.
Diffstat (limited to 'indra/llui/llclipboard.cpp')
-rw-r--r--indra/llui/llclipboard.cpp96
1 files changed, 46 insertions, 50 deletions
diff --git a/indra/llui/llclipboard.cpp b/indra/llui/llclipboard.cpp
index a2a3f7f285..7794a0537f 100644
--- a/indra/llui/llclipboard.cpp
+++ b/indra/llui/llclipboard.cpp
@@ -35,8 +35,8 @@
#include "llwindow.h"
LLClipboard::LLClipboard()
-: mCutMode(false)
{
+ reset();
}
LLClipboard::~LLClipboard()
@@ -44,55 +44,59 @@ LLClipboard::~LLClipboard()
reset();
}
-void LLClipboard::add(const LLUUID& object)
+void LLClipboard::reset()
{
- mObjects.put(object);
+ mObjects.reset();
+ mCutMode = false;
+ mString = LLWString();
}
-void LLClipboard::store(const LLUUID& object)
+// Copy the input uuid to the LL clipboard
+bool LLClipboard::copyToClipboard(const LLUUID& src, const LLAssetType::EType type)
{
reset();
- mObjects.put(object);
+ return addToClipboard(src, type);
}
-void LLClipboard::store(const LLDynamicArray<LLUUID>& inv_objects)
+// Add the input uuid to the LL clipboard
+// Convert the uuid to string and concatenate that string to the system clipboard if legit
+bool LLClipboard::addToClipboard(const LLUUID& src, const LLAssetType::EType type)
{
- reset();
- S32 count = inv_objects.count();
- for(S32 i = 0; i < count; i++)
+ bool res = false;
+ if (src.notNull())
{
- mObjects.put(inv_objects[i]);
+ res = true;
+ if (LLAssetType::lookupIsAssetIDKnowable(type))
+ {
+ LLWString source = utf8str_to_wstring(src.asString());
+ res = addToClipboard(source, 0, source.size());
+ }
+ if (res)
+ {
+ mObjects.put(src);
+ }
}
+ return res;
}
-void LLClipboard::cut(const LLUUID& object)
+bool LLClipboard::pasteFromClipboard(LLDynamicArray<LLUUID>& inv_objects) const
{
- if(!mCutMode && !mObjects.empty())
- {
- //looks like there are some stored items, reset clipboard state
- reset();
- }
- mCutMode = true;
- add(object);
-}
-void LLClipboard::retrieve(LLDynamicArray<LLUUID>& inv_objects) const
-{
- inv_objects.reset();
+ bool res = false;
S32 count = mObjects.count();
- for(S32 i = 0; i < count; i++)
+ if (count > 0)
{
- inv_objects.put(mObjects[i]);
+ res = true;
+ inv_objects.reset();
+ for (S32 i = 0; i < count; i++)
+ {
+ inv_objects.put(mObjects[i]);
+ }
}
-}
-
-void LLClipboard::reset()
-{
- mObjects.reset();
- mCutMode = false;
+ return res;
}
// Returns true if the LL Clipboard has pasteable items in it
-BOOL LLClipboard::hasContents() const
+bool LLClipboard::hasContents() const
{
return (mObjects.count() > 0);
}
@@ -107,30 +111,22 @@ bool LLClipboard::isOnClipboard(const LLUUID& object) const
bool LLClipboard::copyToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary)
{
reset();
- mString = src.substr(pos, len);
- return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString));
+ return addToClipboard(src, pos, len, use_primary);
}
-// Copy the input uuid to the LL clipboard
-// Convert the uuid to string and copy that string to the system clipboard if legit
-bool LLClipboard::copyToClipboard(const LLUUID& src, const LLAssetType::EType type)
+// Concatenate the input string to the LL and the system clipboard
+bool LLClipboard::addToClipboard(const LLWString &src, S32 pos, S32 len, bool use_primary)
{
- bool res = false;
- reset();
- if (src.notNull())
+ const LLWString sep(utf8str_to_wstring(std::string(", ")));
+ if (mString.length() == 0)
{
- res = true;
- if (LLAssetType::lookupIsAssetIDKnowable(type))
- {
- LLWString source = utf8str_to_wstring(src.asString());
- res = copyToClipboard(source, 0, source.size());
- }
- if (res)
- {
- store(src);
- }
+ mString = src.substr(pos, len);
}
- return res;
+ else
+ {
+ mString = mString + sep + src.substr(pos, len);
+ }
+ return (use_primary ? LLView::getWindow()->copyTextToPrimary(mString) : LLView::getWindow()->copyTextToClipboard(mString));
}
// Copy the System clipboard to the output string.