/* -*- 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 .
*/
// The OverlayObjects are cleared using the destructor of OverlayObjectList. // That destructor calls clear() at the list which removes all objects from the // OverlayManager and deletes them.
void ImpSdrCreateViewExtraData::HideOverlay()
{ // the clear() call of the list removes all objects from the // OverlayManager and deletes them.
maObjects.clear();
}
bool SdrCreateView::CheckEdgeMode()
{ if (mpCurrentCreate != nullptr)
{ // is managed by EdgeObj if (mnCurrentInvent==SdrInventor::Default && mnCurrentIdent==SdrObjKind::Edge) returnfalse;
}
if (!IsCreateMode() || mnCurrentInvent!=SdrInventor::Default || mnCurrentIdent!=SdrObjKind::Edge)
{
ImpClearConnectMarker(); returnfalse;
} else
{ // sal_True, if MouseMove should check Connect return !IsAction();
}
}
if(pObj)
{ // Using text tool, mouse cursor is usually I-Beam, // crosshairs with tiny I-Beam appears only on MouseButtonDown. if(IsTextTool())
{ // Here the correct pointer needs to be used // if the default is set to vertical writing
maCurrentCreatePointer = PointerStyle::Text;
} else
maCurrentCreatePointer = pObj->GetCreatePointer();
} else
{
maCurrentCreatePointer = PointerStyle::Cross;
}
}
Point aPnt(rPnt); if (mnCurrentInvent != SdrInventor::Default || (mnCurrentIdent != SdrObjKind::Edge &&
mnCurrentIdent != SdrObjKind::FreehandLine &&
mnCurrentIdent != SdrObjKind::FreehandFill )) { // no snapping for Edge and Freehand
aPnt=GetSnapPos(aPnt, mpCreatePV);
} if (mpCurrentCreate!=nullptr)
{ if (mpDefaultStyleSheet!=nullptr) mpCurrentCreate->NbcSetStyleSheet(mpDefaultStyleSheet, false);
// SW uses a naked SdrObject for frame construction. Normally, such an // object should not be created. Since it is possible to use it as a helper // object (e.g. in letting the user define an area with the interactive // construction) at least no items should be set at that object. if(nInvent != SdrInventor::Default || nIdent != SdrObjKind::NewFrame)
{
mpCurrentCreate->SetMergedItemSet(maDefaultAttr);
}
if (dynamic_cast<const SdrCaptionObj *>(mpCurrentCreate.get()) != nullptr)
{
SfxItemSet aSet(GetModel().GetItemPool());
aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
mpCurrentCreate->SetMergedItemSet(aSet);
} if (nInvent == SdrInventor::Default && (nIdent==SdrObjKind::Text || nIdent==SdrObjKind::TitleText || nIdent==SdrObjKind::OutlineText))
{ // default for all text frames: no background, no border
SfxItemSet aSet(GetModel().GetItemPool());
aSet.Put(XFillColorItem(OUString(),COL_WHITE)); // in case someone turns on Solid
aSet.Put(XFillStyleItem(drawing::FillStyle_NONE));
aSet.Put(XLineColorItem(OUString(),COL_BLACK)); // in case someone turns on Solid
aSet.Put(XLineStyleItem(drawing::LineStyle_NONE));
mpCurrentCreate->SetMergedItemSet(aSet);
} if (!rLogRect.IsEmpty()) mpCurrentCreate->NbcSetLogicRect(rLogRect);
// make sure drag start point is inside WorkArea const tools::Rectangle& rWorkArea = GetWorkArea();
void SdrCreateView::MovCreateObj(const Point& rPnt)
{ if (mpCurrentCreate==nullptr) return;
Point aPnt(rPnt); if (!maDragStat.IsNoSnap())
{
aPnt=GetSnapPos(aPnt, mpCreatePV);
} if (IsOrtho())
{ if (maDragStat.IsOrtho8Possible()) OrthoDistance8(maDragStat.GetPrev(),aPnt,IsBigOrtho()); elseif (maDragStat.IsOrtho4Possible()) OrthoDistance4(maDragStat.GetPrev(),aPnt,IsBigOrtho());
}
// If the drag point was limited and Ortho is active, do // the small ortho correction (reduction) -> last parameter to FALSE. bool bDidLimit(ImpLimitToWorkArea(aPnt)); if(bDidLimit && IsOrtho())
{ if(maDragStat.IsOrtho8Possible())
OrthoDistance8(maDragStat.GetPrev(), aPnt, false); elseif(maDragStat.IsOrtho4Possible())
OrthoDistance4(maDragStat.GetPrev(), aPnt, false);
}
if (aPnt==maDragStat.GetNow()) return; bool bIsMinMoved(maDragStat.IsMinMoved()); if (!maDragStat.CheckMinMoved(aPnt)) return;
if (!bIsMinMoved) maDragStat.NextPoint();
maDragStat.NextMove(aPnt);
mpCurrentCreate->MovCreate(maDragStat);
// MovCreate changes the object, so use ActionChanged() on it
mpCurrentCreate->ActionChanged();
// replace for DrawCreateObjDiff
HideCreateObj();
ShowCreateObj();
}
if (mpCurrentCreate!=nullptr)
{
sal_uInt32 nCount=maDragStat.GetPointCount();
if (nCount<=1 && eCmd==SdrCreateCmd::ForceEnd)
{
BrkCreateObj(); // objects with only a single point don't exist (at least today) returnfalse; // sal_False = event not interpreted
}
bool bPntsEq=nCount>1;
sal_uInt32 i=1;
Point aP0=maDragStat.GetPoint(0); while (bPntsEq && i<nCount) { bPntsEq=aP0==maDragStat.GetPoint(i); i++; }
if (mpCurrentCreate->EndCreate(maDragStat,eCmd))
{
HideCreateObj();
if (!bPntsEq)
{ // otherwise Brk, because all points are equal
rtl::Reference<SdrObject> pObj = std::move(mpCurrentCreate);
if(!bSceneIntoScene)
{ // Here an interactively created SdrObject gets added, so // take into account that interaction created an object in // model coordinates. If we have e.g. a GirdOffset, this is a // little bit tricky - we have an object in model coordinates, // so the fetched offset is at the wrong point in principle // since we need to 'substract' the offset here to get to // 'real' model coordinates. But we have nothing better here, // so go for it. // The 2nd a little tricky thing is that this will early-create // a ViewObjectContact for the new SdrObject, but these VOCs // are anyways layouted for being create-on-demand. This will // be adapted/replaced correctly later on. // This *should* be the right place for getting all interactively // created objects, see InsertObjectAtView below that calls // CreateUndoNewObject.
basegfx::B2DVector aGridOffset(0.0, 0.0); if(getPossibleGridOffsetForSdrObject(aGridOffset, pObj.get(), mpCreatePV))
{ const Size aOffset(
basegfx::fround<tools::Long>(-aGridOffset.getX()),
basegfx::fround<tools::Long>(-aGridOffset.getY()));
pObj->NbcMove(aOffset);
}
// do the same as before
InsertObjectAtView(pObj.get(), *mpCreatePV);
}
mpCreatePV = nullptr;
bRet=true; // sal_True = event interpreted
} else
{
BrkCreateObj();
}
} else
{ // more points if (eCmd==SdrCreateCmd::ForceEnd || // nothing there -- force ending
nCount==0 || // no existing points (should never happen)
(nCount<=1 && !maDragStat.IsMinMoved())) { // MinMove not met
BrkCreateObj();
} else
{ // replace for DrawCreateObjDiff
HideCreateObj();
ShowCreateObj();
maDragStat.ResetMinMoved(); // NextPoint is at MovCreateObj()
bRet=true;
}
}
} return bRet;
}
void SdrCreateView::BckCreateObj()
{ if (mpCurrentCreate==nullptr) return;
if (mpCurrentCreate)
{ // for migration from XOR, replace DrawDragObj here to create // overlay objects instead. bool bUseSolidDragging(IsSolidDragging());
// #i101648# check if dragged object is a SdrObjKind::NewFrame. // This is e.g. used in SW Frame construction as placeholder. // Do not use SolidDragging for SdrObjKind::NewFrame kind of objects, // they cannot have a valid optical representation. if (bUseSolidDragging && SdrObjKind::NewFrame == mpCurrentCreate->GetObjIdentifier())
{
bUseSolidDragging = false;
}
// check for objects with no fill and no line if(bUseSolidDragging)
{ const SfxItemSet& rSet = mpCurrentCreate->GetMergedItemSet(); const drawing::FillStyle eFill(rSet.Get(XATTR_FILLSTYLE).GetValue()); const drawing::LineStyle eLine(rSet.Get(XATTR_LINESTYLE).GetValue());
// check for form controls if(bUseSolidDragging)
{ if (dynamic_cast<const SdrUnoObj*>(mpCurrentCreate.get()) != nullptr)
{
bUseSolidDragging = false;
}
}
// #i101781# force to non-solid dragging when not creating a full circle if(bUseSolidDragging)
{
SdrCircObj* pCircObj = dynamic_cast<SdrCircObj*>(mpCurrentCreate.get());
if (dynamic_cast<const SdrRectObj*>(mpCurrentCreate.get()) != nullptr)
{ // ensure object has some size, necessary for SdrTextObj because // there are still untested divisions by that sizes
tools::Rectangle aCurrentSnapRect(mpCurrentCreate->GetSnapRect());
if (auto pPathObj = dynamic_cast<SdrPathObj*>(mpCurrentCreate.get()))
{ // The up-to-now created path needs to be set at the object to have something // that can be visualized const basegfx::B2DPolyPolygon aCurrentPolyPolygon(pPathObj->getObjectPolyPolygon(maDragStat));
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.