<commit_before>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tabfrm.hxx,v $
 *
 *  $Revision: 1.18 $
 *
 *  last change: $Author: hr $ $Date: 2007-09-27 08:58:50 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _TABFRM_HXX
#define _TABFRM_HXX

#ifndef _SVMEMPOOL_HXX //autogen
#include <tools/mempool.hxx>
#endif
#include "layfrm.hxx"
#include "flowfrm.hxx"

class SwTable;
class SwBorderAttrs;
class SwAttrSetChg;

class SwTabFrm: public SwLayoutFrm, public SwFlowFrm
{
    // OD 14.03.2003 #i11760# - adjustment, because of method signature change
    //darf mit den Flags spielen.
    friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );

    //Fuert Spezialbehandlung fuer _Get[Next|Prev]Leaf() durch.
    using SwFrm::GetLeaf;
    SwLayoutFrm *GetLeaf( MakePageType eMakePage, BOOL bFwd );

    SwTable* pTable;

    BOOL bComplete          :1; //Eintrage als Repaint ohne das CompletePaint
                                //der Basisklasse gesetzt werden muss. Damit
                                //sollen unertraegliche Tabellen-Repaints
                                //vermieden werden.
    BOOL bCalcLowers        :1; //Im MakeAll auf jedenfall auch fuer Stabilitaet
                                //des Inhaltes sorgen.
    BOOL bLowersFormatted   :1;//Kommunikation zwischen MakeAll und Layact
    BOOL bLockBackMove      :1; //BackMove-Test hat der Master erledigt.
    BOOL bResizeHTMLTable   :1; //Resize des HTMLTableLayout rufen im MakeAll
                                //Zur Optimierung, damit dies nicht im
                                //CntntFrm::Grow gerufen werden muss, denn dann
                                //wird es ggf. fuer jede Zelle gerufen #47483#
    BOOL bONECalcLowers     :1; //Primaer fuer die StarONE-SS. Beim MakeAll werden
                                //die Cntnts auf jedenfall per Calc() formatiert.
                                //es finden keine zusaetzlichen Invalidierungen
                                //statt und dieser Weg kann auch kaum garantien
                                //geben.

    BOOL bHasFollowFlowLine :1; // Means that the first line in the follow
                                // is indented to contain content from a broken
                                // cell
    BOOL bIsRebuildLastLine :1; // Means that currently the last line of the
                                // TabFrame is rebuilded. In this case we
                                // do not want any notification to the master
                                // table
    BOOL bRestrictTableGrowth :1;       // Usually, the table may grow infinite,
                                        // because the table can be split in
                                        // SwTabFrm::MakeAll. In MakeAll, this
                                        // flag is set to indicate that the table
                                        // may only grow inside its upper. This
                                        // is necessary, in order to let the text
                                        // flow into the FollowFlowLine
    BOOL bRemoveFollowFlowLinePending :1;
    // --> OD 2004-10-04 #i26945#
    BOOL bConsiderObjsForMinCellHeight :1; // Usually, the floating screen objects
                                           // are considered on the calculation
                                           // for the minimal cell height.
                                           // For splitting table rows algorithm
                                           // it's needed not to consider floating
                                           // screen object for the preparation
                                           // of the re-calculation of the
                                           // last table row.
    // <--
    // --> OD 2004-10-15 #i26945#
    BOOL bObjsDoesFit :1; // For splitting table rows algorithm, this boolean
                          // indicates, if the floating screen objects fits
    // <--
    BOOL bDummy4 :1;

    //Split() spaltet den Frm an der angegebenen Stelle, es wird ein
    //Follow erzeugt und aufgebaut und direkt hinter this gepastet.
    //Join() Holt sich den Inhalt aus dem Follow und vernichtet diesen.
    bool Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep );
    bool Join();

    void _UpdateAttr( SfxPoolItem*, SfxPoolItem*, BYTE &,
                      SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );

    virtual BOOL ShouldBwdMoved( SwLayoutFrm *pNewUpper, BOOL bHead, BOOL &rReformat );

protected:
    virtual void MakeAll();
    virtual void Format( const SwBorderAttrs *pAttrs = 0 );
        //Aendert nur die Framesize, nicht die PrtArea-SSize
    virtual SwTwips GrowFrm  ( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE );
public:
    SwTabFrm( SwTable & );  //Immer nach dem erzeugen _und_ pasten das
                            //Regist Flys rufen!
    SwTabFrm( SwTabFrm & ); //_Nur_ zum erzeugen von Follows
    ~SwTabFrm();

    void JoinAndDelFollows();   //Fuer DelFrms des TableNodes!

    //Ruft das RegistFlys der Zeilen.
    void RegistFlys();

    inline const SwTabFrm *GetFollow() const;
    inline       SwTabFrm *GetFollow();
    SwTabFrm* FindMaster( bool bFirstMaster = false ) const;

    virtual void Modify( SfxPoolItem*, SfxPoolItem* );
    virtual BOOL GetInfo( SfxPoolItem &rHnt ) const;
    virtual void Paint( const SwRect& ) const;
    virtual void  CheckDirection( BOOL bVert );

    virtual void Cut();
    virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );

    virtual void Prepare( const PrepareHint ePrep = PREP_CLEAR,
                          const void *pVoid = 0, sal_Bool bNotify = sal_True );

                 SwCntntFrm *FindLastCntnt();
    inline const SwCntntFrm *FindLastCntnt() const;

    const SwTable *GetTable() const { return pTable; }
          SwTable *GetTable()       { return pTable; }

    BOOL IsComplete()  { return bComplete; }
    void SetComplete() { bComplete = TRUE; }
    void ResetComplete() { bComplete = FALSE; }

    BOOL IsLowersFormatted() const      { return bLowersFormatted; }
    void SetLowersFormatted( BOOL b )   { bLowersFormatted = b;    }

    void SetCalcLowers()        { bCalcLowers = TRUE;      } //Sparsam einsetzen!
    void SetResizeHTMLTable()   { bResizeHTMLTable = TRUE; } //dito
    void SetONECalcLowers()     { bONECalcLowers = TRUE;   }

    //
    // Start: New stuff for breaking table rows
    //
    BOOL HasFollowFlowLine() const { return bHasFollowFlowLine; }
    void SetFollowFlowLine( BOOL bNew ) { bHasFollowFlowLine = bNew; }

    BOOL IsRebuildLastLine() const { return bIsRebuildLastLine; }
    void SetRebuildLastLine( BOOL bNew ) { bIsRebuildLastLine = bNew; }

    BOOL IsRestrictTableGrowth() const { return bRestrictTableGrowth; }
    void SetRestrictTableGrowth( BOOL bNew ) { bRestrictTableGrowth = bNew; }

    BOOL IsRemoveFollowFlowLinePending() const { return bRemoveFollowFlowLinePending; }
    void SetRemoveFollowFlowLinePending( BOOL bNew ) { bRemoveFollowFlowLinePending = bNew; }

    // --> OD 2004-10-04 #i26945#
    BOOL IsConsiderObjsForMinCellHeight() const
    {
        return bConsiderObjsForMinCellHeight;
    }
    void SetConsiderObjsForMinCellHeight( BOOL _bNewConsiderObjsForMinCellHeight )
    {
        bConsiderObjsForMinCellHeight = _bNewConsiderObjsForMinCellHeight;
    }
    // <--
    // --> OD 2004-10-04 #i26945#
    BOOL DoesObjsFit() const
    {
        return bObjsDoesFit;
    }
    void SetDoesObjsFit( BOOL _bNewObjsDoesFit )
    {
        bObjsDoesFit = _bNewObjsDoesFit;
    }
    // <--

    bool RemoveFollowFlowLine();
    //
    // End: New stuff for breaking table rows
    //

    BOOL CalcFlyOffsets( SwTwips& rUpper, long& rLeftOffset,
                         long& rRightOffset ) const;

    SwTwips CalcHeightOfFirstContentLine() const;

    bool IsInHeadline( const SwFrm& rFrm ) const;
    SwRowFrm* GetFirstNonHeadlineRow() const;

    bool IsLayoutSplitAllowed() const;

    // --> collapsing borders FME 2005-05-27 #i29550#
    bool IsCollapsingBorders() const;

    // used for collapsing border lines:
    USHORT GetBottomLineSize() const;
    // <-- collapsing

    DECL_FIXEDMEMPOOL_NEWDEL(SwTabFrm)
};

inline const SwCntntFrm *SwTabFrm::FindLastCntnt() const
{
    return ((SwTabFrm*)this)->FindLastCntnt();
}

inline const SwTabFrm *SwTabFrm::GetFollow() const
{
    return (const SwTabFrm*)SwFlowFrm::GetFollow();
}
inline SwTabFrm *SwTabFrm::GetFollow()
{
    return (SwTabFrm*)SwFlowFrm::GetFollow();
}

#endif  //_TABFRM_HXX
<commit_msg>INTEGRATION: CWS swusing (1.18.38); FILE MERGED 2007/10/10 14:15:08 tl 1.18.38.1: #i82476# make newly added 'using' declarations private<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: tabfrm.hxx,v $
 *
 *  $Revision: 1.19 $
 *
 *  last change: $Author: vg $ $Date: 2007-10-22 15:11:06 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _TABFRM_HXX
#define _TABFRM_HXX

#ifndef _SVMEMPOOL_HXX //autogen
#include <tools/mempool.hxx>
#endif
#include "layfrm.hxx"
#include "flowfrm.hxx"

class SwTable;
class SwBorderAttrs;
class SwAttrSetChg;

class SwTabFrm: public SwLayoutFrm, public SwFlowFrm
{
    // OD 14.03.2003 #i11760# - adjustment, because of method signature change
    //darf mit den Flags spielen.
    friend void CalcCntnt( SwLayoutFrm *pLay, bool bNoColl, bool bNoCalcFollow );

    //Fuert Spezialbehandlung fuer _Get[Next|Prev]Leaf() durch.
    using SwFrm::GetLeaf;
    SwLayoutFrm *GetLeaf( MakePageType eMakePage, BOOL bFwd );

    SwTable* pTable;

    BOOL bComplete          :1; //Eintrage als Repaint ohne das CompletePaint
                                //der Basisklasse gesetzt werden muss. Damit
                                //sollen unertraegliche Tabellen-Repaints
                                //vermieden werden.
    BOOL bCalcLowers        :1; //Im MakeAll auf jedenfall auch fuer Stabilitaet
                                //des Inhaltes sorgen.
    BOOL bLowersFormatted   :1;//Kommunikation zwischen MakeAll und Layact
    BOOL bLockBackMove      :1; //BackMove-Test hat der Master erledigt.
    BOOL bResizeHTMLTable   :1; //Resize des HTMLTableLayout rufen im MakeAll
                                //Zur Optimierung, damit dies nicht im
                                //CntntFrm::Grow gerufen werden muss, denn dann
                                //wird es ggf. fuer jede Zelle gerufen #47483#
    BOOL bONECalcLowers     :1; //Primaer fuer die StarONE-SS. Beim MakeAll werden
                                //die Cntnts auf jedenfall per Calc() formatiert.
                                //es finden keine zusaetzlichen Invalidierungen
                                //statt und dieser Weg kann auch kaum garantien
                                //geben.

    BOOL bHasFollowFlowLine :1; // Means that the first line in the follow
                                // is indented to contain content from a broken
                                // cell
    BOOL bIsRebuildLastLine :1; // Means that currently the last line of the
                                // TabFrame is rebuilded. In this case we
                                // do not want any notification to the master
                                // table
    BOOL bRestrictTableGrowth :1;       // Usually, the table may grow infinite,
                                        // because the table can be split in
                                        // SwTabFrm::MakeAll. In MakeAll, this
                                        // flag is set to indicate that the table
                                        // may only grow inside its upper. This
                                        // is necessary, in order to let the text
                                        // flow into the FollowFlowLine
    BOOL bRemoveFollowFlowLinePending :1;
    // --> OD 2004-10-04 #i26945#
    BOOL bConsiderObjsForMinCellHeight :1; // Usually, the floating screen objects
                                           // are considered on the calculation
                                           // for the minimal cell height.
                                           // For splitting table rows algorithm
                                           // it's needed not to consider floating
                                           // screen object for the preparation
                                           // of the re-calculation of the
                                           // last table row.
    // <--
    // --> OD 2004-10-15 #i26945#
    BOOL bObjsDoesFit :1; // For splitting table rows algorithm, this boolean
                          // indicates, if the floating screen objects fits
    // <--
    BOOL bDummy4 :1;

    //Split() spaltet den Frm an der angegebenen Stelle, es wird ein
    //Follow erzeugt und aufgebaut und direkt hinter this gepastet.
    //Join() Holt sich den Inhalt aus dem Follow und vernichtet diesen.
    bool Split( const SwTwips nCutPos, bool bTryToSplit, bool bTableRowKeep );
    bool Join();

    void _UpdateAttr( SfxPoolItem*, SfxPoolItem*, BYTE &,
                      SwAttrSetChg *pa = 0, SwAttrSetChg *pb = 0 );

    virtual BOOL ShouldBwdMoved( SwLayoutFrm *pNewUpper, BOOL bHead, BOOL &rReformat );

protected:
    virtual void MakeAll();
    virtual void Format( const SwBorderAttrs *pAttrs = 0 );
        //Aendert nur die Framesize, nicht die PrtArea-SSize
    virtual SwTwips GrowFrm  ( SwTwips, BOOL bTst = FALSE, BOOL bInfo = FALSE );
public:
    SwTabFrm( SwTable & );  //Immer nach dem erzeugen _und_ pasten das
                            //Regist Flys rufen!
    SwTabFrm( SwTabFrm & ); //_Nur_ zum erzeugen von Follows
    ~SwTabFrm();

    void JoinAndDelFollows();   //Fuer DelFrms des TableNodes!

    //Ruft das RegistFlys der Zeilen.
    void RegistFlys();

    inline const SwTabFrm *GetFollow() const;
    inline       SwTabFrm *GetFollow();
    SwTabFrm* FindMaster( bool bFirstMaster = false ) const;

    virtual void Modify( SfxPoolItem*, SfxPoolItem* );
    virtual BOOL GetInfo( SfxPoolItem &rHnt ) const;
    virtual void Paint( const SwRect& ) const;
    virtual void  CheckDirection( BOOL bVert );

    virtual void Cut();
    virtual void Paste( SwFrm* pParent, SwFrm* pSibling = 0 );

    virtual void Prepare( const PrepareHint ePrep = PREP_CLEAR,
                          const void *pVoid = 0, sal_Bool bNotify = sal_True );

                 SwCntntFrm *FindLastCntnt();
    inline const SwCntntFrm *FindLastCntnt() const;

    const SwTable *GetTable() const { return pTable; }
          SwTable *GetTable()       { return pTable; }

    BOOL IsComplete()  { return bComplete; }
    void SetComplete() { bComplete = TRUE; }
    void ResetComplete() { bComplete = FALSE; }

    BOOL IsLowersFormatted() const      { return bLowersFormatted; }
    void SetLowersFormatted( BOOL b )   { bLowersFormatted = b;    }

    void SetCalcLowers()        { bCalcLowers = TRUE;      } //Sparsam einsetzen!
    void SetResizeHTMLTable()   { bResizeHTMLTable = TRUE; } //dito
    void SetONECalcLowers()     { bONECalcLowers = TRUE;   }

    //
    // Start: New stuff for breaking table rows
    //
    BOOL HasFollowFlowLine() const { return bHasFollowFlowLine; }
    void SetFollowFlowLine( BOOL bNew ) { bHasFollowFlowLine = bNew; }

    BOOL IsRebuildLastLine() const { return bIsRebuildLastLine; }
    void SetRebuildLastLine( BOOL bNew ) { bIsRebuildLastLine = bNew; }

    BOOL IsRestrictTableGrowth() const { return bRestrictTableGrowth; }
    void SetRestrictTableGrowth( BOOL bNew ) { bRestrictTableGrowth = bNew; }

    BOOL IsRemoveFollowFlowLinePending() const { return bRemoveFollowFlowLinePending; }
    void SetRemoveFollowFlowLinePending( BOOL bNew ) { bRemoveFollowFlowLinePending = bNew; }

    // --> OD 2004-10-04 #i26945#
    BOOL IsConsiderObjsForMinCellHeight() const
    {
        return bConsiderObjsForMinCellHeight;
    }
    void SetConsiderObjsForMinCellHeight( BOOL _bNewConsiderObjsForMinCellHeight )
    {
        bConsiderObjsForMinCellHeight = _bNewConsiderObjsForMinCellHeight;
    }
    // <--
    // --> OD 2004-10-04 #i26945#
    BOOL DoesObjsFit() const
    {
        return bObjsDoesFit;
    }
    void SetDoesObjsFit( BOOL _bNewObjsDoesFit )
    {
        bObjsDoesFit = _bNewObjsDoesFit;
    }
    // <--

    bool RemoveFollowFlowLine();
    //
    // End: New stuff for breaking table rows
    //

    BOOL CalcFlyOffsets( SwTwips& rUpper, long& rLeftOffset,
                         long& rRightOffset ) const;

    SwTwips CalcHeightOfFirstContentLine() const;

    bool IsInHeadline( const SwFrm& rFrm ) const;
    SwRowFrm* GetFirstNonHeadlineRow() const;

    bool IsLayoutSplitAllowed() const;

    // --> collapsing borders FME 2005-05-27 #i29550#
    bool IsCollapsingBorders() const;

    // used for collapsing border lines:
    USHORT GetBottomLineSize() const;
    // <-- collapsing

    DECL_FIXEDMEMPOOL_NEWDEL(SwTabFrm)
};

inline const SwCntntFrm *SwTabFrm::FindLastCntnt() const
{
    return ((SwTabFrm*)this)->FindLastCntnt();
}

inline const SwTabFrm *SwTabFrm::GetFollow() const
{
    return (const SwTabFrm*)SwFlowFrm::GetFollow();
}
inline SwTabFrm *SwTabFrm::GetFollow()
{
    return (SwTabFrm*)SwFlowFrm::GetFollow();
}

#endif  //_TABFRM_HXX
<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: cfgitems.hxx,v $
 *
 *  $Revision: 1.8 $
 *
 *  last change: $Author: kz $ $Date: 2004-02-26 15:43:00 $
 *
 *  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 _CFGITEMS_HXX
#define _CFGITEMS_HXX

#ifndef _SFXPOOLITEM_HXX //autogen
#include <svtools/poolitem.hxx>
#endif

#ifndef _AUTHRATR_HXX
#include <authratr.hxx>
#endif
#ifndef _SW_PRINTDATA_HXX
#include <printdata.hxx>
#endif

class SwWriterApp;
class SwModule;
#ifndef PRODUCT
class SwTestTabPage;
#endif
class SwAddPrinterTabPage;
class SfxPrinter;
class ViewShell;
class SwViewOption;
class SwContentOptPage;
class SwShdwCrsrOptionsTabPage;
class SwDocEditDialog;

SfxPrinter* GetPrt( ViewShell* );
void        SetPrt( SfxPrinter* );

/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Dokumentanzeige
--------------------------------------------------------- */
class SwDocDisplayItem : public SfxPoolItem
{
    friend class SwWriterApp;
    friend class SwShdwCrsrOptionsTabPage;
    friend class SwModule;

    BOOL bParagraphEnd      :1;
    BOOL bTab               :1;
    BOOL bSpace             :1;
    BOOL bNonbreakingSpace  :1;
    BOOL bSoftHyphen        :1;
    BOOL bCharHiddenText    :1;
    BOOL bFldHiddenText     :1;
    BOOL bManualBreak       :1;
    BOOL bShowHiddenPara    :1;

    Color aIndexBackgrndCol;

public:
                                TYPEINFO();
                                SwDocDisplayItem( USHORT nWhich = FN_PARAM_DOCDISP );
                                SwDocDisplayItem(
                                    const SwDocDisplayItem& rSwDocDisplayItem );
                                SwDocDisplayItem( const SwViewOption& rVOpt,
                                                                USHORT nWhich );

    virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
    virtual int                 operator==( const SfxPoolItem& ) const;
    void                        operator=( const SwDocDisplayItem& );
    void                        FillViewOptions( SwViewOption& rVOpt) const;
};
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog, Elementeseite
--------------------------------------------------------- */
class SwElemItem : public SfxPoolItem
{
    //view
    BOOL bHorzScrollbar :1;
    BOOL bVertScrollbar :1;
    BOOL bAnyRuler : 1;
    BOOL bHorzRuler     :1;
    BOOL bVertRuler     :1;
    BOOL bVertRulerRight:1;
    BOOL bSmoothScroll  :1;
    //visual aids
    BOOL bCrosshair     :1;
    BOOL bHandles       :1;
    BOOL bBigHandles    :1;
    //display
    BOOL bTable             :1;
    BOOL bGraphic           :1;
    BOOL bDrawing           :1;
    BOOL bFieldName         :1;
    BOOL bNotes             :1;

    friend class SwContentOptPage;

public:
                            TYPEINFO();
                            SwElemItem( USHORT nWhich = FN_PARAM_ELEM );
                            SwElemItem(const SwElemItem& rElemItem);
                            SwElemItem(const SwViewOption& rVOpt, USHORT nWhich);

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;
    void                    operator=( const SwElemItem& );

    void                    FillViewOptions( SwViewOption& rVOpt) const;

};
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Drucker/Zusaetze
--------------------------------------------------------- */

class SwAddPrinterItem : public SfxPoolItem, public SwPrintData
{
    friend class SwAddPrinterTabPage;

public:
    TYPEINFO();
    SwAddPrinterItem( USHORT nWhich = FN_PARAM_ADDPRINTER );
    SwAddPrinterItem( USHORT nWhich, const SwPrintData& rPrtData );
    SwAddPrinterItem( const SwAddPrinterItem& rAddPrinterItem);

    virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
    virtual int          operator==( const SfxPoolItem& ) const;

    const rtl::OUString &GetFax() const              { return sFaxName; }
    void          SetFax( const String& rFax) { sFaxName = rFax; }

    BOOL   IsPrintProspect() const      { return bPrintProspect; }
    void   SetPrintProspect(BOOL bFlag ){ bPrintProspect = bFlag; }
    BOOL IsPrintGraphic () const { return bPrintGraphic; }
    BOOL IsPrintTable () const { return bPrintTable; }
    BOOL IsPrintDraw () const { return bPrintDraw; }
    BOOL IsPrintControl () const { return bPrintControl; }
    BOOL IsPrintLeftPage () const { return bPrintLeftPage; }
    BOOL IsPrintRightPage() const { return bPrintRightPage; }
    BOOL IsPrintReverse  () const { return bPrintReverse; }
    BOOL IsPaperFromSetup() const { return bPaperFromSetup; }
    BOOL IsPrintPageBackground() const { return bPrintPageBackground; }
    BOOL IsPrintBlackFont() const { return bPrintBlackFont; }
    BOOL IsPrintSingleJobs() const { return bPrintSingleJobs; }
    ULONG GetPrintPostIts () const { return nPrintPostIts; }

};

/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog, ShadowCursorSeite
--------------------------------------------------------- */

class SwShadowCursorItem : public SfxPoolItem
{
    BYTE eMode;
    BOOL bOn;
public:
    TYPEINFO();
    SwShadowCursorItem( USHORT nWhich = FN_PARAM_SHADOWCURSOR );
    SwShadowCursorItem( const SwShadowCursorItem& rElemItem );
    SwShadowCursorItem( const SwViewOption& rVOpt, USHORT nWhich );

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;
    void                    operator=( const SwShadowCursorItem& );

    void FillViewOptions( SwViewOption& rVOpt) const;

    BYTE GetMode() const                { return eMode; }
    BOOL IsOn() const                   { return bOn; }

    void SetMode( BYTE eM )             { eMode = eM; }
    void SetOn( BOOL bFlag )            { bOn = bFlag; }
};

#ifndef PRODUCT
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Testeinstellungen
--------------------------------------------------------- */
class SwTestItem : public SfxPoolItem
{
    friend class SwModule;
    friend class SwWriterApp;
    friend class SwTestTabPage;
    friend class SwDocEditDialog;

    BOOL    bTest1:1;
    BOOL    bTest2:1;
    BOOL    bTest3:1;
    BOOL    bTest4:1;
    BOOL    bTest5:1;
    BOOL    bTest6:1;
    BOOL    bTest7:1;
    BOOL    bTest8:1;
    BOOL    bTest9:1;
    BOOL    bTest10:1;

public:
                            SwTestItem( USHORT nWhich):
                                            SfxPoolItem(nWhich){};
                            SwTestItem( const SwTestItem& pTestItem);

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;

};
#endif

#endif

<commit_msg>INTEGRATION: CWS tune03 (1.8.182); FILE MERGED 2004/07/19 19:11:24 mhu 1.8.182.1: #i29979# Added SW_DLLPUBLIC/PRIVATE (see swdllapi.h) to exported symbols/classes.<commit_after>/*************************************************************************
 *
 *  $RCSfile: cfgitems.hxx,v $
 *
 *  $Revision: 1.9 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:57:09 $
 *
 *  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 _CFGITEMS_HXX
#define _CFGITEMS_HXX

#ifndef _SFXPOOLITEM_HXX //autogen
#include <svtools/poolitem.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif
#ifndef _AUTHRATR_HXX
#include <authratr.hxx>
#endif
#ifndef _SW_PRINTDATA_HXX
#include <printdata.hxx>
#endif

class SwWriterApp;
class SwModule;
#ifndef PRODUCT
class SwTestTabPage;
#endif
class SwAddPrinterTabPage;
class SfxPrinter;
class ViewShell;
class SwViewOption;
class SwContentOptPage;
class SwShdwCrsrOptionsTabPage;
class SwDocEditDialog;

SfxPrinter* GetPrt( ViewShell* );
void        SetPrt( SfxPrinter* );

/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Dokumentanzeige
--------------------------------------------------------- */
class SW_DLLPUBLIC SwDocDisplayItem : public SfxPoolItem
{
    friend class SwWriterApp;
    friend class SwShdwCrsrOptionsTabPage;
    friend class SwModule;

    BOOL bParagraphEnd      :1;
    BOOL bTab               :1;
    BOOL bSpace             :1;
    BOOL bNonbreakingSpace  :1;
    BOOL bSoftHyphen        :1;
    BOOL bCharHiddenText    :1;
    BOOL bFldHiddenText     :1;
    BOOL bManualBreak       :1;
    BOOL bShowHiddenPara    :1;

    Color aIndexBackgrndCol;

public:
                                TYPEINFO();
                                SwDocDisplayItem( USHORT nWhich = FN_PARAM_DOCDISP );
                                SwDocDisplayItem(
                                    const SwDocDisplayItem& rSwDocDisplayItem );
                                SwDocDisplayItem( const SwViewOption& rVOpt,
                                                                USHORT nWhich );

    virtual SfxPoolItem*        Clone( SfxItemPool *pPool = 0 ) const;
    virtual int                 operator==( const SfxPoolItem& ) const;
    void                        operator=( const SwDocDisplayItem& );
    void                        FillViewOptions( SwViewOption& rVOpt) const;
};
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog, Elementeseite
--------------------------------------------------------- */
class SW_DLLPUBLIC SwElemItem : public SfxPoolItem
{
    //view
    BOOL bHorzScrollbar :1;
    BOOL bVertScrollbar :1;
    BOOL bAnyRuler : 1;
    BOOL bHorzRuler     :1;
    BOOL bVertRuler     :1;
    BOOL bVertRulerRight:1;
    BOOL bSmoothScroll  :1;
    //visual aids
    BOOL bCrosshair     :1;
    BOOL bHandles       :1;
    BOOL bBigHandles    :1;
    //display
    BOOL bTable             :1;
    BOOL bGraphic           :1;
    BOOL bDrawing           :1;
    BOOL bFieldName         :1;
    BOOL bNotes             :1;

    friend class SwContentOptPage;

public:
                            TYPEINFO();
                            SwElemItem( USHORT nWhich = FN_PARAM_ELEM );
                            SwElemItem(const SwElemItem& rElemItem);
                            SwElemItem(const SwViewOption& rVOpt, USHORT nWhich);

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;
    void                    operator=( const SwElemItem& );

    void                    FillViewOptions( SwViewOption& rVOpt) const;

};
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Drucker/Zusaetze
--------------------------------------------------------- */

class SW_DLLPUBLIC SwAddPrinterItem : public SfxPoolItem, public SwPrintData
{
    friend class SwAddPrinterTabPage;

public:
    TYPEINFO();
    SwAddPrinterItem( USHORT nWhich = FN_PARAM_ADDPRINTER );
    SwAddPrinterItem( USHORT nWhich, const SwPrintData& rPrtData );
    SwAddPrinterItem( const SwAddPrinterItem& rAddPrinterItem);

    virtual SfxPoolItem* Clone( SfxItemPool *pPool = 0 ) const;
    virtual int          operator==( const SfxPoolItem& ) const;

    const rtl::OUString &GetFax() const              { return sFaxName; }
    void          SetFax( const String& rFax) { sFaxName = rFax; }

    BOOL   IsPrintProspect() const      { return bPrintProspect; }
    void   SetPrintProspect(BOOL bFlag ){ bPrintProspect = bFlag; }
    BOOL IsPrintGraphic () const { return bPrintGraphic; }
    BOOL IsPrintTable () const { return bPrintTable; }
    BOOL IsPrintDraw () const { return bPrintDraw; }
    BOOL IsPrintControl () const { return bPrintControl; }
    BOOL IsPrintLeftPage () const { return bPrintLeftPage; }
    BOOL IsPrintRightPage() const { return bPrintRightPage; }
    BOOL IsPrintReverse  () const { return bPrintReverse; }
    BOOL IsPaperFromSetup() const { return bPaperFromSetup; }
    BOOL IsPrintPageBackground() const { return bPrintPageBackground; }
    BOOL IsPrintBlackFont() const { return bPrintBlackFont; }
    BOOL IsPrintSingleJobs() const { return bPrintSingleJobs; }
    ULONG GetPrintPostIts () const { return nPrintPostIts; }

};

/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog, ShadowCursorSeite
--------------------------------------------------------- */

class SW_DLLPUBLIC SwShadowCursorItem : public SfxPoolItem
{
    BYTE eMode;
    BOOL bOn;
public:
    TYPEINFO();
    SwShadowCursorItem( USHORT nWhich = FN_PARAM_SHADOWCURSOR );
    SwShadowCursorItem( const SwShadowCursorItem& rElemItem );
    SwShadowCursorItem( const SwViewOption& rVOpt, USHORT nWhich );

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;
    void                    operator=( const SwShadowCursorItem& );

    void FillViewOptions( SwViewOption& rVOpt) const;

    BYTE GetMode() const                { return eMode; }
    BOOL IsOn() const                   { return bOn; }

    void SetMode( BYTE eM )             { eMode = eM; }
    void SetOn( BOOL bFlag )            { bOn = bFlag; }
};

#ifndef PRODUCT
/*--------OS 12.01.95 -----------------------------------
Item fuer Einstellungsdialog - Testeinstellungen
--------------------------------------------------------- */
class SwTestItem : public SfxPoolItem
{
    friend class SwModule;
    friend class SwWriterApp;
    friend class SwTestTabPage;
    friend class SwDocEditDialog;

    BOOL    bTest1:1;
    BOOL    bTest2:1;
    BOOL    bTest3:1;
    BOOL    bTest4:1;
    BOOL    bTest5:1;
    BOOL    bTest6:1;
    BOOL    bTest7:1;
    BOOL    bTest8:1;
    BOOL    bTest9:1;
    BOOL    bTest10:1;

public:
                            SwTestItem( USHORT nWhich):
                                            SfxPoolItem(nWhich){};
                            SwTestItem( const SwTestItem& pTestItem);

    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
    virtual int             operator==( const SfxPoolItem& ) const;

};
#endif

#endif

<|endoftext|>


<commit_before>/*************************************************************************
 *
 *  $RCSfile: labelcfg.hxx,v $
 *
 *  $Revision: 1.3 $
 *
 *  last change: $Author: rt $ $Date: 2004-08-23 08:59: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 _LABELCFG_HXX
#define _LABELCFG_HXX

#ifndef _UTL_CONFIGITEM_HXX_
#include <unotools/configitem.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

class SwLabRecs;
class SwLabRec;

class SW_DLLPUBLIC SwLabelConfig : public utl::ConfigItem
{
    com::sun::star::uno::Sequence<rtl::OUString> aNodeNames;

    SW_DLLPRIVATE com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();

public:
    SwLabelConfig();
    virtual ~SwLabelConfig();

    virtual void            Commit();

    void    FillLabels(const rtl::OUString& rManufacturer, SwLabRecs& rLabArr);
    const com::sun::star::uno::Sequence<rtl::OUString>&
            GetManufacturers() const {return aNodeNames;}

    sal_Bool    HasLabel(const rtl::OUString& rManufacturer, const rtl::OUString& rType);
    void        SaveLabel(const rtl::OUString& rManufacturer, const rtl::OUString& rType,
                            const SwLabRec& rRec);
};

#endif

<commit_msg>INTEGRATION: CWS ooo19126 (1.3.596); FILE MERGED 2005/09/05 13:45:19 rt 1.3.596.1: #i54170# Change license header: remove SISSL<commit_after>/*************************************************************************
 *
 *  OpenOffice.org - a multi-platform office productivity suite
 *
 *  $RCSfile: labelcfg.hxx,v $
 *
 *  $Revision: 1.4 $
 *
 *  last change: $Author: rt $ $Date: 2005-09-09 09:24:13 $
 *
 *  The Contents of this file are made available subject to
 *  the terms of GNU Lesser General Public License Version 2.1.
 *
 *
 *    GNU Lesser General Public License Version 2.1
 *    =============================================
 *    Copyright 2005 by Sun Microsystems, Inc.
 *    901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *    This library is free software; you can redistribute it and/or
 *    modify it under the terms of the GNU Lesser General Public
 *    License version 2.1, as published by the Free Software Foundation.
 *
 *    This library is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *    Lesser General Public License for more details.
 *
 *    You should have received a copy of the GNU Lesser General Public
 *    License along with this library; if not, write to the Free Software
 *    Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *    MA  02111-1307  USA
 *
 ************************************************************************/
#ifndef _LABELCFG_HXX
#define _LABELCFG_HXX

#ifndef _UTL_CONFIGITEM_HXX_
#include <unotools/configitem.hxx>
#endif

#ifndef INCLUDED_SWDLLAPI_H
#include "swdllapi.h"
#endif

class SwLabRecs;
class SwLabRec;

class SW_DLLPUBLIC SwLabelConfig : public utl::ConfigItem
{
    com::sun::star::uno::Sequence<rtl::OUString> aNodeNames;

    SW_DLLPRIVATE com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();

public:
    SwLabelConfig();
    virtual ~SwLabelConfig();

    virtual void            Commit();

    void    FillLabels(const rtl::OUString& rManufacturer, SwLabRecs& rLabArr);
    const com::sun::star::uno::Sequence<rtl::OUString>&
            GetManufacturers() const {return aNodeNames;}

    sal_Bool    HasLabel(const rtl::OUString& rManufacturer, const rtl::OUString& rType);
    void        SaveLabel(const rtl::OUString& rManufacturer, const rtl::OUString& rType,
                            const SwLabRec& rRec);
};

#endif

<|endoftext|>


<commit_before>//=======================================================================
// Copyright Baptiste Wicht 2013-2014.
// Distributed under the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

/*!
 * \file stop_watch.hpp
 * \brief Contains stop watches implementation to measure duration
 */

#ifndef CPP_STOP_WATCH_HPP
#define CPP_STOP_WATCH_HPP

#include <chrono>
#include <iostream>

namespace cpp {

/*!
 * \brief Default clock type used by the library
 */
using clock_type = std::chrono::high_resolution_clock;

/*!
 * \class stop_watch
 * \brief A stop watch
 * \tparam P The std::chrono precision used by the watch.
 *
 * The watch automatically starts when the constructor is called
 */
template<typename P = std::chrono::milliseconds>
class stop_watch {
public:
    /*!
     * \brief The std::chrono precision used by the watch.
     */
    using precision = P;

    /*!
     * \brief Constructs a new stop_watch and starts it.
     */
    stop_watch(){
        start_point = clock_type::now();
    }

    /*!
     * \brief Return the elapsed time since construction.
     * \return the elapsed time since construction.
     */
    double elapsed(){
        auto end_point = clock_type::now();
        auto time = std::chrono::duration_cast<precision>(end_point - start_point);
        return time.count();
    }

private:
    clock_type::time_point start_point;
};

/*!
 * \class auto_stop_watch
 * \brief An automatic stop watch
 * \tparam P The std::chrono precision used by the watch.
 *
 * The watch automatically starts when the constructor is called and display the duration when destructed.
 */
template<typename P = std::chrono::milliseconds>
class auto_stop_watch {
public:
    /*!
     * \brief The std::chrono precision used by the watch.
     */
    using precision = P;

    /*!
     * \brief Constructs a new auto_stop_watch and starts it.
     * \param title The title that will be displayed when the watch is over.
     */
    auto_stop_watch(std::string title) : title(std::move(title)) {
        //Empty
    }

    /*!
     * \brief Destroys the auto_stop_watch and display the elapsed time.
     */
    ~auto_stop_watch(){
        std::cout << title << " took " << watch.elapsed() << std::endl;
    }

private:
    std::string title;
    stop_watch<precision> watch;
};

} //end of cpp namespace

#endif //CPP_STOP_WATCH_HPP
<commit_msg>Make 1-arg constructor explicit<commit_after>//=======================================================================
// Copyright Baptiste Wicht 2013-2014.
// Distributed under the MIT License.
// (See accompanying file LICENSE or copy at
//  http://opensource.org/licenses/MIT)
//=======================================================================

/*!
 * \file stop_watch.hpp
 * \brief Contains stop watches implementation to measure duration
 */

#ifndef CPP_STOP_WATCH_HPP
#define CPP_STOP_WATCH_HPP

#include <chrono>
#include <iostream>

namespace cpp {

/*!
 * \brief Default clock type used by the library
 */
using clock_type = std::chrono::high_resolution_clock;

/*!
 * \class stop_watch
 * \brief A stop watch
 * \tparam P The std::chrono precision used by the watch.
 *
 * The watch automatically starts when the constructor is called
 */
template<typename P = std::chrono::milliseconds>
class stop_watch {
public:
    /*!
     * \brief The std::chrono precision used by the watch.
     */
    using precision = P;

    /*!
     * \brief Constructs a new stop_watch and starts it.
     */
    stop_watch(){
        start_point = clock_type::now();
    }

    /*!
     * \brief Return the elapsed time since construction.
     * \return the elapsed time since construction.
     */
    double elapsed(){
        auto end_point = clock_type::now();
        auto time = std::chrono::duration_cast<precision>(end_point - start_point);
        return time.count();
    }

private:
    clock_type::time_point start_point;
};

/*!
 * \class auto_stop_watch
 * \brief An automatic stop watch
 * \tparam P The std::chrono precision used by the watch.
 *
 * The watch automatically starts when the constructor is called and display the duration when destructed.
 */
template<typename P = std::chrono::milliseconds>
class auto_stop_watch {
public:
    /*!
     * \brief The std::chrono precision used by the watch.
     */
    using precision = P;

    /*!
     * \brief Constructs a new auto_stop_watch and starts it.
     * \param title The title that will be displayed when the watch is over.
     */
    explicit auto_stop_watch(std::string title) : title(std::move(title)) {
        //Empty
    }

    /*!
     * \brief Destroys the auto_stop_watch and display the elapsed time.
     */
    ~auto_stop_watch(){
        std::cout << title << " took " << watch.elapsed() << std::endl;
    }

private:
    std::string title;
    stop_watch<precision> watch;
};

} //end of cpp namespace

#endif //CPP_STOP_WATCH_HPP
<|endoftext|>


<commit_before>#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <aslam/cameras/GridCalibrationTargetCheckerboard.hpp>
#include <sm/eigen/serialization.hpp>

namespace aslam {
namespace cameras {

/// \brief Construct a calibration target
///        rows:   number of internal corners (8x8 chessboard would be 7x7 internal corners)
///        cols:   number of internal corners
///        rowSpacingMeters: spacing in y-direction [m]
///        colSpacingMeters: spacing in x-direction [m]
///
///   point ordering in _points: (e.g. 2x2 grid)
///          *-------*-------*-------*
///          | BLACK | WHITE | BLACK |
///          *------(3)-----(4)------*
///          | WHITE | BLACK | WHITE |
///          *------(1)-----(2)------*
///    y     | BLACK | WHITE | BLACK |
///   ^      *-------*-------*-------*
///   |-->x
GridCalibrationTargetCheckerboard::GridCalibrationTargetCheckerboard(
    size_t rows, size_t cols, double rowSpacingMeters, double colSpacingMeters,
    const CheckerboardOptions &options)
    : GridCalibrationTargetBase(rows, cols),
      _rowSpacingMeters(rowSpacingMeters),
      _colSpacingMeters(colSpacingMeters),
      _options(options) {
  SM_ASSERT_GT(Exception, rowSpacingMeters, 0.0,
               "rowSpacingMeters has to be positive");
  SM_ASSERT_GT(Exception, colSpacingMeters, 0.0,
               "colSpacingMeters has to be positive");

  // allocate memory for the grid points
  _points.resize(size(), 3);

  //initialize a normal grid (checkerboard and circlegrids)
  createGridPoints();

  //start the output window if requested
  initialize();
}

/// \brief initialize the object
void GridCalibrationTargetCheckerboard::initialize()
{
  if (_options.showExtractionVideo) {
    cv::namedWindow("Checkerboard corners", CV_WINDOW_AUTOSIZE);
    cvStartWindowThread();
  }
}

/// \brief initialize a checkerboard grid (cols*rows = (cols)*(rows) internal grid points)
///   point ordering: (e.g. 2x2 grid)
///          *-------*-------*-------*
///          | BLACK | WHITE | BLACK |
///          *------(3)-----(4)------*
///          | WHITE | BLACK | WHITE |
///          *------(1)-----(2)------*
///    y     | BLACK | WHITE | BLACK |
///   ^      *-------*-------*-------*
///   |-->x
///
void GridCalibrationTargetCheckerboard::createGridPoints() {
  for (unsigned int r = 0; r < _rows; r++)
    for (unsigned int c = 0; c < _cols; c++)
      _points.row(gridCoordinatesToPoint(r, c)) = Eigen::Matrix<double, 1, 3>(
          _rowSpacingMeters * r, _colSpacingMeters * c, 0.0);
}

/// \brief extract the calibration target points from an image and write to an observation
bool GridCalibrationTargetCheckerboard::computeObservation(const cv::Mat & image,
           Eigen::MatrixXd & outImagePoints, std::vector<bool> &outCornerObserved) const {

  // set the open cv flags
  int flags = cv::CALIB_CB_FAST_CHECK;
  if (_options.useAdaptiveThreshold)
    flags += cv::CALIB_CB_ADAPTIVE_THRESH;
  if ( _options.normalizeImage)
    flags += cv::CALIB_CB_NORMALIZE_IMAGE;
  if (_options.filterQuads)
    flags += cv::CALIB_CB_FILTER_QUADS;

  // extract the checkerboard corners
  cv::Size patternSize(cols(), rows());
  cv::Mat centers(size(), 2, CV_64FC1);
  bool success = cv::findChessboardCorners(image, patternSize, centers, flags);

  // do optional subpixel refinement
  if (_options.doSubpixelRefinement && success) {
    cv::cornerSubPix(
        image, centers, cv::Size(11, 11), cv::Size(-1, -1),
        cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
  }

  //draw corners
  if (_options.showExtractionVideo) {
    //image with refined (blue) and raw corners (red)
    cv::Mat imageCopy1 = image.clone();
    cv::cvtColor(imageCopy1, imageCopy1, CV_GRAY2RGB);
    cv::drawChessboardCorners(imageCopy1, cv::Size(rows(), cols()), centers,
                              true);

    // write error msg
    if (!success)
      cv::putText(imageCopy1, "Detection failed! (frame not used)",
                  cv::Point(50, 50), CV_FONT_HERSHEY_SIMPLEX, 0.8,
                  CV_RGB(255,0,0), 3, 8, false);

    cv::imshow("Checkerboard corners", imageCopy1);  // OpenCV call
  }

  //exit here if there is an error
  if (!success)
    return success;

  //set all points as observed (checkerboard is only usable in that case)
  std::vector<bool> allGood(size(), true);
  outCornerObserved = allGood;

  //convert to eigen for output
  outImagePoints.resize(size(), 2);
  for (unsigned int i = 0; i < size(); i++)
    outImagePoints.row(i) = Eigen::Matrix<double, 1, 2>(
        centers.row(i).at<float>(0), centers.row(i).at<float>(1));

  return success;
}
}  // namespace cameras
}  // namespace aslam

//export explicit instantions for all included archives
#include <sm/boost/serialization.hpp>
#include <boost/serialization/export.hpp>
BOOST_CLASS_EXPORT_IMPLEMENT(aslam::cameras::GridCalibrationTargetCheckerboard);
BOOST_CLASS_EXPORT_IMPLEMENT(aslam::cameras::GridCalibrationTargetCheckerboard::CheckerboardOptions);
<commit_msg>consistent checkerboard pattern size<commit_after>#include <vector>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <aslam/cameras/GridCalibrationTargetCheckerboard.hpp>
#include <sm/eigen/serialization.hpp>

namespace aslam {
namespace cameras {

/// \brief Construct a calibration target
///        rows:   number of internal corners (8x8 chessboard would be 7x7 internal corners)
///        cols:   number of internal corners
///        rowSpacingMeters: spacing in y-direction [m]
///        colSpacingMeters: spacing in x-direction [m]
///
///   point ordering in _points: (e.g. 2x2 grid)
///          *-------*-------*-------*
///          | BLACK | WHITE | BLACK |
///          *------(3)-----(4)------*
///          | WHITE | BLACK | WHITE |
///          *------(1)-----(2)------*
///    y     | BLACK | WHITE | BLACK |
///   ^      *-------*-------*-------*
///   |-->x
GridCalibrationTargetCheckerboard::GridCalibrationTargetCheckerboard(
    size_t rows, size_t cols, double rowSpacingMeters, double colSpacingMeters,
    const CheckerboardOptions &options)
    : GridCalibrationTargetBase(rows, cols),
      _rowSpacingMeters(rowSpacingMeters),
      _colSpacingMeters(colSpacingMeters),
      _options(options) {
  SM_ASSERT_GT(Exception, rowSpacingMeters, 0.0,
               "rowSpacingMeters has to be positive");
  SM_ASSERT_GT(Exception, colSpacingMeters, 0.0,
               "colSpacingMeters has to be positive");

  // allocate memory for the grid points
  _points.resize(size(), 3);

  //initialize a normal grid (checkerboard and circlegrids)
  createGridPoints();

  //start the output window if requested
  initialize();
}

/// \brief initialize the object
void GridCalibrationTargetCheckerboard::initialize()
{
  if (_options.showExtractionVideo) {
    cv::namedWindow("Checkerboard corners", CV_WINDOW_AUTOSIZE);
    cvStartWindowThread();
  }
}

/// \brief initialize a checkerboard grid (cols*rows = (cols)*(rows) internal grid points)
///   point ordering: (e.g. 2x2 grid)
///          *-------*-------*-------*
///          | BLACK | WHITE | BLACK |
///          *------(3)-----(4)------*
///          | WHITE | BLACK | WHITE |
///          *------(1)-----(2)------*
///    y     | BLACK | WHITE | BLACK |
///   ^      *-------*-------*-------*
///   |-->x
///
void GridCalibrationTargetCheckerboard::createGridPoints() {
  for (unsigned int r = 0; r < _rows; r++)
    for (unsigned int c = 0; c < _cols; c++)
      _points.row(gridCoordinatesToPoint(r, c)) = Eigen::Matrix<double, 1, 3>(
          _rowSpacingMeters * r, _colSpacingMeters * c, 0.0);
}

/// \brief extract the calibration target points from an image and write to an observation
bool GridCalibrationTargetCheckerboard::computeObservation(const cv::Mat & image,
           Eigen::MatrixXd & outImagePoints, std::vector<bool> &outCornerObserved) const {

  // set the open cv flags
  int flags = cv::CALIB_CB_FAST_CHECK;
  if (_options.useAdaptiveThreshold)
    flags += cv::CALIB_CB_ADAPTIVE_THRESH;
  if ( _options.normalizeImage)
    flags += cv::CALIB_CB_NORMALIZE_IMAGE;
  if (_options.filterQuads)
    flags += cv::CALIB_CB_FILTER_QUADS;

  // extract the checkerboard corners
  cv::Size patternSize(cols(), rows());
  cv::Mat centers(size(), 2, CV_64FC1);
  bool success = cv::findChessboardCorners(image, patternSize, centers, flags);

  // do optional subpixel refinement
  if (_options.doSubpixelRefinement && success) {
    cv::cornerSubPix(
        image, centers, cv::Size(11, 11), cv::Size(-1, -1),
        cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1));
  }

  //draw corners
  if (_options.showExtractionVideo) {
    //image with refined (blue) and raw corners (red)
    cv::Mat imageCopy1 = image.clone();
    cv::cvtColor(imageCopy1, imageCopy1, CV_GRAY2RGB);
    cv::drawChessboardCorners(imageCopy1, patternSize, centers, true);

    // write error msg
    if (!success)
      cv::putText(imageCopy1, "Detection failed! (frame not used)",
                  cv::Point(50, 50), CV_FONT_HERSHEY_SIMPLEX, 0.8,
                  CV_RGB(255,0,0), 3, 8, false);

    cv::imshow("Checkerboard corners", imageCopy1);  // OpenCV call
  }

  //exit here if there is an error
  if (!success)
    return success;

  //set all points as observed (checkerboard is only usable in that case)
  std::vector<bool> allGood(size(), true);
  outCornerObserved = allGood;

  //convert to eigen for output
  outImagePoints.resize(size(), 2);
  for (unsigned int i = 0; i < size(); i++)
    outImagePoints.row(i) = Eigen::Matrix<double, 1, 2>(
        centers.row(i).at<float>(0), centers.row(i).at<float>(1));

  return success;
}
}  // namespace cameras
}  // namespace aslam

//export explicit instantions for all included archives
#include <sm/boost/serialization.hpp>
#include <boost/serialization/export.hpp>
BOOST_CLASS_EXPORT_IMPLEMENT(aslam::cameras::GridCalibrationTargetCheckerboard);
BOOST_CLASS_EXPORT_IMPLEMENT(aslam::cameras::GridCalibrationTargetCheckerboard::CheckerboardOptions);
<|endoftext|>


<commit_before>/*
 * Promise2
 *
 * Copyright (c) 2015-2016 "0of" Magnus
 * Licensed under the MIT license.
 * https://github.com/0of/Promise2/blob/master/LICENSE
 */
#ifndef PROMISE2_API_CPP
#define PROMISE2_API_CPP

#define NESTING_PROMISE 1
#define DEFERRED_PROMISE 1
#ifdef __APPLE__
# define USE_DISPATCH 1
#endif // __APPLE__
/*
 * testing APIs
 */
#include "Promise.h"
#include "entry.h"
#include "ThreadContext_STL.h"

class CurrentContext : public Promise2::ThreadContext {
public:
  static ThreadContext *New() {
    return new CurrentContext;
  }

public:
  virtual void scheduleToRun(std::function<void()>&& task) override {
    task();
  }
};

#ifdef __APPLE__
#include <cstdlib>
#include <dispatch/dispatch.h>

class GCDContainer : public DefaultContainer {
private:
  std::atomic_int _runningTestCount;

private:
  using Runnable = std::pair<GCDContainer *, LTest::SharedTestRunnable>;

  static void InvokeRunnable(void *context) {
    std::unique_ptr<Runnable> runnable{ static_cast<Runnable *>(context) };
    runnable->second->run(*runnable->first);
  }

  static void quit(void *) {
    std::exit(0);
  }

public:
  virtual void scheduleToRun(const LTest::SharedTestRunnable& runnable) override {
    dispatch_async_f(dispatch_get_main_queue(), new Runnable{ this, runnable }, InvokeRunnable);
    ++_runningTestCount;
  }

  virtual void endRun() override {
    DefaultContainer::endRun();

    if (--_runningTestCount == 0) {
        dispatch_async_f(dispatch_get_main_queue(), nullptr, quit);
    }
  }

protected:
  virtual void startTheLoop() override {
    dispatch_main();
  }
};
# define CONTAINER_TYPE GCDContainer

#include "ThreadContext_GCD.h"
using MainThreadContext = ThreadContextImpl::GCD::MainThreadContext;

#else
# define CONTAINER_TYPE DefaultContainer
#endif // __APPLE__

class UserException : public std::exception {};
class AssertionFailed : public std::exception {};

using STLThreadContext = ThreadContextImpl::STL::DetachedThreadContext;

namespace SpecFixedValue {
  void passUserException(const LTest::SharedCaseEndNotifier& notifier, std::exception_ptr e) {
    if (e) {
      try {
        std::rethrow_exception(e);
      } catch(const UserException&) {
        // pass
        notifier->done();
      } catch(...) {
        notifier->fail(std::make_exception_ptr(AssertionFailed()));
      }
    } else {
      notifier->fail(std::make_exception_ptr(AssertionFailed()));
    }
  }

#define INIT(context, tag) \
    spec \
     /* ==> */ \
    .it(#tag"should acquire the fulfilled value", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::Resolved(truth).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::Rejected(std::make_exception_ptr(UserException())).then([=](bool){ \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from returned task", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=]{ return truth; }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from returned task", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([]() -> bool { throw UserException(); }, context::New()).then([=](bool){ \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from nesting promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=]{ return Promise2::Promise<bool>::Resolved(truth); }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from nesting promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([]{ \
        return Promise2::Promise<bool>::Rejected(std::make_exception_ptr(UserException())); \
      }, context::New()).then([=](bool fulfilled){ \
       notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from deferred promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=](Promise2::PromiseDefer<bool>&& deferred){ \
        deferred.setResult(truth); \
      }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from deferred promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([](Promise2::PromiseDefer<bool>&& deferred){ \
        deferred.setException(std::make_exception_ptr(UserException())); \
      }, context::New()).then([=](bool fulfilled){ \
       notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    });

  template<typename T>
  void init(T& spec) {
    INIT(CurrentContext, CurrentContext:)
    INIT(STLThreadContext, STLThreadContext:)
#ifdef __APPLE__
    INIT(MainThreadContext, GCDThreadContext:)
#endif // __APPLE__
  // end of the init spec
  }
} // SpecFixedValue

TEST_ENTRY(CONTAINER_TYPE, SPEC_TFN(SpecFixedValue::init))

#endif // PROMISE2_API_CPP
<commit_msg>add `isFulfilled` & `isRejected` test cases<commit_after>/*
 * Promise2
 *
 * Copyright (c) 2015-2016 "0of" Magnus
 * Licensed under the MIT license.
 * https://github.com/0of/Promise2/blob/master/LICENSE
 */
#ifndef PROMISE2_API_CPP
#define PROMISE2_API_CPP

#define NESTING_PROMISE 1
#define DEFERRED_PROMISE 1
#ifdef __APPLE__
# define USE_DISPATCH 1
#endif // __APPLE__
/*
 * testing APIs
 */
#include "Promise.h"
#include "entry.h"
#include "ThreadContext_STL.h"

class CurrentContext : public Promise2::ThreadContext {
public:
  static ThreadContext *New() {
    return new CurrentContext;
  }

public:
  virtual void scheduleToRun(std::function<void()>&& task) override {
    task();
  }
};

#ifdef __APPLE__
#include <cstdlib>
#include <dispatch/dispatch.h>

class GCDContainer : public DefaultContainer {
private:
  std::atomic_int _runningTestCount;

private:
  using Runnable = std::pair<GCDContainer *, LTest::SharedTestRunnable>;

  static void InvokeRunnable(void *context) {
    std::unique_ptr<Runnable> runnable{ static_cast<Runnable *>(context) };
    runnable->second->run(*runnable->first);
  }

  static void quit(void *) {
    std::exit(0);
  }

public:
  virtual void scheduleToRun(const LTest::SharedTestRunnable& runnable) override {
    dispatch_async_f(dispatch_get_main_queue(), new Runnable{ this, runnable }, InvokeRunnable);
    ++_runningTestCount;
  }

  virtual void endRun() override {
    DefaultContainer::endRun();

    if (--_runningTestCount == 0) {
        dispatch_async_f(dispatch_get_main_queue(), nullptr, quit);
    }
  }

protected:
  virtual void startTheLoop() override {
    dispatch_main();
  }
};
# define CONTAINER_TYPE GCDContainer

#include "ThreadContext_GCD.h"
using MainThreadContext = ThreadContextImpl::GCD::MainThreadContext;

#else
# define CONTAINER_TYPE DefaultContainer
#endif // __APPLE__

class UserException : public std::exception {};
class AssertionFailed : public std::exception {};

using STLThreadContext = ThreadContextImpl::STL::DetachedThreadContext;

namespace SpecFixedValue {
  void passUserException(const LTest::SharedCaseEndNotifier& notifier, std::exception_ptr e) {
    if (e) {
      try {
        std::rethrow_exception(e);
      } catch(const UserException&) {
        // pass
        notifier->done();
      } catch(...) {
        notifier->fail(std::make_exception_ptr(AssertionFailed()));
      }
    } else {
      notifier->fail(std::make_exception_ptr(AssertionFailed()));
    }
  }

#define INIT(context, tag) \
    spec \
     /* ==> */ \
    .it(#tag"should acquire the fulfilled value", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::Resolved(truth).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::Rejected(std::make_exception_ptr(UserException())).then([=](bool){ \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from returned task", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=]{ return truth; }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from returned task", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([]() -> bool { throw UserException(); }, context::New()).then([=](bool){ \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from nesting promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=]{ return Promise2::Promise<bool>::Resolved(truth); }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from nesting promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([]{ \
        return Promise2::Promise<bool>::Rejected(std::make_exception_ptr(UserException())); \
      }, context::New()).then([=](bool fulfilled){ \
       notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should acquire the fulfilled value from deferred promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      constexpr bool truth = true; \
      Promise2::Promise<bool>::New([=](Promise2::PromiseDefer<bool>&& deferred){ \
        deferred.setResult(truth); \
      }, context::New()).then([=](bool fulfilled){ \
        if (truth != fulfilled) { \
          notifier->fail(std::make_exception_ptr(AssertionFailed())); \
          return; \
        } \
        notifier->done(); \
      }, [=](std::exception_ptr) { \
        notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, context::New()); \
    }) \
    \
    /* ==> */ \
    .it(#tag"should transfer the exception downstream from deferred promise", [](const LTest::SharedCaseEndNotifier& notifier){ \
      Promise2::Promise<bool>::New([](Promise2::PromiseDefer<bool>&& deferred){ \
        deferred.setException(std::make_exception_ptr(UserException())); \
      }, context::New()).then([=](bool fulfilled){ \
       notifier->fail(std::make_exception_ptr(AssertionFailed())); \
      }, std::bind(passUserException, notifier, std::placeholders::_1), context::New()); \
    });

  template<typename T>
  void init(T& spec) {
    INIT(CurrentContext, CurrentContext:)
    INIT(STLThreadContext, STLThreadContext:)
#ifdef __APPLE__
    INIT(MainThreadContext, GCDThreadContext:)
#endif // __APPLE__

    spec
    /* ==> */
    .it("should be fulfilled", []{
      auto p = Promise2::Promise<int>::Resolved(1);
      if (!p.isFulfilled())
        throw AssertionFailed();
    })
    /* ==> */
    .it("should be fulfilled", []{
      auto p = Promise2::Promise<int>::Rejected(std::make_exception_ptr(UserException()));
      if (!p.isRejected())
        throw AssertionFailed();
    });
  // end of the init spec
  }
} // SpecFixedValue

TEST_ENTRY(CONTAINER_TYPE, SPEC_TFN(SpecFixedValue::init))

#endif // PROMISE2_API_CPP
<|endoftext|>


<commit_before>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SD_SOURCE_UI_INC_VIEW_HXX
#define INCLUDED_SD_SOURCE_UI_INC_VIEW_HXX

#include <boost/ptr_container/ptr_vector.hpp>

#include "pres.hxx"
#include <tools/gen.hxx>
#include <svtools/transfer.hxx>
#include <svx/fmview.hxx>
#include <svx/svdmark.hxx>
#include <svx/svdpage.hxx>
#include <vcl/idle.hxx>
#include "fupoor.hxx"

#include "smarttag.hxx"
#include <editeng/numitem.hxx>

class SdDrawDocument;
class SdPage;
class SdrOle2Obj;
class SdrGrafObj;
class SdrMediaObj;
class OutputDevice;
class ImageMap;
class Point;
class Graphic;
class SdrOutliner;
class TransferableDataHelper;
struct StyleRequestData;
class Outliner;

namespace sd {

class DrawDocShell;
struct SdNavigatorDropEvent;
class ViewShell;
class Window;
class ViewClipboard;

// SdViewRedrawRec
struct SdViewRedrawRec
{
    VclPtr<OutputDevice> mpOut;
    Rectangle            aRect;
};

//For master view we want to force that master
//textboxes have readonly text, because the
//text is the auto-generated click-here-to-edit
//and it doesn't help to change it
class OutlinerMasterViewFilter
{
private:
    SdrOutliner *m_pOutl;
    bool m_bReadOnly;
public:
    OutlinerMasterViewFilter()
        : m_pOutl(0)
        , m_bReadOnly(false)
    {
    }
    void Start(SdrOutliner *pOutl);
    void End();
};

class View : public FmFormView
{
public:
    TYPEINFO_OVERRIDE();

    View (
        SdDrawDocument& rDrawDoc,
        OutputDevice* pOutDev,
        ViewShell* pViewSh=NULL);
    virtual ~View();

    void                    CompleteRedraw( OutputDevice* pOutDev, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L) SAL_OVERRIDE;

    virtual bool            GetAttributes( SfxItemSet& rTargetSet, bool bOnlyHardAttr = false ) const;
    virtual bool            SetAttributes(const SfxItemSet& rSet, bool bReplaceAll = false);
    virtual void            MarkListHasChanged() SAL_OVERRIDE;
    virtual void            ModelHasChanged() SAL_OVERRIDE;
    void                    SelectAll();
    void                    DoCut(vcl::Window* pWindow=NULL);
    void                    DoCopy(vcl::Window* pWindow=NULL);
    void                    DoPaste(vcl::Window* pWindow=NULL);
    virtual void            DoConnect(SdrOle2Obj* pOleObj) SAL_OVERRIDE;
    virtual bool            SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr = false);
    void                    StartDrag( const Point& rStartPos, vcl::Window* pWindow );
    virtual void            DragFinished( sal_Int8 nDropAction );
    virtual sal_Int8 AcceptDrop (
        const AcceptDropEvent& rEvt,
        DropTargetHelper& rTargetHelper,
        ::sd::Window* pTargetWindow = NULL,
        sal_uInt16 nPage = SDRPAGE_NOTFOUND,
        sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
    virtual sal_Int8 ExecuteDrop (
        const ExecuteDropEvent& rEvt,
        DropTargetHelper& rTargetHelper,
        ::sd::Window* pTargetWindow = NULL,
        sal_uInt16 nPage = SDRPAGE_NOTFOUND,
        sal_uInt16 nLayer = SDRPAGE_NOTFOUND);

    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateClipboardDataObject (::sd::View*, vcl::Window& rWindow);
    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateDragDataObject (::sd::View*, vcl::Window& rWindow,
            const Point& rDragPos);
    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateSelectionDataObject (::sd::View*, vcl::Window& rWindow);

    void                    UpdateSelectionClipboard( bool bForceDeselect );

    inline DrawDocShell* GetDocSh() const { return mpDocSh; }
    inline SdDrawDocument& GetDoc() const;
    inline ViewShell* GetViewShell() const { return mpViewSh; }

    virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = 0L, vcl::Window* pWin = 0L, bool bIsNewObj = false,
        SdrOutliner* pGivenOutliner = 0L, OutlinerView* pGivenOutlinerView = 0L,
        bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true) SAL_OVERRIDE;

    virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false) SAL_OVERRIDE;

    bool RestoreDefaultText( SdrTextObj* pTextObj );

    bool                    InsertData( const TransferableDataHelper& rDataHelper,
                                        const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
                                        SotClipboardFormatId nFormat = SotClipboardFormatId::NONE,
                                        sal_uInt16 nPage = SDRPAGE_NOTFOUND, sal_uInt16 nLayer = SDRLAYER_NOTFOUND );
    /** gets the metafile from the given transferable helper and insert it as a graphic shape.
        @param bOptimize if set to true, the metafile is analyzed and if only one bitmap action is
                         present, then is inserted as a single graphic.
    */
    bool                    InsertMetaFile( TransferableDataHelper& rDataHelper,
                                            const Point& rInsertPos,
                                            ImageMap* pImageMap, bool bOptimize );

    SdrGrafObj*             InsertGraphic( const Graphic& rGraphic,
                                           sal_Int8& rAction, const Point& rPos,
                                           SdrObject* pSelectedObj, ImageMap* pImageMap );
    SdrMediaObj*            InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
                                            const Point& rPos, const Size& rSize,
                                            bool const bLink );

    SdrMediaObj*            Insert3DModelURL( const OUString& rModelURL, sal_Int8& rAction,
                                              const Point& rPos, const Size& rSize,
                                              bool const bLink );

    SdrMediaObj*            InsertMediaObj( const OUString& rURL, const OUString& rMimeType, sal_Int8& rAction,
                                            const Point& rPos, const Size& rSize );

    bool PasteRTFTable( ::tools::SvRef<SotStorageStream> xStm, SdrPage* pPage, SdrInsertFlags nPasteOptions );

    bool                    IsPresObjSelected(bool bOnPage = true, bool bOnMasterPage = true, bool bCheckPresObjListOnly = false, bool bCheckLayoutOnly = false) const;

    void                    SetMarkedOriginalSize();

    bool                    IsMorphingAllowed() const;
    bool                    IsVectorizeAllowed() const;

    virtual SfxStyleSheet*  GetStyleSheet() const;

    /** return parameter:
        pExchangeList == NULL -> all names are unique
        bNameOK == false -> cancel by user
        nType == 0 -> pages
        nType == 1 -> objects
        nType == 2 -> pages and objects    */

    bool GetExchangeList( std::vector<OUString> &rExchangeList,
                          std::vector<OUString> &rBookmarkList,
                          const sal_uInt16 nType );

    virtual void onAccessibilityOptionsChanged() SAL_OVERRIDE;

    virtual SdrModel*   GetMarkedObjModel() const SAL_OVERRIDE;
    virtual bool Paste(
        const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions,
        const OUString& rSrcShellID, const OUString& rDestShellID ) SAL_OVERRIDE;

    using SdrExchangeView::Paste;

    /** returns true if we have an undo manager and there is an open list undo action */
    bool isRecordingUndo() const;

    virtual void AddCustomHdl() SAL_OVERRIDE;

    SmartTagSet& getSmartTags() { return maSmartTags; }
    void selectSmartTag( const SmartTagReference& xTag );
    void updateHandles();

    virtual SdrViewContext GetContext() const SAL_OVERRIDE;
    virtual bool HasMarkablePoints() const SAL_OVERRIDE;
    virtual sal_uLong GetMarkablePointCount() const SAL_OVERRIDE;
    virtual bool HasMarkedPoints() const SAL_OVERRIDE;
    virtual sal_uLong GetMarkedPointCount() const SAL_OVERRIDE;
    virtual bool IsPointMarkable(const SdrHdl& rHdl) const SAL_OVERRIDE;
    virtual bool MarkPoint(SdrHdl& rHdl, bool bUnmark=false) SAL_OVERRIDE;
    virtual void CheckPossibilities() SAL_OVERRIDE;
    virtual bool MarkPoints(const ::Rectangle* pRect, bool bUnmark) SAL_OVERRIDE;
    using SdrMarkView::MarkPoints;

    bool ShouldToggleOn(
        const bool bBulletOnOffMode,
        const bool bNormalBullet);

    /** change the bullets/numbering of the marked objects

        @param bToggle
        true: just toggle the current bullets/numbering on --> off resp. off --> on

        @param bHandleBullets
        true: handle bullets
        false: handle numbering

        @param pNumRule
        numbering rule which needs to be applied. can be 0.

        @param bSwitchOff
        true: switch off bullets/numbering
    */
    void ChangeMarkedObjectsBulletsNumbering(
        const bool bToggle,
        const bool bHandleBullets,
        const SvxNumRule* pNumRule);

    void SetPossibilitiesDirty() { bPossibilitiesDirty = true; }
    void SetMoveAllowed( bool bSet ) { bMoveAllowed = bSet; }
    void SetMoveProtected( bool bSet ) { bMoveProtect = bSet; }
    void SetResizeFreeAllowed( bool bSet ) { bResizeFreeAllowed = bSet; }
    void SetResizePropAllowed( bool bSet ) { bResizePropAllowed = bSet; }
    void SetResizeProtected( bool bSet ) { bResizeProtect = bSet; }

    void SetMarkedPointsSmoothPossible( bool bSet ) { bSetMarkedPointsSmoothPossible = bSet; }
    void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; }

    SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
    SdPage* GetPage();
    SdrObject* GetSelectedSingleObject(SdPage* pPage);

protected:
    DECL_LINK( OnParagraphInsertedHdl, ::Outliner * );
    DECL_LINK( OnParagraphRemovingHdl, ::Outliner * );

    virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos ) SAL_OVERRIDE;
    virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos ) SAL_OVERRIDE;

    SdDrawDocument&         mrDoc;
    DrawDocShell*           mpDocSh;
    ViewShell*              mpViewSh;
    SdrMarkList*            mpDragSrcMarkList;
    SdrObject*              mpDropMarkerObj;
    SdrDropMarkerOverlay*   mpDropMarker;
    sal_uInt16                  mnDragSrcPgNum;
    Point                   maDropPos;
    ::std::vector<OUString> maDropFileVector;
    sal_Int8                mnAction;
    Idle                    maDropErrorIdle;
    Idle                    maDropInsertFileIdle;
    sal_uInt16                  mnLockRedrawSmph;
    boost::ptr_vector<SdViewRedrawRec> maLockedRedraws;
    bool                    mbIsDropAllowed;

                            DECL_LINK_TYPED( DropErrorHdl, Idle*, void );
                            DECL_LINK_TYPED( DropInsertFileHdl, Idle*, void );
                            DECL_LINK( ExecuteNavigatorDrop, SdNavigatorDropEvent* pSdNavigatorDropEvent );

    void ImplClearDrawDropMarker();

    SmartTagSet             maSmartTags;

private:
    ::std::unique_ptr<ViewClipboard> mpClipboard;
    OutlinerMasterViewFilter maMasterViewFilter;
};

SdDrawDocument& View::GetDoc() const
{
    return mrDoc;
}

} // end of namespace sd

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<commit_msg>Fix comment<commit_after>/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 .
 */

#ifndef INCLUDED_SD_SOURCE_UI_INC_VIEW_HXX
#define INCLUDED_SD_SOURCE_UI_INC_VIEW_HXX

#include <boost/ptr_container/ptr_vector.hpp>

#include "pres.hxx"
#include <tools/gen.hxx>
#include <svtools/transfer.hxx>
#include <svx/fmview.hxx>
#include <svx/svdmark.hxx>
#include <svx/svdpage.hxx>
#include <vcl/idle.hxx>
#include "fupoor.hxx"

#include "smarttag.hxx"
#include <editeng/numitem.hxx>

class SdDrawDocument;
class SdPage;
class SdrOle2Obj;
class SdrGrafObj;
class SdrMediaObj;
class OutputDevice;
class ImageMap;
class Point;
class Graphic;
class SdrOutliner;
class TransferableDataHelper;
struct StyleRequestData;
class Outliner;

namespace sd {

class DrawDocShell;
struct SdNavigatorDropEvent;
class ViewShell;
class Window;
class ViewClipboard;

// SdViewRedrawRec
struct SdViewRedrawRec
{
    VclPtr<OutputDevice> mpOut;
    Rectangle            aRect;
};

//For master view we want to force that master
//textboxes have readonly text, because the
//text is the auto-generated click-here-to-edit
//and it doesn't help to change it
class OutlinerMasterViewFilter
{
private:
    SdrOutliner *m_pOutl;
    bool m_bReadOnly;
public:
    OutlinerMasterViewFilter()
        : m_pOutl(0)
        , m_bReadOnly(false)
    {
    }
    void Start(SdrOutliner *pOutl);
    void End();
};

class View : public FmFormView
{
public:
    TYPEINFO_OVERRIDE();

    View (
        SdDrawDocument& rDrawDoc,
        OutputDevice* pOutDev,
        ViewShell* pViewSh=NULL);
    virtual ~View();

    void                    CompleteRedraw( OutputDevice* pOutDev, const vcl::Region& rReg, sdr::contact::ViewObjectContactRedirector* pRedirector = 0L) SAL_OVERRIDE;

    virtual bool            GetAttributes( SfxItemSet& rTargetSet, bool bOnlyHardAttr = false ) const;
    virtual bool            SetAttributes(const SfxItemSet& rSet, bool bReplaceAll = false);
    virtual void            MarkListHasChanged() SAL_OVERRIDE;
    virtual void            ModelHasChanged() SAL_OVERRIDE;
    void                    SelectAll();
    void                    DoCut(vcl::Window* pWindow=NULL);
    void                    DoCopy(vcl::Window* pWindow=NULL);
    void                    DoPaste(vcl::Window* pWindow=NULL);
    virtual void            DoConnect(SdrOle2Obj* pOleObj) SAL_OVERRIDE;
    virtual bool            SetStyleSheet(SfxStyleSheet* pStyleSheet, bool bDontRemoveHardAttr = false);
    void                    StartDrag( const Point& rStartPos, vcl::Window* pWindow );
    virtual void            DragFinished( sal_Int8 nDropAction );
    virtual sal_Int8 AcceptDrop (
        const AcceptDropEvent& rEvt,
        DropTargetHelper& rTargetHelper,
        ::sd::Window* pTargetWindow = NULL,
        sal_uInt16 nPage = SDRPAGE_NOTFOUND,
        sal_uInt16 nLayer = SDRPAGE_NOTFOUND);
    virtual sal_Int8 ExecuteDrop (
        const ExecuteDropEvent& rEvt,
        DropTargetHelper& rTargetHelper,
        ::sd::Window* pTargetWindow = NULL,
        sal_uInt16 nPage = SDRPAGE_NOTFOUND,
        sal_uInt16 nLayer = SDRPAGE_NOTFOUND);

    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateClipboardDataObject (::sd::View*, vcl::Window& rWindow);
    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateDragDataObject (::sd::View*, vcl::Window& rWindow,
            const Point& rDragPos);
    ::com::sun::star::uno::Reference<
        ::com::sun::star::datatransfer::XTransferable>
        CreateSelectionDataObject (::sd::View*, vcl::Window& rWindow);

    void                    UpdateSelectionClipboard( bool bForceDeselect );

    inline DrawDocShell* GetDocSh() const { return mpDocSh; }
    inline SdDrawDocument& GetDoc() const;
    inline ViewShell* GetViewShell() const { return mpViewSh; }

    virtual bool SdrBeginTextEdit(SdrObject* pObj, SdrPageView* pPV = 0L, vcl::Window* pWin = 0L, bool bIsNewObj = false,
        SdrOutliner* pGivenOutliner = 0L, OutlinerView* pGivenOutlinerView = 0L,
        bool bDontDeleteOutliner = false, bool bOnlyOneView = false, bool bGrabFocus = true) SAL_OVERRIDE;

    virtual SdrEndTextEditKind SdrEndTextEdit(bool bDontDeleteReally = false) SAL_OVERRIDE;

    bool RestoreDefaultText( SdrTextObj* pTextObj );

    bool                    InsertData( const TransferableDataHelper& rDataHelper,
                                        const Point& rPos, sal_Int8& rDnDAction, bool bDrag,
                                        SotClipboardFormatId nFormat = SotClipboardFormatId::NONE,
                                        sal_uInt16 nPage = SDRPAGE_NOTFOUND, sal_uInt16 nLayer = SDRLAYER_NOTFOUND );
    /** gets the metafile from the given transferable helper and insert it as a graphic shape.
        @param bOptimize if set to true, the metafile is analyzed and if only one bitmap action is
                         present, then is inserted as a single graphic.
    */
    bool                    InsertMetaFile( TransferableDataHelper& rDataHelper,
                                            const Point& rInsertPos,
                                            ImageMap* pImageMap, bool bOptimize );

    SdrGrafObj*             InsertGraphic( const Graphic& rGraphic,
                                           sal_Int8& rAction, const Point& rPos,
                                           SdrObject* pSelectedObj, ImageMap* pImageMap );
    SdrMediaObj*            InsertMediaURL( const OUString& rMediaURL, sal_Int8& rAction,
                                            const Point& rPos, const Size& rSize,
                                            bool const bLink );

    SdrMediaObj*            Insert3DModelURL( const OUString& rModelURL, sal_Int8& rAction,
                                              const Point& rPos, const Size& rSize,
                                              bool const bLink );

    SdrMediaObj*            InsertMediaObj( const OUString& rURL, const OUString& rMimeType, sal_Int8& rAction,
                                            const Point& rPos, const Size& rSize );

    bool PasteRTFTable( ::tools::SvRef<SotStorageStream> xStm, SdrPage* pPage, SdrInsertFlags nPasteOptions );

    bool                    IsPresObjSelected(bool bOnPage = true, bool bOnMasterPage = true, bool bCheckPresObjListOnly = false, bool bCheckLayoutOnly = false) const;

    void                    SetMarkedOriginalSize();

    bool                    IsMorphingAllowed() const;
    bool                    IsVectorizeAllowed() const;

    virtual SfxStyleSheet*  GetStyleSheet() const;

    /** return parameter:
        pExchangeList == NULL -> all names are unique
        bNameOK == false -> cancel by user
        nType == 0 -> pages
        nType == 1 -> objects
        nType == 2 -> pages and objects    */

    bool GetExchangeList( std::vector<OUString> &rExchangeList,
                          std::vector<OUString> &rBookmarkList,
                          const sal_uInt16 nType );

    virtual void onAccessibilityOptionsChanged() SAL_OVERRIDE;

    virtual SdrModel*   GetMarkedObjModel() const SAL_OVERRIDE;
    virtual bool Paste(
        const SdrModel& rMod, const Point& rPos, SdrObjList* pLst, SdrInsertFlags nOptions,
        const OUString& rSrcShellID, const OUString& rDestShellID ) SAL_OVERRIDE;

    using SdrExchangeView::Paste;

    /** returns true if we have an undo manager and there is an open list undo action */
    bool isRecordingUndo() const;

    virtual void AddCustomHdl() SAL_OVERRIDE;

    SmartTagSet& getSmartTags() { return maSmartTags; }
    void selectSmartTag( const SmartTagReference& xTag );
    void updateHandles();

    virtual SdrViewContext GetContext() const SAL_OVERRIDE;
    virtual bool HasMarkablePoints() const SAL_OVERRIDE;
    virtual sal_uLong GetMarkablePointCount() const SAL_OVERRIDE;
    virtual bool HasMarkedPoints() const SAL_OVERRIDE;
    virtual sal_uLong GetMarkedPointCount() const SAL_OVERRIDE;
    virtual bool IsPointMarkable(const SdrHdl& rHdl) const SAL_OVERRIDE;
    virtual bool MarkPoint(SdrHdl& rHdl, bool bUnmark=false) SAL_OVERRIDE;
    virtual void CheckPossibilities() SAL_OVERRIDE;
    virtual bool MarkPoints(const ::Rectangle* pRect, bool bUnmark) SAL_OVERRIDE;
    using SdrMarkView::MarkPoints;

    bool ShouldToggleOn(
        const bool bBulletOnOffMode,
        const bool bNormalBullet);

    /** change the bullets/numbering of the marked objects

        @param bToggle
        true: just toggle the current bullets/numbering on --> off resp. off --> on

        @param bHandleBullets
        true: handle bullets
        false: handle numbering

        @param pNumRule
        numbering rule which needs to be applied. can be 0.
    */
    void ChangeMarkedObjectsBulletsNumbering(
        const bool bToggle,
        const bool bHandleBullets,
        const SvxNumRule* pNumRule);

    void SetPossibilitiesDirty() { bPossibilitiesDirty = true; }
    void SetMoveAllowed( bool bSet ) { bMoveAllowed = bSet; }
    void SetMoveProtected( bool bSet ) { bMoveProtect = bSet; }
    void SetResizeFreeAllowed( bool bSet ) { bResizeFreeAllowed = bSet; }
    void SetResizePropAllowed( bool bSet ) { bResizePropAllowed = bSet; }
    void SetResizeProtected( bool bSet ) { bResizeProtect = bSet; }

    void SetMarkedPointsSmoothPossible( bool bSet ) { bSetMarkedPointsSmoothPossible = bSet; }
    void SetMarkedSegmentsKindPossible( bool bSet ) { bSetMarkedSegmentsKindPossible = bSet; }

    SdrObject* GetEmptyPresentationObject( PresObjKind eKind );
    SdPage* GetPage();
    SdrObject* GetSelectedSingleObject(SdPage* pPage);

protected:
    DECL_LINK( OnParagraphInsertedHdl, ::Outliner * );
    DECL_LINK( OnParagraphRemovingHdl, ::Outliner * );

    virtual void OnBeginPasteOrDrop( PasteOrDropInfos* pInfos ) SAL_OVERRIDE;
    virtual void OnEndPasteOrDrop( PasteOrDropInfos* pInfos ) SAL_OVERRIDE;

    SdDrawDocument&         mrDoc;
    DrawDocShell*           mpDocSh;
    ViewShell*              mpViewSh;
    SdrMarkList*            mpDragSrcMarkList;
    SdrObject*              mpDropMarkerObj;
    SdrDropMarkerOverlay*   mpDropMarker;
    sal_uInt16                  mnDragSrcPgNum;
    Point                   maDropPos;
    ::std::vector<OUString> maDropFileVector;
    sal_Int8                mnAction;
    Idle                    maDropErrorIdle;
    Idle                    maDropInsertFileIdle;
    sal_uInt16                  mnLockRedrawSmph;
    boost::ptr_vector<SdViewRedrawRec> maLockedRedraws;
    bool                    mbIsDropAllowed;

                            DECL_LINK_TYPED( DropErrorHdl, Idle*, void );
                            DECL_LINK_TYPED( DropInsertFileHdl, Idle*, void );
                            DECL_LINK( ExecuteNavigatorDrop, SdNavigatorDropEvent* pSdNavigatorDropEvent );

    void ImplClearDrawDropMarker();

    SmartTagSet             maSmartTags;

private:
    ::std::unique_ptr<ViewClipboard> mpClipboard;
    OutlinerMasterViewFilter maMasterViewFilter;
};

SdDrawDocument& View::GetDoc() const
{
    return mrDoc;
}

} // end of namespace sd

#endif

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
<|endoftext|>