Coverage Report

Created: 2026-03-31 11:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/galmisc.hxx
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
#ifndef INCLUDED_SVX_GALMISC_HXX
21
#define INCLUDED_SVX_GALMISC_HXX
22
23
#include <utility>
24
#include <vcl/imap.hxx>
25
#include <svl/hint.hxx>
26
#include <vcl/transfer.hxx>
27
#include <svx/svdobj.hxx>
28
#include <com/sun/star/uno/Reference.h>
29
#include <svx/svxdllapi.h>
30
#include <tools/date.hxx>
31
#include <tools/time.hxx>
32
#include <memory>
33
34
namespace com::sun::star::awt { class XProgressBar; }
35
36
class INetURLObject;
37
class GalleryTheme;
38
39
struct ExchangeData
40
{
41
    GalleryTheme*   pTheme;
42
    OUString        aEditedTitle;
43
    Date            aThemeChangeDate;
44
    tools::Time     aThemeChangeTime;
45
46
    ExchangeData()
47
0
        : pTheme(nullptr)
48
0
        , aThemeChangeDate( Date::EMPTY )
49
0
        , aThemeChangeTime( tools::Time::EMPTY )
50
0
        {
51
0
        }
52
};
53
54
enum class SgaObjKind
55
{
56
    NONE = 0,   // abstract object
57
    Bitmap = 1,    // bitmap object
58
    Sound = 2,  // sound object
59
    Animation = 4,   // animation object
60
    SvDraw = 5, // Svdraw object
61
    Inet = 6    // graphics from the internet
62
};
63
64
0
#define ID_IMAPINFO             2
65
66
enum class GalleryGraphicImportRet
67
{
68
    IMPORT_NONE, IMPORT_FILE
69
};
70
71
0
#define GALLERY_PROGRESS_RANGE  10000
72
73
class SvStream;
74
class Graphic;
75
class FmFormModel;
76
77
GalleryGraphicImportRet  GalleryGraphicImport( const INetURLObject& rURL, Graphic& rGraphic, OUString& rFilterName );
78
bool                GallerySvDrawImport( SvStream& rIStm, SdrModel& rModel );
79
bool                CreateIMapGraphic( const FmFormModel& rModel, Graphic& rGraphic, ImageMap& rImageMap );
80
SVXCORE_DLLPUBLIC OUString
81
                    GetReducedString( const INetURLObject& rURL, sal_Int32 nMaxLen );
82
OUString            GetSvDrawStreamNameFromURL( const INetURLObject& rSvDrawObjURL );
83
84
bool                FileExists( const INetURLObject& rURL );
85
bool                CreateDir(  const INetURLObject& rURL );
86
bool                CopyFile(  const INetURLObject& rSrcURL, const INetURLObject& rDstURL );
87
bool                KillFile( const INetURLObject& rURL );
88
89
class SgaIMapInfo final : public SdrObjUserData, public SfxListener
90
{
91
    ImageMap                m_aImageMap;
92
93
public:
94
0
                            SgaIMapInfo() : SdrObjUserData( SdrInventor::SgaImap, ID_IMAPINFO ) {};
95
96
                            SgaIMapInfo( const ImageMap& rImageMap) :
97
0
                                SdrObjUserData( SdrInventor::SgaImap, ID_IMAPINFO ),
98
0
                                m_aImageMap( rImageMap ) {};
99
100
    virtual std::unique_ptr<SdrObjUserData> Clone( SdrObject* ) const override
101
0
                            {
102
0
                                SgaIMapInfo* pInfo = new SgaIMapInfo;
103
0
                                pInfo->m_aImageMap = m_aImageMap;
104
0
                                return std::unique_ptr<SdrObjUserData>(pInfo);
105
0
                            }
106
107
0
    const ImageMap&         GetImageMap() const { return m_aImageMap; }
108
};
109
110
class GraphicFilter;
111
112
class SVXCORE_DLLPUBLIC GalleryProgress
113
{
114
    css::uno::Reference< css::awt::XProgressBar > mxProgressBar;
115
116
    public:
117
118
                                    GalleryProgress( const GraphicFilter* pFilter = nullptr );
119
                                    ~GalleryProgress();
120
121
    void                            Update( sal_Int32 nVal, sal_Int32 nMaxVal );
122
};
123
124
class GalleryTheme;
125
class GraphicObject;
126
127
class GalleryTransferable final : public TransferDataContainer
128
{
129
friend class GalleryTheme;
130
using TransferableHelper::CopyToClipboard;
131
132
    GalleryTheme*                   mpTheme;
133
    SgaObjKind                      meObjectKind;
134
    sal_uInt32                      mnObjectPos;
135
    std::unique_ptr<SvStream>       mxModelStream;
136
    std::unique_ptr<GraphicObject>  mpGraphicObject;
137
    std::unique_ptr<INetURLObject>  mpURL;
138
139
    void                            InitData( bool bLazy );
140
141
public:
142
                                    GalleryTransferable( GalleryTheme* pTheme, sal_uInt32 nObjectPos, bool bLazy );
143
                                    virtual ~GalleryTransferable() override;
144
145
    void                            SelectObject(sal_uInt32 nObjectPos);
146
147
    // TransferableHelper
148
    virtual void                    AddSupportedFormats() override;
149
    virtual bool GetData( const css::datatransfer::DataFlavor& rFlavor, const OUString& rDestDoc ) override;
150
    virtual bool                    WriteObject( SvStream& rxOStm, void* pUserObject, sal_uInt32 nUserObjectId, const css::datatransfer::DataFlavor& rFlavor ) override;
151
    virtual void                    DragFinished( sal_Int8 nDropAction ) override;
152
    virtual void                    ObjectReleased() override;
153
154
    bool                            StartDrag();
155
};
156
157
enum class GalleryHintType
158
{
159
    CLOSE_THEME,
160
    THEME_REMOVED,
161
    THEME_RENAMED,
162
    THEME_CREATED,
163
    THEME_UPDATEVIEW,
164
    CLOSE_OBJECT,
165
    ADD_OBJECT
166
};
167
168
class GalleryHint final : public SfxHint
169
{
170
private:
171
172
    GalleryHintType     mnType;
173
    OUString            maThemeName;
174
    OUString            maStringData;
175
    void*               mnData1;
176
177
public:
178
179
                     GalleryHint( GalleryHintType nType, OUString aThemeName, void* nData1 = nullptr ) :
180
0
                        SfxHint(SfxHintId::NONE),
181
0
                        mnType( nType ), maThemeName(std::move( aThemeName )), mnData1( nData1 ) {}
182
183
                     GalleryHint( GalleryHintType nType, OUString aThemeName, OUString aStringData ) :
184
0
                        SfxHint(SfxHintId::NONE),
185
0
                        mnType( nType ), maThemeName(std::move( aThemeName )), maStringData(std::move( aStringData )), mnData1( nullptr ) {}
186
187
0
    GalleryHintType  GetType() const { return mnType; }
188
0
    const OUString&  GetThemeName() const { return maThemeName; }
189
0
    const OUString&  GetStringData() const { return maStringData; }
190
0
    void*            GetData1() const { return mnData1; }
191
};
192
193
struct GalleryObject;
194
195
INetURLObject ImplGetURL(const GalleryObject* pObject);
196
197
#endif
198
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */