Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/func/fuconrec.cxx
Line
Count
Source
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
20
#include <fuconrec.hxx>
21
#include <svx/svdpagv.hxx>
22
23
#include <svx/svxids.hrc>
24
#include <svx/strings.hrc>
25
#include <svx/dialmgr.hxx>
26
27
#include <app.hrc>
28
#include <svl/itemset.hxx>
29
#include <svx/constructhelper.hxx>
30
#include <svx/xlineit0.hxx>
31
#include <svx/xlnstwit.hxx>
32
#include <svx/xlnedwit.hxx>
33
#include <svx/xlnedit.hxx>
34
#include <svx/xlnstit.hxx>
35
#include <svx/xlnwtit.hxx>
36
#include <sfx2/viewfrm.hxx>
37
#include <svx/sdtmfitm.hxx>
38
#include <svx/sxekitm.hxx>
39
#include <svx/sderitm.hxx>
40
#include <sfx2/dispatch.hxx>
41
#include <svx/svdopath.hxx>
42
#include <svx/svdocirc.hxx>
43
#include <svl/intitem.hxx>
44
#include <sfx2/request.hxx>
45
#include <editeng/adjustitem.hxx>
46
#include <editeng/eeitem.hxx>
47
#include <svx/xtable.hxx>
48
#include <svx/xfltrit.hxx>
49
#include <svx/xflclit.hxx>
50
#include <svx/sdtagitm.hxx>
51
#include <svx/sdtditm.hxx>
52
53
#include <svx/svdocapt.hxx>
54
55
#include <svx/svdomeas.hxx>
56
#include <ViewShell.hxx>
57
#include <ViewShellBase.hxx>
58
#include <ToolBarManager.hxx>
59
#include <editeng/writingmodeitem.hxx>
60
#include <basegfx/polygon/b2dpolygontools.hxx>
61
#include <basegfx/polygon/b2dpolygon.hxx>
62
#include <svx/xfillit0.hxx>
63
#include <svx/signaturelinehelper.hxx>
64
#include <tools/debug.hxx>
65
#include <osl/diagnose.h>
66
67
#include <sdresid.hxx>
68
#include <View.hxx>
69
#include <sdpage.hxx>
70
#include <Window.hxx>
71
#include <drawdoc.hxx>
72
#include <unokywds.hxx>
73
74
#include <DrawDocShell.hxx>
75
76
#include <strings.hrc>
77
78
using namespace com::sun::star;
79
80
namespace sd {
81
82
83
FuConstructRectangle::FuConstructRectangle (
84
    ViewShell&  rViewSh,
85
    ::sd::Window*       pWin,
86
    ::sd::View*         pView,
87
    SdDrawDocument& rDoc,
88
    SfxRequest&     rReq)
89
0
    : FuConstruct(rViewSh, pWin, pView, rDoc, rReq)
90
0
    , mnFillTransparence(0)
91
0
    , mnLineStyle(SAL_MAX_UINT16)
92
0
{
93
0
}
94
95
namespace{
96
97
/// Checks to see if the request has a parameter of IsSticky:bool=true
98
/// It means that the selected command/button will stay selected after use
99
bool isSticky(const SfxRequest& rReq)
100
0
{
101
0
    const SfxItemSet *pArgs = rReq.GetArgs ();
102
0
    if (pArgs)
103
0
    {
104
0
        const SfxBoolItem* pIsSticky = rReq.GetArg<SfxBoolItem>(FN_PARAM_4);
105
0
        if (pIsSticky && pIsSticky->GetValue())
106
0
            return true;
107
0
    }
108
109
0
    return false;
110
0
}
111
112
}
113
114
rtl::Reference<FuPoor> FuConstructRectangle::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq, bool bPermanent )
115
0
{
116
0
    FuConstructRectangle* pFunc;
117
0
    rtl::Reference<FuPoor> xFunc( pFunc = new FuConstructRectangle( rViewSh, pWin, pView, rDoc, rReq ) );
118
0
    xFunc->DoExecute(rReq);
119
0
    pFunc->SetPermanent(bPermanent || isSticky(rReq));
120
0
    return xFunc;
121
0
}
122
123
void FuConstructRectangle::DoExecute( SfxRequest& rReq )
124
0
{
125
0
    FuConstruct::DoExecute( rReq );
126
127
0
    mrViewShell.GetViewShellBase().GetToolBarManager()->SetToolBar(
128
0
        ToolBarManager::ToolBarGroup::Function,
129
0
        ToolBarManager::msDrawingObjectToolBar);
130
131
0
    const SfxItemSet *pArgs = rReq.GetArgs ();
132
133
0
    if (pArgs)
134
0
    {
135
0
        switch (nSlotId)
136
0
        {
137
0
            case SID_DRAW_ELLIPSE :
138
0
            {
139
0
                const SfxUInt32Item* pCenterX = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_X);
140
0
                const SfxUInt32Item* pCenterY = rReq.GetArg<SfxUInt32Item>(ID_VAL_CENTER_Y);
141
0
                const SfxUInt32Item* pAxisX = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_X);
142
0
                const SfxUInt32Item* pAxisY = rReq.GetArg<SfxUInt32Item>(ID_VAL_AXIS_Y);
143
144
0
                if (!pCenterX || !pCenterY || !pAxisX || !pAxisY)
145
0
                    break;
146
147
0
                ::tools::Rectangle   aNewRectangle (pCenterX->GetValue () - pAxisX->GetValue () / 2,
148
0
                                           pCenterY->GetValue () - pAxisY->GetValue () / 2,
149
0
                                           pCenterX->GetValue () + pAxisX->GetValue () / 2,
150
0
                                           pCenterY->GetValue () + pAxisY->GetValue () / 2);
151
0
                rtl::Reference<SdrCircObj> pNewCircle = new SdrCircObj(
152
0
                    mpView->getSdrModelFromSdrView(),
153
0
                    SdrCircKind::Full,
154
0
                    aNewRectangle);
155
0
                SdrPageView *pPV = mpView->GetSdrPageView();
156
157
0
                mpView->InsertObjectAtView(pNewCircle.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
158
0
            }
159
0
            break;
160
161
0
            case SID_DRAW_RECT :
162
0
            {
163
0
                const SfxUInt32Item* pMouseStartX       = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_X);
164
0
                const SfxUInt32Item* pMouseStartY       = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSESTART_Y);
165
0
                const SfxUInt32Item* pMouseEndX         = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_X);
166
0
                const SfxUInt32Item* pMouseEndY         = rReq.GetArg<SfxUInt32Item>(ID_VAL_MOUSEEND_Y);
167
0
                const SfxUInt16Item* pFillTransparence  = rReq.GetArg<SfxUInt16Item>(FN_PARAM_1);
168
0
                const SfxStringItem* pFillColor         = rReq.GetArg<SfxStringItem>(FN_PARAM_2);
169
0
                const SfxUInt16Item* pLineStyle         = rReq.GetArg<SfxUInt16Item>(FN_PARAM_3);
170
0
                const SfxStringItem* pShapeName         = rReq.GetArg<SfxStringItem>(SID_SHAPE_NAME);
171
172
0
                if (pFillTransparence && pFillTransparence->GetValue() > 0)
173
0
                {
174
0
                    mnFillTransparence = pFillTransparence->GetValue();
175
0
                }
176
0
                if (pFillColor && !pFillColor->GetValue().isEmpty())
177
0
                {
178
0
                    msFillColor = pFillColor->GetValue();
179
0
                }
180
0
                if (pLineStyle)
181
0
                {
182
0
                    mnLineStyle = pLineStyle->GetValue();
183
0
                }
184
0
                if (pShapeName && !pShapeName->GetValue().isEmpty())
185
0
                {
186
0
                    msShapeName = pShapeName->GetValue();
187
0
                }
188
189
0
                if (!pMouseStartX || !pMouseStartY || !pMouseEndX || !pMouseEndY)
190
0
                    break;
191
192
0
                ::tools::Rectangle   aNewRectangle (pMouseStartX->GetValue (),
193
0
                                           pMouseStartY->GetValue (),
194
0
                                           pMouseEndX->GetValue (),
195
0
                                           pMouseEndY->GetValue ());
196
0
                rtl::Reference<SdrRectObj> pNewRect = new SdrRectObj(
197
0
                    mpView->getSdrModelFromSdrView(),
198
0
                    aNewRectangle);
199
0
                SdrPageView *pPV = mpView->GetSdrPageView();
200
201
0
                mpView->InsertObjectAtView(pNewRect.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
202
0
            }
203
0
            break;
204
0
        }
205
0
    }
206
207
0
    if (nSlotId == SID_TOOL_CONNECTOR               ||
208
0
        nSlotId == SID_CONNECTOR_ARROW_START        ||
209
0
        nSlotId == SID_CONNECTOR_ARROW_END          ||
210
0
        nSlotId == SID_CONNECTOR_ARROWS             ||
211
0
        nSlotId == SID_CONNECTOR_CIRCLE_START       ||
212
0
        nSlotId == SID_CONNECTOR_CIRCLE_END         ||
213
0
        nSlotId == SID_CONNECTOR_CIRCLES            ||
214
0
        nSlotId == SID_CONNECTOR_LINE               ||
215
0
        nSlotId == SID_CONNECTOR_LINE_ARROW_START   ||
216
0
        nSlotId == SID_CONNECTOR_LINE_ARROW_END     ||
217
0
        nSlotId == SID_CONNECTOR_LINE_ARROWS        ||
218
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLE_START  ||
219
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLE_END    ||
220
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLES       ||
221
0
        nSlotId == SID_CONNECTOR_CURVE              ||
222
0
        nSlotId == SID_CONNECTOR_CURVE_ARROW_START  ||
223
0
        nSlotId == SID_CONNECTOR_CURVE_ARROW_END    ||
224
0
        nSlotId == SID_CONNECTOR_CURVE_ARROWS       ||
225
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
226
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END   ||
227
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLES      ||
228
0
        nSlotId == SID_CONNECTOR_LINES              ||
229
0
        nSlotId == SID_CONNECTOR_LINES_ARROW_START  ||
230
0
        nSlotId == SID_CONNECTOR_LINES_ARROW_END    ||
231
0
        nSlotId == SID_CONNECTOR_LINES_ARROWS       ||
232
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
233
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLE_END   ||
234
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLES      ||
235
0
        nSlotId == SID_LINE_ARROW_START             ||
236
0
        nSlotId == SID_LINE_ARROW_END               ||
237
0
        nSlotId == SID_LINE_ARROWS                  ||
238
0
        nSlotId == SID_LINE_ARROW_CIRCLE            ||
239
0
        nSlotId == SID_LINE_CIRCLE_ARROW            ||
240
0
        nSlotId == SID_LINE_ARROW_SQUARE            ||
241
0
        nSlotId == SID_LINE_SQUARE_ARROW )
242
0
    {
243
0
        mpView->UnmarkAll();
244
0
    }
245
0
}
246
247
bool FuConstructRectangle::MouseButtonDown(const MouseEvent& rMEvt)
248
0
{
249
0
    bool bReturn = FuConstruct::MouseButtonDown(rMEvt);
250
251
0
    if ( rMEvt.IsLeft() && !mpView->IsAction() )
252
0
    {
253
0
        Point aPnt( mpWindow->PixelToLogic( rMEvt.GetPosPixel() ) );
254
255
0
        mpWindow->CaptureMouse();
256
0
        sal_uInt16 nDrgLog = sal_uInt16 ( mpWindow->PixelToLogic(Size(mpView->GetDragThresholdPixels(),0)).Width() );
257
258
0
        if (mpView->GetCurrentObjIdentifier() == SdrObjKind::Caption)
259
0
        {
260
0
            Size aCaptionSize(846, 846);    // (4x2)cm
261
0
            bReturn = mpView->BegCreateCaptionObj(aPnt, aCaptionSize,
262
0
                                                nullptr, nDrgLog);
263
0
        }
264
0
        else
265
0
        {
266
0
            mpView->BegCreateObj(aPnt, nullptr, nDrgLog);
267
0
        }
268
269
0
        SdrObject* pObj = mpView->GetCreateObj();
270
271
0
        if (pObj)
272
0
        {
273
0
            SfxItemSet aAttr(mrDoc.GetPool());
274
0
            SetStyleSheet(aAttr, pObj);
275
0
            SetAttributes(aAttr, pObj);
276
0
            SetLineEnds(aAttr, *pObj);
277
0
            pObj->SetMergedItemSet(aAttr);
278
279
0
            if( nSlotId == SID_DRAW_CAPTION_VERTICAL )
280
0
                static_cast<SdrTextObj*>(pObj)->SetVerticalWriting( true );
281
0
        }
282
0
    }
283
0
    return bReturn;
284
0
}
285
286
bool FuConstructRectangle::MouseButtonUp(const MouseEvent& rMEvt)
287
0
{
288
0
    if (rMEvt.IsLeft() && IsIgnoreUnexpectedMouseButtonUp())
289
0
        return false;
290
291
0
    bool bReturn(false);
292
293
0
    if(mpView->IsCreateObj() && rMEvt.IsLeft())
294
0
    {
295
0
        SdrObject* pObj = mpView->GetCreateObj();
296
297
0
        if(pObj && mpView->EndCreateObj(SdrCreateCmd::ForceEnd))
298
0
        {
299
0
            if(SID_DRAW_MEASURELINE == nSlotId)
300
0
            {
301
0
                SdrLayerAdmin& rAdmin = mrDoc.GetLayerAdmin();
302
0
                pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
303
0
            }
304
305
            // init text position when vertical caption object is created
306
0
            if( dynamic_cast< const SdrCaptionObj *>( pObj ) !=  nullptr && SID_DRAW_CAPTION_VERTICAL == nSlotId)
307
0
            {
308
                // draw text object, needs to be initialized when vertical text is used
309
0
                SfxItemSet aSet(pObj->GetMergedItemSet());
310
311
0
                aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
312
0
                aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
313
314
                // Correct the value of SDRATTR_TEXTDIRECTION to avoid SetItemSet
315
                // calling SetVerticalWriting() again since this item may not yet
316
                // be set at the object and thus may differ from vertical state of
317
                // the object.
318
0
                aSet.Put(SvxWritingModeItem(css::text::WritingMode_TB_RL, SDRATTR_TEXTDIRECTION));
319
0
                pObj->SetMergedItemSet(aSet);
320
0
            }
321
322
0
            bReturn = true;
323
0
        }
324
0
        else
325
0
        {
326
            //Drag was too small to create object, so insert default object at click pos
327
0
            Point aClickPos(mpWindow->PixelToLogic(rMEvt.GetPosPixel()));
328
0
            sal_uInt32 nDefaultObjectSize(1500);
329
0
            sal_Int32 nCenterOffset(-sal_Int32(nDefaultObjectSize / 2));
330
0
            aClickPos.AdjustX(nCenterOffset);
331
0
            aClickPos.AdjustY(nCenterOffset);
332
333
0
            SdrPageView *pPV = mpView->GetSdrPageView();
334
0
            if(mpView->IsSnapEnabled())
335
0
                aClickPos = mpView->GetSnapPos(aClickPos, pPV);
336
337
0
            ::tools::Rectangle aNewObjectRectangle(aClickPos, Size(nDefaultObjectSize, nDefaultObjectSize));
338
0
            rtl::Reference<SdrObject> pObjDefault = CreateDefaultObject(nSlotId, aNewObjectRectangle);
339
340
0
            bReturn = mpView->InsertObjectAtView(pObjDefault.get(), *pPV, SdrInsertFlags::SETDEFLAYER | SdrInsertFlags::SETDEFATTR);
341
0
        }
342
0
    }
343
344
0
    bReturn = FuConstruct::MouseButtonUp (rMEvt) || bReturn;
345
346
0
    if (!bPermanent)
347
0
        mrViewShell.GetViewFrame()->GetDispatcher()->Execute(SID_OBJECT_SELECT, SfxCallMode::ASYNCHRON);
348
349
0
    return bReturn;
350
0
}
351
352
void FuConstructRectangle::Activate()
353
0
{
354
0
    SdrObjKind aObjKind;
355
356
0
    switch (nSlotId)
357
0
    {
358
0
        case SID_LINE_ARROW_START:
359
0
        case SID_LINE_ARROW_END:
360
0
        case SID_LINE_ARROWS:
361
0
        case SID_LINE_ARROW_CIRCLE:
362
0
        case SID_LINE_CIRCLE_ARROW:
363
0
        case SID_LINE_ARROW_SQUARE:
364
0
        case SID_LINE_SQUARE_ARROW:
365
0
            mpView->SetGlueVisible();
366
0
            [[fallthrough]];
367
0
        case SID_DRAW_LINE :
368
0
        case SID_DRAW_XLINE:
369
0
            aObjKind = SdrObjKind::Line;
370
0
            break;
371
372
0
        case SID_DRAW_MEASURELINE:
373
0
        {
374
0
            aObjKind = SdrObjKind::Measure;
375
0
        }
376
0
        break;
377
378
0
        case SID_DRAW_RECT             :
379
0
        case SID_DRAW_RECT_NOFILL      :
380
0
        case SID_DRAW_RECT_ROUND       :
381
0
        case SID_DRAW_RECT_ROUND_NOFILL:
382
0
        case SID_DRAW_SQUARE           :
383
0
        case SID_DRAW_SQUARE_NOFILL    :
384
0
        case SID_DRAW_SQUARE_ROUND     :
385
0
        case SID_DRAW_SQUARE_ROUND_NOFILL:
386
0
        {
387
0
            aObjKind = SdrObjKind::Rectangle;
388
0
        }
389
0
        break;
390
391
0
        case SID_DRAW_ELLIPSE       :
392
0
        case SID_DRAW_ELLIPSE_NOFILL:
393
0
        case SID_DRAW_CIRCLE        :
394
0
        case SID_DRAW_CIRCLE_NOFILL :
395
0
        {
396
0
            aObjKind = SdrObjKind::CircleOrEllipse;
397
0
        }
398
0
        break;
399
400
0
        case SID_DRAW_CAPTION:
401
0
        case SID_DRAW_CAPTION_VERTICAL:
402
0
        {
403
0
            aObjKind = SdrObjKind::Caption;
404
0
        }
405
0
        break;
406
407
0
        case SID_TOOL_CONNECTOR:
408
0
        case SID_CONNECTOR_ARROW_START:
409
0
        case SID_CONNECTOR_ARROW_END:
410
0
        case SID_CONNECTOR_ARROWS:
411
0
        case SID_CONNECTOR_CIRCLE_START:
412
0
        case SID_CONNECTOR_CIRCLE_END:
413
0
        case SID_CONNECTOR_CIRCLES:
414
0
        case SID_CONNECTOR_LINE:
415
0
        case SID_CONNECTOR_LINE_ARROW_START:
416
0
        case SID_CONNECTOR_LINE_ARROW_END:
417
0
        case SID_CONNECTOR_LINE_ARROWS:
418
0
        case SID_CONNECTOR_LINE_CIRCLE_START:
419
0
        case SID_CONNECTOR_LINE_CIRCLE_END:
420
0
        case SID_CONNECTOR_LINE_CIRCLES:
421
0
        case SID_CONNECTOR_CURVE:
422
0
        case SID_CONNECTOR_CURVE_ARROW_START:
423
0
        case SID_CONNECTOR_CURVE_ARROW_END:
424
0
        case SID_CONNECTOR_CURVE_ARROWS:
425
0
        case SID_CONNECTOR_CURVE_CIRCLE_START:
426
0
        case SID_CONNECTOR_CURVE_CIRCLE_END:
427
0
        case SID_CONNECTOR_CURVE_CIRCLES:
428
0
        case SID_CONNECTOR_LINES:
429
0
        case SID_CONNECTOR_LINES_ARROW_START:
430
0
        case SID_CONNECTOR_LINES_ARROW_END:
431
0
        case SID_CONNECTOR_LINES_ARROWS:
432
0
        case SID_CONNECTOR_LINES_CIRCLE_START:
433
0
        case SID_CONNECTOR_LINES_CIRCLE_END:
434
0
        case SID_CONNECTOR_LINES_CIRCLES:
435
0
        {
436
0
            aObjKind = SdrObjKind::Edge;
437
0
            mpView->SetGlueVisible();
438
0
        }
439
0
        break;
440
0
        case SID_INSERT_SIGNATURELINE:
441
0
        {
442
0
            aObjKind = SdrObjKind::Graphic;
443
0
        }
444
0
        break;
445
446
0
        default:
447
0
        {
448
0
            aObjKind = SdrObjKind::Rectangle;
449
0
        }
450
0
        break;
451
0
    }
452
453
0
    mpView->SetCurrentObj(aObjKind);
454
455
0
    FuConstruct::Activate();
456
0
}
457
458
void FuConstructRectangle::Deactivate()
459
0
{
460
0
    if( nSlotId == SID_TOOL_CONNECTOR               ||
461
0
        nSlotId == SID_CONNECTOR_ARROW_START        ||
462
0
        nSlotId == SID_CONNECTOR_ARROW_END          ||
463
0
        nSlotId == SID_CONNECTOR_ARROWS             ||
464
0
        nSlotId == SID_CONNECTOR_CIRCLE_START       ||
465
0
        nSlotId == SID_CONNECTOR_CIRCLE_END         ||
466
0
        nSlotId == SID_CONNECTOR_CIRCLES            ||
467
0
        nSlotId == SID_CONNECTOR_LINE               ||
468
0
        nSlotId == SID_CONNECTOR_LINE_ARROW_START   ||
469
0
        nSlotId == SID_CONNECTOR_LINE_ARROW_END     ||
470
0
        nSlotId == SID_CONNECTOR_LINE_ARROWS        ||
471
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLE_START  ||
472
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLE_END    ||
473
0
        nSlotId == SID_CONNECTOR_LINE_CIRCLES       ||
474
0
        nSlotId == SID_CONNECTOR_CURVE              ||
475
0
        nSlotId == SID_CONNECTOR_CURVE_ARROW_START  ||
476
0
        nSlotId == SID_CONNECTOR_CURVE_ARROW_END    ||
477
0
        nSlotId == SID_CONNECTOR_CURVE_ARROWS       ||
478
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
479
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END   ||
480
0
        nSlotId == SID_CONNECTOR_CURVE_CIRCLES      ||
481
0
        nSlotId == SID_CONNECTOR_LINES              ||
482
0
        nSlotId == SID_CONNECTOR_LINES_ARROW_START  ||
483
0
        nSlotId == SID_CONNECTOR_LINES_ARROW_END    ||
484
0
        nSlotId == SID_CONNECTOR_LINES_ARROWS       ||
485
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
486
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLE_END   ||
487
0
        nSlotId == SID_CONNECTOR_LINES_CIRCLES      ||
488
0
        nSlotId == SID_LINE_ARROW_START             ||
489
0
        nSlotId == SID_LINE_ARROW_END               ||
490
0
        nSlotId == SID_LINE_ARROWS                  ||
491
0
        nSlotId == SID_LINE_ARROW_CIRCLE            ||
492
0
        nSlotId == SID_LINE_CIRCLE_ARROW            ||
493
0
        nSlotId == SID_LINE_ARROW_SQUARE            ||
494
0
        nSlotId == SID_LINE_SQUARE_ARROW )
495
0
    {
496
0
        mpView->SetGlueVisible( false );
497
0
    }
498
0
    FuConstruct::Deactivate();
499
500
0
    if (nSlotId != SID_INSERT_SIGNATURELINE)
501
0
    {
502
0
        return;
503
0
    }
504
505
0
    const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
506
0
    if (rMarkList.GetMarkCount() < 1)
507
0
    {
508
        // Just switching pages, no signature rectangle yet.
509
0
        return;
510
0
    }
511
512
    // Finished drawing a signature rectangle, now set it up.
513
0
    SfxViewShell* pViewShell = mrViewShell.GetViewShell();
514
0
    svl::crypto::CertificateOrName aCertificateOrName = pViewShell->GetSigningCertificate();
515
0
    if (aCertificateOrName.m_aName.isEmpty())
516
0
    {
517
0
        aCertificateOrName.m_xCertificate = svx::SignatureLineHelper::getSignatureCertificate(
518
0
            mrViewShell.GetObjectShell(), mrViewShell.GetViewShell(),
519
0
            mrViewShell.GetFrameWeld());
520
0
        if (!aCertificateOrName.m_xCertificate.is())
521
0
        {
522
0
            return;
523
0
        }
524
0
    }
525
526
0
    svx::SignatureLineHelper::setShapeCertificate(pViewShell, aCertificateOrName);
527
528
    // Update infobar to offer "finish signing".
529
0
    SfxViewFrame* pFrame = mrViewShell.GetViewFrame();
530
0
    if (pFrame && pFrame->HasInfoBarWithID(u"readonly"))
531
0
    {
532
0
        pFrame->RemoveInfoBar(u"readonly");
533
0
        pFrame->AppendReadOnlyInfobar();
534
0
    }
535
0
}
536
537
namespace {
538
/// Returns the color based on the color names listed in core/include/tools/color.hxx
539
/// Feel free to extend with more color names from color.hxx
540
Color strToColor(std::u16string_view sColor)
541
0
{
542
0
    Color aColor = COL_AUTO;
543
544
0
    if (sColor == u"COL_GRAY")
545
0
        aColor = COL_GRAY;
546
0
    else if (sColor == u"COL_GRAY3")
547
0
        aColor = COL_GRAY3;
548
0
    else if (sColor == u"COL_GRAY7")
549
0
        aColor = COL_GRAY7;
550
551
0
    return aColor;
552
0
}
553
}
554
555
/**
556
 * set attribute for the object to be created
557
 */
558
void FuConstructRectangle::SetAttributes(SfxItemSet& rAttr, SdrObject* pObj)
559
0
{
560
0
    if (nSlotId == SID_DRAW_RECT_ROUND        ||
561
0
        nSlotId == SID_DRAW_RECT_ROUND_NOFILL ||
562
0
        nSlotId == SID_DRAW_SQUARE_ROUND      ||
563
0
        nSlotId == SID_DRAW_SQUARE_ROUND_NOFILL)
564
0
    {
565
        // round corner
566
0
        rAttr.Put(makeSdrEckenradiusItem(500));
567
0
    }
568
0
    else if (nSlotId == SID_CONNECTOR_LINE              ||
569
0
             nSlotId == SID_CONNECTOR_LINE_ARROW_START  ||
570
0
             nSlotId == SID_CONNECTOR_LINE_ARROW_END    ||
571
0
             nSlotId == SID_CONNECTOR_LINE_ARROWS       ||
572
0
             nSlotId == SID_CONNECTOR_LINE_CIRCLE_START ||
573
0
             nSlotId == SID_CONNECTOR_LINE_CIRCLE_END   ||
574
0
             nSlotId == SID_CONNECTOR_LINE_CIRCLES)
575
0
    {
576
        // direct connector
577
0
        rAttr.Put(SdrEdgeKindItem(SdrEdgeKind::OneLine));
578
0
    }
579
0
    else if (nSlotId == SID_CONNECTOR_LINES              ||
580
0
             nSlotId == SID_CONNECTOR_LINES_ARROW_START  ||
581
0
             nSlotId == SID_CONNECTOR_LINES_ARROW_END    ||
582
0
             nSlotId == SID_CONNECTOR_LINES_ARROWS       ||
583
0
             nSlotId == SID_CONNECTOR_LINES_CIRCLE_START ||
584
0
             nSlotId == SID_CONNECTOR_LINES_CIRCLE_END   ||
585
0
             nSlotId == SID_CONNECTOR_LINES_CIRCLES)
586
0
    {
587
        // line connector
588
0
        rAttr.Put(SdrEdgeKindItem(SdrEdgeKind::ThreeLines));
589
0
    }
590
0
    else if (nSlotId == SID_CONNECTOR_CURVE              ||
591
0
             nSlotId == SID_CONNECTOR_CURVE_ARROW_START  ||
592
0
             nSlotId == SID_CONNECTOR_CURVE_ARROW_END    ||
593
0
             nSlotId == SID_CONNECTOR_CURVE_ARROWS       ||
594
0
             nSlotId == SID_CONNECTOR_CURVE_CIRCLE_START ||
595
0
             nSlotId == SID_CONNECTOR_CURVE_CIRCLE_END   ||
596
0
             nSlotId == SID_CONNECTOR_CURVE_CIRCLES)
597
0
    {
598
        // curve connector
599
0
        rAttr.Put(SdrEdgeKindItem(SdrEdgeKind::Bezier));
600
0
    }
601
0
    else if ( nSlotId == SID_DRAW_CAPTION || nSlotId == SID_DRAW_CAPTION_VERTICAL )
602
0
    {
603
        // legend object
604
0
        Size aSize(pObj->GetLogicRect().GetSize());
605
0
        rAttr.Put( makeSdrTextMinFrameHeightItem( aSize.Height() ) );
606
0
        rAttr.Put( makeSdrTextMinFrameWidthItem( aSize.Width() ) );
607
0
        rAttr.Put( makeSdrTextAutoGrowHeightItem( true ) );
608
0
        rAttr.Put( makeSdrTextAutoGrowWidthItem( true ) );
609
610
        // Support full with for vertical caption objects, too
611
0
        if(SID_DRAW_CAPTION == nSlotId)
612
0
            rAttr.Put( SdrTextHorzAdjustItem( SDRTEXTHORZADJUST_BLOCK ) );
613
0
        else
614
0
            rAttr.Put( SdrTextVertAdjustItem( SDRTEXTVERTADJUST_BLOCK ) );
615
616
0
        rAttr.Put( SvxAdjustItem( SvxAdjust::Center, EE_PARA_JUST ) );
617
0
        rAttr.Put( makeSdrTextLeftDistItem( 100 ) );
618
0
        rAttr.Put( makeSdrTextRightDistItem( 100 ) );
619
0
        rAttr.Put( makeSdrTextUpperDistItem( 100 ) );
620
0
        rAttr.Put( makeSdrTextLowerDistItem( 100 ) );
621
0
    }
622
0
    else if (nSlotId == SID_DRAW_MEASURELINE)
623
0
    {
624
        // dimension line
625
0
        SdPage* pPage = static_cast<SdPage*>( mpView->GetSdrPageView()->GetPage() );
626
0
        OUString aName(SdResId(STR_POOLSHEET_MEASURE));
627
0
        SfxStyleSheet* pSheet(
628
0
            static_cast< SfxStyleSheet* >(
629
0
                pPage->getSdrModelFromSdrPage().GetStyleSheetPool()->Find(aName, SfxStyleFamily::Para)));
630
0
        DBG_ASSERT(pSheet, "StyleSheet missing");
631
632
0
        if (pSheet)
633
0
        {
634
0
            pObj->SetStyleSheet(pSheet, false);
635
0
        }
636
637
0
        SdrLayerAdmin& rAdmin = mrDoc.GetLayerAdmin();
638
0
        pObj->SetLayer(rAdmin.GetLayerID(sUNO_LayerName_measurelines));
639
0
    }
640
0
    else if (nSlotId == SID_DRAW_RECT)
641
0
    {
642
0
        if (mnFillTransparence > 0 && mnFillTransparence <= 100)
643
0
            rAttr.Put(XFillTransparenceItem(mnFillTransparence));
644
0
        if (!msFillColor.isEmpty())
645
0
            rAttr.Put(XFillColorItem(OUString(), strToColor(msFillColor)));
646
0
        if (!msShapeName.isEmpty())
647
0
            pObj->SetName(msShapeName);
648
649
0
        switch(mnLineStyle)
650
0
        {
651
0
        case 0:
652
0
            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_NONE ) );
653
0
            break;
654
0
        case 1:
655
0
            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_SOLID ) );
656
0
            break;
657
0
        case 2:
658
0
            rAttr.Put( XLineStyleItem(css::drawing::LineStyle_DASH ) );
659
0
            break;
660
0
        default:
661
            // Leave it to the defaults
662
0
            break;
663
0
        }
664
0
    }
665
0
    else if (nSlotId == SID_INSERT_SIGNATURELINE)
666
0
    {
667
        // Avoid the default solid fill and line, we'll set a graphic instead.
668
0
        rAttr.Put(XFillStyleItem(drawing::FillStyle_NONE));
669
0
        rAttr.Put(XLineStyleItem(drawing::LineStyle_NONE));
670
0
    }
671
0
}
672
673
/**
674
 * set line starts and ends for the object to be created
675
 */
676
void FuConstructRectangle::SetLineEnds(SfxItemSet& rAttr, SdrObject const & rObj)
677
0
{
678
0
    if ( !((rObj.GetObjIdentifier() == SdrObjKind::Edge &&
679
0
          nSlotId != SID_TOOL_CONNECTOR        &&
680
0
          nSlotId != SID_CONNECTOR_LINE        &&
681
0
          nSlotId != SID_CONNECTOR_LINES       &&
682
0
          nSlotId != SID_CONNECTOR_CURVE)      ||
683
0
          nSlotId == SID_LINE_ARROW_START      ||
684
0
          nSlotId == SID_LINE_ARROW_END        ||
685
0
          nSlotId == SID_LINE_ARROWS           ||
686
0
          nSlotId == SID_LINE_ARROW_CIRCLE     ||
687
0
          nSlotId == SID_LINE_CIRCLE_ARROW     ||
688
0
          nSlotId == SID_LINE_ARROW_SQUARE     ||
689
0
          nSlotId == SID_LINE_SQUARE_ARROW) )
690
0
        return;
691
692
    // set attributes of line start and ends
693
0
    SdrModel& rModel(rObj.getSdrModelFromSdrObject());
694
695
    // arrowhead
696
0
    ::basegfx::B2DPolyPolygon aArrow(ConstructHelper::GetLineEndPoly(RID_SVXSTR_ARROW, rModel));
697
0
    if( !aArrow.count() )
698
0
    {
699
0
        ::basegfx::B2DPolygon aNewArrow;
700
0
        aNewArrow.append(::basegfx::B2DPoint(10.0, 0.0));
701
0
        aNewArrow.append(::basegfx::B2DPoint(0.0, 30.0));
702
0
        aNewArrow.append(::basegfx::B2DPoint(20.0, 30.0));
703
0
        aNewArrow.setClosed(true);
704
0
        aArrow.append(aNewArrow);
705
0
    }
706
707
    // Circles
708
0
    ::basegfx::B2DPolyPolygon aCircle(ConstructHelper::GetLineEndPoly(RID_SVXSTR_CIRCLE, rModel));
709
0
    if( !aCircle.count() )
710
0
    {
711
0
        ::basegfx::B2DPolygon aNewCircle = ::basegfx::utils::createPolygonFromEllipse(::basegfx::B2DPoint(0.0, 0.0), 250.0, 250.0);
712
0
        aNewCircle.setClosed(true);
713
0
        aCircle.append(aNewCircle);
714
0
    }
715
716
    // Square
717
0
    ::basegfx::B2DPolyPolygon aSquare(ConstructHelper::GetLineEndPoly(RID_SVXSTR_SQUARE, rModel));
718
0
    if( !aSquare.count() )
719
0
    {
720
0
        ::basegfx::B2DPolygon aNewSquare;
721
0
        aNewSquare.append(::basegfx::B2DPoint(0.0, 0.0));
722
0
        aNewSquare.append(::basegfx::B2DPoint(10.0, 0.0));
723
0
        aNewSquare.append(::basegfx::B2DPoint(10.0, 10.0));
724
0
        aNewSquare.append(::basegfx::B2DPoint(0.0, 10.0));
725
0
        aNewSquare.setClosed(true);
726
0
        aSquare.append(aNewSquare);
727
0
    }
728
729
0
    SfxItemSet aSet( mrDoc.GetPool() );
730
0
    mpView->GetAttributes( aSet );
731
732
    // tdf#126823 - retrieve default arrow sizes for start/end widths
733
    // generated in SdDrawDocument::CreateLayoutTemplates()
734
0
    ::tools::Long nLineStartWidth = LINE_START_WIDTH_DEFAULT;
735
0
    if (aSet.GetItemState(XATTR_LINESTARTWIDTH) != SfxItemState::INVALID)
736
0
        nLineStartWidth = aSet.Get(XATTR_LINESTARTWIDTH).GetValue();
737
738
0
    ::tools::Long nLineEndWidth = LINE_END_WIDTH_DEFAULT;
739
0
    if (aSet.GetItemState(XATTR_LINEENDWIDTH) != SfxItemState::INVALID)
740
0
        nLineEndWidth = aSet.Get(XATTR_LINEENDWIDTH).GetValue();
741
742
0
    switch (nSlotId)
743
0
    {
744
0
        case SID_CONNECTOR_ARROWS:
745
0
        case SID_CONNECTOR_LINE_ARROWS:
746
0
        case SID_CONNECTOR_LINES_ARROWS:
747
0
        case SID_CONNECTOR_CURVE_ARROWS:
748
0
        case SID_LINE_ARROWS:
749
0
        {
750
            // connector with arrow ends
751
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
752
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
753
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
754
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
755
0
        }
756
0
        break;
757
758
0
        case SID_CONNECTOR_ARROW_START:
759
0
        case SID_CONNECTOR_LINE_ARROW_START:
760
0
        case SID_CONNECTOR_LINES_ARROW_START:
761
0
        case SID_CONNECTOR_CURVE_ARROW_START:
762
0
        case SID_LINE_ARROW_START:
763
0
        case SID_LINE_ARROW_CIRCLE:
764
0
        case SID_LINE_ARROW_SQUARE:
765
0
        {
766
            // connector with arrow start
767
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_ARROW), aArrow));
768
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
769
0
        }
770
0
        break;
771
772
0
        case SID_CONNECTOR_ARROW_END:
773
0
        case SID_CONNECTOR_LINE_ARROW_END:
774
0
        case SID_CONNECTOR_LINES_ARROW_END:
775
0
        case SID_CONNECTOR_CURVE_ARROW_END:
776
0
        case SID_LINE_ARROW_END:
777
0
        case SID_LINE_CIRCLE_ARROW:
778
0
        case SID_LINE_SQUARE_ARROW:
779
0
        {
780
            // connector with arrow end
781
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_ARROW), std::move(aArrow)));
782
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
783
0
        }
784
0
        break;
785
786
0
        case SID_CONNECTOR_CIRCLES:
787
0
        case SID_CONNECTOR_LINE_CIRCLES:
788
0
        case SID_CONNECTOR_LINES_CIRCLES:
789
0
        case SID_CONNECTOR_CURVE_CIRCLES:
790
0
        {
791
            // connector with circle ends
792
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
793
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
794
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
795
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
796
0
        }
797
0
        break;
798
799
0
        case SID_CONNECTOR_CIRCLE_START:
800
0
        case SID_CONNECTOR_LINE_CIRCLE_START:
801
0
        case SID_CONNECTOR_LINES_CIRCLE_START:
802
0
        case SID_CONNECTOR_CURVE_CIRCLE_START:
803
0
        {
804
            // connector with circle start
805
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
806
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
807
0
        }
808
0
        break;
809
810
0
        case SID_CONNECTOR_CIRCLE_END:
811
0
        case SID_CONNECTOR_LINE_CIRCLE_END:
812
0
        case SID_CONNECTOR_LINES_CIRCLE_END:
813
0
        case SID_CONNECTOR_CURVE_CIRCLE_END:
814
0
        {
815
            // connector with circle ends
816
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
817
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
818
0
        }
819
0
        break;
820
0
    }
821
822
    // and again, for the still missing ends
823
0
    switch (nSlotId)
824
0
    {
825
0
        case SID_LINE_ARROW_CIRCLE:
826
0
        {
827
            // circle end
828
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_CIRCLE), aCircle));
829
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
830
0
        }
831
0
        break;
832
833
0
        case SID_LINE_CIRCLE_ARROW:
834
0
        {
835
            // circle start
836
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_CIRCLE), std::move(aCircle)));
837
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
838
0
        }
839
0
        break;
840
841
0
        case SID_LINE_ARROW_SQUARE:
842
0
        {
843
            // square end
844
0
            rAttr.Put(XLineEndItem(SvxResId(RID_SVXSTR_SQUARE), aSquare));
845
0
            rAttr.Put(XLineEndWidthItem(nLineEndWidth));
846
0
        }
847
0
        break;
848
849
0
        case SID_LINE_SQUARE_ARROW:
850
0
        {
851
            // square start
852
0
            rAttr.Put(XLineStartItem(SvxResId(RID_SVXSTR_SQUARE), std::move(aSquare)));
853
0
            rAttr.Put(XLineStartWidthItem(nLineStartWidth));
854
0
        }
855
0
        break;
856
0
    }
857
0
}
858
859
rtl::Reference<SdrObject> FuConstructRectangle::CreateDefaultObject(const sal_uInt16 nID, const ::tools::Rectangle& rRectangle)
860
0
{
861
0
    DBG_ASSERT( (nID != SID_DRAW_FONTWORK) && (nID != SID_DRAW_FONTWORK_VERTICAL ), "FuConstRectangle::CreateDefaultObject can not create Fontwork shapes!" );
862
863
    // case SID_DRAW_LINE:
864
    // case SID_DRAW_XLINE:
865
    // case SID_DRAW_MEASURELINE:
866
    // case SID_LINE_ARROW_START:
867
    // case SID_LINE_ARROW_END:
868
    // case SID_LINE_ARROWS:
869
    // case SID_LINE_ARROW_CIRCLE:
870
    // case SID_LINE_CIRCLE_ARROW:
871
    // case SID_LINE_ARROW_SQUARE:
872
    // case SID_LINE_SQUARE_ARROW:
873
    // case SID_DRAW_RECT:
874
    // case SID_DRAW_RECT_NOFILL:
875
    // case SID_DRAW_RECT_ROUND:
876
    // case SID_DRAW_RECT_ROUND_NOFILL:
877
    // case SID_DRAW_SQUARE:
878
    // case SID_DRAW_SQUARE_NOFILL:
879
    // case SID_DRAW_SQUARE_ROUND:
880
    // case SID_DRAW_SQUARE_ROUND_NOFILL:
881
    // case SID_DRAW_ELLIPSE:
882
    // case SID_DRAW_ELLIPSE_NOFILL:
883
    // case SID_DRAW_CIRCLE:
884
    // case SID_DRAW_CIRCLE_NOFILL:
885
    // case SID_DRAW_CAPTION:
886
    // case SID_DRAW_CAPTION_VERTICAL:
887
    // case SID_TOOL_CONNECTOR:
888
    // case SID_CONNECTOR_ARROW_START:
889
    // case SID_CONNECTOR_ARROW_END:
890
    // case SID_CONNECTOR_ARROWS:
891
    // case SID_CONNECTOR_CIRCLE_START:
892
    // case SID_CONNECTOR_CIRCLE_END:
893
    // case SID_CONNECTOR_CIRCLES:
894
    // case SID_CONNECTOR_LINE:
895
    // case SID_CONNECTOR_LINE_ARROW_START:
896
    // case SID_CONNECTOR_LINE_ARROW_END:
897
    // case SID_CONNECTOR_LINE_ARROWS:
898
    // case SID_CONNECTOR_LINE_CIRCLE_START:
899
    // case SID_CONNECTOR_LINE_CIRCLE_END:
900
    // case SID_CONNECTOR_LINE_CIRCLES:
901
    // case SID_CONNECTOR_CURVE:
902
    // case SID_CONNECTOR_CURVE_ARROW_START:
903
    // case SID_CONNECTOR_CURVE_ARROW_END:
904
    // case SID_CONNECTOR_CURVE_ARROWS:
905
    // case SID_CONNECTOR_CURVE_CIRCLE_START:
906
    // case SID_CONNECTOR_CURVE_CIRCLE_END:
907
    // case SID_CONNECTOR_CURVE_CIRCLES:
908
    // case SID_CONNECTOR_LINES:
909
    // case SID_CONNECTOR_LINES_ARROW_START:
910
    // case SID_CONNECTOR_LINES_ARROW_END:
911
    // case SID_CONNECTOR_LINES_ARROWS:
912
    // case SID_CONNECTOR_LINES_CIRCLE_START:
913
    // case SID_CONNECTOR_LINES_CIRCLE_END:
914
    // case SID_CONNECTOR_LINES_CIRCLES:
915
916
0
    rtl::Reference<SdrObject> pObj(SdrObjFactory::MakeNewObject(
917
0
        mpView->getSdrModelFromSdrView(),
918
0
        mpView->GetCurrentObjInventor(),
919
0
        mpView->GetCurrentObjIdentifier()));
920
921
0
    if(pObj)
922
0
    {
923
0
        ::tools::Rectangle aRect(rRectangle);
924
925
0
        if(SID_DRAW_SQUARE == nID ||
926
0
            SID_DRAW_SQUARE_NOFILL == nID ||
927
0
            SID_DRAW_SQUARE_ROUND == nID ||
928
0
            SID_DRAW_SQUARE_ROUND_NOFILL == nID ||
929
0
            SID_DRAW_CIRCLE == nID ||
930
0
            SID_DRAW_CIRCLE_NOFILL == nID)
931
0
        {
932
            // force quadratic
933
0
            ImpForceQuadratic(aRect);
934
0
        }
935
936
0
        Point aStart = aRect.TopLeft();
937
0
        Point aEnd = aRect.BottomRight();
938
939
0
        switch(nID)
940
0
        {
941
0
            case SID_DRAW_LINE:
942
0
            case SID_DRAW_XLINE:
943
0
            case SID_LINE_ARROW_START:
944
0
            case SID_LINE_ARROW_END:
945
0
            case SID_LINE_ARROWS:
946
0
            case SID_LINE_ARROW_CIRCLE:
947
0
            case SID_LINE_CIRCLE_ARROW:
948
0
            case SID_LINE_ARROW_SQUARE:
949
0
            case SID_LINE_SQUARE_ARROW:
950
0
            {
951
0
                if( auto pPathObj = dynamic_cast<SdrPathObj *>( pObj.get() ) )
952
0
                {
953
0
                    sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
954
955
0
                    ::basegfx::B2DPolygon aB2DPolygon;
956
0
                    aB2DPolygon.append(::basegfx::B2DPoint(aStart.X(), nYMiddle));
957
0
                    aB2DPolygon.append(::basegfx::B2DPoint(aEnd.X(), nYMiddle));
958
0
                    pPathObj->SetPathPoly(::basegfx::B2DPolyPolygon(aB2DPolygon));
959
0
                }
960
0
                else
961
0
                {
962
0
                    OSL_FAIL("Object is NO line object");
963
0
                }
964
965
0
                break;
966
0
            }
967
968
0
            case SID_DRAW_MEASURELINE:
969
0
            {
970
0
                if( auto pMeasureObj = dynamic_cast< SdrMeasureObj *>( pObj.get() ) )
971
0
                {
972
0
                    sal_Int32 nYMiddle((aRect.Top() + aRect.Bottom()) / 2);
973
0
                    pMeasureObj->SetPoint(Point(aStart.X(), nYMiddle), 0);
974
0
                    pMeasureObj->SetPoint(Point(aEnd.X(), nYMiddle), 1);
975
0
                }
976
0
                else
977
0
                {
978
0
                    OSL_FAIL("Object is NO measure object");
979
0
                }
980
981
0
                break;
982
0
            }
983
984
0
            case SID_TOOL_CONNECTOR:
985
0
            case SID_CONNECTOR_ARROW_START:
986
0
            case SID_CONNECTOR_ARROW_END:
987
0
            case SID_CONNECTOR_ARROWS:
988
0
            case SID_CONNECTOR_CIRCLE_START:
989
0
            case SID_CONNECTOR_CIRCLE_END:
990
0
            case SID_CONNECTOR_CIRCLES:
991
0
            case SID_CONNECTOR_LINE:
992
0
            case SID_CONNECTOR_LINE_ARROW_START:
993
0
            case SID_CONNECTOR_LINE_ARROW_END:
994
0
            case SID_CONNECTOR_LINE_ARROWS:
995
0
            case SID_CONNECTOR_LINE_CIRCLE_START:
996
0
            case SID_CONNECTOR_LINE_CIRCLE_END:
997
0
            case SID_CONNECTOR_LINE_CIRCLES:
998
0
            case SID_CONNECTOR_CURVE:
999
0
            case SID_CONNECTOR_CURVE_ARROW_START:
1000
0
            case SID_CONNECTOR_CURVE_ARROW_END:
1001
0
            case SID_CONNECTOR_CURVE_ARROWS:
1002
0
            case SID_CONNECTOR_CURVE_CIRCLE_START:
1003
0
            case SID_CONNECTOR_CURVE_CIRCLE_END:
1004
0
            case SID_CONNECTOR_CURVE_CIRCLES:
1005
0
            case SID_CONNECTOR_LINES:
1006
0
            case SID_CONNECTOR_LINES_ARROW_START:
1007
0
            case SID_CONNECTOR_LINES_ARROW_END:
1008
0
            case SID_CONNECTOR_LINES_ARROWS:
1009
0
            case SID_CONNECTOR_LINES_CIRCLE_START:
1010
0
            case SID_CONNECTOR_LINES_CIRCLE_END:
1011
0
            case SID_CONNECTOR_LINES_CIRCLES:
1012
0
            {
1013
0
                if( auto pEdgeObj = dynamic_cast< SdrEdgeObj *>( pObj.get() ) )
1014
0
                {
1015
0
                    pEdgeObj->SetTailPoint(false, aStart);
1016
0
                    pEdgeObj->SetTailPoint(true, aEnd);
1017
0
                }
1018
0
                else
1019
0
                {
1020
0
                    OSL_FAIL("Object is NO connector object");
1021
0
                }
1022
1023
0
                break;
1024
0
            }
1025
0
            case SID_DRAW_CAPTION:
1026
0
            case SID_DRAW_CAPTION_VERTICAL:
1027
0
            {
1028
0
                if( auto pCaptionObj = dynamic_cast< SdrCaptionObj *>( pObj.get() ) )
1029
0
                {
1030
0
                    bool bIsVertical(SID_DRAW_CAPTION_VERTICAL == nID);
1031
1032
0
                    pCaptionObj->SetVerticalWriting(bIsVertical);
1033
1034
0
                    if(bIsVertical)
1035
0
                    {
1036
0
                        SfxItemSet aSet(pObj->GetMergedItemSet());
1037
0
                        aSet.Put(SdrTextVertAdjustItem(SDRTEXTVERTADJUST_CENTER));
1038
0
                        aSet.Put(SdrTextHorzAdjustItem(SDRTEXTHORZADJUST_RIGHT));
1039
0
                        pObj->SetMergedItemSet(aSet);
1040
0
                    }
1041
1042
                    // The default text is not inserted anymore.
1043
1044
0
                    pCaptionObj->SetLogicRect(aRect);
1045
0
                    pCaptionObj->SetTailPos(
1046
0
                        aRect.TopLeft() - Point(aRect.GetWidth() / 2, aRect.GetHeight() / 2));
1047
0
                }
1048
0
                else
1049
0
                {
1050
0
                    OSL_FAIL("Object is NO caption object");
1051
0
                }
1052
1053
0
                break;
1054
0
            }
1055
1056
0
            default:
1057
0
            {
1058
0
                pObj->SetLogicRect(aRect);
1059
1060
0
                break;
1061
0
            }
1062
0
        }
1063
1064
0
        SfxItemSet aAttr(mrDoc.GetPool());
1065
0
        SetStyleSheet(aAttr, pObj.get());
1066
0
        SetAttributes(aAttr, pObj.get());
1067
0
        SetLineEnds(aAttr, *pObj);
1068
0
        pObj->SetMergedItemSet(aAttr);
1069
0
    }
1070
1071
0
    return pObj;
1072
0
}
1073
1074
} // end of namespace sd
1075
1076
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */