11d2dbeb0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 31d2dbeb0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 41d2dbeb0SAndrew Rist * or more contributor license agreements. See the NOTICE file 51d2dbeb0SAndrew Rist * distributed with this work for additional information 61d2dbeb0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 71d2dbeb0SAndrew Rist * to you under the Apache License, Version 2.0 (the 81d2dbeb0SAndrew Rist * "License"); you may not use this file except in compliance 91d2dbeb0SAndrew Rist * with the License. You may obtain a copy of the License at 101d2dbeb0SAndrew Rist * 111d2dbeb0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 121d2dbeb0SAndrew Rist * 131d2dbeb0SAndrew Rist * Unless required by applicable law or agreed to in writing, 141d2dbeb0SAndrew Rist * software distributed under the License is distributed on an 151d2dbeb0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 161d2dbeb0SAndrew Rist * KIND, either express or implied. See the License for the 171d2dbeb0SAndrew Rist * specific language governing permissions and limitations 181d2dbeb0SAndrew Rist * under the License. 191d2dbeb0SAndrew Rist * 201d2dbeb0SAndrew Rist *************************************************************/ 211d2dbeb0SAndrew Rist 221d2dbeb0SAndrew Rist 23cdf0e10cSrcweir /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil -*- */ 24cdf0e10cSrcweir /// @HTML 25cdf0e10cSrcweir 26cdf0e10cSrcweir #ifndef SW_WRITERHELPER 27cdf0e10cSrcweir #define SW_WRITERHELPER 28cdf0e10cSrcweir 29cdf0e10cSrcweir #include <typeinfo> 30cdf0e10cSrcweir #include <vector> 31cdf0e10cSrcweir #include <map> 32cdf0e10cSrcweir #include <com/sun/star/embed/XEmbeddedObject.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <sfx2/objsh.hxx> 35cdf0e10cSrcweir #include "types.hxx" 36cdf0e10cSrcweir #include <svl/itempool.hxx> //SfxItemPool 37cdf0e10cSrcweir #include <svl/itemset.hxx> //SfxItemSet 38cdf0e10cSrcweir #include <format.hxx> //SwFmt 39cdf0e10cSrcweir #include <node.hxx> //SwCntntNode 40cdf0e10cSrcweir #include <pam.hxx> //SwPaM 41cdf0e10cSrcweir #include <tools/poly.hxx> //Polygon, PolyPolygon 42cdf0e10cSrcweir #include <doc.hxx> //SwDoc 43cdf0e10cSrcweir 44cdf0e10cSrcweir //Uncomment to dump debugging streams of graphics 45cdf0e10cSrcweir #if OSL_DEBUG_LEVEL > 1 46cdf0e10cSrcweir //# define DEBUGDUMP 47cdf0e10cSrcweir #endif 48cdf0e10cSrcweir 49cdf0e10cSrcweir class SwTxtFmtColl; 50cdf0e10cSrcweir class SwCharFmt; 51cdf0e10cSrcweir class SdrObject; 52cdf0e10cSrcweir class SdrOle2Obj; 53cdf0e10cSrcweir class OutlinerParaObject; 54cdf0e10cSrcweir class SdrTextObj; 55cdf0e10cSrcweir class SwNumFmt; 56cdf0e10cSrcweir class SwTxtNode; 57cdf0e10cSrcweir class SwNoTxtNode; 58cdf0e10cSrcweir class SwFmtCharFmt; 59cdf0e10cSrcweir class Graphic; 60cdf0e10cSrcweir class SwDoc; 61cdf0e10cSrcweir class SwNumRule; 62cdf0e10cSrcweir 63cdf0e10cSrcweir namespace sw 64cdf0e10cSrcweir { 65cdf0e10cSrcweir namespace util 66cdf0e10cSrcweir { 67cdf0e10cSrcweir class ItemSort 68cdf0e10cSrcweir : public std::binary_function<sal_uInt16, sal_uInt16, bool> 69cdf0e10cSrcweir { 70cdf0e10cSrcweir public: 71cdf0e10cSrcweir bool operator()(sal_uInt16 nA, sal_uInt16 nB) const; 72cdf0e10cSrcweir }; 73cdf0e10cSrcweir } 74cdf0e10cSrcweir } 75cdf0e10cSrcweir 76cdf0e10cSrcweir namespace sw 77cdf0e10cSrcweir { 78cdf0e10cSrcweir /// STL container of Paragraph Styles (SwTxtFmtColl) 79cdf0e10cSrcweir typedef std::vector<SwTxtFmtColl *> ParaStyles; 80cdf0e10cSrcweir /// STL iterator for ParaStyles 81cdf0e10cSrcweir typedef ParaStyles::iterator ParaStyleIter; 82cdf0e10cSrcweir /// STL container of SfxPoolItems (Attributes) 83cdf0e10cSrcweir typedef std::map<sal_uInt16, const SfxPoolItem *, sw::util::ItemSort> PoolItems; 84cdf0e10cSrcweir /// STL const iterator for ParaStyles 85cdf0e10cSrcweir typedef PoolItems::const_iterator cPoolItemIter; 86cdf0e10cSrcweir 87cdf0e10cSrcweir 88cdf0e10cSrcweir /** Make exporting a Writer Frame easy 89cdf0e10cSrcweir 90cdf0e10cSrcweir In word all frames are effectively anchored to character or as 91cdf0e10cSrcweir character. This is nice and simple, writer is massively complex in this 92cdf0e10cSrcweir area, so this sw::Frame simplies matters by providing a single unified 93cdf0e10cSrcweir view of the multitute of elements in writer and their differing quirks. 94cdf0e10cSrcweir 95cdf0e10cSrcweir A sw::Frame wraps a writer frame and is guaranted to have a suitable 96cdf0e10cSrcweir anchor position available from it. It hides much of the needless 97cdf0e10cSrcweir complexity of the multitude of floating/inline elements in writer, it... 98cdf0e10cSrcweir 99cdf0e10cSrcweir Guarantees an anchor position for a frame. 100cdf0e10cSrcweir Provides a readable way to see if we are anchored inline. (as character) 101cdf0e10cSrcweir Provides a simple way to flag what type of entity this frame describes. 102cdf0e10cSrcweir Provides the size of the element as drawn by writer. 103cdf0e10cSrcweir 104cdf0e10cSrcweir @author 105cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 106cdf0e10cSrcweir */ 107cdf0e10cSrcweir class Frame 108cdf0e10cSrcweir { 109cdf0e10cSrcweir public: 11041623124SJian Hong Cheng enum WriterSource {eTxtBox, eGraphic, eOle, eDrawing, eFormControl,eBulletGrf};//For i120928,add Grf Bul Type 111cdf0e10cSrcweir private: 112cdf0e10cSrcweir const SwFrmFmt* mpFlyFrm; 113cdf0e10cSrcweir SwPosition maPos; 114cdf0e10cSrcweir Size maSize; 115cdf0e10cSrcweir // --> OD 2007-04-19 #i43447# 116cdf0e10cSrcweir // Size of the frame in the layout. 117cdf0e10cSrcweir // Especially needed for graphics, whose layout size can differ from its 118cdf0e10cSrcweir // size, because it is scaled into its environment. 119cdf0e10cSrcweir Size maLayoutSize; 120cdf0e10cSrcweir // <-- 121cdf0e10cSrcweir WriterSource meWriterType; 122cdf0e10cSrcweir const SwNode *mpStartFrameContent; 123cdf0e10cSrcweir bool mbIsInline; 12441623124SJian Hong Cheng bool mbForBullet:1; 12541623124SJian Hong Cheng Graphic maGrf; 126cdf0e10cSrcweir public: 127cdf0e10cSrcweir Frame(const SwFrmFmt &rFlyFrm, const SwPosition &rPos); 12841623124SJian Hong Cheng Frame(const Graphic&, const SwPosition &); 12941623124SJian Hong Cheng //End 130cdf0e10cSrcweir /** Get the writer SwFrmFmt that this object describes 131cdf0e10cSrcweir 132cdf0e10cSrcweir @return 133cdf0e10cSrcweir The wrapped SwFrmFmt 134cdf0e10cSrcweir */ GetFrmFmt() const135cdf0e10cSrcweir const SwFrmFmt &GetFrmFmt() const { return *mpFlyFrm; } 136cdf0e10cSrcweir 137cdf0e10cSrcweir /** Get the position this frame is anchored at 138cdf0e10cSrcweir 139cdf0e10cSrcweir @return 140cdf0e10cSrcweir The anchor position of this frame 141cdf0e10cSrcweir */ GetPosition() const142cdf0e10cSrcweir const SwPosition &GetPosition() const { return maPos; } 143cdf0e10cSrcweir 144cdf0e10cSrcweir /** Get the node this frame is anchored into 145cdf0e10cSrcweir 146cdf0e10cSrcweir @return 147cdf0e10cSrcweir The SwTxtNode this frame is anchored inside 148cdf0e10cSrcweir */ GetCntntNode() const149cdf0e10cSrcweir const SwCntntNode *GetCntntNode() const 150cdf0e10cSrcweir { return maPos.nNode.GetNode().GetCntntNode(); } 151cdf0e10cSrcweir 152cdf0e10cSrcweir /** Get the type of frame that this wraps 153cdf0e10cSrcweir 154cdf0e10cSrcweir @return 155cdf0e10cSrcweir a WriterSource which describes the source type of this wrapper 156cdf0e10cSrcweir */ GetWriterType() const157cdf0e10cSrcweir WriterSource GetWriterType() const { return meWriterType; } 158cdf0e10cSrcweir 159cdf0e10cSrcweir /** Is this frame inline (as character) 160cdf0e10cSrcweir 161cdf0e10cSrcweir @return 162cdf0e10cSrcweir whether this is inline or not 163cdf0e10cSrcweir */ 164cdf0e10cSrcweir bool IsInline() const; 165cdf0e10cSrcweir 166cdf0e10cSrcweir 167cdf0e10cSrcweir /** Even if the frame isn't an inline frame, force it to behave as one 168cdf0e10cSrcweir 169cdf0e10cSrcweir There are a variety of circumstances where word cannot have 170cdf0e10cSrcweir anything except inline elements, e.g. inside frames. So its easier 171cdf0e10cSrcweir to force this sw::Frame into behaving as one, instead of special 172cdf0e10cSrcweir casing export code all over the place. 173cdf0e10cSrcweir 174cdf0e10cSrcweir */ 175cdf0e10cSrcweir void ForceTreatAsInline(); 176cdf0e10cSrcweir 177cdf0e10cSrcweir /** Get the first node of content in the frame 178cdf0e10cSrcweir 179cdf0e10cSrcweir @return 180cdf0e10cSrcweir the first node of content in the frame, might not be any at all. 181cdf0e10cSrcweir */ GetContent() const182cdf0e10cSrcweir const SwNode *GetContent() const { return mpStartFrameContent; } GetGraphic() const18341623124SJian Hong Cheng const Graphic &GetGraphic() const { return maGrf; } HasGraphic() const18441623124SJian Hong Cheng bool HasGraphic() const { return mbForBullet; } 185cdf0e10cSrcweir 186cdf0e10cSrcweir 187cdf0e10cSrcweir /** Does this sw::Frame refer to the same writer content as another 188cdf0e10cSrcweir 189cdf0e10cSrcweir @return 190cdf0e10cSrcweir if the two sw::Frames are handling the same writer frame 191cdf0e10cSrcweir */ RefersToSameFrameAs(const Frame & rOther) const192cdf0e10cSrcweir bool RefersToSameFrameAs(const Frame &rOther) const 193cdf0e10cSrcweir { 19441623124SJian Hong Cheng if (mbForBullet && rOther.mbForBullet) 19541623124SJian Hong Cheng return (maGrf == rOther.maGrf); 19641623124SJian Hong Cheng else if ((!mbForBullet) && (!rOther.mbForBullet)) 19741623124SJian Hong Cheng return (mpFlyFrm == rOther.mpFlyFrm); 198*9bd1ff0dSPavel Janík 199*9bd1ff0dSPavel Janík return false; 200cdf0e10cSrcweir } 201cdf0e10cSrcweir 202cdf0e10cSrcweir /** The Size of the contained element 203cdf0e10cSrcweir 204cdf0e10cSrcweir @return 205cdf0e10cSrcweir the best size to use to export to word 206cdf0e10cSrcweir */ GetSize() const207cdf0e10cSrcweir const Size GetSize() const { return maSize; } 208cdf0e10cSrcweir 209cdf0e10cSrcweir /** The layout size of the contained element 210cdf0e10cSrcweir 211cdf0e10cSrcweir OD 2007-04-19 #i43447# 212cdf0e10cSrcweir Needed for graphics, which are scaled into its environment 213cdf0e10cSrcweir 214cdf0e10cSrcweir @return layout size 215cdf0e10cSrcweir */ GetLayoutSize() const216cdf0e10cSrcweir const Size GetLayoutSize() const 217cdf0e10cSrcweir { 218cdf0e10cSrcweir return maLayoutSize; 219cdf0e10cSrcweir } 220cdf0e10cSrcweir }; 221cdf0e10cSrcweir 222cdf0e10cSrcweir /// STL container of Frames 223cdf0e10cSrcweir typedef std::vector<Frame> Frames; 224cdf0e10cSrcweir /// STL iterator for Frames 225cdf0e10cSrcweir typedef std::vector<Frame>::iterator FrameIter; 226cdf0e10cSrcweir } 227cdf0e10cSrcweir 228cdf0e10cSrcweir namespace sw 229cdf0e10cSrcweir { 230cdf0e10cSrcweir namespace util 231cdf0e10cSrcweir { 232cdf0e10cSrcweir /** Provide a dynamic_cast style cast for SfxPoolItems 233cdf0e10cSrcweir 234cdf0e10cSrcweir A SfxPoolItem generally need to be cast back to its original type 235cdf0e10cSrcweir to be useful, which is both tedious and errorprone. So item_cast is 236cdf0e10cSrcweir a helper template to aid the process and test if the cast is 237cdf0e10cSrcweir correct. 238cdf0e10cSrcweir 239cdf0e10cSrcweir @param rItem 240cdf0e10cSrcweir The SfxPoolItem which is to be casted 241cdf0e10cSrcweir 242cdf0e10cSrcweir @tplparam T 243cdf0e10cSrcweir A SfxPoolItem derived class to cast rItem to 244cdf0e10cSrcweir 245cdf0e10cSrcweir @return A rItem upcasted back to a T 246cdf0e10cSrcweir 247cdf0e10cSrcweir @exception std::bad_cast Thrown if the rItem was not a T 248cdf0e10cSrcweir 249cdf0e10cSrcweir @author 250cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 251cdf0e10cSrcweir */ item_cast(const SfxPoolItem & rItem)252cdf0e10cSrcweir template<class T> const T & item_cast(const SfxPoolItem &rItem) 253cdf0e10cSrcweir throw(std::bad_cast) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir if (!rItem.IsA(STATICTYPE(T))) 256cdf0e10cSrcweir throw std::bad_cast(); 257cdf0e10cSrcweir return static_cast<const T &>(rItem); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir /** Provide a dynamic_cast style cast for SfxPoolItems 261cdf0e10cSrcweir 262cdf0e10cSrcweir A SfxPoolItem generally need to be cast back to its original type 263cdf0e10cSrcweir to be useful, which is both tedious and errorprone. So item_cast is 264cdf0e10cSrcweir a helper template to aid the process and test if the cast is 265cdf0e10cSrcweir correct. 266cdf0e10cSrcweir 267cdf0e10cSrcweir @param pItem 268cdf0e10cSrcweir The SfxPoolItem which is to be casted 269cdf0e10cSrcweir 270cdf0e10cSrcweir @tplparam T 271cdf0e10cSrcweir A SfxPoolItem derived class to cast pItem to 272cdf0e10cSrcweir 273cdf0e10cSrcweir @return A pItem upcasted back to a T or 0 if pItem was not a T 274cdf0e10cSrcweir 275cdf0e10cSrcweir @author 276cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 277cdf0e10cSrcweir */ item_cast(const SfxPoolItem * pItem)278cdf0e10cSrcweir template<class T> const T * item_cast(const SfxPoolItem *pItem) 279cdf0e10cSrcweir { 280cdf0e10cSrcweir if (pItem && !pItem->IsA(STATICTYPE(T))) 281cdf0e10cSrcweir pItem = 0; 282cdf0e10cSrcweir return static_cast<const T *>(pItem); 283cdf0e10cSrcweir } 284cdf0e10cSrcweir 285cdf0e10cSrcweir /** Extract a SfxPoolItem derived property from a SwCntntNode 286cdf0e10cSrcweir 287cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 288cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 289cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 290cdf0e10cSrcweir 291cdf0e10cSrcweir ItemGet uses item_cast () on the retrived reference to test that the 292cdf0e10cSrcweir retrived property is of the type that the developer thinks it is. 293cdf0e10cSrcweir 294cdf0e10cSrcweir @param rNode 295cdf0e10cSrcweir The SwCntntNode to retrieve the property from 296cdf0e10cSrcweir 297cdf0e10cSrcweir @param eType 298cdf0e10cSrcweir The numeric identifier of the property to be retrieved 299cdf0e10cSrcweir 300cdf0e10cSrcweir @tplparam T 301cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 302cdf0e10cSrcweir 303cdf0e10cSrcweir @exception std::bad_cast Thrown if the property was not a T 304cdf0e10cSrcweir 305cdf0e10cSrcweir @return The T requested 306cdf0e10cSrcweir 307cdf0e10cSrcweir @author 308cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 309cdf0e10cSrcweir */ ItemGet(const SwCntntNode & rNode,sal_uInt16 eType)310cdf0e10cSrcweir template<class T> const T & ItemGet(const SwCntntNode &rNode, 311cdf0e10cSrcweir sal_uInt16 eType) throw(std::bad_cast) 312cdf0e10cSrcweir { 313cdf0e10cSrcweir return item_cast<T>(rNode.GetAttr(eType)); 314cdf0e10cSrcweir } 315cdf0e10cSrcweir 316cdf0e10cSrcweir /** Extract a SfxPoolItem derived property from a SwFmt 317cdf0e10cSrcweir 318cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 319cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 320cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 321cdf0e10cSrcweir 322cdf0e10cSrcweir ItemGet uses item_cast () on the retrived reference to test that the 323cdf0e10cSrcweir retrived property is of the type that the developer thinks it is. 324cdf0e10cSrcweir 325cdf0e10cSrcweir @param rFmt 326cdf0e10cSrcweir The SwFmt to retrieve the property from 327cdf0e10cSrcweir 328cdf0e10cSrcweir @param eType 329cdf0e10cSrcweir The numeric identifier of the property to be retrieved 330cdf0e10cSrcweir 331cdf0e10cSrcweir @tplparam T 332cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 333cdf0e10cSrcweir 334cdf0e10cSrcweir @exception std::bad_cast Thrown if the property was not a T 335cdf0e10cSrcweir 336cdf0e10cSrcweir @author 337cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 338cdf0e10cSrcweir */ ItemGet(const SwFmt & rFmt,sal_uInt16 eType)339cdf0e10cSrcweir template<class T> const T & ItemGet(const SwFmt &rFmt, 340cdf0e10cSrcweir sal_uInt16 eType) throw(std::bad_cast) 341cdf0e10cSrcweir { 342cdf0e10cSrcweir return item_cast<T>(rFmt.GetFmtAttr(eType)); 343cdf0e10cSrcweir } 344cdf0e10cSrcweir 345cdf0e10cSrcweir /** Extract a SfxPoolItem derived property from a SfxItemSet 346cdf0e10cSrcweir 347cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 348cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 349cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 350cdf0e10cSrcweir 351cdf0e10cSrcweir ItemGet uses item_cast () on the retrived reference to test that the 352cdf0e10cSrcweir retrived property is of the type that the developer thinks it is. 353cdf0e10cSrcweir 354cdf0e10cSrcweir @param rSet 355cdf0e10cSrcweir The SfxItemSet to retrieve the property from 356cdf0e10cSrcweir 357cdf0e10cSrcweir @param eType 358cdf0e10cSrcweir The numeric identifier of the property to be retrieved 359cdf0e10cSrcweir 360cdf0e10cSrcweir @tplparam T 361cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 362cdf0e10cSrcweir 363cdf0e10cSrcweir @exception std::bad_cast Thrown if the property was not a T 364cdf0e10cSrcweir 365cdf0e10cSrcweir @return The T requested 366cdf0e10cSrcweir 367cdf0e10cSrcweir @author 368cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 369cdf0e10cSrcweir */ ItemGet(const SfxItemSet & rSet,sal_uInt16 eType)370cdf0e10cSrcweir template<class T> const T & ItemGet(const SfxItemSet &rSet, 371cdf0e10cSrcweir sal_uInt16 eType) throw(std::bad_cast) 372cdf0e10cSrcweir { 373cdf0e10cSrcweir return item_cast<T>(rSet.Get(eType)); 374cdf0e10cSrcweir } 375cdf0e10cSrcweir 376cdf0e10cSrcweir /** Extract a default SfxPoolItem derived property from a SfxItemPool 377cdf0e10cSrcweir 378cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 379cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 380cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 381cdf0e10cSrcweir 382cdf0e10cSrcweir DefaultItemGet returns a reference to the default property of a 383cdf0e10cSrcweir given SfxItemPool for a given property id, e.g. default fontsize 384cdf0e10cSrcweir 385cdf0e10cSrcweir DefaultItemGet uses item_cast () on the retrived reference to test 386cdf0e10cSrcweir that the retrived property is of the type that the developer thinks 387cdf0e10cSrcweir it is. 388cdf0e10cSrcweir 389cdf0e10cSrcweir @param rPool 390cdf0e10cSrcweir The SfxItemPool whose default property we want 391cdf0e10cSrcweir 392cdf0e10cSrcweir @param eType 393cdf0e10cSrcweir The numeric identifier of the default property to be retrieved 394cdf0e10cSrcweir 395cdf0e10cSrcweir @tplparam T 396cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 397cdf0e10cSrcweir 398cdf0e10cSrcweir @exception std::bad_cast Thrown if the property was not a T 399cdf0e10cSrcweir 400cdf0e10cSrcweir @return The T requested 401cdf0e10cSrcweir 402cdf0e10cSrcweir @author 403cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 404cdf0e10cSrcweir */ DefaultItemGet(const SfxItemPool & rPool,sal_uInt16 eType)405cdf0e10cSrcweir template<class T> const T & DefaultItemGet(const SfxItemPool &rPool, 406cdf0e10cSrcweir sal_uInt16 eType) throw(std::bad_cast) 407cdf0e10cSrcweir { 408cdf0e10cSrcweir return item_cast<T>(rPool.GetDefaultItem(eType)); 409cdf0e10cSrcweir } 410cdf0e10cSrcweir 411cdf0e10cSrcweir /** Extract a default SfxPoolItem derived property from a SwDoc 412cdf0e10cSrcweir 413cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 414cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 415cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 416cdf0e10cSrcweir 417cdf0e10cSrcweir DefaultItemGet returns a reference to the default property of a 418cdf0e10cSrcweir given SwDoc (Writer Document) for a given property id, e.g default 419cdf0e10cSrcweir fontsize 420cdf0e10cSrcweir 421cdf0e10cSrcweir DefaultItemGet uses item_cast () on the retrived reference to test 422cdf0e10cSrcweir that the retrived property is of the type that the developer thinks 423cdf0e10cSrcweir it is. 424cdf0e10cSrcweir 425cdf0e10cSrcweir @param rPool 426cdf0e10cSrcweir The SfxItemPool whose default property we want 427cdf0e10cSrcweir 428cdf0e10cSrcweir @param eType 429cdf0e10cSrcweir The numeric identifier of the default property to be retrieved 430cdf0e10cSrcweir 431cdf0e10cSrcweir @tplparam T 432cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 433cdf0e10cSrcweir 434cdf0e10cSrcweir @exception std::bad_cast Thrown if the property was not a T 435cdf0e10cSrcweir 436cdf0e10cSrcweir @return The T requested 437cdf0e10cSrcweir 438cdf0e10cSrcweir @author 439cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 440cdf0e10cSrcweir */ DefaultItemGet(const SwDoc & rDoc,sal_uInt16 eType)441cdf0e10cSrcweir template<class T> const T & DefaultItemGet(const SwDoc &rDoc, 442cdf0e10cSrcweir sal_uInt16 eType) throw(std::bad_cast) 443cdf0e10cSrcweir { 444cdf0e10cSrcweir return DefaultItemGet<T>(rDoc.GetAttrPool(), eType); 445cdf0e10cSrcweir } 446cdf0e10cSrcweir 447cdf0e10cSrcweir /** Return a pointer to a SfxPoolItem derived class if it exists in an 448cdf0e10cSrcweir SfxItemSet 449cdf0e10cSrcweir 450cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 451cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 452cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 453cdf0e10cSrcweir 454cdf0e10cSrcweir HasItem returns a pointer to the requested SfxPoolItem for a given 455cdf0e10cSrcweir property id if it exists in the SfxItemSet or its chain of parents, 456cdf0e10cSrcweir e.g. fontsize 457cdf0e10cSrcweir 458cdf0e10cSrcweir HasItem uses item_cast () on the retrived pointer to test that the 459cdf0e10cSrcweir retrived property is of the type that the developer thinks it is. 460cdf0e10cSrcweir 461cdf0e10cSrcweir @param rSet 462cdf0e10cSrcweir The SfxItemSet whose property we want 463cdf0e10cSrcweir 464cdf0e10cSrcweir @param eType 465cdf0e10cSrcweir The numeric identifier of the default property to be retrieved 466cdf0e10cSrcweir 467cdf0e10cSrcweir @tplparam T 468cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 469cdf0e10cSrcweir 470cdf0e10cSrcweir @return The T requested or 0 if no T found with id eType 471cdf0e10cSrcweir 472cdf0e10cSrcweir @author 473cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 474cdf0e10cSrcweir */ HasItem(const SfxItemSet & rSet,sal_uInt16 eType)475cdf0e10cSrcweir template<class T> const T* HasItem(const SfxItemSet &rSet, 476cdf0e10cSrcweir sal_uInt16 eType) 477cdf0e10cSrcweir { 478cdf0e10cSrcweir return item_cast<T>(rSet.GetItem(eType)); 479cdf0e10cSrcweir } 480cdf0e10cSrcweir 481cdf0e10cSrcweir /** Return a pointer to a SfxPoolItem derived class if it exists in an 482cdf0e10cSrcweir SwFmt 483cdf0e10cSrcweir 484cdf0e10cSrcweir Writer's attributes are retrieved by passing a numeric identifier 485cdf0e10cSrcweir and receiving a SfxPoolItem reference which must then typically be 486cdf0e10cSrcweir cast back to its original type which is both tedious and verbose. 487cdf0e10cSrcweir 488cdf0e10cSrcweir HasItem returns a pointer to the requested SfxPoolItem for a given 489cdf0e10cSrcweir property id if it exists in the SwFmt e.g. fontsize 490cdf0e10cSrcweir 491cdf0e10cSrcweir HasItem uses item_cast () on the retrived pointer to test that the 492cdf0e10cSrcweir retrived property is of the type that the developer thinks it is. 493cdf0e10cSrcweir 494cdf0e10cSrcweir @param rSet 495cdf0e10cSrcweir The SwFmt whose property we want 496cdf0e10cSrcweir 497cdf0e10cSrcweir @param eType 498cdf0e10cSrcweir The numeric identifier of the default property to be retrieved 499cdf0e10cSrcweir 500cdf0e10cSrcweir @tplparam T 501cdf0e10cSrcweir A SfxPoolItem derived class of the retrieved property 502cdf0e10cSrcweir 503cdf0e10cSrcweir @return The T requested or 0 if no T found with id eType 504cdf0e10cSrcweir 505cdf0e10cSrcweir @author 506cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 507cdf0e10cSrcweir */ HasItem(const SwFmt & rFmt,sal_uInt16 eType)508cdf0e10cSrcweir template<class T> const T* HasItem(const SwFmt &rFmt, 509cdf0e10cSrcweir sal_uInt16 eType) 510cdf0e10cSrcweir { 511cdf0e10cSrcweir return HasItem<T>(rFmt.GetAttrSet(), eType); 512cdf0e10cSrcweir } 513cdf0e10cSrcweir 514cdf0e10cSrcweir /** Get the Paragraph Styles of a SwDoc 515cdf0e10cSrcweir 516cdf0e10cSrcweir Writer's styles are in one of those dreaded macro based pre-STL 517cdf0e10cSrcweir containers. Give me an STL container of the paragraph styles 518cdf0e10cSrcweir instead. 519cdf0e10cSrcweir 520cdf0e10cSrcweir @param rDoc 521cdf0e10cSrcweir The SwDoc document to get the styles from 522cdf0e10cSrcweir 523cdf0e10cSrcweir @return A ParaStyles containing the SwDoc's Paragraph Styles 524cdf0e10cSrcweir 525cdf0e10cSrcweir @author 526cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 527cdf0e10cSrcweir */ 528cdf0e10cSrcweir ParaStyles GetParaStyles(const SwDoc &rDoc); 529cdf0e10cSrcweir 530cdf0e10cSrcweir 531cdf0e10cSrcweir /** Get a Paragraph Style which fits a given name 532cdf0e10cSrcweir 533cdf0e10cSrcweir Its surprisingly tricky to get a style when all you have is a name, 534cdf0e10cSrcweir but that's what this does 535cdf0e10cSrcweir 536cdf0e10cSrcweir @param rDoc 537cdf0e10cSrcweir The SwDoc document to search in 538cdf0e10cSrcweir 539cdf0e10cSrcweir @param rName 540cdf0e10cSrcweir The name of the style to search for 541cdf0e10cSrcweir 542cdf0e10cSrcweir @return A Paragraph Style if one exists which matches the name 543cdf0e10cSrcweir 544cdf0e10cSrcweir @author 545cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 546cdf0e10cSrcweir */ 547cdf0e10cSrcweir SwTxtFmtColl* GetParaStyle(SwDoc &rDoc, const String& rName); 548cdf0e10cSrcweir 549cdf0e10cSrcweir /** Get a Character Style which fits a given name 550cdf0e10cSrcweir 551cdf0e10cSrcweir Its surprisingly tricky to get a style when all you have is a name, 552cdf0e10cSrcweir but that's what this does 553cdf0e10cSrcweir 554cdf0e10cSrcweir @param rDoc 555cdf0e10cSrcweir The SwDoc document to search in 556cdf0e10cSrcweir 557cdf0e10cSrcweir @param rName 558cdf0e10cSrcweir The name of the style to search for 559cdf0e10cSrcweir 560cdf0e10cSrcweir @return A Character Style if one exists which matches the name 561cdf0e10cSrcweir 562cdf0e10cSrcweir @author 563cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 564cdf0e10cSrcweir */ 565cdf0e10cSrcweir SwCharFmt* GetCharStyle(SwDoc &rDoc, const String& rName); 566cdf0e10cSrcweir 567cdf0e10cSrcweir /** Sort sequence of Paragraph Styles by assigned outline style list level 568cdf0e10cSrcweir 569cdf0e10cSrcweir Sort ParaStyles in ascending order of assigned outline style list level, 570cdf0e10cSrcweir e.g. given Normal/Heading1/Heading2/.../Heading10 at their default 571cdf0e10cSrcweir assigned outline style list levels of body level/level 1/level 2/.../level 10 572cdf0e10cSrcweir 573cdf0e10cSrcweir OD 2009-02-04 #i98791# 574cdf0e10cSrcweir adjust the sorting algorithm due to introduced outline level attribute 575cdf0e10cSrcweir 576cdf0e10cSrcweir @param rStyles 577cdf0e10cSrcweir The ParaStyles to sort 578cdf0e10cSrcweir 579cdf0e10cSrcweir @author 580cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 581cdf0e10cSrcweir */ 582cdf0e10cSrcweir void SortByAssignedOutlineStyleListLevel(ParaStyles &rStyles); 583cdf0e10cSrcweir 584cdf0e10cSrcweir /** Get the SfxPoolItems of a SfxItemSet 585cdf0e10cSrcweir 586cdf0e10cSrcweir Writer's SfxPoolItems (attributes) are in one of those dreaded 587cdf0e10cSrcweir macro based pre-STL containers. Give me an STL container of the 588cdf0e10cSrcweir items instead. 589cdf0e10cSrcweir 590cdf0e10cSrcweir @param rSet 591cdf0e10cSrcweir The SfxItemSet to get the items from 592cdf0e10cSrcweir 593cdf0e10cSrcweir @param rItems 594cdf0e10cSrcweir The sw::PoolItems to put the items into 595cdf0e10cSrcweir 596cdf0e10cSrcweir @author 597cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 598cdf0e10cSrcweir */ 599cdf0e10cSrcweir void GetPoolItems(const SfxItemSet &rSet, PoolItems &rItems, bool bExportParentItemSet ); 600cdf0e10cSrcweir 601cdf0e10cSrcweir const SfxPoolItem *SearchPoolItems(const PoolItems &rItems, 602cdf0e10cSrcweir sal_uInt16 eType); 603cdf0e10cSrcweir HasItem(const sw::PoolItems & rItems,sal_uInt16 eType)604cdf0e10cSrcweir template<class T> const T* HasItem(const sw::PoolItems &rItems, 605cdf0e10cSrcweir sal_uInt16 eType) 606cdf0e10cSrcweir { 607cdf0e10cSrcweir return item_cast<T>(SearchPoolItems(rItems, eType)); 608cdf0e10cSrcweir } 609cdf0e10cSrcweir 610cdf0e10cSrcweir 611cdf0e10cSrcweir /** Remove properties from an SfxItemSet which a SwFmtCharFmt overrides 612cdf0e10cSrcweir 613cdf0e10cSrcweir Given an SfxItemSet and a SwFmtCharFmt remove from the rSet all the 614cdf0e10cSrcweir properties which the SwFmtCharFmt would override. An SfxItemSet 615cdf0e10cSrcweir contains attributes, and a SwFmtCharFmt is a "Character Style", 616cdf0e10cSrcweir so if the SfxItemSet contains bold and so does the character style 617cdf0e10cSrcweir then delete bold from the SfxItemSet 618cdf0e10cSrcweir 619cdf0e10cSrcweir @param 620cdf0e10cSrcweir rFmt the SwFmtCharFmt which describes the Character Style 621cdf0e10cSrcweir 622cdf0e10cSrcweir @param 623cdf0e10cSrcweir rSet the SfxItemSet from which we want to remove any properties 624cdf0e10cSrcweir which the rFmt would override 625cdf0e10cSrcweir 626cdf0e10cSrcweir @author 627cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 628cdf0e10cSrcweir 629cdf0e10cSrcweir @see #i24291# for examples 630cdf0e10cSrcweir */ 631cdf0e10cSrcweir void ClearOverridesFromSet(const SwFmtCharFmt &rFmt, SfxItemSet &rSet); 632cdf0e10cSrcweir 633cdf0e10cSrcweir /** Get the Floating elements in a SwDoc 634cdf0e10cSrcweir 635cdf0e10cSrcweir Writer's FrmFmts may or may not be anchored to some text content, 636cdf0e10cSrcweir e.g. Page Anchored elements will not be. For the winword export we 637cdf0e10cSrcweir need them to have something to be anchored to. So this method 638cdf0e10cSrcweir returns all the floating elements in a document as a STL container 639cdf0e10cSrcweir of sw::Frames which are guaranteed to have an appropiate anchor. 640cdf0e10cSrcweir 641cdf0e10cSrcweir @param rDoc 642cdf0e10cSrcweir The SwDoc document to get the styles from 643cdf0e10cSrcweir 644cdf0e10cSrcweir @param pPaM 645cdf0e10cSrcweir The SwPam to describe the selection in the document to get the 646cdf0e10cSrcweir elements from. 0 means the entire document. 647cdf0e10cSrcweir 648cdf0e10cSrcweir @return A Frames containing the selections Floating elements 649cdf0e10cSrcweir 650cdf0e10cSrcweir @author 651cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 652cdf0e10cSrcweir */ 653cdf0e10cSrcweir Frames GetFrames(const SwDoc &rDoc, SwPaM *pPaM = 0); 654cdf0e10cSrcweir 655cdf0e10cSrcweir /** Get the Frames anchored to a given node 656cdf0e10cSrcweir 657cdf0e10cSrcweir Given a container of frames, find the ones anchored to a given node 658cdf0e10cSrcweir 659cdf0e10cSrcweir @param rFrames 660cdf0e10cSrcweir The container of frames to search in 661cdf0e10cSrcweir 662cdf0e10cSrcweir @param rNode 663cdf0e10cSrcweir The SwNode to check for anchors to 664cdf0e10cSrcweir 665cdf0e10cSrcweir @return the Frames in rFrames anchored to rNode 666cdf0e10cSrcweir 667cdf0e10cSrcweir @author 668cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 669cdf0e10cSrcweir */ 670cdf0e10cSrcweir Frames GetFramesInNode(const Frames &rFrames, const SwNode &rNode); 671cdf0e10cSrcweir 672cdf0e10cSrcweir #if 0 673cdf0e10cSrcweir /** Get the Frames anchored for all nodes between two points 674cdf0e10cSrcweir 675cdf0e10cSrcweir Given a container of frames, find the ones anchored to the nodes 676cdf0e10cSrcweir from start to end. Half open sequence, i.e. those anchored to 677cdf0e10cSrcweir start, but not those anchored to end 678cdf0e10cSrcweir 679cdf0e10cSrcweir @param rFrames 680cdf0e10cSrcweir The container of frames to search in 681cdf0e10cSrcweir 682cdf0e10cSrcweir @param rStart 683cdf0e10cSrcweir The SwNode to start check for anchors from 684cdf0e10cSrcweir 685cdf0e10cSrcweir @param rEnd 686cdf0e10cSrcweir The SwNode to end check for anchors from 687cdf0e10cSrcweir 688cdf0e10cSrcweir @return the Frames in rFrames anchored to rNode 689cdf0e10cSrcweir 690cdf0e10cSrcweir @author 691cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 692cdf0e10cSrcweir */ 693cdf0e10cSrcweir Frames GetFramesBetweenNodes(const Frames &rFrames, 694cdf0e10cSrcweir const SwNode &rStart, const SwNode &rEnd); 695cdf0e10cSrcweir #endif 696cdf0e10cSrcweir /** Get the Numbering Format used on a paragraph 697cdf0e10cSrcweir 698cdf0e10cSrcweir There are two differing types of numbering formats that may be on a 699cdf0e10cSrcweir paragraph, normal and outline. The outline is that numbering you 700cdf0e10cSrcweir see in tools->outline numbering. Theres no difference in the 701cdf0e10cSrcweir numbering itself, just how you get it from the SwTxtNode. Needless 702cdf0e10cSrcweir to say the filter generally couldn't care less what type of 703cdf0e10cSrcweir numbering is in use. 704cdf0e10cSrcweir 705cdf0e10cSrcweir @param rTxtNode 706cdf0e10cSrcweir The SwTxtNode that is the paragraph 707cdf0e10cSrcweir 708cdf0e10cSrcweir @return A SwNumFmt pointer that describes the numbering level 709cdf0e10cSrcweir on this paragraph, or 0 if there is none. 710cdf0e10cSrcweir 711cdf0e10cSrcweir @author 712cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 713cdf0e10cSrcweir */ 714cdf0e10cSrcweir const SwNumFmt* GetNumFmtFromTxtNode(const SwTxtNode &rTxtNode); 715cdf0e10cSrcweir 716cdf0e10cSrcweir const SwNumRule* GetNumRuleFromTxtNode(const SwTxtNode &rTxtNd); 717cdf0e10cSrcweir const SwNumRule* GetNormalNumRuleFromTxtNode(const SwTxtNode &rTxtNd); 718cdf0e10cSrcweir 719cdf0e10cSrcweir 720cdf0e10cSrcweir /** Get the SwNoTxtNode associated with a SwFrmFmt if here is one 721cdf0e10cSrcweir 722cdf0e10cSrcweir There are two differing types of numbering formats that may be on a 723cdf0e10cSrcweir paragraph, normal and outline. The outline is that numbering you 724cdf0e10cSrcweir see in tools->outline numbering. Theres no difference in the 725cdf0e10cSrcweir numbering itself, just how you get it from the SwTxtNode. Needless 726cdf0e10cSrcweir to say the filter generally couldn't care less what type of 727cdf0e10cSrcweir numbering is in use. 728cdf0e10cSrcweir 729cdf0e10cSrcweir @param rFmt 730cdf0e10cSrcweir The SwFrmFmt that may describe a graphic 731cdf0e10cSrcweir 732cdf0e10cSrcweir @return A SwNoTxtNode pointer that describes the graphic of this 733cdf0e10cSrcweir frame if there is one, or 0 if there is none. 734cdf0e10cSrcweir 735cdf0e10cSrcweir @author 736cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 737cdf0e10cSrcweir */ 738cdf0e10cSrcweir SwNoTxtNode *GetNoTxtNodeFromSwFrmFmt(const SwFrmFmt &rFmt); 739cdf0e10cSrcweir 740cdf0e10cSrcweir /** Does a node have a "page break before" applied 741cdf0e10cSrcweir 742cdf0e10cSrcweir Both text nodes and tables in writer can have "page break before" 743cdf0e10cSrcweir This function gives a unified view to both entities 744cdf0e10cSrcweir 745cdf0e10cSrcweir @param rNode 746cdf0e10cSrcweir The SwNode to query the page break of 747cdf0e10cSrcweir 748cdf0e10cSrcweir @return true if there is a page break, false otherwise 749cdf0e10cSrcweir 750cdf0e10cSrcweir @author 751cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 752cdf0e10cSrcweir */ 753cdf0e10cSrcweir bool HasPageBreak(const SwNode &rNode); 754cdf0e10cSrcweir 755cdf0e10cSrcweir 756cdf0e10cSrcweir /** Make a best fit Polygon from a PolyPolygon 757cdf0e10cSrcweir 758cdf0e10cSrcweir For custom contours in writer we use a PolyPolygon, while word uses 759cdf0e10cSrcweir a simple polygon, so we need to try and make the best polygon from 760cdf0e10cSrcweir a PolyPolygon 761cdf0e10cSrcweir 762cdf0e10cSrcweir @param rPolyPoly 763cdf0e10cSrcweir The PolyPolygon to try and turn into a Polygon 764cdf0e10cSrcweir 765cdf0e10cSrcweir @return best fit Polygon from rPolyPoly 766cdf0e10cSrcweir 767cdf0e10cSrcweir @author 768cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 769cdf0e10cSrcweir */ 770cdf0e10cSrcweir Polygon PolygonFromPolyPolygon(const PolyPolygon &rPolyPoly); 771cdf0e10cSrcweir 772cdf0e10cSrcweir /** Determine if the font is the special Star|Open Symbol font 773cdf0e10cSrcweir 774cdf0e10cSrcweir @param rFontName 775cdf0e10cSrcweir The FontName to test for being Star|Open Symbol 776cdf0e10cSrcweir 777cdf0e10cSrcweir @return true if this is Star|Open Symbol 778cdf0e10cSrcweir 779cdf0e10cSrcweir @author 780cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 781cdf0e10cSrcweir */ 782cdf0e10cSrcweir bool IsStarSymbol(const String &rFontName); 783cdf0e10cSrcweir 784cdf0e10cSrcweir /** Make setting a drawing object's layer in a Writer document easy 785cdf0e10cSrcweir 786cdf0e10cSrcweir 787cdf0e10cSrcweir Word has the simple concept of a drawing object either in the 788cdf0e10cSrcweir foreground and in the background. We have an additional complexity 789cdf0e10cSrcweir that form components live in a seperate layer, which seems 790cdf0e10cSrcweir unnecessarily complicated. So in the winword filter we set the 791cdf0e10cSrcweir object's layer through this class with either SendObjectToHell for 792cdf0e10cSrcweir the bottom layer and SendObjectToHeaven for the top and we don't 793cdf0e10cSrcweir worry about the odd form layer design wrinkle. 794cdf0e10cSrcweir 795cdf0e10cSrcweir @author 796cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 797cdf0e10cSrcweir */ 798cdf0e10cSrcweir class SetLayer 799cdf0e10cSrcweir { 800cdf0e10cSrcweir private: 801cdf0e10cSrcweir sal_uInt8 mnHeavenLayer, mnHellLayer, mnFormLayer; 802cdf0e10cSrcweir enum Layer {eHeaven, eHell}; 803cdf0e10cSrcweir void SetObjectLayer(SdrObject &rObject, Layer eLayer) const; 804cdf0e10cSrcweir void Swap(SetLayer &rOther) throw(); 805cdf0e10cSrcweir public: 806cdf0e10cSrcweir 807cdf0e10cSrcweir /** Make Object live in the bottom drawing layer 808cdf0e10cSrcweir 809cdf0e10cSrcweir @param rObject 810cdf0e10cSrcweir The object to be set to the bottom layer 811cdf0e10cSrcweir */ 812cdf0e10cSrcweir void SendObjectToHell(SdrObject &rObject) const; 813cdf0e10cSrcweir 814cdf0e10cSrcweir /** Make Object lives in the top top layer 815cdf0e10cSrcweir 816cdf0e10cSrcweir @param rObject 817cdf0e10cSrcweir The object to be set to the bottom layer 818cdf0e10cSrcweir */ 819cdf0e10cSrcweir void SendObjectToHeaven(SdrObject &rObject) const; 820cdf0e10cSrcweir 821cdf0e10cSrcweir /** Normal constructor 822cdf0e10cSrcweir 823cdf0e10cSrcweir @param rDoc 824cdf0e10cSrcweir The Writer document whose drawing layers we will be inserting 825cdf0e10cSrcweir objects into 826cdf0e10cSrcweir */ 827cdf0e10cSrcweir SetLayer(const SwDoc &rDoc); 828cdf0e10cSrcweir 829cdf0e10cSrcweir SetLayer(const SetLayer &rOther) throw(); 830cdf0e10cSrcweir SetLayer& operator=(const SetLayer &rOther) throw(); 831cdf0e10cSrcweir }; 832cdf0e10cSrcweir } 833cdf0e10cSrcweir 834cdf0e10cSrcweir namespace hack 835cdf0e10cSrcweir { 836cdf0e10cSrcweir /** Map an ID valid in one SfxItemPool to its equivalent in another 837cdf0e10cSrcweir 838cdf0e10cSrcweir Given a WhichId (the id that identifies a property e.g. bold) which 839cdf0e10cSrcweir is correct in a given SfxItemPool, get the equivalent whichId in 840cdf0e10cSrcweir another SfxItemPool 841cdf0e10cSrcweir 842cdf0e10cSrcweir This arises because the drawing layer uses the same properties as 843cdf0e10cSrcweir writer e.g. SvxWeight, but for some reason uses different ids 844cdf0e10cSrcweir for the same properties as writer. 845cdf0e10cSrcweir 846cdf0e10cSrcweir @param rDestPool 847cdf0e10cSrcweir The SfxItemPool in whose terms the Id is returned 848cdf0e10cSrcweir 849cdf0e10cSrcweir @param rSrcPool 850cdf0e10cSrcweir The SfxItemPool in whose terms the Id is passed in 851cdf0e10cSrcweir 852cdf0e10cSrcweir @param nWhich 853cdf0e10cSrcweir The Id to transform from source to dest 854cdf0e10cSrcweir 855cdf0e10cSrcweir @return 0 on failure, the correct property Id on success 856cdf0e10cSrcweir 857cdf0e10cSrcweir @author 858cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 859cdf0e10cSrcweir */ 860cdf0e10cSrcweir sal_uInt16 TransformWhichBetweenPools(const SfxItemPool &rDestPool, 861cdf0e10cSrcweir const SfxItemPool &rSrcPool, sal_uInt16 nWhich); 862cdf0e10cSrcweir 863cdf0e10cSrcweir /** Map a SwDoc WhichId to the equivalent Id for a given SfxItemSet 864cdf0e10cSrcweir 865cdf0e10cSrcweir Given a WhichId (the id that identifies a property e.g. bold) which 866cdf0e10cSrcweir is correct for a Writer document, get the equivalent whichId which 867cdf0e10cSrcweir for a given SfxItemSet. 868cdf0e10cSrcweir 869cdf0e10cSrcweir This arises because the drawing layer uses the same properties as 870cdf0e10cSrcweir writer e.g. SvxWeight, but for some reason uses different ids 871cdf0e10cSrcweir for the same properties as writer. 872cdf0e10cSrcweir 873cdf0e10cSrcweir This is effectively the same as TransformWhichBetweenPools except 874cdf0e10cSrcweir at a slightly different layer. 875cdf0e10cSrcweir 876cdf0e10cSrcweir @param rSet 877cdf0e10cSrcweir The SfxItemSet in whose terms the Id is returned 878cdf0e10cSrcweir 879cdf0e10cSrcweir @param rDoc 880cdf0e10cSrcweir The SwDoc in whose terms the Id is passed in 881cdf0e10cSrcweir 882cdf0e10cSrcweir @param nWhich 883cdf0e10cSrcweir The Id to transform from writer to the SfxItemSet's domain 884cdf0e10cSrcweir 885cdf0e10cSrcweir @return 0 on failure, the correct SfxItemSet Id on success 886cdf0e10cSrcweir 887cdf0e10cSrcweir @author 888cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 889cdf0e10cSrcweir */ 890cdf0e10cSrcweir sal_uInt16 GetSetWhichFromSwDocWhich(const SfxItemSet &rSet, 891cdf0e10cSrcweir const SwDoc &rDoc, sal_uInt16 nWhich); 892cdf0e10cSrcweir 893cdf0e10cSrcweir 894cdf0e10cSrcweir /** Make inserting an OLE object into a Writer document easy 895cdf0e10cSrcweir 896cdf0e10cSrcweir The rest of Office uses SdrOle2Obj for their OLE objects, Writer 897cdf0e10cSrcweir doesn't, which makes things a bit difficult as this is the type of 898cdf0e10cSrcweir object that the escher import code shared by the MSOffice filters 899cdf0e10cSrcweir produces when it imports an OLE object. 900cdf0e10cSrcweir 901cdf0e10cSrcweir This utility class takes ownership of the OLE object away from a 902cdf0e10cSrcweir SdrOle2Obj and can massage it into the condition best suited to 903cdf0e10cSrcweir insertion into Writer. 904cdf0e10cSrcweir 905cdf0e10cSrcweir If the object was not transferred into Writer then it is deleted 906cdf0e10cSrcweir during destruction. 907cdf0e10cSrcweir 908cdf0e10cSrcweir @author 909cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 910cdf0e10cSrcweir */ 911cdf0e10cSrcweir class DrawingOLEAdaptor 912cdf0e10cSrcweir { 913cdf0e10cSrcweir private: 914cdf0e10cSrcweir String msOrigPersistName; 915cdf0e10cSrcweir com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject > mxIPRef; 916cdf0e10cSrcweir SfxObjectShell& mrPers; 917cdf0e10cSrcweir Graphic* mpGraphic; 918cdf0e10cSrcweir public: 919cdf0e10cSrcweir /** Take ownership of a SdrOle2Objs OLE object 920cdf0e10cSrcweir 921cdf0e10cSrcweir @param rObj 922cdf0e10cSrcweir The SdrOle2Obj whose OLE object we want to take control of 923cdf0e10cSrcweir 924cdf0e10cSrcweir @param rPers 925cdf0e10cSrcweir The SvPersist of a SwDoc (SwDoc::GetPersist()) into which we 926cdf0e10cSrcweir may want to move the object, or remove it from if unwanted. 927cdf0e10cSrcweir */ 928cdf0e10cSrcweir DrawingOLEAdaptor(SdrOle2Obj &rObj, SfxObjectShell &rPers); 929cdf0e10cSrcweir 930cdf0e10cSrcweir /// Destructor will destroy the owned OLE object if not transferred 931cdf0e10cSrcweir ~DrawingOLEAdaptor(); 932cdf0e10cSrcweir 933cdf0e10cSrcweir /** Transfer ownership of the OLE object to a document's SvPersist 934cdf0e10cSrcweir 935cdf0e10cSrcweir TransferToDoc moves the object into the persist under the name 936cdf0e10cSrcweir passed in. This name is then suitable to be used as an argument 937cdf0e10cSrcweir to SwDoc::InsertOLE. 938cdf0e10cSrcweir 939cdf0e10cSrcweir The object is no longer owned by the adaptor after this call, 940cdf0e10cSrcweir subsequent calls are an error and return false. 941cdf0e10cSrcweir 942cdf0e10cSrcweir @param rName 943cdf0e10cSrcweir The name to store the object under in the document. 944cdf0e10cSrcweir 945cdf0e10cSrcweir @return On success true is returned, otherwise false. On 946cdf0e10cSrcweir success rName is then suitable for user with SwDoc::InsertOLE 947cdf0e10cSrcweir */ 948cdf0e10cSrcweir bool TransferToDoc(::rtl::OUString &rName); 949cdf0e10cSrcweir private: 950cdf0e10cSrcweir /// No assigning allowed 951cdf0e10cSrcweir DrawingOLEAdaptor& operator=(const DrawingOLEAdaptor&); 952cdf0e10cSrcweir /// No copying allowed 953cdf0e10cSrcweir DrawingOLEAdaptor(const DrawingOLEAdaptor &rDoc); 954cdf0e10cSrcweir }; 955cdf0e10cSrcweir 956cdf0e10cSrcweir #ifdef DEBUGDUMP 957cdf0e10cSrcweir /** Create a SvStream to dump data to during debugging 958cdf0e10cSrcweir 959cdf0e10cSrcweir This creates a file in the program dir of OOo, delete the SvStream 960cdf0e10cSrcweir after you are done with it 961cdf0e10cSrcweir 962cdf0e10cSrcweir @param rSuffix 963cdf0e10cSrcweir The suffix that will be appened to this debugging file 964cdf0e10cSrcweir 965cdf0e10cSrcweir @return a SvStream to dump data to 966cdf0e10cSrcweir 967cdf0e10cSrcweir @author 968cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 969cdf0e10cSrcweir */ 970cdf0e10cSrcweir SvStream *CreateDebuggingStream(const String &rSuffix); 971cdf0e10cSrcweir 972cdf0e10cSrcweir /** Dump one SvStream to another 973cdf0e10cSrcweir 974cdf0e10cSrcweir @param rSrc 975cdf0e10cSrcweir The source stream 976cdf0e10cSrcweir 977cdf0e10cSrcweir @param rDest 978cdf0e10cSrcweir The destination stream 979cdf0e10cSrcweir 980cdf0e10cSrcweir @param nLen 981cdf0e10cSrcweir Optional Length of data to copy from rSrc to rDest, if unused copy 982cdf0e10cSrcweir all available data from rSrc 983cdf0e10cSrcweir 984cdf0e10cSrcweir @author 985cdf0e10cSrcweir <a href="mailto:cmc@openoffice.org">Caolán McNamara</a> 986cdf0e10cSrcweir */ 987cdf0e10cSrcweir void DumpStream(const SvStream &rSrc, SvStream &rDest, 988cdf0e10cSrcweir sal_uInt32 nLen = STREAM_SEEK_TO_END); 989cdf0e10cSrcweir #endif 990cdf0e10cSrcweir } 991cdf0e10cSrcweir } 992cdf0e10cSrcweir 993cdf0e10cSrcweir #endif 994cdf0e10cSrcweir /* vi:set tabstop=4 shiftwidth=4 expandtab: */ 995