<commit_before>/*************************************************************************
 *
 *  $RCSfile: xfldui.cxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: vg $ $Date: 2003-04-17 15:29:06 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#pragma hdrstop

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
#include <com/sun/star/sdbc/DataType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif

#ifndef _FLDMGR_HXX
#include <fldmgr.hxx>
#endif
#ifndef _DBMGR_HXX
#include <dbmgr.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>        // Actives Fenster
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _SWMODULE_HXX
#include <swmodule.hxx>
#endif

using namespace com::sun::star::uno;
using namespace com::sun::star::container;
using namespace com::sun::star::lang;
using namespace com::sun::star::sdb;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdbcx;
using namespace com::sun::star::beans;

// ---------------------------------------------------------------------------
// This file contains all routines of the fldui directory, which must compile
// with exceptions. So we can reduce the code of the other files, which don't
// need any exception handling.
// ---------------------------------------------------------------------------

/*--------------------------------------------------------------------
     Beschreibung: Ist das Datenbankfeld numerisch?
     Anm: Im Fehlerfall wird TRUE returnt.
 --------------------------------------------------------------------*/

BOOL SwFldMgr::IsDBNumeric( const String& rDBName, const String& rTblQryName,
                            BOOL bIsTable, const String& rFldName)
{
    BOOL bNumeric = TRUE;

    SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
                            ::GetActiveView()->GetWrtShell().GetNewDBMgr();

    ::rtl::OUString sSource(rDBName);
    Reference< XConnection> xConnection =
                    pDBMgr->RegisterConnection(sSource);

    if( !xConnection.is() )
        return bNumeric;

    Reference<XColumnsSupplier> xColsSupplier;
    if(bIsTable)
    {
        Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
        if(xTSupplier.is())
        {
            Reference<XNameAccess> xTbls = xTSupplier->getTables();
            DBG_ASSERT(xTbls->hasByName(rTblQryName), "table not available anymore?")
            try
            {
                Any aTable = xTbls->getByName(rTblQryName);
                Reference<XPropertySet> xPropSet;
                aTable >>= xPropSet;
                xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
            }
            catch(Exception&){}
        }
    }
    else
    {
        Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
        if(xQSupplier.is())
        {
            Reference<XNameAccess> xQueries = xQSupplier->getQueries();
            DBG_ASSERT(xQueries->hasByName(rTblQryName), "table not available anymore?")
            try
            {
                Any aQuery = xQueries->getByName(rTblQryName);
                Reference<XPropertySet> xPropSet;
                aQuery >>= xPropSet;
                xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
            }
            catch(Exception&){}
        }
    }

    if(xColsSupplier.is())
    {
        Reference <XNameAccess> xCols;
        try
        {
            xCols = xColsSupplier->getColumns();
        }
        catch(Exception& )
        {
            DBG_ERROR("Exception in getColumns()")
        }
        if(xCols.is() && xCols->hasByName(rFldName))
        {
            Any aCol = xCols->getByName(rFldName);
            Reference <XPropertySet> xCol;
            aCol >>= xCol;
            Any aType = xCol->getPropertyValue( UniString::CreateFromAscii("Type"));
            sal_Int32 eDataType;
            aType >>= eDataType;
            switch(eDataType)
            {
                case DataType::BIT:
                case DataType::TINYINT:
                case DataType::SMALLINT:
                case DataType::INTEGER:
                case DataType::BIGINT:
                case DataType::FLOAT:
                case DataType::REAL:
                case DataType::DOUBLE:
                case DataType::NUMERIC:
                case DataType::DECIMAL:
                case DataType::DATE:
                case DataType::TIME:
                case DataType::TIMESTAMP:
                    break;

                case DataType::BINARY:
                case DataType::VARBINARY:
                case DataType::LONGVARBINARY:
                case DataType::SQLNULL:
                case DataType::OTHER:
                case DataType::OBJECT:
                case DataType::DISTINCT:
                case DataType::STRUCT:
                case DataType::ARRAY:
                case DataType::BLOB:
                case DataType::CLOB:
                case DataType::REF:
                case DataType::CHAR:
                case DataType::VARCHAR:
                case DataType::LONGVARCHAR:
                default:
                    bNumeric = FALSE;
            }
        }
    }
    return bNumeric;
}

<commit_msg>INTEGRATION: CWS dba23 (1.5.894); FILE MERGED 2005/01/21 06:28:45 oj 1.5.894.1: #i40648# new DataType::BOOLEAN<commit_after>/*************************************************************************
 *
 *  $RCSfile: xfldui.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: vg $ $Date: 2005-02-17 10:38:07 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#pragma hdrstop

#ifndef _TOOLS_DEBUG_HXX
#include <tools/debug.hxx>
#endif

#ifndef _COM_SUN_STAR_LANG_XMULTISERVICEFACTORY_HPP_
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
#include <com/sun/star/sdbc/DataType.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XTABLESSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XTablesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDBCX_XCOLUMNSSUPPLIER_HPP_
#include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_SDB_XQUERIESSUPPLIER_HPP_
#include <com/sun/star/sdb/XQueriesSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COMPHELPER_PROCESSFACTORY_HXX_
#include <comphelper/processfactory.hxx>
#endif

#ifndef _FLDMGR_HXX
#include <fldmgr.hxx>
#endif
#ifndef _DBMGR_HXX
#include <dbmgr.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>        // Actives Fenster
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _SWMODULE_HXX
#include <swmodule.hxx>
#endif

using namespace com::sun::star::uno;
using namespace com::sun::star::container;
using namespace com::sun::star::lang;
using namespace com::sun::star::sdb;
using namespace com::sun::star::sdbc;
using namespace com::sun::star::sdbcx;
using namespace com::sun::star::beans;

// ---------------------------------------------------------------------------
// This file contains all routines of the fldui directory, which must compile
// with exceptions. So we can reduce the code of the other files, which don't
// need any exception handling.
// ---------------------------------------------------------------------------

/*--------------------------------------------------------------------
     Beschreibung: Ist das Datenbankfeld numerisch?
     Anm: Im Fehlerfall wird TRUE returnt.
 --------------------------------------------------------------------*/

BOOL SwFldMgr::IsDBNumeric( const String& rDBName, const String& rTblQryName,
                            BOOL bIsTable, const String& rFldName)
{
    BOOL bNumeric = TRUE;

    SwNewDBMgr* pDBMgr = pWrtShell ? pWrtShell->GetNewDBMgr() :
                            ::GetActiveView()->GetWrtShell().GetNewDBMgr();

    ::rtl::OUString sSource(rDBName);
    Reference< XConnection> xConnection =
                    pDBMgr->RegisterConnection(sSource);

    if( !xConnection.is() )
        return bNumeric;

    Reference<XColumnsSupplier> xColsSupplier;
    if(bIsTable)
    {
        Reference<XTablesSupplier> xTSupplier = Reference<XTablesSupplier>(xConnection, UNO_QUERY);
        if(xTSupplier.is())
        {
            Reference<XNameAccess> xTbls = xTSupplier->getTables();
            DBG_ASSERT(xTbls->hasByName(rTblQryName), "table not available anymore?")
            try
            {
                Any aTable = xTbls->getByName(rTblQryName);
                Reference<XPropertySet> xPropSet;
                aTable >>= xPropSet;
                xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
            }
            catch(Exception&){}
        }
    }
    else
    {
        Reference<XQueriesSupplier> xQSupplier = Reference<XQueriesSupplier>(xConnection, UNO_QUERY);
        if(xQSupplier.is())
        {
            Reference<XNameAccess> xQueries = xQSupplier->getQueries();
            DBG_ASSERT(xQueries->hasByName(rTblQryName), "table not available anymore?")
            try
            {
                Any aQuery = xQueries->getByName(rTblQryName);
                Reference<XPropertySet> xPropSet;
                aQuery >>= xPropSet;
                xColsSupplier = Reference<XColumnsSupplier>(xPropSet, UNO_QUERY);
            }
            catch(Exception&){}
        }
    }

    if(xColsSupplier.is())
    {
        Reference <XNameAccess> xCols;
        try
        {
            xCols = xColsSupplier->getColumns();
        }
        catch(Exception& )
        {
            DBG_ERROR("Exception in getColumns()")
        }
        if(xCols.is() && xCols->hasByName(rFldName))
        {
            Any aCol = xCols->getByName(rFldName);
            Reference <XPropertySet> xCol;
            aCol >>= xCol;
            Any aType = xCol->getPropertyValue( UniString::CreateFromAscii("Type"));
            sal_Int32 eDataType;
            aType >>= eDataType;
            switch(eDataType)
            {
                case DataType::BIT:
                case DataType::BOOLEAN:
                case DataType::TINYINT:
                case DataType::SMALLINT:
                case DataType::INTEGER:
                case DataType::BIGINT:
                case DataType::FLOAT:
                case DataType::REAL:
                case DataType::DOUBLE:
                case DataType::NUMERIC:
                case DataType::DECIMAL:
                case DataType::DATE:
                case DataType::TIME:
                case DataType::TIMESTAMP:
                    break;

                case DataType::BINARY:
                case DataType::VARBINARY:
                case DataType::LONGVARBINARY:
                case DataType::SQLNULL:
                case DataType::OTHER:
                case DataType::OBJECT:
                case DataType::DISTINCT:
                case DataType::STRUCT:
                case DataType::ARRAY:
                case DataType::BLOB:
                case DataType::CLOB:
                case DataType::REF:
                case DataType::CHAR:
                case DataType::VARCHAR:
                case DataType::LONGVARCHAR:
                default:
                    bNumeric = FALSE;
            }
        }
    }
    return bNumeric;
}

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: instable.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2004-05-03 13:53:48 $
 *
 *  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 _INSTABLE_HXX
#define _INSTABLE_HXX

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _BASEDLGS_HXX //autogen
#include <sfx2/basedlgs.hxx>
#endif
#ifndef _ACTCTRL_HXX
#include <actctrl.hxx>
#endif

#include "textcontrolcombo.hxx"

class SwWrtShell;
class SwTableAutoFmt;

class SwInsTableDlg : public SfxModalDialog
{
    TableNameEdit   aNameEdit;
    FixedText       aNameFT;
    FixedText       aColLbl;
    NumericField    aColEdit;
    FixedText       aRowLbl;
    NumericField    aRowEdit;

    CheckBox        aHeaderCB;
    CheckBox        aRepeatHeaderCB;
    FixedText       aRepeatHeaderFT;    // "dummy" to build before and after FT
    FixedText       aRepeatHeaderBeforeFT;
    NumericField    aRepeatHeaderNF;
    FixedText       aRepeatHeaderAfterFT;
    TextControlCombo    aRepeatHeaderCombo;

    CheckBox        aDontSplitCB;
    CheckBox        aBorderCB;
    FixedLine       aOptionsFL;

    FixedLine       aFL;
    OKButton        aOkBtn;
    CancelButton    aCancelBtn;
    HelpButton      aHelpBtn;
    PushButton      aAutoFmtBtn;

    SwWrtShell*     pShell;
    SwTableAutoFmt* pTAutoFmt;
    long            nEnteredValRepeatHeaderNF;

    DECL_LINK( ModifyName, Edit * );
    DECL_LINK( ModifyRowCol, NumericField * );
    DECL_LINK( AutoFmtHdl, PushButton* );
    DECL_LINK( CheckBoxHdl, CheckBox *pCB = 0 );
    DECL_LINK( ReapeatHeaderCheckBoxHdl, void* p = 0 );
    DECL_LINK( ModifyRepeatHeaderNF_Hdl, void* p = 0 );

public:
    SwInsTableDlg( SwView& rView );
    ~SwInsTableDlg();

    void GetValues( String& rName, USHORT& rRow, USHORT& rCol,
                    SwInsertTableOptions& rInsTblOpts, String& rTableAutoFmtName,
                    SwTableAutoFmt *& prTAFmt );
};

#endif
<commit_msg>INTEGRATION: CWS os38 (1.4.196); FILE MERGED 2004/09/29 08:40:13 os 1.4.196.1: #i31914# FixedText has to be declared before the Edit<commit_after>/*************************************************************************
 *
 *  $RCSfile: instable.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: hr $ $Date: 2004-11-09 16:22:11 $
 *
 *  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 _INSTABLE_HXX
#define _INSTABLE_HXX

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif
#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif
#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif
#ifndef _BASEDLGS_HXX //autogen
#include <sfx2/basedlgs.hxx>
#endif
#ifndef _ACTCTRL_HXX
#include <actctrl.hxx>
#endif

#include "textcontrolcombo.hxx"

class SwWrtShell;
class SwTableAutoFmt;

class SwInsTableDlg : public SfxModalDialog
{
    FixedText       aNameFT;
    TableNameEdit   aNameEdit;
    FixedText       aColLbl;
    NumericField    aColEdit;
    FixedText       aRowLbl;
    NumericField    aRowEdit;

    CheckBox        aHeaderCB;
    CheckBox        aRepeatHeaderCB;
    FixedText       aRepeatHeaderFT;    // "dummy" to build before and after FT
    FixedText       aRepeatHeaderBeforeFT;
    NumericField    aRepeatHeaderNF;
    FixedText       aRepeatHeaderAfterFT;
    TextControlCombo    aRepeatHeaderCombo;

    CheckBox        aDontSplitCB;
    CheckBox        aBorderCB;
    FixedLine       aOptionsFL;

    FixedLine       aFL;
    OKButton        aOkBtn;
    CancelButton    aCancelBtn;
    HelpButton      aHelpBtn;
    PushButton      aAutoFmtBtn;

    SwWrtShell*     pShell;
    SwTableAutoFmt* pTAutoFmt;
    long            nEnteredValRepeatHeaderNF;

    DECL_LINK( ModifyName, Edit * );
    DECL_LINK( ModifyRowCol, NumericField * );
    DECL_LINK( AutoFmtHdl, PushButton* );
    DECL_LINK( CheckBoxHdl, CheckBox *pCB = 0 );
    DECL_LINK( ReapeatHeaderCheckBoxHdl, void* p = 0 );
    DECL_LINK( ModifyRepeatHeaderNF_Hdl, void* p = 0 );

public:
    SwInsTableDlg( SwView& rView );
    ~SwInsTableDlg();

    void GetValues( String& rName, USHORT& rRow, USHORT& rCol,
                    SwInsertTableOptions& rInsTblOpts, String& rTableAutoFmtName,
                    SwTableAutoFmt *& prTAFmt );
};

#endif
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: redlndlg.hxx,v $
 *
 *  $Revision: 1.5 $
 *
 *  last change: $Author: kz $ $Date: 2006-02-06 13:10:21 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 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
 *
 ************************************************************************/
#ifndef _SWREDLNDLG_HXX
#define _SWREDLNDLG_HXX

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif
#ifndef _CHLDWRAP_HXX
#include "chldwrap.hxx"
#endif
#ifndef _REDLINE_HXX
#include <redline.hxx> //CHINA001
#endif
#ifndef _REDLENUM_HXX
#include <redlenum.hxx>
#endif

#ifndef _TOOLS_INTN_HXX //autogen
#include <tools/intn.hxx>
#endif
#ifndef _DATETIME_HXX //autogen
#include <tools/datetime.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SVSTDARR_HXX
#include <svtools/svstdarr.hxx>
#endif
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#ifndef _BASEDLGS_HXX //autogen
#include <sfx2/basedlgs.hxx>
#endif
#ifndef _SFXVIEWFRM_HXX //autogen
#include <sfx2/viewfrm.hxx>
#endif
#ifndef _SFXDISPATCH_HXX //autogen
#include <sfx2/dispatch.hxx>
#endif
#ifndef _SVX_CTREDLIN_HXX //autogen
#include <svx/ctredlin.hxx>
#endif
#ifndef _SVX_POSTATTR_HXX //autogen
#include <svx/postattr.hxx>
#endif

class SwChildWinWrapper;

//CHINA001 class SwRedlineAcceptDlg;
//add CHINA001 begin this part is extracted from sw\source\ui\misc\redlndlg.cxx
struct SwRedlineDataChild
{
    const SwRedlineData*        pChild;     // Verweis auf originale gestackte Daten
    const SwRedlineDataChild*   pNext;      // Verweis auf gestackte Daten
    SvLBoxEntry*                pTLBChild;  // zugehoeriger TreeListBox-Eintrag
};

struct SwRedlineDataParent
{
    const SwRedlineData*        pData;      // RedlineDataPtr
    const SwRedlineDataChild*   pNext;      // Verweis auf gestackte Daten
    SvLBoxEntry*                pTLBParent; // zugehoeriger TreeListBox-Eintrag
    String                      sComment;   // Redline-Kommentar

    inline BOOL operator==( const SwRedlineDataParent& rObj ) const
                        { return (pData && pData->GetSeqNo() == rObj.pData->GetSeqNo()); }
    inline BOOL operator< ( const SwRedlineDataParent& rObj ) const
                        { return (pData && pData->GetSeqNo() <  rObj.pData->GetSeqNo()); }
};

typedef SwRedlineDataParent* SwRedlineDataParentPtr;
SV_DECL_PTRARR_DEL(SwRedlineDataParentArr, SwRedlineDataParentPtr, 10, 20)

SV_DECL_PTRARR_SORT(SwRedlineDataParentSortArr, SwRedlineDataParentPtr, 10, 20)

typedef SwRedlineDataChild* SwRedlineDataChildPtr;
SV_DECL_PTRARR_DEL(SwRedlineDataChildArr, SwRedlineDataChildPtr, 4, 4)

typedef SvLBoxEntry* SvLBoxEntryPtr;
SV_DECL_PTRARR(SvLBoxEntryArr, SvLBoxEntryPtr, 100, 100)

class SW_DLLPUBLIC SwRedlineAcceptDlg
{
    Dialog*                 pParentDlg;
    SwRedlineDataParentArr  aRedlineParents;
    SwRedlineDataChildArr   aRedlineChilds;
    SwRedlineDataParentSortArr aUsedSeqNo;
    SvxAcceptChgCtr         aTabPagesCTRL;
    PopupMenu               aPopup;
    Timer                   aDeselectTimer;
    Timer                   aSelectTimer;
    String                  sInserted;
    String                  sDeleted;
    String                  sFormated;
    String                  sTableChgd;
    String                  sFmtCollSet;
    String                  sFilterAction;
    String                  sAutoFormat;
    Size                    aBorderSz;
    SvxTPView*              pTPView;
    SvxRedlinTable*         pTable; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
    Link                    aOldSelectHdl;
    Link                    aOldDeselectHdl;
    BOOL                    bOnlyFormatedRedlines;
    BOOL                    bHasReadonlySel;
    BOOL                    bRedlnAutoFmt;

    // prevent update dialog data during longer operations (cf #102657#)
    bool                    bInhibitActivate;

    SW_DLLPRIVATE DECL_LINK( AcceptHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( AcceptAllHdl,  void* );
    SW_DLLPRIVATE DECL_LINK( RejectHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( RejectAllHdl,  void* );
    SW_DLLPRIVATE DECL_LINK( UndoHdl,           void* );
    SW_DLLPRIVATE DECL_LINK( DeselectHdl,       void* );
    SW_DLLPRIVATE DECL_LINK( SelectHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( GotoHdl,           void* );
    SW_DLLPRIVATE DECL_LINK( CommandHdl,        void* );

    SW_DLLPRIVATE USHORT            CalcDiff(USHORT nStart, BOOL bChild);
    SW_DLLPRIVATE void          InsertChilds(SwRedlineDataParent *pParent, const SwRedline& rRedln, const USHORT nAutoFmt);
    SW_DLLPRIVATE void          InsertParents(USHORT nStart, USHORT nEnd = USHRT_MAX);
    SW_DLLPRIVATE void          RemoveParents(USHORT nStart, USHORT nEnd);
    SW_DLLPRIVATE void          InitAuthors();

    SW_DLLPRIVATE String            GetRedlineText(const SwRedline& rRedln, DateTime &rDateTime, USHORT nStack = 0);
    SW_DLLPRIVATE const String& GetActionText(const SwRedline& rRedln, USHORT nStack = 0);
    SW_DLLPRIVATE USHORT            GetRedlinePos( const SvLBoxEntry& rEntry) const;

public:
    SwRedlineAcceptDlg(Dialog *pParent, BOOL bAutoFmt = FALSE);
    ~SwRedlineAcceptDlg();

    DECL_LINK( FilterChangedHdl, void *pDummy = 0 );

    inline SvxAcceptChgCtr* GetChgCtrl()        { return &aTabPagesCTRL; }
    inline BOOL     HasRedlineAutoFmt() const   { return bRedlnAutoFmt; }

    void            Init(USHORT nStart = 0);
    void            CallAcceptReject( BOOL bSelect, BOOL bAccept );

    void            Initialize(const String &rExtraData);
    void            FillInfo(String &rExtraData) const;

    virtual void    Activate();
    virtual void    Resize();
};
//add CHINA001 end

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

class SwModelessRedlineAcceptDlg : public SfxModelessDialog
{
    SwRedlineAcceptDlg*     pImplDlg;
    SwChildWinWrapper*      pChildWin;

    virtual void    Resize();

public:
    SwModelessRedlineAcceptDlg(SfxBindings*, SwChildWinWrapper*, Window *pParent);
    ~SwModelessRedlineAcceptDlg();

    virtual void    Activate();
    virtual void    FillInfo(SfxChildWinInfo&) const;
    void            Initialize (SfxChildWinInfo* pInfo);
};

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

//CHINA001 class SwModalRedlineAcceptDlg : public SfxModalDialog
//CHINA001 {
//CHINA001 SwRedlineAcceptDlg*      pImplDlg;
//CHINA001
//CHINA001 virtual void Resize();
//CHINA001
//CHINA001 public:
//CHINA001 SwModalRedlineAcceptDlg(Window *pParent);
//CHINA001 ~SwModalRedlineAcceptDlg();
//CHINA001
//CHINA001 void         AcceptAll( BOOL bAccept );
//CHINA001 virtual void Activate();
//CHINA001 };

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

class SwRedlineAcceptChild : public SwChildWinWrapper
{
public:
    SwRedlineAcceptChild(   Window* ,
                            USHORT nId,
                            SfxBindings*,
                            SfxChildWinInfo*  );

    SFX_DECL_CHILDWINDOW( SwRedlineAcceptChild );

    virtual BOOL    ReInitDlg(SwDocShell *pDocSh);
};

#endif

<commit_msg>INTEGRATION: CWS internatiodel (1.3.476); FILE MERGED 2006/02/10 22:27:29 er 1.3.476.3: RESYNC: (1.4-1.5); FILE MERGED 2006/01/20 14:20:46 er 1.3.476.2: RESYNC: (1.3-1.4); FILE MERGED 2005/06/24 13:11:23 er 1.3.476.1: #i50205# get rid of class International<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: redlndlg.hxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: vg $ $Date: 2006-04-07 15:19:12 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 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
 *
 ************************************************************************/
#ifndef _SWREDLNDLG_HXX
#define _SWREDLNDLG_HXX

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif
#ifndef _CHLDWRAP_HXX
#include "chldwrap.hxx"
#endif
#ifndef _REDLINE_HXX
#include <redline.hxx> //CHINA001
#endif
#ifndef _REDLENUM_HXX
#include <redlenum.hxx>
#endif

#ifndef _DATETIME_HXX //autogen
#include <tools/datetime.hxx>
#endif
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SVSTDARR_HXX
#include <svtools/svstdarr.hxx>
#endif
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#ifndef _BASEDLGS_HXX //autogen
#include <sfx2/basedlgs.hxx>
#endif
#ifndef _SFXVIEWFRM_HXX //autogen
#include <sfx2/viewfrm.hxx>
#endif
#ifndef _SFXDISPATCH_HXX //autogen
#include <sfx2/dispatch.hxx>
#endif
#ifndef _SVX_CTREDLIN_HXX //autogen
#include <svx/ctredlin.hxx>
#endif
#ifndef _SVX_POSTATTR_HXX //autogen
#include <svx/postattr.hxx>
#endif

class SwChildWinWrapper;

//CHINA001 class SwRedlineAcceptDlg;
//add CHINA001 begin this part is extracted from sw\source\ui\misc\redlndlg.cxx
struct SwRedlineDataChild
{
    const SwRedlineData*        pChild;     // Verweis auf originale gestackte Daten
    const SwRedlineDataChild*   pNext;      // Verweis auf gestackte Daten
    SvLBoxEntry*                pTLBChild;  // zugehoeriger TreeListBox-Eintrag
};

struct SwRedlineDataParent
{
    const SwRedlineData*        pData;      // RedlineDataPtr
    const SwRedlineDataChild*   pNext;      // Verweis auf gestackte Daten
    SvLBoxEntry*                pTLBParent; // zugehoeriger TreeListBox-Eintrag
    String                      sComment;   // Redline-Kommentar

    inline BOOL operator==( const SwRedlineDataParent& rObj ) const
                        { return (pData && pData->GetSeqNo() == rObj.pData->GetSeqNo()); }
    inline BOOL operator< ( const SwRedlineDataParent& rObj ) const
                        { return (pData && pData->GetSeqNo() <  rObj.pData->GetSeqNo()); }
};

typedef SwRedlineDataParent* SwRedlineDataParentPtr;
SV_DECL_PTRARR_DEL(SwRedlineDataParentArr, SwRedlineDataParentPtr, 10, 20)

SV_DECL_PTRARR_SORT(SwRedlineDataParentSortArr, SwRedlineDataParentPtr, 10, 20)

typedef SwRedlineDataChild* SwRedlineDataChildPtr;
SV_DECL_PTRARR_DEL(SwRedlineDataChildArr, SwRedlineDataChildPtr, 4, 4)

typedef SvLBoxEntry* SvLBoxEntryPtr;
SV_DECL_PTRARR(SvLBoxEntryArr, SvLBoxEntryPtr, 100, 100)

class SW_DLLPUBLIC SwRedlineAcceptDlg
{
    Dialog*                 pParentDlg;
    SwRedlineDataParentArr  aRedlineParents;
    SwRedlineDataChildArr   aRedlineChilds;
    SwRedlineDataParentSortArr aUsedSeqNo;
    SvxAcceptChgCtr         aTabPagesCTRL;
    PopupMenu               aPopup;
    Timer                   aDeselectTimer;
    Timer                   aSelectTimer;
    String                  sInserted;
    String                  sDeleted;
    String                  sFormated;
    String                  sTableChgd;
    String                  sFmtCollSet;
    String                  sFilterAction;
    String                  sAutoFormat;
    Size                    aBorderSz;
    SvxTPView*              pTPView;
    SvxRedlinTable*         pTable; // PB 2006/02/02 #i48648 now SvHeaderTabListBox
    Link                    aOldSelectHdl;
    Link                    aOldDeselectHdl;
    BOOL                    bOnlyFormatedRedlines;
    BOOL                    bHasReadonlySel;
    BOOL                    bRedlnAutoFmt;

    // prevent update dialog data during longer operations (cf #102657#)
    bool                    bInhibitActivate;

    SW_DLLPRIVATE DECL_LINK( AcceptHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( AcceptAllHdl,  void* );
    SW_DLLPRIVATE DECL_LINK( RejectHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( RejectAllHdl,  void* );
    SW_DLLPRIVATE DECL_LINK( UndoHdl,           void* );
    SW_DLLPRIVATE DECL_LINK( DeselectHdl,       void* );
    SW_DLLPRIVATE DECL_LINK( SelectHdl,     void* );
    SW_DLLPRIVATE DECL_LINK( GotoHdl,           void* );
    SW_DLLPRIVATE DECL_LINK( CommandHdl,        void* );

    SW_DLLPRIVATE USHORT            CalcDiff(USHORT nStart, BOOL bChild);
    SW_DLLPRIVATE void          InsertChilds(SwRedlineDataParent *pParent, const SwRedline& rRedln, const USHORT nAutoFmt);
    SW_DLLPRIVATE void          InsertParents(USHORT nStart, USHORT nEnd = USHRT_MAX);
    SW_DLLPRIVATE void          RemoveParents(USHORT nStart, USHORT nEnd);
    SW_DLLPRIVATE void          InitAuthors();

    SW_DLLPRIVATE String            GetRedlineText(const SwRedline& rRedln, DateTime &rDateTime, USHORT nStack = 0);
    SW_DLLPRIVATE const String& GetActionText(const SwRedline& rRedln, USHORT nStack = 0);
    SW_DLLPRIVATE USHORT            GetRedlinePos( const SvLBoxEntry& rEntry) const;

public:
    SwRedlineAcceptDlg(Dialog *pParent, BOOL bAutoFmt = FALSE);
    ~SwRedlineAcceptDlg();

    DECL_LINK( FilterChangedHdl, void *pDummy = 0 );

    inline SvxAcceptChgCtr* GetChgCtrl()        { return &aTabPagesCTRL; }
    inline BOOL     HasRedlineAutoFmt() const   { return bRedlnAutoFmt; }

    void            Init(USHORT nStart = 0);
    void            CallAcceptReject( BOOL bSelect, BOOL bAccept );

    void            Initialize(const String &rExtraData);
    void            FillInfo(String &rExtraData) const;

    virtual void    Activate();
    virtual void    Resize();
};
//add CHINA001 end

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

class SwModelessRedlineAcceptDlg : public SfxModelessDialog
{
    SwRedlineAcceptDlg*     pImplDlg;
    SwChildWinWrapper*      pChildWin;

    virtual void    Resize();

public:
    SwModelessRedlineAcceptDlg(SfxBindings*, SwChildWinWrapper*, Window *pParent);
    ~SwModelessRedlineAcceptDlg();

    virtual void    Activate();
    virtual void    FillInfo(SfxChildWinInfo&) const;
    void            Initialize (SfxChildWinInfo* pInfo);
};

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

//CHINA001 class SwModalRedlineAcceptDlg : public SfxModalDialog
//CHINA001 {
//CHINA001 SwRedlineAcceptDlg*      pImplDlg;
//CHINA001
//CHINA001 virtual void Resize();
//CHINA001
//CHINA001 public:
//CHINA001 SwModalRedlineAcceptDlg(Window *pParent);
//CHINA001 ~SwModalRedlineAcceptDlg();
//CHINA001
//CHINA001 void         AcceptAll( BOOL bAccept );
//CHINA001 virtual void Activate();
//CHINA001 };

/*------------------------------------------------------------------------
    Beschreibung:
------------------------------------------------------------------------*/

class SwRedlineAcceptChild : public SwChildWinWrapper
{
public:
    SwRedlineAcceptChild(   Window* ,
                            USHORT nId,
                            SfxBindings*,
                            SfxChildWinInfo*  );

    SFX_DECL_CHILDWINDOW( SwRedlineAcceptChild );

    virtual BOOL    ReInitDlg(SwDocShell *pDocSh);
};

#endif

<|endoftext|>


<commit_before>/* Copyright (c) 2010 Stanford University
 *
 * Permission to use, copy, modify, and distribute this software for any purpose
 * with or without fee is hereby granted, provided that the above copyright
 * notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <errno.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>

#include "Common.h"
#include "IpAddress.h"

namespace RAMCloud {

/**
 * Construct an IpAddress from the information in a ServiceLocator.
 * \param serviceLocator
 *      The "host" and "port" options describe the desired address.
 * \throw BadIpAddress
 *      The serviceLocator couldn't be converted to an IpAddress
 *      (e.g. a required option was missing, or the host name
 *      couldn't be parsed).
 */
IpAddress::IpAddress(const ServiceLocator& serviceLocator)
    : address()
{
    try {
        sockaddr_in *addr = reinterpret_cast<sockaddr_in*>(&address);
        addr->sin_family = AF_INET;

        std::string hostName = serviceLocator.getOption("host");
        hostent* host = gethostbyname(hostName.c_str());
        if (host == NULL) {
            throw BadIpAddressException(std::string("couldn't find host '") +
                                        hostName + "'", serviceLocator);
        }
        memcpy(&addr->sin_addr, host->h_addr, sizeof(addr->sin_addr));
        addr->sin_port = htons(serviceLocator.getOption<uint16_t>("port"));
    } catch (ServiceLocator::NoSuchKeyException& e) {
        throw BadIpAddressException(e.message, serviceLocator);
    } catch (boost::bad_lexical_cast& e) {
        throw BadIpAddressException(e.what(), serviceLocator);
    }
}

/**
 * Return a string describing the contents of this IpAddress (host
 * address & port).
 */
string
IpAddress::toString() const {
    const sockaddr_in *addr = reinterpret_cast<const sockaddr_in*>(&address);
    uint32_t ip = ntohl(addr->sin_addr.s_addr);
    uint32_t port = ntohs(addr->sin_port);
    return format("%d.%d.%d.%d:%d", (ip>>24)&0xff,
                  (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff, port);
}

} // namespace RAMCloud
<commit_msg>RAM-117: use gethostbyname_r instead of gethostbyname.<commit_after>/* Copyright (c) 2010 Stanford University
 *
 * Permission to use, copy, modify, and distribute this software for any purpose
 * with or without fee is hereby granted, provided that the above copyright
 * notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR(S) DISCLAIM ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL AUTHORS BE LIABLE FOR ANY
 * SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER
 * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

#include <errno.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sys/types.h>
#include <sys/socket.h>

#include "Common.h"
#include "IpAddress.h"

namespace RAMCloud {

/**
 * Construct an IpAddress from the information in a ServiceLocator.
 * \param serviceLocator
 *      The "host" and "port" options describe the desired address.
 * \throw BadIpAddress
 *      The serviceLocator couldn't be converted to an IpAddress
 *      (e.g. a required option was missing, or the host name
 *      couldn't be parsed).
 */
IpAddress::IpAddress(const ServiceLocator& serviceLocator)
    : address()
{
    try {
        hostent host;
        hostent* result;
        char buffer[4096];
        int error;
        sockaddr_in* addr = reinterpret_cast<sockaddr_in*>(&address);
        addr->sin_family = AF_INET;

        std::string hostName = serviceLocator.getOption("host");

        // Warning! The return value from getthostbyname_r is advertised
        // as being the same as what is returned at error, but it is not;
        // don't use it.
        gethostbyname_r(hostName.c_str(), &host, buffer, sizeof(buffer),
                &result, &error);
        if (result == 0) {
            // If buffer is too small, an error value of ERANGE is supposed
            // to be returned, but in fact it appears that error is -1 in
            // the situation; check for both.
            if ((error == ERANGE) || (error == -1)) {
                throw FatalError("IpAddress::IpAddress called gethostbyname_r"
                        " with too small a buffer");
            }
            throw BadIpAddressException(std::string("couldn't find host '") +
                                        hostName + "'", serviceLocator);
        }
        memcpy(&addr->sin_addr, host.h_addr, sizeof(addr->sin_addr));
        addr->sin_port = htons(serviceLocator.getOption<uint16_t>("port"));
    } catch (ServiceLocator::NoSuchKeyException& e) {
        throw BadIpAddressException(e.message, serviceLocator);
    } catch (boost::bad_lexical_cast& e) {
        throw BadIpAddressException(e.what(), serviceLocator);
    }
}

/**
 * Return a string describing the contents of this IpAddress (host
 * address & port).
 */
string
IpAddress::toString() const {
    const sockaddr_in *addr = reinterpret_cast<const sockaddr_in*>(&address);
    uint32_t ip = ntohl(addr->sin_addr.s_addr);
    uint32_t port = ntohs(addr->sin_port);
    return format("%d.%d.%d.%d:%d", (ip>>24)&0xff,
                  (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff, port);
}

} // namespace RAMCloud
<|endoftext|>


<commit_before>/**
 *   SFCGAL
 *
 *   Copyright (C) 2012-2013 Oslandia <infos@oslandia.com>
 *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program 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 General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <boost/test/unit_test.hpp>

#include <SFCGAL/Kernel.h>
#include <SFCGAL/all.h>
#include <SFCGAL/io/wkt.h>
#include <SFCGAL/algorithm/area.h>

#include <SFCGAL/tools/Registry.h>

using namespace boost::unit_test ;
using namespace SFCGAL ;

BOOST_AUTO_TEST_SUITE( SFCGAL_algorithm_AreaTest )

BOOST_AUTO_TEST_CASE( testEmpty2D3D )
{
	tools::Registry & registry = tools::Registry::instance() ;
	std::vector< std::string > typeNames = tools::Registry::instance().getGeometryTypes();
	for ( size_t i = 0; i < typeNames.size(); i++ ){
		BOOST_TEST_MESSAGE( typeNames[i] ) ;

		std::auto_ptr< Geometry > g( registry.newGeometryByTypeName( typeNames[i] ) ) ;
		BOOST_REQUIRE( g.get() != NULL ) ;
		BOOST_CHECK_EQUAL( algorithm::area( *g ), 0.0 );
		BOOST_CHECK_EQUAL( algorithm::area3D( *g ), 0.0 );
	}
}

// must return 0.0
BOOST_AUTO_TEST_CASE( testPoint2D3D )
{
	BOOST_CHECK_EQUAL( algorithm::area( Point(3.0,4.0) ), 0.0 );
	BOOST_CHECK_EQUAL( algorithm::area3D( Point(3.0,4.0,5.0) ), 0.0 );
}
// must return 0.0
BOOST_AUTO_TEST_CASE( testLineString2D3D )
{
	BOOST_CHECK_EQUAL( algorithm::area( LineString(Point(0.0,0.0),Point(1.0,1.0)) ), 0.0 );
	BOOST_CHECK_EQUAL( algorithm::area3D( LineString(Point(0.0,0.0,0.0),Point(1.0,1.0,1.0)) ), 0.0 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Triangle1 )
{
	Triangle triangle( Point(0.0,0.0,0.0), Point(0.0,0.0,1.0), Point(0.0,1.0, 0.0) );
	BOOST_CHECK_EQUAL( algorithm::area3D( triangle ), 0.5 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Triangle2 )
{
	Triangle triangle( Point(0.0,0.0,0.0), Point(0.0,0.0,4.0), Point(0.0,4.0, 0.0) );
	BOOST_CHECK_EQUAL( algorithm::area3D( triangle ), 8.0 );
}

BOOST_AUTO_TEST_CASE( testArea2D_Triangle )
{
	Triangle triangle1( Point(0.0,0.0), Point(4.0,0.0), Point(4.0,4.0) );
	// the same, inverted
	Triangle triangle2( Point(0.0,0.0), Point(0.0,4.0), Point(4.0,4.0) );
	BOOST_CHECK_EQUAL( algorithm::area( triangle1 ), 8.0 );
	BOOST_CHECK_EQUAL( algorithm::area( triangle2 ), 8.0 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square1x1 )
{
	std::auto_ptr< Geometry > g( io::readWkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 1.0,0.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 0.0))" ) );
	BOOST_CHECK_EQUAL( g->asText(1), "POLYGON((0.0 0.0 0.0,0.0 0.0 1.0,0.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 0.0))" );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 1.0, 1e-10 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square4X4 )
{
	std::string wkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 4.0,0.0 4.0 4.0,0.0 4.0 0.0,0.0 0.0 0.0))" );
	std::auto_ptr< Geometry > g( io::readWkt( wkt ) );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 16.0, 1e-10 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square4X4WithHole )
{
	std::string wkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 4.0,0.0 4.0 4.0,0.0 4.0 0.0,0.0 0.0 0.0),(0.0 2.0 2.0,0.0 2.0 3.0,0.0 3.0 3.0,0.0 3.0 2.0,0.0 2.0 2.0))" );
	std::auto_ptr< Geometry > g( io::readWkt( wkt ) );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 15.0, 1e-10 );
}

BOOST_AUTO_TEST_SUITE_END()

<commit_msg>[test]add test for algorithm::signedArea(LineString|Triangle)<commit_after>/**
 *   SFCGAL
 *
 *   Copyright (C) 2012-2013 Oslandia <infos@oslandia.com>
 *   Copyright (C) 2012-2013 IGN (http://www.ign.fr)
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program 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 General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */
#include <boost/test/unit_test.hpp>

#include <SFCGAL/Kernel.h>
#include <SFCGAL/all.h>
#include <SFCGAL/io/wkt.h>
#include <SFCGAL/algorithm/area.h>

#include <SFCGAL/tools/Registry.h>

using namespace boost::unit_test ;
using namespace SFCGAL ;

BOOST_AUTO_TEST_SUITE( SFCGAL_algorithm_AreaTest )

BOOST_AUTO_TEST_CASE( testEmpty2D3D )
{
	tools::Registry & registry = tools::Registry::instance() ;
	std::vector< std::string > typeNames = tools::Registry::instance().getGeometryTypes();
	for ( size_t i = 0; i < typeNames.size(); i++ ){
		BOOST_TEST_MESSAGE( typeNames[i] ) ;

		std::auto_ptr< Geometry > g( registry.newGeometryByTypeName( typeNames[i] ) ) ;
		BOOST_REQUIRE( g.get() != NULL ) ;
		BOOST_CHECK_EQUAL( algorithm::area( *g ), 0.0 );
		BOOST_CHECK_EQUAL( algorithm::area3D( *g ), 0.0 );
	}
}

BOOST_AUTO_TEST_CASE( testSignedArea2D_lineString )
{
	LineString lineString ;
	lineString.addPoint( Point(0.0,0.0) );
	lineString.addPoint( Point(1.0,0.0) );
	lineString.addPoint( Point(1.0,1.0) );
	lineString.addPoint( Point(0.0,1.0) );
	lineString.addPoint( lineString.startPoint() );

	BOOST_CHECK_EQUAL( algorithm::signedArea( lineString ),  1.0 );
	lineString.reverse() ;
	BOOST_CHECK_EQUAL( algorithm::signedArea( lineString ), -1.0 );
}

BOOST_AUTO_TEST_CASE( testSignedArea2D_triangle )
{
	Triangle triangle(
		Point(0.0,0.0),
		Point(1.0,0.0),
		Point(1.0,1.0)
	) ;

	BOOST_CHECK_EQUAL( algorithm::signedArea( triangle ),  0.5 );
	triangle.reverse() ;
	BOOST_CHECK_EQUAL( algorithm::signedArea( triangle ), -0.5 );
}

// must return 0.0
BOOST_AUTO_TEST_CASE( testPoint2D3D )
{
	BOOST_CHECK_EQUAL( algorithm::area( Point(3.0,4.0) ), 0.0 );
	BOOST_CHECK_EQUAL( algorithm::area3D( Point(3.0,4.0,5.0) ), 0.0 );
}
// must return 0.0
BOOST_AUTO_TEST_CASE( testLineString2D3D )
{
	BOOST_CHECK_EQUAL( algorithm::area( LineString(Point(0.0,0.0),Point(1.0,1.0)) ), 0.0 );
	BOOST_CHECK_EQUAL( algorithm::area3D( LineString(Point(0.0,0.0,0.0),Point(1.0,1.0,1.0)) ), 0.0 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Triangle1 )
{
	Triangle triangle( Point(0.0,0.0,0.0), Point(0.0,0.0,1.0), Point(0.0,1.0, 0.0) );
	BOOST_CHECK_EQUAL( algorithm::area3D( triangle ), 0.5 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Triangle2 )
{
	Triangle triangle( Point(0.0,0.0,0.0), Point(0.0,0.0,4.0), Point(0.0,4.0, 0.0) );
	BOOST_CHECK_EQUAL( algorithm::area3D( triangle ), 8.0 );
}

BOOST_AUTO_TEST_CASE( testArea2D_Triangle )
{
	Triangle triangle1( Point(0.0,0.0), Point(4.0,0.0), Point(4.0,4.0) );
	// the same, inverted
	Triangle triangle2( Point(0.0,0.0), Point(0.0,4.0), Point(4.0,4.0) );
	BOOST_CHECK_EQUAL( algorithm::area( triangle1 ), 8.0 );
	BOOST_CHECK_EQUAL( algorithm::area( triangle2 ), 8.0 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square1x1 )
{
	std::auto_ptr< Geometry > g( io::readWkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 1.0,0.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 0.0))" ) );
	BOOST_CHECK_EQUAL( g->asText(1), "POLYGON((0.0 0.0 0.0,0.0 0.0 1.0,0.0 1.0 1.0,0.0 1.0 0.0,0.0 0.0 0.0))" );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 1.0, 1e-10 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square4X4 )
{
	std::string wkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 4.0,0.0 4.0 4.0,0.0 4.0 0.0,0.0 0.0 0.0))" );
	std::auto_ptr< Geometry > g( io::readWkt( wkt ) );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 16.0, 1e-10 );
}

BOOST_AUTO_TEST_CASE( testArea3D_Square4X4WithHole )
{
	std::string wkt( "POLYGON((0.0 0.0 0.0,0.0 0.0 4.0,0.0 4.0 4.0,0.0 4.0 0.0,0.0 0.0 0.0),(0.0 2.0 2.0,0.0 2.0 3.0,0.0 3.0 3.0,0.0 3.0 2.0,0.0 2.0 2.0))" );
	std::auto_ptr< Geometry > g( io::readWkt( wkt ) );
	BOOST_CHECK_CLOSE( algorithm::area3D( *g ), 15.0, 1e-10 );
}

BOOST_AUTO_TEST_SUITE_END()

<|endoftext|>


<commit_before>#include <stdint.h>
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>

#include <stdio.h>

/*
 * Translation Table as described in RFC1113
 */
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

/*
 * encodeblock
 *
 * encode 3 8-bit binary bytes as 4 '6-bit' characters
 */
void encodeblock( unsigned char in[3], unsigned char out[4], int len ) {
    out[0] = cb64[ in[0] >> 2 ];
    out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
    out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
    out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
}

/*
 * decodeblock
 *
 * decode 4 '6-bit' characters to 3 8-bit bytes
 */
void decodeblock(unsigned char in[4], unsigned char out[3], int len) {
    unsigned char ch[len];
    for (int i = 0; i < 4; i++)
        ch[i] = strchr(cb64, in[i]) - cb64;

    out[0] = (ch[0] << 2) + ((ch[1] & 0x30) >> 4);
    out[1] = (len > 2 ? ((ch[1] & 0xf) << 4) + ((ch[2] & 0x3c) >> 2) : 0);
    out[2] = (len > 3 ? ((ch[2] & 0x3) << 6) + ch[3] : 0);
}
<commit_msg>Use cstring instead of string.h<commit_after>#include <cstring>
#include <vector>
#include <iostream>
#include <iomanip>
#include <stdint.h>

/*
 * Translation Table as described in RFC1113
 */
static const char cb64[]="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";

/*
 * encodeblock
 *
 * encode 3 8-bit binary bytes as 4 '6-bit' characters
 */
void encodeblock( unsigned char in[3], unsigned char out[4], int len ) {
    out[0] = cb64[ in[0] >> 2 ];
    out[1] = cb64[ ((in[0] & 0x03) << 4) | ((in[1] & 0xf0) >> 4) ];
    out[2] = (unsigned char) (len > 1 ? cb64[ ((in[1] & 0x0f) << 2) | ((in[2] & 0xc0) >> 6) ] : '=');
    out[3] = (unsigned char) (len > 2 ? cb64[ in[2] & 0x3f ] : '=');
}

/*
 * decodeblock
 *
 * decode 4 '6-bit' characters to 3 8-bit bytes
 */
void decodeblock(unsigned char in[4], unsigned char out[3], int len) {
    unsigned char ch[len];
    for (int i = 0; i < 4; i++)
        ch[i] = strchr(cb64, in[i]) - cb64;

    out[0] = (ch[0] << 2) + ((ch[1] & 0x30) >> 4);
    out[1] = (len > 2 ? ((ch[1] & 0xf) << 4) + ((ch[2] & 0x3c) >> 2) : 0);
    out[2] = (len > 3 ? ((ch[2] & 0x3) << 6) + ch[3] : 0);
}
<|endoftext|>


<commit_before><commit_msg>Fix typo that broke the directional shadowmap<commit_after><|endoftext|>


<commit_before>// Scintilla source code edit control
/** @file KeyWords.cxx
 ** Colourise for particular languages.
 **/
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>

#include "Platform.h"

#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"

LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;

LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
	const char *languageName_, LexerFunction fnFolder_) :
	language(language_),
	languageName(languageName_),
	fnLexer(fnLexer_),
	fnFolder(fnFolder_) {
	next = base;
	base = this;
	if (language == SCLEX_AUTOMATIC) {
		language = nextLanguage;
		nextLanguage++;
	}
}

LexerModule *LexerModule::Find(int language) {
	LexerModule *lm = base;
	while (lm) {
		if (lm->language == language) {
			return lm;
		}
		lm = lm->next;
	}
	return 0;
}

LexerModule *LexerModule::Find(const char *languageName) {
	if (languageName) {
		LexerModule *lm = base;
		while (lm) {
			if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
				return lm;
			}
			lm = lm->next;
		}
	}
	return 0;
}

void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
	  WordList *keywordlists[], Accessor &styler) {
	if (fnLexer)
		fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}

void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
	  WordList *keywordlists[], Accessor &styler) {
	if (fnFolder) {
		int lineCurrent = styler.GetLine(startPos);
		// Move back one line in case deletion wrecked current line fold state
		if (lineCurrent > 0) {
			lineCurrent--;
			int newStartPos = styler.LineStart(lineCurrent);
			lengthDoc += startPos - newStartPos;
			startPos = newStartPos;
			initStyle = 0;
			if (startPos > 0) {
				initStyle = styler.StyleAt(startPos - 1);
			}
		}
		fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
	}
}

static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
                            Accessor &styler) {
	// Null language means all style bytes are 0 so just mark the end - no need to fill in.
	if (length > 0) {
		styler.StartAt(startPos + length - 1);
		styler.StartSegment(startPos + length - 1);
		styler.ColourTo(startPos + length - 1, 0);
	}
}

LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");

#ifdef __vms
#define LINK_LEXERS
#endif

#ifdef LINK_LEXERS

// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)

// Taken from wxWindow's stc.cpp. Walter.

int wxForceScintillaLexers(void) {
	Scintilla_LinkLexers();
}

int Scintilla_LinkLexers() {
  extern LexerModule lmAda;
  extern LexerModule lmAVE;
  extern LexerModule lmBaan;
  extern LexerModule lmBatch;
  extern LexerModule lmConf;
  extern LexerModule lmCPP;
  extern LexerModule lmDiff;
  extern LexerModule lmEiffel;
  extern LexerModule lmEiffelkw;
  extern LexerModule lmErrorList;
  extern LexerModule lmHTML;
  extern LexerModule lmLatex;
  extern LexerModule lmLISP;
  extern LexerModule lmLua;
  extern LexerModule lmMake;
  extern LexerModule lmPascal;
  extern LexerModule lmPerl;
  extern LexerModule lmProps;
  extern LexerModule lmPython;
  extern LexerModule lmRuby;
  extern LexerModule lmSQL;
  extern LexerModule lmVB;
  extern LexerModule lmXML;
  extern LexerModule lmBullant;

  if (
      &lmAda
      && &lmAVE
      && &lmBaan
      && &lmConf
      && &lmDiff
      && &lmLatex
      && &lmPascal
      && &lmCPP
      && &lmHTML
      && &lmXML
      && &lmProps
      && &lmErrorList
      && &lmMake
      && &lmBatch
      && &lmPerl
      && &lmPython
      && &lmSQL
      && &lmVB
      && &lmRuby
      && &lmEiffel
      && &lmEiffelkw
      && &lmLISP
      && &lmLua
      && &lmNull
      && &lmBullant
      )
    {
      return 1;
    }
  else
    {
      return 0;
    }
}
#endif
<commit_msg>Made compile in LINK_LEXERS mode.<commit_after>// Scintilla source code edit control
/** @file KeyWords.cxx
 ** Colourise for particular languages.
 **/
// Copyright 1998-2002 by Neil Hodgson <neilh@scintilla.org>
// The License.txt file describes the conditions under which this software may be distributed.

#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
#include <stdarg.h>

#include "Platform.h"

#include "PropSet.h"
#include "Accessor.h"
#include "KeyWords.h"
#include "Scintilla.h"
#include "SciLexer.h"

LexerModule *LexerModule::base = 0;
int LexerModule::nextLanguage = SCLEX_AUTOMATIC+1;

LexerModule::LexerModule(int language_, LexerFunction fnLexer_,
	const char *languageName_, LexerFunction fnFolder_) :
	language(language_),
	languageName(languageName_),
	fnLexer(fnLexer_),
	fnFolder(fnFolder_) {
	next = base;
	base = this;
	if (language == SCLEX_AUTOMATIC) {
		language = nextLanguage;
		nextLanguage++;
	}
}

LexerModule *LexerModule::Find(int language) {
	LexerModule *lm = base;
	while (lm) {
		if (lm->language == language) {
			return lm;
		}
		lm = lm->next;
	}
	return 0;
}

LexerModule *LexerModule::Find(const char *languageName) {
	if (languageName) {
		LexerModule *lm = base;
		while (lm) {
			if (lm->languageName && 0 == strcmp(lm->languageName, languageName)) {
				return lm;
			}
			lm = lm->next;
		}
	}
	return 0;
}

void LexerModule::Lex(unsigned int startPos, int lengthDoc, int initStyle,
	  WordList *keywordlists[], Accessor &styler) {
	if (fnLexer)
		fnLexer(startPos, lengthDoc, initStyle, keywordlists, styler);
}

void LexerModule::Fold(unsigned int startPos, int lengthDoc, int initStyle,
	  WordList *keywordlists[], Accessor &styler) {
	if (fnFolder) {
		int lineCurrent = styler.GetLine(startPos);
		// Move back one line in case deletion wrecked current line fold state
		if (lineCurrent > 0) {
			lineCurrent--;
			int newStartPos = styler.LineStart(lineCurrent);
			lengthDoc += startPos - newStartPos;
			startPos = newStartPos;
			initStyle = 0;
			if (startPos > 0) {
				initStyle = styler.StyleAt(startPos - 1);
			}
		}
		fnFolder(startPos, lengthDoc, initStyle, keywordlists, styler);
	}
}

static void ColouriseNullDoc(unsigned int startPos, int length, int, WordList *[],
                            Accessor &styler) {
	// Null language means all style bytes are 0 so just mark the end - no need to fill in.
	if (length > 0) {
		styler.StartAt(startPos + length - 1);
		styler.StartSegment(startPos + length - 1);
		styler.ColourTo(startPos + length - 1, 0);
	}
}

LexerModule lmNull(SCLEX_NULL, ColouriseNullDoc, "null");

#ifdef __vms
#define LINK_LEXERS
#endif

#ifdef LINK_LEXERS

// The following code forces a reference to all of the Scintilla lexers.
// If we don't do something like this, then the linker tends to "optimize"
// them away. (eric@sourcegear.com)

// Taken from wxWindow's stc.cpp. Walter.

int wxForceScintillaLexers(void) {
	return Scintilla_LinkLexers();
}

int Scintilla_LinkLexers() {
  extern LexerModule lmAda;
  extern LexerModule lmAVE;
  extern LexerModule lmBaan;
  extern LexerModule lmBatch;
  extern LexerModule lmConf;
  extern LexerModule lmCPP;
  extern LexerModule lmDiff;
  extern LexerModule lmEiffel;
  extern LexerModule lmEiffelkw;
  extern LexerModule lmErrorList;
  extern LexerModule lmHTML;
  extern LexerModule lmLatex;
  extern LexerModule lmLISP;
  extern LexerModule lmLua;
  extern LexerModule lmMake;
  extern LexerModule lmPascal;
  extern LexerModule lmPerl;
  extern LexerModule lmProps;
  extern LexerModule lmPython;
  extern LexerModule lmRuby;
  extern LexerModule lmSQL;
  extern LexerModule lmVB;
  extern LexerModule lmXML;
  extern LexerModule lmBullant;

  if (
      &lmAda
      && &lmAVE
      && &lmBaan
      && &lmConf
      && &lmDiff
      && &lmLatex
      && &lmPascal
      && &lmCPP
      && &lmHTML
      && &lmXML
      && &lmProps
      && &lmErrorList
      && &lmMake
      && &lmBatch
      && &lmPerl
      && &lmPython
      && &lmSQL
      && &lmVB
      && &lmRuby
      && &lmEiffel
      && &lmEiffelkw
      && &lmLISP
      && &lmLua
      && &lmNull
      && &lmBullant
      )
    {
      return 1;
    }
  else
    {
      return 0;
    }
}
#endif
<|endoftext|>


<commit_before>#ifdef STAN_OPENCL
#include <stan/math/opencl/prim.hpp>
#include <stan/math/prim.hpp>
#include <test/unit/util.hpp>
#include <gtest/gtest.h>

TEST(MathMetaPrim, ref_type_matrix_cl) {
  using stan::math::matrix_cl;
  using stan::ref_type_t;
  Eigen::MatrixXd a_eig(3, 3);
  a_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> a(a_eig);
  matrix_cl<double> a2 = a;
  ref_type_t<matrix_cl<double>> a_ref1 = a;
  ref_type_t<matrix_cl<double>&> a_ref2 = a;
  ref_type_t<matrix_cl<double>&&> a_ref3 = std::move(a2);

  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a));

  EXPECT_TRUE(
      (std::is_same<decltype(a), ref_type_t<decltype(a)&&>>::value));
  EXPECT_TRUE(std::is_lvalue_reference<
              ref_type_t<matrix_cl<double>>>::value);
  EXPECT_TRUE(std::is_lvalue_reference<
              ref_type_t<matrix_cl<double>&>>::value);
  EXPECT_FALSE(
      std::is_reference<ref_type_t<matrix_cl<double>&&>>::value);
}

TEST(MathMetaPrim, ref_type_kg_light_expression) {
  using stan::math::matrix_cl;
  using stan::ref_type_t;
  Eigen::MatrixXd m_eig(3, 3);
  m_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> m(m_eig);
  auto a = stan::math::block_zero_based(m, 0, 1, 2, 2);
  ref_type_t<decltype(a)> a_ref1 = a;
  ref_type_t<decltype(a)&> a_ref2 = a;
  ref_type_t<decltype(a)&&> a_ref3
      = stan::math::block_zero_based(m, 0, 1, 2, 2);

  matrix_cl<double> a_eval = a;
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a_eval));

  EXPECT_FALSE((stan::is_matrix_cl<ref_type_t<decltype(a)>>::value));
  EXPECT_FALSE(
      (stan::is_matrix_cl<ref_type_t<decltype(a)&>>::value));
  EXPECT_FALSE(
      (stan::is_matrix_cl<ref_type_t<decltype(a)&&>>::value));
}

TEST(MathMetaPrim, ref_type_kg_heavy_expression) {
  using stan::math::matrix_cl;
  using stan::ref_type_t;
  Eigen::MatrixXd m_eig(3, 3);
  m_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> m(m_eig);
  auto a = m * 3;
  ref_type_t<decltype(a)> a_ref1 = a;
  ref_type_t<decltype(a)&> a_ref2 = a;
  ref_type_t<decltype(a)&&> a_ref3 = m * 3;

  matrix_cl<double> a_eval = a;
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a_eval));

  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)>>::value));
  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)&>>::value));
  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)&&>>::value));
}

#endif
<commit_msg>[Jenkins] auto-formatting by clang-format version 6.0.0-1ubuntu2~16.04.1 (tags/RELEASE_600/final)<commit_after>#ifdef STAN_OPENCL
#include <stan/math/opencl/prim.hpp>
#include <stan/math/prim.hpp>
#include <test/unit/util.hpp>
#include <gtest/gtest.h>

TEST(MathMetaPrim, ref_type_matrix_cl) {
  using stan::ref_type_t;
  using stan::math::matrix_cl;
  Eigen::MatrixXd a_eig(3, 3);
  a_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> a(a_eig);
  matrix_cl<double> a2 = a;
  ref_type_t<matrix_cl<double>> a_ref1 = a;
  ref_type_t<matrix_cl<double>&> a_ref2 = a;
  ref_type_t<matrix_cl<double>&&> a_ref3 = std::move(a2);

  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a));

  EXPECT_TRUE((std::is_same<decltype(a), ref_type_t<decltype(a)&&>>::value));
  EXPECT_TRUE(std::is_lvalue_reference<ref_type_t<matrix_cl<double>>>::value);
  EXPECT_TRUE(std::is_lvalue_reference<ref_type_t<matrix_cl<double>&>>::value);
  EXPECT_FALSE(std::is_reference<ref_type_t<matrix_cl<double>&&>>::value);
}

TEST(MathMetaPrim, ref_type_kg_light_expression) {
  using stan::ref_type_t;
  using stan::math::matrix_cl;
  Eigen::MatrixXd m_eig(3, 3);
  m_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> m(m_eig);
  auto a = stan::math::block_zero_based(m, 0, 1, 2, 2);
  ref_type_t<decltype(a)> a_ref1 = a;
  ref_type_t<decltype(a)&> a_ref2 = a;
  ref_type_t<decltype(a)&&> a_ref3
      = stan::math::block_zero_based(m, 0, 1, 2, 2);

  matrix_cl<double> a_eval = a;
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a_eval));

  EXPECT_FALSE((stan::is_matrix_cl<ref_type_t<decltype(a)>>::value));
  EXPECT_FALSE((stan::is_matrix_cl<ref_type_t<decltype(a)&>>::value));
  EXPECT_FALSE((stan::is_matrix_cl<ref_type_t<decltype(a)&&>>::value));
}

TEST(MathMetaPrim, ref_type_kg_heavy_expression) {
  using stan::ref_type_t;
  using stan::math::matrix_cl;
  Eigen::MatrixXd m_eig(3, 3);
  m_eig << 1, 2, 3, 4, 5, 6, 7, 8, 9;
  matrix_cl<double> m(m_eig);
  auto a = m * 3;
  ref_type_t<decltype(a)> a_ref1 = a;
  ref_type_t<decltype(a)&> a_ref2 = a;
  ref_type_t<decltype(a)&&> a_ref3 = m * 3;

  matrix_cl<double> a_eval = a;
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref1), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref2), from_matrix_cl(a_eval));
  EXPECT_MATRIX_EQ(from_matrix_cl(a_ref3), from_matrix_cl(a_eval));

  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)>>::value));
  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)&>>::value));
  EXPECT_TRUE((std::is_same<stan::math::matrix_cl<double>,
                            ref_type_t<decltype(a)&&>>::value));
}

#endif
<|endoftext|>