1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <svtools/svtdllapi.h>
23 #include <com/sun/star/uno/Reference.hxx>
24 #include <vcl/graph.hxx>
25 #include <rtl/ustring.hxx>
28 namespace com :: sun :: star :: io
{ class XInputStream
; }
32 class EmbeddedObjectContainer
;
35 namespace com::sun::star::embed
{
36 class XEmbeddedObject
;
40 typedef struct _xmlTextWriter
* xmlTextWriterPtr
;
44 struct EmbeddedObjectRef_Impl
;
46 class SVT_DLLPUBLIC EmbeddedObjectRef
48 std::unique_ptr
<EmbeddedObjectRef_Impl
> mpImpl
;
50 SVT_DLLPRIVATE
std::unique_ptr
<SvStream
> GetGraphicStream( bool bUpdate
) const;
51 SVT_DLLPRIVATE
void GetReplacement( bool bUpdate
);
52 SVT_DLLPRIVATE
void UpdateOleObject( bool bUpdateOle
);
54 EmbeddedObjectRef
& operator = ( const EmbeddedObjectRef
& ) = delete;
57 static void DrawPaintReplacement( const tools::Rectangle
&rRect
, const OUString
&rText
, OutputDevice
*pOut
);
58 static void DrawShading( const tools::Rectangle
&rRect
, OutputDevice
*pOut
);
59 static bool TryRunningState( const css::uno::Reference
< css::embed::XEmbeddedObject
>& );
60 static void SetGraphicToContainer( const Graphic
& rGraphic
,
61 comphelper::EmbeddedObjectContainer
& aContainer
,
62 const OUString
& aName
,
63 const OUString
& aMediaType
);
65 static css::uno::Reference
< css::io::XInputStream
> GetGraphicReplacementStream(
66 sal_Int64 nViewAspect
,
67 const css::uno::Reference
< css::embed::XEmbeddedObject
>&,
68 OUString
* pMediaType
)
71 static bool IsChart(const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
);
73 const css::uno::Reference
<css::embed::XEmbeddedObject
>& operator->() const;
74 const css::uno::Reference
<css::embed::XEmbeddedObject
>& GetObject() const;
76 // default constructed object; needs further assignment before it can be used
79 // assign a previously default constructed object
80 void Assign( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
82 // create object for a certain view aspect
83 EmbeddedObjectRef( const css::uno::Reference
< css::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
86 EmbeddedObjectRef( const EmbeddedObjectRef
& );
88 // assigning to a container enables the object to exchange graphical representations with a storage
89 void AssignToContainer( comphelper::EmbeddedObjectContainer
* pContainer
, const OUString
& rPersistName
);
90 comphelper::EmbeddedObjectContainer
* GetContainer() const;
92 sal_Int64
GetViewAspect() const;
93 void SetViewAspect( sal_Int64 nAspect
);
94 const Graphic
* GetGraphic() const;
96 // the original size of the object ( size of the icon for iconified object )
97 // no conversion is done if no target mode is provided
98 Size
GetSize( MapMode
const * pTargetMapMode
) const;
100 void SetGraphic( const Graphic
& rGraphic
, const OUString
& rMediaType
);
101 void SetGraphicStream(
102 const css::uno::Reference
< css::io::XInputStream
>& xInGrStream
,
103 const OUString
& rMediaType
);
105 // bUpdateOle = false update the Link-Objects
106 // = true update the OLE-Objects
107 void UpdateReplacement( bool bUpdateOle
= false );
108 void UpdateReplacementOnDemand();
109 void Lock( bool bLock
= true );
113 bool IsLocked() const;
115 void SetIsProtectedHdl(const Link
<LinkParamNone
*, bool>& rProtectedHdl
);
116 const Link
<LinkParamNone
*, bool> & GetIsProtectedHdl() const;
118 bool IsChart() const;
120 OUString
GetChartType();
123 // Provides a graphic version number for the fetchable Graphic during this object's lifetime. Internally,
124 // that number is incremented at each change of the Graphic. This mechanism is needed to identify if a
125 // remembered Graphic (e.g. primitives) has changed compared to the current one, but without actively
126 // fetching the Graphic what would be too expensive e.g. for charts
127 sal_uInt32
getGraphicVersion() const;
128 void SetDefaultSizeForChart( const Size
& rSizeIn_100TH_MM
);//#i103460# charts do not necessarily have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method
130 void dumpAsXml(xmlTextWriterPtr pWriter
) const;
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */