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 SC_XCL97ESC_HXX 25 #define SC_XCL97ESC_HXX 26 27 #include <memory> 28 #include <tools/table.hxx> 29 #include <tools/stack.hxx> 30 #include <filter/msfilter/escherex.hxx> 31 #include "xlescher.hxx" 32 #include "xeroot.hxx" 33 34 // 0 = Export TBX form controls, 1 = Export OCX form controls. 35 //#define EXC_EXP_OCX_CTRL 0 36 37 namespace utl { class TempFile; } 38 39 // ============================================================================ 40 41 class SvStream; 42 43 class XclEscherExGlobal : public EscherExGlobal, protected XclExpRoot 44 { 45 public: 46 explicit XclEscherExGlobal( const XclExpRoot& rRoot ); 47 48 private: 49 /** Overloaded to create a new temporary file and return its stream. */ 50 virtual SvStream* ImplQueryPictureStream(); 51 52 private: 53 ::std::auto_ptr< ::utl::TempFile > mxPicTempFile; 54 ::std::auto_ptr< SvStream > mxPicStrm; 55 }; 56 57 // ============================================================================ 58 59 class XclObj; 60 class XclExpDffAnchorBase; 61 class XclEscherHostAppData; 62 class XclEscherClientData; 63 class XclEscherClientTextbox; 64 //delete for exporting OCX 65 //#if EXC_EXP_OCX_CTRL 66 class XclExpOcxControlObj; 67 //#else 68 class XclExpTbxControlObj; 69 //#endif 70 71 class XclEscherEx : public EscherEx, protected XclExpRoot 72 { 73 public: 74 explicit XclEscherEx( 75 const XclExpRoot& rRoot, 76 XclExpObjectManager& rObjMgr, 77 SvStream& rStrm, 78 const XclEscherEx* pParent = 0 ); 79 virtual ~XclEscherEx(); 80 81 /** Called by MSODRAWING record constructors to initialize the DFF stream 82 fragment they will own. returns the DFF fragment identifier. */ 83 sal_uInt32 InitNextDffFragment(); 84 /** Called after some data has been written to the DFF stream, to update 85 the end position of the DFF fragment owned by an MSODRAWING record. */ 86 void UpdateDffFragmentEnd(); 87 88 /** Returns the position of the specified DFF stream fragment. */ 89 sal_uInt32 GetDffFragmentPos( sal_uInt32 nFragmentKey ); 90 /** Returns the size of the specified DFF stream fragment. */ 91 sal_uInt32 GetDffFragmentSize( sal_uInt32 nFragmentKey ); 92 /** Returns true, if there is more data left in the DFF stream than owned 93 by the last MSODRAWING record. */ 94 bool HasPendingDffData(); 95 96 /** Creates a new DFF client anchor object and calculates the anchor 97 position of the passed object. Caller takes ownership! */ 98 XclExpDffAnchorBase* CreateDffAnchor( const SdrObject& rSdrObj ) const; 99 100 virtual EscherExHostAppData* StartShape( 101 const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape>& rxShape, 102 const Rectangle* pChildAnchor ); 103 virtual void EndShape( sal_uInt16 nShapeType, sal_uInt32 nShapeID ); 104 virtual EscherExHostAppData* EnterAdditionalTextGroup(); 105 106 /// Flush and merge PicStream into EscherStream 107 void EndDocument(); 108 //delete for exporting OCX 109 //#if EXC_EXP_OCX_CTRL 110 /** Creates an OCX form control OBJ record from the passed form control. 111 @descr Writes the form control data to the 'Ctls' stream. */ 112 XclExpOcxControlObj* CreateOCXCtrlObj( 113 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, 114 const Rectangle* pChildAnchor ); 115 /** Creates a TBX form control OBJ record from the passed form control. */ 116 XclExpTbxControlObj* CreateTBXCtrlObj( 117 ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape > xShape, 118 const Rectangle* pChildAnchor ); 119 120 121 private: 122 SotStorageStreamRef mxCtlsStrm; /// The 'Ctls' stream. 123 //#else 124 125 private: 126 /** Tries to get the name of a Basic macro from a control. */ 127 void ConvertTbxMacro( 128 XclExpTbxControlObj& rTbxCtrlObj, 129 ::com::sun::star::uno::Reference< 130 ::com::sun::star::awt::XControlModel > xCtrlModel ); 131 //#endif 132 133 void DeleteCurrAppData(); 134 135 private: 136 XclExpObjectManager& mrObjMgr; 137 Stack aStack; 138 XclObj* pCurrXclObj; 139 XclEscherHostAppData* pCurrAppData; 140 XclEscherClientData* pTheClientData; // always the same 141 XclEscherClientTextbox* pAdditionalText; 142 sal_uInt16 nAdditionalText; 143 sal_uInt32 mnNextKey; 144 bool mbIsRootDff; 145 }; 146 147 // --- class XclEscherHostAppData ------------------------------------ 148 149 class XclEscherHostAppData : public EscherExHostAppData 150 { 151 private: 152 sal_Bool bStackedGroup; 153 154 public: XclEscherHostAppData()155 XclEscherHostAppData() : bStackedGroup( sal_False ) 156 {} SetStackedGroup(sal_Bool b)157 inline void SetStackedGroup( sal_Bool b ) { bStackedGroup = b; } IsStackedGroup() const158 inline sal_Bool IsStackedGroup() const { return bStackedGroup; } 159 }; 160 161 162 163 // ============================================================================ 164 165 // --- class XclEscherClientData ------------------------------------- 166 167 class XclEscherClientData : public EscherExClientRecord_Base 168 { 169 public: XclEscherClientData()170 XclEscherClientData() {} 171 virtual void WriteData( EscherEx& rEx ) const; 172 }; 173 174 175 // --- class XclEscherClientTextbox ---------------------------------- 176 177 class SdrTextObj; 178 179 class XclEscherClientTextbox : public EscherExClientRecord_Base, protected XclExpRoot 180 { 181 private: 182 const SdrTextObj& rTextObj; 183 XclObj* pXclObj; 184 185 public: 186 XclEscherClientTextbox( 187 const XclExpRoot& rRoot, 188 const SdrTextObj& rObj, 189 XclObj* pObj ); 190 191 //! ONLY for the AdditionalText mimic SetXclObj(XclObj * p)192 inline void SetXclObj( XclObj* p ) { pXclObj = p; } 193 194 virtual void WriteData( EscherEx& rEx ) const; 195 }; 196 197 198 199 #endif // _XCL97ESC_HXX 200