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