1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 28 // MARKER(update_precomp.py): autogen include statement, do not remove 29 #include "precompiled_sw.hxx" 30 31 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp> 32 #include <com/sun/star/container/XChild.hpp> 33 #include <com/sun/star/embed/XClassifiedObject.hpp> 34 #include <com/sun/star/embed/XVisualObject.hpp> 35 #include <com/sun/star/embed/XComponentSupplier.hpp> 36 #include <com/sun/star/embed/EmbedStates.hpp> 37 #include <com/sun/star/embed/Aspects.hpp> 38 #include <com/sun/star/graphic/XGraphicProvider.hpp> 39 #include <svx/svxids.hrc> 40 #include <editeng/memberids.hrc> 41 42 #include <swtypes.hxx> 43 #include <cmdid.h> 44 45 #include <memory> 46 #include <hints.hxx> 47 #include <doc.hxx> 48 #include <IDocumentUndoRedo.hxx> 49 #include <docsh.hxx> 50 #include <editsh.hxx> 51 #include <swcli.hxx> 52 #include <ndindex.hxx> 53 #include <pam.hxx> 54 #include <ndnotxt.hxx> 55 #include <svx/unomid.hxx> 56 #include <unocrsr.hxx> 57 #include <unocrsrhelper.hxx> 58 #include <docstyle.hxx> 59 #include <dcontact.hxx> 60 #include <fmtcnct.hxx> 61 #include <ndole.hxx> 62 #include <frmfmt.hxx> 63 #include <frame.hxx> 64 #include <unotextrange.hxx> 65 #include <unotextcursor.hxx> 66 #include <unoparagraph.hxx> 67 #include <unomap.hxx> 68 #include <unoprnms.hxx> 69 #include <unoevent.hxx> 70 #include <com/sun/star/table/BorderLine.hpp> 71 #include <com/sun/star/util/XModifyBroadcaster.hpp> 72 #include <com/sun/star/table/ShadowFormat.hpp> 73 #include <com/sun/star/style/GraphicLocation.hpp> 74 #include <com/sun/star/text/GraphicCrop.hpp> 75 #include <com/sun/star/text/TextContentAnchorType.hpp> 76 #include <com/sun/star/text/XTextColumns.hpp> 77 #include <com/sun/star/text/WrapTextMode.hpp> 78 #include <com/sun/star/beans/PropertyAttribute.hpp> 79 #include <com/sun/star/drawing/PointSequenceSequence.hpp> 80 #include <com/sun/star/drawing/PointSequence.hpp> 81 #include <com/sun/star/drawing/ColorMode.hpp> 82 #include <tools/poly.hxx> 83 #include <swundo.hxx> 84 #include <unostyle.hxx> 85 #include <svx/svdmodel.hxx> 86 #include <svx/svdpage.hxx> 87 #include <editeng/brshitem.hxx> 88 #include <editeng/protitem.hxx> 89 #include <fmtornt.hxx> 90 #include <fmturl.hxx> 91 #include <editeng/lrspitem.hxx> 92 #include <editeng/ulspitem.hxx> 93 #include <editeng/boxitem.hxx> 94 #include <editeng/opaqitem.hxx> 95 #include <editeng/prntitem.hxx> 96 #include <editeng/shaditem.hxx> 97 #include <fmtsrnd.hxx> 98 #include <fmtfsize.hxx> 99 #include <grfatr.hxx> 100 #include <unoframe.hxx> 101 #include <fmtanchr.hxx> 102 #include <fmtclds.hxx> 103 #include <fmtcntnt.hxx> 104 #include <frmatr.hxx> 105 #include <ndtxt.hxx> 106 #include <ndgrf.hxx> 107 #include <vos/mutex.hxx> 108 #include <vcl/svapp.hxx> 109 #include <sfx2/printer.hxx> 110 #include <SwStyleNameMapper.hxx> 111 #include <xmloff/xmlcnitm.hxx> 112 #include <poolfmt.hxx> 113 #include <pagedesc.hxx> 114 #include <com/sun/star/style/XStyleFamiliesSupplier.hpp> 115 #include <tools/urlobj.hxx> 116 #include <editeng/frmdiritem.hxx> 117 #include <fmtfollowtextflow.hxx> 118 #include <fmtwrapinfluenceonobjpos.hxx> 119 #include <toolkit/helper/vclunohelper.hxx> 120 #include <switerator.hxx> 121 122 // from fefly1.cxx 123 extern sal_Bool lcl_ChkAndSetNewAnchor( const SwFlyFrm& rFly, SfxItemSet& rSet ); 124 125 using namespace ::com::sun::star; 126 using ::rtl::OUString; 127 128 using ::com::sun::star::frame::XModel; 129 using ::com::sun::star::container::XNameAccess; 130 using ::com::sun::star::style::XStyleFamiliesSupplier; 131 132 const sal_Char __FAR_DATA sPackageProtocol[] = "vnd.sun.star.Package:"; 133 const sal_Char __FAR_DATA sGraphicObjectProtocol[] = "vnd.sun.star.GraphicObject:"; 134 135 /**************************************************************************** 136 Rahmenbeschreibung 137 ****************************************************************************/ 138 class BaseFrameProperties_Impl 139 { 140 SwUnoCursorHelper::SwAnyMapHelper aAnyMap; 141 142 public: 143 virtual ~BaseFrameProperties_Impl(); 144 145 void SetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any& rVal); 146 sal_Bool GetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any*& pAny ); 147 // void GetProperty(const OUString &rPropertyName, const uno::Reference < beans::XPropertySet > &rxPropertySet, uno::Any& rAny ); 148 149 // const SfxItemPropertyMap* GetMap() const {return _pMap;} 150 sal_Bool FillBaseProperties(SfxItemSet& rToSet, const SfxItemSet &rFromSet, sal_Bool& rSizeFound); 151 152 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound) = 0; 153 154 }; 155 156 BaseFrameProperties_Impl::~BaseFrameProperties_Impl() 157 { 158 } 159 160 void BaseFrameProperties_Impl::SetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any& rVal) 161 { 162 aAnyMap.SetValue( nWID, nMemberId, rVal ); 163 } 164 165 sal_Bool BaseFrameProperties_Impl::GetProperty(sal_uInt16 nWID, sal_uInt8 nMemberId, const uno::Any*& rpAny) 166 { 167 return aAnyMap.FillValue( nWID, nMemberId, rpAny ); 168 } 169 170 sal_Bool BaseFrameProperties_Impl::FillBaseProperties(SfxItemSet& rToSet, const SfxItemSet& rFromSet, sal_Bool& rSizeFound) 171 { 172 sal_Bool bRet = sal_True; 173 //Anker kommt auf jeden Fall in den Set 174 SwFmtAnchor aAnchor ( static_cast < const SwFmtAnchor & > ( rFromSet.Get ( RES_ANCHOR ) ) ); 175 { 176 const ::uno::Any* pAnchorPgNo; 177 if(GetProperty(RES_ANCHOR, MID_ANCHOR_PAGENUM, pAnchorPgNo)) 178 bRet &= ((SfxPoolItem&)aAnchor).PutValue(*pAnchorPgNo, MID_ANCHOR_PAGENUM); 179 const ::uno::Any* pAnchorType; 180 if(GetProperty(RES_ANCHOR, MID_ANCHOR_ANCHORTYPE, pAnchorType)) 181 bRet &= ((SfxPoolItem&)aAnchor).PutValue(*pAnchorType, MID_ANCHOR_ANCHORTYPE); 182 } 183 rToSet.Put(aAnchor); 184 { 185 const ::uno::Any* pCol = 0; 186 GetProperty(RES_BACKGROUND, MID_BACK_COLOR, pCol ); 187 const ::uno::Any* pRGBCol = 0; 188 GetProperty(RES_BACKGROUND, MID_BACK_COLOR_R_G_B, pRGBCol ); 189 const ::uno::Any* pColTrans = 0; 190 GetProperty(RES_BACKGROUND, MID_BACK_COLOR_TRANSPARENCY, pColTrans); 191 const ::uno::Any* pTrans = 0; 192 GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENT, pTrans ); 193 const ::uno::Any* pGrLoc = 0; 194 GetProperty(RES_BACKGROUND, MID_GRAPHIC_POSITION, pGrLoc ); 195 const ::uno::Any* pGrURL = 0; 196 GetProperty(RES_BACKGROUND, MID_GRAPHIC_URL, pGrURL ); 197 const ::uno::Any* pGrFilter = 0; 198 GetProperty(RES_BACKGROUND, MID_GRAPHIC_FILTER, pGrFilter ); 199 const ::uno::Any* pGrTranparency = 0; 200 GetProperty(RES_BACKGROUND, MID_GRAPHIC_TRANSPARENCY, pGrTranparency ); 201 202 if(pCol || pTrans || pGrURL || pGrFilter || pGrLoc || 203 pGrTranparency || pColTrans || pRGBCol) 204 { 205 SvxBrushItem aBrush ( static_cast < const :: SvxBrushItem & > ( rFromSet.Get ( RES_BACKGROUND ) ) ); 206 if(pCol ) 207 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pCol,MID_BACK_COLOR ); 208 if(pColTrans) 209 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pColTrans, MID_BACK_COLOR_TRANSPARENCY); 210 if(pRGBCol) 211 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pRGBCol, MID_BACK_COLOR_R_G_B); 212 if(pTrans) 213 { 214 // don't overwrite transparency with a non-transparence flag 215 if(!pColTrans || Any2Bool( *pTrans )) 216 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pTrans, MID_GRAPHIC_TRANSPARENT); 217 } 218 if(pGrURL) 219 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrURL, MID_GRAPHIC_URL); 220 if(pGrFilter) 221 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrFilter, MID_GRAPHIC_FILTER); 222 if(pGrLoc) 223 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrLoc, MID_GRAPHIC_POSITION); 224 if(pGrTranparency) 225 bRet &= ((SfxPoolItem&)aBrush).PutValue(*pGrTranparency, MID_GRAPHIC_TRANSPARENCY); 226 227 rToSet.Put(aBrush); 228 } 229 } 230 { 231 const ::uno::Any* pCont = 0; 232 GetProperty(RES_PROTECT, MID_PROTECT_CONTENT, pCont ); 233 const ::uno::Any* pPos = 0; 234 GetProperty(RES_PROTECT,MID_PROTECT_POSITION, pPos ); 235 const ::uno::Any* pName = 0; 236 GetProperty(RES_PROTECT, MID_PROTECT_SIZE, pName ); 237 if(pCont||pPos||pName) 238 { 239 SvxProtectItem aProt ( static_cast < const :: SvxProtectItem & > ( rFromSet.Get ( RES_PROTECT ) ) ); 240 if(pCont) 241 bRet &= ((SfxPoolItem&)aProt).PutValue(*pCont, MID_PROTECT_CONTENT); 242 if(pPos ) 243 bRet &= ((SfxPoolItem&)aProt).PutValue(*pPos, MID_PROTECT_POSITION); 244 if(pName) 245 bRet &= ((SfxPoolItem&)aProt).PutValue(*pName, MID_PROTECT_SIZE); 246 rToSet.Put(aProt); 247 } 248 } 249 { 250 const ::uno::Any* pHori = 0; 251 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_ORIENT, pHori ); 252 const ::uno::Any* pHoriP = 0; 253 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_POSITION|CONVERT_TWIPS, pHoriP ); 254 const ::uno::Any* pHoriR = 0; 255 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_RELATION, pHoriR ); 256 const ::uno::Any* pPageT = 0; 257 GetProperty(RES_HORI_ORIENT, MID_HORIORIENT_PAGETOGGLE, pPageT); 258 if(pHori||pHoriP||pHoriR||pPageT) 259 { 260 SwFmtHoriOrient aOrient ( static_cast < const :: SwFmtHoriOrient & > ( rFromSet.Get ( RES_HORI_ORIENT ) ) ); 261 if(pHori ) 262 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHori, MID_HORIORIENT_ORIENT); 263 if(pHoriP) 264 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHoriP, MID_HORIORIENT_POSITION|CONVERT_TWIPS); 265 if(pHoriR) 266 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pHoriR, MID_HORIORIENT_RELATION); 267 if(pPageT) 268 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pPageT, MID_HORIORIENT_PAGETOGGLE); 269 rToSet.Put(aOrient); 270 } 271 } 272 273 { 274 const ::uno::Any* pVert = 0; 275 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_ORIENT, pVert); 276 const ::uno::Any* pVertP = 0; 277 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_POSITION|CONVERT_TWIPS, pVertP ); 278 const ::uno::Any* pVertR = 0; 279 GetProperty(RES_VERT_ORIENT, MID_VERTORIENT_RELATION, pVertR ); 280 if(pVert||pVertP||pVertR) 281 { 282 SwFmtVertOrient aOrient ( static_cast < const :: SwFmtVertOrient & > ( rFromSet.Get ( RES_VERT_ORIENT ) ) ); 283 if(pVert ) 284 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVert, MID_VERTORIENT_ORIENT); 285 if(pVertP) 286 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVertP, MID_VERTORIENT_POSITION|CONVERT_TWIPS); 287 if(pVertR) 288 bRet &= ((SfxPoolItem&)aOrient).PutValue(*pVertR, MID_VERTORIENT_RELATION); 289 rToSet.Put(aOrient); 290 } 291 } 292 { 293 const ::uno::Any* pURL = 0; 294 GetProperty(RES_URL, MID_URL_URL, pURL ); 295 const ::uno::Any* pTarget = 0; 296 GetProperty(RES_URL, MID_URL_TARGET, pTarget ); 297 const ::uno::Any* pHyLNm = 0; 298 GetProperty(RES_URL, MID_URL_HYPERLINKNAME, pHyLNm ); 299 const ::uno::Any* pHySMp = 0; 300 GetProperty(RES_URL, MID_URL_SERVERMAP, pHySMp ); 301 if(pURL||pTarget||pHyLNm||pHySMp) 302 { 303 SwFmtURL aURL ( static_cast < const :: SwFmtURL & > ( rFromSet.Get ( RES_URL ) ) ); 304 if(pURL) 305 bRet &= ((SfxPoolItem&)aURL).PutValue(*pURL, MID_URL_URL); 306 if(pTarget) 307 bRet &= ((SfxPoolItem&)aURL).PutValue(*pTarget, MID_URL_TARGET); 308 if(pHyLNm) 309 bRet &= ((SfxPoolItem&)aURL).PutValue(*pHyLNm, MID_URL_HYPERLINKNAME ); 310 if(pHySMp) 311 bRet &= ((SfxPoolItem&)aURL).PutValue(*pHySMp, MID_URL_SERVERMAP); 312 rToSet.Put(aURL); 313 } 314 } 315 const ::uno::Any* pL = 0; 316 GetProperty(RES_LR_SPACE, MID_L_MARGIN|CONVERT_TWIPS, pL ); 317 const ::uno::Any* pR = 0; 318 GetProperty(RES_LR_SPACE, MID_R_MARGIN|CONVERT_TWIPS, pR ); 319 if(pL||pR) 320 { 321 SvxLRSpaceItem aLR ( static_cast < const :: SvxLRSpaceItem & > ( rFromSet.Get ( RES_LR_SPACE ) ) ); 322 if(pL) 323 bRet &= ((SfxPoolItem&)aLR).PutValue(*pL, MID_L_MARGIN|CONVERT_TWIPS); 324 if(pR) 325 bRet &= ((SfxPoolItem&)aLR).PutValue(*pR, MID_R_MARGIN|CONVERT_TWIPS); 326 rToSet.Put(aLR); 327 } 328 const ::uno::Any* pT = 0; 329 GetProperty(RES_UL_SPACE, MID_UP_MARGIN|CONVERT_TWIPS, pT ); 330 const ::uno::Any* pB = 0; 331 GetProperty(RES_UL_SPACE, MID_LO_MARGIN|CONVERT_TWIPS, pB ); 332 if(pT||pB) 333 { 334 SvxULSpaceItem aTB ( static_cast < const :: SvxULSpaceItem &> ( rFromSet.Get ( RES_UL_SPACE ) ) ); 335 if(pT) 336 bRet &= ((SfxPoolItem&)aTB).PutValue(*pT, MID_UP_MARGIN|CONVERT_TWIPS); 337 if(pB) 338 bRet &= ((SfxPoolItem&)aTB).PutValue(*pB, MID_LO_MARGIN|CONVERT_TWIPS); 339 rToSet.Put(aTB); 340 } 341 const ::uno::Any* pOp; 342 if(GetProperty(RES_OPAQUE, 0, pOp)) 343 { 344 SvxOpaqueItem aOp ( static_cast < const :: SvxOpaqueItem& > ( rFromSet.Get ( RES_OPAQUE ) ) ); 345 bRet &= ((SfxPoolItem&)aOp).PutValue(*pOp, 0); 346 rToSet.Put(aOp); 347 } 348 const ::uno::Any* pPrt; 349 if(GetProperty(RES_PRINT, 0, pPrt)) 350 { 351 SvxPrintItem aPrt ( static_cast < const :: SvxPrintItem & > ( rFromSet.Get ( RES_PRINT ) ) ); 352 bRet &= ((SfxPoolItem&)aPrt).PutValue(*pPrt, 0); 353 rToSet.Put(aPrt); 354 } 355 const ::uno::Any* pSh; 356 if(GetProperty(RES_SHADOW, CONVERT_TWIPS, pSh)) 357 { 358 SvxShadowItem aSh ( static_cast < const :: SvxShadowItem& > ( rFromSet.Get ( RES_SHADOW ) ) ); 359 bRet &= ((SfxPoolItem&)aSh).PutValue(*pSh, CONVERT_TWIPS); 360 rToSet.Put(aSh); 361 } 362 const ::uno::Any* pSur = 0; 363 GetProperty(RES_SURROUND, MID_SURROUND_SURROUNDTYPE, pSur); 364 const ::uno::Any* pSurAnch = 0; 365 GetProperty(RES_SURROUND, MID_SURROUND_ANCHORONLY, pSurAnch); 366 if(pSur || pSurAnch) 367 { 368 SwFmtSurround aSrnd ( static_cast < const :: SwFmtSurround & > ( rFromSet.Get ( RES_SURROUND ) ) ); 369 if(pSur) 370 bRet &= ((SfxPoolItem&)aSrnd).PutValue(*pSur, MID_SURROUND_SURROUNDTYPE ); 371 if(pSurAnch) 372 bRet &= ((SfxPoolItem&)aSrnd).PutValue(*pSurAnch, MID_SURROUND_ANCHORONLY); 373 rToSet.Put(aSrnd); 374 } 375 const ::uno::Any* pLeft = 0; 376 GetProperty(RES_BOX, LEFT_BORDER |CONVERT_TWIPS, pLeft ); 377 const ::uno::Any* pRight = 0; 378 GetProperty(RES_BOX, CONVERT_TWIPS|RIGHT_BORDER , pRight ); 379 const ::uno::Any* pTop = 0; 380 GetProperty(RES_BOX, CONVERT_TWIPS|TOP_BORDER , pTop ); 381 const ::uno::Any* pBottom = 0; 382 GetProperty(RES_BOX, CONVERT_TWIPS|BOTTOM_BORDER, pBottom); 383 const ::uno::Any* pDistance = 0; 384 GetProperty(RES_BOX, CONVERT_TWIPS|BORDER_DISTANCE, pDistance); 385 const ::uno::Any* pLeftDistance = 0; 386 GetProperty(RES_BOX, CONVERT_TWIPS|LEFT_BORDER_DISTANCE, pLeftDistance); 387 const ::uno::Any* pRightDistance = 0; 388 GetProperty(RES_BOX, CONVERT_TWIPS|RIGHT_BORDER_DISTANCE, pRightDistance); 389 const ::uno::Any* pTopDistance = 0; 390 GetProperty(RES_BOX, CONVERT_TWIPS|TOP_BORDER_DISTANCE, pTopDistance); 391 const ::uno::Any* pBottomDistance = 0; 392 GetProperty(RES_BOX, CONVERT_TWIPS|BOTTOM_BORDER_DISTANCE, pBottomDistance); 393 if( pLeft || pRight || pTop || pBottom || pDistance || 394 pLeftDistance || pRightDistance || pTopDistance || pBottomDistance ) 395 { 396 SvxBoxItem aBox ( static_cast < const :: SvxBoxItem & > ( rFromSet.Get ( RES_BOX ) ) ); 397 if( pLeft ) 398 bRet &= ((SfxPoolItem&)aBox).PutValue(*pLeft, CONVERT_TWIPS|LEFT_BORDER ); 399 if( pRight ) 400 bRet &= ((SfxPoolItem&)aBox).PutValue(*pRight, CONVERT_TWIPS|RIGHT_BORDER ); 401 if( pTop ) 402 bRet &= ((SfxPoolItem&)aBox).PutValue(*pTop, CONVERT_TWIPS|TOP_BORDER); 403 if( pBottom ) 404 bRet &= ((SfxPoolItem&)aBox).PutValue(*pBottom, CONVERT_TWIPS|BOTTOM_BORDER); 405 if( pDistance ) 406 bRet &= ((SfxPoolItem&)aBox).PutValue(*pDistance, CONVERT_TWIPS|BORDER_DISTANCE); 407 if( pLeftDistance ) 408 bRet &= ((SfxPoolItem&)aBox).PutValue(*pLeftDistance, CONVERT_TWIPS|LEFT_BORDER_DISTANCE); 409 if( pRightDistance ) 410 bRet &= ((SfxPoolItem&)aBox).PutValue(*pRightDistance, CONVERT_TWIPS|RIGHT_BORDER_DISTANCE); 411 if( pTopDistance ) 412 bRet &= ((SfxPoolItem&)aBox).PutValue(*pTopDistance, CONVERT_TWIPS|TOP_BORDER_DISTANCE); 413 if( pBottomDistance ) 414 bRet &= ((SfxPoolItem&)aBox).PutValue(*pBottomDistance, CONVERT_TWIPS|BOTTOM_BORDER_DISTANCE); 415 rToSet.Put(aBox); 416 } 417 { 418 const ::uno::Any* pRelH = 0; 419 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_REL_HEIGHT, pRelH); 420 const ::uno::Any* pRelW = 0; 421 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_REL_WIDTH, pRelW); 422 const ::uno::Any* pSyncWidth = 0; 423 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT, pSyncWidth); 424 const ::uno::Any* pSyncHeight = 0; 425 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH, pSyncHeight); 426 const ::uno::Any* pWidth = 0; 427 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_WIDTH|CONVERT_TWIPS, pWidth); 428 const ::uno::Any* pHeight = 0; 429 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_HEIGHT|CONVERT_TWIPS, pHeight); 430 const ::uno::Any* pSize = 0; 431 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_SIZE|CONVERT_TWIPS, pSize); 432 const ::uno::Any* pSizeType = 0; 433 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_SIZE_TYPE, pSizeType); 434 const ::uno::Any* pWidthType = 0; 435 GetProperty(RES_FRM_SIZE, MID_FRMSIZE_WIDTH_TYPE, pWidthType); 436 if( pWidth || pHeight ||pRelH || pRelW || pSize ||pSizeType || 437 pWidthType ||pSyncWidth || pSyncHeight ) 438 { 439 rSizeFound = sal_True; 440 SwFmtFrmSize aFrmSz ( static_cast < const :: SwFmtFrmSize& > ( rFromSet.Get ( RES_FRM_SIZE ) ) ); 441 if(pWidth) 442 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pWidth, MID_FRMSIZE_WIDTH|CONVERT_TWIPS); 443 if(pHeight) 444 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pHeight, MID_FRMSIZE_HEIGHT|CONVERT_TWIPS); 445 if(pRelH ) 446 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pRelH, MID_FRMSIZE_REL_HEIGHT); 447 if(pRelW ) 448 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pRelW, MID_FRMSIZE_REL_WIDTH); 449 if(pSyncWidth) 450 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSyncWidth, MID_FRMSIZE_IS_SYNC_WIDTH_TO_HEIGHT); 451 if(pSyncHeight) 452 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSyncHeight, MID_FRMSIZE_IS_SYNC_HEIGHT_TO_WIDTH); 453 if(pSize) 454 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSize, MID_FRMSIZE_SIZE|CONVERT_TWIPS); 455 if(pSizeType) 456 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pSizeType, MID_FRMSIZE_SIZE_TYPE); 457 if(pWidthType) 458 bRet &= ((SfxPoolItem&)aFrmSz).PutValue(*pWidthType, MID_FRMSIZE_WIDTH_TYPE); 459 if(!aFrmSz.GetWidth()) 460 aFrmSz.SetWidth(MINFLY); 461 if(!aFrmSz.GetHeight()) 462 aFrmSz.SetHeight(MINFLY); 463 rToSet.Put(aFrmSz); 464 } 465 else 466 { 467 rSizeFound = sal_False; 468 SwFmtFrmSize aFrmSz; 469 awt::Size aSize; 470 aSize.Width = 2 * MM50; 471 aSize.Height = 2 * MM50; 472 ::uno::Any aSizeVal; 473 aSizeVal <<= aSize; 474 ((SfxPoolItem&)aFrmSz).PutValue(aSizeVal, MID_FRMSIZE_SIZE|CONVERT_TWIPS); 475 rToSet.Put(aFrmSz); 476 } 477 } 478 const ::uno::Any* pFrameDirection = 0; 479 GetProperty(RES_FRAMEDIR, 0, pFrameDirection); 480 if(pFrameDirection) 481 { 482 SvxFrameDirectionItem aAttr(FRMDIR_HORI_LEFT_TOP, RES_FRAMEDIR); 483 aAttr.PutValue(*pFrameDirection, 0); 484 rToSet.Put(aAttr); 485 } 486 const ::uno::Any* pUnknown = 0; 487 GetProperty(RES_UNKNOWNATR_CONTAINER, 0, pUnknown); 488 if(pUnknown) 489 { 490 SvXMLAttrContainerItem aAttr(RES_UNKNOWNATR_CONTAINER); 491 aAttr.PutValue(*pUnknown, 0); 492 rToSet.Put(aAttr); 493 } 494 495 // DVO, OD 01.10.2003 #i18732# 496 const ::uno::Any* pFollowTextFlow = 0; 497 GetProperty(RES_FOLLOW_TEXT_FLOW, 0, pFollowTextFlow); 498 if ( pFollowTextFlow ) 499 { 500 SwFmtFollowTextFlow aFmtFollowTextFlow; 501 aFmtFollowTextFlow.PutValue(*pFollowTextFlow, 0); 502 rToSet.Put(aFmtFollowTextFlow); 503 } 504 505 // OD 2004-05-04 #i28701# - RES_WRAP_INFLUENCE_ON_OBJPOS 506 const ::uno::Any* pWrapInfluenceOnObjPos = 0; 507 GetProperty(RES_WRAP_INFLUENCE_ON_OBJPOS, MID_WRAP_INFLUENCE, pWrapInfluenceOnObjPos); 508 if ( pWrapInfluenceOnObjPos ) 509 { 510 SwFmtWrapInfluenceOnObjPos aFmtWrapInfluenceOnObjPos; 511 aFmtWrapInfluenceOnObjPos.PutValue( *pWrapInfluenceOnObjPos, MID_WRAP_INFLUENCE ); 512 rToSet.Put(aFmtWrapInfluenceOnObjPos); 513 } 514 515 return bRet; 516 } 517 518 class SwFrameProperties_Impl : public BaseFrameProperties_Impl 519 { 520 public: 521 SwFrameProperties_Impl(); 522 virtual ~SwFrameProperties_Impl(){} 523 524 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound); 525 }; 526 527 SwFrameProperties_Impl::SwFrameProperties_Impl(): 528 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_FRAME)*/ ) 529 { 530 } 531 532 inline void lcl_FillCol ( SfxItemSet &rToSet, const :: SfxItemSet &rFromSet, const :: uno::Any *pAny) 533 { 534 if ( pAny ) 535 { 536 SwFmtCol aCol ( static_cast < const :: SwFmtCol & > ( rFromSet.Get ( RES_COL ) ) ); 537 ((SfxPoolItem&)aCol).PutValue( *pAny, MID_COLUMNS); 538 rToSet.Put(aCol); 539 } 540 } 541 sal_Bool SwFrameProperties_Impl::AnyToItemSet(SwDoc *pDoc, SfxItemSet& rSet, SfxItemSet&, sal_Bool& rSizeFound) 542 { 543 //Properties fuer alle Frames 544 const ::uno::Any *pStyleName; 545 SwDocStyleSheet* pStyle = NULL; 546 sal_Bool bRet; 547 548 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME, 0, pStyleName ) ) 549 { 550 OUString sStyle; 551 *pStyleName >>= sStyle; 552 pStyle = (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, 553 SFX_STYLE_FAMILY_FRAME); 554 } 555 556 const ::uno::Any* pColumns = NULL; 557 GetProperty (RES_COL, MID_COLUMNS, pColumns); 558 if ( pStyle ) 559 { 560 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet( *pStyle ) ); 561 const :: SfxItemSet *pItemSet = &xStyle->GetItemSet(); 562 bRet = FillBaseProperties( rSet, *pItemSet, rSizeFound ); 563 lcl_FillCol ( rSet, *pItemSet, pColumns ); 564 } 565 else 566 { 567 const :: SfxItemSet *pItemSet = &pDoc->GetFrmFmtFromPool( RES_POOLFRM_FRAME )->GetAttrSet(); 568 bRet = FillBaseProperties( rSet, *pItemSet, rSizeFound ); 569 lcl_FillCol ( rSet, *pItemSet, pColumns ); 570 } 571 const ::uno::Any* pEdit; 572 if(GetProperty(RES_EDIT_IN_READONLY, 0, pEdit)) 573 { 574 SfxBoolItem aBool(RES_EDIT_IN_READONLY); 575 ((SfxPoolItem&)aBool).PutValue(*pEdit, 0); 576 rSet.Put(aBool); 577 } 578 return bRet; 579 } 580 /**************************************************************************** 581 Grafik-Descriptor 582 ****************************************************************************/ 583 class SwGraphicProperties_Impl : public BaseFrameProperties_Impl 584 { 585 public: 586 SwGraphicProperties_Impl(); 587 virtual ~SwGraphicProperties_Impl(){} 588 589 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound); 590 }; 591 592 SwGraphicProperties_Impl::SwGraphicProperties_Impl( ) : 593 BaseFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_TEXT_GRAPHIC)*/ ) 594 { 595 } 596 597 598 inline void lcl_FillMirror ( SfxItemSet &rToSet, const :: SfxItemSet &rFromSet, const ::uno::Any *pHEvenMirror, const ::uno::Any *pHOddMirror, const ::uno::Any *pVMirror, sal_Bool &rRet ) 599 { 600 if(pHEvenMirror || pHOddMirror || pVMirror ) 601 { 602 SwMirrorGrf aMirror ( static_cast < const :: SwMirrorGrf& > ( rFromSet.Get ( RES_GRFATR_MIRRORGRF ) ) ); 603 if(pHEvenMirror) 604 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pHEvenMirror, MID_MIRROR_HORZ_EVEN_PAGES); 605 if(pHOddMirror) 606 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pHOddMirror, MID_MIRROR_HORZ_ODD_PAGES); 607 if(pVMirror) 608 rRet &= ((SfxPoolItem&)aMirror).PutValue(*pVMirror, MID_MIRROR_VERT); 609 rToSet.Put(aMirror); 610 } 611 } 612 613 sal_Bool SwGraphicProperties_Impl::AnyToItemSet( 614 SwDoc* pDoc, 615 SfxItemSet& rFrmSet, 616 SfxItemSet& rGrSet, 617 sal_Bool& rSizeFound) 618 { 619 //Properties fuer alle Frames 620 sal_Bool bRet; 621 const ::uno::Any *pStyleName; 622 SwDocStyleSheet* pStyle = NULL; 623 624 if ( GetProperty ( FN_UNO_FRAME_STYLE_NAME, 0, pStyleName ) ) 625 { 626 OUString sStyle; 627 *pStyleName >>= sStyle; 628 pStyle = (SwDocStyleSheet*)pDoc->GetDocShell()->GetStyleSheetPool()->Find(sStyle, 629 SFX_STYLE_FAMILY_FRAME); 630 } 631 632 const ::uno::Any* pHEvenMirror = 0; 633 const ::uno::Any* pHOddMirror = 0; 634 const ::uno::Any* pVMirror = 0; 635 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_HORZ_EVEN_PAGES, pHEvenMirror); 636 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_HORZ_ODD_PAGES, pHOddMirror); 637 GetProperty(RES_GRFATR_MIRRORGRF, MID_MIRROR_VERT, pVMirror); 638 639 if ( pStyle ) 640 { 641 rtl::Reference< SwDocStyleSheet > xStyle( new SwDocStyleSheet(*pStyle) ); 642 const :: SfxItemSet *pItemSet = &xStyle->GetItemSet(); 643 bRet = FillBaseProperties(rFrmSet, *pItemSet, rSizeFound); 644 lcl_FillMirror ( rGrSet, *pItemSet, pHEvenMirror, pHOddMirror, pVMirror, bRet ); 645 } 646 else 647 { 648 const :: SfxItemSet *pItemSet = &pDoc->GetFrmFmtFromPool( RES_POOLFRM_GRAPHIC )->GetAttrSet(); 649 bRet = FillBaseProperties(rFrmSet, *pItemSet, rSizeFound); 650 lcl_FillMirror ( rGrSet, *pItemSet, pHEvenMirror, pHOddMirror, pVMirror, bRet ); 651 } 652 653 654 static const :: sal_uInt16 nIDs[] = 655 { 656 RES_GRFATR_CROPGRF, 657 RES_GRFATR_ROTATION, 658 RES_GRFATR_LUMINANCE, 659 RES_GRFATR_CONTRAST, 660 RES_GRFATR_CHANNELR, 661 RES_GRFATR_CHANNELG, 662 RES_GRFATR_CHANNELB, 663 RES_GRFATR_GAMMA, 664 RES_GRFATR_INVERT, 665 RES_GRFATR_TRANSPARENCY, 666 RES_GRFATR_DRAWMODE, 667 0 668 }; 669 const ::uno::Any* pAny; 670 for(sal_Int16 nIndex = 0; nIDs[nIndex]; nIndex++) 671 { 672 sal_uInt8 nMId = RES_GRFATR_CROPGRF == nIDs[nIndex] ? CONVERT_TWIPS : 0; 673 if(GetProperty(nIDs[nIndex], nMId, pAny )) 674 { 675 SfxPoolItem* pItem = ::GetDfltAttr( nIDs[nIndex] )->Clone(); 676 bRet &= pItem->PutValue(*pAny, nMId ); 677 rGrSet.Put(*pItem); 678 delete pItem; 679 } 680 } 681 682 return bRet; 683 } 684 685 class SwOLEProperties_Impl : public SwFrameProperties_Impl 686 { 687 public: 688 SwOLEProperties_Impl() : 689 SwFrameProperties_Impl(/*aSwMapProvider.GetPropertyMap(PROPERTY_MAP_EMBEDDED_OBJECT)*/ ){} 690 virtual ~SwOLEProperties_Impl(){} 691 692 virtual sal_Bool AnyToItemSet( SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound); 693 }; 694 695 sal_Bool SwOLEProperties_Impl::AnyToItemSet( 696 SwDoc* pDoc, SfxItemSet& rFrmSet, SfxItemSet& rSet, sal_Bool& rSizeFound) 697 { 698 const ::uno::Any* pTemp; 699 if(!GetProperty(FN_UNO_CLSID, 0, pTemp) && !GetProperty(FN_UNO_STREAM_NAME, 0, pTemp) ) 700 return sal_False; 701 SwFrameProperties_Impl::AnyToItemSet( pDoc, rFrmSet, rSet, rSizeFound); 702 // 703 return sal_True; 704 } 705 706 /****************************************************************** 707 * SwXFrame 708 ******************************************************************/ 709 710 const :: uno::Sequence< sal_Int8 > & SwXFrame::getUnoTunnelId() 711 { 712 static uno::Sequence< sal_Int8 > aSeq = ::CreateUnoTunnelId(); 713 return aSeq; 714 } 715 716 sal_Int64 SAL_CALL SwXFrame::getSomething( const :: uno::Sequence< sal_Int8 >& rId ) 717 throw(uno::RuntimeException) 718 { 719 if( rId.getLength() == 16 720 && 0 == rtl_compareMemory( getUnoTunnelId().getConstArray(), 721 rId.getConstArray(), 16 ) ) 722 { 723 return sal::static_int_cast< sal_Int64 >( reinterpret_cast< sal_IntPtr >(this) ); 724 } 725 return 0; 726 } 727 728 TYPEINIT1(SwXFrame, SwClient); 729 730 OUString SwXFrame::getImplementationName(void) throw( uno::RuntimeException ) 731 { 732 return C2U("SwXFrame"); 733 } 734 735 sal_Bool SwXFrame::supportsService(const :: OUString& rServiceName) throw( uno::RuntimeException ) 736 { 737 return !rServiceName.compareToAscii("com.sun.star.text.BaseFrame")|| 738 !rServiceName.compareToAscii("com.sun.star.text.TextContent") || 739 !rServiceName.compareToAscii("com.sun.star.document.LinkTarget"); 740 } 741 742 uno::Sequence< OUString > SwXFrame::getSupportedServiceNames(void) throw( uno::RuntimeException ) 743 { 744 uno::Sequence< OUString > aRet(3); 745 OUString* pArray = aRet.getArray(); 746 pArray[0] = C2U("com.sun.star.text.BaseFrame"); 747 pArray[1] = C2U("com.sun.star.text.TextContent"); 748 pArray[2] = C2U("com.sun.star.document.LinkTarget"); 749 return aRet; 750 } 751 752 753 SwXFrame::SwXFrame(FlyCntType eSet, const :: SfxItemPropertySet* pSet, SwDoc *pDoc) : 754 aLstnrCntnr( (container::XNamed*)this), 755 m_pPropSet(pSet), 756 m_pDoc ( pDoc ), 757 eType(eSet), 758 bIsDescriptor(sal_True), 759 m_pCopySource( 0 ) 760 { 761 // Register ourselves as a listener to the document (via the page descriptor) 762 pDoc->GetPageDescFromPool(RES_POOLPAGE_STANDARD)->Add(this); 763 // get the property set for the default style data 764 // First get the model 765 uno::Reference < XModel > xModel = pDoc->GetDocShell()->GetBaseModel(); 766 // Ask the model for it's family supplier interface 767 uno::Reference < XStyleFamiliesSupplier > xFamilySupplier ( xModel, uno::UNO_QUERY ); 768 // Get the style families 769 uno::Reference < XNameAccess > xFamilies = xFamilySupplier->getStyleFamilies(); 770 // Get the Frame family (and keep it for later) 771 const ::uno::Any aAny = xFamilies->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "FrameStyles" ) ) ); 772 aAny >>= mxStyleFamily; 773 // In the derived class, we'll ask mxStyleFamily for the relevant default style 774 // mxStyleFamily is initialised in the SwXFrame constructor 775 switch(eType) 776 { 777 case FLYCNTTYPE_FRM: 778 { 779 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Frame" ) ) ); 780 aAny2 >>= mxStyleData; 781 pProps = new SwFrameProperties_Impl( ); 782 } 783 break; 784 case FLYCNTTYPE_GRF: 785 { 786 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Graphics" ) ) ); 787 aAny2 >>= mxStyleData; 788 pProps = new SwGraphicProperties_Impl( ); 789 } 790 break; 791 case FLYCNTTYPE_OLE: 792 { 793 uno::Any aAny2 = mxStyleFamily->getByName ( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "OLE" ) ) ); 794 aAny2 >>= mxStyleData; 795 pProps = new SwOLEProperties_Impl( ); 796 } 797 break; 798 799 default: 800 ; 801 } 802 } 803 804 805 SwXFrame::SwXFrame(SwFrmFmt& rFrmFmt, FlyCntType eSet, const :: SfxItemPropertySet* pSet) : 806 SwClient( &rFrmFmt ), 807 aLstnrCntnr( (container::XNamed*)this), 808 m_pPropSet(pSet), 809 m_pDoc( 0 ), 810 eType(eSet), 811 pProps(0), 812 bIsDescriptor(sal_False), 813 m_pCopySource(0) 814 { 815 816 } 817 818 SwXFrame::~SwXFrame() 819 { 820 delete m_pCopySource; 821 delete pProps; 822 } 823 824 OUString SwXFrame::getName(void) throw( uno::RuntimeException ) 825 { 826 vos::OGuard aGuard(Application::GetSolarMutex()); 827 String sRet; 828 SwFrmFmt* pFmt = GetFrmFmt(); 829 if(pFmt) 830 sRet = pFmt->GetName(); 831 else if(bIsDescriptor) 832 sRet = sName; 833 else 834 throw uno::RuntimeException(); 835 return sRet; 836 } 837 838 void SwXFrame::setName(const :: OUString& rName) throw( uno::RuntimeException ) 839 { 840 vos::OGuard aGuard(Application::GetSolarMutex()); 841 SwFrmFmt* pFmt = GetFrmFmt(); 842 String sTmpName(rName); 843 if(pFmt) 844 { 845 pFmt->GetDoc()->SetFlyName((SwFlyFrmFmt&)*pFmt, sTmpName); 846 if(pFmt->GetName() != sTmpName) 847 { 848 throw uno::RuntimeException(); 849 } 850 } 851 else if(bIsDescriptor) 852 sName = sTmpName; 853 else 854 throw uno::RuntimeException(); 855 } 856 857 uno::Reference< beans::XPropertySetInfo > SwXFrame::getPropertySetInfo(void) throw( uno::RuntimeException ) 858 { 859 uno::Reference< beans::XPropertySetInfo > xRef; 860 static uno::Reference< beans::XPropertySetInfo > xFrmRef; 861 static uno::Reference< beans::XPropertySetInfo > xGrfRef; 862 static uno::Reference< beans::XPropertySetInfo > xOLERef; 863 switch(eType) 864 { 865 case FLYCNTTYPE_FRM: 866 if( !xFrmRef.is() ) 867 xFrmRef = m_pPropSet->getPropertySetInfo(); 868 xRef = xFrmRef; 869 break; 870 case FLYCNTTYPE_GRF: 871 if( !xGrfRef.is() ) 872 xGrfRef = m_pPropSet->getPropertySetInfo(); 873 xRef = xGrfRef; 874 break; 875 case FLYCNTTYPE_OLE: 876 if( !xOLERef.is() ) 877 xOLERef = m_pPropSet->getPropertySetInfo(); 878 xRef = xOLERef; 879 break; 880 default: 881 ; 882 } 883 return xRef; 884 } 885 886 void SwXFrame::SetSelection(SwPaM& rCopySource) 887 { 888 if(m_pCopySource) 889 delete m_pCopySource; 890 m_pCopySource = new SwPaM( *rCopySource.Start() ); 891 m_pCopySource->SetMark(); 892 *m_pCopySource->GetMark() = *rCopySource.End(); 893 } 894 895 SdrObject *SwXFrame::GetOrCreateSdrObject( SwFlyFrmFmt *pFmt ) 896 { 897 SdrObject* pObject = pFmt->FindSdrObject(); 898 if( !pObject ) 899 { 900 SwDoc *pDoc = pFmt->GetDoc(); 901 // --> OD 2005-08-08 #i52858# - method name changed 902 SdrModel *pDrawModel = pDoc->GetOrCreateDrawModel(); 903 // <-- 904 SwFlyDrawContact* pContactObject 905 = new SwFlyDrawContact( pFmt, pDrawModel ); 906 pObject = pContactObject->GetMaster(); 907 908 const :: SwFmtSurround& rSurround = pFmt->GetSurround(); 909 pObject->SetLayer( 910 ( SURROUND_THROUGHT == rSurround.GetSurround() && 911 !pFmt->GetOpaque().GetValue() ) ? pDoc->GetHellId() 912 : pDoc->GetHeavenId() ); 913 914 pDrawModel->GetPage(0)->InsertObject( pObject ); 915 } 916 917 return pObject; 918 } 919 920 SwFrmFmt *lcl_GetFrmFmt( const :: uno::Any& rValue, SwDoc *pDoc ) 921 { 922 SwFrmFmt *pRet = 0; 923 SwDocShell* pDocSh = pDoc->GetDocShell(); 924 if(pDocSh) 925 { 926 OUString uTemp; 927 rValue >>= uTemp; 928 String sStyle; 929 SwStyleNameMapper::FillUIName(String (uTemp), sStyle, nsSwGetPoolIdFromName::GET_POOLID_FRMFMT, sal_True ); 930 SwDocStyleSheet* pStyle = 931 (SwDocStyleSheet*)pDocSh->GetStyleSheetPool()->Find(sStyle, 932 SFX_STYLE_FAMILY_FRAME); 933 if(pStyle) 934 pRet = pStyle->GetFrmFmt(); 935 } 936 937 return pRet; 938 } 939 940 void SwXFrame::setPropertyValue(const :: OUString& rPropertyName, const :: uno::Any& aValue) 941 throw( beans::UnknownPropertyException, beans::PropertyVetoException, lang::IllegalArgumentException, lang::WrappedTargetException, uno::RuntimeException ) 942 { 943 vos::OGuard aGuard(Application::GetSolarMutex()); 944 SwFrmFmt* pFmt = GetFrmFmt(); 945 const :: SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 946 947 if (!pEntry) 948 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 949 950 if(pFmt) 951 { 952 sal_Bool bNextFrame = sal_False; 953 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 954 throw beans::PropertyVetoException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 955 956 SwDoc* pDoc = pFmt->GetDoc(); 957 if ((eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) || 958 (FN_PARAM_COUNTOUR_PP == pEntry->nWID) || 959 (FN_UNO_IS_AUTOMATIC_CONTOUR == pEntry->nWID) || 960 (FN_UNO_IS_PIXEL_CONTOUR == pEntry->nWID) ) 961 { 962 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 963 if(pIdx) 964 { 965 SwNodeIndex aIdx(*pIdx, 1); 966 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 967 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP) 968 { 969 drawing::PointSequenceSequence aParam; 970 if(!aValue.hasValue()) 971 pNoTxt->SetContour(0); 972 else if(aValue >>= aParam) 973 { 974 PolyPolygon aPoly((sal_uInt16)aParam.getLength()); 975 for(sal_Int32 i = 0; i < aParam.getLength(); i++) 976 { 977 const :: drawing::PointSequence* pPointSeq = aParam.getConstArray(); 978 sal_Int32 nPoints = pPointSeq[i].getLength(); 979 const :: awt::Point* pPoints = pPointSeq[i].getConstArray(); 980 Polygon aSet( (sal_uInt16)nPoints ); 981 for(sal_Int32 j = 0; j < nPoints; j++) 982 { 983 Point aPoint(pPoints[j].X, pPoints[j].Y); 984 aSet.SetPoint(aPoint, (sal_uInt16)j); 985 } 986 // Close polygon if it isn't closed already. 987 aSet.Optimize( POLY_OPTIMIZE_CLOSE ); 988 aPoly.Insert( aSet ); 989 } 990 pNoTxt->SetContourAPI( &aPoly ); 991 } 992 else 993 throw lang::IllegalArgumentException(); 994 } 995 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR ) 996 { 997 pNoTxt->SetAutomaticContour( *(sal_Bool *)aValue.getValue() ); 998 } 999 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ) 1000 { 1001 // The IsPixelContour property can only be set if there 1002 // is no contour, or if the contour has been set by the 1003 // API itself (or in other words, if the contour isn't 1004 // used already). 1005 if( !pNoTxt->_HasContour() || 1006 !pNoTxt->IsContourMapModeValid() ) 1007 pNoTxt->SetPixelContour( *(sal_Bool *)aValue.getValue() ); 1008 else 1009 throw lang::IllegalArgumentException(); 1010 } 1011 else 1012 { 1013 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 1014 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet); 1015 pNoTxt->SetAttr(aSet); 1016 } 1017 } 1018 } 1019 // --> OD 2009-07-13 #i73249# 1020 // Attribute AlternativeText was never published. 1021 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances 1022 // else if( FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID && eType != FLYCNTTYPE_FRM ) 1023 // { 1024 // const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1025 // if(pIdx) 1026 // { 1027 // SwNodeIndex aIdx(*pIdx, 1); 1028 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1029 // OUString uTemp; 1030 // aValue >>= uTemp; 1031 // pNoTxt->SetAlternateText(uTemp); 1032 // } 1033 // } 1034 // New attribute Title 1035 else if( FN_UNO_TITLE == pEntry->nWID ) 1036 { 1037 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1038 ASSERT( pFmt, 1039 "unexpected type of <pFmt> --> crash" ); 1040 OUString uTemp; 1041 aValue >>= uTemp; 1042 const String sTitle(uTemp); 1043 // assure that <SdrObject> instance exists. 1044 GetOrCreateSdrObject( pFlyFmt ); 1045 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), sTitle ); 1046 } 1047 // New attribute Description 1048 else if( FN_UNO_DESCRIPTION == pEntry->nWID ) 1049 { 1050 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1051 ASSERT( pFmt, 1052 "unexpected type of <pFmt> --> crash" ); 1053 OUString uTemp; 1054 aValue >>= uTemp; 1055 const String sDescription(uTemp); 1056 // assure that <SdrObject> instance exists. 1057 GetOrCreateSdrObject( pFlyFmt ); 1058 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), sDescription ); 1059 } 1060 // <-- 1061 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) 1062 { 1063 SwFrmFmt *pFrmFmt = lcl_GetFrmFmt( aValue, pFmt->GetDoc() ); 1064 if( pFrmFmt ) 1065 { 1066 UnoActionContext aAction(pFmt->GetDoc()); 1067 1068 SfxItemSet* pSet = 0; 1069 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of 1070 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ), 1071 // if document is currently in reading mode. 1072 if ( !pFmt->GetDoc()->IsInReading() ) 1073 { 1074 // see SwFEShell::SetFrmFmt( SwFrmFmt *pNewFmt, sal_Bool bKeepOrient, Point* pDocPos ) 1075 SwFlyFrm *pFly = 0; 1076 { 1077 const :: SwFrmFmt* pFmtXX = pFmt; 1078 if (PTR_CAST(SwFlyFrmFmt, pFmtXX)) 1079 pFly = ((SwFlyFrmFmt*)pFmtXX)->GetFrm(); 1080 } 1081 if ( pFly ) 1082 { 1083 const :: SfxPoolItem* pItem; 1084 if( SFX_ITEM_SET == pFrmFmt->GetItemState( RES_ANCHOR, sal_False, &pItem )) 1085 { 1086 pSet = new SfxItemSet( pDoc->GetAttrPool(), aFrmFmtSetRange ); 1087 pSet->Put( *pItem ); 1088 if ( !::lcl_ChkAndSetNewAnchor( *pFly, *pSet ) ) 1089 delete pSet, pSet = 0; 1090 } 1091 } 1092 } 1093 // <-- 1094 1095 pFmt->GetDoc()->SetFrmFmtToFly( *pFmt, *pFrmFmt, pSet, sal_False ); 1096 delete pSet; 1097 } 1098 else 1099 throw lang::IllegalArgumentException(); 1100 } 1101 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID || 1102 FN_UNO_GRAPHIC_FILTER == pEntry->nWID) 1103 { 1104 String sGrfName, sFltName; 1105 GraphicObject *pGrfObj = 0; 1106 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, &sFltName ); 1107 OUString uTemp; 1108 aValue >>= uTemp; 1109 String sTmp(uTemp); 1110 UnoActionContext aAction(pFmt->GetDoc()); 1111 if(FN_UNO_GRAPHIC_U_R_L == pEntry->nWID) 1112 { 1113 if( sTmp.EqualsAscii( sPackageProtocol, 1114 0, sizeof( sPackageProtocol )-1 ) ) 1115 { 1116 pGrfObj = new GraphicObject; 1117 pGrfObj->SetUserData( sTmp ); 1118 pGrfObj->SetSwapState(); 1119 sGrfName.Erase(); 1120 } 1121 else if( sTmp.EqualsAscii( sGraphicObjectProtocol, 1122 0, sizeof(sGraphicObjectProtocol)-1 ) ) 1123 { 1124 ByteString sId( sTmp.Copy(sizeof(sGraphicObjectProtocol)-1), 1125 RTL_TEXTENCODING_ASCII_US ); 1126 pGrfObj = new GraphicObject( sId ); 1127 sGrfName.Erase(); 1128 } 1129 else 1130 { 1131 sGrfName = sTmp; 1132 } 1133 } 1134 else 1135 { 1136 sFltName = sTmp; 1137 } 1138 1139 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1140 if(pIdx) 1141 { 1142 SwNodeIndex aIdx(*pIdx, 1); 1143 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1144 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1145 if(!pGrfNode) 1146 { 1147 delete pGrfObj; 1148 throw uno::RuntimeException(); 1149 } 1150 SwPaM aGrfPaM(*pGrfNode); 1151 pFmt->GetDoc()->ReRead( aGrfPaM, sGrfName, sFltName, 0, 1152 pGrfObj ); 1153 } 1154 delete pGrfObj; 1155 } 1156 else if( FN_UNO_GRAPHIC == pEntry->nWID ) 1157 { 1158 uno::Reference< graphic::XGraphic > xGraphic; 1159 aValue >>= xGraphic; 1160 if(xGraphic.is()) 1161 { 1162 const :: SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1163 if(pIdx) 1164 { 1165 SwNodeIndex aIdx(*pIdx, 1); 1166 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1167 if(!pGrfNode) 1168 { 1169 throw uno::RuntimeException(); 1170 } 1171 SwPaM aGrfPaM(*pGrfNode); 1172 Graphic aGraphic( xGraphic ); 1173 pFmt->GetDoc()->ReRead( aGrfPaM, String(), String(), &aGraphic, 0 ); 1174 } 1175 } 1176 } 1177 else if( FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID || FN_UNO_REPLACEMENT_GRAPHIC == pEntry->nWID ) 1178 { 1179 bool bURL = FN_UNO_REPLACEMENT_GRAPHIC_URL == pEntry->nWID; 1180 bool bApply = false; 1181 Graphic aGraphic; 1182 if( bURL ) 1183 { 1184 GraphicObject *pGrfObj = 0; 1185 OUString aGrfUrl; 1186 aValue >>= aGrfUrl; 1187 1188 // the package URL based graphics are handled in different way currently 1189 // TODO/LATER: actually this is the correct place to handle them 1190 ::rtl::OUString aGraphicProtocol( RTL_CONSTASCII_USTRINGPARAM( sGraphicObjectProtocol ) ); 1191 if( aGrfUrl.compareTo( aGraphicProtocol, aGraphicProtocol.getLength() ) == 0 ) 1192 { 1193 ByteString sId( aGrfUrl.copy(sizeof(sGraphicObjectProtocol)-1).getStr(), RTL_TEXTENCODING_ASCII_US ); 1194 pGrfObj = new GraphicObject( sId ); 1195 aGraphic = pGrfObj->GetGraphic(); 1196 bApply = true; 1197 } 1198 } 1199 else 1200 { 1201 uno::Reference< graphic::XGraphic > xGraphic; 1202 aValue >>= xGraphic; 1203 if( xGraphic.is() ) 1204 { 1205 aGraphic = Graphic( xGraphic ); 1206 bApply = true; 1207 } 1208 } 1209 1210 if ( bApply ) 1211 { 1212 const :: SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 1213 if ( pCnt->GetCntntIdx() && pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ] ) 1214 { 1215 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode(); 1216 1217 if ( pOleNode ) 1218 { 1219 svt::EmbeddedObjectRef xObj = pOleNode->GetOLEObj().GetObject(); 1220 1221 ::rtl::OUString aMediaType; 1222 xObj.SetGraphic( aGraphic, aMediaType ); 1223 } 1224 } 1225 } 1226 } 1227 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME)))) 1228 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME))) 1229 { 1230 OUString uTemp; 1231 aValue >>= uTemp; 1232 String sChainName(uTemp); 1233 if(!sChainName.Len()) 1234 { 1235 if(bNextFrame) 1236 pDoc->Unchain(*pFmt); 1237 else 1238 { 1239 SwFmtChain aChain( pFmt->GetChain() ); 1240 SwFrmFmt *pPrev = aChain.GetPrev(); 1241 if(pPrev) 1242 pDoc->Unchain(*pPrev); 1243 } 1244 } 1245 else 1246 { 1247 sal_uInt16 nCount = pDoc->GetFlyCount(FLYCNTTYPE_FRM); 1248 1249 SwFrmFmt* pChain = 0; 1250 for( sal_uInt16 i = 0; i < nCount; i++) 1251 { 1252 SwFrmFmt* pFmt2 = pDoc->GetFlyNum(i, FLYCNTTYPE_FRM); 1253 if(sChainName == pFmt2->GetName() ) 1254 { 1255 pChain = pFmt2; 1256 break; 1257 } 1258 } 1259 if(pChain) 1260 { 1261 SwFrmFmt* pSource = bNextFrame ? pFmt : pChain; 1262 SwFrmFmt* pDest = bNextFrame ? pChain: pFmt; 1263 pDoc->Chain(*pSource, *pDest); 1264 } 1265 } 1266 } 1267 else if(FN_UNO_Z_ORDER == pEntry->nWID) 1268 { 1269 sal_Int32 nZOrder = - 1; 1270 aValue >>= nZOrder; 1271 if( nZOrder >= 0) 1272 { 1273 SdrObject* pObject = 1274 GetOrCreateSdrObject( (SwFlyFrmFmt*)pFmt ); 1275 SdrModel *pDrawModel = pDoc->GetDrawModel(); 1276 pDrawModel->GetPage(0)-> 1277 SetObjectOrdNum(pObject->GetOrdNum(), nZOrder); 1278 } 1279 } 1280 else if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORFRAME == pEntry->nMemberId) 1281 { 1282 sal_Bool bDone = sal_False; 1283 uno::Reference<text::XTextFrame> xFrame; 1284 if(aValue >>= xFrame) 1285 { 1286 uno::Reference<lang::XUnoTunnel> xTunnel(xFrame, uno::UNO_QUERY); 1287 SwXFrame* pFrame = xTunnel.is() ? 1288 reinterpret_cast< SwXFrame * >( sal::static_int_cast< sal_IntPtr >( xTunnel->getSomething(SwXFrame::getUnoTunnelId()) )) 1289 : 0; 1290 if(pFrame && this != pFrame && pFrame->GetFrmFmt() && pFrame->GetFrmFmt()->GetDoc() == pDoc) 1291 { 1292 SfxItemSet aSet( pDoc->GetAttrPool(), 1293 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 ); 1294 aSet.SetParent(&pFmt->GetAttrSet()); 1295 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID); 1296 1297 1298 SwPosition aPos(*pFrame->GetFrmFmt()->GetCntnt().GetCntntIdx()); 1299 aAnchor.SetAnchor(&aPos); 1300 aAnchor.SetType(FLY_AT_FLY); 1301 aSet.Put(aAnchor); 1302 pDoc->SetFlyFrmAttr( *pFmt, aSet ); 1303 bDone = sal_True; 1304 } 1305 } 1306 if(!bDone) 1307 throw lang::IllegalArgumentException(); 1308 } 1309 else 1310 { 1311 SfxItemSet aSet( pDoc->GetAttrPool(), 1312 RES_FRMATR_BEGIN, RES_FRMATR_END - 1, 1313 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 1314 0L); 1315 1316 aSet.SetParent(&pFmt->GetAttrSet()); 1317 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet); 1318 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == pEntry->nMemberId) 1319 { 1320 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID); 1321 if(aAnchor.GetAnchorId() == FLY_AT_FLY) 1322 { 1323 const :: SwPosition* pPosition = aAnchor.GetCntntAnchor(); 1324 SwFrmFmt* pFlyFmt = pPosition ? pPosition->nNode.GetNode().GetFlyFmt() : 0; 1325 if(!pFlyFmt || pFlyFmt->Which() == RES_DRAWFRMFMT) 1326 { 1327 lang::IllegalArgumentException aExcept; 1328 aExcept.Message = C2U("Anchor to frame: no frame found"); 1329 throw aExcept; 1330 } 1331 else 1332 { 1333 SwPosition aPos = *pPosition; 1334 aPos.nNode = *pFlyFmt->GetCntnt().GetCntntIdx(); 1335 aAnchor.SetAnchor(&aPos); 1336 aSet.Put(aAnchor); 1337 } 1338 } 1339 else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && 1340 !aAnchor.GetCntntAnchor()) 1341 { 1342 SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); 1343 SwPaM aPam(rNode); 1344 aPam.Move( fnMoveBackward, fnGoDoc ); 1345 aAnchor.SetAnchor( aPam.Start() ); 1346 aSet.Put(aAnchor); 1347 } 1348 1349 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of 1350 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ), 1351 // if document is currently in reading mode. 1352 if ( !pFmt->GetDoc()->IsInReading() ) 1353 { 1354 // see SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet ) 1355 SwFlyFrm *pFly = 0; 1356 if (PTR_CAST(SwFlyFrmFmt, pFmt)) 1357 pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm(); 1358 if (pFly) 1359 { 1360 const :: SfxPoolItem* pItem; 1361 if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem )) 1362 { 1363 aSet.Put( *pItem ); 1364 ::lcl_ChkAndSetNewAnchor( *pFly, aSet ); 1365 } 1366 } 1367 } 1368 // <-- 1369 1370 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet ); 1371 } 1372 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID) 1373 { 1374 throw lang::IllegalArgumentException(); 1375 } 1376 else 1377 pFmt->SetFmtAttr(aSet); 1378 } 1379 } 1380 else if(IsDescriptor()) 1381 { 1382 pProps->SetProperty(pEntry->nWID, pEntry->nMemberId, aValue); 1383 if( FN_UNO_FRAME_STYLE_NAME == pEntry->nWID ) 1384 { 1385 OUString sStyleName; 1386 aValue >>= sStyleName; 1387 try 1388 { 1389 uno::Any aAny = mxStyleFamily->getByName ( sStyleName ); 1390 aAny >>= mxStyleData; 1391 } 1392 catch ( container::NoSuchElementException const & ) 1393 { 1394 } 1395 catch ( lang::WrappedTargetException const & ) 1396 { 1397 } 1398 catch ( uno::RuntimeException const & ) 1399 { 1400 } 1401 } 1402 } 1403 else 1404 throw uno::RuntimeException(); 1405 } 1406 1407 uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) 1408 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1409 { 1410 vos::OGuard aGuard(Application::GetSolarMutex()); 1411 uno::Any aAny; 1412 SwFrmFmt* pFmt = GetFrmFmt(); 1413 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 1414 if (!pEntry) 1415 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 1416 1417 if(FN_UNO_ANCHOR_TYPES == pEntry->nWID) 1418 { 1419 uno::Sequence<text::TextContentAnchorType> aTypes(5); 1420 text::TextContentAnchorType* pArray = aTypes.getArray(); 1421 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH; 1422 pArray[1] = text::TextContentAnchorType_AS_CHARACTER; 1423 pArray[2] = text::TextContentAnchorType_AT_PAGE; 1424 pArray[3] = text::TextContentAnchorType_AT_FRAME; 1425 pArray[4] = text::TextContentAnchorType_AT_CHARACTER; 1426 aAny.setValue(&aTypes, ::getCppuType(static_cast<uno::Sequence<text::TextContentAnchorType>*>(0))); 1427 } 1428 else if(pFmt) 1429 { 1430 if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) && 1431 pEntry && 1432 (isGRFATR(pEntry->nWID) || 1433 pEntry->nWID == FN_PARAM_COUNTOUR_PP || 1434 pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || 1435 pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )) 1436 { 1437 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1438 if(pIdx) 1439 { 1440 SwNodeIndex aIdx(*pIdx, 1); 1441 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1442 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP) 1443 { 1444 PolyPolygon aContour; 1445 if( pNoTxt->GetContourAPI( aContour ) ) 1446 { 1447 drawing::PointSequenceSequence aPtSeq(aContour.Count()); 1448 drawing::PointSequence* pPSeq = aPtSeq.getArray(); 1449 for(sal_uInt16 i = 0; i < aContour.Count(); i++) 1450 { 1451 const Polygon& rPoly = aContour.GetObject(i); 1452 pPSeq[i].realloc(rPoly.GetSize()); 1453 awt::Point* pPoints = pPSeq[i].getArray(); 1454 for(sal_uInt16 j = 0; j < rPoly.GetSize(); j++) 1455 { 1456 const Point& rPoint = rPoly.GetPoint(j); 1457 pPoints[j].X = rPoint.X(); 1458 pPoints[j].Y = rPoint.Y(); 1459 } 1460 } 1461 aAny <<= aPtSeq; 1462 } 1463 } 1464 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR ) 1465 { 1466 sal_Bool bValue = pNoTxt->HasAutomaticContour(); 1467 aAny.setValue( &bValue, ::getBooleanCppuType() ); 1468 } 1469 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ) 1470 { 1471 sal_Bool bValue = pNoTxt->IsPixelContour(); 1472 aAny.setValue( &bValue, ::getBooleanCppuType() ); 1473 } 1474 else 1475 { 1476 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 1477 m_pPropSet->getPropertyValue(*pEntry, aSet, aAny); 1478 } 1479 } 1480 } 1481 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID) 1482 { 1483 String sGrfName; 1484 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1485 if(pIdx) 1486 { 1487 SwNodeIndex aIdx(*pIdx, 1); 1488 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1489 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1490 if(!pGrfNode) 1491 throw uno::RuntimeException(); 1492 if( pGrfNode->IsGrfLink() ) 1493 { 1494 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, 0 ); 1495 } 1496 else 1497 { 1498 String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) ); 1499 String sId( pGrfNode->GetGrfObj().GetUniqueID(), 1500 RTL_TEXTENCODING_ASCII_US ); 1501 (sGrfName = sPrefix) += sId; 1502 } 1503 } 1504 aAny <<= OUString(sGrfName); 1505 } 1506 else if( FN_UNO_GRAPHIC_FILTER == pEntry->nWID ) 1507 { 1508 String sFltName; 1509 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, 0, &sFltName ); 1510 aAny <<= OUString(sFltName); 1511 } 1512 else if( FN_UNO_GRAPHIC == pEntry->nWID ) 1513 { 1514 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1515 if(pIdx) 1516 { 1517 SwNodeIndex aIdx(*pIdx, 1); 1518 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1519 if(!pGrfNode) 1520 throw uno::RuntimeException(); 1521 aAny <<= pGrfNode->GetGrf().GetXGraphic(); 1522 } 1523 } 1524 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) 1525 { 1526 aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) ); 1527 } 1528 // --> OD 2009-07-13 #i73249# 1529 // Attribute AlternativeText was never published. 1530 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances 1531 // else if(eType != FLYCNTTYPE_FRM && 1532 // FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) 1533 // { 1534 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1535 // if(pIdx) 1536 // { 1537 // SwNodeIndex aIdx(*pIdx, 1); 1538 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1539 // aAny <<= OUString(pNoTxt->GetAlternateText()); 1540 // } 1541 // } 1542 else if( FN_UNO_TITLE == pEntry->nWID ) 1543 { 1544 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1545 ASSERT( pFmt, 1546 "unexpected type of <pFmt> --> crash" ); 1547 // assure that <SdrObject> instance exists. 1548 GetOrCreateSdrObject( pFlyFmt ); 1549 aAny <<= OUString(pFlyFmt->GetObjTitle()); 1550 } 1551 // New attribute Description 1552 else if( FN_UNO_DESCRIPTION == pEntry->nWID ) 1553 { 1554 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1555 ASSERT( pFmt, 1556 "unexpected type of <pFmt> --> crash" ); 1557 // assure that <SdrObject> instance exists. 1558 GetOrCreateSdrObject( pFlyFmt ); 1559 aAny <<= OUString(pFlyFmt->GetObjDescription()); 1560 } 1561 // <-- 1562 else if(eType == FLYCNTTYPE_GRF && 1563 (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE)))) 1564 { 1565 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1566 if(pIdx) 1567 { 1568 SwNodeIndex aIdx(*pIdx, 1); 1569 // --> OD #i85105# 1570 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1571 // Size aActSize = ((SwGrfNode*)pNoTxt)->GetTwipSize(); 1572 Size aActSize; 1573 { 1574 SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode()); 1575 if ( pGrfNode ) 1576 { 1577 aActSize = pGrfNode->GetTwipSize(); 1578 if ( aActSize.Width() == 0 && aActSize.Height() == 0 && 1579 pGrfNode->IsLinkedFile() ) 1580 { 1581 pGrfNode->SwapIn( sal_True ); 1582 aActSize = pGrfNode->GetTwipSize(); 1583 } 1584 } 1585 } 1586 // <-- 1587 awt::Size aTmp; 1588 aTmp.Width = TWIP_TO_MM100(aActSize.Width()); 1589 aTmp.Height = TWIP_TO_MM100(aActSize.Height()); 1590 aAny.setValue(&aTmp, ::getCppuType(static_cast<const awt::Size*>(0))); 1591 } 1592 } 1593 else if(FN_PARAM_LINK_DISPLAY_NAME == pEntry->nWID) 1594 { 1595 aAny <<= OUString(pFmt->GetName()); 1596 } 1597 else if(FN_UNO_Z_ORDER == pEntry->nWID) 1598 { 1599 const SdrObject* pObj = pFmt->FindRealSdrObject(); 1600 if( pObj ) 1601 { 1602 aAny <<= (sal_Int32)pObj->GetOrdNum(); 1603 } 1604 } 1605 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID|| 1606 FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID|| 1607 FN_EMBEDDED_OBJECT == pEntry->nWID) 1608 { 1609 SwDoc* pDoc = pFmt->GetDoc(); 1610 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 1611 DBG_ASSERT( pCnt->GetCntntIdx() && 1612 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 1613 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 1614 1615 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 1616 ->GetIndex() + 1 ]->GetOLENode(); 1617 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef(); 1618 OUString aHexCLSID; 1619 { 1620 SvGlobalName aClassName( xIP->getClassID() ); 1621 aHexCLSID = aClassName.GetHexName(); 1622 if(FN_UNO_CLSID != pEntry->nWID) 1623 { 1624 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) 1625 { 1626 uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY ); 1627 uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY ); 1628 if ( FN_EMBEDDED_OBJECT == pEntry->nWID ) 1629 { 1630 // ensure the 1631 ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" ); 1632 if ( pDoc->GetDocShell() ) 1633 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) ); 1634 aAny <<= xIP; 1635 } 1636 else if ( xModel.is() ) 1637 aAny <<= xModel; 1638 else if ( FN_UNO_COMPONENT == pEntry->nWID ) 1639 aAny <<= xComp; 1640 } 1641 } 1642 } 1643 1644 if(FN_UNO_CLSID == pEntry->nWID) 1645 aAny <<= aHexCLSID; 1646 else if(FN_UNO_STREAM_NAME == pEntry->nWID) 1647 { 1648 aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName()); 1649 } 1650 } 1651 else if(WID_LAYOUT_SIZE == pEntry->nWID) 1652 { 1653 // format document completely in order to get correct value 1654 pFmt->GetDoc()->GetEditShell()->CalcLayout(); 1655 1656 SwFrm* pTmpFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt ); 1657 if ( pTmpFrm ) 1658 { 1659 DBG_ASSERT( pTmpFrm->IsValid(), "frame not valid" ); 1660 const SwRect &rRect = pTmpFrm->Frm(); 1661 Size aMM100Size = OutputDevice::LogicToLogic( 1662 Size( rRect.Width(), rRect.Height() ), 1663 MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM )); 1664 aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() ); 1665 } 1666 } 1667 else 1668 { 1669 const SwAttrSet& rSet = pFmt->GetAttrSet(); 1670 m_pPropSet->getPropertyValue(*pEntry, rSet, aAny); 1671 } 1672 } 1673 else if(IsDescriptor()) 1674 { 1675 if ( ! m_pDoc ) 1676 throw uno::RuntimeException(); 1677 if(WID_LAYOUT_SIZE != pEntry->nWID) // there is no LayoutSize in a descriptor 1678 { 1679 const uno::Any* pAny = 0; 1680 if( !pProps->GetProperty( pEntry->nWID, pEntry->nMemberId, pAny ) ) 1681 aAny = mxStyleData->getPropertyValue( rPropertyName ); 1682 else if ( pAny ) 1683 aAny = *pAny; 1684 } 1685 } 1686 else 1687 throw uno::RuntimeException(); 1688 return aAny; 1689 } 1690 1691 void SwXFrame::addPropertyChangeListener(const OUString& /*PropertyName*/, 1692 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) 1693 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1694 { 1695 DBG_WARNING("not implemented"); 1696 } 1697 1698 void SwXFrame::removePropertyChangeListener(const OUString& /*PropertyName*/, 1699 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) 1700 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1701 { 1702 DBG_WARNING("not implemented"); 1703 } 1704 1705 void SwXFrame::addVetoableChangeListener(const OUString& /*PropertyName*/, 1706 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) 1707 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1708 { 1709 DBG_WARNING("not implemented"); 1710 } 1711 1712 void SwXFrame::removeVetoableChangeListener( 1713 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) 1714 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1715 { 1716 DBG_WARNING("not implemented"); 1717 } 1718 1719 beans::PropertyState SwXFrame::getPropertyState( const OUString& rPropertyName ) 1720 throw(beans::UnknownPropertyException, uno::RuntimeException) 1721 { 1722 vos::OGuard aGuard(Application::GetSolarMutex()); 1723 uno::Sequence< OUString > aPropertyNames(1); 1724 OUString* pNames = aPropertyNames.getArray(); 1725 pNames[0] = rPropertyName; 1726 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aPropertyNames); 1727 return aStates.getConstArray()[0]; 1728 } 1729 1730 uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( 1731 const uno::Sequence< OUString >& aPropertyNames ) 1732 throw(beans::UnknownPropertyException, uno::RuntimeException) 1733 { 1734 vos::OGuard aGuard(Application::GetSolarMutex()); 1735 uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength()); 1736 beans::PropertyState* pStates = aStates.getArray(); 1737 SwFrmFmt* pFmt = GetFrmFmt(); 1738 if(pFmt) 1739 { 1740 const OUString* pNames = aPropertyNames.getConstArray(); 1741 const SwAttrSet& rFmtSet = pFmt->GetAttrSet(); 1742 for(int i = 0; i < aPropertyNames.getLength(); i++) 1743 { 1744 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(pNames[i]); 1745 if (!pEntry) 1746 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); 1747 1748 if(pEntry->nWID == FN_UNO_ANCHOR_TYPES|| 1749 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME|| 1750 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID|| 1751 FN_UNO_GRAPHIC_U_R_L == pEntry->nWID|| 1752 FN_UNO_GRAPHIC_FILTER == pEntry->nWID|| 1753 FN_UNO_ACTUAL_SIZE == pEntry->nWID|| 1754 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) 1755 { 1756 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1757 } 1758 else 1759 { 1760 if ((eType == FLYCNTTYPE_GRF) && 1761 pEntry && isGRFATR(pEntry->nWID)) 1762 { 1763 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1764 if(pIdx) 1765 { 1766 SwNodeIndex aIdx(*pIdx, 1); 1767 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1768 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 1769 aSet.GetItemState(pEntry->nWID); 1770 if(SFX_ITEM_SET == aSet.GetItemState( pEntry->nWID, sal_False )) 1771 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1772 } 1773 } 1774 else 1775 { 1776 if(SFX_ITEM_SET == rFmtSet.GetItemState( pEntry->nWID, sal_False )) 1777 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1778 else 1779 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 1780 } 1781 } 1782 } 1783 } 1784 else if(IsDescriptor()) 1785 { 1786 for(int i = 0; i < aPropertyNames.getLength(); i++) 1787 pStates[i] = beans::PropertyState_DIRECT_VALUE; 1788 } 1789 else 1790 throw uno::RuntimeException(); 1791 return aStates; 1792 } 1793 1794 void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) 1795 throw(beans::UnknownPropertyException, uno::RuntimeException) 1796 { 1797 vos::OGuard aGuard(Application::GetSolarMutex()); 1798 SwFrmFmt* pFmt = GetFrmFmt(); 1799 if(pFmt) 1800 { 1801 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 1802 if (!pEntry) 1803 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 1804 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 1805 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 1806 1807 sal_Bool bNextFrame; 1808 if( pEntry->nWID && 1809 pEntry->nWID != FN_UNO_ANCHOR_TYPES && 1810 pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME) 1811 { 1812 if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ) 1813 { 1814 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1815 if(pIdx) 1816 { 1817 SwNodeIndex aIdx(*pIdx, 1); 1818 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1819 { 1820 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 1821 aSet.ClearItem(pEntry->nWID); 1822 pNoTxt->SetAttr(aSet); 1823 } 1824 } 1825 } 1826 // --> OD 2009-07-13 #i73249# 1827 // Attribute AlternativeText was never published. 1828 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances 1829 // else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID ) 1830 // { 1831 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1832 // if(pIdx) 1833 // { 1834 // SwNodeIndex aIdx(*pIdx, 1); 1835 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1836 // pNoTxt->SetAlternateText(aEmptyStr); 1837 // } 1838 // } 1839 // New attribute Title 1840 else if( FN_UNO_TITLE == pEntry->nWID ) 1841 { 1842 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1843 ASSERT( pFmt, 1844 "unexpected type of <pFmt> --> crash" ); 1845 // assure that <SdrObject> instance exists. 1846 GetOrCreateSdrObject( pFlyFmt ); 1847 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr ); 1848 } 1849 // New attribute Description 1850 else if( FN_UNO_DESCRIPTION == pEntry->nWID ) 1851 { 1852 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 1853 ASSERT( pFmt, 1854 "unexpected type of <pFmt> --> crash" ); 1855 // assure that <SdrObject> instance exists. 1856 GetOrCreateSdrObject( pFlyFmt ); 1857 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr ); 1858 } 1859 // <-- 1860 else 1861 { 1862 SwDoc* pDoc = pFmt->GetDoc(); 1863 SfxItemSet aSet( pDoc->GetAttrPool(), 1864 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 ); 1865 aSet.SetParent(&pFmt->GetAttrSet()); 1866 aSet.ClearItem(pEntry->nWID); 1867 if(!rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE))) 1868 pFmt->SetFmtAttr(aSet); 1869 } 1870 } 1871 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME)))) 1872 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME))) 1873 { 1874 SwDoc* pDoc = pFmt->GetDoc(); 1875 if(bNextFrame) 1876 pDoc->Unchain(*pFmt); 1877 else 1878 { 1879 SwFmtChain aChain( pFmt->GetChain() ); 1880 SwFrmFmt *pPrev = aChain.GetPrev(); 1881 if(pPrev) 1882 pDoc->Unchain(*pPrev); 1883 } 1884 } 1885 } 1886 else if(!IsDescriptor()) 1887 throw uno::RuntimeException(); 1888 1889 } 1890 1891 uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName ) 1892 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 1893 { 1894 vos::OGuard aGuard(Application::GetSolarMutex()); 1895 uno::Any aRet; 1896 SwFrmFmt* pFmt = GetFrmFmt(); 1897 if(pFmt) 1898 { 1899 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 1900 if(pEntry) 1901 { 1902 if ( pEntry->nWID < RES_FRMATR_END ) 1903 { 1904 const SfxPoolItem& rDefItem = 1905 pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); 1906 rDefItem.QueryValue(aRet, pEntry->nMemberId); 1907 } 1908 } 1909 else 1910 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 1911 } 1912 else if(!IsDescriptor()) 1913 throw uno::RuntimeException(); 1914 return aRet; 1915 } 1916 1917 void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 1918 { 1919 if(!GetRegisteredIn()) 1920 throw uno::RuntimeException(); 1921 aLstnrCntnr.AddListener(aListener); 1922 } 1923 1924 void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 1925 { 1926 if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) 1927 throw uno::RuntimeException(); 1928 } 1929 1930 void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 1931 { 1932 ClientModify(this, pOld, pNew); 1933 if(!GetRegisteredIn()) 1934 { 1935 mxStyleData.clear(); 1936 mxStyleFamily.clear(); 1937 m_pDoc = 0; 1938 aLstnrCntnr.Disposing(); 1939 } 1940 } 1941 1942 1943 void SwXFrame::dispose(void) throw( uno::RuntimeException ) 1944 { 1945 vos::OGuard aGuard(Application::GetSolarMutex()); 1946 SwFrmFmt* pFmt = GetFrmFmt(); 1947 if ( pFmt ) 1948 { 1949 SdrObject* pObj = pFmt->FindSdrObject(); 1950 // OD 11.09.2003 #112039# - add condition to perform delete of 1951 // format/anchor sign, not only if the object is inserted, but also 1952 // if a contact object is registered, which isn't in the destruction. 1953 if ( pObj && 1954 ( pObj->IsInserted() || 1955 ( pObj->GetUserCall() && 1956 !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) ) 1957 { 1958 if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) 1959 { 1960 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); 1961 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); 1962 const xub_StrLen nIdx = rPos.nContent.GetIndex(); 1963 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); 1964 } 1965 else 1966 pFmt->GetDoc()->DelLayoutFmt(pFmt); 1967 } 1968 } 1969 1970 } 1971 1972 uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::RuntimeException ) 1973 { 1974 vos::OGuard aGuard(Application::GetSolarMutex()); 1975 uno::Reference< text::XTextRange > aRef; 1976 SwFrmFmt* pFmt = GetFrmFmt(); 1977 if(pFmt) 1978 { 1979 const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); 1980 // return an anchor for non-page bound frames 1981 // and for page bound frames that have a page no == NULL and a content position 1982 if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || 1983 (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) 1984 { 1985 const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); 1986 aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); 1987 } 1988 } 1989 else 1990 throw uno::RuntimeException(); 1991 return aRef; 1992 } 1993 1994 void SwXFrame::ResetDescriptor() 1995 { 1996 bIsDescriptor = sal_False; 1997 mxStyleData.clear(); 1998 mxStyleFamily.clear(); 1999 DELETEZ(pProps); 2000 } 2001 2002 void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) 2003 throw( lang::IllegalArgumentException, uno::RuntimeException ) 2004 { 2005 vos::OGuard aGuard(Application::GetSolarMutex()); 2006 if(!IsDescriptor()) 2007 throw uno::RuntimeException(); 2008 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 2009 SwXTextRange* pRange = 0; 2010 OTextCursorHelper* pCursor = 0; 2011 if(xRangeTunnel.is()) 2012 { 2013 pRange = reinterpret_cast< SwXTextRange * >( 2014 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); 2015 pCursor = reinterpret_cast< OTextCursorHelper * >( 2016 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); 2017 } 2018 2019 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; 2020 if(pDoc) 2021 { 2022 SwUnoInternalPaM aIntPam(*pDoc); 2023 //das muss jetzt sal_True liefern 2024 ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); 2025 2026 SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); 2027 SwPaM aPam(rNode); 2028 aPam.Move( fnMoveBackward, fnGoDoc ); 2029 static sal_uInt16 __READONLY_DATA aFrmAttrRange[] = 2030 { 2031 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 2032 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 2033 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 2034 0 2035 }; 2036 static sal_uInt16 __READONLY_DATA aGrAttrRange[] = 2037 { 2038 RES_GRFATR_BEGIN, RES_GRFATR_END-1, 2039 0 2040 }; 2041 SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange ); 2042 2043 SfxItemSet aFrmSet(pDoc->GetAttrPool(), aFrmAttrRange ); 2044 //jetzt muessen die passenden Items in den Set 2045 sal_Bool bSizeFound; 2046 if(!pProps->AnyToItemSet( pDoc, aFrmSet, aGrSet, bSizeFound)) 2047 throw lang::IllegalArgumentException(); 2048 //der TextRange wird einzeln behandelt 2049 *aPam.GetPoint() = *aIntPam.GetPoint(); 2050 if(aIntPam.HasMark()) 2051 { 2052 aPam.SetMark(); 2053 *aPam.GetMark() = *aIntPam.GetMark(); 2054 } 2055 2056 const SfxPoolItem* pItem; 2057 RndStdIds eAnchorId = FLY_AT_PARA; 2058 if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) ) 2059 { 2060 eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId(); 2061 if( FLY_AT_FLY == eAnchorId && 2062 !aPam.GetNode()->FindFlyStartNode()) 2063 { 2064 //rahmengebunden geht nur dort, wo ein Rahmen ist! 2065 SwFmtAnchor aAnchor(FLY_AT_PARA); 2066 aFrmSet.Put(aAnchor); 2067 } 2068 else if ((FLY_AT_PAGE == eAnchorId) && 2069 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() ) 2070 { 2071 SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) ); 2072 aAnchor.SetAnchor( aPam.GetPoint() ); 2073 aFrmSet.Put(aAnchor); 2074 } 2075 } 2076 2077 const ::uno::Any* pStyle; 2078 SwFrmFmt *pParentFrmFmt = 0; 2079 if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle)) 2080 pParentFrmFmt = lcl_GetFrmFmt( *pStyle, pDoc ); 2081 2082 SwFlyFrmFmt* pFmt = 0; 2083 if( eType == FLYCNTTYPE_FRM) 2084 { 2085 UnoActionContext aCont(pDoc); 2086 if(m_pCopySource) 2087 { 2088 SwFmtAnchor* pAnchorItem = 0; 2089 // the frame is inserted bound to page 2090 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text 2091 if (eAnchorId != FLY_AT_PAGE) 2092 { 2093 pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone()); 2094 aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); 2095 } 2096 2097 aPam.DeleteMark(); // mark position node will be deleted! 2098 aIntPam.DeleteMark(); // mark position node will be deleted! 2099 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, 2100 0, 2101 pParentFrmFmt ); 2102 if(pAnchorItem && pFmt) 2103 { 2104 pFmt->DelFrms(); 2105 pAnchorItem->SetAnchor( m_pCopySource->Start() ); 2106 SfxItemSet aAnchorSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR ); 2107 aAnchorSet.Put( *pAnchorItem ); 2108 pDoc->SetFlyFrmAttr( *pFmt, aAnchorSet ); 2109 delete pAnchorItem; 2110 } 2111 DELETEZ( m_pCopySource ); 2112 } 2113 else 2114 { 2115 pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(), 2116 &aFrmSet, pParentFrmFmt ); 2117 } 2118 if(pFmt) 2119 { 2120 pFmt->Add(this); 2121 if(sName.Len()) 2122 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName); 2123 } 2124 //den SwXText wecken 2125 ((SwXTextFrame*)this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrmFmt()->GetDoc() ); 2126 } 2127 else if( eType == FLYCNTTYPE_GRF) 2128 { 2129 UnoActionContext aCont(pDoc); 2130 const ::uno::Any* pGraphicURL; 2131 String sGraphicURL; 2132 GraphicObject *pGrfObj = 0; 2133 if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL)) 2134 { 2135 OUString uTemp; 2136 (*pGraphicURL) >>= uTemp; 2137 sGraphicURL = String(uTemp); 2138 if( sGraphicURL.EqualsAscii( sPackageProtocol, 2139 0, sizeof( sPackageProtocol )-1 ) ) 2140 { 2141 pGrfObj = new GraphicObject; 2142 pGrfObj->SetUserData( sGraphicURL ); 2143 pGrfObj->SetSwapState(); 2144 sGraphicURL.Erase(); 2145 } 2146 else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol, 2147 0, sizeof(sGraphicObjectProtocol)-1 ) ) 2148 { 2149 ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ), 2150 RTL_TEXTENCODING_ASCII_US ); 2151 pGrfObj = new GraphicObject( sId ); 2152 sGraphicURL.Erase(); 2153 } 2154 } 2155 Graphic aGraphic; 2156 const ::uno::Any* pGraphic; 2157 if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic )) 2158 { 2159 uno::Reference< graphic::XGraphic > xGraphic; 2160 (*pGraphic) >>= xGraphic; 2161 aGraphic = Graphic( xGraphic ); 2162 } 2163 2164 String sFltName; 2165 const ::uno::Any* pFilter; 2166 if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter)) 2167 { 2168 OUString uTemp; 2169 (*pFilter) >>= uTemp; 2170 sFltName = String(uTemp); 2171 } 2172 2173 pFmt = 2174 pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet, 2175 pParentFrmFmt ) 2176 : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic, 2177 &aFrmSet, &aGrSet, pParentFrmFmt ); 2178 delete pGrfObj; 2179 if(pFmt) 2180 { 2181 SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx() 2182 ->GetIndex()+1 ]->GetGrfNode(); 2183 pGrfNd->SetChgTwipSize( !bSizeFound ); 2184 pFmt->Add(this); 2185 if(sName.Len()) 2186 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName); 2187 2188 } 2189 const ::uno::Any* pSurroundContour; 2190 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour)) 2191 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SURROUND_CONTOUR)), *pSurroundContour); 2192 const ::uno::Any* pContourOutside; 2193 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside)) 2194 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_OUTSIDE)), *pContourOutside); 2195 const ::uno::Any* pContourPoly; 2196 if(pProps->GetProperty(FN_PARAM_COUNTOUR_PP, 0, pContourPoly)) 2197 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_POLY_POLYGON)), *pContourPoly); 2198 const ::uno::Any* pPixelContour; 2199 if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour)) 2200 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_PIXEL_CONTOUR)), *pPixelContour); 2201 const ::uno::Any* pAutoContour; 2202 if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour)) 2203 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour); 2204 // const ::uno::Any* pAltText; 2205 // if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText)) 2206 // setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText); 2207 } 2208 else 2209 { 2210 const ::uno::Any* pCLSID = 0; 2211 const ::uno::Any* pStreamName = 0; 2212 if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName )) 2213 throw uno::RuntimeException(); 2214 if(pCLSID) 2215 { 2216 OUString aCLSID; 2217 SvGlobalName aClassName; 2218 uno::Reference < embed::XEmbeddedObject > xIPObj; 2219 std::auto_ptr < comphelper::EmbeddedObjectContainer > pCnt; 2220 if( (*pCLSID) >>= aCLSID ) 2221 { 2222 if( !aClassName.MakeId( aCLSID ) ) 2223 { 2224 lang::IllegalArgumentException aExcept; 2225 aExcept.Message = OUString::createFromAscii("CLSID invalid"); 2226 throw aExcept; 2227 } 2228 2229 pCnt.reset( new comphelper::EmbeddedObjectContainer ); 2230 ::rtl::OUString aName; 2231 xIPObj = pCnt->CreateEmbeddedObject( aClassName.GetByteSequence(), aName ); 2232 } 2233 if ( xIPObj.is() ) 2234 { 2235 //TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE 2236 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xIPObj->GetMiscStatus() && pDoc->getPrinter( false ) ) 2237 // xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) ); 2238 2239 UnoActionContext aAction(pDoc); 2240 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); 2241 if(!bSizeFound) 2242 { 2243 //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode? 2244 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 2245 2246 // TODO/LEAN: VisualArea still needs running state 2247 svt::EmbeddedObjectRef::TryRunningState( xIPObj ); 2248 2249 // set parent to get correct VisArea(in case of object needing parent printer) 2250 uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY ); 2251 if ( xChild.is() ) 2252 xChild->setParent( pDoc->GetDocShell()->GetModel() ); 2253 2254 //The Size should be suggested by the OLE server if not manually set 2255 MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) ); 2256 awt::Size aSize; 2257 try 2258 { 2259 aSize = xIPObj->getVisualAreaSize( nAspect ); 2260 } 2261 catch ( embed::NoVisualAreaSizeException& ) 2262 { 2263 // the default size will be set later 2264 } 2265 2266 Size aSz( aSize.Width, aSize.Height ); 2267 if ( !aSz.Width() || !aSz.Height() ) 2268 { 2269 aSz.Width() = aSz.Height() = 5000; 2270 aSz = OutputDevice::LogicToLogic 2271 ( aSz, MapMode( MAP_100TH_MM ), aRefMap ); 2272 } 2273 MapMode aMyMap( MAP_TWIP ); 2274 aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap ); 2275 SwFmtFrmSize aFrmSz; 2276 aFrmSz.SetSize(aSz); 2277 aFrmSet.Put(aFrmSz); 2278 } 2279 SwFlyFrmFmt* pFmt2 = 0; 2280 2281 // TODO/LATER: Is it the only possible aspect here? 2282 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 2283 ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect ); 2284 pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL ); 2285 ASSERT( pFmt2, "Doc->Insert(notxt) failed." ); 2286 2287 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); 2288 pFmt2->Add(this); 2289 if(sName.Len()) 2290 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName); 2291 } 2292 } 2293 else if( pStreamName ) 2294 { 2295 ::rtl::OUString sStreamName; 2296 (*pStreamName) >>= sStreamName; 2297 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); 2298 2299 SwFlyFrmFmt* pFrmFmt = 0; 2300 pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL ); 2301 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); 2302 pFrmFmt->Add(this); 2303 if(sName.Len()) 2304 pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName); 2305 } 2306 } 2307 if( pFmt && pDoc->GetDrawModel() ) 2308 GetOrCreateSdrObject( pFmt ); 2309 const ::uno::Any* pOrder; 2310 if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) ) 2311 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_Z_ORDER)), *pOrder); 2312 const ::uno::Any* pReplacement; 2313 if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) ) 2314 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement); 2315 // --> OD 2009-07-13 #i73249# 2316 // new attribute Title 2317 const ::uno::Any* pTitle; 2318 if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) ) 2319 { 2320 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle); 2321 } 2322 // new attribute Description 2323 const ::uno::Any* pDescription; 2324 if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) ) 2325 { 2326 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription); 2327 } 2328 // <-- 2329 } 2330 else 2331 throw lang::IllegalArgumentException(); 2332 //setzt das Flag zurueck und loescht den Descriptor-Pointer 2333 ResetDescriptor(); 2334 } 2335 2336 void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) 2337 throw( lang::IllegalArgumentException, uno::RuntimeException ) 2338 { 2339 SwFrmFmt* pFmt; 2340 if(IsDescriptor()) 2341 attachToRange(xTextRange); 2342 else if(0 != (pFmt = GetFrmFmt())) 2343 { 2344 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 2345 SwXTextRange* pRange = 0; 2346 OTextCursorHelper* pCursor = 0; 2347 if(xRangeTunnel.is()) 2348 { 2349 pRange = reinterpret_cast< SwXTextRange * >( 2350 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); 2351 pCursor = reinterpret_cast< OTextCursorHelper * >( 2352 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); 2353 } 2354 SwDoc* pDoc = pFmt->GetDoc(); 2355 SwUnoInternalPaM aIntPam(*pDoc); 2356 if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) 2357 { 2358 SfxItemSet aSet( pDoc->GetAttrPool(), 2359 RES_ANCHOR, RES_ANCHOR ); 2360 aSet.SetParent(&pFmt->GetAttrSet()); 2361 SwFmtAnchor aAnchor = (const SwFmtAnchor&)aSet.Get(RES_ANCHOR); 2362 aAnchor.SetAnchor( aIntPam.Start() ); 2363 aSet.Put(aAnchor); 2364 pDoc->SetFlyFrmAttr( *pFmt, aSet ); 2365 } 2366 else 2367 throw lang::IllegalArgumentException(); 2368 } 2369 } 2370 2371 awt::Point SwXFrame::getPosition(void) throw( uno::RuntimeException ) 2372 { 2373 vos::OGuard aGuard(Application::GetSolarMutex()); 2374 uno::RuntimeException aRuntime; 2375 aRuntime.Message = C2U("position cannot be determined with this method"); 2376 throw aRuntime; 2377 } 2378 2379 void SwXFrame::setPosition(const awt::Point& /*aPosition*/) throw( uno::RuntimeException ) 2380 { 2381 vos::OGuard aGuard(Application::GetSolarMutex()); 2382 uno::RuntimeException aRuntime; 2383 aRuntime.Message = C2U("position cannot be changed with this method"); 2384 throw aRuntime; 2385 } 2386 2387 awt::Size SwXFrame::getSize(void) throw( uno::RuntimeException ) 2388 { 2389 const ::uno::Any aVal = getPropertyValue(C2U("Size")); 2390 awt::Size* pRet = (awt::Size*)aVal.getValue(); 2391 return *pRet; 2392 } 2393 2394 void SwXFrame::setSize(const awt::Size& aSize) 2395 throw( beans::PropertyVetoException, uno::RuntimeException ) 2396 { 2397 const ::uno::Any aVal(&aSize, ::getCppuType(static_cast<const awt::Size*>(0))); 2398 setPropertyValue(C2U("Size"), aVal); 2399 } 2400 2401 OUString SwXFrame::getShapeType(void) throw( uno::RuntimeException ) 2402 { 2403 return C2U("FrameShape"); 2404 } 2405 2406 2407 /****************************************************************** 2408 * SwXTextFrame 2409 ******************************************************************/ 2410 2411 SwXTextFrame::SwXTextFrame( SwDoc *_pDoc ) : 2412 SwXText(0, CURSOR_FRAME), 2413 SwXFrame(FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME), _pDoc ) 2414 { 2415 } 2416 2417 SwXTextFrame::SwXTextFrame(SwFrmFmt& rFmt) : 2418 SwXText(rFmt.GetDoc(), CURSOR_FRAME), 2419 SwXFrame(rFmt, FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME)) 2420 { 2421 2422 } 2423 2424 SwXTextFrame::~SwXTextFrame() 2425 { 2426 } 2427 2428 void SAL_CALL SwXTextFrame::acquire( )throw() 2429 { 2430 SwXFrame::acquire(); 2431 } 2432 2433 void SAL_CALL SwXTextFrame::release( )throw() 2434 { 2435 SwXFrame::release(); 2436 } 2437 2438 ::uno::Any SAL_CALL SwXTextFrame::queryInterface( const uno::Type& aType ) 2439 throw (uno::RuntimeException) 2440 { 2441 ::uno::Any aRet = SwXFrame::queryInterface(aType); 2442 if(aRet.getValueType() == ::getCppuVoidType()) 2443 aRet = SwXText::queryInterface(aType); 2444 if(aRet.getValueType() == ::getCppuVoidType()) 2445 aRet = SwXTextFrameBaseClass::queryInterface(aType); 2446 return aRet; 2447 } 2448 2449 uno::Sequence< uno::Type > SAL_CALL SwXTextFrame::getTypes( ) throw(uno::RuntimeException) 2450 { 2451 uno::Sequence< uno::Type > aTextFrameTypes = SwXTextFrameBaseClass::getTypes(); 2452 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 2453 uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); 2454 2455 long nIndex = aTextFrameTypes.getLength(); 2456 aTextFrameTypes.realloc( 2457 aTextFrameTypes.getLength() + 2458 aFrameTypes.getLength() + 2459 aTextTypes.getLength()); 2460 2461 uno::Type* pTextFrameTypes = aTextFrameTypes.getArray(); 2462 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 2463 long nPos; 2464 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 2465 pTextFrameTypes[nIndex++] = pFrameTypes[nPos]; 2466 2467 const uno::Type* pTextTypes = aTextTypes.getConstArray(); 2468 for(nPos = 0; nPos <aTextTypes.getLength(); nPos++) 2469 pTextFrameTypes[nIndex++] = pTextTypes[nPos]; 2470 2471 return aTextFrameTypes; 2472 } 2473 2474 uno::Sequence< sal_Int8 > SAL_CALL SwXTextFrame::getImplementationId( ) throw(uno::RuntimeException) 2475 { 2476 vos::OGuard aGuard(Application::GetSolarMutex()); 2477 static uno::Sequence< sal_Int8 > aId( 16 ); 2478 static sal_Bool bInit = sal_False; 2479 if(!bInit) 2480 { 2481 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 2482 bInit = sal_True; 2483 } 2484 return aId; 2485 } 2486 2487 uno::Reference< text::XText > SwXTextFrame::getText(void) throw( uno::RuntimeException ) 2488 { 2489 return this; 2490 } 2491 2492 const SwStartNode *SwXTextFrame::GetStartNode() const 2493 { 2494 const SwStartNode *pSttNd = 0; 2495 2496 SwFrmFmt* pFmt = GetFrmFmt(); 2497 if(pFmt) 2498 { 2499 const SwFmtCntnt& rFlyCntnt = pFmt->GetCntnt(); 2500 if( rFlyCntnt.GetCntntIdx() ) 2501 pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode(); 2502 } 2503 2504 return pSttNd; 2505 } 2506 2507 uno::Reference< text::XTextCursor > 2508 SwXTextFrame::CreateCursor() throw (uno::RuntimeException) 2509 { 2510 return createTextCursor(); 2511 } 2512 2513 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( uno::RuntimeException ) 2514 { 2515 vos::OGuard aGuard(Application::GetSolarMutex()); 2516 uno::Reference< text::XTextCursor > aRef; 2517 SwFrmFmt* pFmt = GetFrmFmt(); 2518 if(pFmt) 2519 { 2520 //save current start node to be able to check if there is content after the table - 2521 //otherwise the cursor would be in the body text! 2522 const SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); 2523 const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode); 2524 2525 SwPaM aPam(rNode); 2526 aPam.Move(fnMoveForward, fnGoNode); 2527 SwTableNode* pTblNode = aPam.GetNode()->FindTableNode(); 2528 SwCntntNode* pCont = 0; 2529 while( pTblNode ) 2530 { 2531 aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); 2532 pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); 2533 pTblNode = pCont->FindTableNode(); 2534 } 2535 if(pCont) 2536 aPam.GetPoint()->nContent.Assign(pCont, 0); 2537 2538 const SwStartNode* pNewStartNode = 2539 aPam.GetNode()->FindSttNodeByType(SwFlyStartNode); 2540 if(!pNewStartNode || pNewStartNode != pOwnStartNode) 2541 { 2542 uno::RuntimeException aExcept; 2543 aExcept.Message = S2U("no text available"); 2544 throw aExcept; 2545 } 2546 2547 SwXTextCursor *const pXCursor = new SwXTextCursor( 2548 *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint()); 2549 aRef = static_cast<text::XWordCursor*>(pXCursor); 2550 #if OSL_DEBUG_LEVEL > 1 2551 SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); 2552 (void) pUnoCrsr; 2553 #endif 2554 } 2555 else 2556 throw uno::RuntimeException(); 2557 return aRef; 2558 } 2559 2560 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) 2561 { 2562 vos::OGuard aGuard(Application::GetSolarMutex()); 2563 uno::Reference< text::XTextCursor > aRef; 2564 SwFrmFmt* pFmt = GetFrmFmt(); 2565 SwUnoInternalPaM aPam(*GetDoc()); 2566 if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) 2567 { 2568 SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); 2569 #if OSL_DEBUG_LEVEL > 1 2570 const SwStartNode* p1 = aPam.GetNode()->FindFlyStartNode(); 2571 const SwStartNode* p2 = rNode.FindFlyStartNode(); 2572 (void)p1; 2573 (void)p2; 2574 #endif 2575 if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode()) 2576 { 2577 aRef = static_cast<text::XWordCursor*>( 2578 new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME, 2579 *aPam.GetPoint(), aPam.GetMark())); 2580 } 2581 } 2582 else 2583 throw uno::RuntimeException(); 2584 return aRef; 2585 } 2586 2587 uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) throw( uno::RuntimeException ) 2588 { 2589 vos::OGuard aGuard(Application::GetSolarMutex()); 2590 uno::Reference< container::XEnumeration > aRef; 2591 SwFrmFmt* pFmt = GetFrmFmt(); 2592 if(pFmt) 2593 { 2594 SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode()); 2595 ::std::auto_ptr<SwUnoCrsr> pUnoCursor( 2596 GetDoc()->CreateUnoCrsr(aPos, sal_False)); 2597 pUnoCursor->Move(fnMoveForward, fnGoNode); 2598 // // no Cursor in protected sections 2599 // SwCrsrSaveState aSave( *pUnoCrsr ); 2600 // if(pUnoCrsr->IsInProtectTable( sal_True ) || 2601 // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS )) 2602 // throw uno::RuntimeException() ); 2603 aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME); 2604 } 2605 return aRef; 2606 } 2607 2608 uno::Type SwXTextFrame::getElementType(void) throw( uno::RuntimeException ) 2609 { 2610 return ::getCppuType(static_cast<uno::Reference<text::XTextRange>*>(0)); 2611 } 2612 2613 sal_Bool SwXTextFrame::hasElements(void) throw( uno::RuntimeException ) 2614 { 2615 return sal_True; 2616 } 2617 2618 void SwXTextFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) 2619 throw( lang::IllegalArgumentException, uno::RuntimeException ) 2620 { 2621 SwXFrame::attach(xTextRange); 2622 } 2623 2624 uno::Reference< text::XTextRange > SwXTextFrame::getAnchor(void) throw( uno::RuntimeException ) 2625 { 2626 vos::OGuard aGuard(Application::GetSolarMutex()); 2627 return SwXFrame::getAnchor(); 2628 } 2629 2630 void SwXTextFrame::dispose(void) throw( uno::RuntimeException ) 2631 { 2632 vos::OGuard aGuard(Application::GetSolarMutex()); 2633 SwXFrame::dispose(); 2634 } 2635 2636 void SwXTextFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2637 { 2638 SwXFrame::addEventListener(aListener); 2639 } 2640 2641 void SwXTextFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2642 { 2643 SwXFrame::removeEventListener(aListener); 2644 } 2645 2646 OUString SwXTextFrame::getImplementationName(void) throw( uno::RuntimeException ) 2647 { 2648 return C2U("SwXTextFrame"); 2649 } 2650 2651 sal_Bool SwXTextFrame::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 2652 { 2653 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.Text")|| 2654 COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextFrame")|| 2655 SwXFrame::supportsService(rServiceName); 2656 } 2657 2658 uno::Sequence< OUString > SwXTextFrame::getSupportedServiceNames(void) throw( uno::RuntimeException ) 2659 { 2660 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 2661 aRet.realloc(aRet.getLength() + 2); 2662 OUString* pArray = aRet.getArray(); 2663 pArray[aRet.getLength() - 2] = C2U("com.sun.star.text.TextFrame"); 2664 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.Text"); 2665 return aRet; 2666 } 2667 2668 void * SAL_CALL SwXTextFrame::operator new( size_t t) throw() 2669 { 2670 return SwXTextFrameBaseClass::operator new( t); 2671 } 2672 2673 void SAL_CALL SwXTextFrame::operator delete( void * p) throw() 2674 { 2675 SwXTextFrameBaseClass::operator delete(p); 2676 } 2677 2678 uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents() 2679 throw(uno::RuntimeException) 2680 { 2681 return new SwFrameEventDescriptor( *this ); 2682 } 2683 2684 sal_Int64 SAL_CALL SwXTextFrame::getSomething( const uno::Sequence< sal_Int8 >& rId ) 2685 throw(uno::RuntimeException) 2686 { 2687 sal_Int64 nRet = SwXFrame::getSomething( rId ); 2688 if( !nRet ) 2689 nRet = SwXText::getSomething( rId ); 2690 2691 return nRet; 2692 } 2693 2694 ::uno::Any SwXTextFrame::getPropertyValue(const OUString& rPropertyName) 2695 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2696 { 2697 vos::OGuard aGuard(Application::GetSolarMutex()); 2698 ::uno::Any aRet; 2699 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| 2700 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) 2701 { 2702 //redline can only be returned if it's a living object 2703 if(!IsDescriptor()) 2704 aRet = SwXText::getPropertyValue(rPropertyName); 2705 } 2706 else 2707 aRet = SwXFrame::getPropertyValue(rPropertyName); 2708 return aRet; 2709 } 2710 /****************************************************************** 2711 * SwXTextGraphicObject 2712 ******************************************************************/ 2713 2714 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc *pDoc ) : 2715 SwXFrame(FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC), pDoc) 2716 { 2717 } 2718 2719 SwXTextGraphicObject::SwXTextGraphicObject(SwFrmFmt& rFmt) : 2720 SwXFrame(rFmt, FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC)) 2721 { 2722 2723 } 2724 2725 SwXTextGraphicObject::~SwXTextGraphicObject() 2726 { 2727 2728 } 2729 2730 void SAL_CALL SwXTextGraphicObject::acquire( )throw() 2731 { 2732 SwXFrame::acquire(); 2733 } 2734 2735 void SAL_CALL SwXTextGraphicObject::release( )throw() 2736 { 2737 SwXFrame::release(); 2738 } 2739 2740 ::uno::Any SAL_CALL SwXTextGraphicObject::queryInterface( const uno::Type& aType ) 2741 throw(uno::RuntimeException) 2742 { 2743 ::uno::Any aRet = SwXFrame::queryInterface(aType); 2744 if(aRet.getValueType() == ::getCppuVoidType()) 2745 aRet = SwXTextGraphicObjectBaseClass::queryInterface(aType); 2746 return aRet; 2747 } 2748 2749 uno::Sequence< uno::Type > SAL_CALL 2750 SwXTextGraphicObject::getTypes( ) throw(uno::RuntimeException) 2751 { 2752 uno::Sequence< uno::Type > aGraphicTypes = SwXTextGraphicObjectBaseClass::getTypes(); 2753 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 2754 2755 long nIndex = aGraphicTypes.getLength(); 2756 aGraphicTypes.realloc( 2757 aGraphicTypes.getLength() + 2758 aFrameTypes.getLength()); 2759 2760 uno::Type* pGraphicTypes = aGraphicTypes.getArray(); 2761 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 2762 long nPos; 2763 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 2764 pGraphicTypes[nIndex++] = pFrameTypes[nPos]; 2765 2766 return aGraphicTypes; 2767 } 2768 2769 uno::Sequence< sal_Int8 > SAL_CALL SwXTextGraphicObject::getImplementationId( ) throw(uno::RuntimeException) 2770 { 2771 vos::OGuard aGuard(Application::GetSolarMutex()); 2772 static uno::Sequence< sal_Int8 > aId( 16 ); 2773 static sal_Bool bInit = sal_False; 2774 if(!bInit) 2775 { 2776 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 2777 bInit = sal_True; 2778 } 2779 return aId; 2780 } 2781 2782 void SwXTextGraphicObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException ) 2783 { 2784 SwXFrame::attach(xTextRange); 2785 } 2786 2787 uno::Reference< text::XTextRange > SwXTextGraphicObject::getAnchor(void) throw( uno::RuntimeException ) 2788 { 2789 vos::OGuard aGuard(Application::GetSolarMutex()); 2790 return SwXFrame::getAnchor(); 2791 } 2792 2793 void SwXTextGraphicObject::dispose(void) throw( uno::RuntimeException ) 2794 { 2795 vos::OGuard aGuard(Application::GetSolarMutex()); 2796 SwXFrame::dispose(); 2797 } 2798 2799 void SwXTextGraphicObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) 2800 throw( uno::RuntimeException ) 2801 { 2802 SwXFrame::addEventListener(aListener); 2803 } 2804 2805 void SwXTextGraphicObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) 2806 throw( uno::RuntimeException ) 2807 { 2808 SwXFrame::removeEventListener(aListener); 2809 } 2810 2811 OUString SwXTextGraphicObject::getImplementationName(void) throw( uno::RuntimeException ) 2812 { 2813 return C2U("SwXTextGraphicObject"); 2814 } 2815 2816 sal_Bool SwXTextGraphicObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 2817 { 2818 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextGraphicObject") || 2819 SwXFrame::supportsService(rServiceName); 2820 } 2821 2822 uno::Sequence< OUString > SwXTextGraphicObject::getSupportedServiceNames(void) 2823 throw( uno::RuntimeException ) 2824 { 2825 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 2826 aRet.realloc(aRet.getLength() + 1); 2827 OUString* pArray = aRet.getArray(); 2828 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextGraphicObject"); 2829 return aRet; 2830 } 2831 2832 void * SAL_CALL SwXTextGraphicObject::operator new( size_t t) throw() 2833 { 2834 return SwXTextGraphicObjectBaseClass::operator new(t); 2835 } 2836 2837 void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw() 2838 { 2839 SwXTextGraphicObjectBaseClass::operator delete(p); 2840 } 2841 2842 uno::Reference<container::XNameReplace> SAL_CALL 2843 SwXTextGraphicObject::getEvents() 2844 throw(uno::RuntimeException) 2845 { 2846 return new SwFrameEventDescriptor( *this ); 2847 } 2848 2849 /****************************************************************** 2850 * 2851 ******************************************************************/ 2852 2853 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc *pDoc ) : 2854 SwXFrame(FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT), pDoc) 2855 { 2856 } 2857 2858 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrmFmt& rFmt) : 2859 SwXFrame(rFmt, FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT)) 2860 { 2861 2862 } 2863 2864 SwXTextEmbeddedObject::~SwXTextEmbeddedObject() 2865 { 2866 2867 } 2868 2869 void SAL_CALL SwXTextEmbeddedObject::acquire()throw() 2870 { 2871 SwXFrame::acquire(); 2872 } 2873 2874 void SAL_CALL SwXTextEmbeddedObject::release()throw() 2875 { 2876 SwXFrame::release(); 2877 } 2878 2879 ::uno::Any SAL_CALL SwXTextEmbeddedObject::queryInterface( const uno::Type& aType ) 2880 throw( uno::RuntimeException) 2881 { 2882 ::uno::Any aRet = SwXFrame::queryInterface(aType);; 2883 if(aRet.getValueType() == ::getCppuVoidType()) 2884 aRet = SwXTextEmbeddedObjectBaseClass::queryInterface(aType); 2885 return aRet; 2886 } 2887 2888 uno::Sequence< uno::Type > SAL_CALL SwXTextEmbeddedObject::getTypes( ) throw(uno::RuntimeException) 2889 { 2890 uno::Sequence< uno::Type > aTextEmbeddedTypes = SwXTextEmbeddedObjectBaseClass::getTypes(); 2891 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 2892 2893 long nIndex = aTextEmbeddedTypes.getLength(); 2894 aTextEmbeddedTypes.realloc( 2895 aTextEmbeddedTypes.getLength() + 2896 aFrameTypes.getLength()); 2897 2898 uno::Type* pTextEmbeddedTypes = aTextEmbeddedTypes.getArray(); 2899 2900 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 2901 long nPos; 2902 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 2903 pTextEmbeddedTypes[nIndex++] = pFrameTypes[nPos]; 2904 2905 return aTextEmbeddedTypes; 2906 } 2907 2908 uno::Sequence< sal_Int8 > SAL_CALL SwXTextEmbeddedObject::getImplementationId( ) throw(uno::RuntimeException) 2909 { 2910 vos::OGuard aGuard(Application::GetSolarMutex()); 2911 static uno::Sequence< sal_Int8 > aId( 16 ); 2912 static sal_Bool bInit = sal_False; 2913 if(!bInit) 2914 { 2915 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 2916 bInit = sal_True; 2917 } 2918 return aId; 2919 } 2920 2921 void SwXTextEmbeddedObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException ) 2922 { 2923 SwXFrame::attach(xTextRange); 2924 } 2925 2926 uno::Reference< text::XTextRange > SwXTextEmbeddedObject::getAnchor(void) throw( uno::RuntimeException ) 2927 { 2928 vos::OGuard aGuard(Application::GetSolarMutex()); 2929 return SwXFrame::getAnchor(); 2930 } 2931 2932 void SwXTextEmbeddedObject::dispose(void) throw( uno::RuntimeException ) 2933 { 2934 vos::OGuard aGuard(Application::GetSolarMutex()); 2935 SwXFrame::dispose(); 2936 } 2937 2938 void SwXTextEmbeddedObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2939 { 2940 SwXFrame::addEventListener(aListener); 2941 } 2942 2943 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2944 { 2945 SwXFrame::removeEventListener(aListener); 2946 } 2947 2948 uno::Reference< lang::XComponent > SwXTextEmbeddedObject::getEmbeddedObject(void) throw( uno::RuntimeException ) 2949 { 2950 uno::Reference< lang::XComponent > xRet; 2951 SwFrmFmt* pFmt = GetFrmFmt(); 2952 if(pFmt) 2953 { 2954 SwDoc* pDoc = pFmt->GetDoc(); 2955 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 2956 DBG_ASSERT( pCnt->GetCntntIdx() && 2957 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 2958 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 2959 2960 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 2961 ->GetIndex() + 1 ]->GetOLENode(); 2962 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef(); 2963 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) 2964 { 2965 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here 2966 if ( pDoc->GetDocShell() ) 2967 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) ); 2968 2969 xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY ); 2970 uno::Reference< util::XModifyBroadcaster > xBrdcst( xRet, uno::UNO_QUERY); 2971 uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY); 2972 if( xBrdcst.is() && xModel.is() ) 2973 { 2974 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt ); 2975 //create a new one if the OLE object doesn't have one already 2976 if( !pListener ) 2977 { 2978 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel); 2979 xBrdcst->addModifyListener( xOLEListener ); 2980 } 2981 } 2982 } 2983 } 2984 return xRet; 2985 } 2986 2987 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject() 2988 throw( uno::RuntimeException ) 2989 { 2990 uno::Reference< embed::XEmbeddedObject > xResult; 2991 SwFrmFmt* pFmt = GetFrmFmt(); 2992 if(pFmt) 2993 { 2994 SwDoc* pDoc = pFmt->GetDoc(); 2995 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 2996 DBG_ASSERT( pCnt->GetCntntIdx() && 2997 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 2998 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 2999 3000 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 3001 ->GetIndex() + 1 ]->GetOLENode(); 3002 xResult = pOleNode->GetOLEObj().GetOleRef(); 3003 if ( svt::EmbeddedObjectRef::TryRunningState( xResult ) ) 3004 { 3005 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here 3006 if ( pDoc->GetDocShell() ) 3007 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult, embed::Aspects::MSOLE_CONTENT ) ); 3008 3009 uno::Reference < lang::XComponent > xComp( xResult->getComponent(), uno::UNO_QUERY ); 3010 uno::Reference< util::XModifyBroadcaster > xBrdcst( xComp, uno::UNO_QUERY); 3011 uno::Reference< frame::XModel > xModel( xComp, uno::UNO_QUERY); 3012 if( xBrdcst.is() && xModel.is() ) 3013 { 3014 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt ); 3015 //create a new one if the OLE object doesn't have one already 3016 if( !pListener ) 3017 { 3018 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel); 3019 xBrdcst->addModifyListener( xOLEListener ); 3020 } 3021 } 3022 } 3023 } 3024 return xResult; 3025 } 3026 3027 sal_Int64 SAL_CALL SwXTextEmbeddedObject::getAspect() throw (uno::RuntimeException) 3028 { 3029 SwFrmFmt* pFmt = GetFrmFmt(); 3030 if(pFmt) 3031 { 3032 SwDoc* pDoc = pFmt->GetDoc(); 3033 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3034 DBG_ASSERT( pCnt->GetCntntIdx() && 3035 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3036 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3037 3038 return pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect(); 3039 } 3040 3041 return embed::Aspects::MSOLE_CONTENT; // return the default value 3042 } 3043 3044 void SAL_CALL SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect ) throw (uno::RuntimeException) 3045 { 3046 SwFrmFmt* pFmt = GetFrmFmt(); 3047 if(pFmt) 3048 { 3049 SwDoc* pDoc = pFmt->GetDoc(); 3050 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3051 DBG_ASSERT( pCnt->GetCntntIdx() && 3052 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3053 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3054 3055 pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect ); 3056 } 3057 } 3058 3059 uno::Reference< graphic::XGraphic > SAL_CALL SwXTextEmbeddedObject::getReplacementGraphic() throw (uno::RuntimeException) 3060 { 3061 SwFrmFmt* pFmt = GetFrmFmt(); 3062 if(pFmt) 3063 { 3064 SwDoc* pDoc = pFmt->GetDoc(); 3065 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3066 DBG_ASSERT( pCnt->GetCntntIdx() && 3067 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3068 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3069 3070 Graphic* pGraphic = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic(); 3071 if ( pGraphic ) 3072 return pGraphic->GetXGraphic(); 3073 } 3074 3075 return uno::Reference< graphic::XGraphic >(); 3076 } 3077 3078 3079 OUString SwXTextEmbeddedObject::getImplementationName(void) throw( uno::RuntimeException ) 3080 3081 { 3082 return C2U("SwXTextEmbeddedObject"); 3083 } 3084 3085 sal_Bool SwXTextEmbeddedObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 3086 { 3087 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextEmbeddedObject")|| 3088 SwXFrame::supportsService(rServiceName); 3089 } 3090 3091 uno::Sequence< OUString > SwXTextEmbeddedObject::getSupportedServiceNames(void) 3092 throw( uno::RuntimeException ) 3093 { 3094 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 3095 aRet.realloc(aRet.getLength() + 1); 3096 OUString* pArray = aRet.getArray(); 3097 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextEmbeddedObject"); 3098 return aRet; 3099 } 3100 3101 void * SAL_CALL SwXTextEmbeddedObject::operator new( size_t t) throw() 3102 { 3103 return SwXTextEmbeddedObjectBaseClass::operator new(t); 3104 } 3105 3106 void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw() 3107 { 3108 SwXTextEmbeddedObjectBaseClass::operator delete(p); 3109 } 3110 3111 uno::Reference<container::XNameReplace> SAL_CALL 3112 SwXTextEmbeddedObject::getEvents() 3113 throw(uno::RuntimeException) 3114 { 3115 return new SwFrameEventDescriptor( *this ); 3116 } 3117 3118 3119 /****************************************************************** 3120 * 3121 ******************************************************************/ 3122 TYPEINIT1(SwXOLEListener, SwClient); 3123 3124 SwXOLEListener::SwXOLEListener( SwFmt& rOLEFmt, uno::Reference< XModel > xOLE) : 3125 SwClient(&rOLEFmt), 3126 xOLEModel(xOLE) 3127 { 3128 } 3129 3130 SwXOLEListener::~SwXOLEListener() 3131 {} 3132 3133 void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ ) 3134 throw( uno::RuntimeException ) 3135 { 3136 vos::OGuard aGuard(Application::GetSolarMutex()); 3137 3138 SwOLENode* pNd = 0; 3139 SwFmt* pFmt = GetFmt(); 3140 if(pFmt) 3141 {const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 3142 if(pIdx) 3143 { 3144 SwNodeIndex aIdx(*pIdx, 1); 3145 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 3146 pNd = pNoTxt->GetOLENode(); 3147 } 3148 } 3149 if(!pNd) 3150 throw uno::RuntimeException(); 3151 3152 uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef(); 3153 if ( xIP.is() ) 3154 { 3155 sal_Int32 nState = xIP->getCurrentState(); 3156 if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE ) 3157 return; 3158 } 3159 3160 // if the OLE-Node is UI-Active do nothing 3161 pNd->SetOLESizeInvalid( sal_True ); 3162 pNd->GetDoc()->SetOLEObjModified(); 3163 } 3164 3165 /* --------------------------------------------------------------------------- 3166 3167 ---------------------------------------------------------------------------*/ 3168 void SwXOLEListener::disposing( const lang::EventObject& rEvent ) 3169 throw( uno::RuntimeException ) 3170 { 3171 vos::OGuard aGuard(Application::GetSolarMutex()); 3172 3173 uno::Reference< util::XModifyListener > xListener( this ); 3174 3175 3176 uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY ); 3177 uno::Reference< util::XModifyBroadcaster > xBrdcst(xModel, uno::UNO_QUERY); 3178 3179 try 3180 { 3181 if( xBrdcst.is() ) 3182 xBrdcst->removeModifyListener( xListener ); 3183 } 3184 catch(uno::Exception const &) 3185 { 3186 DBG_ERROR("OLE Listener couldn't be removed"); 3187 } 3188 } 3189 /* --------------------------------------------------------------------------- 3190 3191 ---------------------------------------------------------------------------*/ 3192 void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) 3193 { 3194 ClientModify(this, pOld, pNew); 3195 if(!GetRegisteredIn()) 3196 xOLEModel = 0; 3197 } 3198 3199