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