/* -*- 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 .
*/
namespace
{ /** * This mutex is only used for the paste listeners, where the solar mutex can't * be used.
*/
osl::Mutex& GetPasteMutex()
{ static osl::Mutex aMutex; return aMutex;
}
}
SwNodeOffset nIdx(0); bool bInnerCntIsFly = false;
SwFlyFrameFormat* pFlyFormat = nullptr; switch( eType )
{ case SwLabelType::Object: case SwLabelType::Fly:
bInnerCntIsFly = pCnt->IsInFly(); if (bInnerCntIsFly)
{ // pass down index to the startnode for flys
nIdx = pCnt->FindFlyFrame()->
GetFormat()->GetContent().GetContentIdx()->GetIndex();
} break; case SwLabelType::Table: if( pCnt->IsInTab() )
{ // pass down index to the TableNode for tables
SwTabFrame* pTabFrame = pCnt->FindTabFrame(); const SwTable& rTable = *pTabFrame->GetTable();
nIdx = rTable.GetTabSortBoxes()[ 0 ]
->GetSttNd()->FindTableNode()->GetIndex();
SwFlyFrame* pFly = pTabFrame->FindFlyFrame(); if (pFly && pFly->IsFlySplitAllowed())
{ // This table is in a split fly, but we will insert a label, which means this is not // a floating table anymore, disable the "can split" bit, it'll be hidden on the UI // anyway.
SwFrameFormat* pFormat = pFly->GetFrameFormat();
SfxItemSetFixed<RES_FLY_SPLIT, RES_FLY_SPLIT> aSet(GetDoc()->GetAttrPool());
SwFormatFlySplit aSplit(false);
aSet.Put(aSplit); // SwUndoFormatAttr is created for us.
GetDoc()->SetFlyFrameAttr(*pFormat, aSet);
}
} break; case SwLabelType::Draw: if( Imp()->GetDrawView() )
{
SwDrawView *pDView = Imp()->GetDrawView(); const SdrMarkList& rMrkList = pDView->GetMarkedObjectList();
// copy marked drawing objects to // local list to perform the corresponding action for each object
std::vector<SdrObject*> aDrawObjs;
{ for ( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
{
SdrObject* pDrawObj = rMrkList.GetMark(i)->GetMarkedSdrObj(); if( pDrawObj )
aDrawObjs.push_back( pDrawObj );
}
} // loop on marked drawing objects while ( !aDrawObjs.empty() )
{
SdrObject* pDrawObj = aDrawObjs.back();
assert(pDrawObj); if ( dynamic_cast<const SwVirtFlyDrawObj*>( pDrawObj) == nullptr && dynamic_cast<const SwFlyDrawObj*>( pDrawObj) == nullptr )
{
SwFlyFrameFormat *pFormat =
GetDoc()->InsertDrawLabel( rText, rSeparator, rNumberSeparator, nId, rCharacterStyle, *pDrawObj ); if( !pFlyFormat )
pFlyFormat = pFormat;
}
aDrawObjs.pop_back();
}
} break; default:
OSL_ENSURE( false, "Cursor neither in table nor in fly." );
}
if (pFlyFormat)
{ const Point aPt(GetCursorDocPos()); if (SwFlyFrame* pFrame = pFlyFormat->GetFrame(&aPt))
SelectFlyFrame(*pFrame);
}
EndUndo();
EndAllActionAndCall();
CurrShell aCurr( this ); bool bRet = false;
StartAllAction(); if(IsTableMode())
{ // Sort table // check if Point/Mark of current Cursor are in one table
SwFrame *pFrame = GetCurrFrame( false );
OSL_ENSURE( pFrame->FindTabFrame(), "Cursor not in table." );
// search boxes via the layout
SwSelBoxes aBoxes;
GetTableSel(*this, aBoxes);
// The Cursor should be removed from the deletion area. // Always put them behind/on the table; via the // document position they will always be set to the old position while( !pFrame->IsCellFrame() )
pFrame = pFrame->GetUpper();
{ /* ParkCursor->ParkCursorTab */
ParkCursorInTab();
}
if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
{
bVertic = aRectFnSet.IsVert();
bVerticalL2R = aRectFnSet.IsVertL2R();
_bMirror = false; // no mirroring in vertical environment switch ( _eHoriRelOrient )
{ case text::RelOrientation::PAGE_RIGHT: case text::RelOrientation::FRAME_RIGHT: aPos.AdjustY(pFrame->getFramePrintArea().Height() );
[[fallthrough]]; case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustY(pFrame->getFramePrintArea().Top() ); break; default: break;
}
} elseif ( _bMirror )
{ switch ( _eHoriRelOrient )
{ case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
[[fallthrough]]; case text::RelOrientation::PAGE_RIGHT: case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break; default: aPos.AdjustX(pFrame->getFrameArea().Width() );
}
} elseif ( bRTL )
{ switch ( _eHoriRelOrient )
{ case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
[[fallthrough]]; case text::RelOrientation::PAGE_LEFT: case text::RelOrientation::FRAME_LEFT: aPos.AdjustX(pFrame->getFramePrintArea().Left() -
pFrame->getFrameArea().Width() ); break; default: break;
}
} else
{ switch ( _eHoriRelOrient )
{ case text::RelOrientation::PAGE_RIGHT: case text::RelOrientation::FRAME_RIGHT: aPos.AdjustX(pFrame->getFramePrintArea().Width() );
[[fallthrough]]; case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA: aPos.AdjustX(pFrame->getFramePrintArea().Left() ); break; default:break;
}
}
if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
{ switch ( _eVertRelOrient )
{ case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA:
{
aPos.AdjustX( -(pFrame->GetRightMargin()) );
} break;
}
} elseif ( aRectFnSet.IsVertL2R() )
{ switch ( _eVertRelOrient )
{ case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA:
{
aPos.AdjustX(pFrame->GetLeftMargin() );
} break;
}
} else
{ switch ( _eVertRelOrient )
{ case text::RelOrientation::PRINT_AREA: case text::RelOrientation::PAGE_PRINT_AREA:
{ if ( pFrame->IsPageFrame() )
{
aPos.setY( static_cast<const SwPageFrame*>(pFrame)->PrtWithoutHeaderAndFooter().Top() );
} else
{
aPos.AdjustY(pFrame->getFramePrintArea().Top() );
}
} break;
}
} if ( _opPercent )
*_opPercent = pFrame->getFramePrintArea().SSize();
} else
{ const SwFrame* pUpper = ( pFrame->IsPageFrame() || pFrame->IsFlyFrame() ) ?
pFrame : pFrame->GetUpper();
SwRectFnSet aRectFnSet(pUpper); if ( _opPercent )
{ // If the size is relative from page, then full size should be counted from the page frame. if (pFormatFrameSize && pFormatFrameSize->GetWidthPercentRelation() == text::RelOrientation::PAGE_FRAME)
_opPercent->setWidth(pPage->getFrameArea().Width()); else
_opPercent->setWidth(pUpper->getFramePrintArea().Width());
if (pFormatFrameSize && pFormatFrameSize->GetHeightPercentRelation() == text::RelOrientation::PAGE_FRAME) // If the size is relative from page, then full size should be counted from the page frame.
_opPercent->setHeight(pPage->getFrameArea().Height()); else
_opPercent->setHeight(pUpper->getFramePrintArea().Height());
}
bRTL = pFrame->IsRightToLeft(); if ( bRTL )
aPos = pFrame->getFrameArea().TopRight(); else
aPos = aRectFnSet.GetPos(pFrame->getFrameArea()); // #i17567# - allow negative positions // for fly frames anchor to paragraph/to character. if ((_nAnchorId == RndStdIds::FLY_AT_PARA) || (_nAnchorId == RndStdIds::FLY_AT_CHAR))
{ // The rectangle, the fly frame can be positioned in, is determined // horizontally by the frame area of the horizontal environment // and vertically by the printing area of the vertical environment, // if the object follows the text flow, or by the frame area of the // vertical environment, if the object doesn't follow the text flow. // new class <SwEnvironmentOfAnchoredObject>
objectpositioning::SwEnvironmentOfAnchoredObject aEnvOfObj(
_bFollowTextFlow ); const SwLayoutFrame& rHoriEnvironLayFrame =
aEnvOfObj.GetHoriEnvironmentLayoutFrame( *pFrame ); const SwLayoutFrame& rVertEnvironLayFrame =
aEnvOfObj.GetVertEnvironmentLayoutFrame( *pFrame ); const SwRect& aHoriEnvironRect( rHoriEnvironLayFrame.getFrameArea() );
SwRect aVertEnvironRect; if ( _bFollowTextFlow )
{
aVertEnvironRect = rVertEnvironLayFrame.getFramePrintArea();
aVertEnvironRect.Pos() += rVertEnvironLayFrame.getFrameArea().Pos(); // #i18732# - adjust vertical 'virtual' anchor position // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned // to page areas. if ( _eVertRelOrient == text::RelOrientation::PAGE_FRAME || _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{ if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
{
aPos.setX( aVertEnvironRect.Right() );
} elseif ( aRectFnSet.IsVertL2R() )
{
aPos.setX( aVertEnvironRect.Left() );
} else
{
aPos.setY( aVertEnvironRect.Top() );
}
}
} else
{
OSL_ENSURE( rVertEnvironLayFrame.IsPageFrame(), " - not following text flow, but vertical environment *not* page!" );
aVertEnvironRect = rVertEnvironLayFrame.getFrameArea(); // #i18732# - adjustment vertical 'virtual' anchor position // (<aPos.Y()> respectively <aPos.X()>), if object is vertical aligned // to page areas. if (_eVertRelOrient == text::RelOrientation::PAGE_FRAME
|| _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA
|| _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
{ if ( aRectFnSet.IsVert() && !aRectFnSet.IsVertL2R() )
{
aPos.setX( aVertEnvironRect.Right() ); if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setX(aPos.getX() - rVertEnvironLayFrame.GetRightMargin());
}
} elseif ( aRectFnSet.IsVertL2R() )
{
aPos.setX( aVertEnvironRect.Left() ); if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setX(aPos.getX() + rVertEnvironLayFrame.GetLeftMargin());
}
} else
{
aPos.setY( aVertEnvironRect.Top() ); if ( _eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA )
{
aPos.setY(aPos.getY() + rVertEnvironLayFrame.GetTopMargin()); // add height of page header const SwFrame* pTmpFrame = rVertEnvironLayFrame.Lower(); if ( pTmpFrame->IsHeaderFrame() )
{
aPos.setY(aPos.getY() + pTmpFrame->getFrameArea().Height());
}
} elseif (_eVertRelOrient == text::RelOrientation::PAGE_PRINT_AREA_BOTTOM)
{ if (rVertEnvironLayFrame.IsPageFrame())
{ auto& rPageFrame = static_cast<const SwPageFrame&>(rVertEnvironLayFrame);
aPos.setY(rPageFrame.PrtWithoutHeaderAndFooter().Bottom());
} else
{
aPos.AdjustY(rVertEnvironLayFrame.getFramePrintArea().Bottom());
}
}
}
}
}
// #i22341# - adjust vertical 'virtual' anchor position // (<aPos.Y()> respectively <aPos.X()>), if object is anchored to // character and vertical aligned at character or top of line // <pFrame>, which is the anchor frame or the proposed anchor frame, // doesn't have to be a text frame (e.g. edit a to-page anchored // fly frame). Thus, assure this. const SwTextFrame* pTextFrame = pFrame->DynCastTextFrame(); if ( pTextFrame &&
(_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
( _eVertRelOrient == text::RelOrientation::CHAR ||
_eVertRelOrient == text::RelOrientation::TEXT_LINE ) )
{
SwTwips nTop = 0; if ( _eVertRelOrient == text::RelOrientation::CHAR )
{
SwRect aChRect; if ( _pToCharContentPos )
{
pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos->GetContentAnchor() );
} else
{ // No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
}
nTop = aRectFnSet.GetBottom(aChRect);
} else
{ if ( _pToCharContentPos )
{
pTextFrame->GetTopOfLine( nTop, *_pToCharContentPos->GetContentAnchor() );
} else
{ // No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
pTextFrame->GetTopOfLine( nTop, aDefaultContentPos );
}
} if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
{
aPos.setX(nTop);
} else
{
aPos.setY(nTop);
}
}
// #i26945# - adjust horizontal 'virtual' anchor // position (<aPos.X()> respectively <aPos.Y()>), if object is // anchored to character and horizontal aligned at character. if ( pTextFrame &&
(_nAnchorId == RndStdIds::FLY_AT_CHAR) &&
_eHoriRelOrient == text::RelOrientation::CHAR )
{
SwTwips nLeft = 0;
SwRect aChRect; if ( _pToCharContentPos )
{
pTextFrame->GetAutoPos( aChRect, *_pToCharContentPos->GetContentAnchor() );
} else
{ // No content position provided. Thus, use a default one.
SwPosition aDefaultContentPos(*(pTextFrame->GetTextNodeFirst()));
pTextFrame->GetAutoPos( aChRect, aDefaultContentPos );
}
nLeft = aRectFnSet.GetLeft(aChRect); if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
{
aPos.setY(nLeft);
} else
{
aPos.setX(nLeft);
}
} if ( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
{
_orRect = SwRect( aVertEnvironRect.Left(),
aHoriEnvironRect.Top(),
aVertEnvironRect.Width(),
aHoriEnvironRect.Height() );
} else
{
_orRect = SwRect( aHoriEnvironRect.Left(),
aVertEnvironRect.Top(),
aHoriEnvironRect.Width(),
aVertEnvironRect.Height() );
}
} else
{ if( _opRef && pFly && pFly->IsFlyInContentFrame() )
*_opRef = static_cast<const SwFlyInContentFrame*>( pFly )->GetRefPoint();
_orRect = pUpper->getFrameArea(); if( !pUpper->IsBodyFrame() )
{
_orRect += pUpper->getFramePrintArea().Pos();
_orRect.SSize( pUpper->getFramePrintArea().SSize() ); if ( pUpper->IsCellFrame() )//MA_FLY_HEIGHT
{ const SwFrame* pTab = pUpper->FindTabFrame();
tools::Long nBottom = aRectFnSet.GetPrtBottom(*pTab->GetUpper());
aRectFnSet.SetBottom( _orRect, nBottom );
}
} // only use 90% of height for character bound
{ if( aRectFnSet.IsVert() || aRectFnSet.IsVertL2R() )
_orRect.Width( (_orRect.Width()*9)/10 ); else
_orRect.Height( (_orRect.Height()*9)/10 );
}
}
Size SwFEShell::GetGraphicDefaultSize() const
{
Size aRet;
SwFlyFrame *pFly = GetSelectedFlyFrame(); if ( pFly )
{ // #i32951# - due to issue #i28701# no format of a // newly inserted Writer fly frame or its anchor frame is performed // any more. Thus, it could be possible (e.g. on insert of a horizontal // line) that the anchor frame isn't formatted and its printing area // size is (0,0). If this is the case the printing area of the upper // of the anchor frame is taken. const SwFrame* pAnchorFrame = pFly->GetAnchorFrame();
aRet = pAnchorFrame->getFramePrintArea().SSize(); if ( aRet.IsEmpty() && pAnchorFrame->GetUpper() )
{
aRet = pAnchorFrame->GetUpper()->getFramePrintArea().SSize();
}
void SwFEShell::MoveObjectIfActive( svt::EmbeddedObjectRef&, const Point& )
{ // does not do anything, only avoids crash if the method is used for wrong shell
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.