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