1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _SVTOOLS_EMBEDHLP_HXX 25 #define _SVTOOLS_EMBEDHLP_HXX 26 27 #include "svtools/svtdllapi.h" 28 #include <com/sun/star/uno/Reference.hxx> 29 #include <com/sun/star/embed/XEmbeddedObject.hpp> 30 #include <com/sun/star/embed/Aspects.hpp> 31 #include <com/sun/star/io/XInputStream.hpp> 32 #include <vcl/graph.hxx> 33 #include <tools/mapunit.hxx> 34 #include <rtl/ustring.hxx> 35 36 #define NS_UNO ::com::sun::star::uno 37 #define NS_EMBED ::com::sun::star::embed 38 #define NS_IO ::com::sun::star::io 39 40 namespace comphelper 41 { 42 class EmbeddedObjectContainer; 43 } 44 45 class Rectangle; 46 class OutputDevice; 47 class String; 48 namespace svt 49 { 50 struct EmbeddedObjectRef_Impl; 51 class SVT_DLLPUBLIC EmbeddedObjectRef 52 { 53 EmbeddedObjectRef_Impl* mpImp; 54 NS_UNO::Reference < NS_EMBED::XEmbeddedObject > mxObj; 55 56 SVT_DLLPRIVATE SvStream* GetGraphicStream( sal_Bool bUpdate ) const; 57 /* SVT_DLLPRIVATE */ void GetReplacement( sal_Bool bUpdate ); 58 SVT_DLLPRIVATE void Construct_Impl(); 59 60 EmbeddedObjectRef& operator = ( const EmbeddedObjectRef& ); 61 62 public: operator ->() const63 const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& operator ->() const { return mxObj; } GetObject() const64 const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& GetObject() const { return mxObj; } 65 66 static void DrawPaintReplacement( const Rectangle &rRect, const String &rText, OutputDevice *pOut ); 67 static void DrawShading( const Rectangle &rRect, OutputDevice *pOut ); 68 static sal_Bool TryRunningState( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& ); 69 static void SetGraphicToContainer( const Graphic& rGraphic, 70 comphelper::EmbeddedObjectContainer& aContainer, 71 const ::rtl::OUString& aName, 72 const ::rtl::OUString& aMediaType ); 73 74 static sal_Bool ObjectIsModified( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& ); 75 static NS_UNO::Reference< NS_IO::XInputStream > GetGraphicReplacementStream( 76 sal_Int64 nViewAspect, 77 const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >&, 78 ::rtl::OUString* pMediaType ) 79 throw(); 80 81 // default constructed object; needs further assignment before it can be used 82 EmbeddedObjectRef(); 83 84 // assign a previously default constructed object 85 void Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect ); 86 87 // create object for a certain view aspect 88 EmbeddedObjectRef( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect ); 89 90 ~EmbeddedObjectRef(); 91 EmbeddedObjectRef( const EmbeddedObjectRef& ); 92 sal_Bool TryRunningState(); 93 94 // assigning to a container enables the object to exchange graphical representations with a storage 95 void AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName ); 96 comphelper::EmbeddedObjectContainer* GetContainer() const; 97 98 ::rtl::OUString GetPersistName() const; 99 sal_Int64 GetViewAspect() const; 100 void SetViewAspect( sal_Int64 nAspect ); 101 Graphic* GetGraphic( ::rtl::OUString* pMediaType=0 ) const; 102 103 // the original size of the object ( size of the icon for iconified object ) 104 // no conversion is done if no target mode is provided 105 Size GetSize( MapMode* pTargetMapMode = NULL ) const; 106 107 // the following method tries to get the HC graphic if it is possible, otherwise returns NULL 108 Graphic* GetHCGraphic() const; 109 110 void SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType ); 111 void SetGraphicStream( 112 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInGrStream, 113 const ::rtl::OUString& rMediaType ); 114 UpdateReplacement()115 void UpdateReplacement() { GetReplacement( sal_True ); } 116 void UpdateReplacementOnDemand(); 117 MapUnit GetMapUnit() const; 118 void Lock( sal_Bool bLock = sal_True ); 119 sal_Bool IsLocked() const; 120 void Clear(); is() const121 sal_Bool is() const { return mxObj.is(); } 122 123 sal_Bool IsChart() const; 124 rtl::OUString GetChartType(); 125 126 // #i104867# 127 // Provides a graphic version number for the fetchable Graphic during this object's lifetime. Internally, 128 // that number is incremented at each change of the Graphic. This mechanism is needed to identify if a 129 // remembered Graphic (e.g. primitives) has changed compared to the current one, but without actively 130 // fetching the Graphic what would be too expensive e.g. for charts 131 sal_uInt32 getGraphicVersion() const; 132 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 133 }; 134 } 135 136 #endif 137