/* -*- 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 .
*/
/// Checks to see if the request has a parameter of IsSticky:bool=true /// It means that the selected command/button will stay selected after use bool isSticky(const SfxRequest& rReq)
{ const SfxItemSet *pArgs = rReq.GetArgs (); if (pArgs)
{ const SfxBoolItem* pIsSticky = rReq.GetArg<SfxBoolItem>(FN_PARAM_4); if (pIsSticky && pIsSticky->GetValue()) returntrue;
}
// init text position when vertical caption object is created if( dynamic_cast< const SdrCaptionObj *>( pObj ) != nullptr && SID_DRAW_CAPTION_VERTICAL == nSlotId)
{ // draw text object, needs to be initialized when vertical text is used
SfxItemSet aSet(pObj->GetMergedItemSet());
// Correct the value of SDRATTR_TEXTDIRECTION to avoid SetItemSet // calling SetVerticalWriting() again since this item may not yet // be set at the object and thus may differ from vertical state of // the object.
aSet.Put(SvxWritingModeItem(css::text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION));
pObj->SetMergedItemSet(aSet);
}
bReturn = true;
} else
{ //Drag was too small to create object, so insert default object at click pos
Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel()));
sal_uInt32 nDefaultObjectSize(1500);
sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2));
aClickPos.AdjustX(nCenterOffset);
aClickPos.AdjustY(nCenterOffset);
switch (nSlotId)
{ case SID_LINE_ARROW_START: case SID_LINE_ARROW_END: case SID_LINE_ARROWS: case SID_LINE_ARROW_CIRCLE: case SID_LINE_CIRCLE_ARROW: case SID_LINE_ARROW_SQUARE: case SID_LINE_SQUARE_ARROW:
mpView->SetGlueVisible();
[[fallthrough]]; case SID_DRAW_LINE : case SID_DRAW_XLINE:
aObjKind = SdrObjKind::Line; break;
case SID_DRAW_MEASURELINE:
{
aObjKind = SdrObjKind::Measure;
} break;
case SID_DRAW_RECT : case SID_DRAW_RECT_NOFILL : case SID_DRAW_RECT_ROUND : case SID_DRAW_RECT_ROUND_NOFILL: case SID_DRAW_SQUARE : case SID_DRAW_SQUARE_NOFILL : case SID_DRAW_SQUARE_ROUND : case SID_DRAW_SQUARE_ROUND_NOFILL:
{
aObjKind = SdrObjKind::Rectangle;
} break;
case SID_DRAW_ELLIPSE : case SID_DRAW_ELLIPSE_NOFILL: case SID_DRAW_CIRCLE : case SID_DRAW_CIRCLE_NOFILL :
{
aObjKind = SdrObjKind::CircleOrEllipse;
} break;
case SID_DRAW_CAPTION: case SID_DRAW_CAPTION_VERTICAL:
{
aObjKind = SdrObjKind::Caption;
} break;
case SID_TOOL_CONNECTOR: case SID_CONNECTOR_ARROW_START: case SID_CONNECTOR_ARROW_END: case SID_CONNECTOR_ARROWS: case SID_CONNECTOR_CIRCLE_START: case SID_CONNECTOR_CIRCLE_END: case SID_CONNECTOR_CIRCLES: case SID_CONNECTOR_LINE: case SID_CONNECTOR_LINE_ARROW_START: case SID_CONNECTOR_LINE_ARROW_END: case SID_CONNECTOR_LINE_ARROWS: case SID_CONNECTOR_LINE_CIRCLE_START: case SID_CONNECTOR_LINE_CIRCLE_END: case SID_CONNECTOR_LINE_CIRCLES: case SID_CONNECTOR_CURVE: case SID_CONNECTOR_CURVE_ARROW_START: case SID_CONNECTOR_CURVE_ARROW_END: case SID_CONNECTOR_CURVE_ARROWS: case SID_CONNECTOR_CURVE_CIRCLE_START: case SID_CONNECTOR_CURVE_CIRCLE_END: case SID_CONNECTOR_CURVE_CIRCLES: case SID_CONNECTOR_LINES: case SID_CONNECTOR_LINES_ARROW_START: case SID_CONNECTOR_LINES_ARROW_END: case SID_CONNECTOR_LINES_ARROWS: case SID_CONNECTOR_LINES_CIRCLE_START: case SID_CONNECTOR_LINES_CIRCLE_END: case SID_CONNECTOR_LINES_CIRCLES:
{
aObjKind = SdrObjKind::Edge;
mpView->SetGlueVisible();
} break; case SID_INSERT_SIGNATURELINE:
{
aObjKind = SdrObjKind::Graphic;
} break;
// Update infobar to offer "finish signing".
SfxViewFrame* pFrame = mrViewShell.GetViewFrame(); if (pFrame && pFrame->HasInfoBarWithID(u"readonly"))
{
pFrame->RemoveInfoBar(u"readonly");
pFrame->AppendReadOnlyInfobar();
}
}
namespace { /// Returns the color based on the color names listed in core/include/tools/color.hxx /// Feel free to extend with more color names from color.hxx
Color strToColor(std::u16string_view sColor)
{
Color aColor = COL_AUTO;
// Support full with for vertical caption objects, too if(SID_DRAW_CAPTION == nSlotId)
rAttr.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) ); else
rAttr.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_BLOCK ) );
if (pSheet)
{
pObj->SetStyleSheet(pSheet, false);
}
SdrLayerAdmin& rAdmin = mrDoc.GetLayerAdmin();
pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
} elseif (nSlotId == SID_DRAW_RECT)
{ if (mnFillTransparence > 0 && mnFillTransparence <= 100)
rAttr.Put(XFillTransparenceItem(mnFillTransparence)); if (!msFillColor.isEmpty())
rAttr.Put(XFillColorItem(OUString(), strToColor(msFillColor))); if (!msShapeName.isEmpty())
pObj->SetName(msShapeName);
switch(mnLineStyle)
{ case 0:
rAttr.Put( XLineStyleItem(css::drawing::LineStyle_NONE ) ); break; case 1:
rAttr.Put( XLineStyleItem(css::drawing::LineStyle_SOLID ) ); break; case 2:
rAttr.Put( XLineStyleItem(css::drawing::LineStyle_DASH ) ); break; default: // Leave it to the defaults break;
}
} elseif (nSlotId == SID_INSERT_SIGNATURELINE)
{ // Avoid the default solid fill and line, we'll set a graphic instead.
rAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
rAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
}
}
/** * set line starts and ends for the object to be created
*/ void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj)
{ if ( !((rObj.GetObjIdentifier() == SdrObjKind::Edge &&
nSlotId != SID_TOOL_CONNECTOR &&
nSlotId != SID_CONNECTOR_LINE &&
nSlotId != SID_CONNECTOR_LINES &&
nSlotId != SID_CONNECTOR_CURVE) ||
nSlotId == SID_LINE_ARROW_START ||
nSlotId == SID_LINE_ARROW_END ||
nSlotId == SID_LINE_ARROWS ||
nSlotId == SID_LINE_ARROW_CIRCLE ||
nSlotId == SID_LINE_CIRCLE_ARROW ||
nSlotId == SID_LINE_ARROW_SQUARE ||
nSlotId == SID_LINE_SQUARE_ARROW) ) return;
// set attributes of line start and ends
SdrModel& rModel(rObj.getSdrModelFromSdrObject());
SfxItemSet aSet( mrDoc.GetPool() );
mpView->GetAttributes( aSet );
// #i3908# Here, the default Line Start/End width for arrow construction is // set. To have the same value in all situations (construction) in i3908 // it was decided to change the default to 0.03 cm for all situations.
::tools::Long nWidth = 300; // (1/100th mm)
// determine line width and calculate with it the line end width if( aSet.GetItemState( XATTR_LINEWIDTH ) != SfxItemState::INVALID )
{
::tools::Long nValue = aSet.Get( XATTR_LINEWIDTH ).GetValue(); if( nValue > 0 )
nWidth = nValue * 3;
}
switch (nSlotId)
{ case SID_CONNECTOR_ARROWS: case SID_CONNECTOR_LINE_ARROWS: case SID_CONNECTOR_LINES_ARROWS: case SID_CONNECTOR_CURVE_ARROWS: case SID_LINE_ARROWS:
{ // connector with arrow ends
rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
rAttr.Put(XLineStartWidthItem(nWidth));
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
case SID_CONNECTOR_ARROW_START: case SID_CONNECTOR_LINE_ARROW_START: case SID_CONNECTOR_LINES_ARROW_START: case SID_CONNECTOR_CURVE_ARROW_START: case SID_LINE_ARROW_START: case SID_LINE_ARROW_CIRCLE: case SID_LINE_ARROW_SQUARE:
{ // connector with arrow start
rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
rAttr.Put(XLineStartWidthItem(nWidth));
} break;
case SID_CONNECTOR_ARROW_END: case SID_CONNECTOR_LINE_ARROW_END: case SID_CONNECTOR_LINES_ARROW_END: case SID_CONNECTOR_CURVE_ARROW_END: case SID_LINE_ARROW_END: case SID_LINE_CIRCLE_ARROW: case SID_LINE_SQUARE_ARROW:
{ // connector with arrow end
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), std::move(aArrow)));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
case SID_CONNECTOR_CIRCLES: case SID_CONNECTOR_LINE_CIRCLES: case SID_CONNECTOR_LINES_CIRCLES: case SID_CONNECTOR_CURVE_CIRCLES:
{ // connector with circle ends
rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
rAttr.Put(XLineStartWidthItem(nWidth));
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
case SID_CONNECTOR_CIRCLE_START: case SID_CONNECTOR_LINE_CIRCLE_START: case SID_CONNECTOR_LINES_CIRCLE_START: case SID_CONNECTOR_CURVE_CIRCLE_START:
{ // connector with circle start
rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
rAttr.Put(XLineStartWidthItem(nWidth));
} break;
case SID_CONNECTOR_CIRCLE_END: case SID_CONNECTOR_LINE_CIRCLE_END: case SID_CONNECTOR_LINES_CIRCLE_END: case SID_CONNECTOR_CURVE_CIRCLE_END:
{ // connector with circle ends
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
}
// and again, for the still missing ends switch (nSlotId)
{ case SID_LINE_ARROW_CIRCLE:
{ // circle end
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
case SID_LINE_CIRCLE_ARROW:
{ // circle start
rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), std::move(aCircle)));
rAttr.Put(XLineStartWidthItem(nWidth));
} break;
case SID_LINE_ARROW_SQUARE:
{ // square end
rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
rAttr.Put(XLineEndWidthItem(nWidth));
} break;
// case SID_DRAW_LINE: // case SID_DRAW_XLINE: // case SID_DRAW_MEASURELINE: // case SID_LINE_ARROW_START: // case SID_LINE_ARROW_END: // case SID_LINE_ARROWS: // case SID_LINE_ARROW_CIRCLE: // case SID_LINE_CIRCLE_ARROW: // case SID_LINE_ARROW_SQUARE: // case SID_LINE_SQUARE_ARROW: // case SID_DRAW_RECT: // case SID_DRAW_RECT_NOFILL: // case SID_DRAW_RECT_ROUND: // case SID_DRAW_RECT_ROUND_NOFILL: // case SID_DRAW_SQUARE: // case SID_DRAW_SQUARE_NOFILL: // case SID_DRAW_SQUARE_ROUND: // case SID_DRAW_SQUARE_ROUND_NOFILL: // case SID_DRAW_ELLIPSE: // case SID_DRAW_ELLIPSE_NOFILL: // case SID_DRAW_CIRCLE: // case SID_DRAW_CIRCLE_NOFILL: // case SID_DRAW_CAPTION: // case SID_DRAW_CAPTION_VERTICAL: // case SID_TOOL_CONNECTOR: // case SID_CONNECTOR_ARROW_START: // case SID_CONNECTOR_ARROW_END: // case SID_CONNECTOR_ARROWS: // case SID_CONNECTOR_CIRCLE_START: // case SID_CONNECTOR_CIRCLE_END: // case SID_CONNECTOR_CIRCLES: // case SID_CONNECTOR_LINE: // case SID_CONNECTOR_LINE_ARROW_START: // case SID_CONNECTOR_LINE_ARROW_END: // case SID_CONNECTOR_LINE_ARROWS: // case SID_CONNECTOR_LINE_CIRCLE_START: // case SID_CONNECTOR_LINE_CIRCLE_END: // case SID_CONNECTOR_LINE_CIRCLES: // case SID_CONNECTOR_CURVE: // case SID_CONNECTOR_CURVE_ARROW_START: // case SID_CONNECTOR_CURVE_ARROW_END: // case SID_CONNECTOR_CURVE_ARROWS: // case SID_CONNECTOR_CURVE_CIRCLE_START: // case SID_CONNECTOR_CURVE_CIRCLE_END: // case SID_CONNECTOR_CURVE_CIRCLES: // case SID_CONNECTOR_LINES: // case SID_CONNECTOR_LINES_ARROW_START: // case SID_CONNECTOR_LINES_ARROW_END: // case SID_CONNECTOR_LINES_ARROWS: // case SID_CONNECTOR_LINES_CIRCLE_START: // case SID_CONNECTOR_LINES_CIRCLE_END: // case SID_CONNECTOR_LINES_CIRCLES:
if(SID_DRAW_SQUARE == nID ||
SID_DRAW_SQUARE_NOFILL == nID ||
SID_DRAW_SQUARE_ROUND == nID ||
SID_DRAW_SQUARE_ROUND_NOFILL == nID ||
SID_DRAW_CIRCLE == nID ||
SID_DRAW_CIRCLE_NOFILL == nID)
{ // force quadratic
ImpForceQuadratic(aRect);
}
Point aStart = aRect.TopLeft();
Point aEnd = aRect.BottomRight();
switch(nID)
{ case SID_DRAW_LINE: case SID_DRAW_XLINE: case SID_LINE_ARROW_START: case SID_LINE_ARROW_END: case SID_LINE_ARROWS: case SID_LINE_ARROW_CIRCLE: case SID_LINE_CIRCLE_ARROW: case SID_LINE_ARROW_SQUARE: case SID_LINE_SQUARE_ARROW:
{ if( auto pPathObj = dynamic_cast<SdrPathObj *>( pObj.get() ) )
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
::basegfx::B2DPolygon aB2DPolygon;
aB2DPolygon.append(::basegfx::B2DPoint(aStart.X(), nYMiddle));
aB2DPolygon.append(::basegfx::B2DPoint(aEnd.X(), nYMiddle));
pPathObj->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon));
} else
{
OSL_FAIL("Object is NO line object");
}
break;
}
case SID_DRAW_MEASURELINE:
{ if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj.get() ) )
{
sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
} else
{
OSL_FAIL("Object is NO measure object");
}
break;
}
case SID_TOOL_CONNECTOR: case SID_CONNECTOR_ARROW_START: case SID_CONNECTOR_ARROW_END: case SID_CONNECTOR_ARROWS: case SID_CONNECTOR_CIRCLE_START: case SID_CONNECTOR_CIRCLE_END: case SID_CONNECTOR_CIRCLES: case SID_CONNECTOR_LINE: case SID_CONNECTOR_LINE_ARROW_START: case SID_CONNECTOR_LINE_ARROW_END: case SID_CONNECTOR_LINE_ARROWS: case SID_CONNECTOR_LINE_CIRCLE_START: case SID_CONNECTOR_LINE_CIRCLE_END: case SID_CONNECTOR_LINE_CIRCLES: case SID_CONNECTOR_CURVE: case SID_CONNECTOR_CURVE_ARROW_START: case SID_CONNECTOR_CURVE_ARROW_END: case SID_CONNECTOR_CURVE_ARROWS: case SID_CONNECTOR_CURVE_CIRCLE_START: case SID_CONNECTOR_CURVE_CIRCLE_END: case SID_CONNECTOR_CURVE_CIRCLES: case SID_CONNECTOR_LINES: case SID_CONNECTOR_LINES_ARROW_START: case SID_CONNECTOR_LINES_ARROW_END: case SID_CONNECTOR_LINES_ARROWS: case SID_CONNECTOR_LINES_CIRCLE_START: case SID_CONNECTOR_LINES_CIRCLE_END: case SID_CONNECTOR_LINES_CIRCLES:
{ if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj.get() ) )
{
pEdgeObj->SetTailPoint(false, aStart);
pEdgeObj->SetTailPoint(true, aEnd);
} else
{
OSL_FAIL("Object is NO connector object");
}
break;
} case SID_DRAW_CAPTION: case SID_DRAW_CAPTION_VERTICAL:
{ if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj.get() ) )
{ bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
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.