1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ 2 /* 3 * This file is part of the LibreOffice project. 4 * 5 * This Source Code Form is subject to the terms of the Mozilla Public 6 * License, v. 2.0. If a copy of the MPL was not distributed with this 7 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 8 * 9 * This file incorporates work covered by the following license notice: 10 * 11 * Licensed to the Apache Software Foundation (ASF) under one or more 12 * contributor license agreements. See the NOTICE file distributed 13 * with this work for additional information regarding copyright 14 * ownership. The ASF licenses this file to you under the Apache 15 * License, Version 2.0 (the "License"); you may not use this file 16 * except in compliance with the License. You may obtain a copy of 17 * the License at http://www.apache.org/licenses/LICENSE-2.0 . 18 */ 19 #ifndef INCLUDED_SW_SOURCE_CORE_INC_TOCNTNTANCHOREDOBJECTPOSITION_HXX 20 #define INCLUDED_SW_SOURCE_CORE_INC_TOCNTNTANCHOREDOBJECTPOSITION_HXX 21 #include "anchoredobjectposition.hxx" 22 23 class SwFrame; 24 class SwTextFrame; 25 class SwLayoutFrame; 26 class SwRect; 27 28 namespace objectpositioning 29 { 30 class SwToContentAnchoredObjectPosition : public SwAnchoredObjectPosition 31 { 32 private: 33 // calculated data for object position 34 const SwLayoutFrame* mpVertPosOrientFrame; 35 // #i26791# 36 // determine offset to frame anchor position according to the 37 // positioning alignments 38 Point maOffsetToFrameAnchorPos; 39 40 // data for calculation of position 41 bool mbAnchorToChar; 42 const SwFrame* mpToCharOrientFrame; 43 const SwRect* mpToCharRect; 44 SwTwips mnToCharTopOfLine; 45 46 virtual bool IsAnchoredToChar() const override; 47 virtual const SwFrame* ToCharOrientFrame() const override; 48 virtual const SwRect* ToCharRect() const override; 49 // #i22341# 50 virtual SwTwips ToCharTopOfLine() const override; 51 52 // method to cast <SwAnchoredObjectPosition::GetAnchorFrame()> to 53 // the needed type 54 SwTextFrame& GetAnchorTextFrame() const; 55 56 /** determine frame for horizontal position 57 58 if the given proposed frame is a content frame, the proposed 59 frame is returned. 60 otherwise (given proposed frame is a layout frame), 61 the lower content frames of the proposed frame are checked 62 for the first, that the anchor or a follow of the anchor. 63 If none is found, the proposed frame is returned. 64 65 @param _pProposedFrame 66 input parameter - proposed frame for horizontal position 67 68 @return constant reference to <SwFrame> object, at which the 69 horizontal position is determined. 70 */ 71 const SwFrame& GetHoriVirtualAnchor( const SwLayoutFrame& _pProposedFrame ) const; 72 73 public: 74 SwToContentAnchoredObjectPosition( SdrObject& _rDrawObj ); 75 virtual ~SwToContentAnchoredObjectPosition() override; 76 77 /** calculate position of object 78 */ 79 virtual void CalcPosition() override; 80 81 /** frame, at which the vertical position is oriented at 82 */ GetVertPosOrientFrame() const83 const SwLayoutFrame& GetVertPosOrientFrame() const { return *mpVertPosOrientFrame;} 84 85 /// In case overlap is not allowed, re-position the current object. 86 void CalcOverlap(const SwTextFrame* pAnchorFrameForVertPos, Point& rRelPos, 87 const SwTwips nTopOfAnch); 88 }; 89 } // namespace objectpositioning 90 91 #endif 92 93 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ 94