Kaydet (Commit) f4990af4 authored tarafından Tino Rachui's avatar Tino Rachui

#97684#

üst 31a40039
#include <stdexcept>
#ifndef _OSL_DIAGNOSE_H_
#include <osl/diagnose.h>
#endif
#ifndef _CMDLINE_HXX_
#include "cmdline.hxx"
#endif
//---------------------------------
/** Simple command line abstraction
*/
//################################
// Creation
//################################
CommandLine::CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix) :
m_argc(argc),
m_argv(argv),
m_argprefix(ArgPrefix)
{
}
//################################
// Query
//################################
/** Return the argument count
*/
size_t CommandLine::GetArgumentCount() const
{
return m_argc;
}
/** Return an argument by index
This method doesn't skip argument
names if any, so if the second
argument is an argument name the
function nevertheless returns it.
@precond 0 <= Index < GetArgumentCount
@throws std::out_of_range exception
if the given index is to high
*/
std::string CommandLine::GetArgument(size_t Index) const
{
OSL_PRECOND(Index < m_argc, "Index out of range");
if (Index > (m_argc - 1))
throw std::out_of_range("Invalid index");
return m_argv[Index];
}
/** Returns all argument name found in the
command line. An argument will be identified
by a specified prefix. The standard prefix
is '-'.
If the are no argument names the returned
container is empty.
*/
StringListPtr_t CommandLine::GetArgumentNames() const
{
StringListPtr_t arg_cont(new StringList_t());
for (size_t i = 0; i < m_argc; i++)
{
std::string argn = m_argv[i];
if (IsArgumentName(argn))
arg_cont->push_back(argn);
}
return arg_cont;
}
/** Returns an argument by name. If there are
duplicate argument names in the command line,
the first one wins.
Argument name an the argument value must be separated
by spaces. If the argument value starts with an
argument prefix use quotes else the return value is
an empty string because the value will be interpreted
as the next argument name.
If an argument value contains spaces use quotes.
@precond GetArgumentNames() -> has element ArgumentName
@throws std::invalid_argument exception
if the specified argument could not be
found
*/
std::string CommandLine::GetArgument(const std::string& ArgumentName) const
{
std::string arg_value;
for (size_t i = 0; i < m_argc; i++)
{
std::string arg = m_argv[i];
if (ArgumentName == arg && ((i+1) < m_argc) && !IsArgumentName(m_argv[i+1]))
{
arg_value = m_argv[i+1];
break;
}
}
if (i == m_argc)
throw std::invalid_argument("Invalid argument name");
return arg_value;
}
//################################
// Command
//################################
/** Set the prefix used to identify arguments in
the command line.
@precond prefix is not empty
@throws std::invalid_argument exception if
the prefix is empty
*/
void CommandLine::SetArgumentPrefix(const std::string& Prefix)
{
OSL_PRECOND(Prefix.length(), "Empty argument prefix!");
if (0 == Prefix.length())
throw std::invalid_argument("Empty argument prefix not allowed");
m_argprefix = Prefix;
}
/** Returns whether a given argument is an argument name
*/
bool CommandLine::IsArgumentName(const std::string& Argument) const
{
return (0 == Argument.compare(0, m_argprefix.length(), m_argprefix));
}
#ifndef _CMDLINE_HXX_
#define _CMDLINE_HXX_
#ifndef _DEFS_HXX_
#include "defs.hxx"
#endif
//---------------------------------
/** Simple command line abstraction
*/
class CommandLine
{
public:
//################################
// Creation
//################################
CommandLine(size_t argc, char* argv[], const std::string& ArgPrefix = std::string("-"));
//################################
// Query
//################################
/** Return the argument count
*/
size_t GetArgumentCount() const;
/** Return an argument by index
This method doesn't skip argument
names if any, so if the second
argument is an argument name the
function nevertheless returns it.
@precond 0 <= Index < GetArgumentCount
@throws std::out_of_range exception
if the given index is to high
*/
std::string GetArgument(size_t Index) const;
/** Returns all argument name found in the
command line. An argument will be identified
by a specified prefix. The standard prefix
is '-'.
If there are no argument names the returned
container is empty.
*/
StringListPtr_t GetArgumentNames() const;
/** Returns an argument by name. If there are
duplicate argument names in the command line,
the first one wins.
Argument name an the argument value must be separated
by spaces. If the argument value starts with an
argument prefix use quotes else the return value is
an empty string because the value will be interpreted
as the next argument name.
If an argument value contains spaces use quotes.
@precond GetArgumentNames() -> has element ArgumentName
@throws std::invalid_argument exception
if the specified argument could not be
found
*/
std::string GetArgument(const std::string& ArgumentName) const;
//################################
// Command
//################################
/** Set the prefix used to identify arguments in
the command line.
@precond prefix is not empty
@throws std::invalid_argument exception if
the prefix is empty
*/
void SetArgumentPrefix(const std::string& Prefix);
private:
/** Returns whether a given argument is an argument name
*/
bool IsArgumentName(const std::string& Argument) const;
private:
size_t m_argc;
char** m_argv;
std::string m_argprefix;
// prevent copy and assignment
private:
CommandLine(const CommandLine&);
CommandLine& operator=(const CommandLine&);
};
#endif
#ifndef _DEFS_HXX_
#define _DEFS_HXX_
#include <vector>
#include <string>
#include <memory>
typedef std::vector<std::string> StringList_t;
typedef std::auto_ptr<StringList_t> StringListPtr_t;
typedef std::vector<int> IntegerList_t;
typedef std::auto_ptr<IntegerList_t> IntegerListPtr_t;
#endif
This diff is collapsed.
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: tra $ $Date: 2002-08-26 10:50:02 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..$/..
PRJNAME=shell
TARGET=lngconvex
TARGETTYPE=CUI
LIBTARGET=NO
ENABLE_EXCEPTIONS=TRUE
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# --- Files --------------------------------------------------------
CFLAGS+=/Ob0 /D_NTSDK
APP1TARGET=$(TARGET)
APP1OBJS=$(OBJ)$/$(TARGET).obj\
$(OBJ)$/cmdline.obj
# need msvcprt.lib for bad_cast exception
# symbols if we compiler with exceptions
# only valid for a tool like this
APP1STDLIBS= $(SALLIB)\
$(TOOLSLIB)\
$(SOLARLIBDIR)$/atools.lib\
msvcprt.lib
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
/*************************************************************************
*
* $RCSfile: classfactory.cxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2002-08-26 10:53:56 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _GLOBAL_HXX_
#include "global.hxx"
#endif
#ifndef _CLASSFACTORY_HXX_
#include "classfactory.hxx"
#endif
#ifndef _INFOTIP_HXX_
#include "infotip.hxx"
#endif
#ifndef _PROPSHTHDL_HXX_
#include "propshthdl.hxx"
#endif
#ifndef _COLUMNPROVIDER_HXX_
#include "columnprovider.hxx"
#endif
#ifndef _SHLXTHDL_HXX_
#include "shlxthdl.hxx"
#endif
//-----------------------------
//
//-----------------------------
long CClassFactory::s_ServerLocks = 0;
//-----------------------------
//
//-----------------------------
CClassFactory::CClassFactory(const CLSID& clsid) :
m_RefCnt(1),
m_Clsid(clsid)
{
InterlockedIncrement(&g_DllRefCnt);
}
//-----------------------------
//
//-----------------------------
CClassFactory::~CClassFactory()
{
InterlockedDecrement(&g_DllRefCnt);
}
//-----------------------------
// IUnknown methods
//-----------------------------
HRESULT STDMETHODCALLTYPE CClassFactory::QueryInterface(REFIID riid, void __RPC_FAR *__RPC_FAR *ppvObject)
{
*ppvObject = 0;
if (IID_IUnknown == riid || IID_IClassFactory == riid)
{
IUnknown* pUnk = this;
pUnk->AddRef();
*ppvObject = pUnk;
return S_OK;
}
return E_NOINTERFACE;
}
//-----------------------------
//
//-----------------------------
ULONG STDMETHODCALLTYPE CClassFactory::AddRef(void)
{
return InterlockedIncrement(&m_RefCnt);
}
//-----------------------------
//
//-----------------------------
ULONG STDMETHODCALLTYPE CClassFactory::Release(void)
{
long refcnt = InterlockedDecrement(&m_RefCnt);
if (0 == refcnt)
delete this;
return refcnt;
}
//-----------------------------
// IClassFactory methods
//-----------------------------
HRESULT STDMETHODCALLTYPE CClassFactory::CreateInstance(
IUnknown __RPC_FAR *pUnkOuter,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject)
{
if ((pUnkOuter != NULL))
return CLASS_E_NOAGGREGATION;
IUnknown* pUnk = 0;
if (CLSID_PROPERTYSHEET_HANDLER == m_Clsid)
pUnk = static_cast<IShellExtInit*>(new CPropertySheetHandler());
#ifdef BUILD_SOSL
else if (CLSID_INFOTIP_HANDLER == m_Clsid)
pUnk = static_cast<IQueryInfo*>(new CInfoTip());
#endif
#if defined(_WINXPSDK) && (BUILD_SOSL)
else if (CLSID_COLUMN_HANDLER == m_Clsid)
pUnk = static_cast<IColumnProvider*>(new CColumnProvider());
#endif
POST_CONDITION(pUnk != 0, "Could not create COM object");
if (0 == pUnk)
return E_OUTOFMEMORY;
HRESULT hr = pUnk->QueryInterface(riid, ppvObject);
// if QueryInterface failed the component
// will destroy itself
pUnk->Release();
return hr;
}
//-----------------------------
//
//-----------------------------
HRESULT STDMETHODCALLTYPE CClassFactory::LockServer(BOOL fLock)
{
if (fLock)
InterlockedIncrement(&s_ServerLocks);
else
InterlockedDecrement(&s_ServerLocks);
return S_OK;
}
//-----------------------------
//
//-----------------------------
bool CClassFactory::IsLocked()
{
return (s_ServerLocks > 0);
}
/*************************************************************************
*
* $RCSfile: classfactory.hxx,v $
*
* $Revision: 1.1 $
*
* last change: $Author: tra $ $Date: 2002-08-26 10:53:44 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
*
* - GNU Lesser General Public License Version 2.1
* - Sun Industry Standards Source License Version 1.1
*
* Sun Microsystems Inc., October, 2000
*
* GNU Lesser General Public License Version 2.1
* =============================================
* Copyright 2000 by Sun Microsystems, Inc.
* 901 San Antonio Road, Palo Alto, CA 94303, USA
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License version 2.1, as published by the Free Software Foundation.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*
*
* Sun Industry Standards Source License Version 1.1
* =================================================
* The contents of this file are subject to the Sun Industry Standards
* Source License Version 1.1 (the "License"); You may not use this file
* except in compliance with the License. You may obtain a copy of the
* License at http://www.openoffice.org/license.html.
*
* Software provided under this License is provided on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
* See the License for the specific provisions governing your rights and
* obligations concerning the Software.
*
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
*
* Copyright: 2000 by Sun Microsystems, Inc.
*
* All Rights Reserved.
*
* Contributor(s): _______________________________________
*
*
************************************************************************/
#ifndef _CLASSFACTORY_HXX_
#define _CLASSFACTORY_HXX_
#include <objidl.h>
class CClassFactory : public IClassFactory
{
public:
CClassFactory(const CLSID& clsid);
virtual ~CClassFactory();
//-----------------------------
// IUnknown methods
//-----------------------------
virtual HRESULT STDMETHODCALLTYPE QueryInterface(
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject);
virtual ULONG STDMETHODCALLTYPE AddRef(void);
virtual ULONG STDMETHODCALLTYPE Release(void);
//-----------------------------
// IClassFactory methods
//-----------------------------
virtual HRESULT STDMETHODCALLTYPE CreateInstance(
IUnknown __RPC_FAR *pUnkOuter,
REFIID riid,
void __RPC_FAR *__RPC_FAR *ppvObject);
virtual HRESULT STDMETHODCALLTYPE LockServer(BOOL fLock);
static bool IsLocked();
private:
long m_RefCnt;
CLSID m_Clsid;
static long s_ServerLocks;
};
#endif
DllRegisterServer PRIVATE
DllUnregisterServer PRIVATE
DllGetClassObject PRIVATE
DllCanUnloadNow PRIVATE
\ No newline at end of file
#*************************************************************************
#
# $RCSfile: makefile.mk,v $
#
# $Revision: 1.1 $
#
# last change: $Author: tra $ $Date: 2002-08-26 10:54:14 $
#
# The Contents of this file are made available subject to the terms of
# either of the following licenses
#
# - GNU Lesser General Public License Version 2.1
# - Sun Industry Standards Source License Version 1.1
#
# Sun Microsystems Inc., October, 2000
#
# GNU Lesser General Public License Version 2.1
# =============================================
# Copyright 2000 by Sun Microsystems, Inc.
# 901 San Antonio Road, Palo Alto, CA 94303, USA
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License version 2.1, as published by the Free Software Foundation.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#
#
# Sun Industry Standards Source License Version 1.1
# =================================================
# The contents of this file are subject to the Sun Industry Standards
# Source License Version 1.1 (the "License"); You may not use this file
# except in compliance with the License. You may obtain a copy of the
# License at http://www.openoffice.org/license.html.
#
# Software provided under this License is provided on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
# WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
# MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
# See the License for the specific provisions governing your rights and
# obligations concerning the Software.
#
# The Initial Developer of the Original Code is: Sun Microsystems, Inc.
#
# Copyright: 2000 by Sun Microsystems, Inc.
#
# All Rights Reserved.
#
# Contributor(s): _______________________________________
#
#
#
#*************************************************************************
PRJ=..$/..$/..
PRJNAME=shell
TARGET=shlxthdl
LIBTARGET=NO
ENABLE_EXCEPTIONS=TRUE
USE_DEFFILE=TRUE
TARGET1=regsvrex
TARGETTYPE=CUI
# --- Settings -----------------------------------------------------
.INCLUDE : settings.mk
# set the define _WINXPSDK if you compile
# with a Microsoft platform sdk for Windows
# 2000 and greater
#
# set ISOLATION_AWARE_ENABLE for activating
# the Windows XP visual styles
#/D_WINXPSDK set this for a Win2000/WinXP Platform SDK
#/DBUILD_SOSL for extended functionality (Infotip and
# Column Handler)
CFLAGS+=/DISOLATION_AWARE_ENABLED /DWIN32_LEAN_AND_MEAN /DXML_UNICODE /D_NTSDK /DUNICODE
# --- Files --------------------------------------------------------
RCFILES=$(TARGET).rc
LNGFILES=$(TARGET).lng
SLOFILES=$(SLO)$/classfactory.obj\
$(SLO)$/columnprovider.obj\
$(SLO)$/dbgmacros.obj\
$(SLO)$/fileextensions.obj\
$(SLO)$/infotip.obj\
$(SLO)$/propshthdl.obj\
$(SLO)$/registry.obj\
$(SLO)$/saxdochdl.obj\
$(SLO)$/saxprsrexcptn.obj\
$(SLO)$/shlxthdl.obj\
$(SLO)$/xmlprsr.obj\
$(SLO)$/ziparchv.obj\
$(SLO)$/zipexcptn.obj\
$(SLO)$/metaaccessor.obj\
$(SLO)$/utilities.obj
SHL1TARGET=$(TARGET)
SHL1STDLIBS=uwinapi.lib\
unicows.lib\
oleaut32.lib\
advapi32.lib\
ole32.lib\
uuid.lib\
shell32.lib\
comctl32.lib
SHL1LIBS=$(SOLARLIBDIR)$/zlib.lib\
$(SOLARLIBDIR)$/expat_xmlparse.lib\
$(SOLARLIBDIR)$/expat_xmltok.lib
SHL1DEPN=
SHL1OBJS=$(SLOFILES)
SHL1DEF=$(MISC)$/$(SHL1TARGET).def
SHL1RES=$(RES)$/$(TARGET).res
DEF1NAME=$(SHL1TARGET)
DEF1EXPORTFILE=exports.dxp
OBJFILES=$(OBJ)$/regsvrex.obj
APP1TARGET=$(TARGET1)
APP1OBJS=$(OBJFILES)
APP1STDLIBS=kernel32.lib
APP1DEF=$(MISC)$/$(APP1TARGET).def
# --- Targets ------------------------------------------------------
.INCLUDE : target.mk
# Generate the native Windows resource file
# using lngconvex.exe
$(RCFILES) : $(LNGFILES) makefile.mk rcfooter.txt rcheader.txt rctmpl.txt ctrylnglist.txt
+$(BIN)$/lngconvex.exe -lng ..\..\source\win32\shlxthandler\shlxthdl.lng -rc ..\..\source\win32\shlxthandler\shlxthdl.rc -c ..\..\source\win32\shlxthandler\ctrylnglist.txt -rct ..\..\source\win32\shlxthandler\rctmpl.txt -rch ..\..\source\win32\shlxthandler\rcheader.txt -rcf ..\..\source\win32\shlxthandler\rcfooter.txt
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment