<commit_before>/*************************************************************************
 *
 *  $RCSfile: fmpgeimp.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: obo $ $Date: 2005-03-18 10:01:44 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
#ifndef _SVX_FMUNOPGE_HXX
#define _SVX_FMUNOPGE_HXX

#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
#include <com/sun/star/form/XFormComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
#include <com/sun/star/form/XForm.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif

#ifndef _LIST_HXX //autogen
#include <tools/list.hxx>
#endif

#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif

#ifndef INCLUDED_SVXDLLAPI_H
#include "svx/dllapi.h"
#endif

class SvStream;
//BFS01class SdrIOHeader;
class FmFormObj;
class SdrObject;

//FORWARD_DECLARE_INTERFACE(uno,Reference)
FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
FORWARD_DECLARE_INTERFACE(container,XIndexContainer)

class SdrObjList;

DECLARE_LIST(FmObjectList, FmFormObj*);

//==================================================================
// FmFormPageImpl
// lauscht an allen Containern, um festzustellen, wann Objecte
// eingefuegt worden sind und wann diese entfernt wurden
//==================================================================

class SVX_DLLPRIVATE FmFormPageImpl
{
    friend class FmFormPage;
    friend class FmFormObj;
    friend class FmXFormShell;

    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>                xCurrentForm;   // aktuelles Formular
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>  xForms;         // Liste aller Forms
    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel>              xModel;
    FmFormPage*             pPage;

    sal_Bool        m_bFirstActivation  : 1;

protected:
    FmFormPageImpl(FmFormPage* _pPage);
    FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl);
    ~FmFormPageImpl();

    void Init();

public:
    //  nur wichtig fuer den DesignMode
    void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();

    /** inserts a form component into the form component hierarchy

        If the given component does not yet belong into the form hierarchy, a suitable place for
        it is found, using <member>findFormForDataSource</member>, if possible.

        If no sutiable form is found, a new one is created, and also inserted into the
        hierarchy.
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> placeInFormComponentHierarchy(
        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
        const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
        const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
        sal_Int32 nCommandType = 0
    );

    // activation handling
    inline  sal_Bool    hasEverBeenActivated( ) const { return !m_bFirstActivation; }
    inline  void        setHasBeenActivated( ) { m_bFirstActivation = sal_False; }

protected:
    // lesen und schreiben der Objecte
//BFS01 void WriteData(SvStream& rOut) const; //
//BFS01 void ReadData(const SdrIOHeader& rHead, SvStream& rIn); //

    void write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& OutStream) const;
    void read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& InStream);

    const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms() {return xForms;}

    void fillList(FmObjectList& rList, const SdrObjList& rObjList, sal_Bool bConnected) const;

    /** finds a form with a given data source signature
        @param rForm
            the form to start the search with. This form, including all possible sub forms,
            will be examined
        @param rDatabase
            the data source which to which the found form must be bound
        @param rCommand
            the desired Command property value of the sought-after form
        @param nCommandType
            the desired CommandType property value of the sought-after form
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
        const ::rtl::OUString& rCommand,
        sal_Int32 nCommandType
    );

    ::rtl::OUString getDefaultName(
                        sal_Int16 _nClassId,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& _rxControls,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject
                    ) const;

private:
    /** validates whether <member>xCurrentForm</member> is still valid and to be used

        There are situations where our current form becomes invalid, without us noticing this. Thus,
        every method which accesses <member>xCurrentForm</member> should beforehand validate the current
        form by calling this method.

        If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.

        @since #i40086#
    */
    void    validateCurForm();

public:

    static UniString getDefaultName(
                        sal_Int16 nClassId,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject
                    );

    ::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls);
    ::rtl::OUString getUniqueName(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& xNamedSet) const;
};

#endif // _SVX_FMUNOPGE_HXX

<commit_msg>INTEGRATION: CWS xmlperf02 (1.9.234); FILE MERGED 2005/02/23 13:59:03 oj 1.9.234.2: RESYNC: (1.9-1.10); FILE MERGED 2005/02/01 14:45:47 fs 1.9.234.1: #119224# create the forms collection on demand only<commit_after>/*************************************************************************
 *
 *  $RCSfile: fmpgeimp.hxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: kz $ $Date: 2005-03-18 18:43:38 $
 *
 *  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 _SVX_FMUNOPGE_HXX
#define _SVX_FMUNOPGE_HXX

#ifndef _COM_SUN_STAR_SDBC_XDATASOURCE_HPP_
#include <com/sun/star/sdbc/XDataSource.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
#include <com/sun/star/container/XNameAccess.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORMCOMPONENT_HPP_
#include <com/sun/star/form/XFormComponent.hpp>
#endif
#ifndef _COM_SUN_STAR_FORM_XFORM_HPP_
#include <com/sun/star/form/XForm.hpp>
#endif
#ifndef _COM_SUN_STAR_CONTAINER_XNAMECONTAINER_HPP_
#include <com/sun/star/container/XNameContainer.hpp>
#endif
#ifndef _COM_SUN_STAR_FRAME_XMODEL_HPP_
#include <com/sun/star/frame/XModel.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif

#ifndef _LIST_HXX //autogen
#include <tools/list.hxx>
#endif

#ifndef _COMPHELPER_UNO3_HXX_
#include <comphelper/uno3.hxx>
#endif

#ifndef INCLUDED_SVXDLLAPI_H
#include "svx/dllapi.h"
#endif

class SvStream;
//BFS01class SdrIOHeader;
class FmFormObj;
class SdrObject;

//FORWARD_DECLARE_INTERFACE(uno,Reference)
FORWARD_DECLARE_INTERFACE(io,XObjectOutputStream)
FORWARD_DECLARE_INTERFACE(io,XObjectInputStream)
FORWARD_DECLARE_INTERFACE(container,XIndexContainer)

class SdrObjList;

DECLARE_LIST(FmObjectList, FmFormObj*);

//==================================================================
// FmFormPageImpl
// lauscht an allen Containern, um festzustellen, wann Objecte
// eingefuegt worden sind und wann diese entfernt wurden
//==================================================================

class SVX_DLLPRIVATE FmFormPageImpl
{
    friend class FmFormPage;
    friend class FmFormObj;
    friend class FmXFormShell;

    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>                xCurrentForm;
    ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>  m_xForms;
    FmFormPage*             pPage;

    sal_Bool        m_bFirstActivation  : 1;
    sal_Bool        m_bAttemptedFormCreation : 2;

protected:
    FmFormPageImpl(FmFormPage* _pPage);
    FmFormPageImpl(FmFormPage* _pPage, const FmFormPageImpl& rImpl);
    ~FmFormPageImpl();

    void Init();

public:
    //  nur wichtig fuer den DesignMode
    void setCurForm(::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> xForm);
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> getDefaultForm();

    /** inserts a form component into the form component hierarchy

        If the given component does not yet belong into the form hierarchy, a suitable place for
        it is found, using <member>findFormForDataSource</member>, if possible.

        If no sutiable form is found, a new one is created, and also inserted into the
        hierarchy.
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> placeInFormComponentHierarchy(
        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& rContent,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase = ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>(),
        const ::rtl::OUString& rDBTitle = ::rtl::OUString(),
        const ::rtl::OUString& rCursorSource = ::rtl::OUString(),
        sal_Int32 nCommandType = 0
    );

    // activation handling
    inline  sal_Bool    hasEverBeenActivated( ) const { return !m_bFirstActivation; }
    inline  void        setHasBeenActivated( ) { m_bFirstActivation = sal_False; }

protected:
    // lesen und schreiben der Objecte
//BFS01 void WriteData(SvStream& rOut) const; //
//BFS01 void ReadData(const SdrIOHeader& rHead, SvStream& rIn); //

    void write(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectOutputStream>& OutStream) const;
    void read(const ::com::sun::star::uno::Reference< ::com::sun::star::io::XObjectInputStream>& InStream);

    const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer>& getForms( bool _bForceCreate = true );

    void fillList(FmObjectList& rList, const SdrObjList& rObjList, sal_Bool bConnected) const;

    /** finds a form with a given data source signature
        @param rForm
            the form to start the search with. This form, including all possible sub forms,
            will be examined
        @param rDatabase
            the data source which to which the found form must be bound
        @param rCommand
            the desired Command property value of the sought-after form
        @param nCommandType
            the desired CommandType property value of the sought-after form
    */
    ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm> findFormForDataSource(
        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& rForm,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource>& rDatabase,
        const ::rtl::OUString& rCommand,
        sal_Int32 nCommandType
    );

    ::rtl::OUString getDefaultName(
                        sal_Int16 _nClassId,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& _rxControls,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject
                    ) const;

private:
    /** validates whether <member>xCurrentForm</member> is still valid and to be used

        There are situations where our current form becomes invalid, without us noticing this. Thus,
        every method which accesses <member>xCurrentForm</member> should beforehand validate the current
        form by calling this method.

        If <member>xCurrentForm</member> is not valid anymore, it is reset to <NULL/>.

        @since #i40086#
    */
    void    validateCurForm();

public:

    static UniString getDefaultName(
                        sal_Int16 nClassId,
                        const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XServiceInfo >& _rxObject
                    );

    ::rtl::OUString setUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::form::XFormComponent>& xFormComponent, const ::com::sun::star::uno::Reference< ::com::sun::star::form::XForm>& xControls);
    ::rtl::OUString getUniqueName(const ::rtl::OUString& rName, const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& xNamedSet) const;
};

#endif // _SVX_FMUNOPGE_HXX

<|endoftext|>


<commit_before><commit_msg>CID#1078608 unlikely NULL deref case<commit_after><|endoftext|>


<commit_before><commit_msg>fdo#31405 CommandType is a LONG, so use a sal_Int32 to retrieve it<commit_after><|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: edtwin.hxx,v $
 *
 *  $Revision: 1.16 $
 *
 *  last change: $Author: kz $ $Date: 2004-05-17 17:28:39 $
 *
 *  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 _EDTWIN_HXX
#define _EDTWIN_HXX

#ifndef _LINK_HXX
#include <tools/link.hxx>
#endif
#ifndef _TIMER_HXX
#include <vcl/timer.hxx>
#endif
#ifndef _WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _TRANSFER_HXX
#include <svtools/transfer.hxx>
#endif

#ifndef _SWEVENT_HXX
#include <swevent.hxx>
#endif

#define _SVSTDARR_STRINGSISORTDTOR
#include <svtools/svstdarr.hxx>

class   SwWrtShell;
class   SwView;
class   SwRect;
class   SwDrawBase;
class   ViewShell;
class   SwAnchorMarker;
class   SdrViewUserMarker;
class   SdrObject;
class   SwShadowCursor;
class   DataChangedEvent;
class   SvxAutoCorrCfg;
class   SvxAutoCorrect;
struct  SwApplyTemplate;
struct  QuickHelpData;

/*--------------------------------------------------------------------
    Beschreibung:   Eingabe-Fenster
 --------------------------------------------------------------------*/

class SwEditWin: public Window,
                public DropTargetHelper, public DragSourceHelper
{
friend void     ScrollMDI(ViewShell* pVwSh, const SwRect&,
                          USHORT nRangeX, USHORT nRangeY);
friend BOOL     IsScrollMDI(ViewShell* pVwSh, const SwRect&);

friend void     SizeNotify(ViewShell* pVwSh, const Size &);

friend void     PageNumNotify(  ViewShell* pVwSh,
                                USHORT nPhyNum,
                                USHORT nVirtNum,
                                const String& rPg );

    static  QuickHelpData* pQuickHlpData;

    static  BOOL    bReplaceQuote;
    static  long    nDDStartPosX, nDDStartPosY;

    static  Color   aTextColor;     //Textfarbe, fuer die Giesskanne
    static  BOOL    bTransparentBackColor; // Hintergrund transparent
    static  Color   aTextBackColor; //Texthintergrundfarbe, fuer die Giesskanne

    /*
     * Timer und Handler fuer das Weiterscrollen, wenn der
     * Mauspointer innerhalb eines Drag-Vorgangs ausserhalb des
     * EditWin stehen bleibt.  In regelmaessigen Intervallen wird
     * die Selektion in Richtung der Mausposition vergroessert.
     */
    AutoTimer       aTimer;
    // Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
    Timer           aKeyInputTimer;
    // timer for ANY-KeyInut question without a following KeyInputEvent
    Timer           aKeyInputFlushTimer;

    String          aInBuffer;
    Point           aStartPos;
    Point           aMovePos;
    Point           aRszMvHdlPt;
    Timer           aTemplateTimer;

    // Type/Objecte ueber dem der MousePointer steht
    SwCallMouseEvent aSaveCallEvent;

    SwApplyTemplate     *pApplyTempl;
    SwAnchorMarker      *pAnchorMarker; // zum Verschieben eines Ankers

    SdrViewUserMarker   *pUserMarker;
    SdrObject           *pUserMarkerObj;
    SwShadowCursor      *pShadCrsr;

    SwView         &rView;

    int             aActHitType;    // aktueller Mauspointer

    ULONG           nDropFormat;    //Format aus dem letzten QueryDrop
    USHORT          nDropAction;    //Action aus dem letzten QueryDrop
    USHORT          nDropDestination;   //Ziel aus dem letzten QueryDrop

    UINT16          eDrawMode;
    UINT16          eBezierMode;
    UINT16          nInsFrmColCount; //Spaltenzahl fuer interaktiven Rahmen
    BOOL            bLinkRemoved    : 1,
                    bMBPressed      : 1,
                    bInsDraw        : 1,
                    bInsFrm         : 1,
                    bIsInMove       : 1,
                    bIsInDrag       : 1, //StartExecuteDrag nich doppelt ausfuehren
                    bOldIdle        : 1, //Zum abschalten des Idle'ns
                    bOldIdleSet     : 1, //waehrend QeueryDrop
                    bTblInsDelMode  : 1, //
                    bTblIsInsMode   : 1, //
                    bTblIsColMode   : 1, //
                    bChainMode      : 1, //Rahmen verbinden
                    bWasShdwCrsr    : 1, //ShadowCrsr war im MouseButtonDown an
                    bLockInput      : 1; //Lock waehrend die Rechenleiste aktiv ist

    USHORT          nKS_NUMDOWN_Count; // #i23725#
    USHORT          nKS_NUMINDENTINC_Count;

    void            LeaveArea(const Point &);
    void            JustifyAreaTimer();
    inline void     EnterArea();

    void            RstMBDownFlags();

    void            ChangeFly( BYTE nDir, BOOL bWeb = FALSE );
    void            ChangeDrawing( BYTE nDir );

    BOOL            EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
    BOOL            RulerColumnDrag( SwView& , const MouseEvent& rMEvt, BOOL bVerticalMode);

    //Hilfsfunktionen fuer D&D
    void            DropCleanup();
    void            CleanupDropUserMarker();
    USHORT          GetDropDestination( const Point& rPixPnt,
                                        SdrObject ** ppObj = 0 );
    //select the object/cursor at the mouse position of the context menu request
    BOOL            SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );

    /*
     * Handler fuer das Weiterscrollen, wenn der Mauspointer innerhalb eines
     * Drag-Vorgangs ausserhalb des EditWin stehen bleibt. In regelmaessigen
     * Intervallen wird die Selektion in Richtung der Mausposition
     * vergroessert.
     */
    DECL_LINK( TimerHandler, Timer * );
    void            StartDDTimer();
    void            StopDDTimer(SwWrtShell *, const Point &);
    DECL_LINK( DDHandler, Timer * );

    // timer for ANY-KeyInut question without a following KeyInputEvent
    DECL_LINK( KeyInputFlushHandler, Timer * );

    // Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
    DECL_LINK( KeyInputTimerHandler, Timer * );

    // Timer fuer das ApplyTemplates per Maus (verkapptes Drag&Drop)
    DECL_LINK( TemplateTimerHdl, Timer* );

protected:

    virtual void    DataChanged( const DataChangedEvent& );
    virtual void    Paint( const Rectangle& rRect );
    virtual void    KeyInput(const KeyEvent &rKEvt);

    virtual void    GetFocus();
    virtual void    LoseFocus();

    virtual void    MouseMove(const MouseEvent& rMEvt);
    virtual void    MouseButtonDown(const MouseEvent& rMEvt);
    virtual void    MouseButtonUp(const MouseEvent& rMEvt);
    virtual void    RequestHelp(const HelpEvent& rEvt);

    virtual void    Command( const CommandEvent& rCEvt );

                                // Drag & Drop Interface
    virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
    virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
    virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel );

    void    ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr );
public:

    void            UpdatePointer(const Point &, USHORT nButtons = 0);

    BOOL            IsDrawSelMode();
    BOOL            IsDrawAction()                  { return (bInsDraw); }
    void            SetDrawAction(BOOL bFlag)       { bInsDraw = bFlag; }
    inline UINT16   GetDrawMode(BOOL bBuf = FALSE) const { return eDrawMode; }
    inline void     SetDrawMode(UINT16 eDrwMode)    { eDrawMode = eDrwMode; }
    void            StdDrawMode(USHORT nSlotId);
    BOOL            IsFrmAction()                   { return (bInsFrm); }
    inline UINT16   GetBezierMode()                 { return eBezierMode; }
    void            SetBezierMode(UINT16 eBezMode)  { eBezierMode = eBezMode; }
    void            EnterDrawTextMode(const Point& aDocPos); // DrawTextEditMode einschalten
    void            InsFrm(USHORT nCols);
    void            StopInsFrm();
    UINT16          GetFrmColCount() const {return nInsFrmColCount;} //Spaltenzahl fuer interaktiven Rahmen

    void            SetChainMode( BOOL bOn );
    BOOL            IsChainMode() const             { return bChainMode; }

    void            FlushInBuffer( SwWrtShell *pSh );

    static  void    SetReplaceQuote(BOOL bOn = TRUE) { bReplaceQuote = bOn; }
    static  BOOL    IsReplaceQuote() { return bReplaceQuote; }

    void             SetApplyTemplate(const SwApplyTemplate &);
    SwApplyTemplate* GetApplyTemplate() const { return pApplyTempl; }

    void            StartExecuteDrag();
    void            DragFinished();
    USHORT          GetDropAction() const { return nDropAction; }
    ULONG           GetDropFormat() const { return nDropFormat; }

    Color           GetTextColor() { return aTextColor; }
    void            SetTextColor(const Color& rCol ) { aTextColor = rCol; }

    Color           GetTextBackColor()
                                            { return aTextBackColor; }
    void            SetTextBackColor(const Color& rCol )
                                            { aTextBackColor = rCol; }
    void            SetTextBackColorTransparent(BOOL bSet)
                                    { bTransparentBackColor = bSet; }
    BOOL            IsTextBackColorTransparent()
                                    { return bTransparentBackColor; }
    void            LockKeyInput(BOOL bSet){bLockInput = bSet;}

    const SwView &GetView() const { return rView; }
          SwView &GetView()       { return rView; }

#ifdef ACCESSIBLE_LAYOUT
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
#endif

    // Tipfenster loeschen
    static void ClearTip();

    static inline long GetDDStartPosX() { return nDDStartPosX; }
    static inline long GetDDStartPosY() { return nDDStartPosY; }

    static void _InitStaticData();
    static void _FinitStaticData();

    //#i3370# remove quick help to prevent saving of autocorrection suggestions
    void StopQuickHelp();

    BOOL SwEditWin::RulerMarginDrag( SwView& rView , const MouseEvent& rMEvt);

    SwEditWin(Window *pParent, SwView &);
    virtual ~SwEditWin();
};

#endif

<commit_msg>INTEGRATION: CWS os30 (1.14.66); FILE MERGED 2004/05/19 17:41:22 os 1.14.66.2: RESYNC: (1.14-1.15); FILE MERGED 2004/05/19 13:13:52 os 1.14.66.1: #i21019# set CJK/CTL language on text input if necessary<commit_after>/*************************************************************************
 *
 *  $RCSfile: edtwin.hxx,v $
 *
 *  $Revision: 1.17 $
 *
 *  last change: $Author: rt $ $Date: 2004-06-17 16:05:39 $
 *
 *  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 _EDTWIN_HXX
#define _EDTWIN_HXX

#ifndef _LINK_HXX
#include <tools/link.hxx>
#endif
#ifndef _TIMER_HXX
#include <vcl/timer.hxx>
#endif
#ifndef _WINDOW_HXX
#include <vcl/window.hxx>
#endif
#ifndef _TRANSFER_HXX
#include <svtools/transfer.hxx>
#endif

#ifndef _SWEVENT_HXX
#include <swevent.hxx>
#endif

#define _SVSTDARR_STRINGSISORTDTOR
#include <svtools/svstdarr.hxx>

class   SwWrtShell;
class   SwView;
class   SwRect;
class   SwDrawBase;
class   ViewShell;
class   SwAnchorMarker;
class   SdrViewUserMarker;
class   SdrObject;
class   SwShadowCursor;
class   DataChangedEvent;
class   SvxAutoCorrCfg;
class   SvxAutoCorrect;
struct  SwApplyTemplate;
struct  QuickHelpData;

/*--------------------------------------------------------------------
    Beschreibung:   Eingabe-Fenster
 --------------------------------------------------------------------*/

class SwEditWin: public Window,
                public DropTargetHelper, public DragSourceHelper
{
friend void     ScrollMDI(ViewShell* pVwSh, const SwRect&,
                          USHORT nRangeX, USHORT nRangeY);
friend BOOL     IsScrollMDI(ViewShell* pVwSh, const SwRect&);

friend void     SizeNotify(ViewShell* pVwSh, const Size &);

friend void     PageNumNotify(  ViewShell* pVwSh,
                                USHORT nPhyNum,
                                USHORT nVirtNum,
                                const String& rPg );

    static  QuickHelpData* pQuickHlpData;

    static  BOOL    bReplaceQuote;
    static  long    nDDStartPosX, nDDStartPosY;

    static  Color   aTextColor;     //Textfarbe, fuer die Giesskanne
    static  BOOL    bTransparentBackColor; // Hintergrund transparent
    static  Color   aTextBackColor; //Texthintergrundfarbe, fuer die Giesskanne

    /*
     * Timer und Handler fuer das Weiterscrollen, wenn der
     * Mauspointer innerhalb eines Drag-Vorgangs ausserhalb des
     * EditWin stehen bleibt.  In regelmaessigen Intervallen wird
     * die Selektion in Richtung der Mausposition vergroessert.
     */
    AutoTimer       aTimer;
    // Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
    Timer           aKeyInputTimer;
    // timer for ANY-KeyInut question without a following KeyInputEvent
    Timer           aKeyInputFlushTimer;

    String          aInBuffer;
    LanguageType    eBufferLanguage;
    Point           aStartPos;
    Point           aMovePos;
    Point           aRszMvHdlPt;
    Timer           aTemplateTimer;

    // Type/Objecte ueber dem der MousePointer steht
    SwCallMouseEvent aSaveCallEvent;

    SwApplyTemplate     *pApplyTempl;
    SwAnchorMarker      *pAnchorMarker; // zum Verschieben eines Ankers

    SdrViewUserMarker   *pUserMarker;
    SdrObject           *pUserMarkerObj;
    SwShadowCursor      *pShadCrsr;

    SwView         &rView;

    int             aActHitType;    // aktueller Mauspointer

    ULONG           nDropFormat;    //Format aus dem letzten QueryDrop
    USHORT          nDropAction;    //Action aus dem letzten QueryDrop
    USHORT          nDropDestination;   //Ziel aus dem letzten QueryDrop

    UINT16          eDrawMode;
    UINT16          eBezierMode;
    UINT16          nInsFrmColCount; //Spaltenzahl fuer interaktiven Rahmen
    BOOL            bLinkRemoved    : 1,
                    bMBPressed      : 1,
                    bInsDraw        : 1,
                    bInsFrm         : 1,
                    bIsInMove       : 1,
                    bIsInDrag       : 1, //StartExecuteDrag nich doppelt ausfuehren
                    bOldIdle        : 1, //Zum abschalten des Idle'ns
                    bOldIdleSet     : 1, //waehrend QeueryDrop
                    bTblInsDelMode  : 1, //
                    bTblIsInsMode   : 1, //
                    bTblIsColMode   : 1, //
                    bChainMode      : 1, //Rahmen verbinden
                    bWasShdwCrsr    : 1, //ShadowCrsr war im MouseButtonDown an
                    bLockInput      : 1; //Lock waehrend die Rechenleiste aktiv ist

    USHORT          nKS_NUMDOWN_Count; // #i23725#
    USHORT          nKS_NUMINDENTINC_Count;

    void            LeaveArea(const Point &);
    void            JustifyAreaTimer();
    inline void     EnterArea();

    void            RstMBDownFlags();

    void            ChangeFly( BYTE nDir, BOOL bWeb = FALSE );
    void            ChangeDrawing( BYTE nDir );

    BOOL            EnterDrawMode(const MouseEvent& rMEvt, const Point& aDocPos);
    BOOL            RulerColumnDrag( SwView& , const MouseEvent& rMEvt, BOOL bVerticalMode);

    //Hilfsfunktionen fuer D&D
    void            DropCleanup();
    void            CleanupDropUserMarker();
    USHORT          GetDropDestination( const Point& rPixPnt,
                                        SdrObject ** ppObj = 0 );
    //select the object/cursor at the mouse position of the context menu request
    BOOL            SelectMenuPosition(SwWrtShell& rSh, const Point& rMousePos );

    /*
     * Handler fuer das Weiterscrollen, wenn der Mauspointer innerhalb eines
     * Drag-Vorgangs ausserhalb des EditWin stehen bleibt. In regelmaessigen
     * Intervallen wird die Selektion in Richtung der Mausposition
     * vergroessert.
     */
    DECL_LINK( TimerHandler, Timer * );
    void            StartDDTimer();
    void            StopDDTimer(SwWrtShell *, const Point &);
    DECL_LINK( DDHandler, Timer * );

    // timer for ANY-KeyInut question without a following KeyInputEvent
    DECL_LINK( KeyInputFlushHandler, Timer * );

    // Timer fuer verschachtelte KeyInputs (z.B. fuer Tabellen)
    DECL_LINK( KeyInputTimerHandler, Timer * );

    // Timer fuer das ApplyTemplates per Maus (verkapptes Drag&Drop)
    DECL_LINK( TemplateTimerHdl, Timer* );

protected:

    virtual void    DataChanged( const DataChangedEvent& );
    virtual void    Paint( const Rectangle& rRect );
    virtual void    KeyInput(const KeyEvent &rKEvt);

    virtual void    GetFocus();
    virtual void    LoseFocus();

    virtual void    MouseMove(const MouseEvent& rMEvt);
    virtual void    MouseButtonDown(const MouseEvent& rMEvt);
    virtual void    MouseButtonUp(const MouseEvent& rMEvt);
    virtual void    RequestHelp(const HelpEvent& rEvt);

    virtual void    Command( const CommandEvent& rCEvt );

                                // Drag & Drop Interface
    virtual sal_Int8    AcceptDrop( const AcceptDropEvent& rEvt );
    virtual sal_Int8    ExecuteDrop( const ExecuteDropEvent& rEvt );
    virtual void        StartDrag( sal_Int8 nAction, const Point& rPosPixel );

    void    ShowAutoTextCorrectQuickHelp( const String& rWord, SvxAutoCorrCfg* pACfg, SvxAutoCorrect* pACorr );
public:

    void            UpdatePointer(const Point &, USHORT nButtons = 0);

    BOOL            IsDrawSelMode();
    BOOL            IsDrawAction()                  { return (bInsDraw); }
    void            SetDrawAction(BOOL bFlag)       { bInsDraw = bFlag; }
    inline UINT16   GetDrawMode(BOOL bBuf = FALSE) const { return eDrawMode; }
    inline void     SetDrawMode(UINT16 eDrwMode)    { eDrawMode = eDrwMode; }
    void            StdDrawMode(USHORT nSlotId);
    BOOL            IsFrmAction()                   { return (bInsFrm); }
    inline UINT16   GetBezierMode()                 { return eBezierMode; }
    void            SetBezierMode(UINT16 eBezMode)  { eBezierMode = eBezMode; }
    void            EnterDrawTextMode(const Point& aDocPos); // DrawTextEditMode einschalten
    void            InsFrm(USHORT nCols);
    void            StopInsFrm();
    UINT16          GetFrmColCount() const {return nInsFrmColCount;} //Spaltenzahl fuer interaktiven Rahmen

    void            SetChainMode( BOOL bOn );
    BOOL            IsChainMode() const             { return bChainMode; }

    void            FlushInBuffer();

    static  void    SetReplaceQuote(BOOL bOn = TRUE) { bReplaceQuote = bOn; }
    static  BOOL    IsReplaceQuote() { return bReplaceQuote; }

    void             SetApplyTemplate(const SwApplyTemplate &);
    SwApplyTemplate* GetApplyTemplate() const { return pApplyTempl; }

    void            StartExecuteDrag();
    void            DragFinished();
    USHORT          GetDropAction() const { return nDropAction; }
    ULONG           GetDropFormat() const { return nDropFormat; }

    Color           GetTextColor() { return aTextColor; }
    void            SetTextColor(const Color& rCol ) { aTextColor = rCol; }

    Color           GetTextBackColor()
                                            { return aTextBackColor; }
    void            SetTextBackColor(const Color& rCol )
                                            { aTextBackColor = rCol; }
    void            SetTextBackColorTransparent(BOOL bSet)
                                    { bTransparentBackColor = bSet; }
    BOOL            IsTextBackColorTransparent()
                                    { return bTransparentBackColor; }
    void            LockKeyInput(BOOL bSet){bLockInput = bSet;}

    const SwView &GetView() const { return rView; }
          SwView &GetView()       { return rView; }

#ifdef ACCESSIBLE_LAYOUT
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
#endif

    // Tipfenster loeschen
    static void ClearTip();

    static inline long GetDDStartPosX() { return nDDStartPosX; }
    static inline long GetDDStartPosY() { return nDDStartPosY; }

    static void _InitStaticData();
    static void _FinitStaticData();

    //#i3370# remove quick help to prevent saving of autocorrection suggestions
    void StopQuickHelp();

    BOOL SwEditWin::RulerMarginDrag( SwView& rView , const MouseEvent& rMEvt);

    SwEditWin(Window *pParent, SwView &);
    virtual ~SwEditWin();
};

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: idxmrk.hxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 09:20:10 $
 *
 *  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 _IDXMRK_HXX
#define _IDXMRK_HXX

//CHINA001 #ifndef _COM_SUN_STAR_CONTAINER_XNAMEACCESS_HPP_
//CHINA001 #include <com/sun/star/container/XNameAccess.hpp>
//CHINA001 #endif
//CHINA001 #ifndef _BASEDLGS_HXX
//CHINA001 #include <sfx2/basedlgs.hxx>
//CHINA001 #endif
//CHINA001
//CHINA001 #ifndef _FIXED_HXX //autogen
//CHINA001 #include <vcl/fixed.hxx>
//CHINA001 #endif

//CHINA001 #ifndef _SV_LSTBOX_HXX
//CHINA001 #include <vcl/lstbox.hxx>
//CHINA001 #endif
//CHINA001 #ifndef _COMBOBOX_HXX //autogen
//CHINA001 #include <vcl/combobox.hxx>
//CHINA001 #endif
//CHINA001 #ifndef _SVX_STDDLG_HXX
//CHINA001 #include <svx/stddlg.hxx>
//CHINA001 #endif
//CHINA001
//CHINA001 #ifndef _FIELD_HXX //autogen
//CHINA001 #include <vcl/field.hxx>
//CHINA001 #endif
//CHINA001
//CHINA001 #ifndef _GROUP_HXX //autogen
//CHINA001 #include <vcl/group.hxx>
//CHINA001 #endif

//CHINA001 #ifndef _BUTTON_HXX //autogen
//CHINA001 #include <vcl/button.hxx>
//CHINA001 #endif
//CHINA001
//CHINA001 #ifndef _IMAGEBTN_HXX //autogen
//CHINA001 #include <vcl/imagebtn.hxx>
//CHINA001 #endif
#ifndef _SFX_CHILDWIN_HXX //autogen
#include <sfx2/childwin.hxx>
#endif
//CHINA001 #ifndef _TOXE_HXX
//CHINA001 #include "toxe.hxx"
//CHINA001 #endif
//CHINA001 #ifndef _STDCTRL_HXX
//CHINA001 #include <svtools/stdctrl.hxx>
//CHINA001 #endif
//CHINA001 #ifndef  _COM_SUN_STAR_I18N_XEXTENDEDINDEXENTRYSUPPLIER_HPP_
//CHINA001 #include <com/sun/star/i18n/XExtendedIndexEntrySupplier.hpp>
//CHINA001 #endif
#include "swabstdlg.hxx" //CHINA001
class SwWrtShell;

/* -----------------07.09.99 08:02-------------------

 --------------------------------------------------*/
class SwInsertIdxMarkWrapper : public SfxChildWindow
{
    AbstractMarkFloatDlg*   pAbstDlg; //CHINA001
protected:
    SwInsertIdxMarkWrapper( Window *pParentWindow,
                            sal_uInt16 nId,
                            SfxBindings* pBindings,
                            SfxChildWinInfo* pInfo );

    SFX_DECL_CHILDWINDOW(SwInsertIdxMarkWrapper);

public:
    void    ReInitDlg(SwWrtShell& rWrtShell);
};

/* -----------------07.09.99 08:02-------------------

 --------------------------------------------------*/
class SwInsertAuthMarkWrapper : public SfxChildWindow
{
    AbstractMarkFloatDlg*   pAbstDlg; //CHINA001
protected:
    SwInsertAuthMarkWrapper(    Window *pParentWindow,
                            sal_uInt16 nId,
                            SfxBindings* pBindings,
                            SfxChildWinInfo* pInfo );

    SFX_DECL_CHILDWINDOW(SwInsertAuthMarkWrapper);

public:
    void    ReInitDlg(SwWrtShell& rWrtShell);
};

#endif // _IDXMRK_HXX

<commit_msg>INTEGRATION: CWS swwarnings (1.11.710); FILE MERGED 2007/04/13 12:18:01 tl 1.11.710.1: #i69287# binfilter related comments removed<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: idxmrk.hxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 12:02: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 _IDXMRK_HXX
#define _IDXMRK_HXX

#ifndef _SFX_CHILDWIN_HXX //autogen
#include <sfx2/childwin.hxx>
#endif

#include "swabstdlg.hxx"

class SwWrtShell;

/* -----------------07.09.99 08:02-------------------

 --------------------------------------------------*/
class SwInsertIdxMarkWrapper : public SfxChildWindow
{
    AbstractMarkFloatDlg*   pAbstDlg;
protected:
    SwInsertIdxMarkWrapper( Window *pParentWindow,
                            sal_uInt16 nId,
                            SfxBindings* pBindings,
                            SfxChildWinInfo* pInfo );

    SFX_DECL_CHILDWINDOW(SwInsertIdxMarkWrapper);

public:
    void    ReInitDlg(SwWrtShell& rWrtShell);
};

/* -----------------07.09.99 08:02-------------------

 --------------------------------------------------*/
class SwInsertAuthMarkWrapper : public SfxChildWindow
{
    AbstractMarkFloatDlg*   pAbstDlg;
protected:
    SwInsertAuthMarkWrapper(    Window *pParentWindow,
                            sal_uInt16 nId,
                            SfxBindings* pBindings,
                            SfxChildWinInfo* pInfo );

    SFX_DECL_CHILDWINDOW(SwInsertAuthMarkWrapper);

public:
    void    ReInitDlg(SwWrtShell& rWrtShell);
};

#endif // _IDXMRK_HXX

<|endoftext|>


<commit_before>#include "PerformanceTools.hpp"

#include <cstdio>

#include <sys/types.h>
#include <unistd.h>
#include <ctime>

#ifdef VTRACE
#include <vt_user.h>
#endif

#ifdef GOOGLE_PROFILER
#include <gperftools/profiler.h>
#endif

DEFINE_bool(record_grappa_events, true, "Sampling rate of Grappa tracing events.");

/// set when we should take a sample at the next context switch
bool take_profiling_sample = false;

// remember argv[0] for generating profiler filenames
static char * argv0_for_profiler = NULL;
int time_for_profiler = 0;

#define PROFILER_FILENAME_LENGTH 2048
static char profiler_filename[PROFILER_FILENAME_LENGTH] = {0};

// which profiling phase are we in?
static int profiler_phase = 0;

void SoftXMT_set_profiler_argv0( char * argv0 ) {
  argv0_for_profiler = argv0;
  time_for_profiler = time(NULL);
}

char * SoftXMT_get_next_profiler_filename( ) {
  // use Slurm environment variables if we can
  char * jobname = getenv("SLURM_JOB_NAME");
  char * jobid = getenv("SLURM_JOB_ID");
  char * procid = getenv("SLURM_PROCID");
  if( false && jobname != NULL && jobid != NULL && procid != NULL ) {
    sprintf( profiler_filename, "%s.%s.rank%s.phase%d.prof", jobname, jobid, procid, profiler_phase );
  } else {
    sprintf( profiler_filename, "%s.%d.pid%d.phase%d.prof", argv0_for_profiler, time_for_profiler, getpid(), profiler_phase );
  }
  ++profiler_phase;
  return profiler_filename;
}

/// callback for sampling at profiler signals
/// runs in signal handler, so should be async-signal-safe
int SoftXMT_profile_handler( void * arg ) {
  take_profiling_sample = true;
  return 1; // tell profiler to profile at this tick
}

void SoftXMT_start_profiling() {
#ifdef GOOGLE_PROFILER
  ProfilerOptions po;
  po.filter_in_thread = &SoftXMT_profile_handler;
  po.filter_in_thread_arg = NULL;
  ProfilerStartWithOptions( SoftXMT_get_next_profiler_filename(), &po );
  //ProfilerStart( SoftXMT_get_profiler_filename() );
#ifdef VTRACE_SAMPLED
  VT_USER_START("sampling");
#endif
#endif
}

void SoftXMT_stop_profiling() {
#ifdef GOOGLE_PROFILER
    ProfilerStop( );
    SoftXMT_profile_handler(NULL);
#ifdef VTRACE_SAMPLED
  VT_USER_END("sampling");
#endif
#endif
}
<commit_msg>Whoops, forgot to remove test code<commit_after>#include "PerformanceTools.hpp"

#include <cstdio>

#include <sys/types.h>
#include <unistd.h>
#include <ctime>

#ifdef VTRACE
#include <vt_user.h>
#endif

#ifdef GOOGLE_PROFILER
#include <gperftools/profiler.h>
#endif

DEFINE_bool(record_grappa_events, true, "Sampling rate of Grappa tracing events.");

/// set when we should take a sample at the next context switch
bool take_profiling_sample = false;

// remember argv[0] for generating profiler filenames
static char * argv0_for_profiler = NULL;
int time_for_profiler = 0;

#define PROFILER_FILENAME_LENGTH 2048
static char profiler_filename[PROFILER_FILENAME_LENGTH] = {0};

// which profiling phase are we in?
static int profiler_phase = 0;

void SoftXMT_set_profiler_argv0( char * argv0 ) {
  argv0_for_profiler = argv0;
  time_for_profiler = time(NULL);
}

char * SoftXMT_get_next_profiler_filename( ) {
  // use Slurm environment variables if we can
  char * jobname = getenv("SLURM_JOB_NAME");
  char * jobid = getenv("SLURM_JOB_ID");
  char * procid = getenv("SLURM_PROCID");
  if( jobname != NULL && jobid != NULL && procid != NULL ) {
    sprintf( profiler_filename, "%s.%s.rank%s.phase%d.prof", jobname, jobid, procid, profiler_phase );
  } else {
    sprintf( profiler_filename, "%s.%d.pid%d.phase%d.prof", argv0_for_profiler, time_for_profiler, getpid(), profiler_phase );
  }
  ++profiler_phase;
  return profiler_filename;
}

/// callback for sampling at profiler signals
/// runs in signal handler, so should be async-signal-safe
int SoftXMT_profile_handler( void * arg ) {
  take_profiling_sample = true;
  return 1; // tell profiler to profile at this tick
}

void SoftXMT_start_profiling() {
#ifdef GOOGLE_PROFILER
  ProfilerOptions po;
  po.filter_in_thread = &SoftXMT_profile_handler;
  po.filter_in_thread_arg = NULL;
  ProfilerStartWithOptions( SoftXMT_get_next_profiler_filename(), &po );
  //ProfilerStart( SoftXMT_get_profiler_filename() );
#ifdef VTRACE_SAMPLED
  VT_USER_START("sampling");
#endif
#endif
}

void SoftXMT_stop_profiling() {
#ifdef GOOGLE_PROFILER
    ProfilerStop( );
    SoftXMT_profile_handler(NULL);
#ifdef VTRACE_SAMPLED
  VT_USER_END("sampling");
#endif
#endif
}
<|endoftext|>


<commit_before>// -*-c++-*-

/*
 * Copyright (C) 2004 Stephan Huber http://digitalmind.de
 *
 *
 * The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for
 * real-time rendering of large 3D photo-realistic models.
 * The OSG homepage is http://www.openscenegraph.org/
 *
 * This software is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "QuicktimeImageStream.h"
#include <osg/Notify>
#include <osg/Timer>

#include "QTUtils.h"
#include "MovieData.h"

using namespace osg;

#define IDLE_TIMEOUT 150000L
#define ERR_MSG(no,msg) osg::notify(osg::WARN) << "QT-ImageStream: " << msg << " failed with error " << no << std::endl;

// Constructor: setup and start thread
QuicktimeImageStream::QuicktimeImageStream(std::string fileName) : ImageStream()
{

    osgQuicktime::initQuicktime();

    _len = 0;

    _data = new MovieData();

    for (int i = 0; i < NUM_CMD_INDEX; i++)
        _cmd[i] = THREAD_IDLE;
    _wrIndex = _rdIndex = 0;

    load(fileName);

    if (!fileName.empty())
        setFileName(fileName);

    startThread();
    start();
}

// Deconstructor: stop and terminate thread
QuicktimeImageStream::~QuicktimeImageStream()
{
    stop();

    setCmd(THREAD_QUIT);

    if( isRunning() )
    {

        // cancel the thread..
        cancel();
        //join();

        // then wait for the the thread to stop running.
        while(isRunning())
        {
            osg::notify(osg::DEBUG_INFO)<<"Waiting for QuicktimeImageStream to cancel"<<std::endl;
            OpenThreads::Thread::YieldCurrentThread();
        }

    }

    delete _data;

}

// Set command
void QuicktimeImageStream::setCmd(ThreadCommand cmd)
{
    lock();
    _cmd[_wrIndex] = cmd;
    _wrIndex = (_wrIndex + 1) % NUM_CMD_INDEX;
    unlock();
}

// Get command
QuicktimeImageStream::ThreadCommand QuicktimeImageStream::getCmd()
{
    ThreadCommand cmd = THREAD_IDLE;
    lock();
    if (_rdIndex != _wrIndex) {
        cmd = _cmd[_rdIndex];
        _rdIndex = (_rdIndex + 1) % NUM_CMD_INDEX;
    }
    unlock();
    return cmd;
}

void QuicktimeImageStream::load(std::string fileName)
{
    osg::notify(osg::DEBUG_INFO) << "QT-ImageStream: loading quicktime movie from " << fileName << std::endl;

    _data->load(this, fileName);

    _len = _data->getMovieDuration();

}

void QuicktimeImageStream::run()
{
    bool playing = false;
    bool done = false;
    OSErr err;

    // err = EnterMoviesOnThread(0);
    // ERR_MSG(err,"EnterMoviesOnThread");

    while (!done) {
        // osg::notify(osg::ALWAYS) << "movietime: " << _data->getMovieTime() << " state " << getCmd() << std::endl;
        // Handle commands
        ThreadCommand cmd = getCmd();
        if (cmd != THREAD_IDLE) {
            switch (cmd) {
                case THREAD_START: // Start or continue stream
                    StartMovie(_data->getMovie());
                    playing = true;
                    break;

                case THREAD_STOP:
                    SetMovieRate(_data->getMovie(),0);
                    osg::notify(NOTICE) << "QT-ImageStream: stop at "<< std::endl;
                    playing = false;
                    break;

                case THREAD_REWIND:
                    SetMovieRate(_data->getMovie(),0);
                    GoToBeginningOfMovie(_data->getMovie());
                    break;

                case THREAD_CLOSE:
                    SetMovieRate(_data->getMovie(),0);
                    break;

                case THREAD_QUIT: // TODO
                    SetMovieRate(_data->getMovie(),0);
                    osg::notify(NOTICE) << "QT-ImageStream: quit" << std::endl;
                    done = true;
                    break;
                default:
                    osg::notify(osg::WARN) << "QT-ImageStream: Unknown command " << cmd << std::endl;
                    break;
            }
        }

        MoviesTask(_data->getMovie(),0);
        float currentTime = _data->getMovieTime();
        if (_lastUpdate!= currentTime) {
            dirty();
            _lastUpdate = currentTime;
        }

        if (playing) {
            // TODO

        }
        else {
            ::usleep(IDLE_TIMEOUT);
        }
    }
    // err = ExitMoviesOnThread();
    //ERR_MSG(err,"ExitMoviesOnThread");
}
<commit_msg>Added mutex to image stream thread to serialize calls to Quicktime.<commit_after>// -*-c++-*-

/*
 * Copyright (C) 2004 Stephan Huber http://digitalmind.de
 *
 *
 * The Open Scene Graph (OSG) is a cross platform C++/OpenGL library for
 * real-time rendering of large 3D photo-realistic models.
 * The OSG homepage is http://www.openscenegraph.org/
 *
 * This software is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include "QuicktimeImageStream.h"
#include <osg/Notify>
#include <osg/Timer>

#include "QTUtils.h"
#include "MovieData.h"

using namespace osg;

#define IDLE_TIMEOUT 150000L
#define ERR_MSG(no,msg) osg::notify(osg::WARN) << "QT-ImageStream: " << msg << " failed with error " << no << std::endl;

// Constructor: setup and start thread
QuicktimeImageStream::QuicktimeImageStream(std::string fileName) : ImageStream()
{

    osgQuicktime::initQuicktime();

    _len = 0;

    _data = new MovieData();

    for (int i = 0; i < NUM_CMD_INDEX; i++)
        _cmd[i] = THREAD_IDLE;
    _wrIndex = _rdIndex = 0;

    load(fileName);

    if (!fileName.empty())
        setFileName(fileName);

    startThread();
    start();
}

// Deconstructor: stop and terminate thread
QuicktimeImageStream::~QuicktimeImageStream()
{
    stop();

    setCmd(THREAD_QUIT);

    if( isRunning() )
    {

        // cancel the thread..
        cancel();
        //join();

        // then wait for the the thread to stop running.
        while(isRunning())
        {
            osg::notify(osg::DEBUG_INFO)<<"Waiting for QuicktimeImageStream to cancel"<<std::endl;
            OpenThreads::Thread::YieldCurrentThread();
        }

    }

    delete _data;

}

// Set command
void QuicktimeImageStream::setCmd(ThreadCommand cmd)
{
    lock();
    _cmd[_wrIndex] = cmd;
    _wrIndex = (_wrIndex + 1) % NUM_CMD_INDEX;
    unlock();
}

// Get command
QuicktimeImageStream::ThreadCommand QuicktimeImageStream::getCmd()
{
    ThreadCommand cmd = THREAD_IDLE;
    lock();
    if (_rdIndex != _wrIndex) {
        cmd = _cmd[_rdIndex];
        _rdIndex = (_rdIndex + 1) % NUM_CMD_INDEX;
    }
    unlock();
    return cmd;
}

void QuicktimeImageStream::load(std::string fileName)
{
    osg::notify(osg::DEBUG_INFO) << "QT-ImageStream: loading quicktime movie from " << fileName << std::endl;

    _data->load(this, fileName);

    _len = _data->getMovieDuration();

}

void QuicktimeImageStream::run()
{
    static OpenThreads::Mutex s_qtMutex;

    bool playing = false;
    bool done = false;
    OSErr err;

    // err = EnterMoviesOnThread(0);
    // ERR_MSG(err,"EnterMoviesOnThread");

    while (!done) {
        // osg::notify(osg::ALWAYS) << "movietime: " << _data->getMovieTime() << " state " << getCmd() << std::endl;
        // Handle commands
        ThreadCommand cmd = getCmd();

	s_qtMutex.lock();

        if (cmd != THREAD_IDLE) {
            switch (cmd) {
                case THREAD_START: // Start or continue stream
                    StartMovie(_data->getMovie());
                    playing = true;
                    break;

                case THREAD_STOP:
                    SetMovieRate(_data->getMovie(),0);
                    osg::notify(NOTICE) << "QT-ImageStream: stop at "<< std::endl;
                    playing = false;
                    break;

                case THREAD_REWIND:
                    SetMovieRate(_data->getMovie(),0);
                    GoToBeginningOfMovie(_data->getMovie());
                    break;

                case THREAD_CLOSE:
                    SetMovieRate(_data->getMovie(),0);
                    break;

                case THREAD_QUIT: // TODO
                    SetMovieRate(_data->getMovie(),0);
                    osg::notify(NOTICE) << "QT-ImageStream: quit" << std::endl;
                    done = true;
                    break;
                default:
                    osg::notify(osg::WARN) << "QT-ImageStream: Unknown command " << cmd << std::endl;
                    break;
            }
        }

        MoviesTask(_data->getMovie(),0);
        float currentTime = _data->getMovieTime();

	s_qtMutex.unlock();

        if (_lastUpdate!= currentTime) {
            dirty();
            _lastUpdate = currentTime;
        }

        if (playing) {
            // TODO

        }
        else {
            ::usleep(IDLE_TIMEOUT);
        }
    }
    // err = ExitMoviesOnThread();
    //ERR_MSG(err,"ExitMoviesOnThread");
}
<|endoftext|>


<commit_before>//==============================================================================
// CellML file class
//==============================================================================

#include "cellmlfile.h"

//==============================================================================

#include <QTime>
#include <QUrl>

//==============================================================================

#include "IfaceVACSS.hxx"

#include "CellMLBootstrap.hpp"
#include "VACSSBootstrap.hpp"

//==============================================================================

namespace OpenCOR {
namespace CellMLSupport {

//==============================================================================

CellmlFile::CellmlFile(const QString &pFileName) :
    mFileName(pFileName)
{
    // Instantiate our runtime object

    mRuntime = new CellmlFileRuntime();

    // Reset ourselves

    reset();
}

//==============================================================================

CellmlFile::~CellmlFile()
{
    // Delete some internal objects

    delete mRuntime;
}

//==============================================================================

void CellmlFile::reset()
{
    // Reset all of the file's properties

    delete mModel; mModel = 0;

    mIssues.clear();

    mLoadingNeeded       = true;
    mIsValidNeeded       = true;
    mRuntimeUpdateNeeded = true;
}

//==============================================================================

bool CellmlFile::load()
{
    if (!mLoadingNeeded)
        // The file is already loaded, so...

        return true;

    // Reset any issues that we may have found before

    mIssues.clear();

    // Get a bootstrap object

    ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();

    // Get its model loader

    ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();

    // Try to load the model

qDebug("---------------------------------------");
qDebug("%s:", qPrintable(mFileName));

    try {
QTime time;

time.start();

        mModel = modelLoader->loadFromURL(QUrl::fromLocalFile(mFileName).toString().toStdWString().c_str());

qDebug(" - CellML Loading time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));
    } catch (iface::cellml_api::CellMLException &) {
        // Something went wrong with the loading of the model, so...

        mIssues.append(CellmlFileIssue(CellmlFileIssue::Error,
                                       tr("the model could not be loaded (%1)").arg(QString::fromStdWString(modelLoader->lastErrorMessage()))));

        return false;
    }

    // In the case of a non CellML 1.0 model, we want all imports to be fully
    // instantiated

    if (QString::fromStdWString(mModel->cellmlVersion()).compare(Cellml_1_0))
        try {
QTime time;

time.start();

            mModel->fullyInstantiateImports();

qDebug(" - CellML full instantiation time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));
        } catch (...) {
            // Something went wrong with the full instantiation of the imports,
            // so...

            reset();

            mIssues.append(CellmlFileIssue(CellmlFileIssue::Error,
                                           tr("the model's imports could not be fully instantiated")));

            return false;
        }

    // All done, so...

    mLoadingNeeded = false;

    return true;
}

//==============================================================================

bool CellmlFile::reload()
{
    // We want to reload the file, so we must first reset it

    reset();

    // Now, we can try to (re)load the file

    return load();
}

//==============================================================================

bool CellmlFile::isValid()
{
    if (!mIsValidNeeded)
        // The file has already been validated, so...

        return mIsValid;

    // Load (but not reload!) the file, if needed

    if (load()) {
        // The file was properly loaded (or was already loaded), so check
        // whether it is CellML valid
        // Note: validateModel() is somewhat slow, but there is (unfortunately)
        //       nothing we can do about it. Then, there is getPositionInXML()
        //       which is painfully slow, but unlike for validateModel() its use
        //       is not essential (even though it would be nice from an
        //       end-user's perspective). So, rather than retrieve the
        //       line/column of every single warning/error, we only keep track
        //       of the various warnings/errors and only retrieve their
        //       corresponding line/column when requested (definitely not neat
        //       from an end-user's perspective, but we just can't afford the
        //       time it takes to fully validate a model that has many
        //       warnings/errors)...

QTime time;

time.start();

        ObjRef<iface::cellml_services::VACSService> vacssService = CreateVACSService();
        ObjRef<iface::cellml_services::CellMLValidityErrorSet> cellmlValidityErrorSet = vacssService->validateModel(mModel);

qDebug(" - CellML validation time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));

        // Determine the number of errors and warnings
        // Note: CellMLValidityErrorSet::nValidityErrors() returns any type of
        //       validation issue, be it an error or a warning, so we need to
        //       determine the number of true errors

        int cellmlErrorsCount = 0;

time.restart();

        for (int i = 0, iMax = cellmlValidityErrorSet->nValidityErrors(); i < iMax; ++i) {
            ObjRef<iface::cellml_services::CellMLValidityError> cellmlValidityIssue = cellmlValidityErrorSet->getValidityError(i);

            DECLARE_QUERY_INTERFACE_OBJREF(cellmlRepresentationValidityError, cellmlValidityIssue,
                                           cellml_services::CellMLRepresentationValidityError);

            // Determine the issue's location

            int line = 0;
            int column = 0;
            QString importedFile = QString();

            if (cellmlRepresentationValidityError) {
                // We are dealing with a CellML representation issue, so
                // determine its line and column

                ObjRef<iface::dom::Node> errorNode = cellmlRepresentationValidityError->errorNode();

                line = vacssService->getPositionInXML(errorNode,
                                                      cellmlRepresentationValidityError->errorNodalOffset(),
                                                      &column);
            } else {
                // We are not dealing with a CellML representation issue, so
                // check whether we are dealing with a semantic one

                DECLARE_QUERY_INTERFACE_OBJREF(cellmlSemanticValidityError, cellmlValidityIssue,
                                               cellml_services::CellMLSemanticValidityError);

                if (cellmlSemanticValidityError) {
                    // We are dealing with a CellML semantic issue, so determine
                    // its line and column

                    ObjRef<iface::cellml_api::CellMLElement> cellmlElement = cellmlSemanticValidityError->errorElement();

                    DECLARE_QUERY_INTERFACE_OBJREF(cellmlDomElement, cellmlElement, cellml_api::CellMLDOMElement);

                    ObjRef<iface::dom::Element> domElement = cellmlDomElement->domElement();

                    line = vacssService->getPositionInXML(domElement, 0,
                                                          &column);

                    // Also determine its imported file, if any

                    while (true) {
                        // Retrieve the CellML element's parent

                        iface::cellml_api::CellMLElement *cellmlElementParent = already_AddRefd<iface::cellml_api::CellMLElement>(cellmlElement->parentElement());

                        if (!cellmlElementParent)
                            // There is no parent, so...

                            break;

                        // Check whether the parent is an imported file

                        DECLARE_QUERY_INTERFACE_OBJREF(importedCellmlFile,
                                                       cellmlElementParent,
                                                       cellml_api::Model);

                        if (!importedCellmlFile)
                            // This is not an imported file, so...

                            continue;

                        // Retrieve the imported CellML element

                        ObjRef<iface::cellml_api::CellMLElement> importedCellmlElement = importedCellmlFile->parentElement();

                        if (!importedCellmlElement)
                            // This is not an imported CellML element, so...

                            break;

                        // Check whether the imported CellML element is an
                        // import CellML element

                        DECLARE_QUERY_INTERFACE(importCellmlElement,
                                                importedCellmlElement,
                                                cellml_api::CellMLImport);

                        if (!importCellmlElement)
                            // This is not an import CellML element, so...

                            break;

                        ObjRef<iface::cellml_api::URI> href = importCellmlElement->xlinkHref();

                        importedFile = QString::fromStdWString(href->asText());

                        break;
                    }
                }
            }

            // Determine the issue's type

            CellmlFileIssue::Type issueType;

            if (cellmlValidityIssue->isWarningOnly()) {
                // We are dealing with a warning

                issueType = CellmlFileIssue::Warning;
            } else {
                // We are dealing with an error

                ++cellmlErrorsCount;

                issueType = CellmlFileIssue::Error;
            }

            // Append the issue to our list

            mIssues.append(CellmlFileIssue(issueType,
                                           QString::fromStdWString(cellmlValidityIssue->description()),
                                           line, column, importedFile));
        }

qDebug(" - CellML warnings vs. errors time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));

        if (cellmlErrorsCount)
            // There are CellML errors, so...

            mIsValid = false;
        else
            // Everything went as expected, so...

            mIsValid = true;

        mIsValidNeeded = false;

        return mIsValid;
    } else {
        // Something went wrong with the loading of the file, so...

        return false;
    }
}

//==============================================================================

CellmlFileIssues CellmlFile::issues()
{
    // Return the file's issue(s)

    return mIssues;
}

//==============================================================================

CellmlFileRuntime * CellmlFile::runtime()
{
    if (!mRuntimeUpdateNeeded)
        // There is no need for the runtime to be updated, so...

        return mRuntime;

    // Load (but not reload!) the file, if needed

    if (load()) {
        // The file is loaded, so return an updated version of its runtime

        mRuntime->update(mModel);

        mRuntimeUpdateNeeded = !mRuntime->isValid();

        return mRuntime;
    } else {
        // The file isn't valid, so reset its runtime

        return mRuntime->update();
    }
}

//==============================================================================

}   // namespace CellMLSupport
}   // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================
<commit_msg>Argh, the joy of developing a cross-platform application...<commit_after>//==============================================================================
// CellML file class
//==============================================================================

#include "cellmlfile.h"

//==============================================================================

#include <QTime>
#include <QUrl>

//==============================================================================

#ifdef Q_WS_X11
    #include <stdint.h>
    //---GRY--- THE ABOVE HEADER FILE IS REQUIRED ON LINUX, SO WE CAN USE
    //          uint32_t (SO WE CAN 'PROPERLY' MAKE USE OF THE CellML API). NOW,
    //          WE WOULD NORMALLY HAVE
    //              #include <cstdint>
    //          BUT THIS IS NOT CURRENTLY SUPPORTED BY THE CURRENT ISO C++
    //          STANDARD. INDEED, TO INCLUDE IT WILL GENERATE THE FOLLOWING
    //          ERROR AT COMPILE TIME:
    //              error: #error This file requires compiler and library
    //              support for the upcoming ISO C++ standard, C++0x. This
    //              support is currently experimental, and must be enabled with
    //              the -std=c++0x or -std=gnu++0x compiler options.
    //          AND WELL, WE DON'T WANT TO ENABLE EITHER OF THESE OPTIONS SINCE
    //          SUPPORT IS STILL ONLY EXPERIMENTAL, SO...
#endif

//==============================================================================

#include "IfaceVACSS.hxx"

#include "CellMLBootstrap.hpp"
#include "VACSSBootstrap.hpp"

//==============================================================================

namespace OpenCOR {
namespace CellMLSupport {

//==============================================================================

CellmlFile::CellmlFile(const QString &pFileName) :
    mFileName(pFileName)
{
    // Instantiate our runtime object

    mRuntime = new CellmlFileRuntime();

    // Reset ourselves

    reset();
}

//==============================================================================

CellmlFile::~CellmlFile()
{
    // Delete some internal objects

    delete mRuntime;
}

//==============================================================================

void CellmlFile::reset()
{
    // Reset all of the file's properties

    delete mModel; mModel = 0;

    mIssues.clear();

    mLoadingNeeded       = true;
    mIsValidNeeded       = true;
    mRuntimeUpdateNeeded = true;
}

//==============================================================================

bool CellmlFile::load()
{
    if (!mLoadingNeeded)
        // The file is already loaded, so...

        return true;

    // Reset any issues that we may have found before

    mIssues.clear();

    // Get a bootstrap object

    ObjRef<iface::cellml_api::CellMLBootstrap> cellmlBootstrap = CreateCellMLBootstrap();

    // Get its model loader

    ObjRef<iface::cellml_api::DOMModelLoader> modelLoader = cellmlBootstrap->modelLoader();

    // Try to load the model

qDebug("---------------------------------------");
qDebug("%s:", qPrintable(mFileName));

    try {
QTime time;

time.start();

        mModel = modelLoader->loadFromURL(QUrl::fromLocalFile(mFileName).toString().toStdWString().c_str());

qDebug(" - CellML Loading time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));
    } catch (iface::cellml_api::CellMLException &) {
        // Something went wrong with the loading of the model, so...

        mIssues.append(CellmlFileIssue(CellmlFileIssue::Error,
                                       tr("the model could not be loaded (%1)").arg(QString::fromStdWString(modelLoader->lastErrorMessage()))));

        return false;
    }

    // In the case of a non CellML 1.0 model, we want all imports to be fully
    // instantiated

    if (QString::fromStdWString(mModel->cellmlVersion()).compare(Cellml_1_0))
        try {
QTime time;

time.start();

            mModel->fullyInstantiateImports();

qDebug(" - CellML full instantiation time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));
        } catch (...) {
            // Something went wrong with the full instantiation of the imports,
            // so...

            reset();

            mIssues.append(CellmlFileIssue(CellmlFileIssue::Error,
                                           tr("the model's imports could not be fully instantiated")));

            return false;
        }

    // All done, so...

    mLoadingNeeded = false;

    return true;
}

//==============================================================================

bool CellmlFile::reload()
{
    // We want to reload the file, so we must first reset it

    reset();

    // Now, we can try to (re)load the file

    return load();
}

//==============================================================================

bool CellmlFile::isValid()
{
    if (!mIsValidNeeded)
        // The file has already been validated, so...

        return mIsValid;

    // Load (but not reload!) the file, if needed

    if (load()) {
        // The file was properly loaded (or was already loaded), so check
        // whether it is CellML valid
        // Note: validateModel() is somewhat slow, but there is (unfortunately)
        //       nothing we can do about it. Then, there is getPositionInXML()
        //       which is painfully slow, but unlike for validateModel() its use
        //       is not essential (even though it would be nice from an
        //       end-user's perspective). So, rather than retrieve the
        //       line/column of every single warning/error, we only keep track
        //       of the various warnings/errors and only retrieve their
        //       corresponding line/column when requested (definitely not neat
        //       from an end-user's perspective, but we just can't afford the
        //       time it takes to fully validate a model that has many
        //       warnings/errors)...

QTime time;

time.start();

        ObjRef<iface::cellml_services::VACSService> vacssService = CreateVACSService();
        ObjRef<iface::cellml_services::CellMLValidityErrorSet> cellmlValidityErrorSet = vacssService->validateModel(mModel);

qDebug(" - CellML validation time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));

        // Determine the number of errors and warnings
        // Note: CellMLValidityErrorSet::nValidityErrors() returns any type of
        //       validation issue, be it an error or a warning, so we need to
        //       determine the number of true errors

        int cellmlErrorsCount = 0;

time.restart();

        for (int i = 0, iMax = cellmlValidityErrorSet->nValidityErrors(); i < iMax; ++i) {
            ObjRef<iface::cellml_services::CellMLValidityError> cellmlValidityIssue = cellmlValidityErrorSet->getValidityError(i);

            DECLARE_QUERY_INTERFACE_OBJREF(cellmlRepresentationValidityError, cellmlValidityIssue,
                                           cellml_services::CellMLRepresentationValidityError);

            // Determine the issue's location

            uint32_t line = 0;
            uint32_t column = 0;
            QString importedFile = QString();

            if (cellmlRepresentationValidityError) {
                // We are dealing with a CellML representation issue, so
                // determine its line and column

                ObjRef<iface::dom::Node> errorNode = cellmlRepresentationValidityError->errorNode();

                line = vacssService->getPositionInXML(errorNode,
                                                      cellmlRepresentationValidityError->errorNodalOffset(),
                                                      &column);
            } else {
                // We are not dealing with a CellML representation issue, so
                // check whether we are dealing with a semantic one

                DECLARE_QUERY_INTERFACE_OBJREF(cellmlSemanticValidityError, cellmlValidityIssue,
                                               cellml_services::CellMLSemanticValidityError);

                if (cellmlSemanticValidityError) {
                    // We are dealing with a CellML semantic issue, so determine
                    // its line and column

                    ObjRef<iface::cellml_api::CellMLElement> cellmlElement = cellmlSemanticValidityError->errorElement();

                    DECLARE_QUERY_INTERFACE_OBJREF(cellmlDomElement, cellmlElement, cellml_api::CellMLDOMElement);

                    ObjRef<iface::dom::Element> domElement = cellmlDomElement->domElement();

                    line = vacssService->getPositionInXML(domElement, 0,
                                                          &column);

                    // Also determine its imported file, if any

                    while (true) {
                        // Retrieve the CellML element's parent

                        iface::cellml_api::CellMLElement *cellmlElementParent = already_AddRefd<iface::cellml_api::CellMLElement>(cellmlElement->parentElement());

                        if (!cellmlElementParent)
                            // There is no parent, so...

                            break;

                        // Check whether the parent is an imported file

                        DECLARE_QUERY_INTERFACE_OBJREF(importedCellmlFile,
                                                       cellmlElementParent,
                                                       cellml_api::Model);

                        if (!importedCellmlFile)
                            // This is not an imported file, so...

                            continue;

                        // Retrieve the imported CellML element

                        ObjRef<iface::cellml_api::CellMLElement> importedCellmlElement = importedCellmlFile->parentElement();

                        if (!importedCellmlElement)
                            // This is not an imported CellML element, so...

                            break;

                        // Check whether the imported CellML element is an
                        // import CellML element

                        DECLARE_QUERY_INTERFACE(importCellmlElement,
                                                importedCellmlElement,
                                                cellml_api::CellMLImport);

                        if (!importCellmlElement)
                            // This is not an import CellML element, so...

                            break;

                        ObjRef<iface::cellml_api::URI> href = importCellmlElement->xlinkHref();

                        importedFile = QString::fromStdWString(href->asText());

                        break;
                    }
                }
            }

            // Determine the issue's type

            CellmlFileIssue::Type issueType;

            if (cellmlValidityIssue->isWarningOnly()) {
                // We are dealing with a warning

                issueType = CellmlFileIssue::Warning;
            } else {
                // We are dealing with an error

                ++cellmlErrorsCount;

                issueType = CellmlFileIssue::Error;
            }

            // Append the issue to our list

            mIssues.append(CellmlFileIssue(issueType,
                                           QString::fromStdWString(cellmlValidityIssue->description()),
                                           line, column, importedFile));
        }

qDebug(" - CellML warnings vs. errors time: %s s", qPrintable(QString::number(0.001*time.elapsed(), 'g', 3)));

        if (cellmlErrorsCount)
            // There are CellML errors, so...

            mIsValid = false;
        else
            // Everything went as expected, so...

            mIsValid = true;

        mIsValidNeeded = false;

        return mIsValid;
    } else {
        // Something went wrong with the loading of the file, so...

        return false;
    }
}

//==============================================================================

CellmlFileIssues CellmlFile::issues()
{
    // Return the file's issue(s)

    return mIssues;
}

//==============================================================================

CellmlFileRuntime * CellmlFile::runtime()
{
    if (!mRuntimeUpdateNeeded)
        // There is no need for the runtime to be updated, so...

        return mRuntime;

    // Load (but not reload!) the file, if needed

    if (load()) {
        // The file is loaded, so return an updated version of its runtime

        mRuntime->update(mModel);

        mRuntimeUpdateNeeded = !mRuntime->isValid();

        return mRuntime;
    } else {
        // The file isn't valid, so reset its runtime

        return mRuntime->update();
    }
}

//==============================================================================

}   // namespace CellMLSupport
}   // namespace OpenCOR

//==============================================================================
// End of file
//==============================================================================
<|endoftext|>


<commit_before>#include <gtest/gtest.h>
#include <memory>
#include "Map.hpp"

std::shared_ptr<Map> testMap = std::make_shared<Map>();
std::vector<int> testMapArray1 {1,1,1,1,0,0,0,0,
			        0,0,0,1,1,0,0,0,
			        0,0,1,1,1,1,1,0,
			        1,1,1,1,1,1,1,0};

TEST(MapLoadMapTest, testLoadMapMethodWithDefaultMap)
{
    testMap->loadMap("../Data/data1.csv");
    ASSERT_EQ(testMap->returnColumn(), 8);
    ASSERT_EQ(testMap->returnRow(), 4);
    ASSERT_EQ(testMap->getMap(), testMapArray1);
}

<commit_msg>Task 2.1 removed dummy test and added test cases for Map class methods<commit_after>#include <gtest/gtest.h>
#include <memory>
#include "Map.hpp"

std::shared_ptr<Map> testMap = std::make_shared<Map>();
std::vector<int> testMapArray1 {1,1,1,1,0,0,0,0,
			        0,0,0,1,1,0,0,0,
			        0,0,1,1,1,1,1,0,
			        1,1,1,1,1,1,1,0};

TEST(MapLoadMapTest, testLoadMapMethodWithDefaultMap)
{
    testMap->loadMap("../Data/data1.csv");
    ASSERT_EQ(testMap->returnColumn(), 8);
    ASSERT_EQ(testMap->returnRow(), 4);
    ASSERT_EQ(testMap->getMap(), testMapArray1);
}

<|endoftext|>


<commit_before>/** \file   Main.cc
 *  \brief  Default main entry point.
 *  \author Dr. Johannes Ruscheinski (johannes.ruscheinski@uni-tuebingen.de)
 *
 *  \copyright 2018 Universitätsbibliothek Tübingen.  All rights reserved.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "Main.h"
#include <algorithm>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <cstdlib>
#include <cerrno>
#include "StringUtil.h"
#include "util.h"

namespace {

struct MainHandler {
    enum HandlerType { PROLOGUE, EPILOGUE };

    HandlerType type_;
    unsigned priority_;
    std::function<void()> handler_;
public:
    MainHandler(const HandlerType type, const unsigned priority, const std::function<void()> &handler)
        : type_(type), priority_(priority), handler_(handler) {}
};

bool MainHandlerComparator(const MainHandler &a, const MainHandler &b) {
    return a.priority_ > b.priority_;
}

std::vector<MainHandler> * GetHandlers(const MainHandler::HandlerType type) {
    static std::vector<MainHandler> prologue_handlers;
    static std::vector<MainHandler> epilogue_handlers;

    switch (type) {
    case MainHandler::HandlerType::PROLOGUE:
        return &prologue_handlers;
    case MainHandler::HandlerType::EPILOGUE:
        return &epilogue_handlers;
    default:
        LOG_ERROR("unknown handler type " + std::to_string(type));
    }

    return nullptr;
}

void RunHandlers(const MainHandler::HandlerType type) {
    const auto handlers(GetHandlers(type));

    for (const auto &handler : *handlers)
        handler.handler_();
}

bool prologue_handlers_finalised(false);
bool epilogue_handlers_finalised(false);

} // unnamed namespace

void RegisterProgramPrologueHandler(const unsigned priority, const std::function<void()> &handler) {
    if (prologue_handlers_finalised)
        LOG_ERROR("prologue handlers have already been finalised!");

    GetHandlers(MainHandler::HandlerType::PROLOGUE)->emplace_back(MainHandler::HandlerType::PROLOGUE, priority, handler);
}

void RegisterProgramEpilogueHandler(const unsigned priority, const std::function<void()> &handler) {
    if (epilogue_handlers_finalised)
        LOG_ERROR("epilogue handlers have already been finalised!");

    GetHandlers(MainHandler::HandlerType::EPILOGUE)->emplace_back(MainHandler::HandlerType::EPILOGUE, priority, handler);
}

int main(int argc, char *argv[]) {
    ::progname = argv[0];

    Logger::LogLevel log_level(Logger::LL_INFO);
    if (argc > 1 and StringUtil::StartsWith(argv[1], "--min-log-level=")) {
        const std::string level(argv[1] + __builtin_strlen("--min-log-level="));
        if (level == "ERROR")
            log_level = Logger::LL_ERROR;
        else if (level == "WARNING")
            log_level = Logger::LL_WARNING;
        else if (level == "INFO")
            log_level = Logger::LL_INFO;
        else if (level == "DEBUG")
            log_level = Logger::LL_DEBUG;
        else
            LOG_ERROR("unknown log level \"" + level + "\"!");
        --argc, ++argv;
    }
    logger->setMinimumLogLevel(log_level);

    try {
        errno = 0;
        prologue_handlers_finalised = true;
        std::sort(GetHandlers(MainHandler::HandlerType::PROLOGUE)->begin(), GetHandlers(MainHandler::HandlerType::PROLOGUE)->end(),
                  MainHandlerComparator);
        RunHandlers(MainHandler::HandlerType::PROLOGUE);

        const auto ret_code(Main(argc, argv));

        epilogue_handlers_finalised = true;
        std::sort(GetHandlers(MainHandler::HandlerType::EPILOGUE)->begin(), GetHandlers(MainHandler::HandlerType::EPILOGUE)->end(),
                  MainHandlerComparator);
        RunHandlers(MainHandler::HandlerType::EPILOGUE);

        return ret_code;
    } catch (const std::exception &x) {
        LOG_ERROR("caught exception: " + std::string(x.what()));
    }
}
<commit_msg>Final nit<commit_after>/** \file   Main.cc
 *  \brief  Default main entry point.
 *  \author Dr. Johannes Ruscheinski (johannes.ruscheinski@uni-tuebingen.de)
 *
 *  \copyright 2018 Universitätsbibliothek Tübingen.  All rights reserved.
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU Affero General Public License as
 *  published by the Free Software Foundation, either version 3 of the
 *  License, or (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Affero General Public License for more details.
 *
 *  You should have received a copy of the GNU Affero General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "Main.h"
#include <algorithm>
#include <memory>
#include <stdexcept>
#include <string>
#include <vector>
#include <cerrno>
#include <cstdlib>
#include "StringUtil.h"
#include "util.h"

namespace {

struct MainHandler {
    enum HandlerType { PROLOGUE, EPILOGUE };

    HandlerType type_;
    unsigned priority_;
    std::function<void()> handler_;
public:
    MainHandler(const HandlerType type, const unsigned priority, const std::function<void()> &handler)
        : type_(type), priority_(priority), handler_(handler) {}
};

bool MainHandlerComparator(const MainHandler &a, const MainHandler &b) {
    return a.priority_ > b.priority_;
}

std::vector<MainHandler> * GetHandlers(const MainHandler::HandlerType type) {
    static std::vector<MainHandler> prologue_handlers;
    static std::vector<MainHandler> epilogue_handlers;

    switch (type) {
    case MainHandler::HandlerType::PROLOGUE:
        return &prologue_handlers;
    case MainHandler::HandlerType::EPILOGUE:
        return &epilogue_handlers;
    default:
        LOG_ERROR("unknown handler type " + std::to_string(type));
    }

    return nullptr;
}

void RunHandlers(const MainHandler::HandlerType type) {
    const auto handlers(GetHandlers(type));

    for (const auto &handler : *handlers)
        handler.handler_();
}

bool prologue_handlers_finalised(false);
bool epilogue_handlers_finalised(false);

} // unnamed namespace

void RegisterProgramPrologueHandler(const unsigned priority, const std::function<void()> &handler) {
    if (prologue_handlers_finalised)
        LOG_ERROR("prologue handlers have already been finalised!");

    GetHandlers(MainHandler::HandlerType::PROLOGUE)->emplace_back(MainHandler::HandlerType::PROLOGUE, priority, handler);
}

void RegisterProgramEpilogueHandler(const unsigned priority, const std::function<void()> &handler) {
    if (epilogue_handlers_finalised)
        LOG_ERROR("epilogue handlers have already been finalised!");

    GetHandlers(MainHandler::HandlerType::EPILOGUE)->emplace_back(MainHandler::HandlerType::EPILOGUE, priority, handler);
}

int main(int argc, char *argv[]) {
    ::progname = argv[0];

    Logger::LogLevel log_level(Logger::LL_INFO);
    if (argc > 1 and StringUtil::StartsWith(argv[1], "--min-log-level=")) {
        const std::string level(argv[1] + __builtin_strlen("--min-log-level="));
        if (level == "ERROR")
            log_level = Logger::LL_ERROR;
        else if (level == "WARNING")
            log_level = Logger::LL_WARNING;
        else if (level == "INFO")
            log_level = Logger::LL_INFO;
        else if (level == "DEBUG")
            log_level = Logger::LL_DEBUG;
        else
            LOG_ERROR("unknown log level \"" + level + "\"!");
        --argc, ++argv;
    }
    logger->setMinimumLogLevel(log_level);

    try {
        errno = 0;
        prologue_handlers_finalised = true;
        std::sort(GetHandlers(MainHandler::HandlerType::PROLOGUE)->begin(), GetHandlers(MainHandler::HandlerType::PROLOGUE)->end(),
                  MainHandlerComparator);
        RunHandlers(MainHandler::HandlerType::PROLOGUE);

        const auto ret_code(Main(argc, argv));

        epilogue_handlers_finalised = true;
        std::sort(GetHandlers(MainHandler::HandlerType::EPILOGUE)->begin(), GetHandlers(MainHandler::HandlerType::EPILOGUE)->end(),
                  MainHandlerComparator);
        RunHandlers(MainHandler::HandlerType::EPILOGUE);

        return ret_code;
    } catch (const std::exception &x) {
        LOG_ERROR("caught exception: " + std::string(x.what()));
    }
}
<|endoftext|>