Files
libreoffice/sw/source/core/inc/anchoredobjectposition.hxx

415 lines
17 KiB
C++
Raw Normal View History

/*************************************************************************
*
* $RCSfile: anchoredobjectposition.hxx,v $
*
2004-03-11 12:05:04 +00:00
* $Revision: 1.3 $
*
2004-03-11 12:05:04 +00:00
* last change: $Author: od $ $Date: 2004-03-11 13:05:04 $
*
* 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 _ANCHOREDOBJECTPOSITION_HXX
#define _ANCHOREDOBJECTPOSITION_HXX
#ifndef _SWTYPES_HXX
#include <swtypes.hxx>
#endif
#ifndef _ORNTENUM_HXX
#include <orntenum.hxx>
#endif
class SdrObject;
class SwFrm;
class SwFlyFrm;
2004-03-11 12:05:04 +00:00
class SwContact;
class SwFrmFmt;
2004-03-11 12:05:04 +00:00
class SwRect;
class SvxLRSpaceItem;
class SvxULSpaceItem;
2004-03-11 12:05:04 +00:00
class SwFmtHoriOrient;
namespace objectpositioning
{
2004-03-11 12:05:04 +00:00
class SwEnvironmentOfAnchoredObject;
class SwAnchoredObjectPosition
{
private:
// object to be positioned
SdrObject& mrDrawObj;
2004-03-11 12:05:04 +00:00
// information about object
// does the object represents a Writer fly frame
bool mbIsObjFly;
// frame the object belongs to; NULL, if !<mbObjIsFly>
2004-03-11 12:05:04 +00:00
SwFrm* mpFrmOfObj;
// frame the object is anchored at
2004-03-11 12:05:04 +00:00
SwFrm* mpAnchorFrm;
// contact object
SwContact* mpContact;
2004-03-11 12:05:04 +00:00
// frame format
const SwFrmFmt* mpFrmFmt;
/** determine information about object
OD 30.07.2003 #110978#
2004-03-11 12:05:04 +00:00
member <mbIsObjFly>, <mpFrmOfObj>, <mpAnchorFrm>, <mpContact>
and <mpFrmFmt> are set
@author OD
*/
void _GetInfoAboutObj();
2004-03-11 12:05:04 +00:00
protected:
SwAnchoredObjectPosition( SdrObject& _rDrawObj );
~SwAnchoredObjectPosition();
2004-03-11 12:05:04 +00:00
// accessors for object and its corresponding data/information
SdrObject& GetObject() const;
bool IsObjFly() const;
SwFrm* GetFrmOfObj() const;
SwFrm& GetAnchorFrm() const;
SwContact& GetContact() const;
const SwFrmFmt& GetFrmFmt() const;
2004-03-11 12:05:04 +00:00
// virtual methods providing data for to character anchored objects.
virtual bool IsAnchoredToChar() const;
virtual const SwFrm* ToCharOrientFrm() const;
virtual const SwRect* ToCharRect() const;
// OD 12.11.2003 #i22341#
virtual SwTwips ToCharTopOfLine() const;
// *********************************************************************
2004-03-11 12:05:04 +00:00
void _GetVertAlignmentValues( const SwFrm& _rVertOrientFrm,
const SwFrm& _rPageAlignLayFrm,
const SwRelationOrient _eRelOrient,
SwTwips& _orAlignAreaHeight,
SwTwips& _orAlignAreaOffset ) const;
// *********************************************************************
2004-03-11 12:05:04 +00:00
SwTwips _GetVertRelPos( const SwFrm& _rVertOrientFrm,
const SwFrm& _rPageAlignLayFrm,
const SwVertOrient _eVertOrient,
const SwRelationOrient _eRelOrient,
const SwTwips _nVertPos,
const SvxLRSpaceItem& _rLRSpacing,
const SvxULSpaceItem& _rULSpacing ) const;
// *********************************************************************
/** adjust calculated vertical in order to keep object inside
'page' alignment layout frame.
2004-03-11 12:05:04 +00:00
@param _rPageAlignLayFrm
input paramter - layout frame, which determines the 'page area'
the object has to be vertical positioned in.
2004-03-11 12:05:04 +00:00
@param _nProposedRelPosY
input parameter - proposed relative vertical position, which
will be adjusted.
@author OD
*/
2004-03-11 12:05:04 +00:00
SwTwips _AdjustVertRelPos( const SwFrm& _rPageAlignLayFrm,
const SwTwips _nProposedRelPosY ) const;
// *********************************************************************
2004-03-11 12:05:04 +00:00
/** calculate relative horizontal position
@author OD
@param _rHoriOrientFrm
input parameter - frame the horizontal position of the object
is oriented at.
2004-03-11 12:05:04 +00:00
@param _rEnvOfObj
input parameter - object instance to retrieve environment
information about the object
@param _rHoriOrient
input parameter - horizontal positioning and alignment, for which
the relative position is calculated.
@param _rLRSpacing
input parameter - left and right spacing of the object to the text
@param _rULSpacing
input parameter - upper and lower spacing of the object to the text
@param _bObjWrapThrough
input parameter - boolean indicating, if object has wrap mode
'wrap through'.
@param _nRelPosY
input parameter - relative vertical position
@return relative horizontal position in SwTwips
*/
SwTwips _CalcRelPosX( const SwFrm& _rHoriOrientFrm,
2004-03-11 12:05:04 +00:00
const SwEnvironmentOfAnchoredObject& _rEnvOfObj,
const SwFmtHoriOrient& _rHoriOrient,
const SvxLRSpaceItem& _rLRSpacing,
const SvxULSpaceItem& _rULSpacing,
const bool _bObjWrapThrough,
const SwTwips _nRelPosY
) const;
// *********************************************************************
2004-03-11 12:05:04 +00:00
/** adjust calculated horizontal in order to keep object inside
'page' alignment layout frame for object type position TO_CNTNT
@author OD
2004-03-11 12:05:04 +00:00
@param _rPageAlignLayFrm
input paramter - layout frame, which determines the 'page area'
the object has to be horizontal positioned in.
@param _nProposedRelPosX
input parameter - proposed relative horizontal position, which
will be adjusted.
2004-03-11 12:05:04 +00:00
@return adjusted relative horizontal position in SwTwips.
*/
2004-03-11 12:05:04 +00:00
SwTwips _AdjustHoriRelPos( const SwFrm& _rPageAlignLayFrm,
const SwTwips _nProposedRelPosX ) const;
// *********************************************************************
2004-03-11 12:05:04 +00:00
/** toggle given horizontal orientation and relative alignment
@author OD
@param _bToggleLeftRight
input parameter - boolean indicating, if horizontal orientation
and relative alignment has to be toggled.
@param _ioeHoriOrient
input/output parameter - horizontal orientation, that is toggled,
if needed.
@param _iopeRelOrient
optional input/output parameter (default value NULL)
- if set, relative alignment, that is toggled, if needed.
*/
void _ToggleHoriOrientAndAlign( const bool _bToggleLeftRight,
SwHoriOrient& _ioeHoriOrient,
SwRelationOrient& _iopeRelOrient
) const;
2004-03-11 12:05:04 +00:00
// *********************************************************************
/** determine alignment values for horizontal position of object
@author OD
@param _rHoriOrientFrm
input parameter - frame the horizontal position of the object
is oriented at.
@param _rPageAlignLayFrm
input paramter - layout frame, which determines the 'page area'
the object has to be horizontal positioned in.
@param _eRelOrient
input parameter - horizontal relative alignment, for which
the relative position is calculated.
@param _bToggleLeftRight
input parameter - boolean indicating, if left/right alignments
have to be toggled.
@param _bObjWrapThrough
input parameter - boolean indicating, if object has wrap mode
'wrap through'.
important note: value is only relevant, if _rHoriOrientFrm is
a text frame.
@param _orAlignAreaWidth
output parameter - width in SwTwips of the area the horizontal
position is aligned to.
@param _orAlignAreaOffset
output parameter - offset in SwTwips of the area the horizontal
position is aligned to. offset is given to the 'left' of the
anchor position.
@param _obAlignedRelToPage
output parameter - boolean indicating, that object is aligned
to 'page area'.
*/
void _GetHoriAlignmentValues( const SwFrm& _rHoriOrientFrm,
const SwFrm& _rPageAlignLayFrm,
const SwRelationOrient _eRelOrient,
const bool _bObjWrapThrough,
SwTwips& _orAlignAreaWidth,
SwTwips& _orAlignAreaOffset,
bool& _obAlignedRelToPage ) const;
// *********************************************************************
/** adjust calculated horizontal position in order to draw object
aside other objects with same positioning
@author OD
@param _rHoriOrientFrm
input parameter - frame the horizontal position of the object
is oriented at.
@param _nProposedRelPosX
input parameter - proposed relative horizontal position, which
will be adjusted.
@param _nRelPosY
input parameter - relative vertical position
@param _eHoriOrient
input parameter - horizontal position of object
@param _eRelOrient
inpt parameter - alignment of object
@param _rLRSpacing
input parameter - left and right spacing of the object to the text
@param _rULSpacing
input parameter - upper and lower spacing of the object to the text
@param _bEvenPage
input parameter - boolean indicating, if object is on an even page.
@return adjusted relative horizontal position in SwTwips
*/
SwTwips _AdjustHoriRelPosForDrawAside( const SwFrm& _rHoriOrientFrm,
const SwTwips _nProposedRelPosX,
const SwTwips _nRelPosY,
const SwHoriOrient _eHoriOrient,
const SwRelationOrient _eRelOrient,
const SvxLRSpaceItem& _rLRSpacing,
const SvxULSpaceItem& _rULSpacing,
const bool _bEvenPage
) const;
// *********************************************************************
/** detemine, if object has to draw aside given fly frame
method used by <_AdjustHoriRelPosForDrawAside(..)>
@author OD
@param _pFly
input parameter - fly frame the draw aside check is done for.
@param _rObjRect
input parameter - proposed object rectangle
@param _pObjContext
input parameter - context of the object
@param _nObjIndex
input parameter - index of the anchor frame of the object
@param _bEvenPage
input parameter - boolean indicating, if object is on an even page.
@param _eHoriOrient
input parameter - horizontal position of object
@param _eRelOrient
inpt parameter - alignment of object
@return boolean indicating, if object has to be drawn aside
given fly frame.
*/
bool _DrawAsideFly( const SwFlyFrm* _pFly,
const SwRect& _rObjRect,
const SwFrm* _pObjContext,
const ULONG _nObjIndex,
const bool _bEvenPage,
const SwHoriOrient _eHoriOrient,
const SwRelationOrient _eRelOrient
) const;
// *********************************************************************
/** determine, if object has to draw aside another object
the different alignments of the objects determines, if one has
to draw aside another one. Thus, the given alignment are checked
against each other, which one has to be drawn aside the other one.
depending on parameter _bLeft check is done for left or right
positioning.
method used by <_DrawAsideFly(..)>
@author OD
@param _eRelOrient1
input parameter - alignment 1
@param _eRelOrient2
input parameter - alignment 2
@param _bLeft
input parameter - boolean indicating, if check is done for left
or for right positioning.
@return boolean indicating, if an object with an alignment
<_eRelOrient1> has to be drawn aside an object with an
alignment <_eRelOrient2>
*/
bool _Minor( SwRelationOrient _eRelOrient1,
SwRelationOrient _eRelOrient2,
bool _bLeft ) const;
public:
2004-03-11 12:05:04 +00:00
virtual void CalcPosition() = 0;
};
};
#endif