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