<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: cntnrsrt.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: hr $ $Date: 2006-06-19 20:12:38 $
 *
 *  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 _CNTRSRT_HXX
#define _CNTRSRT_HXX

#if 0
***********************************************************************
*
*   Hier folgt die Beschreibung fuer die exportierten Makros:
*
*       DECLARE_CONTAINER_SORT( ClassName, Type )
*       IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
*
*       Definiert eine von Container abgeleitete Klasse "ClassName",
*       in der die Elemente des Typs "Type" sortiert enthalten sind.
*       Dazu muss einer Funktion "SortFunc" definiert sein, die als
*       Paramter zwei "const Type&" erwartet und 0 zurueckgibt, wenn
*       beide gleich sind, -1 wenn der erste Paramter kleiner ist als
*       der zweite und +1 wenn der erste Paramter groesser ist als
*       der zweite.
*
*       Die Zugriffs-Methoden entsprechen in etwa denen der Container-
*       Klasse, mit Ausnahme von Insert, DeleteAndDestroy und Seek_Entry,
*       der den SV-Pointer-Arrays entsprechen.
*
*       DECLARE_CONTAINER_SORT_DEL( ClassName, Type )
*       IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
*
*       Wie DECLARE_CONTAINER_SORT, nur dass beim Aufruf des Destruktors
*       alle im Conatiner vorhandenen Objekte geloescht werden.
*
#endif

#ifndef _CONTNR_HXX //autogen
#include <tools/contnr.hxx>
#endif

#define DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                        \
    ClassName( const ClassName& );                                          \
    ClassName& operator =( const ClassName& );                              \
public:                                                                     \
    Container::Count;                                                       \
                                                                            \
    ClassName( USHORT  InitSize, USHORT  ReSize ) :                         \
        Container( CONTAINER_MAXBLOCKSIZE, InitSize, ReSize )   {}          \
                                                                            \
    BOOL Insert( Type* pObj );                                              \
                                                                               \
    Type *Remove( ULONG nPos )                                              \
        { return (Type *)Container::Remove( nPos ); }                       \
                                                                            \
    Type *Remove( Type* pObj );                                             \
                                                                               \
    void DeleteAndDestroy( ULONG nPos )                                     \
    {                                                                       \
        Type *pObj = Remove( nPos );                                        \
        if( pObj )                                                          \
            delete pObj;                                                    \
    }                                                                       \
                                                                               \
    void DeleteAndDestroy()                                                 \
        { while( Count() ) DeleteAndDestroy( 0 ); }                         \
                                                                            \
    Type* GetObject( ULONG nPos ) const                                     \
        { return (Type *)Container::GetObject( nPos ); }                    \
                                                                            \
    Type* operator[]( ULONG nPos ) const                                    \
        { return GetObject(nPos); }                                         \
                                                                            \
    BOOL Seek_Entry( const Type *pObj, ULONG* pPos ) const;                 \
                                                                            \
    ULONG GetPos( const Type* pObj ) const;                                 \

#define DECLARE_CONTAINER_SORT( ClassName, Type )                           \
class ClassName : private Container                                         \
{                                                                           \
    DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                        \
    ~ClassName() {}                                                         \
};                                                                          \

#define DECLARE_CONTAINER_SORT_DEL( ClassName, Type )                           \
class ClassName : private Container                                         \
{                                                                           \
    DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                            \
    ~ClassName() { DeleteAndDestroy(); }                                    \
};                                                                          \

#define IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )                    \
BOOL ClassName::Insert( Type *pObj )                                        \
{                                                                           \
    ULONG nPos;                                                             \
    BOOL bExist;                                                            \
    if( ! ( bExist = Seek_Entry( pObj, &nPos ) ) )                          \
        Container::Insert( pObj, nPos );                                    \
    return !bExist;                                                         \
}                                                                           \
                                                                            \
Type *ClassName::Remove( Type* pObj )                                       \
{                                                                           \
    ULONG nPos;                                                             \
    if( Seek_Entry( pObj, &nPos ) )                                         \
        return Remove( nPos );                                              \
    else                                                                    \
        return 0;                                                           \
}                                                                           \
                                                                            \
ULONG ClassName::GetPos( const Type* pObj ) const                           \
{                                                                           \
    ULONG nPos;                                                             \
    if( Seek_Entry( pObj, &nPos ) )                                         \
        return nPos;                                                        \
    else                                                                    \
        return CONTAINER_ENTRY_NOTFOUND;                                    \
}                                                                           \
                                                                            \
BOOL ClassName::Seek_Entry( const Type* pObj, ULONG* pPos ) const           \
{                                                                           \
    register ULONG nO  = Count(),                                           \
            nM,                                                             \
            nU = 0;                                                         \
    if( nO > 0 )                                                            \
    {                                                                       \
        nO--;                                                               \
        while( nU <= nO )                                                   \
        {                                                                   \
            nM = nU + ( nO - nU ) / 2;                                      \
            int nCmp = SortFunc( *GetObject(nM), *pObj );                   \
                                                                            \
            if( 0 == nCmp )                                                 \
            {                                                               \
                if( pPos ) *pPos = nM;                                      \
                return TRUE;                                                \
            }                                                               \
            else if( nCmp < 0 )                                             \
                nU = nM + 1;                                                \
            else if( nM == 0 )                                              \
            {                                                               \
                if( pPos ) *pPos = nU;                                      \
                return FALSE;                                               \
            }                                                               \
            else                                                            \
                nO = nM - 1;                                                \
        }                                                                   \
    }                                                                       \
    if( pPos ) *pPos = nU;                                                  \
    return FALSE;                                                           \
}                                                                           \

#endif
<commit_msg>INTEGRATION: CWS sb59 (1.3.64); FILE MERGED 2006/08/09 11:09:38 sb 1.3.64.2: #i67487 Made code warning-free (wntmsci10). 2006/08/09 08:13:11 sb 1.3.64.1: #i67487 Made code warning-free (wntmsci10).<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: cntnrsrt.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: obo $ $Date: 2006-10-12 15:03: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 _CNTRSRT_HXX
#define _CNTRSRT_HXX

#if 0
***********************************************************************
*
*   Hier folgt die Beschreibung fuer die exportierten Makros:
*
*       DECLARE_CONTAINER_SORT( ClassName, Type )
*       IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
*
*       Definiert eine von Container abgeleitete Klasse "ClassName",
*       in der die Elemente des Typs "Type" sortiert enthalten sind.
*       Dazu muss einer Funktion "SortFunc" definiert sein, die als
*       Paramter zwei "const Type&" erwartet und 0 zurueckgibt, wenn
*       beide gleich sind, -1 wenn der erste Paramter kleiner ist als
*       der zweite und +1 wenn der erste Paramter groesser ist als
*       der zweite.
*
*       Die Zugriffs-Methoden entsprechen in etwa denen der Container-
*       Klasse, mit Ausnahme von Insert, DeleteAndDestroy und Seek_Entry,
*       der den SV-Pointer-Arrays entsprechen.
*
*       DECLARE_CONTAINER_SORT_DEL( ClassName, Type )
*       IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )
*
*       Wie DECLARE_CONTAINER_SORT, nur dass beim Aufruf des Destruktors
*       alle im Conatiner vorhandenen Objekte geloescht werden.
*
#endif

#ifndef _CONTNR_HXX //autogen
#include <tools/contnr.hxx>
#endif

#define DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                        \
    ClassName( const ClassName& );                                          \
    ClassName& operator =( const ClassName& );                              \
public:                                                                     \
    using Container::Count;                                                 \
                                                                            \
    ClassName( USHORT  InitSize, USHORT  ReSize ) :                         \
        Container( CONTAINER_MAXBLOCKSIZE, InitSize, ReSize )   {}          \
                                                                            \
    BOOL Insert( Type* pObj );                                              \
                                                                               \
    Type *Remove( ULONG nPos )                                              \
        { return (Type *)Container::Remove( nPos ); }                       \
                                                                            \
    Type *Remove( Type* pObj );                                             \
                                                                               \
    void DeleteAndDestroy( ULONG nPos )                                     \
    {                                                                       \
        Type *pObj = Remove( nPos );                                        \
        if( pObj )                                                          \
            delete pObj;                                                    \
    }                                                                       \
                                                                               \
    void DeleteAndDestroy()                                                 \
        { while( Count() ) DeleteAndDestroy( 0 ); }                         \
                                                                            \
    Type* GetObject( ULONG nPos ) const                                     \
        { return (Type *)Container::GetObject( nPos ); }                    \
                                                                            \
    Type* operator[]( ULONG nPos ) const                                    \
        { return GetObject(nPos); }                                         \
                                                                            \
    BOOL Seek_Entry( const Type *pObj, ULONG* pPos ) const;                 \
                                                                            \
    ULONG GetPos( const Type* pObj ) const;                                 \

#define DECLARE_CONTAINER_SORT( ClassName, Type )                           \
class ClassName : private Container                                         \
{                                                                           \
    DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                        \
    ~ClassName() {}                                                         \
};                                                                          \

#define DECLARE_CONTAINER_SORT_DEL( ClassName, Type )                           \
class ClassName : private Container                                         \
{                                                                           \
    DECLARE_CONTAINER_SORT_COMMON( ClassName, Type )                            \
    ~ClassName() { DeleteAndDestroy(); }                                    \
};                                                                          \

#define IMPL_CONTAINER_SORT( ClassName, Type, SortFunc )                    \
BOOL ClassName::Insert( Type *pObj )                                        \
{                                                                           \
    ULONG nPos;                                                             \
    BOOL bExist = Seek_Entry( pObj, &nPos );                                \
    if( !bExist )                                                           \
        Container::Insert( pObj, nPos );                                    \
    return !bExist;                                                         \
}                                                                           \
                                                                            \
Type *ClassName::Remove( Type* pObj )                                       \
{                                                                           \
    ULONG nPos;                                                             \
    if( Seek_Entry( pObj, &nPos ) )                                         \
        return Remove( nPos );                                              \
    else                                                                    \
        return 0;                                                           \
}                                                                           \
                                                                            \
ULONG ClassName::GetPos( const Type* pObj ) const                           \
{                                                                           \
    ULONG nPos;                                                             \
    if( Seek_Entry( pObj, &nPos ) )                                         \
        return nPos;                                                        \
    else                                                                    \
        return CONTAINER_ENTRY_NOTFOUND;                                    \
}                                                                           \
                                                                            \
BOOL ClassName::Seek_Entry( const Type* pObj, ULONG* pPos ) const           \
{                                                                           \
    register ULONG nO  = Count(),                                           \
            nM,                                                             \
            nU = 0;                                                         \
    if( nO > 0 )                                                            \
    {                                                                       \
        nO--;                                                               \
        while( nU <= nO )                                                   \
        {                                                                   \
            nM = nU + ( nO - nU ) / 2;                                      \
            int nCmp = SortFunc( *GetObject(nM), *pObj );                   \
                                                                            \
            if( 0 == nCmp )                                                 \
            {                                                               \
                if( pPos ) *pPos = nM;                                      \
                return TRUE;                                                \
            }                                                               \
            else if( nCmp < 0 )                                             \
                nU = nM + 1;                                                \
            else if( nM == 0 )                                              \
            {                                                               \
                if( pPos ) *pPos = nU;                                      \
                return FALSE;                                               \
            }                                                               \
            else                                                            \
                nO = nM - 1;                                                \
        }                                                                   \
    }                                                                       \
    if( pPos ) *pPos = nU;                                                  \
    return FALSE;                                                           \
}                                                                           \

#endif
<|endoftext|>


<commit_before>// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <chainparams.h>
#include <key.h>
#include <script/descriptor.h>
#include <script/standard.h>
#include <test/fuzz/fuzz.h>

void initialize()
{
    SelectParams(CBaseChainParams::REGTEST);
}

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string descriptor(buffer.begin(), buffer.end());
    FlatSigningProvider signing_provider;
    std::string error;
    for (const bool require_checksum : {true, false}) {
        Parse(descriptor, signing_provider, error);
    }
}
<commit_msg>fuzz: fix 17018<commit_after>// Copyright (c) 2009-2019 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include <chainparams.h>
#include <key.h>
#include <script/descriptor.h>
#include <script/standard.h>
#include <test/fuzz/fuzz.h>

void initialize()
{
    SelectParams(CBaseChainParams::REGTEST);
}

void test_one_input(const std::vector<uint8_t>& buffer)
{
    const std::string descriptor(buffer.begin(), buffer.end());
    FlatSigningProvider signing_provider;
    std::string error;
    for (const bool require_checksum : {true, false}) {
        Parse(descriptor, signing_provider, error, require_checksum);
    }
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: filectrl.hxx,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 16:58:50 $
 *
 *  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 _SV_FILECTRL_HXX
#define _SV_FILECTRL_HXX

#ifndef _SV_WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _SV_EDIT_HXX
#include <vcl/edit.hxx>
#endif
#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
#endif

#define STR_FILECTRL_BUTTONTEXT     333     // ID-Range?!

// Flags for FileControl
typedef USHORT FileControlMode;
#define FILECTRL_RESIZEBUTTONBYPATHLEN  ((USHORT)0x0001)//if this is set, the button will become small as soon as the Text in the Edit Field is to long to be shown completely

// Flags for internal use of FileControl
typedef USHORT FileControlMode_Internal;
#define FILECTRL_INRESIZE               ((USHORT)0x0001)
#define FILECTRL_ORIGINALBUTTONTEXT     ((USHORT)0x0002)

class VclFileDialog;
class FileDialog;
class FileControl : public Window
{
private:
    Edit            maEdit;
    PushButton      maButton;

    String          maButtonText;
    BOOL            mbOpenDlg;

    VclFileDialog*  mpVclDlg;
    FileDialog*     mpFDlg;

    Link            maDialogCreatedHdl;

    FileControlMode             mnFlags;
    FileControlMode_Internal    mnInternalFlags;

protected:
    void            Resize();
    void            GetFocus();
    void            StateChanged( StateChangedType nType );
    WinBits         ImplInitStyle( WinBits nStyle );
    DECL_LINK(      ButtonHdl, PushButton* );

public:
                    FileControl( Window* pParent, WinBits nStyle, FileControlMode = 0 );
                    ~FileControl();

    Edit&           GetEdit() { return maEdit; }
    PushButton&     GetButton() { return maButton; }

    void            Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags );

    void            SetOpenDialog( BOOL bOpen )     { mbOpenDlg = bOpen; }
    BOOL            IsOpenDialog() const            { return mbOpenDlg; }

    void            SetText( const XubString& rStr );
    XubString       GetText() const;
    UniString           GetSelectedText() const         { return maEdit.GetSelected(); }

    void            SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); }
    Selection       GetSelection() const                        { return maEdit.GetSelection(); }

    void            SetReadOnly( BOOL bReadOnly = TRUE )    { maEdit.SetReadOnly( bReadOnly ); }
    BOOL            IsReadOnly() const                      { return maEdit.IsReadOnly(); }

    //------
    //manipulate the Button-Text:
    XubString       GetButtonText() const { return maButtonText; }
    void            SetButtonText( const XubString& rStr );
    void            ResetButtonText();

    //------
    //use this to manipulate the dialog bevore executing it:
    void            SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; }
    const Link&     GetDialogCreatedHdl() const { return maDialogCreatedHdl; }

        //only use the next two methods in 'DialogCreatedHdl' and don't store the dialog-pointer
    VclFileDialog*  GetVclFileDialog() const { return mpVclDlg; }
    FileDialog*     GetFileDialog() const { return mpFDlg; }
    //------
};

#endif

<commit_msg>#83847# ImplBrowseFile<commit_after>/*************************************************************************
 *
 *  $RCSfile: filectrl.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: fs $ $Date: 2001-09-04 08:57: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 _SV_FILECTRL_HXX
#define _SV_FILECTRL_HXX

#ifndef _SV_WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _SV_EDIT_HXX
#include <vcl/edit.hxx>
#endif
#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
#endif

#define STR_FILECTRL_BUTTONTEXT     333     // ID-Range?!

// Flags for FileControl
typedef USHORT FileControlMode;
#define FILECTRL_RESIZEBUTTONBYPATHLEN  ((USHORT)0x0001)//if this is set, the button will become small as soon as the Text in the Edit Field is to long to be shown completely

// Flags for internal use of FileControl
typedef USHORT FileControlMode_Internal;
#define FILECTRL_INRESIZE               ((USHORT)0x0001)
#define FILECTRL_ORIGINALBUTTONTEXT     ((USHORT)0x0002)

class VclFileDialog;
class FileDialog;
class FileControl : public Window
{
private:
    Edit            maEdit;
    PushButton      maButton;

    String          maButtonText;
    BOOL            mbOpenDlg;

    VclFileDialog*  mpVclDlg;
    FileDialog*     mpFDlg;

    Link            maDialogCreatedHdl;

    FileControlMode             mnFlags;
    FileControlMode_Internal    mnInternalFlags;

private:
    void            ImplBrowseFile( );

protected:
    void            Resize();
    void            GetFocus();
    void            StateChanged( StateChangedType nType );
    WinBits         ImplInitStyle( WinBits nStyle );
    DECL_LINK(      ButtonHdl, PushButton* );

public:
                    FileControl( Window* pParent, WinBits nStyle, FileControlMode = 0 );
                    ~FileControl();

    Edit&           GetEdit() { return maEdit; }
    PushButton&     GetButton() { return maButton; }

    void            Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize, ULONG nFlags );

    void            SetOpenDialog( BOOL bOpen )     { mbOpenDlg = bOpen; }
    BOOL            IsOpenDialog() const            { return mbOpenDlg; }

    void            SetText( const XubString& rStr );
    XubString       GetText() const;
    UniString           GetSelectedText() const         { return maEdit.GetSelected(); }

    void            SetSelection( const Selection& rSelection ) { maEdit.SetSelection( rSelection ); }
    Selection       GetSelection() const                        { return maEdit.GetSelection(); }

    void            SetReadOnly( BOOL bReadOnly = TRUE )    { maEdit.SetReadOnly( bReadOnly ); }
    BOOL            IsReadOnly() const                      { return maEdit.IsReadOnly(); }

    //------
    //manipulate the Button-Text:
    XubString       GetButtonText() const { return maButtonText; }
    void            SetButtonText( const XubString& rStr );
    void            ResetButtonText();

    //------
    //use this to manipulate the dialog bevore executing it:
    void            SetDialogCreatedHdl( const Link& rLink ) { maDialogCreatedHdl = rLink; }
    const Link&     GetDialogCreatedHdl() const { return maDialogCreatedHdl; }

        //only use the next two methods in 'DialogCreatedHdl' and don't store the dialog-pointer
    VclFileDialog*  GetVclFileDialog() const { return mpVclDlg; }
    FileDialog*     GetFileDialog() const { return mpFDlg; }
    //------
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: templdlg.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: os $ $Date: 2002-11-29 17:21:43 $
 *
 *  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 _SVTOOLS_TEMPLDLG_HXX
#define _SVTOOLS_TEMPLDLG_HXX

#include <vcl/button.hxx>
#include <vcl/dialog.hxx>
#include <vcl/fixed.hxx>

struct SvtTmplDlg_Impl;

// class SvtDocumentTemplateDialog ---------------------------------------

class SvtTemplateWindow;

class SvtDocumentTemplateDialog : public ModalDialog
{
private:
    FixedLine           aLine;
    PushButton          aManageBtn;
    PushButton          aEditBtn;
    OKButton            aOKBtn;
    CancelButton        aCancelBtn;
    HelpButton          aHelpBtn;

    SvtTmplDlg_Impl*    pImpl;

    DECL_LINK(          SelectHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          DoubleClickHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          NewFolderHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          SendFocusHdl_Impl, SvtTemplateWindow* );
    DECL_LINK(          OKHdl_Impl, PushButton* );
    DECL_LINK(          OrganizerHdl_Impl, PushButton* );
    DECL_LINK(          UpdateHdl_Impl, Timer* );

public:
    SvtDocumentTemplateDialog( Window* pParent );

    /** ctor for calling the dialog for selection only, not for opening a document

If you use this ctor, the dialog will behave differently in the following areas:

The Edit button will be hidden.

Upon pressing em>Open, the selected file will not be opened. Instead, it's
                URL is available (see <method>GetSelectedFileURL</method>).

    */
    struct SelectOnly { };
    SvtDocumentTemplateDialog( Window* _pParent, SelectOnly );

    ~SvtDocumentTemplateDialog();

    sal_Bool    IsFileSelected( ) const;
    String      GetSelectedFileURL( ) const;

    void        SelectTemplateFolder();

private:
    void InitImpl( );
};

#endif // _SVTOOLS_TEMPLDLG_HXX

<commit_msg>INTEGRATION: CWS visibility03 (1.11.900); FILE MERGED 2005/03/24 14:14:03 mhu 1.11.900.1: #i45006# Include svtools/(svl|svt)dllapi.h, declare symbol visibility with (SVL|SVT)_DLL(PUBLIC|PRIVATE) as appropriate; partial cleanup.<commit_after>/*************************************************************************
 *
 *  $RCSfile: templdlg.hxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: obo $ $Date: 2005-04-13 10:37:35 $
 *
 *  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 _SVTOOLS_TEMPLDLG_HXX
#define _SVTOOLS_TEMPLDLG_HXX

#ifndef INCLUDED_SVTDLLAPI_H
#include "svtools/svtdllapi.h"
#endif

#ifndef _SV_BUTTON_HXX
#include <vcl/button.hxx>
#endif
#ifndef _SV_DIALOG_HXX
#include <vcl/dialog.hxx>
#endif
#ifndef _SV_FIXED_HXX
#include <vcl/fixed.hxx>
#endif

struct SvtTmplDlg_Impl;

// class SvtDocumentTemplateDialog ---------------------------------------

class SvtTemplateWindow;

class SVT_DLLPUBLIC SvtDocumentTemplateDialog : public ModalDialog
{
private:
    FixedLine           aLine;
    PushButton          aManageBtn;
    PushButton          aEditBtn;
    OKButton            aOKBtn;
    CancelButton        aCancelBtn;
    HelpButton          aHelpBtn;

    SvtTmplDlg_Impl*    pImpl;

    DECL_DLLPRIVATE_LINK(           SelectHdl_Impl, SvtTemplateWindow* );
    DECL_DLLPRIVATE_LINK(           DoubleClickHdl_Impl, SvtTemplateWindow* );
    DECL_DLLPRIVATE_LINK(           NewFolderHdl_Impl, SvtTemplateWindow* );
    DECL_DLLPRIVATE_LINK(           SendFocusHdl_Impl, SvtTemplateWindow* );
    DECL_DLLPRIVATE_LINK(           OKHdl_Impl, PushButton* );
    DECL_DLLPRIVATE_LINK(           OrganizerHdl_Impl, PushButton* );
    DECL_DLLPRIVATE_LINK(           UpdateHdl_Impl, Timer* );

public:
    SvtDocumentTemplateDialog( Window* pParent );

    /** ctor for calling the dialog for selection only, not for opening a document

If you use this ctor, the dialog will behave differently in the following areas:

The Edit button will be hidden.

Upon pressing em>Open, the selected file will not be opened. Instead, it's
                URL is available (see <method>GetSelectedFileURL</method>).

    */
    struct SelectOnly { };
    SvtDocumentTemplateDialog( Window* _pParent, SelectOnly );

    ~SvtDocumentTemplateDialog();

    sal_Bool    IsFileSelected( ) const;
    String      GetSelectedFileURL( ) const;

    void        SelectTemplateFolder();

private:
    SVT_DLLPRIVATE void InitImpl( );
};

#endif // _SVTOOLS_TEMPLDLG_HXX

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: ifaceids.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: vg $ $Date: 2007-04-11 15:57:50 $
 *
 *  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 _SVX_IFACEIDS_HXX
#define _SVX_IFACEIDS_HXX

// -----------------------------------------------------------------------

#include <sfx2/shell.hxx>

#define SVX_INTERFACE_BASIDE_DOCSH      (SFX_INTERFACE_IDE_START+ 0)
#define SVX_INTERFACE_BASIDE_VIEWSH     (SFX_INTERFACE_IDE_START+ 1)
#define SVX_INTERFACE_EXTRUSION_BAR     (SFX_INTERFACE_IDE_START+ 2)
#define SVX_INTERFACE_FONTWORK_BAR      (SFX_INTERFACE_IDE_START+ 3)

#define HID_INTERFACE_BASIDE_VIEWSH     SVX_INTERFACE_BASIDE_VIEWSH

#define SVX_INTERFACE_FORM_SH           (SFX_INTERFACE_IDE_END+ 1)

#endif

<commit_msg>INTEGRATION: CWS changefileheader (1.2.466); FILE MERGED 2008/03/31 14:18:13 rt 1.2.466.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: ifaceids.hxx,v $
 * $Revision: 1.3 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/
#ifndef _SVX_IFACEIDS_HXX
#define _SVX_IFACEIDS_HXX

// -----------------------------------------------------------------------

#include <sfx2/shell.hxx>

#define SVX_INTERFACE_BASIDE_DOCSH      (SFX_INTERFACE_IDE_START+ 0)
#define SVX_INTERFACE_BASIDE_VIEWSH     (SFX_INTERFACE_IDE_START+ 1)
#define SVX_INTERFACE_EXTRUSION_BAR     (SFX_INTERFACE_IDE_START+ 2)
#define SVX_INTERFACE_FONTWORK_BAR      (SFX_INTERFACE_IDE_START+ 3)

#define HID_INTERFACE_BASIDE_VIEWSH     SVX_INTERFACE_BASIDE_VIEWSH

#define SVX_INTERFACE_FORM_SH           (SFX_INTERFACE_IDE_END+ 1)

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fmurl.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-08 23:21:31 $
 *
 *  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 _SVX_FMURL_HXX
#define _SVX_FMURL_HXX

#ifndef _FM_STATIC_HXX_
#include "fmstatic.hxx"
#endif

namespace svxform
{

    DECLARE_CONSTASCII_USTRING(FMURL_FORMSLOTS_PREFIX);

    DECLARE_CONSTASCII_USTRING(FMURL_FORM_POSITION);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_RECORDCOUNT);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVEFIRST);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVEPREV);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVENEXT);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVELAST);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVETONEW);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_UNDO);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_SAVE);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_DELETE);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_REFRESH);

    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT_UP);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT_DOWN);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_AUTO_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_APPLY_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_REMOVE_FILTER);

    DECLARE_CONSTASCII_USTRING(FMURL_CONFIRM_DELETION);

    DECLARE_CONSTASCII_USTRING(FMURL_COMPONENT_FORMGRIDVIEW);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_CLEARVIEW);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_ADDCOLUMN);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_ATTACHTOFORM);

    DECLARE_CONSTASCII_USTRING(FMARG_ATTACHTO_MASTERFORM);
    DECLARE_CONSTASCII_USTRING(FMARG_ADDCOL_COLUMNTYPE);
    DECLARE_CONSTASCII_USTRING(FMARG_ADDCOL_COLUMNPOS);

}   // namespace svxform

#endif // _SVX_FMURL_HXX

<commit_msg>INTEGRATION: CWS changefileheader (1.4.1254); FILE MERGED 2008/04/01 12:49:06 thb 1.4.1254.2: #i85898# Stripping all external header guards 2008/03/31 14:22:20 rt 1.4.1254.1: #i87441# Change license header to LPGL v3.<commit_after>/*************************************************************************
 *
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * Copyright 2008 by Sun Microsystems, Inc.
 *
 * OpenOffice.org - a multi-platform office productivity suite
 *
 * $RCSfile: fmurl.hxx,v $
 * $Revision: 1.5 $
 *
 * This file is part of OpenOffice.org.
 *
 * OpenOffice.org is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License version 3
 * only, as published by the Free Software Foundation.
 *
 * OpenOffice.org 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 version 3 for more details
 * (a copy is included in the LICENSE file that accompanied this code).
 *
 * You should have received a copy of the GNU Lesser General Public License
 * version 3 along with OpenOffice.org.  If not, see
 * <http://www.openoffice.org/license.html>
 * for a copy of the LGPLv3 License.
 *
 ************************************************************************/

#ifndef _SVX_FMURL_HXX
#define _SVX_FMURL_HXX

#include "fmstatic.hxx"

namespace svxform
{

    DECLARE_CONSTASCII_USTRING(FMURL_FORMSLOTS_PREFIX);

    DECLARE_CONSTASCII_USTRING(FMURL_FORM_POSITION);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_RECORDCOUNT);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVEFIRST);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVEPREV);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVENEXT);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVELAST);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_MOVETONEW);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_UNDO);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_SAVE);
    DECLARE_CONSTASCII_USTRING(FMURL_RECORD_DELETE);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_REFRESH);

    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT_UP);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT_DOWN);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_SORT);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_AUTO_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_APPLY_FILTER);
    DECLARE_CONSTASCII_USTRING(FMURL_FORM_REMOVE_FILTER);

    DECLARE_CONSTASCII_USTRING(FMURL_CONFIRM_DELETION);

    DECLARE_CONSTASCII_USTRING(FMURL_COMPONENT_FORMGRIDVIEW);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_CLEARVIEW);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_ADDCOLUMN);
    DECLARE_CONSTASCII_USTRING(FMURL_GRIDVIEW_ATTACHTOFORM);

    DECLARE_CONSTASCII_USTRING(FMARG_ATTACHTO_MASTERFORM);
    DECLARE_CONSTASCII_USTRING(FMARG_ADDCOL_COLUMNTYPE);
    DECLARE_CONSTASCII_USTRING(FMARG_ADDCOL_COLUMNPOS);

}   // namespace svxform

#endif // _SVX_FMURL_HXX

<|endoftext|>


<commit_before>/*
 *The MIT License (MIT)
 *
 * Copyright (c) <2016> <Stephan Gatzka>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE websocket_frame_tests

#include <boost/test/unit_test.hpp>
#include <endian.h>
#include <stdint.h>

#include "buffered_reader.h"
#include "http_connection.h"
#include "websocket.h"

#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif

static const uint8_t WS_HEADER_FIN = 0x80;
static const uint8_t WS_HEADER_MASK = 0x80;
static const uint8_t WS_OPCODE_CLOSE = 0x08;
static const uint8_t WS_OPCODE_TEXT = 0x01;

static uint8_t write_buffer[5000];
static uint8_t *write_buffer_ptr;

static uint8_t read_buffer[5000];
static uint8_t *read_buffer_ptr;
static size_t read_buffer_length;
static uint8_t readback_buffer[5000];
static uint8_t *readback_buffer_ptr;

static bool close_called;
static bool text_message_received_called;

static void ws_on_error(struct websocket *ws)
{
	(void)ws;
}

static int writev(void *this_ptr, struct buffered_socket_io_vector *io_vec, unsigned int count)
{
	(void)this_ptr;
	size_t complete_length = 0;

	for (unsigned int i = 0; i < count; i++) {
		::memcpy(write_buffer_ptr, io_vec[i].iov_base, io_vec[i].iov_len);
		write_buffer_ptr += io_vec[i].iov_len;
		complete_length += io_vec[i].iov_len;
	}
	return complete_length;
}

static int read_exactly(void *this_ptr, size_t num, read_handler handler, void *handler_context)
{
	(void)this_ptr;
	uint8_t *ptr = read_buffer_ptr;
	read_buffer_ptr += num;
	handler(handler_context, ptr, num);
	return 0;
}

static bool is_close_frame()
{
	const uint8_t *ptr = write_buffer;
	uint8_t header;
	::memcpy(&header, ptr, sizeof(header));
	if ((header & WS_HEADER_FIN) != WS_HEADER_FIN) {
		return false;
	}
	if ((header & WS_OPCODE_CLOSE) != WS_OPCODE_CLOSE) {
		return false;
	}
	ptr += sizeof(header);

	uint8_t length;
	::memcpy(&length, ptr, sizeof(length));
	if ((length & WS_HEADER_MASK) == WS_HEADER_MASK) {
		return false;
	}
	if (length != 2) {
		return false;
	}
	ptr += sizeof(length);

	uint16_t status_code;
	::memcpy(&status_code, ptr, sizeof(status_code));
	status_code = be16toh(status_code);
	if (status_code != 1001) {
		return false;
	}
	return true;
}

static int close(void *this_ptr)
{
	(void)this_ptr;
	close_called = true;
	return 0;
}

static enum websocket_callback_return text_message_received(struct websocket *s, char *msg, size_t length)
{
	(void)s;
	(void)msg;
	(void)length;
	::strncpy((char *)readback_buffer, msg, length);
	text_message_received_called = true;
	return WS_OK;
}

static void fill_payload(uint8_t *ptr, const uint8_t *payload, uint64_t length, bool shall_mask, uint8_t mask[4])
{
	if (!shall_mask) {
		::memcpy(ptr, payload, length);
	} else {
		for (uint64_t i = 0; i < length; i++) {
			uint8_t byte = payload[i] ^ mask[i % 4];
			*ptr = byte;
			ptr++;
		}
	}
}

static void prepare_text_message(const char *message, bool shall_mask, uint8_t mask[4])
{
	uint8_t *ptr = read_buffer;
	read_buffer_length = 0;
	uint8_t header = 0x00;
	header |= WS_HEADER_FIN;
	header |= WS_OPCODE_TEXT;
	::memcpy(ptr, &header, sizeof(header));
	ptr += sizeof(header);
	read_buffer_length += sizeof(header);

	uint8_t first_length = 0x00;
	if (shall_mask) {
		first_length |= WS_HEADER_MASK;
	}
	uint64_t length = ::strlen(message);
	if (length < 126) {
		first_length = first_length | (uint8_t)length;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
	} else if (length <= sizeof(uint16_t)) {
		first_length = first_length | 126;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
		uint16_t len = (uint16_t)length;
		len = htobe16(len);
		::memcpy(ptr, &len, sizeof(len));
		ptr += sizeof(len);
		read_buffer_length += sizeof(len);
	} else {
		first_length = first_length | 127;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
		length = htobe64(length);
		::memcpy(ptr, &length, sizeof(length));
		ptr += sizeof(length);
		read_buffer_length += sizeof(length);
	}

	if (shall_mask) {
		::memcpy(ptr, mask, 4);
		ptr += 4;
	}

	fill_payload(ptr, (const uint8_t *)message, length, shall_mask, mask);
	read_buffer_length += length;
}

struct F {

	F()
	{
		close_called = false;
		text_message_received_called = false;
		write_buffer_ptr = write_buffer;
		read_buffer_ptr = read_buffer;
		readback_buffer_ptr = readback_buffer;

		struct http_connection *connection = alloc_http_connection();
		connection->br.writev = writev;
		connection->br.read_exactly = read_exactly;
		connection->br.close = close;
		websocket_init(&ws, connection, true, ws_on_error, "jet");
		ws.upgrade_complete = true;
		ws.text_message_received = text_message_received;
	}

	~F()
	{
	}

	struct websocket ws;
};

BOOST_FIXTURE_TEST_CASE(test_close_frame_on_websocket_free, F)
{
	websocket_free(&ws);
	BOOST_CHECK_MESSAGE(is_close_frame(), "No close frame sent when freeing the websocket!");
}

BOOST_FIXTURE_TEST_CASE(test_receive_text_frame, F)
{
	static const char *message = "Hello World!";
	uint8_t mask[4] = {0xaa, 0x55, 0xcc, 0x11};
	prepare_text_message(message, true, mask);
	ws_get_header(&ws, read_buffer_ptr++, read_buffer_length);
	websocket_free(&ws);
	BOOST_CHECK_MESSAGE(text_message_received_called, "Callback for text messages was not called!");
	BOOST_CHECK_MESSAGE(::strcmp(message, (char *)readback_buffer) == 0, "Did not received the same message as sent!");
}
<commit_msg>Initialize fixture with information if websocket is server.<commit_after>/*
 *The MIT License (MIT)
 *
 * Copyright (c) <2016> <Stephan Gatzka>
 *
 * Permission is hereby granted, free of charge, to any person obtaining
 * a copy of this software and associated documentation files (the
 * "Software"), to deal in the Software without restriction, including
 * without limitation the rights to use, copy, modify, merge, publish,
 * distribute, sublicense, and/or sell copies of the Software, and to
 * permit persons to whom the Software is furnished to do so, subject to
 * the following conditions:
 *
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */

#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MAIN
#define BOOST_TEST_MODULE websocket_frame_tests

#include <boost/test/unit_test.hpp>
#include <endian.h>
#include <stdint.h>

#include "buffered_reader.h"
#include "http_connection.h"
#include "websocket.h"

#ifndef ARRAY_SIZE
 #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
#endif

static const uint8_t WS_HEADER_FIN = 0x80;
static const uint8_t WS_HEADER_MASK = 0x80;
static const uint8_t WS_OPCODE_CLOSE = 0x08;
static const uint8_t WS_OPCODE_TEXT = 0x01;

static uint8_t write_buffer[5000];
static uint8_t *write_buffer_ptr;

static uint8_t read_buffer[5000];
static uint8_t *read_buffer_ptr;
static size_t read_buffer_length;
static uint8_t readback_buffer[5000];
static uint8_t *readback_buffer_ptr;

static bool close_called;
static bool text_message_received_called;

static void ws_on_error(struct websocket *ws)
{
	(void)ws;
}

static int writev(void *this_ptr, struct buffered_socket_io_vector *io_vec, unsigned int count)
{
	(void)this_ptr;
	size_t complete_length = 0;

	for (unsigned int i = 0; i < count; i++) {
		::memcpy(write_buffer_ptr, io_vec[i].iov_base, io_vec[i].iov_len);
		write_buffer_ptr += io_vec[i].iov_len;
		complete_length += io_vec[i].iov_len;
	}
	return complete_length;
}

static int read_exactly(void *this_ptr, size_t num, read_handler handler, void *handler_context)
{
	(void)this_ptr;
	uint8_t *ptr = read_buffer_ptr;
	read_buffer_ptr += num;
	handler(handler_context, ptr, num);
	return 0;
}

static bool is_close_frame()
{
	const uint8_t *ptr = write_buffer;
	uint8_t header;
	::memcpy(&header, ptr, sizeof(header));
	if ((header & WS_HEADER_FIN) != WS_HEADER_FIN) {
		return false;
	}
	if ((header & WS_OPCODE_CLOSE) != WS_OPCODE_CLOSE) {
		return false;
	}
	ptr += sizeof(header);

	uint8_t length;
	::memcpy(&length, ptr, sizeof(length));
	if ((length & WS_HEADER_MASK) == WS_HEADER_MASK) {
		return false;
	}
	if (length != 2) {
		return false;
	}
	ptr += sizeof(length);

	uint16_t status_code;
	::memcpy(&status_code, ptr, sizeof(status_code));
	status_code = be16toh(status_code);
	if (status_code != 1001) {
		return false;
	}
	return true;
}

static int close(void *this_ptr)
{
	(void)this_ptr;
	close_called = true;
	return 0;
}

static enum websocket_callback_return text_message_received(struct websocket *s, char *msg, size_t length)
{
	(void)s;
	(void)msg;
	(void)length;
	::strncpy((char *)readback_buffer, msg, length);
	text_message_received_called = true;
	return WS_OK;
}

static void fill_payload(uint8_t *ptr, const uint8_t *payload, uint64_t length, bool shall_mask, uint8_t mask[4])
{
	if (!shall_mask) {
		::memcpy(ptr, payload, length);
	} else {
		for (uint64_t i = 0; i < length; i++) {
			uint8_t byte = payload[i] ^ mask[i % 4];
			*ptr = byte;
			ptr++;
		}
	}
}

static void prepare_text_message(const char *message, bool shall_mask, uint8_t mask[4])
{
	uint8_t *ptr = read_buffer;
	read_buffer_length = 0;
	uint8_t header = 0x00;
	header |= WS_HEADER_FIN;
	header |= WS_OPCODE_TEXT;
	::memcpy(ptr, &header, sizeof(header));
	ptr += sizeof(header);
	read_buffer_length += sizeof(header);

	uint8_t first_length = 0x00;
	if (shall_mask) {
		first_length |= WS_HEADER_MASK;
	}
	uint64_t length = ::strlen(message);
	if (length < 126) {
		first_length = first_length | (uint8_t)length;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
	} else if (length <= sizeof(uint16_t)) {
		first_length = first_length | 126;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
		uint16_t len = (uint16_t)length;
		len = htobe16(len);
		::memcpy(ptr, &len, sizeof(len));
		ptr += sizeof(len);
		read_buffer_length += sizeof(len);
	} else {
		first_length = first_length | 127;
		::memcpy(ptr, &first_length, sizeof(first_length));
		ptr += sizeof(first_length);
		read_buffer_length += sizeof(first_length);
		length = htobe64(length);
		::memcpy(ptr, &length, sizeof(length));
		ptr += sizeof(length);
		read_buffer_length += sizeof(length);
	}

	if (shall_mask) {
		::memcpy(ptr, mask, 4);
		ptr += 4;
	}

	fill_payload(ptr, (const uint8_t *)message, length, shall_mask, mask);
	read_buffer_length += length;
}

struct F {

	F(bool is_server)
	{
		close_called = false;
		text_message_received_called = false;
		write_buffer_ptr = write_buffer;
		read_buffer_ptr = read_buffer;
		readback_buffer_ptr = readback_buffer;

		struct http_connection *connection = alloc_http_connection();
		connection->br.writev = writev;
		connection->br.read_exactly = read_exactly;
		connection->br.close = close;
		websocket_init(&ws, connection, is_server, ws_on_error, "jet");
		ws.upgrade_complete = true;
		ws.text_message_received = text_message_received;
	}

	~F()
	{
	}

	struct websocket ws;
};

BOOST_AUTO_TEST_CASE(test_close_frame_on_websocket_free)
{
	bool is_server = true;
	F f(is_server);

	websocket_free(&f.ws);
	BOOST_CHECK_MESSAGE(is_close_frame(), "No close frame sent when freeing the websocket!");
}

BOOST_AUTO_TEST_CASE(test_receive_text_frame)
{
	bool is_server = true;
	F f(is_server);

	static const char *message = "Hello World!";
	uint8_t mask[4] = {0xaa, 0x55, 0xcc, 0x11};
	prepare_text_message(message, is_server, mask);
	ws_get_header(&f.ws, read_buffer_ptr++, read_buffer_length);
	websocket_free(&f.ws);
	BOOST_CHECK_MESSAGE(text_message_received_called, "Callback for text messages was not called!");
	BOOST_CHECK_MESSAGE(::strcmp(message, (char *)readback_buffer) == 0, "Did not received the same message as sent!");
}
<|endoftext|>


<commit_before>/*
 * Sensitive.cpp
 *
 *  Created on: 25/lug/2011
 *      Author: Massi
 */

#include <iostream>
#include <cstdio>

#include <Renal/NextCalculator.h>
#include <Renal/NextException.h>
#include <Renal/LaGrangeCalculator.h>

int main()
{
	Renal::NextCalculator *generic_calculator = new Renal::LaGrangeCalculator();

	generic_calculator->InsertCoords(1., 2.);
	generic_calculator->InsertCoords(2., 3.);
	generic_calculator->InsertCoords(3., 4.);

	try {
		if (generic_calculator->BuildFunction()) {
			std::vector<double> polynom = generic_calculator->GetPolynom();

			printf("\t\tf(x) = ");
			for (std::vector<double>::iterator ite = polynom.begin(); ite != polynom.end(); ++ite)
				printf("%1.f ", *ite);
			printf("\n\n\n\n"); /* 0 1 1 = x + 1 */
		}
	}

	catch (Renal::NextException &e) {
		e.PrintMessage();
	}

	generic_calculator->Clear();

	generic_calculator->InsertCoords(1., 7.);
	generic_calculator->InsertCoords(3., 31.);
	generic_calculator->InsertCoords(5., 71.);

	try {
		if (generic_calculator->BuildFunction()) {
			std::vector<double> polynom = generic_calculator->GetPolynom();

			printf("\t\tf(x) = ");
			for (std::vector<double>::iterator ite = polynom.begin(); ite != polynom.end(); ++ite)
				printf("%1.f ", *ite);
			printf("\n\n\n\n"); /* 2 4 1 = 2x^2 + 4x + 1 */
		}
	}

	catch (Renal::NextException &e) {
		e.PrintMessage();
	}

	generic_calculator->Clear();

	generic_calculator->InsertCoords(2., 1.);
	generic_calculator->InsertCoords(4., 2.);
	generic_calculator->InsertCoords(6., 3.);

	try {
		if (generic_calculator->BuildFunction()) {
			std::vector<double> polynom = generic_calculator->GetPolynom();

			printf("\t\tf(x) = ");
			for (std::vector<double>::iterator ite = polynom.begin(); ite != polynom.end(); ++ite)
				printf("%1.2f ", *ite);
			printf("\n\n\n\n"); /* 0 0.5 0 = x/2 */
		}
	}

	catch (Renal::NextException &e) {
		e.PrintMessage();
	}

	delete(generic_calculator);

	return 0;
}
<commit_msg>Better testing unit<commit_after>/*
 * Sensitive.cpp
 *
 *  Created on: 25/lug/2011
 *      Author: Massi
 */

#include <iostream>
#include <cstdio>

#include <Renal/NextCalculator.h>
#include <Renal/NextException.h>
#include <Renal/LaGrangeCalculator.h>

Renal::NextCalculator *generic_calculator;

void TestWithCoords(std::pair<double, double> pair1, std::pair<double, double> pair2, std::pair<double, double> pair3)
{
	generic_calculator->Clear();

	generic_calculator->InsertCoords(pair1);
	generic_calculator->InsertCoords(pair2);
	generic_calculator->InsertCoords(pair3);

	try {
		if (generic_calculator->BuildFunction()) {
			std::vector<double> polynom = generic_calculator->GetPolynom();

			printf("\t\tf(x) = ");
			for (std::vector<double>::iterator ite = polynom.begin(); ite != polynom.end(); ++ite)
				printf("%.2f ", *ite);
			printf("\n\n\n\n"); /* 0 1 1 = x + 1 */
		}
	}

	catch (Renal::NextException &e) {
		e.PrintMessage();
	}

}

int main()
{
	generic_calculator = new Renal::LaGrangeCalculator();

	TestWithCoords(std::pair<double, double> (1., 2.), std::pair<double, double> (2., 3.), std::pair<double, double> (3., 4.)); /* 0 1 1 = x + 1 */
	TestWithCoords(std::pair<double, double> (1., 7.), std::pair<double, double> (3., 31.), std::pair<double, double> (5., 71.)); /* 2 4 1 = 2x^2 + 4x + 1 */
	TestWithCoords(std::pair<double, double> (2., 1.), std::pair<double, double> (4., 2.), std::pair<double, double> (8., 4.)); /* 0 0.05 0 = x/2 */
	TestWithCoords(std::pair<double, double> (1., 3.), std::pair<double, double> (2., 7.), std::pair<double, double> (3., 13.)); /* 1 1 1 = x^2 + x + 1 */
	TestWithCoords(std::pair<double, double> (1., 30.), std::pair<double, double> (3., 296.), std::pair<double, double> (4., 525.)); /* 32 5 -7 = 32x^2 + 5x - 7 */

	delete(generic_calculator);

	return 0;
}
<|endoftext|>


<commit_before>// This file is part of the dune-gdt project:
//   http://users.dune-project.org/projects/dune-gdt
// Copyright holders: Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH
#define DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH

#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>

#if HAVE_DUNE_PDELAB
#include <dune/pdelab/gridfunctionspace/localfunctionspace.hh>
#endif

#include <dune/stuff/common/type_utils.hh>

#include "interface.hh"

namespace Dune {
namespace GDT {
namespace BaseFunctionSet {

#if HAVE_DUNE_PDELAB

// forwards, to be used in the traits and to allow for specialization
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PdelabWrapper
{
  static_assert(Dune::AlwaysFalse<PdelabSpaceImp>::value, "Untested for arbitrary dimension!");
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PiolaTransformedPdelabWrapper
{
  static_assert(Dune::AlwaysFalse<PdelabSpaceImp>::value, "Untested for these dimensions!");
};

namespace internal {

// forward, to allow for specialization
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols>
class PdelabWrapperTraits;

//! Specialization for dimRange = 1, dimRangeRows = 1
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp>
class PdelabWrapperTraits<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
{
public:
  typedef PdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1> derived_type;

private:
  typedef PDELab::LocalFunctionSpace<PdelabSpaceImp, PDELab::TrialSpaceTag> PdelabLFSType;
  typedef FiniteElementInterfaceSwitch<typename PdelabSpaceImp::Traits::FiniteElementType> FESwitchType;

public:
  typedef typename FESwitchType::Basis BackendType;
  typedef EntityImp EntityType;

private:
  friend class PdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>;
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class PiolaTransformedPdelabWrapperTraits
{
  static_assert(domainDim == rangeDim, "Untested!");

public:
  typedef PiolaTransformedPdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim>
      derived_type;

private:
  typedef PDELab::LocalFunctionSpace<PdelabSpaceImp, PDELab::TrialSpaceTag> PdelabLFSType;
  typedef FiniteElementInterfaceSwitch<typename PdelabSpaceImp::Traits::FiniteElementType> FESwitchType;

public:
  typedef typename FESwitchType::Basis BackendType;
  typedef EntityImp EntityType;

private:
  friend class PiolaTransformedPdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp,
                                             rangeDim, 1>;
};

} // namespace internal

//! Specialization for dimRange = 1, dimRangeRows = 1
template <class PdelabSpaceType, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp>
class PdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
    : public BaseFunctionSetInterface<internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp,
                                                                    domainDim, RangeFieldImp, 1, 1>,
                                      DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
{
  typedef PdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1> ThisType;
  typedef BaseFunctionSetInterface<internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim,
                                                                 RangeFieldImp, 1, 1>,
                                   DomainFieldImp, domainDim, RangeFieldImp, 1, 1> BaseType;

public:
  typedef internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
      Traits;
  typedef typename Traits::BackendType BackendType;
  typedef typename Traits::EntityType EntityType;

private:
  typedef typename Traits::PdelabLFSType PdelabLFSType;
  typedef typename Traits::FESwitchType FESwitchType;

public:
  typedef Dune::FieldVector<DomainFieldType, dimDomain> DomainType;
  typedef Dune::FieldVector<RangeFieldType, dimRange> RangeType;
  typedef Dune::FieldMatrix<RangeFieldType, dimRange, dimDomain> JacobianRangeType;

  PdelabWrapper(const PdelabSpaceType& space, const EntityType& ent)
    : BaseType(ent)
    , tmp_domain_(0)
  {
    PdelabLFSType* lfs_ptr = new PdelabLFSType(space);
    lfs_ptr->bind(this->entity());
    lfs_     = std::unique_ptr<PdelabLFSType>(lfs_ptr);
    backend_ = std::unique_ptr<BackendType>(new BackendType(FESwitchType::basis(lfs_->finiteElement())));
  } // PdelabWrapper(...)

  PdelabWrapper(ThisType&& source) = default;
  PdelabWrapper(const ThisType& /*other*/) = delete;

  ThisType& operator=(const ThisType& /*other*/) = delete;

  const BackendType& backend() const
  {
    return *backend_;
  }

  virtual size_t size() const override final
  {
    return backend_->size();
  }

  virtual size_t order() const override final
  {
    return backend_->order();
  }

  virtual void evaluate(const DomainType& xx, std::vector<RangeType>& ret) const override final
  {
    assert(ret.size() >= backend_->size());
    backend_->evaluateFunction(xx, ret);
  } // ... evaluate(...)

  using BaseType::evaluate;

  virtual void jacobian(const DomainType& xx, std::vector<JacobianRangeType>& ret) const override final
  {
    assert(ret.size() >= backend_->size());
    backend_->evaluateJacobian(xx, ret);
    const auto jacobian_inverse_transposed = this->entity().geometry().jacobianInverseTransposed(xx);
    for (size_t ii = 0; ii < ret.size(); ++ii) {
      jacobian_inverse_transposed.mv(ret[ii][0], tmp_domain_);
      ret[ii][0] = tmp_domain_;
    }
  } // ... jacobian(...)

  using BaseType::jacobian;

private:
  mutable DomainType tmp_domain_;
  std::unique_ptr<const PdelabLFSType> lfs_;
  std::unique_ptr<const BackendType> backend_;
}; // class PdelabWrapper

template <class PdelabSpaceType, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp,
          int rangeDim>
class PiolaTransformedPdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1>
    : public BaseFunctionSetInterface<internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp,
                                                                                DomainFieldImp, domainDim,
                                                                                RangeFieldImp, rangeDim>,
                                      DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1>
{
  typedef PiolaTransformedPdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim,
                                        1> ThisType;
  typedef BaseFunctionSetInterface<internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp,
                                                                                DomainFieldImp, domainDim,
                                                                                RangeFieldImp, rangeDim>,
                                   DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1> BaseType;

public:
  typedef internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim,
                                                        RangeFieldImp, rangeDim> Traits;
  typedef typename Traits::BackendType BackendType;
  typedef typename Traits::EntityType EntityType;

private:
  typedef typename Traits::PdelabLFSType PdelabLFSType;
  typedef typename Traits::FESwitchType FESwitchType;

public:
  using typename BaseType::DomainFieldType;
  using BaseType::dimDomain;
  using typename BaseType::DomainType;
  using typename BaseType::RangeType;
  using typename BaseType::JacobianRangeType;

  PiolaTransformedPdelabWrapper(const PdelabSpaceType& space, const EntityType& ent)
    : BaseType(ent)
    , tmp_domain_(DomainFieldType(0))
    , tmp_jacobian_transposed_(DomainFieldType(0))
    , tmp_jacobian_inverse_transposed_(DomainFieldType(0))
  {
    PdelabLFSType* lfs_ptr = new PdelabLFSType(space);
    lfs_ptr->bind(this->entity());
    lfs_                 = std::unique_ptr<PdelabLFSType>(lfs_ptr);
    backend_             = std::unique_ptr<BackendType>(new BackendType(FESwitchType::basis(lfs_->finiteElement())));
    tmp_ranges_          = std::vector<RangeType>(backend_->size(), RangeType(0));
    tmp_jacobian_ranges_ = std::vector<JacobianRangeType>(backend_->size(), JacobianRangeType(0));
  } // PdelabWrapper(...)

  PiolaTransformedPdelabWrapper(ThisType&& source) = default;

  PiolaTransformedPdelabWrapper(const ThisType& /*other*/) = delete;

  ThisType& operator=(const ThisType& /*other*/) = delete;

  const BackendType& backend() const
  {
    return *backend_;
  }

  virtual size_t size() const override final
  {
    return backend_->size();
  }

  virtual size_t order() const override final
  {
    return backend_->order();
  }

  virtual void evaluate(const DomainType& xx, std::vector<RangeType>& ret) const override final
  {
    assert(lfs_);
    assert(backend_);
    assert(tmp_ranges_.size() >= backend_->size());
    assert(ret.size() >= backend_->size());
    backend_->evaluateFunction(xx, tmp_ranges_);
    const auto geometry                       = this->entity().geometry();
    tmp_jacobian_transposed_                  = geometry.jacobianTransposed(xx);
    const DomainFieldType integration_element = geometry.integrationElement(xx);
    for (size_t ii = 0; ii < backend_->size(); ++ii) {
      tmp_jacobian_transposed_.mtv(tmp_ranges_[ii], ret[ii]);
      ret[ii] /= integration_element;
    }
  } // ... evaluate(...)

  using BaseType::evaluate;

  virtual void jacobian(const DomainType& xx, std::vector<JacobianRangeType>& ret) const override final
  {
    assert(lfs_);
    assert(backend_);
    assert(ret.size() >= backend_->size());
    backend_->evaluateJacobian(xx, tmp_jacobian_ranges_);
    const auto geometry                       = this->entity().geometry();
    tmp_jacobian_transposed_                  = geometry.jacobianTransposed(xx);
    tmp_jacobian_inverse_transposed_          = geometry.jacobianInverseTransposed(xx);
    const DomainFieldType integration_element = geometry.integrationElement(xx);
    for (size_t ii = 0; ii < backend_->size(); ++ii) {
      for (size_t jj = 0; jj < dimDomain; ++jj) {
        tmp_jacobian_inverse_transposed_.mv(tmp_jacobian_ranges_[ii][jj], ret[ii][jj]);
        tmp_jacobian_transposed_.mv(ret[ii][jj], tmp_jacobian_ranges_[ii][jj]);
        tmp_jacobian_ranges_[ii][jj] /= integration_element;
        ret[ii][jj] = tmp_jacobian_ranges_[ii][jj];
      }
    }
  } // ... jacobian(...)

  using BaseType::jacobian;

private:
  mutable DomainType tmp_domain_;
  mutable typename EntityType::Geometry::JacobianTransposed tmp_jacobian_transposed_;
  mutable typename EntityType::Geometry::JacobianInverseTransposed tmp_jacobian_inverse_transposed_;
  std::unique_ptr<const PdelabLFSType> lfs_;
  std::unique_ptr<const BackendType> backend_;
  mutable std::vector<RangeType> tmp_ranges_;
  mutable std::vector<JacobianRangeType> tmp_jacobian_ranges_;
}; // class PiolaTransformedPdelabWrapper

#else // HAVE_DUNE_PDELAB

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PdelabWrapper
{
  static_assert(AlwaysFalse<PdelabSpaceImp>::value, "You are missing dune-pdelab!");
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PiolaTransformedPdelabWrapper
{
  static_assert(AlwaysFalse<PdelabSpaceImp>::value, "You are missing dune-pdelab!");
};

#endif // HAVE_DUNE_PDELAB

} // namespace BaseFunctionSet
} // namespace GDT
} // namespace Dune

#endif // DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH
<commit_msg>[basefunctionset.pdelab] use correct types from base<commit_after>// This file is part of the dune-gdt project:
//   http://users.dune-project.org/projects/dune-gdt
// Copyright holders: Felix Schindler
// License: BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)

#ifndef DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH
#define DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH

#include <dune/common/fmatrix.hh>
#include <dune/common/fvector.hh>

#if HAVE_DUNE_PDELAB
#include <dune/pdelab/gridfunctionspace/localfunctionspace.hh>
#endif

#include <dune/stuff/common/type_utils.hh>

#include "interface.hh"

namespace Dune {
namespace GDT {
namespace BaseFunctionSet {

#if HAVE_DUNE_PDELAB

// forwards, to be used in the traits and to allow for specialization
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PdelabWrapper
{
  static_assert(Dune::AlwaysFalse<PdelabSpaceImp>::value, "Untested for arbitrary dimension!");
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PiolaTransformedPdelabWrapper
{
  static_assert(Dune::AlwaysFalse<PdelabSpaceImp>::value, "Untested for these dimensions!");
};

namespace internal {

// forward, to allow for specialization
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols>
class PdelabWrapperTraits;

//! Specialization for dimRange = 1, dimRangeRows = 1
template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp>
class PdelabWrapperTraits<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
{
public:
  typedef PdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1> derived_type;

private:
  typedef PDELab::LocalFunctionSpace<PdelabSpaceImp, PDELab::TrialSpaceTag> PdelabLFSType;
  typedef FiniteElementInterfaceSwitch<typename PdelabSpaceImp::Traits::FiniteElementType> FESwitchType;

public:
  typedef typename FESwitchType::Basis BackendType;
  typedef EntityImp EntityType;

private:
  friend class PdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>;
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim>
class PiolaTransformedPdelabWrapperTraits
{
  static_assert(domainDim == rangeDim, "Untested!");

public:
  typedef PiolaTransformedPdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim>
      derived_type;

private:
  typedef PDELab::LocalFunctionSpace<PdelabSpaceImp, PDELab::TrialSpaceTag> PdelabLFSType;
  typedef FiniteElementInterfaceSwitch<typename PdelabSpaceImp::Traits::FiniteElementType> FESwitchType;

public:
  typedef typename FESwitchType::Basis BackendType;
  typedef EntityImp EntityType;

private:
  friend class PiolaTransformedPdelabWrapper<PdelabSpaceImp, EntityImp, DomainFieldImp, domainDim, RangeFieldImp,
                                             rangeDim, 1>;
};

} // namespace internal

//! Specialization for dimRange = 1, dimRangeRows = 1
template <class PdelabSpaceType, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp>
class PdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
    : public BaseFunctionSetInterface<internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp,
                                                                    domainDim, RangeFieldImp, 1, 1>,
                                      DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
{
  typedef PdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1> ThisType;
  typedef BaseFunctionSetInterface<internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim,
                                                                 RangeFieldImp, 1, 1>,
                                   DomainFieldImp, domainDim, RangeFieldImp, 1, 1> BaseType;

public:
  typedef internal::PdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, 1, 1>
      Traits;
  typedef typename Traits::BackendType BackendType;
  typedef typename Traits::EntityType EntityType;

private:
  typedef typename Traits::PdelabLFSType PdelabLFSType;
  typedef typename Traits::FESwitchType FESwitchType;

public:
  typedef typename BaseType::DomainType DomainType;
  typedef typename BaseType::RangeType RangeType;
  typedef typename BaseType::JacobianRangeType JacobianRangeType;

  PdelabWrapper(const PdelabSpaceType& space, const EntityType& ent)
    : BaseType(ent)
    , tmp_domain_(0)
  {
    PdelabLFSType* lfs_ptr = new PdelabLFSType(space);
    lfs_ptr->bind(this->entity());
    lfs_     = std::unique_ptr<PdelabLFSType>(lfs_ptr);
    backend_ = std::unique_ptr<BackendType>(new BackendType(FESwitchType::basis(lfs_->finiteElement())));
  } // PdelabWrapper(...)

  PdelabWrapper(ThisType&& source) = default;
  PdelabWrapper(const ThisType& /*other*/) = delete;

  ThisType& operator=(const ThisType& /*other*/) = delete;

  const BackendType& backend() const
  {
    return *backend_;
  }

  virtual size_t size() const override final
  {
    return backend_->size();
  }

  virtual size_t order() const override final
  {
    return backend_->order();
  }

  virtual void evaluate(const DomainType& xx, std::vector<RangeType>& ret) const override final
  {
    assert(ret.size() >= backend_->size());
    backend_->evaluateFunction(xx, ret);
  } // ... evaluate(...)

  using BaseType::evaluate;

  virtual void jacobian(const DomainType& xx, std::vector<JacobianRangeType>& ret) const override final
  {
    assert(ret.size() >= backend_->size());
    backend_->evaluateJacobian(xx, ret);
    const auto jacobian_inverse_transposed = this->entity().geometry().jacobianInverseTransposed(xx);
    for (size_t ii = 0; ii < ret.size(); ++ii) {
      jacobian_inverse_transposed.mv(ret[ii][0], tmp_domain_);
      ret[ii][0] = tmp_domain_;
    }
  } // ... jacobian(...)

  using BaseType::jacobian;

private:
  mutable DomainType tmp_domain_;
  std::unique_ptr<const PdelabLFSType> lfs_;
  std::unique_ptr<const BackendType> backend_;
}; // class PdelabWrapper

template <class PdelabSpaceType, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp,
          int rangeDim>
class PiolaTransformedPdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1>
    : public BaseFunctionSetInterface<internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp,
                                                                                DomainFieldImp, domainDim,
                                                                                RangeFieldImp, rangeDim>,
                                      DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1>
{
  typedef PiolaTransformedPdelabWrapper<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim, RangeFieldImp, rangeDim,
                                        1> ThisType;
  typedef BaseFunctionSetInterface<internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp,
                                                                                DomainFieldImp, domainDim,
                                                                                RangeFieldImp, rangeDim>,
                                   DomainFieldImp, domainDim, RangeFieldImp, rangeDim, 1> BaseType;

public:
  typedef internal::PiolaTransformedPdelabWrapperTraits<PdelabSpaceType, EntityImp, DomainFieldImp, domainDim,
                                                        RangeFieldImp, rangeDim> Traits;
  typedef typename Traits::BackendType BackendType;
  typedef typename Traits::EntityType EntityType;

private:
  typedef typename Traits::PdelabLFSType PdelabLFSType;
  typedef typename Traits::FESwitchType FESwitchType;

public:
  using typename BaseType::DomainFieldType;
  using BaseType::dimDomain;
  using typename BaseType::DomainType;
  using typename BaseType::RangeType;
  using typename BaseType::JacobianRangeType;

  PiolaTransformedPdelabWrapper(const PdelabSpaceType& space, const EntityType& ent)
    : BaseType(ent)
    , tmp_domain_(DomainFieldType(0))
    , tmp_jacobian_transposed_(DomainFieldType(0))
    , tmp_jacobian_inverse_transposed_(DomainFieldType(0))
  {
    PdelabLFSType* lfs_ptr = new PdelabLFSType(space);
    lfs_ptr->bind(this->entity());
    lfs_                 = std::unique_ptr<PdelabLFSType>(lfs_ptr);
    backend_             = std::unique_ptr<BackendType>(new BackendType(FESwitchType::basis(lfs_->finiteElement())));
    tmp_ranges_          = std::vector<RangeType>(backend_->size(), RangeType(0));
    tmp_jacobian_ranges_ = std::vector<JacobianRangeType>(backend_->size(), JacobianRangeType(0));
  } // PdelabWrapper(...)

  PiolaTransformedPdelabWrapper(ThisType&& source) = default;

  PiolaTransformedPdelabWrapper(const ThisType& /*other*/) = delete;

  ThisType& operator=(const ThisType& /*other*/) = delete;

  const BackendType& backend() const
  {
    return *backend_;
  }

  virtual size_t size() const override final
  {
    return backend_->size();
  }

  virtual size_t order() const override final
  {
    return backend_->order();
  }

  virtual void evaluate(const DomainType& xx, std::vector<RangeType>& ret) const override final
  {
    assert(lfs_);
    assert(backend_);
    assert(tmp_ranges_.size() >= backend_->size());
    assert(ret.size() >= backend_->size());
    backend_->evaluateFunction(xx, tmp_ranges_);
    const auto geometry                       = this->entity().geometry();
    tmp_jacobian_transposed_                  = geometry.jacobianTransposed(xx);
    const DomainFieldType integration_element = geometry.integrationElement(xx);
    for (size_t ii = 0; ii < backend_->size(); ++ii) {
      tmp_jacobian_transposed_.mtv(tmp_ranges_[ii], ret[ii]);
      ret[ii] /= integration_element;
    }
  } // ... evaluate(...)

  using BaseType::evaluate;

  virtual void jacobian(const DomainType& xx, std::vector<JacobianRangeType>& ret) const override final
  {
    assert(lfs_);
    assert(backend_);
    assert(ret.size() >= backend_->size());
    backend_->evaluateJacobian(xx, tmp_jacobian_ranges_);
    const auto geometry                       = this->entity().geometry();
    tmp_jacobian_transposed_                  = geometry.jacobianTransposed(xx);
    tmp_jacobian_inverse_transposed_          = geometry.jacobianInverseTransposed(xx);
    const DomainFieldType integration_element = geometry.integrationElement(xx);
    for (size_t ii = 0; ii < backend_->size(); ++ii) {
      for (size_t jj = 0; jj < dimDomain; ++jj) {
        tmp_jacobian_inverse_transposed_.mv(tmp_jacobian_ranges_[ii][jj], ret[ii][jj]);
        tmp_jacobian_transposed_.mv(ret[ii][jj], tmp_jacobian_ranges_[ii][jj]);
        tmp_jacobian_ranges_[ii][jj] /= integration_element;
        ret[ii][jj] = tmp_jacobian_ranges_[ii][jj];
      }
    }
  } // ... jacobian(...)

  using BaseType::jacobian;

private:
  mutable DomainType tmp_domain_;
  mutable typename EntityType::Geometry::JacobianTransposed tmp_jacobian_transposed_;
  mutable typename EntityType::Geometry::JacobianInverseTransposed tmp_jacobian_inverse_transposed_;
  std::unique_ptr<const PdelabLFSType> lfs_;
  std::unique_ptr<const BackendType> backend_;
  mutable std::vector<RangeType> tmp_ranges_;
  mutable std::vector<JacobianRangeType> tmp_jacobian_ranges_;
}; // class PiolaTransformedPdelabWrapper

#else // HAVE_DUNE_PDELAB

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PdelabWrapper
{
  static_assert(AlwaysFalse<PdelabSpaceImp>::value, "You are missing dune-pdelab!");
};

template <class PdelabSpaceImp, class EntityImp, class DomainFieldImp, int domainDim, class RangeFieldImp, int rangeDim,
          int rangeDimCols = 1>
class PiolaTransformedPdelabWrapper
{
  static_assert(AlwaysFalse<PdelabSpaceImp>::value, "You are missing dune-pdelab!");
};

#endif // HAVE_DUNE_PDELAB

} // namespace BaseFunctionSet
} // namespace GDT
} // namespace Dune

#endif // DUNE_GDT_BASEFUNCTIONSET_PDELAB_HH
<|endoftext|>