LibreOffice Module svx (master)  1
galobj.hxx
Go to the documentation of this file.
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_INC_GALOBJ_HXX
21 #define INCLUDED_SVX_INC_GALOBJ_HXX
22 
23 #include <config_options.h>
24 #include <tools/urlobj.hxx>
25 #include <vcl/graph.hxx>
26 #include <vcl/gdimtf.hxx>
27 #include <svx/galmisc.hxx>
28 
29 #define S_THUMB 80
30 
31 
33 {
42 };
43 
44 class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) SgaObject
45 {
46  friend class GalleryTheme;
47 
48 private:
49 
50  void ImplUpdateURL( const INetURLObject& rNewURL ) { aURL = rNewURL; }
51 
52 protected:
53 
54  BitmapEx aThumbBmp; // Allow transparence to survive
55  GDIMetaFile aThumbMtf;
57  OUString aTitle;
58  bool bIsValid;
59  bool bIsThumbBmp;
60 
61  virtual void WriteData( SvStream& rOut, const OUString& rDestDir ) const;
62  virtual void ReadData( SvStream& rIn, sal_uInt16& rReadVersion );
63 
64  bool CreateThumb( const Graphic& rGraphic );
65 
66 public:
67  SgaObject();
68  virtual ~SgaObject() {};
69 
70  virtual SgaObjKind GetObjKind() const = 0;
71  virtual sal_uInt16 GetVersion() const = 0;
72 
73  virtual BitmapEx GetThumbBmp() const { return aThumbBmp; }
74  const GDIMetaFile& GetThumbMtf() const { return aThumbMtf; }
75  const INetURLObject& GetURL() const { return aURL; }
76  bool IsValid() const { return bIsValid; }
77  bool IsThumbBitmap() const { return bIsThumbBmp; }
78 
79  OUString const & GetTitle() const;
80  void SetTitle( const OUString& rTitle );
81 
82  friend SvStream& WriteSgaObject( SvStream& rOut, const SgaObject& rObj );
83  friend SvStream& ReadSgaObject( SvStream& rIn, SgaObject& rObj );
84 
85  BitmapEx createPreviewBitmapEx(const Size& rSizePixel) const;
86 };
87 
88 class SgaObjectSound final : public SgaObject
89 {
90 private:
91 
93 
94  virtual void WriteData( SvStream& rOut, const OUString& rDestDir ) const override;
95  virtual void ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) override;
96 
97  virtual sal_uInt16 GetVersion() const override { return 6; }
98 
99 public:
100 
101  SgaObjectSound();
102  SgaObjectSound( const INetURLObject& rURL );
103  virtual ~SgaObjectSound() override;
104 
105  virtual SgaObjKind GetObjKind() const override { return SgaObjKind::Sound; }
106  virtual BitmapEx GetThumbBmp() const override;
107 };
108 
109 class FmFormModel;
110 
111 class SgaObjectSvDraw final : public SgaObject
112 {
113  using SgaObject::CreateThumb;
114 
115 private:
116 
117  bool CreateThumb( const FmFormModel& rModel );
118 
119  virtual void WriteData( SvStream& rOut, const OUString& rDestDir ) const override;
120  virtual void ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) override;
121 
122  virtual sal_uInt16 GetVersion() const override { return 5; }
123 
124 public:
125 
126  SgaObjectSvDraw();
127  SgaObjectSvDraw( const FmFormModel& rModel, const INetURLObject& rURL );
128  SgaObjectSvDraw( SvStream& rIStm, const INetURLObject& rURL );
129 
130  virtual SgaObjKind GetObjKind() const override { return SgaObjKind::SvDraw; }
131 };
132 
133 class SgaObjectBmp: public SgaObject
134 {
135 private:
136 
137  void Init( const Graphic& rGraphic, const INetURLObject& rURL );
138 
139  virtual void WriteData( SvStream& rOut, const OUString& rDestDir ) const override;
140  virtual void ReadData( SvStream& rIn, sal_uInt16& rReadVersion ) override;
141 
142  virtual sal_uInt16 GetVersion() const override { return 5; }
143 
144 public:
145 
146  SgaObjectBmp();
147  SgaObjectBmp( const INetURLObject& rURL );
148  SgaObjectBmp( const Graphic& rGraphic, const INetURLObject& rURL );
149 
150  virtual SgaObjKind GetObjKind() const override { return SgaObjKind::Bitmap; }
151 };
152 
154 {
155 public:
156 
157  SgaObjectAnim();
158  SgaObjectAnim( const Graphic& rGraphic, const INetURLObject& rURL );
159 
160  virtual SgaObjKind GetObjKind() const override { return SgaObjKind::Animation; }
161 };
162 
163 class SgaObjectINet final : public SgaObjectAnim
164 {
165 public:
166 
167  SgaObjectINet();
168  SgaObjectINet( const Graphic& rGraphic, const INetURLObject& rURL );
169 
170  virtual SgaObjKind GetObjKind() const override { return SgaObjKind::Inet; }
171 };
172 #endif
173 
174 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
URL aURL
void Init()
virtual sal_uInt16 GetVersion() const override
Definition: galobj.hxx:142
SvStream & ReadSgaObject(SvStream &rIn, SgaObject &rObj)
Definition: galobj.cxx:226
SAL_DLLPRIVATE SvStream & WriteData(SvStream &rOut) const
Definition: galtheme.cxx:1225
SvStream & WriteSgaObject(SvStream &rOut, const SgaObject &rObj)
Definition: galobj.cxx:220
virtual SgaObjKind GetObjKind() const override
Definition: galobj.hxx:105
SAL_DLLPRIVATE bool GetURL(sal_uInt32 nPos, INetURLObject &rURL)
Definition: galtheme.cxx:1037
UNOTOOLS_DLLPUBLIC bool GetTitle(OUString const &url, OUString *title)
SAL_DLLPRIVATE SvStream & ReadData(SvStream &rIn)
Definition: galtheme.cxx:1313
virtual sal_uInt16 GetVersion() const override
Definition: galobj.hxx:122
SgaObjKind
Definition: galmisc.hxx:54
virtual sal_uInt16 GetVersion() const override
Definition: galobj.hxx:97
virtual SgaObjKind GetObjKind() const override
Definition: galobj.hxx:130
GalSoundType eSoundType
Definition: galobj.hxx:92
virtual SgaObjKind GetObjKind() const override
Definition: galobj.hxx:170
GalSoundType
Definition: galobj.hxx:32
sal_uInt16 GetVersion(sal_uInt16)
Definition: legacyitem.cxx:29
virtual SgaObjKind GetObjKind() const override
Definition: galobj.hxx:150
virtual SgaObjKind GetObjKind() const override
Definition: galobj.hxx:160