Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sd/source/ui/func/fuvect.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 <fuvect.hxx>
21
#include <svx/svdograf.hxx>
22
23
#include <View.hxx>
24
#include <Window.hxx>
25
#include <strings.hrc>
26
#include <sdresid.hxx>
27
#include <sdabstdlg.hxx>
28
29
namespace sd
30
{
31
32
33
FuVectorize::FuVectorize (
34
    ViewShell& rViewSh,
35
    ::sd::Window* pWin,
36
    ::sd::View* pView,
37
    SdDrawDocument& rDoc,
38
    SfxRequest& rReq)
39
0
    : FuPoor (rViewSh, pWin, pView, rDoc, rReq)
40
0
{
41
0
}
42
43
rtl::Reference<FuPoor> FuVectorize::Create( ViewShell& rViewSh, ::sd::Window* pWin, ::sd::View* pView, SdDrawDocument& rDoc, SfxRequest& rReq )
44
0
{
45
0
    rtl::Reference<FuPoor> xFunc( new FuVectorize( rViewSh, pWin, pView, rDoc, rReq ) );
46
0
    xFunc->DoExecute(rReq);
47
0
    return xFunc;
48
0
}
49
50
void FuVectorize::DoExecute( SfxRequest& )
51
0
{
52
0
    const SdrMarkList& rMarkList = mpView->GetMarkedObjectList();
53
54
0
    if( rMarkList.GetMarkCount() != 1 )
55
0
        return;
56
57
0
    SdrObject* pObj = rMarkList.GetMark( 0 )->GetMarkedSdrObj();
58
59
0
    auto pSdrGrafObj = dynamic_cast< const SdrGrafObj *>( pObj );
60
0
    if( !pSdrGrafObj )
61
0
        return;
62
63
0
    SdAbstractDialogFactory* pFact = SdAbstractDialogFactory::Create();
64
0
    ScopedVclPtr<AbstractSdVectorizeDlg> pDlg(
65
0
            pFact->CreateSdVectorizeDlg(mpWindow ? mpWindow->GetFrameWeld() : nullptr,
66
0
                                        pSdrGrafObj->GetGraphic().GetBitmap().CreateColorBitmap(), mpDocSh ) );
67
0
    if( pDlg->Execute() != RET_OK )
68
0
        return;
69
70
0
    const GDIMetaFile&  rMtf = pDlg->GetGDIMetaFile();
71
0
    SdrPageView*        pPageView = mpView->GetSdrPageView();
72
73
0
    if( pPageView && rMtf.GetActionSize() )
74
0
    {
75
0
        rtl::Reference<SdrGrafObj> pVectObj = SdrObject::Clone(static_cast<SdrGrafObj&>(*pObj), pObj->getSdrModelFromSdrObject());
76
0
        OUString aStr = rMarkList.GetMarkDescription() +
77
0
            " " + SdResId( STR_UNDO_VECTORIZE );
78
0
        mpView->BegUndo( aStr );
79
0
        pVectObj->SetGraphic( rMtf );
80
0
        mpView->ReplaceObjectAtView( pObj, *pPageView, pVectObj.get() );
81
0
        mpView->EndUndo();
82
0
    }
83
0
}
84
85
} // end of namespace sd
86
87
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */