<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: mailmrge.hxx,v $
 *
 *  $Revision: 1.13 $
 *
 *  last change: $Author: rt $ $Date: 2007-07-05 07:41:35 $
 *
 *  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 _MAILMRGE_HXX
#define _MAILMRGE_HXX

#ifndef _SVX_STDDLG_HXX //autogen
#include <svx/stddlg.hxx>
#endif

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif

#ifndef _STDCTRL_HXX
#include <svtools/stdctrl.hxx>
#endif

#ifndef _LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
#include <com/sun/star/uno/Sequence.h>
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif

class SwWrtShell;
class SwModuleOptions;
class SwXSelChgLstnr_Impl;
struct SwMailMergeDlg_Impl;
namespace com{namespace sun{namespace star{
    namespace frame{
        class XFrame;
    }
    namespace sdbc{
        class XResultSet;
        class XConnection;
    }
}}}

class SwMailMergeDlg : public SvxStandardDialog
{
    friend class SwXSelChgLstnr_Impl;

    Window*         pBeamerWin;

    RadioButton     aAllRB;
    RadioButton     aMarkedRB;
    RadioButton     aFromRB;
    NumericField    aFromNF;
    FixedText       aBisFT;
    NumericField    aToNF;
    FixedLine       aRecordFL;

    FixedLine       aSeparatorFL;

    RadioButton     aPrinterRB;
    RadioButton     aMailingRB;
    RadioButton     aFileRB;

    CheckBox        aSingleJobsCB;

    FixedLine       aSaveMergedDocumentFL;
    RadioButton     aSaveSingleDocRB;
    RadioButton     aSaveIndividualRB;

    CheckBox        aGenerateFromDataBaseCB;

    FixedText       aColumnFT;
    ListBox         aColumnLB;
    FixedText       aPathFT;
    Edit            aPathED;
    PushButton      aPathPB;
    FixedText       aFilterFT;
    ListBox         aFilterLB;

    ListBox         aAddressFldLB;
    FixedText       aSubjectFT;
    Edit            aSubjectED;
    FixedText       aFormatFT;
    FixedText       aAttachFT;
    Edit            aAttachED;
    PushButton      aAttachPB;
    CheckBox        aFormatHtmlCB;
    CheckBox        aFormatRtfCB;
    CheckBox        aFormatSwCB;
    FixedLine       aDestFL;

    FixedLine       aBottomSeparatorFL;

    OKButton        aOkBTN;
    CancelButton    aCancelBTN;
    HelpButton      aHelpBTN;

    SwMailMergeDlg_Impl* pImpl;

    SwWrtShell&     rSh;
    SwModuleOptions* pModOpt;
    const String&   rDBName;
    const String&   rTableName;

    USHORT          nMergeType;
    ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >       m_aSelection;
    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;

    Size            m_aDialogSize;
    ::rtl::OUString m_sSaveFilter;

    DECL_LINK( ButtonHdl, Button* pBtn );
    DECL_LINK( InsertPathHdl, PushButton * );
    DECL_LINK( AttachFileHdl, PushButton * );
    DECL_LINK( OutputTypeHdl, RadioButton* pBtn );
    DECL_LINK( FilenameHdl, CheckBox* pBtn );
    DECL_LINK( ModifyHdl, NumericField* pLB );
    DECL_LINK( SaveTypeHdl, RadioButton* pBtn );

    virtual void    Apply();
    virtual void    Resize();
    bool            ExecQryShell();

public:
     SwMailMergeDlg(Window* pParent, SwWrtShell& rSh,
         const String& rSourceName,
        const String& rTblName,
        sal_Int32 nCommandType,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& xConnection,
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >* pSelection = 0);
    ~SwMailMergeDlg();

    inline USHORT   GetMergeType() { return nMergeType; }
    const ::rtl::OUString& GetSaveFilter() const {return m_sSaveFilter;}
    inline const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > GetSelection() const { return m_aSelection; }
    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const;

};
/* -----------------27.11.2002 12:05-----------------
 *
 * --------------------------------------------------*/
class SwMailMergeCreateFromDlg : public ModalDialog
{
    FixedLine       aCreateFromFL;
    RadioButton     aThisDocRB;
    RadioButton     aUseTemplateRB;

    OKButton        aOK;
    CancelButton    aCancel;
    HelpButton      aHelp;
public:
    SwMailMergeCreateFromDlg(Window* pParent);
    ~SwMailMergeCreateFromDlg();

    BOOL    IsThisDocument() const {return aThisDocRB.IsChecked();}
};
/* -----------------04.02.2003 13:41-----------------
 *
 * --------------------------------------------------*/
class SwMailMergeFieldConnectionsDlg : public ModalDialog
{
    FixedLine       aConnectionsFL;
    RadioButton     aUseExistingRB;
    RadioButton     aCreateNewRB;

    FixedInfo       aInfoFI;

    OKButton        aOK;
    CancelButton    aCancel;
    HelpButton      aHelp;
public:
    SwMailMergeFieldConnectionsDlg(Window* pParent);
    ~SwMailMergeFieldConnectionsDlg();

    BOOL    IsUseExistingConnections() const {return aUseExistingRB.IsChecked();}
};

#endif

<commit_msg>INTEGRATION: CWS swwarnings (1.12.710); FILE MERGED 2007/08/20 15:52:56 tl 1.12.710.2: RESYNC: (1.12-1.13); FILE MERGED 2007/03/26 12:09:08 tl 1.12.710.1: #i69287# warning-free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: mailmrge.hxx,v $
 *
 *  $Revision: 1.14 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 12:04:46 $
 *
 *  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 _MAILMRGE_HXX
#define _MAILMRGE_HXX

#ifndef _SVX_STDDLG_HXX //autogen
#include <svx/stddlg.hxx>
#endif

#ifndef _BUTTON_HXX //autogen
#include <vcl/button.hxx>
#endif

#ifndef _FIELD_HXX //autogen
#include <vcl/field.hxx>
#endif

#ifndef _FIXED_HXX //autogen
#include <vcl/fixed.hxx>
#endif
#ifndef _EDIT_HXX //autogen
#include <vcl/edit.hxx>
#endif

#ifndef _STDCTRL_HXX
#include <svtools/stdctrl.hxx>
#endif

#ifndef _LSTBOX_HXX //autogen
#include <vcl/lstbox.hxx>
#endif
#ifndef _COM_SUN_STAR_UNO_SEQUENCE_H_
#include <com/sun/star/uno/Sequence.h>
#endif
#ifndef _COM_SUN_STAR_UNO_REFERENCE_H_
#include <com/sun/star/uno/Reference.h>
#endif

class SwWrtShell;
class SwModuleOptions;
class SwXSelChgLstnr_Impl;
struct SwMailMergeDlg_Impl;
namespace com{namespace sun{namespace star{
    namespace frame{
        class XFrame;
    }
    namespace sdbc{
        class XResultSet;
        class XConnection;
    }
}}}

class SwMailMergeDlg : public SvxStandardDialog
{
    friend class SwXSelChgLstnr_Impl;

    Window*         pBeamerWin;

    RadioButton     aAllRB;
    RadioButton     aMarkedRB;
    RadioButton     aFromRB;
    NumericField    aFromNF;
    FixedText       aBisFT;
    NumericField    aToNF;
    FixedLine       aRecordFL;

    FixedLine       aSeparatorFL;

    RadioButton     aPrinterRB;
    RadioButton     aMailingRB;
    RadioButton     aFileRB;

    CheckBox        aSingleJobsCB;

    FixedLine       aSaveMergedDocumentFL;
    RadioButton     aSaveSingleDocRB;
    RadioButton     aSaveIndividualRB;

    CheckBox        aGenerateFromDataBaseCB;

    FixedText       aColumnFT;
    ListBox         aColumnLB;
    FixedText       aPathFT;
    Edit            aPathED;
    PushButton      aPathPB;
    FixedText       aFilterFT;
    ListBox         aFilterLB;

    ListBox         aAddressFldLB;
    FixedText       aSubjectFT;
    Edit            aSubjectED;
    FixedText       aFormatFT;
    FixedText       aAttachFT;
    Edit            aAttachED;
    PushButton      aAttachPB;
    CheckBox        aFormatHtmlCB;
    CheckBox        aFormatRtfCB;
    CheckBox        aFormatSwCB;
    FixedLine       aDestFL;

    FixedLine       aBottomSeparatorFL;

    OKButton        aOkBTN;
    CancelButton    aCancelBTN;
    HelpButton      aHelpBTN;

    SwMailMergeDlg_Impl* pImpl;

    SwWrtShell&     rSh;
    SwModuleOptions* pModOpt;
    const String&   rDBName;
    const String&   rTableName;

    USHORT          nMergeType;
    ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >       m_aSelection;
    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > xFrame;

    Size            m_aDialogSize;
    ::rtl::OUString m_sSaveFilter;

    DECL_LINK( ButtonHdl, Button* pBtn );
    DECL_LINK( InsertPathHdl, PushButton * );
    DECL_LINK( AttachFileHdl, PushButton * );
    DECL_LINK( OutputTypeHdl, RadioButton* pBtn );
    DECL_LINK( FilenameHdl, CheckBox* pBtn );
    DECL_LINK( ModifyHdl, NumericField* pLB );
    DECL_LINK( SaveTypeHdl, RadioButton* pBtn );

    virtual void    Apply();
    virtual void    Resize();
    bool            ExecQryShell();

public:
     SwMailMergeDlg(Window* pParent, SwWrtShell& rSh,
         const String& rSourceName,
        const String& rTblName,
        sal_Int32 nCommandType,
        const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& xConnection,
        ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >* pSelection = 0);
    ~SwMailMergeDlg();

    inline USHORT   GetMergeType() { return nMergeType; }
    const ::rtl::OUString& GetSaveFilter() const {return m_sSaveFilter;}
    inline const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > GetSelection() const { return m_aSelection; }
    ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet> GetResultSet() const;

};
/* -----------------27.11.2002 12:05-----------------
 *
 * --------------------------------------------------*/
class SwMailMergeCreateFromDlg : public ModalDialog
{
    FixedLine       aCreateFromFL;
    RadioButton     aThisDocRB;
    RadioButton     aUseTemplateRB;

    OKButton        aOK;
    CancelButton    aCancel;
    HelpButton      aHelp;
public:
    SwMailMergeCreateFromDlg(Window* pParent);
    ~SwMailMergeCreateFromDlg();

    BOOL    IsThisDocument() const {return aThisDocRB.IsChecked();}
};
/* -----------------04.02.2003 13:41-----------------
 *
 * --------------------------------------------------*/
class SwMailMergeFieldConnectionsDlg : public ModalDialog
{
    FixedLine       aConnectionsFL;
    RadioButton     aUseExistingRB;
    RadioButton     aCreateNewRB;

    FixedInfo       aInfoFI;

    OKButton        aOK;
    CancelButton    aCancel;
    HelpButton      aHelp;
public:
    SwMailMergeFieldConnectionsDlg(Window* pParent);
    ~SwMailMergeFieldConnectionsDlg();

    BOOL    IsUseExistingConnections() const {return aUseExistingRB.IsChecked();}
};

#endif

<|endoftext|>


<commit_before>/*
Copyright (c) 2006-2008 Advanced Micro Devices, Inc. All Rights Reserved.
This software is subject to the Apache v2.0 License.
*/

#include "Arithmetic/Def/SubDef.h"
#include "fwSignal.h"

using namespace OPT_LEVEL;

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s		)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw16s* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s<0> data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> > (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32f		)(const Fw32f* pSrc1, const Fw32f* pSrc2, Fw32f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32f> (data, pSrc1, pSrc2, pDst, len);
}

//Begin:[SKiran] Sub_64s declaration
FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64s		)(const Fw64s* pSrc1, const Fw64s* pSrc2, Fw64s* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64s data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64s> (data, pSrc1, pSrc2, pDst, len);
}
//End:[SKiran] Sub_64s declaration

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64f		)(const Fw64f* pSrc1, const Fw64f* pSrc2, Fw64f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64f> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32fc		)(const Fw32fc* pSrc1, const Fw32fc* pSrc2, Fw32fc* pDst,int len)
{
	DEF_SUB::SUB::C1::Sub_32fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32fc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64fc		)(const Fw64fc* pSrc1, const Fw64fc* pSrc2, Fw64fc* pDst,int len)
{
	DEF_SUB::SUB::C1::Sub_64fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64fc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_I		)(const Fw16s* pSrc, Fw16s* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s<0> data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> >(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32f_I		)(const Fw32f* pSrc, Fw32f* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32f>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64f_I		)(const Fw64f* pSrc, Fw64f* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64f>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32fc_I	)(const Fw32fc* pSrc, Fw32fc* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32fc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64fc_I	)(const Fw64fc* pSrc, Fw64fc* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64fc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_8u_Sfs	)(const Fw8u* pSrc1, const Fw8u* pSrc2, Fw8u* pDst,int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_8u<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_Sfs	)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw16s*pDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16s<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32s_Sfs	)(const Fw32s* pSrc1, const Fw32s* pSrc2, Fw32s*pDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32s data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32s> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16sc_Sfs	)(const Fw16sc* pSrc1, const Fw16sc* pSrc2, Fw16sc* pDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16sc<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32sc_Sfs	)(const Fw32sc* pSrc1, const Fw32sc* pSrc2, Fw32sc* pDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32sc data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32sc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_8u_ISfs	)(const Fw8u* pSrc, Fw8u* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_8u<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_ISfs	)(const Fw16s* pSrc, Fw16s* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16s<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32s_ISfs	)(const Fw32s* pSrc, Fw32s* pSrcDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32s data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32s>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16sc_ISfs	)(const Fw16sc* pSrc, Fw16sc* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16sc<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32sc_ISfs	)(const Fw32sc* pSrc, Fw32sc* pSrcDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32sc data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32sc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s32f			)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw32f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s32f data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s32f >(data, pSrc1, pSrc2, pDst, len);
}

// Please do NOT remove the above line for CPP files that need to be multipass compiled
// OREFR OSSE2 OF10H
<commit_msg>Removed comments around sub_64s function definition.<commit_after>/*
Copyright (c) 2006-2008 Advanced Micro Devices, Inc. All Rights Reserved.
This software is subject to the Apache v2.0 License.
*/

#include "Arithmetic/Def/SubDef.h"
#include "fwSignal.h"

using namespace OPT_LEVEL;

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s		)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw16s* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s<0> data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> > (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32f		)(const Fw32f* pSrc1, const Fw32f* pSrc2, Fw32f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32f> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64s		)(const Fw64s* pSrc1, const Fw64s* pSrc2, Fw64s* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64s data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64s> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64f		)(const Fw64f* pSrc1, const Fw64f* pSrc2, Fw64f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64f> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32fc		)(const Fw32fc* pSrc1, const Fw32fc* pSrc2, Fw32fc* pDst,int len)
{
	DEF_SUB::SUB::C1::Sub_32fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32fc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64fc		)(const Fw64fc* pSrc1, const Fw64fc* pSrc2, Fw64fc* pDst,int len)
{
	DEF_SUB::SUB::C1::Sub_64fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64fc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_I		)(const Fw16s* pSrc, Fw16s* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s<0> data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> >(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32f_I		)(const Fw32f* pSrc, Fw32f* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32f>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64f_I		)(const Fw64f* pSrc, Fw64f* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64f data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64f>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32fc_I	)(const Fw32fc* pSrc, Fw32fc* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_32fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32fc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_64fc_I	)(const Fw64fc* pSrc, Fw64fc* pSrcDst, int len)
{
	DEF_SUB::SUB::C1::Sub_64fc data;
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_64fc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_8u_Sfs	)(const Fw8u* pSrc1, const Fw8u* pSrc2, Fw8u* pDst,int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_8u<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_Sfs	)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw16s*pDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16s<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32s_Sfs	)(const Fw32s* pSrc1, const Fw32s* pSrc2, Fw32s*pDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32s data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32s> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16sc_Sfs	)(const Fw16sc* pSrc1, const Fw16sc* pSrc2, Fw16sc* pDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<0> > (data, pSrc1, pSrc2, pDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<-1> >(data, pSrc1, pSrc2, pDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16sc<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<1> > (data, pSrc1, pSrc2, pDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32sc_Sfs	)(const Fw32sc* pSrc1, const Fw32sc* pSrc2, Fw32sc* pDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32sc data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32sc> (data, pSrc1, pSrc2, pDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_8u_ISfs	)(const Fw8u* pSrc, Fw8u* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_8u<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_8u<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_8u<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s_ISfs	)(const Fw16s* pSrc, Fw16s* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16s<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16s<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32s_ISfs	)(const Fw32s* pSrc, Fw32s* pSrcDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32s data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32s>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16sc_ISfs	)(const Fw16sc* pSrc, Fw16sc* pSrcDst, int len, int scaleFactor)
{
	if(scaleFactor == 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<0> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<0> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else if(scaleFactor < 0)
	{
		DEF_SUB::SUB::C1::Sub_16sc<-1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<-1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
	else
	{
		DEF_SUB::SUB::C1::Sub_16sc<1> data(scaleFactor);
		return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16sc<1> >(data, pSrc, pSrcDst, pSrcDst, len);
	}
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_32sc_ISfs	)(const Fw32sc* pSrc, Fw32sc* pSrcDst, int len, int scaleFactor)
{
	DEF_SUB::SUB::C1::Sub_32sc data(scaleFactor);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_32sc>(data, pSrc, pSrcDst, pSrcDst, len);
}

FwStatus PREFIX_OPT(OPT_PREFIX, fwsSub_16s32f			)(const Fw16s* pSrc1, const Fw16s* pSrc2, Fw32f* pDst, int len)
{
	DEF_SUB::SUB::C1::Sub_16s32f data(0);
	return OPT_LEVEL::fe< DEF_SUB::SUB::C1::Sub_16s32f >(data, pSrc1, pSrc2, pDst, len);
}

// Please do NOT remove the above line for CPP files that need to be multipass compiled
// OREFR OSSE2 OF10H
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: paminit.cxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: jp $ $Date: 2002-02-01 12:37:59 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#ifdef PRECOMPILED
#include "core_pch.hxx"
#endif

#pragma hdrstop

#ifndef _PAMTYP_HXX
#include <pamtyp.hxx>
#endif

static SwMoveFnCollection aFwrd = {
    /* fnNd         */  &GoNext,
    /* fnNds        */  &GoNextNds,
    /* fnDoc        */  &GoEndDoc,
    /* fnSections   */  &GoEndSection,
    /* fnCmpOp      */  &SwPosition::operator<,
    /* fnGetHint    */  &GetFrwrdTxtHint,
    /* fnSearch     */  &utl::TextSearch::SearchFrwrd,
    /* fnSection    */  &SwNodes::GoStartOfSection
};

static SwMoveFnCollection aBwrd = {
    /* fnNd         */  &GoPrevious,
    /* fnNds        */  &GoPreviousNds,
    /* fnDoc        */  &GoStartDoc,
    /* fnSections   */  &GoStartSection,
    /* fnCmpOp      */  &SwPosition::operator>,
    /* fnGetHint    */  &GetBkwrdTxtHint,
    /* fnSearch     */  &utl::TextSearch::SearchBkwrd,
    /* fnSection    */  &SwNodes::GoEndOfSection
};

SwGoInDoc fnGoDoc       = &GoInDoc;
SwGoInDoc fnGoSection   = &GoInSection;
SwGoInDoc fnGoNode      = &GoInNode;
SwGoInDoc fnGoCntnt     = &GoInCntnt;
SwGoInDoc fnGoCntntCells= &GoInCntntCells;

SwWhichPara fnParaPrev  = &GoPrevPara;
SwWhichPara fnParaCurr  = &GoCurrPara;
SwWhichPara fnParaNext  = &GoNextPara;
SwPosPara fnParaStart   = &aFwrd;
SwPosPara fnParaEnd     = &aBwrd;

SwWhichSection fnSectionPrev    = &GoPrevSection;
SwWhichSection fnSectionCurr    = &GoCurrSection;
SwWhichSection fnSectionNext    = &GoNextSection;
SwPosSection fnSectionStart     = &aFwrd;
SwPosSection fnSectionEnd       = &aBwrd;

// Travelling in Tabellen
FASTBOOL GotoPrevTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );
FASTBOOL GotoNextTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );

SwWhichTable fnTablePrev = &GotoPrevTable;
SwWhichTable fnTableCurr = &GotoCurrTable;
SwWhichTable fnTableNext = &GotoNextTable;
SwPosTable fnTableStart = &aFwrd;
SwPosTable fnTableEnd = &aBwrd;

// Travelling in Bereichen
FASTBOOL GotoPrevRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrRegionAndSkip( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoNextRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );

SwWhichRegion fnRegionPrev = &GotoPrevRegion;
SwWhichRegion fnRegionCurr = &GotoCurrRegion;
SwWhichRegion fnRegionCurrAndSkip = &GotoCurrRegionAndSkip;
SwWhichRegion fnRegionNext = &GotoNextRegion;
SwPosRegion fnRegionStart = &aFwrd;
SwPosRegion fnRegionEnd = &aBwrd;

SwMoveFn fnMoveBackward = &aBwrd;
SwMoveFn fnMoveForward  = &aFwrd;

#ifdef USED

// JP 30.11.95:
//  war fuer die CFRONT-Compiler noetig, jetzt sollte das nicht mehr
//  benoetigt werden.

void _InitPam()
{
    aBwrd.fnNd      =  &GoPrevious;
    aBwrd.fnNds     =  &GoPreviousNds;
    aBwrd.fnDoc     =  &GoStartDoc;
    aBwrd.fnSections=  &GoStartSection;
    aBwrd.fnCmpOp   =  &SwPosition::operator>;
    aBwrd.fnGetHint =  &GetBkwrdTxtHint;
    aBwrd.fnSearch  =  &SearchText::SearchBkwrd;
    aBwrd.fnSection =  &SwNodes::GoEndOfSection;

    aFwrd.fnNd      =  &GoNext;
    aFwrd.fnNds     =  &GoNextNds;
    aFwrd.fnDoc     =  &GoEndDoc;
    aFwrd.fnSections=  &GoEndSection;
    aFwrd.fnCmpOp   =  &SwPosition::operator<;
    aFwrd.fnGetHint =  &GetFrwrdTxtHint;
    aFwrd.fnSearch  =  &SearchText::SearchFrwrd;
    aFwrd.fnSection =  &SwNodes::GoStartOfSection;
}
#endif

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

#pragma hdrstop

#ifndef _PAMTYP_HXX
#include <pamtyp.hxx>
#endif

static SwMoveFnCollection aFwrd = {
    /* fnNd         */  &GoNext,
    /* fnNds        */  &GoNextNds,
    /* fnDoc        */  &GoEndDoc,
    /* fnSections   */  &GoEndSection,
    /* fnCmpOp      */  &SwPosition::operator<,
    /* fnGetHint    */  &GetFrwrdTxtHint,
    /* fnSearch     */  &utl::TextSearch::SearchFrwrd,
    /* fnSection    */  &SwNodes::GoStartOfSection
};

static SwMoveFnCollection aBwrd = {
    /* fnNd         */  &GoPrevious,
    /* fnNds        */  &GoPreviousNds,
    /* fnDoc        */  &GoStartDoc,
    /* fnSections   */  &GoStartSection,
    /* fnCmpOp      */  &SwPosition::operator>,
    /* fnGetHint    */  &GetBkwrdTxtHint,
    /* fnSearch     */  &utl::TextSearch::SearchBkwrd,
    /* fnSection    */  &SwNodes::GoEndOfSection
};

SwGoInDoc fnGoDoc       = &GoInDoc;
SwGoInDoc fnGoSection   = &GoInSection;
SwGoInDoc fnGoNode      = &GoInNode;
SwGoInDoc fnGoCntnt     = &GoInCntnt;
SwGoInDoc fnGoCntntCells= &GoInCntntCells;

SwWhichPara fnParaPrev  = &GoPrevPara;
SwWhichPara fnParaCurr  = &GoCurrPara;
SwWhichPara fnParaNext  = &GoNextPara;
SwPosPara fnParaStart   = &aFwrd;
SwPosPara fnParaEnd     = &aBwrd;

SwWhichSection fnSectionPrev    = &GoPrevSection;
SwWhichSection fnSectionCurr    = &GoCurrSection;
SwWhichSection fnSectionNext    = &GoNextSection;
SwPosSection fnSectionStart     = &aFwrd;
SwPosSection fnSectionEnd       = &aBwrd;

// Travelling in Tabellen
FASTBOOL GotoPrevTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );
FASTBOOL GotoNextTable( SwPaM&, SwPosTable, FASTBOOL bInReadOnly );

SwWhichTable fnTablePrev = &GotoPrevTable;
SwWhichTable fnTableCurr = &GotoCurrTable;
SwWhichTable fnTableNext = &GotoNextTable;
SwPosTable fnTableStart = &aFwrd;
SwPosTable fnTableEnd = &aBwrd;

// Travelling in Bereichen
FASTBOOL GotoPrevRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoCurrRegionAndSkip( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );
FASTBOOL GotoNextRegion( SwPaM&, SwPosRegion, FASTBOOL bInReadOnly );

SwWhichRegion fnRegionPrev = &GotoPrevRegion;
SwWhichRegion fnRegionCurr = &GotoCurrRegion;
SwWhichRegion fnRegionCurrAndSkip = &GotoCurrRegionAndSkip;
SwWhichRegion fnRegionNext = &GotoNextRegion;
SwPosRegion fnRegionStart = &aFwrd;
SwPosRegion fnRegionEnd = &aBwrd;

SwMoveFn fnMoveBackward = &aBwrd;
SwMoveFn fnMoveForward  = &aFwrd;

#ifdef USED

// JP 30.11.95:
//  war fuer die CFRONT-Compiler noetig, jetzt sollte das nicht mehr
//  benoetigt werden.

void _InitPam()
{
    aBwrd.fnNd      =  &GoPrevious;
    aBwrd.fnNds     =  &GoPreviousNds;
    aBwrd.fnDoc     =  &GoStartDoc;
    aBwrd.fnSections=  &GoStartSection;
    aBwrd.fnCmpOp   =  &SwPosition::operator>;
    aBwrd.fnGetHint =  &GetBkwrdTxtHint;
    aBwrd.fnSearch  =  &SearchText::SearchBkwrd;
    aBwrd.fnSection =  &SwNodes::GoEndOfSection;

    aFwrd.fnNd      =  &GoNext;
    aFwrd.fnNds     =  &GoNextNds;
    aFwrd.fnDoc     =  &GoEndDoc;
    aFwrd.fnSections=  &GoEndSection;
    aFwrd.fnCmpOp   =  &SwPosition::operator<;
    aFwrd.fnGetHint =  &GetFrwrdTxtHint;
    aFwrd.fnSearch  =  &SearchText::SearchFrwrd;
    aFwrd.fnSection =  &SwNodes::GoStartOfSection;
}
#endif

<|endoftext|>


<commit_before>/*************************************************
 * Solution to question 2.2 - Return Kth to Last
 *
 * Status: INCOMPLETE
*************************************************/

#include <iostream>

#include "../snode.h"
#include "../slist.h"

using namespace std;
using namespace ctci;

class SListSub : public SList {
    public:
        SListSub(int data);
        ~SListSub();

        SNode * kth_to_last(size_t k);
};

SListSub::SListSub(int data) : SList(data) {}

SListSub::~SListSub() {}

SNode * SListSub::kth_to_last(size_t k) {
    SNode *target = this->head;

    for (size_t i = 0; i < (this->size - k); i++) {
        target = target->getNext();
    }

    return target;
}

void print_slist(ostream &file, SListSub &slist) {
    SNode *ptr = slist.getHead();

    do {
        file << ptr->getData() << endl;
        ptr = ptr->getNext();
    }
    while (ptr != NULL);
}

int main(void) {
    SListSub slist(7);
    slist.add(4);
    slist.add(2);   // Target
    slist.add(1);   // 2nd to last
    slist.add(5);

    size_t k = 3;
    SNode *node = slist.kth_to_last(k);
    cout << "Retrieving k = " << k << " from last node" << endl;
    cout << node->getData() << endl;

    return EXIT_SUCCESS;
}
<commit_msg>Updated comments for question 2.2<commit_after>/*************************************************
 * Solution to question 2.2 - Return Kth to Last
 *
 * This solution assumes that the list size
 * is known.
 *
 * Status: COMPLETE
*************************************************/

#include <iostream>

#include "../snode.h"
#include "../slist.h"

using namespace std;
using namespace ctci;

class SListSub : public SList {
    public:
        SListSub(int data);
        ~SListSub();

        SNode * kth_to_last(size_t k);
};

SListSub::SListSub(int data) : SList(data) {}

SListSub::~SListSub() {}

SNode * SListSub::kth_to_last(size_t k) {
    SNode *target = this->head;

    for (size_t i = 0; i < (this->size - k); i++) {
        target = target->getNext();
    }

    return target;
}

void print_slist(ostream &file, SListSub &slist) {
    SNode *ptr = slist.getHead();

    do {
        file << ptr->getData() << endl;
        ptr = ptr->getNext();
    }
    while (ptr != NULL);
}

int main(void) {
    SListSub slist(7);
    slist.add(4);
    slist.add(2);   // Target
    slist.add(1);   // 2nd to last
    slist.add(5);

    size_t k = 3;
    SNode *node = slist.kth_to_last(k);
    cout << "Retrieving k = " << k << " from last node" << endl;
    cout << node->getData() << endl;

    return EXIT_SUCCESS;
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: node2lay.hxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 03:51:24 $
 *
 *  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 _NODE2LAY_HXX
#define _NODE2LAY_HXX

/* -----------------23.02.99 11:33-------------------
 * Die Klasse SwNode2Layout stellt die Verbindung von Nodes zum Layout her.
 * Sie liefert einen intelligenten Iterator ueber die zum Node oder Nodebereich
 * gehoerenden Frames. Je nach Zweck der Iteration, z.B. um vor oder hinter
 * den Frames andere Frames einzufuegen, werden Master/Follows erkannt und nur
 * die relevanten zurueckgegeben. Auch wiederholte Tabellenueberschriften werden
 * beachtet.
 * Es ist auch moeglich, ueber SectionNodes zu iterieren, die durch Schachtelung
 * manchmal gar keinem SectionFrm direkt zugeordnet sind, manchmal aber sogar
 * mehreren.
 * SwNode2Layout ist ein Schnittstelle zwischen der aufrufenden Methode und
 * einem SwClientIter, sie waehlt je nach Aufgabenstellung das richtige
 * SwModify aus, erzeugt einen SwClientIter und filtert dessen Iterationen
 * je nach Aufgabenstellung.
 * Die Aufgabenstellung wird durch die Wahl des Ctors bestimmt.
 * 1. Das Einsammeln der UpperFrms, damit spaeter RestoreUpperFrms wird,
 *    wird von MakeFrms gerufen, wenn es keinen PrevNext gibt, vor/hinter den
 *    die Frames gehaengt werden koennen.
 * 2. Die Lieferung der Frames hinter/vor die die neuen Frames eines Nodes
 *    gehaengt werden muessen, ebenfalls von MakeFrms gerufen.
 * --------------------------------------------------*/

class SwNode2LayImpl;
class SwFrm;
class SwLayoutFrm;
class SwNode;

class SwNode2Layout
{
    SwNode2LayImpl *pImpl;
public:
    // Dieser Ctor ist zum Einsammeln der UpperFrms gedacht.
    SwNode2Layout( const SwNode& rNd );
    // Dieser Ctor ist fuer das Einfuegen vor oder hinter rNd gedacht,
    // nIdx ist der Index des einzufuegenden Nodes
    SwNode2Layout( const SwNode& rNd, ULONG nIdx );
    ~SwNode2Layout();
    SwFrm* NextFrm();
    SwLayoutFrm* UpperFrm( SwFrm* &rpFrm, const SwNode& rNode );
    void RestoreUpperFrms( SwNodes& rNds, ULONG nStt, ULONG nEnd );

    SwFrm *GetFrm( const Point* pDocPos = 0,
                    const SwPosition *pPos = 0,
                    const BOOL bCalcFrm = TRUE ) const;
};

#endif
<commit_msg>INTEGRATION: CWS swwarnings (1.2.710); FILE MERGED 2007/02/27 13:07:04 tl 1.2.710.1: #i69287# warning-free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: node2lay.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 08:57:37 $
 *
 *  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 _NODE2LAY_HXX
#define _NODE2LAY_HXX

#include <tools/solar.h>

/* -----------------23.02.99 11:33-------------------
 * Die Klasse SwNode2Layout stellt die Verbindung von Nodes zum Layout her.
 * Sie liefert einen intelligenten Iterator ueber die zum Node oder Nodebereich
 * gehoerenden Frames. Je nach Zweck der Iteration, z.B. um vor oder hinter
 * den Frames andere Frames einzufuegen, werden Master/Follows erkannt und nur
 * die relevanten zurueckgegeben. Auch wiederholte Tabellenueberschriften werden
 * beachtet.
 * Es ist auch moeglich, ueber SectionNodes zu iterieren, die durch Schachtelung
 * manchmal gar keinem SectionFrm direkt zugeordnet sind, manchmal aber sogar
 * mehreren.
 * SwNode2Layout ist ein Schnittstelle zwischen der aufrufenden Methode und
 * einem SwClientIter, sie waehlt je nach Aufgabenstellung das richtige
 * SwModify aus, erzeugt einen SwClientIter und filtert dessen Iterationen
 * je nach Aufgabenstellung.
 * Die Aufgabenstellung wird durch die Wahl des Ctors bestimmt.
 * 1. Das Einsammeln der UpperFrms, damit spaeter RestoreUpperFrms wird,
 *    wird von MakeFrms gerufen, wenn es keinen PrevNext gibt, vor/hinter den
 *    die Frames gehaengt werden koennen.
 * 2. Die Lieferung der Frames hinter/vor die die neuen Frames eines Nodes
 *    gehaengt werden muessen, ebenfalls von MakeFrms gerufen.
 * --------------------------------------------------*/

class SwNode2LayImpl;
class SwFrm;
class SwLayoutFrm;
class SwNode;
class SwNodes;
class Point;
struct SwPosition;

class SwNode2Layout
{
    SwNode2LayImpl *pImpl;
public:
    // Dieser Ctor ist zum Einsammeln der UpperFrms gedacht.
    SwNode2Layout( const SwNode& rNd );
    // Dieser Ctor ist fuer das Einfuegen vor oder hinter rNd gedacht,
    // nIdx ist der Index des einzufuegenden Nodes
    SwNode2Layout( const SwNode& rNd, ULONG nIdx );
    ~SwNode2Layout();
    SwFrm* NextFrm();
    SwLayoutFrm* UpperFrm( SwFrm* &rpFrm, const SwNode& rNode );
    void RestoreUpperFrms( SwNodes& rNds, ULONG nStt, ULONG nEnd );

    SwFrm *GetFrm( const Point* pDocPos = 0,
                    const SwPosition *pPos = 0,
                    const BOOL bCalcFrm = TRUE ) const;
};

#endif
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: glshell.cxx,v $
 *
 *  $Revision: 1.15 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-16 23:07:18 $
 *
 *  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
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#ifndef _LIST_HXX //autogen
#include <tools/list.hxx>
#endif
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#ifndef _SFXSTRITEM_HXX //autogen
#include <svtools/stritem.hxx>
#endif
#ifndef _SFX_PRINTER_HXX //autogen
#include <sfx2/printer.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif
#ifndef _SFXSIDS_HRC //autogen
#include <sfx2/sfxsids.hrc>
#endif
#ifndef _SVX_SRCHITEM_HXX
#include <svx/srchitem.hxx>
#endif
#ifndef _SFXMACITEM_HXX
#include <svtools/macitem.hxx>
#endif
#ifndef _GLOSHDL_HXX
#include <gloshdl.hxx>
#endif

#include <svx/acorrcfg.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/viewfrm.hxx>

#ifndef _UITOOL_HXX
#include <uitool.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _GLSHELL_HXX
#include <glshell.hxx>
#endif
#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _GLOSDOC_HXX
#include <glosdoc.hxx>
#endif
#ifndef _SHELLIO_HXX
#include <shellio.hxx>
#endif
#ifndef _INITUI_HXX
#include <initui.hxx>                   // fuer ::GetGlossaries()
#endif
#ifndef _CMDID_H
#include <cmdid.h>
#endif
#ifndef _SWERROR_H
#include <swerror.h>
#endif
#ifndef _MISC_HRC
#include <misc.hrc>
#endif

#define SwWebGlosDocShell
#define SwGlosDocShell
#ifndef _ITEMDEF_HXX
#include <itemdef.hxx>
#endif
#ifndef _SWSLOTS_HXX
#include <swslots.hxx>
#endif

SFX_IMPL_INTERFACE( SwGlosDocShell, SwDocShell, SW_RES(0) )
{
}

SFX_IMPL_INTERFACE( SwWebGlosDocShell, SwWebDocShell, SW_RES(0) )
{
}

TYPEINIT1( SwGlosDocShell, SwDocShell );
TYPEINIT1( SwWebGlosDocShell, SwWebDocShell );

void lcl_Execute( SwDocShell& rSh, SfxRequest& rReq )
{
    if ( rReq.GetSlot() == SID_SAVEDOC )
    {
        if( !rSh.HasName() )
        {
            rReq.SetReturnValue( SfxBoolItem( 0, rSh.Save() ) );
        }
        else
        {
            const SfxBoolItem* pRes = ( const SfxBoolItem* )
                                        rSh.ExecuteSlot( rReq,
                                        rSh.SfxObjectShell::GetInterface() );
            if( pRes->GetValue() )
                rSh.GetDoc()->ResetModified();
        }
    }
}

void lcl_GetState( SwDocShell& rSh, SfxItemSet& rSet )
{
    if( SFX_ITEM_AVAILABLE >= rSet.GetItemState( SID_SAVEDOC, FALSE ))
    {
        if( !rSh.GetDoc()->IsModified() )
            rSet.DisableItem( SID_SAVEDOC );
        else
            rSet.Put( SfxStringItem( SID_SAVEDOC, SW_RESSTR(STR_SAVE_GLOSSARY)));
    }
}

BOOL lcl_Save( SwWrtShell& rSh, const String& rGroupName,
                const String& rShortNm, const String& rLongNm )
{
    const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
    SwTextBlocks * pBlock = ::GetGlossaries()->GetGroupDoc( rGroupName );

    SvxMacro aStart(aEmptyStr, aEmptyStr);
    SvxMacro aEnd(aEmptyStr, aEmptyStr);
    SwGlossaryHdl* pGlosHdl;

    pGlosHdl = rSh.GetView().GetGlosHdl();
    pGlosHdl->GetMacros( rShortNm, aStart, aEnd, pBlock );

    USHORT nRet = rSh.SaveGlossaryDoc( *pBlock, rLongNm, rShortNm,
                                pCfg->IsSaveRelFile(), pCfg->IsSaveRelNet(),
                                pBlock->IsOnlyTextBlock( rShortNm ) );

    if(aStart.GetMacName().Len() || aEnd.GetMacName().Len() )
    {
        SvxMacro* pStart = aStart.GetMacName().Len() ? &aStart : 0;
        SvxMacro* pEnd = aEnd.GetMacName().Len() ? &aEnd : 0;
        pGlosHdl->SetMacros( rShortNm, pStart, pEnd, pBlock );
    }

    rSh.EnterStdMode();
    if( USHRT_MAX != nRet )
        rSh.ResetModified();
    delete pBlock;
    return nRet != USHRT_MAX;
}

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

SwGlosDocShell::SwGlosDocShell( sal_Bool bNewShow)
    : bShow ( bNewShow )
    , SwDocShell( bShow ? SFX_CREATE_MODE_STANDARD : SFX_CREATE_MODE_INTERNAL )
{
    SetHelpId(SW_GLOSDOCSHELL);
}

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

SwGlosDocShell::~SwGlosDocShell(  )
{
}

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

void SwGlosDocShell::Execute( SfxRequest& rReq )
{
    ::lcl_Execute( *this, rReq );
}

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

void SwGlosDocShell::GetState( SfxItemSet& rSet )
{
    ::lcl_GetState( *this, rSet );
}

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

BOOL SwGlosDocShell::Save()
{
    // In case of an API object which holds this document, it is possible that the WrtShell is already
    // dead. For instance, if the doc is modified via this API object, and then, upon office shutdown,
    // the document's view is closed (by the SFX framework) _before_ the API object is release and
    // tries to save the doc, again.
    // 96380 - 2002-03-03 - fs@openoffice.org
    if ( GetWrtShell() )
        return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
    else
    {
        SetModified( FALSE );
        return FALSE;
    }
}

/**/

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

SwWebGlosDocShell::SwWebGlosDocShell()
    : SwWebDocShell( SFX_CREATE_MODE_STANDARD )
{
    SetHelpId(SW_WEBGLOSDOCSHELL);
}

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

SwWebGlosDocShell::~SwWebGlosDocShell(  )
{
}

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

void SwWebGlosDocShell::Execute( SfxRequest& rReq )
{
    ::lcl_Execute( *this, rReq );
}
/*--------------------------------------------------------------------
    Beschreibung:
 --------------------------------------------------------------------*/

void SwWebGlosDocShell::GetState( SfxItemSet& rSet )
{
    ::lcl_GetState( *this, rSet );
}

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

BOOL SwWebGlosDocShell::Save()
{
    // same comment as in SwGlosDocShell::Save - see there
    if ( GetWrtShell() )
        return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
    else
    {
        SetModified( FALSE );
        return FALSE;
    }
}

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

SV_IMPL_REF ( SwDocShell )

SwDocShellRef SwGlossaries::EditGroupDoc( const String& rGroup, const String& rShortName, BOOL bShow )
{
    SwDocShellRef xDocSh;

    SwTextBlocks* pGroup = GetGroupDoc( rGroup );
    if( pGroup && pGroup->GetCount() )
    {
        // erfrage welche View registriert ist. Im WebWriter gibts es keine
        // normale View
        USHORT nViewId = 0 != &SwView::Factory() ? 2 : 6;
        String sLongName = pGroup->GetLongName(pGroup->GetIndex( rShortName ));

        if( 6 == nViewId )
        {
            SwWebGlosDocShell* pDocSh = new SwWebGlosDocShell();
            xDocSh = pDocSh;
            pDocSh->DoInitNew( 0 );
            pDocSh->SetLongName( sLongName );
            pDocSh->SetShortName( rShortName);
            pDocSh->SetGroupName( rGroup );
        }
        else
        {
            SwGlosDocShell* pDocSh = new SwGlosDocShell(bShow);
            xDocSh = pDocSh;
            pDocSh->DoInitNew( 0 );
            pDocSh->SetLongName( sLongName );
            pDocSh->SetShortName( rShortName );
            pDocSh->SetGroupName( rGroup );
        }

        // Dokumenttitel setzen
        SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *xDocSh, nViewId, !bShow );
        String aDocTitle(SW_RES( STR_GLOSSARY ));
        aDocTitle += ' ';
        aDocTitle += sLongName;

        BOOL bDoesUndo = xDocSh->GetDoc()->DoesUndo();
        xDocSh->GetDoc()->DoUndo( FALSE );

        xDocSh->GetWrtShell()->InsertGlossary( *pGroup, rShortName );
        if( !xDocSh->GetDoc()->getPrinter( false ) )
        {
            // wir erzeugen einen default SfxPrinter.
            // Das ItemSet wird vom Sfx geloescht!
            SfxItemSet *pSet = new SfxItemSet( xDocSh->GetDoc()->GetAttrPool(),
                        FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
                        SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                        SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                        0 );
            SfxPrinter* pPrinter = new SfxPrinter( pSet );

            // und haengen ihn ans Dokument.
            xDocSh->GetDoc()->setPrinter( pPrinter, true, true );
        }

        xDocSh->SetTitle( aDocTitle );
        xDocSh->GetDoc()->DoUndo( bDoesUndo );
        xDocSh->GetDoc()->ResetModified();
        if ( bShow )
            pFrame->GetFrame()->Appear();

        delete pGroup;
    }
    return xDocSh;
}

<commit_msg>INTEGRATION: CWS swwarnings (1.15.222); FILE MERGED 2007/03/26 12:09:13 tl 1.15.222.1: #i69287# warning-free code<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: glshell.cxx,v $
 *
 *  $Revision: 1.16 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 12:20:32 $
 *
 *  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
 *
 ************************************************************************/

// MARKER(update_precomp.py): autogen include statement, do not remove
#include "precompiled_sw.hxx"

#ifndef _LIST_HXX //autogen
#include <tools/list.hxx>
#endif
#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#ifndef _SFXSTRITEM_HXX //autogen
#include <svtools/stritem.hxx>
#endif
#ifndef _SFX_PRINTER_HXX //autogen
#include <sfx2/printer.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif
#ifndef _SFXSIDS_HRC //autogen
#include <sfx2/sfxsids.hrc>
#endif
#ifndef _SVX_SRCHITEM_HXX
#include <svx/srchitem.hxx>
#endif
#ifndef _SFXMACITEM_HXX
#include <svtools/macitem.hxx>
#endif
#ifndef _GLOSHDL_HXX
#include <gloshdl.hxx>
#endif

#include <svx/acorrcfg.hxx>
#include <sfx2/app.hxx>
#include <sfx2/objface.hxx>
#include <sfx2/viewfrm.hxx>

#ifndef _UITOOL_HXX
#include <uitool.hxx>
#endif
#ifndef _WRTSH_HXX
#include <wrtsh.hxx>
#endif
#ifndef _VIEW_HXX
#include <view.hxx>
#endif
#ifndef _GLSHELL_HXX
#include <glshell.hxx>
#endif
#ifndef _DOC_HXX
#include <doc.hxx>
#endif
#ifndef _GLOSDOC_HXX
#include <glosdoc.hxx>
#endif
#ifndef _SHELLIO_HXX
#include <shellio.hxx>
#endif
#ifndef _INITUI_HXX
#include <initui.hxx>                   // fuer ::GetGlossaries()
#endif
#ifndef _CMDID_H
#include <cmdid.h>
#endif
#ifndef _SWERROR_H
#include <swerror.h>
#endif
#ifndef _MISC_HRC
#include <misc.hrc>
#endif

#define SwWebGlosDocShell
#define SwGlosDocShell
#ifndef _ITEMDEF_HXX
#include <itemdef.hxx>
#endif
#ifndef _SWSLOTS_HXX
#include <swslots.hxx>
#endif

SFX_IMPL_INTERFACE( SwGlosDocShell, SwDocShell, SW_RES(0) )
{
}

SFX_IMPL_INTERFACE( SwWebGlosDocShell, SwWebDocShell, SW_RES(0) )
{
}

TYPEINIT1( SwGlosDocShell, SwDocShell );
TYPEINIT1( SwWebGlosDocShell, SwWebDocShell );

void lcl_Execute( SwDocShell& rSh, SfxRequest& rReq )
{
    if ( rReq.GetSlot() == SID_SAVEDOC )
    {
        if( !rSh.HasName() )
        {
            rReq.SetReturnValue( SfxBoolItem( 0, rSh.Save() ) );
        }
        else
        {
            const SfxBoolItem* pRes = ( const SfxBoolItem* )
                                        rSh.ExecuteSlot( rReq,
                                        rSh.SfxObjectShell::GetInterface() );
            if( pRes->GetValue() )
                rSh.GetDoc()->ResetModified();
        }
    }
}

void lcl_GetState( SwDocShell& rSh, SfxItemSet& rSet )
{
    if( SFX_ITEM_AVAILABLE >= rSet.GetItemState( SID_SAVEDOC, FALSE ))
    {
        if( !rSh.GetDoc()->IsModified() )
            rSet.DisableItem( SID_SAVEDOC );
        else
            rSet.Put( SfxStringItem( SID_SAVEDOC, SW_RESSTR(STR_SAVE_GLOSSARY)));
    }
}

BOOL lcl_Save( SwWrtShell& rSh, const String& rGroupName,
                const String& rShortNm, const String& rLongNm )
{
    const SvxAutoCorrCfg* pCfg = SvxAutoCorrCfg::Get();
    SwTextBlocks * pBlock = ::GetGlossaries()->GetGroupDoc( rGroupName );

    SvxMacro aStart(aEmptyStr, aEmptyStr);
    SvxMacro aEnd(aEmptyStr, aEmptyStr);
    SwGlossaryHdl* pGlosHdl;

    pGlosHdl = rSh.GetView().GetGlosHdl();
    pGlosHdl->GetMacros( rShortNm, aStart, aEnd, pBlock );

    USHORT nRet = rSh.SaveGlossaryDoc( *pBlock, rLongNm, rShortNm,
                                pCfg->IsSaveRelFile(),
                                pBlock->IsOnlyTextBlock( rShortNm ) );

    if(aStart.GetMacName().Len() || aEnd.GetMacName().Len() )
    {
        SvxMacro* pStart = aStart.GetMacName().Len() ? &aStart : 0;
        SvxMacro* pEnd = aEnd.GetMacName().Len() ? &aEnd : 0;
        pGlosHdl->SetMacros( rShortNm, pStart, pEnd, pBlock );
    }

    rSh.EnterStdMode();
    if( USHRT_MAX != nRet )
        rSh.ResetModified();
    delete pBlock;
    return nRet != USHRT_MAX;
}

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

SwGlosDocShell::SwGlosDocShell( sal_Bool bNewShow)
    :
    SwDocShell( bShow ? SFX_CREATE_MODE_STANDARD : SFX_CREATE_MODE_INTERNAL )
    ,bShow ( bNewShow )
{
    SetHelpId(SW_GLOSDOCSHELL);
}

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

SwGlosDocShell::~SwGlosDocShell(  )
{
}

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

void SwGlosDocShell::Execute( SfxRequest& rReq )
{
    ::lcl_Execute( *this, rReq );
}

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

void SwGlosDocShell::GetState( SfxItemSet& rSet )
{
    ::lcl_GetState( *this, rSet );
}

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

BOOL SwGlosDocShell::Save()
{
    // In case of an API object which holds this document, it is possible that the WrtShell is already
    // dead. For instance, if the doc is modified via this API object, and then, upon office shutdown,
    // the document's view is closed (by the SFX framework) _before_ the API object is release and
    // tries to save the doc, again.
    // 96380 - 2002-03-03 - fs@openoffice.org
    if ( GetWrtShell() )
        return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
    else
    {
        SetModified( FALSE );
        return FALSE;
    }
}

/**/

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

SwWebGlosDocShell::SwWebGlosDocShell()
    : SwWebDocShell( SFX_CREATE_MODE_STANDARD )
{
    SetHelpId(SW_WEBGLOSDOCSHELL);
}

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

SwWebGlosDocShell::~SwWebGlosDocShell(  )
{
}

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

void SwWebGlosDocShell::Execute( SfxRequest& rReq )
{
    ::lcl_Execute( *this, rReq );
}
/*--------------------------------------------------------------------
    Beschreibung:
 --------------------------------------------------------------------*/

void SwWebGlosDocShell::GetState( SfxItemSet& rSet )
{
    ::lcl_GetState( *this, rSet );
}

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

BOOL SwWebGlosDocShell::Save()
{
    // same comment as in SwGlosDocShell::Save - see there
    if ( GetWrtShell() )
        return ::lcl_Save( *GetWrtShell(), aGroupName, aShortName, aLongName );
    else
    {
        SetModified( FALSE );
        return FALSE;
    }
}

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

SV_IMPL_REF ( SwDocShell )

SwDocShellRef SwGlossaries::EditGroupDoc( const String& rGroup, const String& rShortName, BOOL bShow )
{
    SwDocShellRef xDocSh;

    SwTextBlocks* pGroup = GetGroupDoc( rGroup );
    if( pGroup && pGroup->GetCount() )
    {
        // erfrage welche View registriert ist. Im WebWriter gibts es keine
        // normale View
        USHORT nViewId = 0 != &SwView::Factory() ? 2 : 6;
        String sLongName = pGroup->GetLongName(pGroup->GetIndex( rShortName ));

        if( 6 == nViewId )
        {
            SwWebGlosDocShell* pDocSh = new SwWebGlosDocShell();
            xDocSh = pDocSh;
            pDocSh->DoInitNew( 0 );
            pDocSh->SetLongName( sLongName );
            pDocSh->SetShortName( rShortName);
            pDocSh->SetGroupName( rGroup );
        }
        else
        {
            SwGlosDocShell* pDocSh = new SwGlosDocShell(bShow);
            xDocSh = pDocSh;
            pDocSh->DoInitNew( 0 );
            pDocSh->SetLongName( sLongName );
            pDocSh->SetShortName( rShortName );
            pDocSh->SetGroupName( rGroup );
        }

        // Dokumenttitel setzen
        SfxViewFrame* pFrame = SfxViewFrame::CreateViewFrame( *xDocSh, nViewId, !bShow );
        String aDocTitle(SW_RES( STR_GLOSSARY ));
        aDocTitle += ' ';
        aDocTitle += sLongName;

        BOOL bDoesUndo = xDocSh->GetDoc()->DoesUndo();
        xDocSh->GetDoc()->DoUndo( FALSE );

        xDocSh->GetWrtShell()->InsertGlossary( *pGroup, rShortName );
        if( !xDocSh->GetDoc()->getPrinter( false ) )
        {
            // wir erzeugen einen default SfxPrinter.
            // Das ItemSet wird vom Sfx geloescht!
            SfxItemSet *pSet = new SfxItemSet( xDocSh->GetDoc()->GetAttrPool(),
                        FN_PARAM_ADDPRINTER, FN_PARAM_ADDPRINTER,
                        SID_PRINTER_NOTFOUND_WARN, SID_PRINTER_NOTFOUND_WARN,
                        SID_PRINTER_CHANGESTODOC, SID_PRINTER_CHANGESTODOC,
                        0 );
            SfxPrinter* pPrinter = new SfxPrinter( pSet );

            // und haengen ihn ans Dokument.
            xDocSh->GetDoc()->setPrinter( pPrinter, true, true );
        }

        xDocSh->SetTitle( aDocTitle );
        xDocSh->GetDoc()->DoUndo( bDoesUndo );
        xDocSh->GetDoc()->ResetModified();
        if ( bShow )
            pFrame->GetFrame()->Appear();

        delete pGroup;
    }
    return xDocSh;
}

<|endoftext|>


<commit_before>///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-10-16
// Updated : 2011-10-16
// Licence : This source is under MIT License
// File    : test/core/core_func_swizzle.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////

#define GLM_MESSAGES
#define GLM_SWIZZLE
#include <glm/glm.hpp>

int test_ivec2_swizzle()
{
	int Error = 0;

	glm::ivec2 A(1, 2);
	glm::ivec2 B = A.xy();
	glm::ivec2 C(0);
	C.xy() = B.xy();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_ivec3_swizzle()
{
	int Error = 0;

	glm::ivec3 A(1, 2, 3);
	glm::ivec3 B = A.xyz();
	glm::ivec3 C(0);
	C.xyz() = B.xyz();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_ivec4_swizzle()
{
	int Error = 0;

	glm::ivec4 A(1, 2, 3, 4);
	glm::ivec4 B = A.xyzw();
	glm::ivec4 C(0);
	C.xyzw() = B.xyzw();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_vec4_swizzle()
{
	int Error = 0;

	glm::vec4 A(1, 2, 3, 4);
	glm::vec4 B = A.xyzw();
	glm::vec4 C(0);
	//C.xyzw() = B.xyzw();

	float f = glm::dot(C.wzyx(), C.xyzw());

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	static_assert(sizeof(int) <= 4, "Test");
	return Error;
}

int main()
{
	int Error = 0;

	Error += test_ivec2_swizzle();
	Error += test_ivec3_swizzle();
	Error += test_ivec4_swizzle();

	Error += test_vec4_swizzle();

	return Error;
}

<commit_msg>Removed a static_assert<commit_after>///////////////////////////////////////////////////////////////////////////////////////////////////
// OpenGL Mathematics Copyright (c) 2005 - 2013 G-Truc Creation (www.g-truc.net)
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2011-10-16
// Updated : 2011-10-16
// Licence : This source is under MIT License
// File    : test/core/core_func_swizzle.cpp
///////////////////////////////////////////////////////////////////////////////////////////////////

#define GLM_MESSAGES
#define GLM_SWIZZLE
#include <glm/glm.hpp>

int test_ivec2_swizzle()
{
	int Error = 0;

	glm::ivec2 A(1, 2);
	glm::ivec2 B = A.xy();
	glm::ivec2 C(0);
	C.xy() = B.xy();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_ivec3_swizzle()
{
	int Error = 0;

	glm::ivec3 A(1, 2, 3);
	glm::ivec3 B = A.xyz();
	glm::ivec3 C(0);
	C.xyz() = B.xyz();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_ivec4_swizzle()
{
	int Error = 0;

	glm::ivec4 A(1, 2, 3, 4);
	glm::ivec4 B = A.xyzw();
	glm::ivec4 C(0);
	C.xyzw() = B.xyzw();

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int test_vec4_swizzle()
{
	int Error = 0;

	glm::vec4 A(1, 2, 3, 4);
	glm::vec4 B = A.xyzw();
	glm::vec4 C(0);
	//C.xyzw() = B.xyzw();

	float f = glm::dot(C.wzyx(), C.xyzw());

	Error += A == B ? 0 : 1;
	Error += A == C ? 0 : 1;

	return Error;
}

int main()
{
	int Error = 0;

	Error += test_ivec2_swizzle();
	Error += test_ivec3_swizzle();
	Error += test_ivec4_swizzle();

	Error += test_vec4_swizzle();

	return Error;
}

<|endoftext|>


<commit_before>#include "devicesConfigurationWidget.h"

#include <QtWidgets/QBoxLayout>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLabel>

#include <interpreterBase/robotModel/robotModelInterface.h>

using namespace interpreterCore::ui;
using namespace interpreterBase::robotModel;

DevicesConfigurationWidget::DevicesConfigurationWidget(QWidget *parent, bool autosaveMode)
	: QScrollArea(parent)
	, mAutosaveMode(autosaveMode)
	, mSaving(false)
	, mRefreshing(false)
{
	setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setFrameShadow(QFrame::Sunken);
	setMinimumHeight(140);
}

void DevicesConfigurationWidget::loadRobotModels(QList<RobotModelInterface *> const &models)
{
	for (RobotModelInterface * const model : models) {
		QString const name = model->name();
		mRobotModels[name] = model;
		QWidget * const configurer = configurerForRobotModel(*model);
		mRobotModelConfigurers[name] = configurer;
	}
}

void DevicesConfigurationWidget::selectRobotModel(RobotModelInterface &robotModel)
{
	QString const robotModelId = robotModel.name();
	mCurrentModel = robotModelId;
	takeWidget();
	if (mRobotModels.contains(robotModelId)) {
		setWidget(mRobotModelConfigurers[robotModelId]);
		refresh();
	}
}

QWidget *DevicesConfigurationWidget::configurerForRobotModel(RobotModelInterface &robotModel)
{
	/// @todo: What if robot model has no configurable sensors?
	QWidget *result = new QWidget;
	QVBoxLayout * const layout = new QVBoxLayout;
	result->setLayout(layout);
	QList<PortInfo> const configurablePorts = robotModel.configurablePorts();
	for (PortInfo const &port : configurablePorts) {
		layout->addLayout(initPort(robotModel.name(), port, robotModel.allowedDevices(port)));
	}

	return result;
}

QLayout *DevicesConfigurationWidget::initPort(QString const &robotModel
		, PortInfo const &port, QList<DeviceInfo> const &sensors)
{
	QLabel * const portLabel = new QLabel(tr("Port %1:").arg(port.name()), this);
	QComboBox * const comboBox = new QComboBox(this);
	comboBox->setProperty("robotModel", robotModel);
	comboBox->setProperty("port", QVariant::fromValue(port));
	mConfigurers << comboBox;
	comboBox->addItem(tr("Unused"), QVariant::fromValue(DeviceInfo()));
	for (DeviceInfo const &sensor : sensors) {
		comboBox->addItem(sensor.friendlyName(), QVariant::fromValue(sensor));
	}

	if (mAutosaveMode) {
		connect(comboBox, &QComboBox::currentTextChanged, this, &DevicesConfigurationWidget::save);
	}

	QHBoxLayout * const layout = new QHBoxLayout;
	layout->addWidget(portLabel);
	layout->addWidget(comboBox);
	layout->setStretch(0, 0);
	layout->setStretch(1, 1);

	return layout;
}

void DevicesConfigurationWidget::onDeviceConfigurationChanged(QString const &robotModel
		, PortInfo const &port, DeviceInfo const &sensor)
{
	Q_UNUSED(robotModel)
	Q_UNUSED(port)
	Q_UNUSED(sensor)

	// This method can be called when we did not accomplish processing all combo boxes during saving.
	// So ignoring such case.
	if (!mSaving) {
		refresh();
	}
}

void DevicesConfigurationWidget::refresh()
{
	mRefreshing = true;
	for (QComboBox * const box : mConfigurers) {
		PortInfo const port = box->property("port").value<PortInfo>();
		DeviceInfo const device = currentConfiguration(mCurrentModel, port);
		if (device.isNull()) {
			box->setCurrentIndex(0);
		} else {
			for (int index = 0; index < box->count(); ++index) {
				if (box->itemData(index).value<DeviceInfo>().isA(device)) {
					box->setCurrentIndex(index);
					break;
				}
			}
		}
	}

	mRefreshing = false;
}

void DevicesConfigurationWidget::save()
{
	// Refreshing may affect combobox current index. No saving is needed then.
	if (mRefreshing) {
		return;
	}

	mSaving = true;
	for (QComboBox * const box : mConfigurers) {
		if (!box->isVisible()) {
			continue;
		}

		QString const robotModel = box->property("robotModel").toString();
		PortInfo const port = box->property("port").value<PortInfo>();
		DeviceInfo const device = box->itemData(box->currentIndex()).value<DeviceInfo>();
		if (currentConfiguration(robotModel, port) != device) {
			propagateChanges(port, device);
		}
	}

	mSaving = false;
}

void DevicesConfigurationWidget::propagateChanges(PortInfo const &port, DeviceInfo const &sensor)
{
	for (QString const &robotModelId : mRobotModels.keys()) {
		RobotModelInterface const *robotModel = mRobotModels[robotModelId];
		for (PortInfo const &otherPort : robotModel->configurablePorts()) {
			if (areConvertible(port, otherPort)) {
				if (sensor.isNull()) {
					deviceConfigurationChanged(robotModelId, otherPort, DeviceInfo());
				} else {
					DeviceInfo const otherDevice = convertibleDevice(robotModel, otherPort, sensor);
					if (!otherDevice.isNull()) {
						deviceConfigurationChanged(robotModelId, otherPort, otherDevice);
					}
				}
			}
		}
	}
}

bool DevicesConfigurationWidget::areConvertible(PortInfo const &port1, PortInfo const &port2) const
{
	return (port1.name() == port2.name()
			|| port1.nameAliases().contains(port2.name())
			|| port2.nameAliases().contains(port1.name()))
			&& port1.direction() == port2.direction();
}

DeviceInfo DevicesConfigurationWidget::convertibleDevice(RobotModelInterface const *robotModel
		, PortInfo const &port, DeviceInfo const &device) const
{
	QList<DeviceInfo> const convertibleBases = robotModel->convertibleBases();
	for (DeviceInfo const &allowedDevice : robotModel->allowedDevices(port)) {
		for (DeviceInfo const &convertibleBase : convertibleBases) {
			if (device.isA(convertibleBase) && allowedDevice.isA(convertibleBase)) {
				return allowedDevice;
			}
		}
	}

	return DeviceInfo();
}
<commit_msg>Device configurator`s background made transparent<commit_after>#include "devicesConfigurationWidget.h"

#include <QtWidgets/QBoxLayout>
#include <QtWidgets/QComboBox>
#include <QtWidgets/QLabel>

#include <interpreterBase/robotModel/robotModelInterface.h>

using namespace interpreterCore::ui;
using namespace interpreterBase::robotModel;

DevicesConfigurationWidget::DevicesConfigurationWidget(QWidget *parent, bool autosaveMode)
	: QScrollArea(parent)
	, mAutosaveMode(autosaveMode)
	, mSaving(false)
	, mRefreshing(false)
{
	setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
	setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
	setMinimumHeight(125);
	setFrameShape(QFrame::NoFrame);

	setWidgetResizable(true);
	QPalette palette = this->palette();
	palette.setColor(QPalette::Background, Qt::transparent);
	setPalette(palette);
}

void DevicesConfigurationWidget::loadRobotModels(QList<RobotModelInterface *> const &models)
{
	for (RobotModelInterface * const model : models) {
		QString const name = model->name();
		mRobotModels[name] = model;
		QWidget * const configurer = configurerForRobotModel(*model);
		mRobotModelConfigurers[name] = configurer;
	}
}

void DevicesConfigurationWidget::selectRobotModel(RobotModelInterface &robotModel)
{
	QString const robotModelId = robotModel.name();
	mCurrentModel = robotModelId;
	takeWidget();
	if (mRobotModels.contains(robotModelId)) {
		setWidget(mRobotModelConfigurers[robotModelId]);
		refresh();
	}
}

QWidget *DevicesConfigurationWidget::configurerForRobotModel(RobotModelInterface &robotModel)
{
	/// @todo: What if robot model has no configurable sensors?
	QWidget *result = new QWidget;
	QPalette palette = result->palette();
	palette.setColor(QPalette::Background, Qt::transparent);
	result->setPalette(palette);
	QVBoxLayout * const layout = new QVBoxLayout;
	result->setLayout(layout);
	QList<PortInfo> const configurablePorts = robotModel.configurablePorts();
	for (PortInfo const &port : configurablePorts) {
		layout->addLayout(initPort(robotModel.name(), port, robotModel.allowedDevices(port)));
	}

	return result;
}

QLayout *DevicesConfigurationWidget::initPort(QString const &robotModel
		, PortInfo const &port, QList<DeviceInfo> const &sensors)
{
	QLabel * const portLabel = new QLabel(tr("Port %1:").arg(port.name()), this);
	QComboBox * const comboBox = new QComboBox(this);
	comboBox->setProperty("robotModel", robotModel);
	comboBox->setProperty("port", QVariant::fromValue(port));
	mConfigurers << comboBox;
	comboBox->addItem(tr("Unused"), QVariant::fromValue(DeviceInfo()));
	for (DeviceInfo const &sensor : sensors) {
		comboBox->addItem(sensor.friendlyName(), QVariant::fromValue(sensor));
	}

	if (mAutosaveMode) {
		connect(comboBox, &QComboBox::currentTextChanged, this, &DevicesConfigurationWidget::save);
	}

	QHBoxLayout * const layout = new QHBoxLayout;
	layout->addWidget(portLabel);
	layout->addWidget(comboBox);
	layout->setStretch(0, 0);
	layout->setStretch(1, 1);

	return layout;
}

void DevicesConfigurationWidget::onDeviceConfigurationChanged(QString const &robotModel
		, PortInfo const &port, DeviceInfo const &sensor)
{
	Q_UNUSED(robotModel)
	Q_UNUSED(port)
	Q_UNUSED(sensor)

	// This method can be called when we did not accomplish processing all combo boxes during saving.
	// So ignoring such case.
	if (!mSaving) {
		refresh();
	}
}

void DevicesConfigurationWidget::refresh()
{
	mRefreshing = true;
	for (QComboBox * const box : mConfigurers) {
		PortInfo const port = box->property("port").value<PortInfo>();
		DeviceInfo const device = currentConfiguration(mCurrentModel, port);
		if (device.isNull()) {
			box->setCurrentIndex(0);
		} else {
			for (int index = 0; index < box->count(); ++index) {
				if (box->itemData(index).value<DeviceInfo>().isA(device)) {
					box->setCurrentIndex(index);
					break;
				}
			}
		}
	}

	mRefreshing = false;
}

void DevicesConfigurationWidget::save()
{
	// Refreshing may affect combobox current index. No saving is needed then.
	if (mRefreshing) {
		return;
	}

	mSaving = true;
	for (QComboBox * const box : mConfigurers) {
		if (!box->isVisible()) {
			continue;
		}

		QString const robotModel = box->property("robotModel").toString();
		PortInfo const port = box->property("port").value<PortInfo>();
		DeviceInfo const device = box->itemData(box->currentIndex()).value<DeviceInfo>();
		if (currentConfiguration(robotModel, port) != device) {
			propagateChanges(port, device);
		}
	}

	mSaving = false;
}

void DevicesConfigurationWidget::propagateChanges(PortInfo const &port, DeviceInfo const &sensor)
{
	for (QString const &robotModelId : mRobotModels.keys()) {
		RobotModelInterface const *robotModel = mRobotModels[robotModelId];
		for (PortInfo const &otherPort : robotModel->configurablePorts()) {
			if (areConvertible(port, otherPort)) {
				if (sensor.isNull()) {
					deviceConfigurationChanged(robotModelId, otherPort, DeviceInfo());
				} else {
					DeviceInfo const otherDevice = convertibleDevice(robotModel, otherPort, sensor);
					if (!otherDevice.isNull()) {
						deviceConfigurationChanged(robotModelId, otherPort, otherDevice);
					}
				}
			}
		}
	}
}

bool DevicesConfigurationWidget::areConvertible(PortInfo const &port1, PortInfo const &port2) const
{
	return (port1.name() == port2.name()
			|| port1.nameAliases().contains(port2.name())
			|| port2.nameAliases().contains(port1.name()))
			&& port1.direction() == port2.direction();
}

DeviceInfo DevicesConfigurationWidget::convertibleDevice(RobotModelInterface const *robotModel
		, PortInfo const &port, DeviceInfo const &device) const
{
	QList<DeviceInfo> const convertibleBases = robotModel->convertibleBases();
	for (DeviceInfo const &allowedDevice : robotModel->allowedDevices(port)) {
		for (DeviceInfo const &convertibleBase : convertibleBases) {
			if (device.isA(convertibleBase) && allowedDevice.isA(convertibleBase)) {
				return allowedDevice;
			}
		}
	}

	return DeviceInfo();
}
<|endoftext|>