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 .
20 #ifndef INCLUDED_SVTOOLS_EMBEDHLP_HXX
21 #define INCLUDED_SVTOOLS_EMBEDHLP_HXX
23 #include <svtools/svtdllapi.h>
24 #include <com/sun/star/uno/Reference.hxx>
25 #include <com/sun/star/io/XInputStream.hpp>
26 #include <vcl/graph.hxx>
27 #include <tools/mapunit.hxx>
28 #include <rtl/ustring.hxx>
32 class EmbeddedObjectContainer
;
35 namespace com
{ namespace sun
{ namespace star
{ namespace embed
{
36 class XEmbeddedObject
;
44 struct EmbeddedObjectRef_Impl
;
46 class SVT_DLLPUBLIC EmbeddedObjectRef
48 EmbeddedObjectRef_Impl
* mpImpl
;
50 SVT_DLLPRIVATE SvStream
* GetGraphicStream( bool bUpdate
) const;
51 SVT_DLLPRIVATE
void GetReplacement( bool bUpdate
);
53 EmbeddedObjectRef
& operator = ( const EmbeddedObjectRef
& );
56 static void DrawPaintReplacement( const Rectangle
&rRect
, const OUString
&rText
, OutputDevice
*pOut
);
57 static void DrawShading( const Rectangle
&rRect
, OutputDevice
*pOut
);
58 static bool TryRunningState( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& );
59 static void SetGraphicToContainer( const Graphic
& rGraphic
,
60 comphelper::EmbeddedObjectContainer
& aContainer
,
61 const OUString
& aName
,
62 const OUString
& aMediaType
);
64 static ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
> GetGraphicReplacementStream(
65 sal_Int64 nViewAspect
,
66 const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>&,
67 OUString
* pMediaType
)
70 const com::sun::star::uno::Reference
<com::sun::star::embed::XEmbeddedObject
>& operator->() const;
71 const com::sun::star::uno::Reference
<com::sun::star::embed::XEmbeddedObject
>& GetObject() const;
73 // default constructed object; needs further assignment before it can be used
76 // assign a previously default constructed object
77 void Assign( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
79 // create object for a certain view aspect
80 EmbeddedObjectRef( const ::com::sun::star::uno::Reference
< ::com::sun::star::embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
);
83 EmbeddedObjectRef( const EmbeddedObjectRef
& );
85 // assigning to a container enables the object to exchange graphical representations with a storage
86 void AssignToContainer( comphelper::EmbeddedObjectContainer
* pContainer
, const OUString
& rPersistName
);
87 comphelper::EmbeddedObjectContainer
* GetContainer() const;
89 sal_Int64
GetViewAspect() const;
90 void SetViewAspect( sal_Int64 nAspect
);
91 const Graphic
* GetGraphic( OUString
* pMediaType
= NULL
) const;
93 // the original size of the object ( size of the icon for iconified object )
94 // no conversion is done if no target mode is provided
95 Size
GetSize( MapMode
* pTargetMapMode
= NULL
) const;
97 void SetGraphic( const Graphic
& rGraphic
, const OUString
& rMediaType
);
98 void SetGraphicStream(
99 const ::com::sun::star::uno::Reference
< ::com::sun::star::io::XInputStream
>& xInGrStream
,
100 const OUString
& rMediaType
);
102 void UpdateReplacement();
103 void UpdateReplacementOnDemand();
104 void Lock( bool bLock
= true );
108 bool IsLocked() const;
109 bool IsChart() const;
111 OUString
GetChartType();
114 // Provides a graphic version number for the fetchable Graphic during this object's lifetime. Internally,
115 // that number is incremented at each change of the Graphic. This mechanism is needed to identify if a
116 // remembered Graphic (e.g. primitives) has changed compared to the current one, but without actively
117 // fetching the Graphic what would be too expensive e.g. for charts
118 sal_uInt32
getGraphicVersion() const;
119 void SetDefaultSizeForChart( const Size
& rSizeIn_100TH_MM
);//#i103460# charts do not necessaryly 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
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */