void xlw::XlfAbstractCmdDesc::GenerateMamlDocs(const std::string outputDir, int itemId) const
{
    std::ostringstream oss;
    oss << outputDir << "\\" << GetAlias() << ".maml";
    std::ofstream outFile(oss.str().c_str());

    outFile << "<?xml version=\"1.0\" encoding=\"utf-8\"?>" << std::endl;
    outFile << "<topic id=\""<< GetAlias() << "\" revisionNumber=\"9\">" << std::endl;
    outFile << "<developerReferenceWithSyntaxDocument xmlns=\"http://ddue.schemas.microsoft.com/authoring/2003/5\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">" << std::endl;
    outFile << "<title>"<< GetAlias() << "</title>" << std::endl;
    DoMamlDocs(outFile);
    outFile << "<relatedTopics></relatedTopics>" << std::endl;
    outFile << "</developerReferenceWithSyntaxDocument>" << std::endl;
    outFile << "</topic>" << std::endl;
}
Beispiel #2
0
	virtual const wchar_t* GetDisplayName()
	{
		const wchar_t* name = GetAlias();
		if(name == 0 || *name == 0)
			name = GetUserID();
		return name;
	}
Beispiel #3
0
void xlw::XlfFuncDesc::DoMamlDocs(std::ostream& ostr) const
{
    ostr << "<introduction>" << std::endl;
    XlfArgDescList& arguments = impl_->arguments_;
    ostr << "<para>" << GetComment() << "</para>" << std::endl;

    std::string argnames;

    XlfArgDescList::const_iterator it = arguments.begin();
    while (it != arguments.end())
    {
        argnames += (*it).GetName();
        ++it;
        if (it != arguments.end())
            argnames+=", ";
    }

    ostr << "<code>=" << GetAlias() << "(" << argnames << ")</code>" << std::endl;
    ostr << "</introduction>" << std::endl;

    ostr << "<section>" << std::endl;
    ostr << "  <title>Parameters</title>" << std::endl;
    ostr << "  <content>" << std::endl;


    for (it = arguments.begin(); it != arguments.end(); ++it)
    {
        ostr << "    <para>";
        ostr << (*it).GetName() << ": " << (*it).GetComment();
        ostr << "</para>" << std::endl;
    }
    ostr << "  </content>" << std::endl;
    ostr << "</section>" << std::endl;
}
/*!
Performs the parts of the Registration that are common to all the subclasses of
XlfAbstractCmdDesc. It then calls the pure virtual method DoRegister for the
subclass dependant parts of the algorithm.
*/
void xlw::XlfAbstractCmdDesc::Register(int functionId) const
{
    std::string dllName = XlfExcel::Instance().GetName();
    if (dllName.empty())
    {
        THROW_XLW("Could not get library name");
    }

    // generate the default helpId if we have found a
    // suitable help file
    std::string helpName = XlfExcel::Instance().GetHelpName();
    std::string suggestedHelpId;
    if(!helpName.empty())
    {
        std::ostringstream oss;
        oss << helpName << "!" << functionId;
        suggestedHelpId = oss.str();
    }
    int err = DoRegister(dllName, suggestedHelpId);
    if (err != xlretSuccess)
    {
        std::cerr << XLW__HERE__ << "Error " << err << " while registering " << GetAlias().c_str() << std::endl;
    }
    return;
}
Beispiel #5
0
int XlfCmdDesc::AddToMenuBar(const std::string& menu, const std::string& text)
{
	XLOPER xMenu;
	LPXLOPER pxMenu;
	LPXLOPER px;

	menu_ = menu;
	text_ = text;

	// This is a small trick to allocate an array 5 XlfOper
	// One must first allocate the array with XLOPER
//	px = pxMenu = (LPXLOPER)new XLOPER[5];
	px = pxMenu = new XLOPER[5];
	// and then assign the XLOPER to XlfOper specifying false
	// to tell the Framework that the data is not owned by
	// Excel and that it should not call xlFree when destroyed
	XlfOper(px++).Set(text_.c_str());
	XlfOper(px++).Set(GetAlias().c_str());
	XlfOper(px++).Set("");
	XlfOper(px++).Set(GetComment().c_str());
	XlfOper(px++).Set("");

	xMenu.xltype = xltypeMulti;
	xMenu.val.array.lparray = pxMenu;
	xMenu.val.array.rows = 1;
	xMenu.val.array.columns = 5;

	int err = XlfExcel::Instance().Call(xlfAddCommand, 0, 3, (LPXLOPER)XlfOper(1.0), (LPXLOPER)XlfOper(menu_.c_str()), (LPXLOPER)&xMenu);
	if (err != xlretSuccess)
    std::cerr << XLW__HERE__ << "Add command " << GetName().c_str() << " to " << menu_.c_str() << " failed" << std::endl;
	delete[] pxMenu;
	return err;
}
Beispiel #6
0
/*
 * __RegisterClass - cover for register class
 */
BOOL  FAR PASCAL __RegisterClass(LPWNDCLASS wc)
{
    WNDCLASS    nwc;
    BOOL        rc;

    nwc = *wc;

    GetAlias( &nwc.lpszMenuName );
    GetAlias( &nwc.lpszClassName );

    rc = RegisterClass( &nwc );

    ReleaseAlias( wc->lpszMenuName, nwc.lpszMenuName );
    ReleaseAlias( wc->lpszClassName, nwc.lpszClassName );

    return( rc );

} /* __RegisterClass */
/*!
Performs the parts of the Unregistration that are common to all the subclasses
of XlfAbstractCmdDesc. It then calls the pure virtual method DoUnregister for
the subclass dependent parts of the algorithm.
*/
void xlw::XlfAbstractCmdDesc::Unregister() const
{
  std::string dllName = XlfExcel::Instance().GetName();
  if (dllName.empty())
    THROW_XLW("Could not get library name");
  int err = DoUnregister(dllName);
  if (err != xlretSuccess)
    std::cerr << XLW__HERE__ << "Error " << err << " while registering " << GetAlias().c_str() << std::endl;
  return;
}
/*!
Performs the parts of the Registration that are common to a registration
of all the subclasses of XlfAbstractCmdDesc. It then calls the pure
virtual method DoRegister for the subclass dependant parts of the
algorithm.
*/
void XlfAbstractCmdDesc::Register() const
{
  std::string dllName = XlfExcel::Instance().GetName();
  if (dllName.empty())
    throw std::runtime_error("Could not get library name");
  int err = DoRegister(dllName);
  if (err != xlretSuccess)
    std::cerr << __HERE__ << "Error " << err << " while registering " << GetAlias().c_str() << std::endl;
  return;
}
Beispiel #9
0
	bool CFileSystem::Init(void) {

		Log("\tInitializing FileSystem...\n");

#if PLATFORM == PLATFORM_WIN32
		WCHAR	buf[256];
		WCHAR	c, *p;
		size_t	i;

		HMODULE hMod	= GetModuleHandle( NULL );
		DWORD	res		= GetModuleFileNameW( hMod, buf, sizeof( buf ) );

		for ( i = 0; i < 3; i++ ) {
			p = wcsrchr( buf, '\\' );
			p[0] = 0;
		}

		// convert backslashes to slashes
		p = buf;
		while ( ( c = *p ) ) {
			if ( c == '\\' ) *p = '/';
			p++;
		}
		wcscat( buf, L"/" );

		std::wstring wstr = _wcslwr( buf );
		std::string dest;
		dest.resize(wstr.length());
		std::transform(wstr.begin(), wstr.end(), dest.begin(), wide_to_narrow);

		SetAlias( "home", dest );
		string_t home = GetAlias( "home" );
		SetAlias( "bin", home+"bin/win32/debug/" );
		SetAlias( "data", home+"../data/" );
#endif

		Log("\t\tHome:%s\n", GetAlias("home").c_str());
		Log("\t\tData:%s\n", GetAlias("data").c_str());
		m_initialized = true;

		return m_initialized;
	}
Beispiel #10
0
int XlfCmdDesc::Check(bool ERR_CHECK) const
{
	if (menu_.empty())
	{
    std::cerr << XLW__HERE__ << "No menu specified for the command \"" << GetName().c_str() << "\"" << std::endl;
		return xlretFailed;
	}
	int err = XlfExcel::Instance().Call(xlfCheckCommand, 0, 4, (LPXLOPER)XlfOper(1.0), (LPXLOPER)XlfOper(menu_.c_str()), (LPXLOPER)XlfOper(text_.c_str()), (LPXLOPER)XlfOper(ERR_CHECK));
	if (err != xlretSuccess)
	{
    std::cerr << XLW__HERE__ << "Registration of " << GetAlias().c_str() << " failed" << std::endl;
		return err;
	}
	return xlretSuccess;
}
Beispiel #11
0
QVariant QtPropertyData::data(int role) const
{
	QVariant ret;

	switch(role)
	{
	case Qt::EditRole:
	case Qt::DisplayRole:
		ret = GetAlias();
		if(!ret.isValid())
		{
			ret = GetValue();
		}
		break;
    case Qt::ToolTipRole:
        ret = GetToolTip();
        if (!ret.isValid())
        {
            ret = data(Qt::DisplayRole);
        }
        break;
	case Qt::CheckStateRole:
		if(GetFlags() & Qt::ItemIsUserCheckable)
		{
            ret = GetValue();
            if ( !ret.isValid() )
            {
                ret = Qt::PartiallyChecked;
            }
            else
            {
			    ret = GetValue().toBool() ? Qt::Checked : Qt::Unchecked;
            }
		}
		break;
	case Qt::FontRole:
	case Qt::DecorationRole:
	case Qt::BackgroundRole:
	case Qt::ForegroundRole:
		ret = style.value(role);
		break;
	default:
		break;
	}

	return ret;
}
Beispiel #12
0
int xlw::XlfFuncDesc::DoUnregister(const std::string& dllName) const
{
    if(funcId_ != InvalidFunctionId)
    {
        // slightly pointless as it doesn't work but we're supposed to deregister
        // the name as well as the function
        XlfExcel::Instance().Call(xlfSetName, NULL, 1, XlfOper(GetAlias()));

        XlfOper unreg;
        int err = XlfExcel::Instance().Call(xlfUnregister, unreg, 1, XlfOper(funcId_));
        return err;
    }
    else
    {
        return xlretSuccess;
    }
}
void pawsBuddyWindow::HandleMessage( MsgEntry* me )
{
    if ( me->GetType() == MSGTYPE_BUDDY_LIST )
    {
        psBuddyListMsg mesg(me);
    
        onlineBuddies.DeleteAll();
        offlineBuddies.DeleteAll();

        // Load aliases
        LoadAliases(psengine->GetMainPlayerName());

        for (size_t x = 0; x < mesg.buddies.GetSize(); x++ )
        {
            if (mesg.buddies[x].online)
                onlineBuddies.Push(GetAlias(mesg.buddies[x].name));
            else
                offlineBuddies.Push(GetAlias(mesg.buddies[x].name));
            chatWindow->AddAutoCompleteName(mesg.buddies[x].name);
        }

    }
    else if ( me->GetType() == MSGTYPE_BUDDY_STATUS )
    {
        psBuddyStatus mesg(me);
        
        // If player is online now remove from the offline list
        // else remove them from offline list and add to the online list.
        if ( mesg.onlineStatus )       
        {   
            size_t loc = offlineBuddies.Find(GetAlias(mesg.buddy.GetData()));
            if ( loc != csArrayItemNotFound )
            {
                offlineBuddies.DeleteIndex(loc);
            }                
            onlineBuddies.Push(GetAlias(mesg.buddy));
        }
        else
        {
            size_t loc = onlineBuddies.Find(GetAlias(mesg.buddy.GetData()));
            if ( loc != csArrayItemNotFound )
            {
                onlineBuddies.DeleteIndex(loc);
            }                

            offlineBuddies.Push(GetAlias(mesg.buddy));
        }

        chatWindow->AddAutoCompleteName(mesg.buddy);
    }

    FillBuddyList();
}
Beispiel #14
0
/*!
Registers the function as a function in excel.
\sa XlfExcel, XlfCmdDesc.
*/
int XlfFuncDesc::DoRegister(const std::string& dllName) const
{
  // alias arguments
  XlfArgDescList& arguments = impl_->arguments_;

	size_t nbargs = arguments.size();
	std::string args("R");
	std::string argnames;

	XlfArgDescList::const_iterator it = arguments.begin();
	while (it != arguments.end())
	{
		argnames += (*it).GetName();
		args += (*it).GetType();
		++it;
		if (it != arguments.end())
			argnames+=", ";
	}
	if (impl_->recalcPolicy_ == XlfFuncDesc::Volatile)
	{
		args+="!";
		args[nbargs + 2] = 0;
	} 
	else
		args[nbargs + 1] = 0;
	LPXLOPER *rgx = new LPXLOPER[10 + nbargs];
	LPXLOPER *px = rgx;
	(*px++) = XlfOper(dllName.c_str());
	(*px++) = XlfOper(GetName().c_str());
	(*px++) = XlfOper(args.c_str());
	(*px++) = XlfOper(GetAlias().c_str());
	(*px++) = XlfOper(argnames.c_str());
	(*px++) = XlfOper(1.0);
	(*px++) = XlfOper(impl_->category_.c_str());
	(*px++) = XlfOper("");
	(*px++) = XlfOper("");
	(*px++) = XlfOper(GetComment().c_str());
	for (it = arguments.begin(); it != arguments.end(); ++it)
  {
		(*px++) = XlfOper((*it).GetComment().c_str());
  }
	int err = XlfExcel::Instance().Callv(xlfRegister, NULL, 10 + nbargs, rgx);
	delete[] rgx;
	return err;
}
Beispiel #15
0
/*!
Registers the command as a macro in excel.
\sa XlfExcel, XlfFuncDesc.
*/
int XlfCmdDesc::DoRegister() const
{
	const std::string& dllname = XlfExcel::Instance().GetName();
	if (dllname.empty())
	{
    std::cerr << XLW__HERE__ << "Library name is not initialized" << std::endl;
		return xlretFailed;
	}
//	ERR_LOG("Registering command \"" << alias_.c_str() << "\" from \"" << name_.c_str() << "\" in \"" << dllname.c_str() << "\"");
	int err = XlfExcel::Instance().Call(
		xlfRegister, NULL, 7,
		(LPXLOPER)XlfOper(dllname.c_str()),
		(LPXLOPER)XlfOper(GetName().c_str()),
		(LPXLOPER)XlfOper("A"),
		(LPXLOPER)XlfOper(GetAlias().c_str()),
		(LPXLOPER)XlfOper(""),
		(LPXLOPER)XlfOper(2.0),
		(LPXLOPER)XlfOper(""));
	return err;
}
Beispiel #16
0
TError TNetwork::Update() {
    if (!config().network().dynamic_ifaces())
        return TError::Success();

    L() << "Update network" << std::endl;

    std::vector<std::shared_ptr<TNlLink>> newLinks;

    auto net_lock = ScopedLock();

    TError error = OpenLinks(newLinks);
    if (error)
        return error;

    for (auto link : newLinks) {
        auto i = std::find_if(Links.begin(), Links.end(),
                              [link](std::shared_ptr<TNlLink> i) {
                                 return i->GetAlias() == link->GetAlias();
                              });

        if (i == Links.end()) {
            L() << "Found new link: " << link->GetAlias() << std::endl;
            TError error = PrepareLink(link);
            if (error)
                return error;
        } else {
            L() << "Found existing link: " << link->GetAlias() << std::endl;
            TError error = link->RefillClassCache();
            if (error)
                return error;
        }
    }

    Links = newLinks;
    return TError::Success();
}
Beispiel #17
0
/*!
Registers the command as a macro in excel.
\sa XlfExcel, XlfFuncDesc.
*/
int xlw::XlfCmdDesc::DoRegister(const std::string& dllName, const std::string& suggestedHelpId) const
{
    XlfArgDescList arguments = GetArguments();

    // 2 = normal macro, 0 = hidden command
    double type = hidden_ ? 0 : 2;

    int nbargs = static_cast<int>(arguments.size());
    std::string args("A");
    std::string argnames;

    XlfArgDescList::const_iterator it = arguments.begin();
    while (it != arguments.end())
    {
        argnames += (*it).GetName();
        args += (*it).GetType();
        ++it;
        if (it != arguments.end())
            argnames+=", ";
    }

    // When the arguments add up to more then 255 char is problematic. the functions
    // will not register see  see BUG ID: 2834715 on sourceforge - nc
    if(argnames.length() > 255)
    {
        argnames = "Too many arguments for Function Wizard";
    }

    std::vector<LPXLOPER> argArray(10 + nbargs);
    LPXLOPER *px = &argArray[0];

    (*px++) = XlfOper4(dllName);
    (*px++) = XlfOper4(GetName());
    (*px++) = XlfOper4(args);
    (*px++) = XlfOper4(GetAlias());
    (*px++) = XlfOper4(argnames);
    (*px++) = XlfOper4(type);
    (*px++) = XlfOper4("");
    (*px++) = XlfOper4("");
    (*px++) = XlfOper4("");
    (*px++) = XlfOper4(GetComment());
    int counter(0);
    for (it = arguments.begin(); it != arguments.end(); ++it)
    {
        ++counter;
        if(counter < nbargs)
        {
            (*px++) = XlfOper4((*it).GetComment());
        }
        else
        {
            // add dot space to last comment to work around known excel bug
            // see http://msdn.microsoft.com/en-us/library/bb687841.aspx
            (*px++) = XlfOper4((*it).GetComment() + ". ");
        }
    }

    if(XlfExcel::Instance().excel12())
    {
        // total number of arguments limited to 255
        // so we can't send more than 245 argument comments
        nbargs = std::min(nbargs, 245);
    }
    else
    {
        // you can't send more than 30 arguments to the register function
        // in up to version 2003, so just only send help for up to the first 20 parameters
        nbargs = std::min(nbargs, 20);
    }

    XlfOper4 res;
    int err = XlfExcel::Instance().Call4v(xlfRegister, res, 10 + nbargs, &argArray[0]);
    if(err == xlretSuccess && res.IsNumber())
    {
        funcId_ = res.AsDouble();
    }
    else
    {
        funcId_ = InvalidFunctionId;
    }
    return err;
}
Beispiel #18
0
void pgType::ShowTreeDetail(ctlTree *browser, frmMain *form, ctlListView *properties, ctlSQLBox *sqlPane)
{
	wxString query;
	wxString collation;

	if (!expandedKids)
	{
		expandedKids = true;
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			query = wxT("SELECT attname, format_type(t.oid,NULL) AS typname, attndims, atttypmod, nsp.nspname,\n")
			        wxT("       (SELECT COUNT(1) from pg_type t2 WHERE t2.typname=t.typname) > 1 AS isdup");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(",\n       collname, nspc.nspname as collnspname");
			query += wxT("\n  FROM pg_attribute att\n")
			         wxT("  JOIN pg_type t ON t.oid=atttypid\n")
			         wxT("  JOIN pg_namespace nsp ON t.typnamespace=nsp.oid\n")
			         wxT("  LEFT OUTER JOIN pg_type b ON t.typelem=b.oid\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT("  LEFT OUTER JOIN pg_collation c ON att.attcollation=c.oid\n")
				         wxT("  LEFT OUTER JOIN pg_namespace nspc ON c.collnamespace=nspc.oid\n");
			query += wxT(" WHERE att.attrelid=") + NumToStr(relOid) + wxT("\n")
			         wxT(" ORDER by attnum");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						typesList += wxT(", ");
						quotedTypesList += wxT(",\n    ");
					}
					typesList += set->GetVal(wxT("attname")) + wxT(" ");
					typesArray.Add(set->GetVal(wxT("attname")));
					quotedTypesList += qtIdent(set->GetVal(wxT("attname"))) + wxT(" ");

					pgDatatype dt(set->GetVal(wxT("nspname")), set->GetVal(wxT("typname")),
					              set->GetBool(wxT("isdup")), set->GetLong(wxT("attndims")) > 0, set->GetLong(wxT("atttypmod")));

					wxString nspname = set->GetVal(wxT("nspname"));

					typesList += dt.GetSchemaPrefix(GetDatabase()) + dt.FullName();
					typesArray.Add(dt.GetSchemaPrefix(GetDatabase()) + dt.FullName());
					quotedTypesList += dt.GetQuotedSchemaPrefix(GetDatabase()) + dt.QuotedFullName();

					if (GetConnection()->BackendMinimumVersion(9, 1))
					{
						if (set->GetVal(wxT("collname")).IsEmpty() || (set->GetVal(wxT("collname")) == wxT("default") && set->GetVal(wxT("collnspname")) == wxT("pg_catalog")))
							collation = wxEmptyString;
						else
						{
							collation = qtIdent(set->GetVal(wxT("collnspname"))) + wxT(".") + qtIdent(set->GetVal(wxT("collname")));
							quotedTypesList += wxT(" COLLATE ") + collation;
						}
						collationsArray.Add(collation);
					}
					typesArray.Add(collation);

					set->MoveNext();
				}
				delete set;
			}
		}
		else if (GetTypeClass() == TYPE_ENUM)
		{
			query = wxT("SELECT enumlabel\n")
			        wxT("  FROM pg_enum\n")
			        wxT(" WHERE enumtypid=") + GetOidStr() + wxT("\n");
			if (GetConnection()->BackendMinimumVersion(9, 1))
				query += wxT(" ORDER by enumsortorder");
			else
				query += wxT(" ORDER by oid");
			pgSet *set = ExecuteSet(query);
			if (set)
			{
				int anzvar = 0;
				while (!set->Eof())
				{
					wxString element;
					if (anzvar++)
					{
						labelList += wxT(", ");
						quotedLabelList += wxT(",\n    ");
					}
					labelList += set->GetVal(wxT("enumlabel"));
					labelArray.Add(set->GetVal(wxT("enumlabel")));
					quotedLabelList += GetDatabase()->connection()->qtDbString(set->GetVal(wxT("enumlabel")));

					set->MoveNext();
				}
				delete set;
			}
		}
	}

	if (properties)
	{
		CreateListColumns(properties);

		properties->AppendItem(_("Name"), GetName());
		properties->AppendItem(_("OID"), GetOid());
		properties->AppendItem(_("Owner"), GetOwner());
		properties->AppendItem(_("Alias"), GetAlias());
		if (GetTypeClass() == TYPE_COMPOSITE)
		{
			properties->AppendItem(_("Members"), GetTypesList());
		}
		if (GetTypeClass() == TYPE_ENUM)
		{
			properties->AppendItem(_("Labels"), GetLabelList());
		}
		else
		{
			properties->AppendItem(_("Alignment"), GetAlignment());
			properties->AppendItem(_("Internal length"), GetInternalLength());
			properties->AppendItem(_("Default"), GetDefault());
			properties->AppendItem(_("Passed by Value?"), BoolToYesNo(GetPassedByValue()));
			if (!GetElement().IsEmpty())
			{
				properties->AppendItem(_("Element"), GetElement());
				properties->AppendItem(_("Delimiter"), GetDelimiter());
			}
			properties->AppendItem(_("Input function"), GetInputFunction());
			properties->AppendItem(_("Output function"), GetOutputFunction());
			if (GetConnection()->BackendMinimumVersion(7, 4))
			{
				properties->AppendItem(_("Receive function"), GetReceiveFunction());
				properties->AppendItem(_("Send function"), GetSendFunction());
			}
			if (GetConnection()->BackendMinimumVersion(8, 3))
			{
				if (GetTypmodinFunction().Length() > 0)
					properties->AppendItem(_("Typmod in function"), GetTypmodinFunction());
				if (GetTypmodoutFunction().Length() > 0)
					properties->AppendItem(_("Typmod out function"), GetTypmodoutFunction());
			}
			properties->AppendItem(_("Storage"), GetStorage());
			if (GetConnection()->BackendMinimumVersion(9, 1))
				properties->AppendItem(_("Collatable?"), BoolToYesNo(GetCollatable()));
		}
		properties->AppendYesNoItem(_("System type?"), GetSystemObject());
		properties->AppendItem(_("Comment"), firstLineOnly(GetComment()));

		if (!GetLabels().IsEmpty())
		{
			wxArrayString seclabels = GetProviderLabelArray();
			if (seclabels.GetCount() > 0)
			{
				for (unsigned int index = 0 ; index < seclabels.GetCount() - 1 ; index += 2)
				{
					properties->AppendItem(seclabels.Item(index), seclabels.Item(index + 1));
				}
			}
		}
	}
}
void pawsBuddyWindow::OnStringEntered(const char* name, int /*param*/, const char* value)
{
    if (!value || !strlen(value))
    {
        if (!strcmp(name, "EditBuddy"))
            editBuddy.Clear();
        return;
    }

    if (!strcmp(name,"AddBuddy"))
    {
        // Is the new buddy name unique?
        if (!IsUniqueAlias(value))
        {
            psSystemMessage err(0, MSG_ERROR, "%s '%s' %s", 
                                PawsManager::GetSingleton().Translate("Buddy with the name").GetData(),value,
                                PawsManager::GetSingleton().Translate("already exists.").GetData());
            err.FireEvent();
            return;
        }
        csString command;
        command.Format("/buddy %s add", value);
        psengine->GetCmdHandler()->Execute(command);
    }
    else if (!strcmp(name,"RemoveBuddy"))
    {
        csString command;
        command.Format("/buddy %s remove", value);
        psengine->GetCmdHandler()->Execute(command);
        
        currentBuddy.Clear();

        if (editBuddy.Compare(value))
        {
            // Removing the buddy that is being edited
            editBuddy.Clear();
        }

        // Remove from the alias list. It may fail on the server, but we don't have enough
        // information to remove the alias when the buddy was actually removed.
        if (aliases.DeleteAll(value))
            SaveAliases(psengine->GetMainPlayerName());
    }
    else if (!strcmp(name, "EditBuddy"))
    {
        // It might be that the player removed the buddy from the list before clicking OK
        if (editBuddy.IsEmpty())
        {
            psSystemMessage err(0, MSG_ERROR,
                                "%s '%s' %s",
                                PawsManager::GetSingleton().Translate("Buddy with the new name").GetData(),
                                value,
                                PawsManager::GetSingleton().Translate("cannot be found. Perhaps it was removed.").GetData());
            err.FireEvent();
            return;
        }

        csString alias = GetAlias(editBuddy);
        ChangeAlias(editBuddy, alias, value);

        editBuddy.Clear();

    }
    else
    {
        csString command;
        command.Format("/tell %s %s", name, value );
        psengine->GetCmdHandler()->Execute(command, false);
    }
}
Beispiel #20
0
// function Excel4 calls always as using XLOPER12 seem problematic
int xlw::XlfFuncDesc::RegisterAs(const std::string& dllName, const std::string& suggestedHelpId, double mode_) const
{
    // alias arguments
    XlfArgDescList& arguments = impl_->arguments_;

    int nbargs = static_cast<int>(arguments.size());
    std::string args(returnTypeCode_);
    std::string argnames;

    // the synchronous part of an asynchronous function returns void
    if (XlfExcel::Instance().excel14() && impl_->Asynchronous_)
    {
        args = ">";
    }

    XlfArgDescList::const_iterator it = arguments.begin();
    while (it != arguments.end())
    {
        argnames += (*it).GetName();
        args += (*it).GetType();
        ++it;
        if (it != arguments.end())
            argnames+=", ";
    }
    
    // When the arguments add up to more then 255 char is problematic. the functions
    // will not register see  see BUG ID: 2834715 on sourceforge - nc
    if(argnames.length() > 255)
    {
        argnames = "Too many arguments for Function Wizard";
    }

    // the synchronous part of an asynchronous function have an extra 
    // bigdata xloper on the end containing the handle
    if (XlfExcel::Instance().excel14() && impl_->Asynchronous_)
    {
        args += "X";
    }
    if (impl_->recalcPolicy_ == xlw::XlfFuncDesc::Volatile)
    {
        args+="!";
    }
    if (XlfExcel::Instance().excel12() && impl_->Threadsafe_)
    {
        args+="$";
    }
    if (XlfExcel::Instance().excel14() && impl_->ClusterSafe_)
    {
        args+="&";
    }
    if (impl_->MacroSheetEquivalent_)
    {
        args+="#";
    }

    args+='\0'; // null termination for C string

    std::vector<LPXLOPER> argArray(10 + nbargs);
    LPXLOPER *px = &argArray[0];
    std::string functionName(GetName());

    // We need to have 2 functions exposed one for less than
    // version 14 and that it the normal function, we also need
    // the Synchronous part that returns void and takes an extra int
    // By convension this is the same as the normal function but with 
    // Sync on the end
    if (XlfExcel::Instance().excel14() && impl_->Asynchronous_)
    {
        functionName += "Sync";
    }

    (*px++) = XlfOper4(dllName);
    (*px++) = XlfOper4(functionName);
    (*px++) = XlfOper4(args);
    (*px++) = XlfOper4(GetAlias());
    (*px++) = XlfOper4(argnames);
    (*px++) = XlfOper4(mode_);
    (*px++) = XlfOper4(impl_->category_);
    (*px++) = XlfOper4(""); // shortcut
    // use best help context
    if(!helpID_.empty() && helpID_ != "auto")
    {
        (*px++) = XlfOper4(helpID_);
    }
    else
    {
        (*px++) = XlfOper4(suggestedHelpId); 
    }
    (*px++) = XlfOper4(GetComment());
    int counter(0);
    for (it = arguments.begin(); it != arguments.end(); ++it)
    {
        ++counter;
        if(counter < nbargs)
        {
            (*px++) = XlfOper4((*it).GetComment());
        }
        else
        {
            // add dot space to last comment to work around known excel bug
            // see http://msdn.microsoft.com/en-us/library/bb687841.aspx
            (*px++) = XlfOper4((*it).GetComment() + ". ");
        }
    }

    if(XlfExcel::Instance().excel12())
    {
        // total number of arguments limited to 255
        // so we can't send more than 245 argument comments
        nbargs = std::min(nbargs, 245);
    }
    else
    {
        // you can't send more than 30 arguments to the register function
        // in up to version 2003, so just only send help for up to the first 20 parameters
        nbargs = std::min(nbargs, 20);
    }

    XlfOper4 res;
    int err = XlfExcel::Instance().Call4v(xlfRegister, res, 10 + nbargs, &argArray[0]);
    if(err == xlretSuccess && res.IsNumber())
    {
        funcId_ = res.AsDouble();
    }
    else
    {
        funcId_ = InvalidFunctionId;
    }

    return err;
}
Beispiel #21
0
	string_t CFileSystem::GetWorkingDir( void ) {
		return GetAlias( "home" );
	}
Beispiel #22
0
/// This function is using a naked XLOPER
int xlw::XlfCmdDesc::AddToMenuBar(const char* menu, const char* text)
{
    // allow user to override stored values
    if(menu)
    {
        menu_ = menu;
    }
    if(text)
    {
        text_ = text;
    }

    // we can only proceed if we have both
    if(menu_.empty() || text_.empty())
    {
        return 0;
    }

    //first check to see if the menu already exists
    XlfOper barNum(10);
    XlfOper menuLocation;
    XlfOper missingValue;
    XlfOper menuOper(menu_);
    int err = XlfExcel::Instance().Call(xlfGetBar, menuLocation, 3, barNum, menuOper, XlfOper(0));
    if (err || menuLocation.IsError())
    {
		// if it doesn't then we have to find the id of the last menu item on the worksheet bar
		// usually this is Help but we need to cope with internation versions so we find it by
		// searching over the bars until we get an error.
		// we skip the search at 1 as we want to fail safe and always exit with something that will work
		int menuPosition(1);
		XlfOper menuName;
		err = XlfExcel::Instance().Call(xlfGetBar, menuName, 3, barNum, XlfOper(menuPosition + 1), XlfOper(0));
		while(!err && !menuName.IsError())
		{
			++menuPosition;
			err = XlfExcel::Instance().Call(xlfGetBar, menuName, 3, barNum, XlfOper(menuPosition + 1), XlfOper(0));
		}

		// now add the menu and the first command in a single request
        XlfOper menuDesc(2,5);
        menuDesc(0,0) = menu_;
        menuDesc(0,1) = "";
        menuDesc(0,2) = "";
        menuDesc(0,3) = "";
        menuDesc(0,4) = "";
        menuDesc(1,0) = text_;
        menuDesc(1,1) = GetAlias();
        menuDesc(1,2) = "";
        menuDesc(1,3) = GetComment();
        menuDesc(1,4) = "";
        err = XlfExcel::Instance().Call(xlfAddMenu, 0, 3, barNum, menuDesc, XlfOper(menuPosition));
        if(err != xlretSuccess)
		{
			// continue on failure but would be good to get reports if this happens
            std::cerr << XLW__HERE__ << "Add Menu " <<  menu_.c_str() << " failed" << std::endl;
		}
    }
	else
	{
		// if the bar is already there then add the current commamnd
		XlfOper command(1,4);
		command(0,0) = text_;
		command(0,1) = GetAlias();
		command(0,2) = "";
		command(0,3) = GetComment();

		err = XlfExcel::Instance().Call(xlfAddCommand, 0, 3, barNum, menuOper, command);
		if (err != xlretSuccess)
		{
			// continue on failure but would be good to get reports if this happens
			std::cerr << XLW__HERE__ << "Add command " << GetName().c_str() << " to " << menu_.c_str() << " failed" << std::endl;
		}
	}
    return err;
}