<commit_before>/*************************************************************************
 *
 *  $RCSfile: ins_paste.cxx,v $
 *
 *  $Revision: 1.1 $
 *
 *  last change: $Author: ka $ $Date: 2002-04-29 10:34:49 $
 *
 *  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): _______________________________________
 *
 *
 ************************************************************************/

#include "ins_paste.hrc"
#include "ins_paste.hxx"

// --------------------
// - SdInsertPasteDlg -
// --------------------

SdInsertPasteDlg::SdInsertPasteDlg( Window* pWindow ) :
    ModalDialog( pWindow, SdResId( DLG_INSERT_PASTE ) ),
    aFlPosition( this, SdResId( FL_POSITION ) ),
    aRbBefore( this, SdResId( RB_BEFORE ) ),
    aRbAfter( this, SdResId( RB_AFTER ) ),
    aBtnOK( this, SdResId( BTN_OK ) ),
    aBtnCancel( this, SdResId( BTN_CANCEL ) ),
    aBtnHelp( this, SdResId( BTN_HELP ) )
{
    FreeResource();
    aRbAfter.Check( TRUE );
}

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

SdInsertPasteDlg::~SdInsertPasteDlg()
{
}

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

BOOL SdInsertPasteDlg::IsInsertBefore() const
{
    return( aRbBefore.IsChecked() );
}
<commit_msg>INTEGRATION: CWS tune03 (1.1.508); FILE MERGED 2004/08/08 12:54:06 mhu 1.1.508.1: #i29979# Added SD_DLLPUBLIC/PRIVATE (see sddllapi.h) to exported symbols/classes.<commit_after>/*************************************************************************
 *
 *  $RCSfile: ins_paste.cxx,v $
 *
 *  $Revision: 1.2 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:16:21 $
 *
 *  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 SD_DLLIMPLEMENTATION
#undef SD_DLLIMPLEMENTATION
#endif

#include "ins_paste.hrc"
#include "ins_paste.hxx"

// --------------------
// - SdInsertPasteDlg -
// --------------------

SdInsertPasteDlg::SdInsertPasteDlg( Window* pWindow ) :
    ModalDialog( pWindow, SdResId( DLG_INSERT_PASTE ) ),
    aFlPosition( this, SdResId( FL_POSITION ) ),
    aRbBefore( this, SdResId( RB_BEFORE ) ),
    aRbAfter( this, SdResId( RB_AFTER ) ),
    aBtnOK( this, SdResId( BTN_OK ) ),
    aBtnCancel( this, SdResId( BTN_CANCEL ) ),
    aBtnHelp( this, SdResId( BTN_HELP ) )
{
    FreeResource();
    aRbAfter.Check( TRUE );
}

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

SdInsertPasteDlg::~SdInsertPasteDlg()
{
}

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

BOOL SdInsertPasteDlg::IsInsertBefore() const
{
    return( aRbBefore.IsChecked() );
}
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fuediglu.cxx,v $
 *
 *  $Revision: 1.11 $
 *
 *  last change: $Author: kz $ $Date: 2006-12-12 17:17:33 $
 *
 *  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_sd.hxx"

#include "fuediglu.hxx"

#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#include <svx/dialogs.hrc>
#ifndef _SVDGLUE_HXX //autogen
#include <svx/svdglue.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif

#include "app.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx"
#endif
#include "drawdoc.hxx"
#ifndef SD_FRAMW_VIEW_HXX
#include "FrameView.hxx"
#endif
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_VIEW_SHELL_HXX
#include "ViewShell.hxx"
#endif
#ifndef SD_VIEW_SHELL_BASE_HXX
#include "ViewShellBase.hxx"
#endif
#ifndef SD_TOOL_BAR_MANAGER_HXX
#include "ToolBarManager.hxx"
#endif

namespace sd {

TYPEINIT1( FuEditGluePoints, FuDraw );

/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/

FuEditGluePoints::FuEditGluePoints (
    ViewShell* pViewSh,
    ::sd::Window* pWin,
    ::sd::View* pView,
    SdDrawDocument* pDoc,
    SfxRequest& rReq)
    : FuDraw(pViewSh, pWin, pView, pDoc, rReq)
{
}

FunctionReference FuEditGluePoints::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
{
    FuEditGluePoints* pFunc;
    FunctionReference xFunc( pFunc = new FuEditGluePoints( pViewSh, pWin, pView, pDoc, rReq ) );
    xFunc->DoExecute(rReq);
    pFunc->SetPermanent( bPermanent );
    return xFunc;
}

void FuEditGluePoints::DoExecute( SfxRequest& rReq )
{
    FuDraw::DoExecute( rReq );
    mpView->SetInsGluePointMode(FALSE);
    mpViewShell->GetViewShellBase().GetToolBarManager().AddToolBar(
        ToolBarManager::TBG_FUNCTION,
        ToolBarManager::msGluePointsToolBar);
}

/*************************************************************************
|*
|* Destruktor
|*
\************************************************************************/

FuEditGluePoints::~FuEditGluePoints()
{
    mpView->BrkAction();
    mpView->UnmarkAllGluePoints();
    mpView->SetInsGluePointMode(FALSE);
}

/*************************************************************************
|*
|* MouseButtonDown-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseButtonDown(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FuDraw::MouseButtonDown(rMEvt);

    if (mpView->IsAction())
    {
        if (rMEvt.IsRight())
            mpView->BckAction();

        return TRUE;
    }

    if (rMEvt.IsLeft())
    {
        bReturn = TRUE;
        USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
        USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
        mpWindow->CaptureMouse();

        SdrViewEvent aVEvt;
        SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);

        if (eHit == SDRHIT_HANDLE)
        {
            /******************************************************************
            * Handle draggen
            ******************************************************************/
            SdrHdl* pHdl = aVEvt.pHdl;

            if (mpView->IsGluePointMarked(aVEvt.pObj, aVEvt.nGlueId) && rMEvt.IsShift())
            {
                mpView->UnmarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
                pHdl = NULL;
            }

            if (pHdl)
            {
                // Handle draggen
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
            }
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && mpView->IsInsGluePointMode())
        {
            /******************************************************************
            * Klebepunkt einfuegen
            ******************************************************************/
            mpView->BegInsGluePoint(aMDPos);
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
        {
            /******************************************************************
            * Klebepunkt selektieren
            ******************************************************************/
            if (!rMEvt.IsShift())
                mpView->UnmarkAllGluePoints();

            mpView->BegMarkGluePoints(aMDPos);
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
        {
            /******************************************************************
            * Objekt verschieben
            ******************************************************************/
            mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, NULL, nDrgLog);
        }
        else if (eHit == SDRHIT_GLUEPOINT)
        {
            /******************************************************************
            * Klebepunkt selektieren
            ******************************************************************/
            if (!rMEvt.IsShift())
                mpView->UnmarkAllGluePoints();

            mpView->MarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
            SdrHdl* pHdl = mpView->GetGluePointHdl(aVEvt.pObj, aVEvt.nGlueId);

            if (pHdl)
            {
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
            }
        }
        else
        {
            /******************************************************************
            * Objekt selektieren oder draggen
            ******************************************************************/
            if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SDRHIT_UNMARKEDOBJECT)
            {
               mpView->UnmarkAllObj();
            }

            BOOL bMarked = FALSE;

            if (!rMEvt.IsMod1())
            {
                if (rMEvt.IsMod2())
                {
                    bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
                }
                else
                {
                    bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift());
                }
            }

            if (bMarked &&
                (!rMEvt.IsShift() || eHit == SDRHIT_MARKEDOBJECT))
            {
                // Objekt verschieben
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
            }
            else if (mpView->AreObjectsMarked())
            {
                /**************************************************************
                * Klebepunkt selektieren
                **************************************************************/
                if (!rMEvt.IsShift())
                    mpView->UnmarkAllGluePoints();

                mpView->BegMarkGluePoints(aMDPos);
            }
            else
            {
                /**************************************************************
                * Objekt selektieren
                **************************************************************/
                mpView->BegMarkObj(aMDPos);
            }
        }

        ForcePointer(&rMEvt);
    }

    return bReturn;
}

/*************************************************************************
|*
|* MouseMove-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseMove(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    FuDraw::MouseMove(rMEvt);

    if (mpView->IsAction())
    {
        Point aPix(rMEvt.GetPosPixel());
        Point aPnt( mpWindow->PixelToLogic(aPix) );
        ForceScroll(aPix);
        mpView->MovAction(aPnt);
    }

    ForcePointer(&rMEvt);

    return TRUE;
}

/*************************************************************************
|*
|* MouseButtonUp-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseButtonUp(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FALSE;

    if (mpView->IsAction())
    {
        bReturn = TRUE;
        mpView->EndAction();
    }

    FuDraw::MouseButtonUp(rMEvt);

    USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
    Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );

    if (Abs(aMDPos.X() - aPos.X()) < nDrgLog &&
        Abs(aMDPos.Y() - aPos.Y()) < nDrgLog &&
        !rMEvt.IsShift() && !rMEvt.IsMod2())
    {
        SdrViewEvent aVEvt;
        SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);

        if (eHit == SDRHIT_NONE)
        {
            // Klick auf der Stelle: deselektieren
            mpView->UnmarkAllObj();
        }
    }

    mpWindow->ReleaseMouse();

    return bReturn;
}

/*************************************************************************
|*
|* Tastaturereignisse bearbeiten
|*
|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
|* FALSE.
|*
\************************************************************************/

BOOL FuEditGluePoints::KeyInput(const KeyEvent& rKEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FuDraw::KeyInput(rKEvt);

    return bReturn;
}

/*************************************************************************
|*
|* Command-event
|*
\************************************************************************/

BOOL FuEditGluePoints::Command(const CommandEvent& rCEvt)
{
    mpView->SetActualWin( mpWindow );
    return FuPoor::Command( rCEvt );
}

/*************************************************************************
|*
|* Funktion aktivieren
|*
\************************************************************************/

void FuEditGluePoints::Activate()
{
    mpView->SetGluePointEditMode();
    FuDraw::Activate();
}

/*************************************************************************
|*
|* Funktion deaktivieren
|*
\************************************************************************/

void FuEditGluePoints::Deactivate()
{
    mpView->SetGluePointEditMode( FALSE );
    FuDraw::Deactivate();
}

/*************************************************************************
|*
|* Request verarbeiten
|*
\************************************************************************/

void FuEditGluePoints::ReceiveRequest(SfxRequest& rReq)
{
    switch (rReq.GetSlot())
    {
        case SID_GLUE_INSERT_POINT:
        {
            mpView->SetInsGluePointMode(!mpView->IsInsGluePointMode());
        }
        break;

        case SID_GLUE_ESCDIR_LEFT:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_LEFT,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_LEFT ) );
        }
        break;

        case SID_GLUE_ESCDIR_RIGHT:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_RIGHT,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_RIGHT ) );
        }
        break;

        case SID_GLUE_ESCDIR_TOP:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_TOP,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_TOP ) );
        }
        break;

        case SID_GLUE_ESCDIR_BOTTOM:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_BOTTOM,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_BOTTOM ) );
        }
        break;

        case SID_GLUE_PERCENT:
        {
            const SfxItemSet* pSet = rReq.GetArgs();
            const SfxPoolItem& rItem = pSet->Get(SID_GLUE_PERCENT);
            BOOL bPercent = ((const SfxBoolItem&) rItem).GetValue();
            mpView->SetMarkedGluePointsPercent(bPercent);
        }
        break;

        case SID_GLUE_HORZALIGN_CENTER:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_CENTER);
        }
        break;

        case SID_GLUE_HORZALIGN_LEFT:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_LEFT);
        }
        break;

        case SID_GLUE_HORZALIGN_RIGHT:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_RIGHT);
        }
        break;

        case SID_GLUE_VERTALIGN_CENTER:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_CENTER);
        }
        break;

        case SID_GLUE_VERTALIGN_TOP:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_TOP);
        }
        break;

        case SID_GLUE_VERTALIGN_BOTTOM:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_BOTTOM);
        }
        break;
    }

    // Zum Schluss Basisklasse rufen
    FuPoor::ReceiveRequest(rReq);
}

} // end of namespace sd
<commit_msg>INTEGRATION: CWS impress122 (1.11.114); FILE MERGED 2007/06/12 15:02:09 af 1.11.114.1: #141146# Made the ToolBarManager a shared_ptr member of ViewShellBase.<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fuediglu.cxx,v $
 *
 *  $Revision: 1.12 $
 *
 *  last change: $Author: hr $ $Date: 2007-06-27 15:42:43 $
 *
 *  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_sd.hxx"

#include "fuediglu.hxx"

#ifndef _SFXENUMITEM_HXX //autogen
#include <svtools/eitem.hxx>
#endif
#include <svx/dialogs.hrc>
#ifndef _SVDGLUE_HXX //autogen
#include <svx/svdglue.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif

#include "app.hrc"
#include "strings.hrc"
#include "res_bmp.hrc"
#ifndef SD_WINDOW_SHELL_HXX
#include "Window.hxx"
#endif
#include "drawdoc.hxx"
#ifndef SD_FRAMW_VIEW_HXX
#include "FrameView.hxx"
#endif
#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_VIEW_SHELL_HXX
#include "ViewShell.hxx"
#endif
#ifndef SD_VIEW_SHELL_BASE_HXX
#include "ViewShellBase.hxx"
#endif
#ifndef SD_TOOL_BAR_MANAGER_HXX
#include "ToolBarManager.hxx"
#endif

namespace sd {

TYPEINIT1( FuEditGluePoints, FuDraw );

/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/

FuEditGluePoints::FuEditGluePoints (
    ViewShell* pViewSh,
    ::sd::Window* pWin,
    ::sd::View* pView,
    SdDrawDocument* pDoc,
    SfxRequest& rReq)
    : FuDraw(pViewSh, pWin, pView, pDoc, rReq)
{
}

FunctionReference FuEditGluePoints::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq, bool bPermanent )
{
    FuEditGluePoints* pFunc;
    FunctionReference xFunc( pFunc = new FuEditGluePoints( pViewSh, pWin, pView, pDoc, rReq ) );
    xFunc->DoExecute(rReq);
    pFunc->SetPermanent( bPermanent );
    return xFunc;
}

void FuEditGluePoints::DoExecute( SfxRequest& rReq )
{
    FuDraw::DoExecute( rReq );
    mpView->SetInsGluePointMode(FALSE);
    mpViewShell->GetViewShellBase().GetToolBarManager()->AddToolBar(
        ToolBarManager::TBG_FUNCTION,
        ToolBarManager::msGluePointsToolBar);
}

/*************************************************************************
|*
|* Destruktor
|*
\************************************************************************/

FuEditGluePoints::~FuEditGluePoints()
{
    mpView->BrkAction();
    mpView->UnmarkAllGluePoints();
    mpView->SetInsGluePointMode(FALSE);
}

/*************************************************************************
|*
|* MouseButtonDown-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseButtonDown(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FuDraw::MouseButtonDown(rMEvt);

    if (mpView->IsAction())
    {
        if (rMEvt.IsRight())
            mpView->BckAction();

        return TRUE;
    }

    if (rMEvt.IsLeft())
    {
        bReturn = TRUE;
        USHORT nHitLog = USHORT ( mpWindow->PixelToLogic(Size(HITPIX,0)).Width() );
        USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
        mpWindow->CaptureMouse();

        SdrViewEvent aVEvt;
        SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);

        if (eHit == SDRHIT_HANDLE)
        {
            /******************************************************************
            * Handle draggen
            ******************************************************************/
            SdrHdl* pHdl = aVEvt.pHdl;

            if (mpView->IsGluePointMarked(aVEvt.pObj, aVEvt.nGlueId) && rMEvt.IsShift())
            {
                mpView->UnmarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
                pHdl = NULL;
            }

            if (pHdl)
            {
                // Handle draggen
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
            }
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && mpView->IsInsGluePointMode())
        {
            /******************************************************************
            * Klebepunkt einfuegen
            ******************************************************************/
            mpView->BegInsGluePoint(aMDPos);
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && rMEvt.IsMod1())
        {
            /******************************************************************
            * Klebepunkt selektieren
            ******************************************************************/
            if (!rMEvt.IsShift())
                mpView->UnmarkAllGluePoints();

            mpView->BegMarkGluePoints(aMDPos);
        }
        else if (eHit == SDRHIT_MARKEDOBJECT && !rMEvt.IsShift() && !rMEvt.IsMod2())
        {
            /******************************************************************
            * Objekt verschieben
            ******************************************************************/
            mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, NULL, nDrgLog);
        }
        else if (eHit == SDRHIT_GLUEPOINT)
        {
            /******************************************************************
            * Klebepunkt selektieren
            ******************************************************************/
            if (!rMEvt.IsShift())
                mpView->UnmarkAllGluePoints();

            mpView->MarkGluePoint(aVEvt.pObj, aVEvt.nGlueId, aVEvt.pPV);
            SdrHdl* pHdl = mpView->GetGluePointHdl(aVEvt.pObj, aVEvt.nGlueId);

            if (pHdl)
            {
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, pHdl, nDrgLog);
            }
        }
        else
        {
            /******************************************************************
            * Objekt selektieren oder draggen
            ******************************************************************/
            if (!rMEvt.IsShift() && !rMEvt.IsMod2() && eHit == SDRHIT_UNMARKEDOBJECT)
            {
               mpView->UnmarkAllObj();
            }

            BOOL bMarked = FALSE;

            if (!rMEvt.IsMod1())
            {
                if (rMEvt.IsMod2())
                {
                    bMarked = mpView->MarkNextObj(aMDPos, nHitLog, rMEvt.IsShift());
                }
                else
                {
                    bMarked = mpView->MarkObj(aMDPos, nHitLog, rMEvt.IsShift());
                }
            }

            if (bMarked &&
                (!rMEvt.IsShift() || eHit == SDRHIT_MARKEDOBJECT))
            {
                // Objekt verschieben
                mpView->BegDragObj(aMDPos, (OutputDevice*) NULL, aVEvt.pHdl, nDrgLog);
            }
            else if (mpView->AreObjectsMarked())
            {
                /**************************************************************
                * Klebepunkt selektieren
                **************************************************************/
                if (!rMEvt.IsShift())
                    mpView->UnmarkAllGluePoints();

                mpView->BegMarkGluePoints(aMDPos);
            }
            else
            {
                /**************************************************************
                * Objekt selektieren
                **************************************************************/
                mpView->BegMarkObj(aMDPos);
            }
        }

        ForcePointer(&rMEvt);
    }

    return bReturn;
}

/*************************************************************************
|*
|* MouseMove-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseMove(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    FuDraw::MouseMove(rMEvt);

    if (mpView->IsAction())
    {
        Point aPix(rMEvt.GetPosPixel());
        Point aPnt( mpWindow->PixelToLogic(aPix) );
        ForceScroll(aPix);
        mpView->MovAction(aPnt);
    }

    ForcePointer(&rMEvt);

    return TRUE;
}

/*************************************************************************
|*
|* MouseButtonUp-event
|*
\************************************************************************/

BOOL FuEditGluePoints::MouseButtonUp(const MouseEvent& rMEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FALSE;

    if (mpView->IsAction())
    {
        bReturn = TRUE;
        mpView->EndAction();
    }

    FuDraw::MouseButtonUp(rMEvt);

    USHORT nDrgLog = USHORT ( mpWindow->PixelToLogic(Size(DRGPIX,0)).Width() );
    Point aPos = mpWindow->PixelToLogic( rMEvt.GetPosPixel() );

    if (Abs(aMDPos.X() - aPos.X()) < nDrgLog &&
        Abs(aMDPos.Y() - aPos.Y()) < nDrgLog &&
        !rMEvt.IsShift() && !rMEvt.IsMod2())
    {
        SdrViewEvent aVEvt;
        SdrHitKind eHit = mpView->PickAnything(rMEvt, SDRMOUSEBUTTONDOWN, aVEvt);

        if (eHit == SDRHIT_NONE)
        {
            // Klick auf der Stelle: deselektieren
            mpView->UnmarkAllObj();
        }
    }

    mpWindow->ReleaseMouse();

    return bReturn;
}

/*************************************************************************
|*
|* Tastaturereignisse bearbeiten
|*
|* Wird ein KeyEvent bearbeitet, so ist der Return-Wert TRUE, andernfalls
|* FALSE.
|*
\************************************************************************/

BOOL FuEditGluePoints::KeyInput(const KeyEvent& rKEvt)
{
    mpView->SetActualWin( mpWindow );

    BOOL bReturn = FuDraw::KeyInput(rKEvt);

    return bReturn;
}

/*************************************************************************
|*
|* Command-event
|*
\************************************************************************/

BOOL FuEditGluePoints::Command(const CommandEvent& rCEvt)
{
    mpView->SetActualWin( mpWindow );
    return FuPoor::Command( rCEvt );
}

/*************************************************************************
|*
|* Funktion aktivieren
|*
\************************************************************************/

void FuEditGluePoints::Activate()
{
    mpView->SetGluePointEditMode();
    FuDraw::Activate();
}

/*************************************************************************
|*
|* Funktion deaktivieren
|*
\************************************************************************/

void FuEditGluePoints::Deactivate()
{
    mpView->SetGluePointEditMode( FALSE );
    FuDraw::Deactivate();
}

/*************************************************************************
|*
|* Request verarbeiten
|*
\************************************************************************/

void FuEditGluePoints::ReceiveRequest(SfxRequest& rReq)
{
    switch (rReq.GetSlot())
    {
        case SID_GLUE_INSERT_POINT:
        {
            mpView->SetInsGluePointMode(!mpView->IsInsGluePointMode());
        }
        break;

        case SID_GLUE_ESCDIR_LEFT:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_LEFT,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_LEFT ) );
        }
        break;

        case SID_GLUE_ESCDIR_RIGHT:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_RIGHT,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_RIGHT ) );
        }
        break;

        case SID_GLUE_ESCDIR_TOP:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_TOP,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_TOP ) );
        }
        break;

        case SID_GLUE_ESCDIR_BOTTOM:
        {
            mpView->SetMarkedGluePointsEscDir( SDRESC_BOTTOM,
                    !mpView->IsMarkedGluePointsEscDir( SDRESC_BOTTOM ) );
        }
        break;

        case SID_GLUE_PERCENT:
        {
            const SfxItemSet* pSet = rReq.GetArgs();
            const SfxPoolItem& rItem = pSet->Get(SID_GLUE_PERCENT);
            BOOL bPercent = ((const SfxBoolItem&) rItem).GetValue();
            mpView->SetMarkedGluePointsPercent(bPercent);
        }
        break;

        case SID_GLUE_HORZALIGN_CENTER:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_CENTER);
        }
        break;

        case SID_GLUE_HORZALIGN_LEFT:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_LEFT);
        }
        break;

        case SID_GLUE_HORZALIGN_RIGHT:
        {
            mpView->SetMarkedGluePointsAlign(FALSE, SDRHORZALIGN_RIGHT);
        }
        break;

        case SID_GLUE_VERTALIGN_CENTER:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_CENTER);
        }
        break;

        case SID_GLUE_VERTALIGN_TOP:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_TOP);
        }
        break;

        case SID_GLUE_VERTALIGN_BOTTOM:
        {
            mpView->SetMarkedGluePointsAlign(TRUE, SDRVERTALIGN_BOTTOM);
        }
        break;
    }

    // Zum Schluss Basisklasse rufen
    FuPoor::ReceiveRequest(rReq);
}

} // end of namespace sd
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fumeasur.cxx,v $
 *
 *  $Revision: 1.6 $
 *
 *  last change: $Author: rt $ $Date: 2005-12-14 17:00:19 $
 *
 *  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
 *
 ************************************************************************/

#pragma hdrstop

#include "fumeasur.hxx"

//CHINA001 #include <svx/measure.hxx>
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif

#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_VIEW_SHELL_HXX
#include "ViewShell.hxx"
#endif
#include "drawdoc.hxx"
#include <svx/svxdlg.hxx> //CHINA001
#include <svx/dialogs.hrc> //CHINA001

namespace sd {

TYPEINIT1( FuMeasureDlg, FuPoor );

/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/

FuMeasureDlg::FuMeasureDlg (
    ViewShell* pViewSh,
    ::sd::Window* pWin,
    ::sd::View* pView,
    SdDrawDocument* pDoc,
    SfxRequest& rReq)
    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}

FunctionReference FuMeasureDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
    FunctionReference xFunc( new FuMeasureDlg( pViewSh, pWin, pView, pDoc, rReq ) );
    xFunc->DoExecute(rReq);
    return xFunc;
}

void FuMeasureDlg::DoExecute( SfxRequest& rReq )
{
    SfxItemSet aNewAttr( pDoc->GetPool() );
    pView->GetAttributes( aNewAttr );

    const SfxItemSet* pArgs = rReq.GetArgs();

    ::std::auto_ptr<AbstractSfxSingleTabDialog> pDlg (NULL);
    if( !pArgs )
    {
        //CHINA001 SvxMeasureDialog* pDlg = new SvxMeasureDialog( NULL, aNewAttr, pView );
        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
        DBG_ASSERT(pFact, "Dialogdiet Factory fail!");//CHINA001
        pDlg.reset (pFact->CreateSfxSingleTabDialog( NULL,
                aNewAttr,
                pView,
                ResId(RID_SVXPAGE_MEASURE)));
        DBG_ASSERT(pDlg.get()!=NULL, "Dialogdiet fail!");//CHINA001

        USHORT nResult = pDlg->Execute();

        switch( nResult )
        {
            case RET_OK:
            {
                pArgs = pDlg->GetOutputItemSet();
                rReq.Done( *pArgs );
            }
            break;

            default:
                return; // Abbruch
        }
    }
    pView->SetAttributes( *pArgs );
}

} // end of namespace sd
<commit_msg>INTEGRATION: CWS pchfix02 (1.6.214); FILE MERGED 2006/09/01 17:37:07 kaib 1.6.214.1: #i68856# Added header markers and pch files<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: fumeasur.cxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: obo $ $Date: 2006-09-16 18:51:55 $
 *
 *  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_sd.hxx"

#include "fumeasur.hxx"

//CHINA001 #include <svx/measure.hxx>
#ifndef _SV_MSGBOX_HXX //autogen
#include <vcl/msgbox.hxx>
#endif
#ifndef _SFXREQUEST_HXX //autogen
#include <sfx2/request.hxx>
#endif

#ifndef SD_VIEW_HXX
#include "View.hxx"
#endif
#ifndef SD_VIEW_SHELL_HXX
#include "ViewShell.hxx"
#endif
#include "drawdoc.hxx"
#include <svx/svxdlg.hxx> //CHINA001
#include <svx/dialogs.hrc> //CHINA001

namespace sd {

TYPEINIT1( FuMeasureDlg, FuPoor );

/*************************************************************************
|*
|* Konstruktor
|*
\************************************************************************/

FuMeasureDlg::FuMeasureDlg (
    ViewShell* pViewSh,
    ::sd::Window* pWin,
    ::sd::View* pView,
    SdDrawDocument* pDoc,
    SfxRequest& rReq)
    : FuPoor(pViewSh, pWin, pView, pDoc, rReq)
{
}

FunctionReference FuMeasureDlg::Create( ViewShell* pViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument* pDoc, SfxRequest& rReq )
{
    FunctionReference xFunc( new FuMeasureDlg( pViewSh, pWin, pView, pDoc, rReq ) );
    xFunc->DoExecute(rReq);
    return xFunc;
}

void FuMeasureDlg::DoExecute( SfxRequest& rReq )
{
    SfxItemSet aNewAttr( pDoc->GetPool() );
    pView->GetAttributes( aNewAttr );

    const SfxItemSet* pArgs = rReq.GetArgs();

    ::std::auto_ptr<AbstractSfxSingleTabDialog> pDlg (NULL);
    if( !pArgs )
    {
        //CHINA001 SvxMeasureDialog* pDlg = new SvxMeasureDialog( NULL, aNewAttr, pView );
        SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
        DBG_ASSERT(pFact, "Dialogdiet Factory fail!");//CHINA001
        pDlg.reset (pFact->CreateSfxSingleTabDialog( NULL,
                aNewAttr,
                pView,
                ResId(RID_SVXPAGE_MEASURE)));
        DBG_ASSERT(pDlg.get()!=NULL, "Dialogdiet fail!");//CHINA001

        USHORT nResult = pDlg->Execute();

        switch( nResult )
        {
            case RET_OK:
            {
                pArgs = pDlg->GetOutputItemSet();
                rReq.Done( *pArgs );
            }
            break;

            default:
                return; // Abbruch
        }
    }
    pView->SetAttributes( *pArgs );
}

} // end of namespace sd
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: unoobj.hxx,v $
 *
 *  $Revision: 1.7 $
 *
 *  last change: $Author: cl $ $Date: 2001-12-04 16:10: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 _UNOOBJ_HXX
#define _UNOOBJ_HXX

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
#include <com/sun/star/drawing/XShape.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
#include <com/sun/star/lang/XTypeProvider.hpp>
#endif

#ifndef _SVDPOOL_HXX //autogen
#include <svx/svdpool.hxx>
#endif

#ifndef _SVX_UNOMASTER_HXX
#include <svx/unomaster.hxx>
#endif

#include <svx/unoipset.hxx>

#include <cppuhelper/implbase2.hxx>

class SdrObject;
class SdXImpressDocument;
class SdAnimationInfo;

class SdXShape : public SvxShapeMaster,
                 public ::com::sun::star::document::XEventsSupplier
{
    friend class SdUnoEventsAccess;

private:
    SvxShape* mpShape;
    SvxItemPropertySet  maPropSet;
    const SfxItemPropertyMap* mpMap;
    SdXImpressDocument* mpModel;

    void SetStyleSheet( const ::com::sun::star::uno::Any& rAny ) throw( ::com::sun::star::lang::IllegalArgumentException );
    ::com::sun::star::uno::Any GetStyleSheet() const throw( ::com::sun::star::beans::UnknownPropertyException  );

    // Intern
    SdAnimationInfo* GetAnimationInfo( sal_Bool bCreate = sal_False ) const throw();
    sal_Bool IsPresObj() const throw();
    void SetPresObj( sal_Bool bPresObj ) throw();

    sal_Bool IsEmptyPresObj() const throw();
    void SetEmptyPresObj( sal_Bool bEmpty ) throw();

    sal_Bool IsMasterDepend() const throw();
    void SetMasterDepend( sal_Bool bDepend ) throw();

    SdrObject* GetSdrObject() const throw();
    sal_Int32 GetPresentationOrderPos() const throw();
    void SetPresentationOrderPos( sal_Int32 nPos ) throw();

    com::sun::star::uno::Sequence< sal_Int8 >* mpImplementationId;

public:
    SdXShape() throw();
    SdXShape(SvxShape* pShape, SdXImpressDocument* pModel) throw();
    virtual ~SdXShape() throw();

    virtual sal_Bool queryAggregation( const com::sun::star::uno::Type & rType, com::sun::star::uno::Any& aAny );
    virtual void dispose();

    // XInterface
    virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL acquire() throw();
    virtual void SAL_CALL release() throw();

    // XServiceInfo
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);

    //XPropertySet
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    //XPropertyState
    virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    // XTypeProvider
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);

    // XEventsSupplier
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw(::com::sun::star::uno::RuntimeException);
};

struct SvEventDescription;
const SvEventDescription* ImplGetSupportedMacroItems();

#endif

<commit_msg>INTEGRATION: CWS presentationengine01 (1.7.344); FILE MERGED 2004/08/22 22:25:10 cl 1.7.344.1: first wrapper for old animation api<commit_after>/*************************************************************************
 *
 *  $RCSfile: unoobj.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: rt $ $Date: 2004-11-26 20:28:52 $
 *
 *  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 _UNOOBJ_HXX
#define _UNOOBJ_HXX

#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSTATE_HPP_
#include <com/sun/star/beans/XPropertyState.hpp>
#endif
#ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
#include <com/sun/star/beans/XPropertySet.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XSERVICEINFO_HPP_
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
#ifndef _COM_SUN_STAR_DRAWING_XSHAPE_HPP_
#include <com/sun/star/drawing/XShape.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_DOCUMENT_XEVENTSSUPPLIER_HPP_
#include <com/sun/star/document/XEventsSupplier.hpp>
#endif
#ifndef _COM_SUN_STAR_LANG_XTYPEPROVIDER_HPP_
#include <com/sun/star/lang/XTypeProvider.hpp>
#endif

#ifndef _SVDPOOL_HXX //autogen
#include <svx/svdpool.hxx>
#endif

#ifndef _SVX_UNOMASTER_HXX
#include <svx/unomaster.hxx>
#endif

#include <svx/unoipset.hxx>

#include <cppuhelper/implbase2.hxx>

class SdrObject;
class SdXImpressDocument;
class SdAnimationInfo;

class SdXShape : public SvxShapeMaster,
                 public ::com::sun::star::document::XEventsSupplier
{
    friend class SdUnoEventsAccess;

private:
    SvxShape* mpShape;
    SvxItemPropertySet  maPropSet;
    const SfxItemPropertyMap* mpMap;
    SdXImpressDocument* mpModel;

    void SetStyleSheet( const ::com::sun::star::uno::Any& rAny ) throw( ::com::sun::star::lang::IllegalArgumentException );
    ::com::sun::star::uno::Any GetStyleSheet() const throw( ::com::sun::star::beans::UnknownPropertyException  );

    // Intern
    SdAnimationInfo* GetAnimationInfo( sal_Bool bCreate = sal_False ) const throw();
    sal_Bool IsPresObj() const throw();
    void SetPresObj( sal_Bool bPresObj ) throw();

    sal_Bool IsEmptyPresObj() const throw();
    void SetEmptyPresObj( sal_Bool bEmpty ) throw();

    sal_Bool IsMasterDepend() const throw();
    void SetMasterDepend( sal_Bool bDepend ) throw();

    SdrObject* GetSdrObject() const throw();
    sal_Int32 GetPresentationOrderPos() const throw();
    void SetPresentationOrderPos( sal_Int32 nPos ) throw();

    com::sun::star::uno::Sequence< sal_Int8 >* mpImplementationId;

public:
    SdXShape() throw();
    SdXShape(SvxShape* pShape, SdXImpressDocument* pModel) throw();
    virtual ~SdXShape() throw();

    virtual sal_Bool queryAggregation( const com::sun::star::uno::Type & rType, com::sun::star::uno::Any& aAny );
    virtual void dispose();

    // XInterface
    virtual ::com::sun::star::uno::Any SAL_CALL queryAggregation( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type & rType ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL acquire() throw();
    virtual void SAL_CALL release() throw();

    // XServiceInfo
    virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames() throw(::com::sun::star::uno::RuntimeException);

    //XPropertySet
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo(  ) throw(::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyValue( const ::rtl::OUString& aPropertyName, const ::com::sun::star::uno::Any& aValue ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::beans::PropertyVetoException, ::com::sun::star::lang::IllegalArgumentException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyValue( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    //XPropertyState
    virtual ::com::sun::star::beans::PropertyState SAL_CALL getPropertyState( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual void SAL_CALL setPropertyToDefault( const ::rtl::OUString& PropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::uno::RuntimeException);
    virtual ::com::sun::star::uno::Any SAL_CALL getPropertyDefault( const ::rtl::OUString& aPropertyName ) throw(::com::sun::star::beans::UnknownPropertyException, ::com::sun::star::lang::WrappedTargetException, ::com::sun::star::uno::RuntimeException);

    // XTypeProvider
    virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > SAL_CALL getTypes(  ) throw(::com::sun::star::uno::RuntimeException);

    // XEventsSupplier
    virtual ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameReplace > SAL_CALL getEvents(  ) throw(::com::sun::star::uno::RuntimeException);

private:
    void setOldEffect( const com::sun::star::uno::Any& aValue );
    void setOldTextEffect( const com::sun::star::uno::Any& aValue );
    void setOldSpeed( const com::sun::star::uno::Any& aValue );
    void setOldDimColor( const com::sun::star::uno::Any& aValue );
    void setOldDimHide( const com::sun::star::uno::Any& aValue );
    void setOldDimPrevious( const com::sun::star::uno::Any& aValue );
    void setOldPresOrder( const com::sun::star::uno::Any& aValue );

};

struct SvEventDescription;
const SvEventDescription* ImplGetSupportedMacroItems();

#endif

<|endoftext|>


<commit_before>//=- ClangDiagnosticsEmitter.cpp - Generate Clang diagnostics tables -*- C++ -*-
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// These tablegen backends emit Clang diagnostics tables.
//
//===----------------------------------------------------------------------===//

#include "ClangDiagnosticsEmitter.h"
#include "Record.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Streams.h"
#include "llvm/ADT/VectorExtras.h"
#include "llvm/ADT/DenseSet.h"
#include <set>
#include <map>

using namespace llvm;

//===----------------------------------------------------------------------===//
// Generic routines for all Clang TableGen backens.
//===----------------------------------------------------------------------===//

typedef std::vector<Record*> RecordVector;
typedef std::vector<Record*> SuperClassVector;
typedef std::vector<RecordVal> RecordValVector;

static const RecordVal* findRecordVal(const Record& R, const std::string &key) {
  const RecordValVector &Vals = R.getValues();
  for (RecordValVector::const_iterator I=Vals.begin(), E=Vals.end(); I!=E; ++I)
    if ((*I).getName() == key)
      return &*I;

  return 0;
}

static const Record* getDiagKind(const Record* DiagClass, const Record &R) {
  const SuperClassVector &SC = R.getSuperClasses();
  for (SuperClassVector::const_iterator I=SC.begin(), E=SC.end(); I!=E; ++I)
    if ((*I)->isSubClassOf(DiagClass))
      return *I;

  return 0;
}

static void EmitEscaped(std::ostream& OS, const std::string &s) {
  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
    switch (*I) {
      default: OS << *I; break;
      case '\"': OS << "\\" << *I; break;
      case '\\': OS << "\\\\"; break;
    }
}

static void EmitAllCaps(std::ostream& OS, const std::string &s) {
  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
    OS << char(toupper(*I));
}

//===----------------------------------------------------------------------===//
// Warning Tables (.inc file) generation.
//===----------------------------------------------------------------------===//

static void ProcessDiag(std::ostream& OS, const Record* DiagClass,
                        const Record& R) {

  const Record* DiagKind = getDiagKind(DiagClass, R);
  if (!DiagKind)
    return;

  OS << "DIAG(" << R.getName() << ", ";
  EmitAllCaps(OS, DiagKind->getName());

  const RecordVal* Text = findRecordVal(R, "Text");
  assert(Text && "No 'Text' entry in Diagnostic.");
  const StringInit* TextVal = dynamic_cast<const StringInit*>(Text->getValue());
  assert(TextVal && "Value 'Text' must be a string.");
  OS << ", \"";
  EmitEscaped(OS, TextVal->getValue());
  OS << "\")\n";
}

void ClangDiagsDefsEmitter::run(std::ostream &OS) {
  const RecordVector &Diags = Records.getAllDerivedDefinitions("Diagnostic");

  const Record* DiagClass = Records.getClass("Diagnostic");
  assert(DiagClass && "No Diagnostic class defined.");

  // Write the #if guard
  if (!Component.empty()) {
    OS << "#ifdef ";
    EmitAllCaps(OS, Component);
    OS << "START\n__";
    EmitAllCaps(OS, Component);
    OS << "START = DIAG_START_";
    EmitAllCaps(OS, Component);
    OS << ",\n#undef ";
    EmitAllCaps(OS, Component);
    OS << "START\n#endif\n";
  }

  for (RecordVector::const_iterator I=Diags.begin(), E=Diags.end(); I!=E; ++I) {
    if (!Component.empty()) {
      const RecordVal* V = findRecordVal(**I, "Component");
      if (!V)
        continue;

      const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
      if (SV->getValue() != Component)
        continue;
    }

    ProcessDiag(OS, DiagClass, **I);
  }
}

//===----------------------------------------------------------------------===//
// Warning Group Tables generation.
//===----------------------------------------------------------------------===//

typedef std::set<const Record*> DiagnosticSet;
typedef std::map<const Record*, DiagnosticSet> OptionMap;
typedef llvm::DenseSet<const ListInit*> VisitedLists;

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited, const Init* X);

static void BuildGroup(DiagnosticSet &DS, VisitedLists &Visited,
                       const ListInit* LV) {

  // Simple hack to prevent including a list multiple times.  This may be useful
  // if one declares an Option by including a bunch of other Options that
  // include other Options, etc.
  if (Visited.count(LV))
    return;

  Visited.insert(LV);

  // Iterate through the list and grab all DiagnosticControlled.
  for (ListInit::const_iterator I = LV->begin(), E = LV->end(); I!=E; ++I)
    BuildGroup(DS, Visited, *I);
}

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited,
                       const Record *Def) {

  // If an Option includes another Option, inline the Diagnostics of the
  // included Option.
  if (Def->isSubClassOf("Option")) {
    if (const RecordVal* V = findRecordVal(*Def, "Members"))
      if (const ListInit* LV = dynamic_cast<const ListInit*>(V->getValue()))
        BuildGroup(DS, Visited, LV);

    return;
  }

  if (Def->isSubClassOf("DiagnosticControlled"))
    DS.insert(Def);
}

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited,
                       const Init* X) {

  if (const DefInit *D = dynamic_cast<const DefInit*>(X))
    BuildGroup(DS, Visited, D->getDef());

  // We may have some other cases here in the future.
}

void ClangOptionsEmitter::run(std::ostream &OS) {
  // Build up a map from options to controlled diagnostics.
  OptionMap OM;

  const RecordVector &Opts = Records.getAllDerivedDefinitions("Option");
  for (RecordVector::const_iterator I=Opts.begin(), E=Opts.end(); I!=E; ++I)
    if (const RecordVal* V = findRecordVal(**I, "Members"))
      if (const ListInit* LV = dynamic_cast<const ListInit*>(V->getValue())) {
        VisitedLists Visited;
        BuildGroup(OM[*I], Visited, LV);
      }

  // Iterate through the OptionMap and emit the declarations.
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
    // Output the option.
    OS << "static const diag::kind " << I->first->getName() << "[] = { ";

    DiagnosticSet &DS = I->second;
    bool first = true;
    for (DiagnosticSet::iterator I2 = DS.begin(), E2 = DS.end(); I2!=E2; ++I2) {
      if (first)
        first = false;
      else
        OS << ", ";

      OS << "diag::" << (*I2)->getName();
    }
    OS << " };\n";
  }

  // Now emit the OptionTable table.
  OS << "\nstatic const WarningOption OptionTable[] = {";
  bool first = true;
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
    const RecordVal *V = findRecordVal(*I->first, "Name");
    assert(V && "Options must have a 'Name' value.");
    const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
    assert(SV && "'Name' entry must be a string.");

    if (first)
      first = false;
    else
      OS << ',';

    OS << "\n  {\"" << SV->getValue()
       << "\", DIAGS(" << I->first->getName() << ")}";
  }
  OS << "\n};\n";
}
<commit_msg>tblgen -gen-clang-diags-options: Output OptionTable entries in lexicographic order.<commit_after>//=- ClangDiagnosticsEmitter.cpp - Generate Clang diagnostics tables -*- C++ -*-
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
// These tablegen backends emit Clang diagnostics tables.
//
//===----------------------------------------------------------------------===//

#include "ClangDiagnosticsEmitter.h"
#include "Record.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Streams.h"
#include "llvm/ADT/VectorExtras.h"
#include "llvm/ADT/DenseSet.h"
#include <set>
#include <map>

using namespace llvm;

//===----------------------------------------------------------------------===//
// Generic routines for all Clang TableGen backens.
//===----------------------------------------------------------------------===//

typedef std::vector<Record*> RecordVector;
typedef std::vector<Record*> SuperClassVector;
typedef std::vector<RecordVal> RecordValVector;

static const RecordVal* findRecordVal(const Record& R, const std::string &key) {
  const RecordValVector &Vals = R.getValues();
  for (RecordValVector::const_iterator I=Vals.begin(), E=Vals.end(); I!=E; ++I)
    if ((*I).getName() == key)
      return &*I;

  return 0;
}

static const Record* getDiagKind(const Record* DiagClass, const Record &R) {
  const SuperClassVector &SC = R.getSuperClasses();
  for (SuperClassVector::const_iterator I=SC.begin(), E=SC.end(); I!=E; ++I)
    if ((*I)->isSubClassOf(DiagClass))
      return *I;

  return 0;
}

static void EmitEscaped(std::ostream& OS, const std::string &s) {
  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
    switch (*I) {
      default: OS << *I; break;
      case '\"': OS << "\\" << *I; break;
      case '\\': OS << "\\\\"; break;
    }
}

static void EmitAllCaps(std::ostream& OS, const std::string &s) {
  for (std::string::const_iterator I=s.begin(), E=s.end(); I!=E; ++I)
    OS << char(toupper(*I));
}

//===----------------------------------------------------------------------===//
// Warning Tables (.inc file) generation.
//===----------------------------------------------------------------------===//

static void ProcessDiag(std::ostream& OS, const Record* DiagClass,
                        const Record& R) {

  const Record* DiagKind = getDiagKind(DiagClass, R);
  if (!DiagKind)
    return;

  OS << "DIAG(" << R.getName() << ", ";
  EmitAllCaps(OS, DiagKind->getName());

  const RecordVal* Text = findRecordVal(R, "Text");
  assert(Text && "No 'Text' entry in Diagnostic.");
  const StringInit* TextVal = dynamic_cast<const StringInit*>(Text->getValue());
  assert(TextVal && "Value 'Text' must be a string.");
  OS << ", \"";
  EmitEscaped(OS, TextVal->getValue());
  OS << "\")\n";
}

void ClangDiagsDefsEmitter::run(std::ostream &OS) {
  const RecordVector &Diags = Records.getAllDerivedDefinitions("Diagnostic");

  const Record* DiagClass = Records.getClass("Diagnostic");
  assert(DiagClass && "No Diagnostic class defined.");

  // Write the #if guard
  if (!Component.empty()) {
    OS << "#ifdef ";
    EmitAllCaps(OS, Component);
    OS << "START\n__";
    EmitAllCaps(OS, Component);
    OS << "START = DIAG_START_";
    EmitAllCaps(OS, Component);
    OS << ",\n#undef ";
    EmitAllCaps(OS, Component);
    OS << "START\n#endif\n";
  }

  for (RecordVector::const_iterator I=Diags.begin(), E=Diags.end(); I!=E; ++I) {
    if (!Component.empty()) {
      const RecordVal* V = findRecordVal(**I, "Component");
      if (!V)
        continue;

      const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
      if (SV->getValue() != Component)
        continue;
    }

    ProcessDiag(OS, DiagClass, **I);
  }
}

//===----------------------------------------------------------------------===//
// Warning Group Tables generation.
//===----------------------------------------------------------------------===//

static const std::string &getOptName(const Record *R) {
  const RecordVal *V = findRecordVal(*R, "Name");
  assert(V && "Options must have a 'Name' value.");
  const StringInit* SV = dynamic_cast<const StringInit*>(V->getValue());
  assert(SV && "'Name' entry must be a string.");
  return SV->getValue();
}

namespace {
struct VISIBILITY_HIDDEN CompareOptName {
  bool operator()(const Record* A, const Record* B) {
    return getOptName(A) < getOptName(B);
  }
};
}

typedef std::set<const Record*> DiagnosticSet;
typedef std::map<const Record*, DiagnosticSet, CompareOptName> OptionMap;
typedef llvm::DenseSet<const ListInit*> VisitedLists;

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited, const Init* X);

static void BuildGroup(DiagnosticSet &DS, VisitedLists &Visited,
                       const ListInit* LV) {

  // Simple hack to prevent including a list multiple times.  This may be useful
  // if one declares an Option by including a bunch of other Options that
  // include other Options, etc.
  if (Visited.count(LV))
    return;

  Visited.insert(LV);

  // Iterate through the list and grab all DiagnosticControlled.
  for (ListInit::const_iterator I = LV->begin(), E = LV->end(); I!=E; ++I)
    BuildGroup(DS, Visited, *I);
}

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited,
                       const Record *Def) {

  // If an Option includes another Option, inline the Diagnostics of the
  // included Option.
  if (Def->isSubClassOf("Option")) {
    if (const RecordVal* V = findRecordVal(*Def, "Members"))
      if (const ListInit* LV = dynamic_cast<const ListInit*>(V->getValue()))
        BuildGroup(DS, Visited, LV);

    return;
  }

  if (Def->isSubClassOf("DiagnosticControlled"))
    DS.insert(Def);
}

static void BuildGroup(DiagnosticSet& DS, VisitedLists &Visited,
                       const Init* X) {

  if (const DefInit *D = dynamic_cast<const DefInit*>(X))
    BuildGroup(DS, Visited, D->getDef());

  // We may have some other cases here in the future.
}

void ClangOptionsEmitter::run(std::ostream &OS) {
  // Build up a map from options to controlled diagnostics.
  OptionMap OM;

  const RecordVector &Opts = Records.getAllDerivedDefinitions("Option");
  for (RecordVector::const_iterator I=Opts.begin(), E=Opts.end(); I!=E; ++I)
    if (const RecordVal* V = findRecordVal(**I, "Members"))
      if (const ListInit* LV = dynamic_cast<const ListInit*>(V->getValue())) {
        VisitedLists Visited;
        BuildGroup(OM[*I], Visited, LV);
      }

  // Iterate through the OptionMap and emit the declarations.
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
    // Output the option.
    OS << "static const diag::kind " << I->first->getName() << "[] = { ";

    DiagnosticSet &DS = I->second;
    bool first = true;
    for (DiagnosticSet::iterator I2 = DS.begin(), E2 = DS.end(); I2!=E2; ++I2) {
      if (first)
        first = false;
      else
        OS << ", ";

      OS << "diag::" << (*I2)->getName();
    }
    OS << " };\n";
  }

  // Now emit the OptionTable table.
  OS << "\nstatic const WarningOption OptionTable[] = {";
  bool first = true;
  for (OptionMap::iterator I = OM.begin(), E = OM.end(); I!=E; ++I) {
    if (first)
      first = false;
    else
      OS << ',';

    OS << "\n  {\"" << getOptName(I->first)
       << "\", DIAGS(" << I->first->getName() << ")}";
  }
  OS << "\n};\n";
}
<|endoftext|>


<commit_before>#include <iostream>
#include <cstdlib>

using namespace std;

class basic
{
    double** p;
    int x;
    int y;

public:
    basic(int x1 = 0, int y1 = 0)
    {
        cout << "Creating basic" << endl;
        x = x1;
        y = y1;
        alloc(x, y);
    }

    ~basic()
    {
        cout << "Deleting basic" << endl;
        free_mem(x, y);
    }

    void alloc(int x, int y)
    {
        p = new double* [x];
        for(int i = 0; i < x; i++)
            *(p + i) = new double[y];
    }

    void free_mem(int x, int y)
    {
        for(int i = 0; i < x; i++)
            delete[] * (p + i);
        delete[] p;
    }

    void show_all()
    {
        cout << "Showing object" << endl;
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++)
                cout << "a[" << i << "][" << j << "]"
                     << " = " << p[i][j] << endl;
        cout << endl;
    }

    void set_object()
    {
        double value;
        cout << "Setting object" << endl;
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++) {
                cout << "a[" << i << "][" << j << "]"
                     << " = ";
                cin >> value;
                p[i][j] = value;
            }
        cout << endl;
    }

    const basic& operator=(const basic& obj2)
    {
        cout << "Operator =" << endl;
        free_mem(x, y);
        x = obj2.x;
        y = obj2.y;
        alloc(x, y);
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++)
                (*this).p[i][j] = obj2.p[i][j];
        return *this;
    }

    void* operator new(size_t size)
    {
        cout << "Using overloaded new:" << size << endl;
        return malloc(size);
    }

    void* operator new [](size_t size) {
        cout << "Using overloaded new[]:" << size << endl;
        return malloc(size);
    }

    void
    operator delete(void* p)
    {
        cout << "Using overloaded delete:" << endl;
        free(p);
    }

    void operator delete [](void* p) {
        cout << "Using overloaded delete[]:" << endl;
        free(p);
    }

    /* const basic
     operator+(const basic& obj2)
     {
         int x_min, y_min, x_max, y_max;

         cout << "Operator +" << endl;
         if(x > obj2.x) {
             x_min = obj2.x;
             x_max = x;
         } else {
             x_min = x;
             x_max = obj2.x;
         }

         if(y > obj2.y) {
             y_min = obj2.y;
             y_max = y;
         } else {
             y_min = y;
             y_max = obj2.y;
         }

         basic temp(x_max, y_max);

         for(int i = 0; i < x_min; i++)
             for(int j = 0; j < y_min; j++)
                 temp.p[i][j] = p[i][j] + obj2.p[i][j];
                 //дописать дополнение разных элементов
         return temp;
     }*/

    /*void compare(const basic& obj2)
    {
        int x_min, y_min;

        if(x > obj2.x)
            x_min = obj2.x;
        else
            x_min = x;

        if(y > obj2.y)
            y_min = obj2.y;
        else
            y_min = y;

        for(int i = 0; i < x_min; i++) {
            for(int j = 0; j < y_min; j++)
                    if(p[i][j]< obj2.p[i][j]) {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] < ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    } else if(p[i][j][k] > obj2.p[i][j][k]) {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] > ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    } else {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] = ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    }
        }
        cout << endl;
    }*/

    friend const basic
    operator+(const basic&, double);
    friend const basic operator+(double, const basic& );
};

const basic operator+(const basic& obj2, double d)
{
    basic temp(obj2.x, obj2.y);
    cout << "Operator + (friendly)" << endl;
    for(int i = 0; i < obj2.x; i++)
        for(int j = 0; j < obj2.y; j++)
            temp.p[i][j] = obj2.p[i][j] + d;
    return temp;
}

const basic operator+(double d, const basic& obj2)
{
    basic temp(obj2.x, obj2.y);
    cout << "Operator + (friendly)" << endl;
    for(int i = 0; i < obj2.x; i++)
        for(int j = 0; j < obj2.y; j++)
            temp.p[i][j] = obj2.p[i][j] + d;
    return temp;
}

int main()
{
    //пример для локального оператора =
    /*basic obj1(2, 1), obj2(2, 2);
    obj1.set_object();
    obj1.show_all();
    obj2.set_object();
    obj2.show_all();
    obj1 = obj2;
    obj1.show_all();*/

//пример для локальных new & delete
    /*basic* ptr;
    ptr = new basic;
    ptr->show_all();
    delete ptr;*/

//пример для локальных new[] & delete[]
    /*basic* ptr2;
    ptr2 = new basic [2];
    for(int i = 0; i < 2; i++)
        ptr2->show_all();
    delete[] ptr2;*/

//пример для локального оператора = (дописать код)
    /*basic obj11(1, 1), obj12(2, 2);
    obj11.set_object();
    obj11.show_all();
    obj12.set_object();
    obj12.show_all();
    obj1 + obj2;
    obj1.show_all();*/

//пример для дружественного оператора =
    basic obj2(2, 1), obj21;
    double d = 8.56;
    obj2.set_object();
    obj2.show_all();
    obj21 = d+obj2 + d ;
    obj21.show_all();
    return 0;
}
<commit_msg>Operator <<<commit_after>#include <iostream>
#include <cstdlib>

using namespace std;

class basic
{
    double** p;
    int x;
    int y;

public:
    basic(int x1 = 0, int y1 = 0)
    {
        cout << "Creating basic" << endl;
        x = x1;
        y = y1;
        alloc(x, y);
    }

    ~basic()
    {
        cout << "Deleting basic" << endl;
        free_mem(x, y);
    }

    void alloc(int x, int y)
    {
        p = new double* [x];
        for(int i = 0; i < x; i++)
            *(p + i) = new double[y];
    }

    void free_mem(int x, int y)
    {
        for(int i = 0; i < x; i++)
            delete[] * (p + i);
        delete[] p;
    }

    void show_all()
    {
        cout << "Showing object" << endl << "X : " << x << endl << "Y : " << y << endl;
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++)
                cout << "a[" << i << "][" << j << "]"
                     << " = " << p[i][j] << endl;
        cout << endl;
    }

    void set_object()
    {
        double value;
        cout << "Setting object" << endl;
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++) {
                cout << "a[" << i << "][" << j << "]"
                     << " = ";
                cin >> value;
                p[i][j] = value;
            }
        cout << endl;
    }

    const basic& operator=(const basic& obj2)
    {
        cout << "Operator =" << endl;
        free_mem(x, y);
        x = obj2.x;
        y = obj2.y;
        alloc(x, y);
        for(int i = 0; i < x; i++)
            for(int j = 0; j < y; j++)
                (*this).p[i][j] = obj2.p[i][j];
        return *this;
    }

    void* operator new(size_t size)
    {
        cout << "Using overloaded new:" << size << endl;
        return malloc(size);
    }

    void* operator new [](size_t size) {
        cout << "Using overloaded new[]:" << size << endl;
        return malloc(size);
    }

    void
    operator delete(void* p)
    {
        cout << "Using overloaded delete:" << endl;
        free(p);
    }

    void operator delete [](void* p) {
        cout << "Using overloaded delete[]:" << endl;
        free(p);
    }

    /* const basic
     operator+(const basic& obj2)
     {
         int x_min, y_min, x_max, y_max;

         cout << "Operator +" << endl;
         if(x > obj2.x) {
             x_min = obj2.x;
             x_max = x;
         } else {
             x_min = x;
             x_max = obj2.x;
         }

         if(y > obj2.y) {
             y_min = obj2.y;
             y_max = y;
         } else {
             y_min = y;
             y_max = obj2.y;
         }

         basic temp(x_max, y_max);

         for(int i = 0; i < x_min; i++)
             for(int j = 0; j < y_min; j++)
                 temp.p[i][j] = p[i][j] + obj2.p[i][j];
                 //дописать дополнение разных элементов
         return temp;
     }*/

    /*void compare(const basic& obj2)
    {
        int x_min, y_min;

        if(x > obj2.x)
            x_min = obj2.x;
        else
            x_min = x;

        if(y > obj2.y)
            y_min = obj2.y;
        else
            y_min = y;

        for(int i = 0; i < x_min; i++) {
            for(int j = 0; j < y_min; j++)
                    if(p[i][j]< obj2.p[i][j]) {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] < ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    } else if(p[i][j][k] > obj2.p[i][j][k]) {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] > ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    } else {
                        cout << "obj1[" << i << "][" << j << "][" << k << "] = ";
                        cout << "obj2[" << i << "][" << j << "][" << k << "] " << endl;
                    }
        }
        cout << endl;
    }*/

    friend const basic
    operator+(const basic&, double);
    friend const basic operator+(double, const basic&);
    friend ostream& operator<<(ostream& s, basic& obj);
};

ostream& operator<<(ostream& s, basic& obj)
{
    s << "Operator <<" << endl;
    s << "Matrix size:" << endl;
    s << "X : " << obj.x << endl;
    s << "Y : " << obj.y << endl;
    s << "Matrix elements are:" << endl;
    for(int i = 0; i < obj.x; i++)
        for(int j = 0; j < obj.y; j++)
            s << "a[" << i << "][" << j << "]"
              << " = " << obj.p[i][j] << endl;
    return s;
}

const basic operator+(const basic& obj2, double d)
{
    basic temp(obj2.x, obj2.y);
    cout << "Operator + (friendly)" << endl;
    for(int i = 0; i < obj2.x; i++)
        for(int j = 0; j < obj2.y; j++)
            temp.p[i][j] = obj2.p[i][j] + d;
    return temp;
}

const basic operator+(double d, const basic& obj2)
{
    basic temp(obj2.x, obj2.y);
    cout << "Operator + (friendly)" << endl;
    for(int i = 0; i < obj2.x; i++)
        for(int j = 0; j < obj2.y; j++)
            temp.p[i][j] = obj2.p[i][j] + d;
    return temp;
}

int main()
{
    //пример для локального оператора =
    /*basic obj1(2, 1), obj2(2, 2);
    obj1.set_object();
    obj1.show_all();
    obj2.set_object();
    obj2.show_all();
    obj1 = obj2;
    obj1.show_all();*/

    //пример для локальных new & delete
    /*basic* ptr;
    ptr = new basic;
    ptr->show_all();
    delete ptr;*/

    //пример для локальных new[] & delete[]
    /*basic* ptr2;
    ptr2 = new basic [2];
    for(int i = 0; i < 2; i++)
        ptr2->show_all();
    delete[] ptr2;*/

    //пример для локального оператора = (дописать код)
    /*basic obj11(1, 1), obj12(2, 2);
    obj11.set_object();
    obj11.show_all();
    obj12.set_object();
    obj12.show_all();
    obj1 + obj2;
    obj1.show_all();*/

    //пример для дружественного оператора =
    basic obj2(2, 1), obj21;
    double d = 8.56;
    obj2.set_object();
    obj2.show_all();
    obj21 = d + obj2 + d;
    obj21.show_all();
    cout << obj21;
    return 0;
}
<|endoftext|>


<commit_before>#include <windows.h>
#include "tchar.h"
#include "stdio.h"

LPTSTR tchar2cw(TCHAR c, LPTSTR* cw);

int _tmain(int argc, TCHAR* argv[]) {

	/* Error message */
	if (argc <= 1) {
		MessageBox(NULL, _T("No arguments"), _T("error"), MB_OK);
		return -1;
	}

	/* string to cw code */
	int i = 0;
	int length = (int) ::_tcslen(argv[1]); //size_t -> int
	LPTSTR cw = 0;
	for (i = 0; i < length; i++) {
		tchar2cw(argv[1][i], &cw);
		_tprintf(_T("%c: %s\n"), argv[1][i], cw);
	}

	return 0;
}

LPTSTR tchar2cw(TCHAR c, LPTSTR* cw) {
	switch(c) {
		/* Alphabets */
		case 'a':
		case 'A': *cw = _T(". - "); break;
		case 'B':
		case 'B': *cw = _T("- . . . "); break;
		case 'C':
		case 'C': *cw = _T("- . - . "); break;
		case 'D':
		case 'D': *cw = _T("- . . "); break;
		case 'e':
		case 'E': *cw = _T(". "); break;
		case 'f':
		case 'F': *cw = _T(". . - . "); break;
		case 'g':
		case 'G': *cw = _T("- - . "); break;
		case 'h':
		case 'H': *cw = _T(". . . . "); break;
		case 'i':
		case 'I': *cw = _T(". . "); break;
		case 'j':
		case 'J': *cw = _T(". - - - "); break;
		case 'k':
		case 'K': *cw = _T("- . - "); break;
		case 'l':
		case 'L': *cw = _T(". - . . "); break;
		case 'm':
		case 'M': *cw = _T("- - "); break;
		case 'n':
		case 'N': *cw = _T("- . "); break;
		case 'o':
		case 'O': *cw = _T("- - - "); break;
		case 'p':
		case 'P': *cw = _T(". - - . "); break;
		case 'q':
		case 'Q': *cw = _T("- - . - "); break;
		case 'r':
		case 'R': *cw = _T(". - . "); break;
		case 's':
		case 'S': *cw = _T(". . . "); break;
		case 't':
		case 'T': *cw = _T("- "); break;
		case 'u':
		case 'U': *cw = _T(". . - "); break;
		case 'v':
		case 'V': *cw = _T(". . . - "); break;
		case 'w':
		case 'W': *cw = _T(". - - "); break;
		case 'x':
		case 'X': *cw = _T("- . . - "); break;
		case 'y':
		case 'Y': *cw = _T("- . - - "); break;
		case 'z':
		case 'Z': *cw = _T("- - . . "); break;

		/* Numbers */
		case '1': *cw = _T(". - - - - "); break;
		case '2': *cw = _T(". . - - - "); break;
		case '3': *cw = _T(". . . - - "); break;
		case '4': *cw = _T(". . . . - "); break;
		case '5': *cw = _T(". . . . . "); break;
		case '6': *cw = _T("- . . . . "); break;
		case '7': *cw = _T("- - . . . "); break;
		case '8': *cw = _T("- - - . . "); break;
		case '9': *cw = _T("- - - - . "); break;
		case '0': *cw = _T("- - - - - "); break;

		/* Simbols */
		case '.': *cw = _T(". - . - . - ");
		case ',': *cw = _T("- - . . - - ");
		case '?': *cw = _T(". . - - . . ");
		case '-': *cw = _T("- . . . . - ");
		case '/': *cw = _T("- . . - . ");
		case '@': *cw = _T(". - - . - . ");
		case ' ': *cw = _T("   ");

		/* Nothing */
		default: *cw = _T("?????"); break;
	}
	return *cw;
}
<commit_msg>A a ok<commit_after>#include <windows.h>
#include "tchar.h"
#include "stdio.h"

LPTSTR tchar2cw(TCHAR c, LPTSTR* cw);

int _tmain(int argc, TCHAR* argv[]) {

	/* Error message */
	if (argc <= 1) {
		MessageBox(NULL, _T("No arguments"), _T("error"), MB_OK);
		return -1;
	}

	/* string to cw code */
	int i = 0;
	int length = (int) ::_tcslen(argv[1]); //size_t -> int
	LPTSTR cw = 0;
	for (i = 0; i < length; i++) {
		tchar2cw(argv[1][i], &cw);
		_tprintf(_T("%c: %s\n"), argv[1][i], cw);
	}

	return 0;
}

LPTSTR tchar2cw(TCHAR c, LPTSTR* cw) {
	switch(c) {
		/* Alphabets */
		case 'a':
		case 'A': *cw = _T(". - "); break;
		case 'b':
		case 'B': *cw = _T("- . . . "); break;
		case 'c':
		case 'C': *cw = _T("- . - . "); break;
		case 'd':
		case 'D': *cw = _T("- . . "); break;
		case 'e':
		case 'E': *cw = _T(". "); break;
		case 'f':
		case 'F': *cw = _T(". . - . "); break;
		case 'g':
		case 'G': *cw = _T("- - . "); break;
		case 'h':
		case 'H': *cw = _T(". . . . "); break;
		case 'i':
		case 'I': *cw = _T(". . "); break;
		case 'j':
		case 'J': *cw = _T(". - - - "); break;
		case 'k':
		case 'K': *cw = _T("- . - "); break;
		case 'l':
		case 'L': *cw = _T(". - . . "); break;
		case 'm':
		case 'M': *cw = _T("- - "); break;
		case 'n':
		case 'N': *cw = _T("- . "); break;
		case 'o':
		case 'O': *cw = _T("- - - "); break;
		case 'p':
		case 'P': *cw = _T(". - - . "); break;
		case 'q':
		case 'Q': *cw = _T("- - . - "); break;
		case 'r':
		case 'R': *cw = _T(". - . "); break;
		case 's':
		case 'S': *cw = _T(". . . "); break;
		case 't':
		case 'T': *cw = _T("- "); break;
		case 'u':
		case 'U': *cw = _T(". . - "); break;
		case 'v':
		case 'V': *cw = _T(". . . - "); break;
		case 'w':
		case 'W': *cw = _T(". - - "); break;
		case 'x':
		case 'X': *cw = _T("- . . - "); break;
		case 'y':
		case 'Y': *cw = _T("- . - - "); break;
		case 'z':
		case 'Z': *cw = _T("- - . . "); break;

		/* Numbers */
		case '1': *cw = _T(". - - - - "); break;
		case '2': *cw = _T(". . - - - "); break;
		case '3': *cw = _T(". . . - - "); break;
		case '4': *cw = _T(". . . . - "); break;
		case '5': *cw = _T(". . . . . "); break;
		case '6': *cw = _T("- . . . . "); break;
		case '7': *cw = _T("- - . . . "); break;
		case '8': *cw = _T("- - - . . "); break;
		case '9': *cw = _T("- - - - . "); break;
		case '0': *cw = _T("- - - - - "); break;

		/* Simbols */
		case '.': *cw = _T(". - . - . - ");
		case ',': *cw = _T("- - . . - - ");
		case '?': *cw = _T(". . - - . . ");
		case '-': *cw = _T("- . . . . - ");
		case '/': *cw = _T("- . . - . ");
		case '@': *cw = _T(". - - . - . ");
		case ' ': *cw = _T("   ");

		/* Nothing */
		default: *cw = _T("?????"); break;
	}
	return *cw;
}
<|endoftext|>


<commit_before>#include <iostream>

int main (int argc, char* args[]) {
    std::cout << "top level main" << std::endl;

    return 0;
}
<commit_msg>take xml file path as command line parameter<commit_after>#include <iostream>

int main () {
    std::cout << "top level main" << std::endl;

    return 0;
}
<|endoftext|>


<commit_before><commit_msg>`yli::audio::AudioMaster` constructor: initialize `audio_spec` fields.<commit_after><|endoftext|>


<commit_before>37d7eb7a-ad5d-11e7-b4fa-ac87a332f658<commit_msg>Nope, didn't work, now it does<commit_after>3864a92b-ad5d-11e7-9fc1-ac87a332f658<|endoftext|>


<commit_before>2484b391-2748-11e6-9987-e0f84713e7b8<commit_msg>Nope, didn't work, now it does<commit_after>248e781e-2748-11e6-80dc-e0f84713e7b8<|endoftext|>


<commit_before>#include <QtGui/QApplication>
#include "mainwindow.h"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>

#include <stdio.h>
#include <iostream>
#include <vector>

#include "geom/chessgen.h"

using namespace cv;
using namespace std;
using namespace fr;

int main(int, char**)
{
    VideoCapture cap(0); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    cap.set(CV_CAP_PROP_FRAME_WIDTH,640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT,480);
    Mat edges;
    Size size(7,7);

    int counter = 10;

    vector<Point2f> corners;
    bool found;

    vector<Point3f> chess = fr::ChessGen::getBoard(size,1,false);
   /* for(unsigned int i=0;i<chess.size();i++){
        cout << chess[i].x << "," << chess[i].y << endl;
    }*/

    vector<vector<Point3f> > objectPoints;
    vector<vector<Point2f> > imagePoints;

    Mat camera = Mat::eye(3,3,CV_64F);
    camera.at<double>(0,2) = 640/2;
    camera.at<double>(1,2) = 480/2;
    Mat distortion = Mat::zeros(8, 1, CV_64F);
    vector<Mat > rvecs;
    vector<Mat > tvecs;

    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);

        found = findChessboardCorners(edges,size,corners);
        /*
        found = findCirclesGrid(edges,size,corners
                                ,CALIB_CB_ASYMMETRIC_GRID
                                );//*/
        if(found) frame.convertTo(edges,-1,0.2);

        drawChessboardCorners(edges,size,corners,found);

        imshow("edges", edges);
        if(found){
            //if(waitKey(200)>=0){
            waitKey(300);
                objectPoints.push_back(chess);
                imagePoints.push_back(corners);
                if(--counter<= 0)
                    break;
            //}
        }
        else waitKey(30);
    }

    double rpe = calibrateCamera(objectPoints,imagePoints,Size(800,600),camera,distortion,rvecs,tvecs,CV_CALIB_FIX_ASPECT_RATIO);

    if(found) imwrite("/home/ryan/chessboard.png",edges);

    cout << camera << endl;
    cout << rpe << endl;

    return 0;
}
<commit_msg>quick modifications for testing<commit_after>#include <QtGui/QApplication>
#include "mainwindow.h"

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>

#include <stdio.h>
#include <iostream>
#include <vector>

#include "geom/chessgen.h"

using namespace cv;
using namespace std;
using namespace fr;

int main(int, char**)
{
    VideoCapture cap(1); // open the default camera
    if(!cap.isOpened())  // check if we succeeded
        return -1;

    cap.set(CV_CAP_PROP_FRAME_WIDTH,640);
    cap.set(CV_CAP_PROP_FRAME_HEIGHT,480);
    Mat edges;
    Size size(12,9);

    int counter = 10;

    vector<Point2f> corners;
    bool found;

    vector<Point3f> chess = fr::ChessGen::getBoard(size,1,false);
   /* for(unsigned int i=0;i<chess.size();i++){
        cout << chess[i].x << "," << chess[i].y << endl;
    }*/

    vector<vector<Point3f> > objectPoints;
    vector<vector<Point2f> > imagePoints;

    Mat camera = Mat::eye(3,3,CV_64F);
    camera.at<double>(0,2) = 640/2;
    camera.at<double>(1,2) = 480/2;
    Mat distortion = Mat::zeros(8, 1, CV_64F);
    vector<Mat > rvecs;
    vector<Mat > tvecs;

    namedWindow("edges",1);
    for(;;)
    {
        Mat frame;
        cap >> frame; // get a new frame from camera
        cvtColor(frame, edges, CV_BGR2GRAY);

        found = findChessboardCorners(edges,size,corners);
        /*
        found = findCirclesGrid(edges,size,corners
                                ,CALIB_CB_ASYMMETRIC_GRID
                                );//*/
        if(found) frame.convertTo(edges,-1,0.2);

        drawChessboardCorners(edges,size,corners,found);

        imshow("edges", edges);
        /*if(found){
            //if(waitKey(200)>=0){
            waitKey(300);
                objectPoints.push_back(chess);
                imagePoints.push_back(corners);
                if(--counter<= 0)
                    break;
            //}
        }
        else waitKey(30);*/
        if(waitKey(30)>1) break;
    }

    //double rpe = calibrateCamera(objectPoints,imagePoints,Size(800,600),camera,distortion,rvecs,tvecs,CV_CALIB_FIX_ASPECT_RATIO);

    if(found) imwrite("/home/ryan/chessboard.png",edges);

    //cout << camera << endl;
    //cout << rpe << endl;

    return 0;
}
<|endoftext|>


<commit_before>9647c6d4-4b02-11e5-bd5b-28cfe9171a43<commit_msg>almost working<commit_after>9654a55e-4b02-11e5-a803-28cfe9171a43<|endoftext|>


<commit_before>c35bd5a3-ad5c-11e7-bc6d-ac87a332f658<commit_msg>That didn't fix it<commit_after>c4079dcf-ad5c-11e7-8663-ac87a332f658<|endoftext|>