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 throw( NS_UNO::Exception ); 76 static NS_UNO::Reference< NS_IO::XInputStream > GetGraphicReplacementStream( 77 sal_Int64 nViewAspect, 78 const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >&, 79 ::rtl::OUString* pMediaType ) 80 throw(); 81 82 // default constructed object; needs further assignment before it can be used 83 EmbeddedObjectRef(); 84 85 // assign a previously default constructed object 86 void Assign( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect ); 87 88 // create object for a certain view aspect 89 EmbeddedObjectRef( const NS_UNO::Reference < NS_EMBED::XEmbeddedObject >& xObj, sal_Int64 nAspect ); 90 91 ~EmbeddedObjectRef(); 92 EmbeddedObjectRef( const EmbeddedObjectRef& ); 93 sal_Bool TryRunningState(); 94 95 // assigning to a container enables the object to exchange graphical representations with a storage 96 void AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName ); 97 comphelper::EmbeddedObjectContainer* GetContainer() const; 98 99 ::rtl::OUString GetPersistName() const; 100 sal_Int64 GetViewAspect() const; 101 void SetViewAspect( sal_Int64 nAspect ); 102 Graphic* GetGraphic( ::rtl::OUString* pMediaType=0 ) const; 103 104 // the original size of the object ( size of the icon for iconified object ) 105 // no conversion is done if no target mode is provided 106 Size GetSize( MapMode* pTargetMapMode = NULL ) const; 107 108 // the following method tries to get the HC graphic if it is possible, otherwise returns NULL 109 Graphic* GetHCGraphic() const; 110 111 void SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType ); 112 void SetGraphicStream( 113 const ::com::sun::star::uno::Reference< ::com::sun::star::io::XInputStream >& xInGrStream, 114 const ::rtl::OUString& rMediaType ); 115 UpdateReplacement()116 void UpdateReplacement() { GetReplacement( sal_True ); } 117 void UpdateReplacementOnDemand(); 118 MapUnit GetMapUnit() const; 119 void Lock( sal_Bool bLock = sal_True ); 120 sal_Bool IsLocked() const; 121 void Clear(); is() const122 sal_Bool is() const { return mxObj.is(); } 123 124 sal_Bool IsChart() const; 125 rtl::OUString GetChartType(); 126 127 // #i104867# 128 // Provides a graphic version number for the fetchable Graphic during this object's lifetime. Internally, 129 // that number is incremented at each change of the Graphic. This mechanism is needed to identify if a 130 // remembered Graphic (e.g. primitives) has changed compared to the current one, but without actively 131 // fetching the Graphic what would be too expensive e.g. for charts 132 sal_uInt32 getGraphicVersion() const; 133 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 134 }; 135 } 136 137 #endif 138