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 if(!bDone) 1769 { 1770 m_pPropSet->setPropertyValue(*pEntry, aValue, aSet); 1771 } 1772 1773 if(RES_ANCHOR == pEntry->nWID && MID_ANCHOR_ANCHORTYPE == nMemberId) 1774 { 1775 SwFmtAnchor aAnchor = (const :: SwFmtAnchor&)aSet.Get(pEntry->nWID); 1776 if(aAnchor.GetAnchorId() == FLY_AT_FLY) 1777 { 1778 const :: SwPosition* pPosition = aAnchor.GetCntntAnchor(); 1779 SwFrmFmt* pFlyFmt = pPosition ? pPosition->nNode.GetNode().GetFlyFmt() : 0; 1780 if(!pFlyFmt || pFlyFmt->Which() == RES_DRAWFRMFMT) 1781 { 1782 lang::IllegalArgumentException aExcept; 1783 aExcept.Message = C2U("Anchor to frame: no frame found"); 1784 throw aExcept; 1785 } 1786 else 1787 { 1788 SwPosition aPos = *pPosition; 1789 aPos.nNode = *pFlyFmt->GetCntnt().GetCntntIdx(); 1790 aAnchor.SetAnchor(&aPos); 1791 aSet.Put(aAnchor); 1792 } 1793 } 1794 else if ((aAnchor.GetAnchorId() != FLY_AT_PAGE) && 1795 !aAnchor.GetCntntAnchor()) 1796 { 1797 SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); 1798 SwPaM aPam(rNode); 1799 aPam.Move( fnMoveBackward, fnGoDoc ); 1800 aAnchor.SetAnchor( aPam.Start() ); 1801 aSet.Put(aAnchor); 1802 } 1803 1804 // --> OD 2004-08-13 #i31771#, #i25798# - No adjustment of 1805 // anchor ( no call of method <::lcl_ChkAndSetNewAnchor(..)> ), 1806 // if document is currently in reading mode. 1807 if ( !pFmt->GetDoc()->IsInReading() ) 1808 { 1809 // see SwFEShell::SetFlyFrmAttr( SfxItemSet& rSet ) 1810 SwFlyFrm *pFly = 0; 1811 if (PTR_CAST(SwFlyFrmFmt, pFmt)) 1812 pFly = ((SwFlyFrmFmt*)pFmt)->GetFrm(); 1813 if (pFly) 1814 { 1815 const :: SfxPoolItem* pItem; 1816 if( SFX_ITEM_SET == aSet.GetItemState( RES_ANCHOR, sal_False, &pItem )) 1817 { 1818 aSet.Put( *pItem ); 1819 if ( pFmt->GetDoc()->GetEditShell() != NULL ) 1820 { 1821 ::lcl_ChkAndSetNewAnchor( *(pFmt->GetDoc()->GetEditShell()), *pFly, aSet ); 1822 } 1823 } 1824 } 1825 } 1826 // <-- 1827 1828 pFmt->GetDoc()->SetFlyFrmAttr( *pFmt, aSet ); 1829 } 1830 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_STREAM_NAME == pEntry->nWID) 1831 { 1832 throw lang::IllegalArgumentException(); 1833 } 1834 else 1835 pFmt->SetFmtAttr(aSet); 1836 } 1837 } 1838 else if(IsDescriptor()) 1839 { 1840 pProps->SetProperty(pEntry->nWID, nMemberId, aValue); 1841 if( FN_UNO_FRAME_STYLE_NAME == pEntry->nWID ) 1842 { 1843 OUString sStyleName; 1844 aValue >>= sStyleName; 1845 try 1846 { 1847 uno::Any aAny = mxStyleFamily->getByName ( sStyleName ); 1848 aAny >>= mxStyleData; 1849 } 1850 catch ( container::NoSuchElementException const & ) 1851 { 1852 } 1853 catch ( lang::WrappedTargetException const & ) 1854 { 1855 } 1856 catch ( uno::RuntimeException const & ) 1857 { 1858 } 1859 } 1860 } 1861 else 1862 throw uno::RuntimeException(); 1863 } 1864 1865 uno::Any SwXFrame::getPropertyValue(const OUString& rPropertyName) 1866 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 1867 { 1868 vos::OGuard aGuard(Application::GetSolarMutex()); 1869 uno::Any aAny; 1870 SwFrmFmt* pFmt = GetFrmFmt(); 1871 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 1872 if (!pEntry) 1873 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 1874 1875 //UUUU 1876 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 1877 1878 if(FN_UNO_ANCHOR_TYPES == pEntry->nWID) 1879 { 1880 uno::Sequence<text::TextContentAnchorType> aTypes(5); 1881 text::TextContentAnchorType* pArray = aTypes.getArray(); 1882 pArray[0] = text::TextContentAnchorType_AT_PARAGRAPH; 1883 pArray[1] = text::TextContentAnchorType_AS_CHARACTER; 1884 pArray[2] = text::TextContentAnchorType_AT_PAGE; 1885 pArray[3] = text::TextContentAnchorType_AT_FRAME; 1886 pArray[4] = text::TextContentAnchorType_AT_CHARACTER; 1887 aAny.setValue(&aTypes, ::getCppuType(static_cast<uno::Sequence<text::TextContentAnchorType>*>(0))); 1888 } 1889 else if(pFmt) 1890 { 1891 if( ((eType == FLYCNTTYPE_GRF) || (eType == FLYCNTTYPE_OLE)) && 1892 pEntry && 1893 (isGRFATR(pEntry->nWID) || 1894 pEntry->nWID == FN_PARAM_COUNTOUR_PP || 1895 pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR || 1896 pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR )) 1897 { 1898 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1899 if(pIdx) 1900 { 1901 SwNodeIndex aIdx(*pIdx, 1); 1902 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1903 if(pEntry->nWID == FN_PARAM_COUNTOUR_PP) 1904 { 1905 PolyPolygon aContour; 1906 if( pNoTxt->GetContourAPI( aContour ) ) 1907 { 1908 drawing::PointSequenceSequence aPtSeq(aContour.Count()); 1909 drawing::PointSequence* pPSeq = aPtSeq.getArray(); 1910 for(sal_uInt16 i = 0; i < aContour.Count(); i++) 1911 { 1912 const Polygon& rPoly = aContour.GetObject(i); 1913 pPSeq[i].realloc(rPoly.GetSize()); 1914 awt::Point* pPoints = pPSeq[i].getArray(); 1915 for(sal_uInt16 j = 0; j < rPoly.GetSize(); j++) 1916 { 1917 const Point& rPoint = rPoly.GetPoint(j); 1918 pPoints[j].X = rPoint.X(); 1919 pPoints[j].Y = rPoint.Y(); 1920 } 1921 } 1922 aAny <<= aPtSeq; 1923 } 1924 } 1925 else if(pEntry->nWID == FN_UNO_IS_AUTOMATIC_CONTOUR ) 1926 { 1927 sal_Bool bValue = pNoTxt->HasAutomaticContour(); 1928 aAny.setValue( &bValue, ::getBooleanCppuType() ); 1929 } 1930 else if(pEntry->nWID == FN_UNO_IS_PIXEL_CONTOUR ) 1931 { 1932 sal_Bool bValue = pNoTxt->IsPixelContour(); 1933 aAny.setValue( &bValue, ::getBooleanCppuType() ); 1934 } 1935 else 1936 { 1937 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 1938 m_pPropSet->getPropertyValue(*pEntry, aSet, aAny); 1939 } 1940 } 1941 } 1942 else if( FN_UNO_GRAPHIC_U_R_L == pEntry->nWID) 1943 { 1944 String sGrfName; 1945 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1946 if(pIdx) 1947 { 1948 SwNodeIndex aIdx(*pIdx, 1); 1949 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 1950 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1951 if(!pGrfNode) 1952 throw uno::RuntimeException(); 1953 if( pGrfNode->IsGrfLink() ) 1954 { 1955 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, &sGrfName, 0 ); 1956 } 1957 else 1958 { 1959 String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) ); 1960 String sId( pGrfNode->GetGrfObj().GetUniqueID(), 1961 RTL_TEXTENCODING_ASCII_US ); 1962 (sGrfName = sPrefix) += sId; 1963 } 1964 } 1965 aAny <<= OUString(sGrfName); 1966 } 1967 else if( FN_UNO_REPLACEMENT_GRAPHIC_U_R_L == pEntry->nWID) 1968 { 1969 String sGrfName; 1970 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 1971 1972 if(pIdx) 1973 { 1974 SwNodeIndex aIdx(*pIdx, 1); 1975 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 1976 if(!pGrfNode) 1977 throw uno::RuntimeException(); 1978 1979 const GraphicObject* pGraphicObject = pGrfNode->GetReplacementGrfObj(); 1980 1981 if(pGraphicObject) 1982 { 1983 String sPrefix( RTL_CONSTASCII_STRINGPARAM(sGraphicObjectProtocol) ); 1984 String sId( pGraphicObject->GetUniqueID(), RTL_TEXTENCODING_ASCII_US ); 1985 (sGrfName = sPrefix) += sId; 1986 } 1987 } 1988 1989 aAny <<= OUString(sGrfName); 1990 } 1991 else if( FN_UNO_GRAPHIC_FILTER == pEntry->nWID ) 1992 { 1993 String sFltName; 1994 pFmt->GetDoc()->GetGrfNms( *(SwFlyFrmFmt*)pFmt, 0, &sFltName ); 1995 aAny <<= OUString(sFltName); 1996 } 1997 else if( FN_UNO_GRAPHIC == pEntry->nWID ) 1998 { 1999 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2000 if(pIdx) 2001 { 2002 SwNodeIndex aIdx(*pIdx, 1); 2003 SwGrfNode* pGrfNode = aIdx.GetNode().GetGrfNode(); 2004 if(!pGrfNode) 2005 throw uno::RuntimeException(); 2006 aAny <<= pGrfNode->GetGrf().GetXGraphic(); 2007 } 2008 } 2009 else if(FN_UNO_FRAME_STYLE_NAME == pEntry->nWID) 2010 { 2011 aAny <<= OUString(SwStyleNameMapper::GetProgName(pFmt->DerivedFrom()->GetName(), nsSwGetPoolIdFromName::GET_POOLID_FRMFMT ) ); 2012 } 2013 // --> OD 2009-07-13 #i73249# 2014 // Attribute AlternativeText was never published. 2015 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances 2016 // else if(eType != FLYCNTTYPE_FRM && 2017 // FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) 2018 // { 2019 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2020 // if(pIdx) 2021 // { 2022 // SwNodeIndex aIdx(*pIdx, 1); 2023 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 2024 // aAny <<= OUString(pNoTxt->GetAlternateText()); 2025 // } 2026 // } 2027 else if( FN_UNO_TITLE == pEntry->nWID ) 2028 { 2029 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 2030 ASSERT( pFmt, 2031 "unexpected type of <pFmt> --> crash" ); 2032 // assure that <SdrObject> instance exists. 2033 GetOrCreateSdrObject( pFlyFmt ); 2034 aAny <<= OUString(pFlyFmt->GetObjTitle()); 2035 } 2036 // New attribute Description 2037 else if( FN_UNO_DESCRIPTION == pEntry->nWID ) 2038 { 2039 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 2040 ASSERT( pFmt, 2041 "unexpected type of <pFmt> --> crash" ); 2042 // assure that <SdrObject> instance exists. 2043 GetOrCreateSdrObject( pFlyFmt ); 2044 aAny <<= OUString(pFlyFmt->GetObjDescription()); 2045 } 2046 // <-- 2047 else if(eType == FLYCNTTYPE_GRF && 2048 (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ACTUAL_SIZE)))) 2049 { 2050 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2051 if(pIdx) 2052 { 2053 SwNodeIndex aIdx(*pIdx, 1); 2054 // --> OD #i85105# 2055 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 2056 // Size aActSize = ((SwGrfNode*)pNoTxt)->GetTwipSize(); 2057 Size aActSize; 2058 { 2059 SwGrfNode* pGrfNode = dynamic_cast<SwGrfNode*>(aIdx.GetNode().GetNoTxtNode()); 2060 if ( pGrfNode ) 2061 { 2062 aActSize = pGrfNode->GetTwipSize(); 2063 if ( aActSize.Width() == 0 && aActSize.Height() == 0 && 2064 pGrfNode->IsLinkedFile() ) 2065 { 2066 pGrfNode->SwapIn( sal_True ); 2067 aActSize = pGrfNode->GetTwipSize(); 2068 } 2069 } 2070 } 2071 // <-- 2072 awt::Size aTmp; 2073 aTmp.Width = TWIP_TO_MM100(aActSize.Width()); 2074 aTmp.Height = TWIP_TO_MM100(aActSize.Height()); 2075 aAny.setValue(&aTmp, ::getCppuType(static_cast<const awt::Size*>(0))); 2076 } 2077 } 2078 else if(FN_PARAM_LINK_DISPLAY_NAME == pEntry->nWID) 2079 { 2080 aAny <<= OUString(pFmt->GetName()); 2081 } 2082 else if(FN_UNO_Z_ORDER == pEntry->nWID) 2083 { 2084 const SdrObject* pObj = pFmt->FindRealSdrObject(); 2085 if( pObj ) 2086 { 2087 aAny <<= (sal_Int32)pObj->GetOrdNum(); 2088 } 2089 } 2090 else if(FN_UNO_CLSID == pEntry->nWID || FN_UNO_MODEL == pEntry->nWID|| 2091 FN_UNO_COMPONENT == pEntry->nWID ||FN_UNO_STREAM_NAME == pEntry->nWID|| 2092 FN_EMBEDDED_OBJECT == pEntry->nWID) 2093 { 2094 SwDoc* pDoc = pFmt->GetDoc(); 2095 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 2096 DBG_ASSERT( pCnt->GetCntntIdx() && 2097 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 2098 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 2099 2100 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 2101 ->GetIndex() + 1 ]->GetOLENode(); 2102 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef(); 2103 OUString aHexCLSID; 2104 { 2105 SvGlobalName aClassName( xIP->getClassID() ); 2106 aHexCLSID = aClassName.GetHexName(); 2107 if(FN_UNO_CLSID != pEntry->nWID) 2108 { 2109 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) 2110 { 2111 uno::Reference < lang::XComponent > xComp( xIP->getComponent(), uno::UNO_QUERY ); 2112 uno::Reference < frame::XModel > xModel( xComp, uno::UNO_QUERY ); 2113 if ( FN_EMBEDDED_OBJECT == pEntry->nWID ) 2114 { 2115 // ensure the 2116 ASSERT( pDoc->GetDocShell(), "no doc shell => no client site" ); 2117 if ( pDoc->GetDocShell() ) 2118 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) ); 2119 aAny <<= xIP; 2120 } 2121 else if ( xModel.is() ) 2122 aAny <<= xModel; 2123 else if ( FN_UNO_COMPONENT == pEntry->nWID ) 2124 aAny <<= xComp; 2125 } 2126 } 2127 } 2128 2129 if(FN_UNO_CLSID == pEntry->nWID) 2130 aAny <<= aHexCLSID; 2131 else if(FN_UNO_STREAM_NAME == pEntry->nWID) 2132 { 2133 aAny <<= ::rtl::OUString(pOleNode->GetOLEObj().GetCurrentPersistName()); 2134 } 2135 } 2136 else if(WID_LAYOUT_SIZE == pEntry->nWID) 2137 { 2138 // format document completely in order to get correct value 2139 pFmt->GetDoc()->GetEditShell()->CalcLayout(); 2140 2141 SwFrm* pTmpFrm = SwIterator<SwFrm,SwFmt>::FirstElement( *pFmt ); 2142 if ( pTmpFrm ) 2143 { 2144 DBG_ASSERT( pTmpFrm->IsValid(), "frame not valid" ); 2145 const SwRect &rRect = pTmpFrm->Frm(); 2146 Size aMM100Size = OutputDevice::LogicToLogic( 2147 Size( rRect.Width(), rRect.Height() ), 2148 MapMode( MAP_TWIP ), MapMode( MAP_100TH_MM )); 2149 aAny <<= awt::Size( aMM100Size.Width(), aMM100Size.Height() ); 2150 } 2151 } 2152 else 2153 { //UUUU 2154 // standard UNO API read attributes 2155 // adapt former attr from SvxBrushItem::PutValue to new items XATTR_FILL_FIRST, XATTR_FILL_LAST 2156 const SwAttrSet& rSet = pFmt->GetAttrSet(); 2157 bool bDone(false); 2158 2159 if(RES_BACKGROUND == pEntry->nWID) 2160 { 2161 //UUUU 2162 const SvxBrushItem aOriginalBrushItem(getSvxBrushItemFromSourceSet(rSet)); 2163 2164 if(!aOriginalBrushItem.QueryValue(aAny, nMemberId)) 2165 { 2166 OSL_ENSURE(false, "Error getting attribute from RES_BACKGROUND (!)"); 2167 } 2168 2169 bDone = true; 2170 } 2171 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 2172 { 2173 //UUUU 2174 const XFillBmpStretchItem* pStretchItem = dynamic_cast< const XFillBmpStretchItem* >(&rSet.Get(XATTR_FILLBMP_STRETCH)); 2175 const XFillBmpTileItem* pTileItem = dynamic_cast< const XFillBmpTileItem* >(&rSet.Get(XATTR_FILLBMP_TILE)); 2176 2177 if( pTileItem && pTileItem->GetValue() ) 2178 { 2179 aAny <<= drawing::BitmapMode_REPEAT; 2180 } 2181 else if( pStretchItem && pStretchItem->GetValue() ) 2182 { 2183 aAny <<= drawing::BitmapMode_STRETCH; 2184 } 2185 else 2186 { 2187 aAny <<= drawing::BitmapMode_NO_REPEAT; 2188 } 2189 2190 bDone = true; 2191 } 2192 2193 if(!bDone) 2194 { 2195 m_pPropSet->getPropertyValue(*pEntry, rSet, aAny); 2196 } 2197 } 2198 } 2199 else if(IsDescriptor()) 2200 { 2201 if ( ! m_pDoc ) 2202 throw uno::RuntimeException(); 2203 if(WID_LAYOUT_SIZE != pEntry->nWID) // there is no LayoutSize in a descriptor 2204 { 2205 const uno::Any* pAny = 0; 2206 if( !pProps->GetProperty( pEntry->nWID, nMemberId, pAny ) ) 2207 aAny = mxStyleData->getPropertyValue( rPropertyName ); 2208 else if ( pAny ) 2209 aAny = *pAny; 2210 } 2211 } 2212 else 2213 throw uno::RuntimeException(); 2214 2215 //UUUU 2216 if(pEntry && pEntry->pType && *(pEntry->pType) == ::getCppuType((const sal_Int16*)0) && *(pEntry->pType) != aAny.getValueType()) 2217 { 2218 // since the sfx uint16 item now exports a sal_Int32, we may have to fix this here 2219 sal_Int32 nValue = 0; 2220 aAny >>= nValue; 2221 aAny <<= (sal_Int16)nValue; 2222 } 2223 2224 //UUUU check for needed metric translation 2225 if(pEntry->nMemberId & SFX_METRIC_ITEM) 2226 { 2227 bool bDoIt(true); 2228 2229 if(XATTR_FILLBMP_SIZEX == pEntry->nWID || XATTR_FILLBMP_SIZEY == pEntry->nWID) 2230 { 2231 // exception: If these ItemTypes are used, do not convert when these are negative 2232 // since this means they are intended as percent values 2233 sal_Int32 nValue = 0; 2234 2235 if(aAny >>= nValue) 2236 { 2237 bDoIt = nValue > 0; 2238 } 2239 } 2240 2241 if(bDoIt) 2242 { 2243 const SwDoc* pDoc = (IsDescriptor() ? m_pDoc : GetFrmFmt()->GetDoc()); 2244 const SfxItemPool& rPool = pDoc->GetAttrPool(); 2245 const SfxMapUnit eMapUnit(rPool.GetMetric(pEntry->nWID)); 2246 2247 if(eMapUnit != SFX_MAPUNIT_100TH_MM) 2248 { 2249 SvxUnoConvertToMM(eMapUnit, aAny); 2250 } 2251 } 2252 } 2253 2254 return aAny; 2255 } 2256 2257 void SwXFrame::addPropertyChangeListener(const OUString& /*PropertyName*/, 2258 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) 2259 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2260 { 2261 DBG_WARNING("not implemented"); 2262 } 2263 2264 void SwXFrame::removePropertyChangeListener(const OUString& /*PropertyName*/, 2265 const uno::Reference< beans::XPropertyChangeListener > & /*aListener*/) 2266 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2267 { 2268 DBG_WARNING("not implemented"); 2269 } 2270 2271 void SwXFrame::addVetoableChangeListener(const OUString& /*PropertyName*/, 2272 const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) 2273 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2274 { 2275 DBG_WARNING("not implemented"); 2276 } 2277 2278 void SwXFrame::removeVetoableChangeListener( 2279 const OUString& /*PropertyName*/, const uno::Reference< beans::XVetoableChangeListener > & /*aListener*/) 2280 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 2281 { 2282 DBG_WARNING("not implemented"); 2283 } 2284 2285 beans::PropertyState SwXFrame::getPropertyState( const OUString& rPropertyName ) 2286 throw(beans::UnknownPropertyException, uno::RuntimeException) 2287 { 2288 vos::OGuard aGuard(Application::GetSolarMutex()); 2289 uno::Sequence< OUString > aPropertyNames(1); 2290 OUString* pNames = aPropertyNames.getArray(); 2291 pNames[0] = rPropertyName; 2292 uno::Sequence< beans::PropertyState > aStates = getPropertyStates(aPropertyNames); 2293 return aStates.getConstArray()[0]; 2294 } 2295 2296 //UUUU 2297 bool SwXFrame::needToMapFillItemsToSvxBrushItemTypes() const 2298 { 2299 SwFrmFmt* pFmt = GetFrmFmt(); 2300 2301 if(!pFmt) 2302 { 2303 return false; 2304 } 2305 2306 const SwAttrSet& rFmtSet = pFmt->GetAttrSet(); 2307 const XFillStyleItem* pXFillStyleItem(static_cast< const XFillStyleItem* >(rFmtSet.GetItem(XATTR_FILLSTYLE, false))); 2308 2309 if(!pXFillStyleItem) 2310 { 2311 return false; 2312 } 2313 2314 //UUUU here different FillStyles can be excluded for export; it will depend on the 2315 // quality these fallbacks can reach. That again is done in getSvxBrushItemFromSourceSet, 2316 // take a look there how the superset of DrawObject FillStyles is mapped to SvxBrushItem. 2317 // For now, take them all - except XFILL_NONE 2318 2319 if(XFILL_NONE != pXFillStyleItem->GetValue()) 2320 { 2321 return true; 2322 } 2323 2324 //if(XFILL_SOLID == pXFillStyleItem->GetValue() || XFILL_BITMAP == pXFillStyleItem->GetValue()) 2325 //{ 2326 // return true; 2327 //} 2328 2329 return false; 2330 } 2331 2332 uno::Sequence< beans::PropertyState > SwXFrame::getPropertyStates( 2333 const uno::Sequence< OUString >& aPropertyNames ) 2334 throw(beans::UnknownPropertyException, uno::RuntimeException) 2335 { 2336 vos::OGuard aGuard(Application::GetSolarMutex()); 2337 uno::Sequence< beans::PropertyState > aStates(aPropertyNames.getLength()); 2338 beans::PropertyState* pStates = aStates.getArray(); 2339 SwFrmFmt* pFmt = GetFrmFmt(); 2340 if(pFmt) 2341 { 2342 const OUString* pNames = aPropertyNames.getConstArray(); 2343 const SwAttrSet& rFmtSet = pFmt->GetAttrSet(); 2344 for(int i = 0; i < aPropertyNames.getLength(); i++) 2345 { 2346 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(pNames[i]); 2347 if (!pEntry) 2348 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + pNames[i], static_cast < cppu::OWeakObject * > ( this ) ); 2349 2350 if(pEntry->nWID == FN_UNO_ANCHOR_TYPES|| 2351 pEntry->nWID == FN_PARAM_LINK_DISPLAY_NAME|| 2352 FN_UNO_FRAME_STYLE_NAME == pEntry->nWID|| 2353 FN_UNO_GRAPHIC_U_R_L == pEntry->nWID|| 2354 FN_UNO_GRAPHIC_FILTER == pEntry->nWID|| 2355 FN_UNO_ACTUAL_SIZE == pEntry->nWID|| 2356 FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID) 2357 { 2358 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2359 } 2360 else if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 2361 { 2362 //UUUU 2363 if(SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_STRETCH, false) 2364 || SFX_ITEM_SET == rFmtSet.GetItemState(XATTR_FILLBMP_TILE, false)) 2365 { 2366 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2367 } 2368 else 2369 { 2370 pStates[i] = beans::PropertyState_AMBIGUOUS_VALUE; 2371 } 2372 } 2373 //UUUU for FlyFrames we need to mark all properties from type RES_BACKGROUND 2374 // as beans::PropertyState_DIRECT_VALUE to let users of this property call 2375 // getPropertyValue where the member properties will be mapped from the 2376 // fill attributes to the according SvxBrushItem entries 2377 else if(RES_BACKGROUND == pEntry->nWID && needToMapFillItemsToSvxBrushItemTypes()) 2378 { 2379 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2380 } 2381 else 2382 { 2383 if ((eType == FLYCNTTYPE_GRF) && 2384 pEntry && isGRFATR(pEntry->nWID)) 2385 { 2386 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2387 if(pIdx) 2388 { 2389 SwNodeIndex aIdx(*pIdx, 1); 2390 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 2391 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 2392 aSet.GetItemState(pEntry->nWID); 2393 if(SFX_ITEM_SET == aSet.GetItemState( pEntry->nWID, sal_False )) 2394 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2395 } 2396 } 2397 else 2398 { 2399 if(SFX_ITEM_SET == rFmtSet.GetItemState( pEntry->nWID, sal_False )) 2400 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2401 else 2402 pStates[i] = beans::PropertyState_DEFAULT_VALUE; 2403 } 2404 } 2405 } 2406 } 2407 else if(IsDescriptor()) 2408 { 2409 for(int i = 0; i < aPropertyNames.getLength(); i++) 2410 pStates[i] = beans::PropertyState_DIRECT_VALUE; 2411 } 2412 else 2413 throw uno::RuntimeException(); 2414 return aStates; 2415 } 2416 2417 void SwXFrame::setPropertyToDefault( const OUString& rPropertyName ) 2418 throw(beans::UnknownPropertyException, uno::RuntimeException) 2419 { 2420 vos::OGuard aGuard(Application::GetSolarMutex()); 2421 SwFrmFmt* pFmt = GetFrmFmt(); 2422 if(pFmt) 2423 { 2424 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 2425 if (!pEntry) 2426 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 2427 if ( pEntry->nFlags & beans::PropertyAttribute::READONLY) 2428 throw uno::RuntimeException( OUString ( RTL_CONSTASCII_USTRINGPARAM ( "setPropertyToDefault: property is read-only: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 2429 2430 sal_Bool bNextFrame; 2431 2432 if(OWN_ATTR_FILLBMP_MODE == pEntry->nWID) 2433 { 2434 //UUUU 2435 SwDoc* pDoc = pFmt->GetDoc(); 2436 SfxItemSet aSet(pDoc->GetAttrPool(), XATTR_FILL_FIRST, XATTR_FILL_LAST); 2437 aSet.SetParent(&pFmt->GetAttrSet()); 2438 2439 aSet.ClearItem(XATTR_FILLBMP_STRETCH); 2440 aSet.ClearItem(XATTR_FILLBMP_TILE); 2441 2442 pFmt->SetFmtAttr(aSet); 2443 } 2444 else if( pEntry->nWID && 2445 pEntry->nWID != FN_UNO_ANCHOR_TYPES && 2446 pEntry->nWID != FN_PARAM_LINK_DISPLAY_NAME) 2447 { 2448 if ( (eType == FLYCNTTYPE_GRF) && isGRFATR(pEntry->nWID) ) 2449 { 2450 const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2451 if(pIdx) 2452 { 2453 SwNodeIndex aIdx(*pIdx, 1); 2454 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 2455 { 2456 SfxItemSet aSet(pNoTxt->GetSwAttrSet()); 2457 aSet.ClearItem(pEntry->nWID); 2458 pNoTxt->SetAttr(aSet); 2459 } 2460 } 2461 } 2462 // --> OD 2009-07-13 #i73249# 2463 // Attribute AlternativeText was never published. 2464 // Now it has been replaced by Attribute Title - valid for all <SwXFrame> instances 2465 // else if( eType != FLYCNTTYPE_FRM && FN_UNO_ALTERNATIVE_TEXT == pEntry->nWID ) 2466 // { 2467 // const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 2468 // if(pIdx) 2469 // { 2470 // SwNodeIndex aIdx(*pIdx, 1); 2471 // SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 2472 // pNoTxt->SetAlternateText(aEmptyStr); 2473 // } 2474 // } 2475 // New attribute Title 2476 else if( FN_UNO_TITLE == pEntry->nWID ) 2477 { 2478 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 2479 ASSERT( pFmt, 2480 "unexpected type of <pFmt> --> crash" ); 2481 // assure that <SdrObject> instance exists. 2482 GetOrCreateSdrObject( pFlyFmt ); 2483 pFlyFmt->GetDoc()->SetFlyFrmTitle( *(pFlyFmt), aEmptyStr ); 2484 } 2485 // New attribute Description 2486 else if( FN_UNO_DESCRIPTION == pEntry->nWID ) 2487 { 2488 SwFlyFrmFmt* pFlyFmt = dynamic_cast<SwFlyFrmFmt*>(pFmt); 2489 ASSERT( pFmt, 2490 "unexpected type of <pFmt> --> crash" ); 2491 // assure that <SdrObject> instance exists. 2492 GetOrCreateSdrObject( pFlyFmt ); 2493 pFlyFmt->GetDoc()->SetFlyFrmDescription( *(pFlyFmt), aEmptyStr ); 2494 } 2495 // <-- 2496 else 2497 { 2498 SwDoc* pDoc = pFmt->GetDoc(); 2499 SfxItemSet aSet( pDoc->GetAttrPool(), 2500 RES_FRMATR_BEGIN, RES_FRMATR_END - 1 ); 2501 aSet.SetParent(&pFmt->GetAttrSet()); 2502 aSet.ClearItem(pEntry->nWID); 2503 if(!rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_ANCHOR_TYPE))) 2504 pFmt->SetFmtAttr(aSet); 2505 } 2506 } 2507 else if(0 != (bNextFrame = (rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_NEXT_NAME)))) 2508 || rPropertyName.equalsAsciiL( SW_PROP_NAME(UNO_NAME_CHAIN_PREV_NAME))) 2509 { 2510 SwDoc* pDoc = pFmt->GetDoc(); 2511 if(bNextFrame) 2512 pDoc->Unchain(*pFmt); 2513 else 2514 { 2515 SwFmtChain aChain( pFmt->GetChain() ); 2516 SwFrmFmt *pPrev = aChain.GetPrev(); 2517 if(pPrev) 2518 pDoc->Unchain(*pPrev); 2519 } 2520 } 2521 } 2522 else if(!IsDescriptor()) 2523 throw uno::RuntimeException(); 2524 2525 } 2526 2527 uno::Any SwXFrame::getPropertyDefault( const OUString& rPropertyName ) 2528 throw(beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException) 2529 { 2530 vos::OGuard aGuard(Application::GetSolarMutex()); 2531 uno::Any aRet; 2532 SwFrmFmt* pFmt = GetFrmFmt(); 2533 if(pFmt) 2534 { 2535 const SfxItemPropertySimpleEntry* pEntry = m_pPropSet->getPropertyMap()->getByName(rPropertyName); 2536 if(pEntry) 2537 { 2538 if ( pEntry->nWID < RES_FRMATR_END ) 2539 { 2540 const SfxPoolItem& rDefItem = 2541 pFmt->GetDoc()->GetAttrPool().GetDefaultItem(pEntry->nWID); 2542 //UUUU 2543 const sal_uInt8 nMemberId(pEntry->nMemberId & (~SFX_METRIC_ITEM)); 2544 2545 rDefItem.QueryValue(aRet, nMemberId); 2546 } 2547 } 2548 else 2549 throw beans::UnknownPropertyException(OUString ( RTL_CONSTASCII_USTRINGPARAM ( "Unknown property: " ) ) + rPropertyName, static_cast < cppu::OWeakObject * > ( this ) ); 2550 } 2551 else if(!IsDescriptor()) 2552 throw uno::RuntimeException(); 2553 return aRet; 2554 } 2555 2556 void SwXFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2557 { 2558 if(!GetRegisteredIn()) 2559 throw uno::RuntimeException(); 2560 aLstnrCntnr.AddListener(aListener); 2561 } 2562 2563 void SwXFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 2564 { 2565 if(!GetRegisteredIn() || !aLstnrCntnr.RemoveListener(aListener)) 2566 throw uno::RuntimeException(); 2567 } 2568 2569 void SwXFrame::Modify( const SfxPoolItem* pOld, const SfxPoolItem *pNew) 2570 { 2571 ClientModify(this, pOld, pNew); 2572 if(!GetRegisteredIn()) 2573 { 2574 mxStyleData.clear(); 2575 mxStyleFamily.clear(); 2576 m_pDoc = 0; 2577 aLstnrCntnr.Disposing(); 2578 } 2579 } 2580 2581 2582 void SwXFrame::dispose(void) throw( uno::RuntimeException ) 2583 { 2584 vos::OGuard aGuard(Application::GetSolarMutex()); 2585 SwFrmFmt* pFmt = GetFrmFmt(); 2586 if ( pFmt ) 2587 { 2588 SdrObject* pObj = pFmt->FindSdrObject(); 2589 // OD 11.09.2003 #112039# - add condition to perform delete of 2590 // format/anchor sign, not only if the object is inserted, but also 2591 // if a contact object is registered, which isn't in the destruction. 2592 if ( pObj && 2593 ( pObj->IsInserted() || 2594 ( pObj->GetUserCall() && 2595 !static_cast<SwContact*>(pObj->GetUserCall())->IsInDTOR() ) ) ) 2596 { 2597 if (pFmt->GetAnchor().GetAnchorId() == FLY_AS_CHAR) 2598 { 2599 const SwPosition &rPos = *(pFmt->GetAnchor().GetCntntAnchor()); 2600 SwTxtNode *pTxtNode = rPos.nNode.GetNode().GetTxtNode(); 2601 const xub_StrLen nIdx = rPos.nContent.GetIndex(); 2602 pTxtNode->DeleteAttributes( RES_TXTATR_FLYCNT, nIdx, nIdx ); 2603 } 2604 else 2605 pFmt->GetDoc()->DelLayoutFmt(pFmt); 2606 } 2607 } 2608 2609 } 2610 2611 uno::Reference< text::XTextRange > SwXFrame::getAnchor(void) throw( uno::RuntimeException ) 2612 { 2613 vos::OGuard aGuard(Application::GetSolarMutex()); 2614 uno::Reference< text::XTextRange > aRef; 2615 SwFrmFmt* pFmt = GetFrmFmt(); 2616 if(pFmt) 2617 { 2618 const SwFmtAnchor& rAnchor = pFmt->GetAnchor(); 2619 // return an anchor for non-page bound frames 2620 // and for page bound frames that have a page no == NULL and a content position 2621 if ((rAnchor.GetAnchorId() != FLY_AT_PAGE) || 2622 (rAnchor.GetCntntAnchor() && !rAnchor.GetPageNum())) 2623 { 2624 const SwPosition &rPos = *(rAnchor.GetCntntAnchor()); 2625 aRef = SwXTextRange::CreateXTextRange(*pFmt->GetDoc(), rPos, 0); 2626 } 2627 } 2628 else 2629 throw uno::RuntimeException(); 2630 return aRef; 2631 } 2632 2633 void SwXFrame::ResetDescriptor() 2634 { 2635 bIsDescriptor = sal_False; 2636 mxStyleData.clear(); 2637 mxStyleFamily.clear(); 2638 DELETEZ(pProps); 2639 } 2640 2641 void SwXFrame::attachToRange(const uno::Reference< text::XTextRange > & xTextRange) 2642 throw( lang::IllegalArgumentException, uno::RuntimeException ) 2643 { 2644 vos::OGuard aGuard(Application::GetSolarMutex()); 2645 if(!IsDescriptor()) 2646 throw uno::RuntimeException(); 2647 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 2648 SwXTextRange* pRange = 0; 2649 OTextCursorHelper* pCursor = 0; 2650 if(xRangeTunnel.is()) 2651 { 2652 pRange = reinterpret_cast< SwXTextRange * >( 2653 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); 2654 pCursor = reinterpret_cast< OTextCursorHelper * >( 2655 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); 2656 } 2657 2658 SwDoc* pDoc = pRange ? (SwDoc*)pRange->GetDoc() : pCursor ? (SwDoc*)pCursor->GetDoc() : 0; 2659 if(pDoc) 2660 { 2661 SwUnoInternalPaM aIntPam(*pDoc); 2662 //das muss jetzt sal_True liefern 2663 ::sw::XTextRangeToSwPaM(aIntPam, xTextRange); 2664 2665 SwNode& rNode = pDoc->GetNodes().GetEndOfContent(); 2666 SwPaM aPam(rNode); 2667 aPam.Move( fnMoveBackward, fnGoDoc ); 2668 static sal_uInt16 __READONLY_DATA aFrmAttrRange[] = 2669 { 2670 RES_FRMATR_BEGIN, RES_FRMATR_END-1, 2671 RES_UNKNOWNATR_CONTAINER, RES_UNKNOWNATR_CONTAINER, 2672 2673 //UUUU FillAttribute support 2674 XATTR_FILL_FIRST, XATTR_FILL_LAST, 2675 2676 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, 2677 0 2678 }; 2679 static sal_uInt16 __READONLY_DATA aGrAttrRange[] = 2680 { 2681 RES_GRFATR_BEGIN, RES_GRFATR_END-1, 2682 0 2683 }; 2684 SfxItemSet aGrSet(pDoc->GetAttrPool(), aGrAttrRange ); 2685 2686 SfxItemSet aFrmSet(pDoc->GetAttrPool(), aFrmAttrRange ); 2687 //jetzt muessen die passenden Items in den Set 2688 sal_Bool bSizeFound; 2689 if(!pProps->AnyToItemSet( pDoc, aFrmSet, aGrSet, bSizeFound)) 2690 throw lang::IllegalArgumentException(); 2691 //der TextRange wird einzeln behandelt 2692 *aPam.GetPoint() = *aIntPam.GetPoint(); 2693 if(aIntPam.HasMark()) 2694 { 2695 aPam.SetMark(); 2696 *aPam.GetMark() = *aIntPam.GetMark(); 2697 } 2698 2699 const SfxPoolItem* pItem; 2700 RndStdIds eAnchorId = FLY_AT_PARA; 2701 if(SFX_ITEM_SET == aFrmSet.GetItemState(RES_ANCHOR, sal_False, &pItem) ) 2702 { 2703 eAnchorId = ((const SwFmtAnchor*)pItem)->GetAnchorId(); 2704 if( FLY_AT_FLY == eAnchorId && 2705 !aPam.GetNode()->FindFlyStartNode()) 2706 { 2707 //rahmengebunden geht nur dort, wo ein Rahmen ist! 2708 SwFmtAnchor aAnchor(FLY_AT_PARA); 2709 aFrmSet.Put(aAnchor); 2710 } 2711 else if ((FLY_AT_PAGE == eAnchorId) && 2712 0 == ((const SwFmtAnchor*)pItem)->GetPageNum() ) 2713 { 2714 SwFmtAnchor aAnchor( *((const SwFmtAnchor*)pItem) ); 2715 aAnchor.SetAnchor( aPam.GetPoint() ); 2716 aFrmSet.Put(aAnchor); 2717 } 2718 } 2719 2720 const ::uno::Any* pStyle; 2721 SwFrmFmt *pParentFrmFmt = 0; 2722 if(pProps->GetProperty(FN_UNO_FRAME_STYLE_NAME, 0, pStyle)) 2723 pParentFrmFmt = lcl_GetFrmFmt( *pStyle, pDoc ); 2724 2725 SwFlyFrmFmt* pFmt = 0; 2726 if( eType == FLYCNTTYPE_FRM) 2727 { 2728 UnoActionContext aCont(pDoc); 2729 if(m_pCopySource) 2730 { 2731 SwFmtAnchor* pAnchorItem = 0; 2732 // the frame is inserted bound to page 2733 // to prevent conflicts if the to-be-anchored position is part of the to-be-copied text 2734 if (eAnchorId != FLY_AT_PAGE) 2735 { 2736 pAnchorItem = static_cast<SwFmtAnchor*>(aFrmSet.Get(RES_ANCHOR).Clone()); 2737 aFrmSet.Put( SwFmtAnchor( FLY_AT_PAGE, 1 )); 2738 } 2739 2740 aPam.DeleteMark(); // mark position node will be deleted! 2741 aIntPam.DeleteMark(); // mark position node will be deleted! 2742 pFmt = pDoc->MakeFlyAndMove( *m_pCopySource, aFrmSet, 2743 0, 2744 pParentFrmFmt ); 2745 if(pAnchorItem && pFmt) 2746 { 2747 pFmt->DelFrms(); 2748 pAnchorItem->SetAnchor( m_pCopySource->Start() ); 2749 SfxItemSet aAnchorSet( pDoc->GetAttrPool(), RES_ANCHOR, RES_ANCHOR ); 2750 aAnchorSet.Put( *pAnchorItem ); 2751 pDoc->SetFlyFrmAttr( *pFmt, aAnchorSet ); 2752 delete pAnchorItem; 2753 } 2754 DELETEZ( m_pCopySource ); 2755 } 2756 else 2757 { 2758 pFmt = pDoc->MakeFlySection( FLY_AT_PARA, aPam.GetPoint(), 2759 &aFrmSet, pParentFrmFmt ); 2760 } 2761 if(pFmt) 2762 { 2763 pFmt->Add(this); 2764 if(sName.Len()) 2765 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName); 2766 } 2767 //den SwXText wecken 2768 ((SwXTextFrame*)this)->SetDoc( bIsDescriptor ? m_pDoc : GetFrmFmt()->GetDoc() ); 2769 } 2770 else if( eType == FLYCNTTYPE_GRF) 2771 { 2772 UnoActionContext aCont(pDoc); 2773 const ::uno::Any* pGraphicURL; 2774 String sGraphicURL; 2775 GraphicObject *pGrfObj = 0; 2776 if(pProps->GetProperty(FN_UNO_GRAPHIC_U_R_L, 0, pGraphicURL)) 2777 { 2778 OUString uTemp; 2779 (*pGraphicURL) >>= uTemp; 2780 sGraphicURL = String(uTemp); 2781 if( sGraphicURL.EqualsAscii( sPackageProtocol, 2782 0, sizeof( sPackageProtocol )-1 ) ) 2783 { 2784 pGrfObj = new GraphicObject; 2785 pGrfObj->SetUserData( sGraphicURL ); 2786 pGrfObj->SetSwapState(); 2787 sGraphicURL.Erase(); 2788 } 2789 else if( sGraphicURL.EqualsAscii( sGraphicObjectProtocol, 2790 0, sizeof(sGraphicObjectProtocol)-1 ) ) 2791 { 2792 ByteString sId( sGraphicURL.Copy( sizeof(sGraphicObjectProtocol)-1 ), 2793 RTL_TEXTENCODING_ASCII_US ); 2794 pGrfObj = new GraphicObject( sId ); 2795 sGraphicURL.Erase(); 2796 } 2797 } 2798 Graphic aGraphic; 2799 const ::uno::Any* pGraphic; 2800 if( pProps->GetProperty( FN_UNO_GRAPHIC, 0, pGraphic )) 2801 { 2802 uno::Reference< graphic::XGraphic > xGraphic; 2803 (*pGraphic) >>= xGraphic; 2804 aGraphic = Graphic( xGraphic ); 2805 } 2806 2807 String sFltName; 2808 const ::uno::Any* pFilter; 2809 if(pProps->GetProperty(FN_UNO_GRAPHIC_FILTER, 0, pFilter)) 2810 { 2811 OUString uTemp; 2812 (*pFilter) >>= uTemp; 2813 sFltName = String(uTemp); 2814 } 2815 2816 pFmt = 2817 pGrfObj ? pDoc->Insert( aPam, *pGrfObj, &aFrmSet, &aGrSet, 2818 pParentFrmFmt ) 2819 : pDoc->Insert( aPam, sGraphicURL, sFltName, &aGraphic, 2820 &aFrmSet, &aGrSet, pParentFrmFmt ); 2821 delete pGrfObj; 2822 if(pFmt) 2823 { 2824 SwGrfNode *pGrfNd = pDoc->GetNodes()[ pFmt->GetCntnt().GetCntntIdx() 2825 ->GetIndex()+1 ]->GetGrfNode(); 2826 pGrfNd->SetChgTwipSize( !bSizeFound ); 2827 pFmt->Add(this); 2828 if(sName.Len()) 2829 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt, sName); 2830 2831 } 2832 const ::uno::Any* pSurroundContour; 2833 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUR, pSurroundContour)) 2834 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_SURROUND_CONTOUR)), *pSurroundContour); 2835 const ::uno::Any* pContourOutside; 2836 if(pProps->GetProperty(RES_SURROUND, MID_SURROUND_CONTOUROUTSIDE, pContourOutside)) 2837 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_OUTSIDE)), *pContourOutside); 2838 const ::uno::Any* pContourPoly; 2839 if(pProps->GetProperty(FN_PARAM_COUNTOUR_PP, 0, pContourPoly)) 2840 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_CONTOUR_POLY_POLYGON)), *pContourPoly); 2841 const ::uno::Any* pPixelContour; 2842 if(pProps->GetProperty(FN_UNO_IS_PIXEL_CONTOUR, 0, pPixelContour)) 2843 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_PIXEL_CONTOUR)), *pPixelContour); 2844 const ::uno::Any* pAutoContour; 2845 if(pProps->GetProperty(FN_UNO_IS_AUTOMATIC_CONTOUR, 0, pAutoContour)) 2846 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_IS_AUTOMATIC_CONTOUR)), *pAutoContour); 2847 // const ::uno::Any* pAltText; 2848 // if(pProps->GetProperty(FN_UNO_ALTERNATIVE_TEXT, 0, pAltText)) 2849 // setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_ALTERNATIVE_TEXT)), *pAltText); 2850 } 2851 else 2852 { 2853 const ::uno::Any* pCLSID = 0; 2854 const ::uno::Any* pStreamName = 0; 2855 if(!pProps->GetProperty(FN_UNO_CLSID, 0, pCLSID) && !pProps->GetProperty( FN_UNO_STREAM_NAME, 0, pStreamName )) 2856 throw uno::RuntimeException(); 2857 if(pCLSID) 2858 { 2859 OUString aCLSID; 2860 SvGlobalName aClassName; 2861 uno::Reference < embed::XEmbeddedObject > xIPObj; 2862 std::auto_ptr < comphelper::EmbeddedObjectContainer > pCnt; 2863 if( (*pCLSID) >>= aCLSID ) 2864 { 2865 if( !aClassName.MakeId( aCLSID ) ) 2866 { 2867 lang::IllegalArgumentException aExcept; 2868 aExcept.Message = OUString::createFromAscii("CLSID invalid"); 2869 throw aExcept; 2870 } 2871 2872 pCnt.reset( new comphelper::EmbeddedObjectContainer ); 2873 ::rtl::OUString aName; 2874 xIPObj = pCnt->CreateEmbeddedObject( aClassName.GetByteSequence(), aName ); 2875 } 2876 if ( xIPObj.is() ) 2877 { 2878 //TODO/LATER: MISCSTATUS_RESIZEONPRINTERCHANGE 2879 //if( SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE & xIPObj->GetMiscStatus() && pDoc->getPrinter( false ) ) 2880 // xIPObj->OnDocumentPrinterChanged( pDoc->getPrinter( false ) ); 2881 2882 UnoActionContext aAction(pDoc); 2883 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); 2884 if(!bSizeFound) 2885 { 2886 //TODO/LATER: from where do I get a ViewAspect? And how do I transport it to the OLENode? 2887 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 2888 2889 // TODO/LEAN: VisualArea still needs running state 2890 svt::EmbeddedObjectRef::TryRunningState( xIPObj ); 2891 2892 // set parent to get correct VisArea(in case of object needing parent printer) 2893 uno::Reference < container::XChild > xChild( xIPObj, uno::UNO_QUERY ); 2894 if ( xChild.is() ) 2895 xChild->setParent( pDoc->GetDocShell()->GetModel() ); 2896 2897 //The Size should be suggested by the OLE server if not manually set 2898 MapUnit aRefMap = VCLUnoHelper::UnoEmbed2VCLMapUnit( xIPObj->getMapUnit( nAspect ) ); 2899 awt::Size aSize; 2900 try 2901 { 2902 aSize = xIPObj->getVisualAreaSize( nAspect ); 2903 } 2904 catch ( embed::NoVisualAreaSizeException& ) 2905 { 2906 // the default size will be set later 2907 } 2908 2909 Size aSz( aSize.Width, aSize.Height ); 2910 if ( !aSz.Width() || !aSz.Height() ) 2911 { 2912 aSz.Width() = aSz.Height() = 5000; 2913 aSz = OutputDevice::LogicToLogic 2914 ( aSz, MapMode( MAP_100TH_MM ), aRefMap ); 2915 } 2916 MapMode aMyMap( MAP_TWIP ); 2917 aSz = OutputDevice::LogicToLogic( aSz, aRefMap, aMyMap ); 2918 SwFmtFrmSize aFrmSz; 2919 aFrmSz.SetSize(aSz); 2920 aFrmSet.Put(aFrmSz); 2921 } 2922 SwFlyFrmFmt* pFmt2 = 0; 2923 2924 // TODO/LATER: Is it the only possible aspect here? 2925 sal_Int64 nAspect = embed::Aspects::MSOLE_CONTENT; 2926 ::svt::EmbeddedObjectRef xObjRef( xIPObj, nAspect ); 2927 pFmt2 = pDoc->Insert(aPam, xObjRef, &aFrmSet, NULL, NULL ); 2928 ASSERT( pFmt2, "Doc->Insert(notxt) failed." ); 2929 2930 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); 2931 pFmt2->Add(this); 2932 if(sName.Len()) 2933 pDoc->SetFlyName((SwFlyFrmFmt&)*pFmt2, sName); 2934 } 2935 } 2936 else if( pStreamName ) 2937 { 2938 ::rtl::OUString sStreamName; 2939 (*pStreamName) >>= sStreamName; 2940 pDoc->GetIDocumentUndoRedo().StartUndo(UNDO_INSERT, NULL); 2941 2942 SwFlyFrmFmt* pFrmFmt = 0; 2943 pFrmFmt = pDoc->InsertOLE( aPam, sStreamName, embed::Aspects::MSOLE_CONTENT, &aFrmSet, NULL, NULL ); 2944 pDoc->GetIDocumentUndoRedo().EndUndo(UNDO_INSERT, NULL); 2945 pFrmFmt->Add(this); 2946 if(sName.Len()) 2947 pDoc->SetFlyName((SwFlyFrmFmt&)*pFrmFmt, sName); 2948 } 2949 } 2950 if( pFmt && pDoc->GetDrawModel() ) 2951 GetOrCreateSdrObject( pFmt ); 2952 const ::uno::Any* pOrder; 2953 if( pProps->GetProperty(FN_UNO_Z_ORDER, 0, pOrder) ) 2954 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_Z_ORDER)), *pOrder); 2955 const ::uno::Any* pReplacement; 2956 if( pProps->GetProperty(FN_UNO_REPLACEMENT_GRAPHIC, 0, pReplacement) ) 2957 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_GRAPHIC)), *pReplacement); 2958 // --> OD 2009-07-13 #i73249# 2959 // new attribute Title 2960 const ::uno::Any* pTitle; 2961 if ( pProps->GetProperty(FN_UNO_TITLE, 0, pTitle) ) 2962 { 2963 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_TITLE)), *pTitle); 2964 } 2965 // new attribute Description 2966 const ::uno::Any* pDescription; 2967 if ( pProps->GetProperty(FN_UNO_DESCRIPTION, 0, pDescription) ) 2968 { 2969 setPropertyValue(C2U(SW_PROP_NAME_STR(UNO_NAME_DESCRIPTION)), *pDescription); 2970 } 2971 // <-- 2972 } 2973 else 2974 throw lang::IllegalArgumentException(); 2975 //setzt das Flag zurueck und loescht den Descriptor-Pointer 2976 ResetDescriptor(); 2977 } 2978 2979 void SwXFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) 2980 throw( lang::IllegalArgumentException, uno::RuntimeException ) 2981 { 2982 SwFrmFmt* pFmt; 2983 if(IsDescriptor()) 2984 attachToRange(xTextRange); 2985 else if(0 != (pFmt = GetFrmFmt())) 2986 { 2987 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY); 2988 SwXTextRange* pRange = 0; 2989 OTextCursorHelper* pCursor = 0; 2990 if(xRangeTunnel.is()) 2991 { 2992 pRange = reinterpret_cast< SwXTextRange * >( 2993 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( SwXTextRange::getUnoTunnelId()) )); 2994 pCursor = reinterpret_cast< OTextCursorHelper * >( 2995 sal::static_int_cast< sal_IntPtr >( xRangeTunnel->getSomething( OTextCursorHelper::getUnoTunnelId()) )); 2996 } 2997 SwDoc* pDoc = pFmt->GetDoc(); 2998 SwUnoInternalPaM aIntPam(*pDoc); 2999 if (::sw::XTextRangeToSwPaM(aIntPam, xTextRange)) 3000 { 3001 SfxItemSet aSet( pDoc->GetAttrPool(), 3002 RES_ANCHOR, RES_ANCHOR ); 3003 aSet.SetParent(&pFmt->GetAttrSet()); 3004 SwFmtAnchor aAnchor = (const SwFmtAnchor&)aSet.Get(RES_ANCHOR); 3005 aAnchor.SetAnchor( aIntPam.Start() ); 3006 aSet.Put(aAnchor); 3007 pDoc->SetFlyFrmAttr( *pFmt, aSet ); 3008 } 3009 else 3010 throw lang::IllegalArgumentException(); 3011 } 3012 } 3013 3014 awt::Point SwXFrame::getPosition(void) throw( uno::RuntimeException ) 3015 { 3016 vos::OGuard aGuard(Application::GetSolarMutex()); 3017 uno::RuntimeException aRuntime; 3018 aRuntime.Message = C2U("position cannot be determined with this method"); 3019 throw aRuntime; 3020 } 3021 3022 void SwXFrame::setPosition(const awt::Point& /*aPosition*/) throw( uno::RuntimeException ) 3023 { 3024 vos::OGuard aGuard(Application::GetSolarMutex()); 3025 uno::RuntimeException aRuntime; 3026 aRuntime.Message = C2U("position cannot be changed with this method"); 3027 throw aRuntime; 3028 } 3029 3030 awt::Size SwXFrame::getSize(void) throw( uno::RuntimeException ) 3031 { 3032 const ::uno::Any aVal = getPropertyValue(C2U("Size")); 3033 awt::Size* pRet = (awt::Size*)aVal.getValue(); 3034 return *pRet; 3035 } 3036 3037 void SwXFrame::setSize(const awt::Size& aSize) 3038 throw( beans::PropertyVetoException, uno::RuntimeException ) 3039 { 3040 const ::uno::Any aVal(&aSize, ::getCppuType(static_cast<const awt::Size*>(0))); 3041 setPropertyValue(C2U("Size"), aVal); 3042 } 3043 3044 OUString SwXFrame::getShapeType(void) throw( uno::RuntimeException ) 3045 { 3046 return C2U("FrameShape"); 3047 } 3048 3049 3050 /****************************************************************** 3051 * SwXTextFrame 3052 ******************************************************************/ 3053 3054 SwXTextFrame::SwXTextFrame( SwDoc *_pDoc ) : 3055 SwXText(0, CURSOR_FRAME), 3056 SwXFrame(FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME), _pDoc ) 3057 { 3058 } 3059 3060 SwXTextFrame::SwXTextFrame(SwFrmFmt& rFmt) : 3061 SwXText(rFmt.GetDoc(), CURSOR_FRAME), 3062 SwXFrame(rFmt, FLYCNTTYPE_FRM, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_FRAME)) 3063 { 3064 3065 } 3066 3067 SwXTextFrame::~SwXTextFrame() 3068 { 3069 } 3070 3071 void SAL_CALL SwXTextFrame::acquire( )throw() 3072 { 3073 SwXFrame::acquire(); 3074 } 3075 3076 void SAL_CALL SwXTextFrame::release( )throw() 3077 { 3078 SwXFrame::release(); 3079 } 3080 3081 ::uno::Any SAL_CALL SwXTextFrame::queryInterface( const uno::Type& aType ) 3082 throw (uno::RuntimeException) 3083 { 3084 ::uno::Any aRet = SwXFrame::queryInterface(aType); 3085 if(aRet.getValueType() == ::getCppuVoidType()) 3086 aRet = SwXText::queryInterface(aType); 3087 if(aRet.getValueType() == ::getCppuVoidType()) 3088 aRet = SwXTextFrameBaseClass::queryInterface(aType); 3089 return aRet; 3090 } 3091 3092 uno::Sequence< uno::Type > SAL_CALL SwXTextFrame::getTypes( ) throw(uno::RuntimeException) 3093 { 3094 uno::Sequence< uno::Type > aTextFrameTypes = SwXTextFrameBaseClass::getTypes(); 3095 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 3096 uno::Sequence< uno::Type > aTextTypes = SwXText::getTypes(); 3097 3098 long nIndex = aTextFrameTypes.getLength(); 3099 aTextFrameTypes.realloc( 3100 aTextFrameTypes.getLength() + 3101 aFrameTypes.getLength() + 3102 aTextTypes.getLength()); 3103 3104 uno::Type* pTextFrameTypes = aTextFrameTypes.getArray(); 3105 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 3106 long nPos; 3107 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 3108 pTextFrameTypes[nIndex++] = pFrameTypes[nPos]; 3109 3110 const uno::Type* pTextTypes = aTextTypes.getConstArray(); 3111 for(nPos = 0; nPos <aTextTypes.getLength(); nPos++) 3112 pTextFrameTypes[nIndex++] = pTextTypes[nPos]; 3113 3114 return aTextFrameTypes; 3115 } 3116 3117 uno::Sequence< sal_Int8 > SAL_CALL SwXTextFrame::getImplementationId( ) throw(uno::RuntimeException) 3118 { 3119 vos::OGuard aGuard(Application::GetSolarMutex()); 3120 static uno::Sequence< sal_Int8 > aId( 16 ); 3121 static sal_Bool bInit = sal_False; 3122 if(!bInit) 3123 { 3124 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 3125 bInit = sal_True; 3126 } 3127 return aId; 3128 } 3129 3130 uno::Reference< text::XText > SwXTextFrame::getText(void) throw( uno::RuntimeException ) 3131 { 3132 return this; 3133 } 3134 3135 const SwStartNode *SwXTextFrame::GetStartNode() const 3136 { 3137 const SwStartNode *pSttNd = 0; 3138 3139 SwFrmFmt* pFmt = GetFrmFmt(); 3140 if(pFmt) 3141 { 3142 const SwFmtCntnt& rFlyCntnt = pFmt->GetCntnt(); 3143 if( rFlyCntnt.GetCntntIdx() ) 3144 pSttNd = rFlyCntnt.GetCntntIdx()->GetNode().GetStartNode(); 3145 } 3146 3147 return pSttNd; 3148 } 3149 3150 uno::Reference< text::XTextCursor > 3151 SwXTextFrame::CreateCursor() throw (uno::RuntimeException) 3152 { 3153 return createTextCursor(); 3154 } 3155 3156 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursor(void) throw( uno::RuntimeException ) 3157 { 3158 vos::OGuard aGuard(Application::GetSolarMutex()); 3159 uno::Reference< text::XTextCursor > aRef; 3160 SwFrmFmt* pFmt = GetFrmFmt(); 3161 if(pFmt) 3162 { 3163 //save current start node to be able to check if there is content after the table - 3164 //otherwise the cursor would be in the body text! 3165 const SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); 3166 const SwStartNode* pOwnStartNode = rNode.FindSttNodeByType(SwFlyStartNode); 3167 3168 SwPaM aPam(rNode); 3169 aPam.Move(fnMoveForward, fnGoNode); 3170 SwTableNode* pTblNode = aPam.GetNode()->FindTableNode(); 3171 SwCntntNode* pCont = 0; 3172 while( pTblNode ) 3173 { 3174 aPam.GetPoint()->nNode = *pTblNode->EndOfSectionNode(); 3175 pCont = GetDoc()->GetNodes().GoNext(&aPam.GetPoint()->nNode); 3176 pTblNode = pCont->FindTableNode(); 3177 } 3178 if(pCont) 3179 aPam.GetPoint()->nContent.Assign(pCont, 0); 3180 3181 const SwStartNode* pNewStartNode = 3182 aPam.GetNode()->FindSttNodeByType(SwFlyStartNode); 3183 if(!pNewStartNode || pNewStartNode != pOwnStartNode) 3184 { 3185 uno::RuntimeException aExcept; 3186 aExcept.Message = C2U("no text available"); 3187 throw aExcept; 3188 } 3189 3190 SwXTextCursor *const pXCursor = new SwXTextCursor( 3191 *pFmt->GetDoc(), this, CURSOR_FRAME, *aPam.GetPoint()); 3192 aRef = static_cast<text::XWordCursor*>(pXCursor); 3193 #if OSL_DEBUG_LEVEL > 1 3194 SwUnoCrsr *const pUnoCrsr = pXCursor->GetCursor(); 3195 (void) pUnoCrsr; 3196 #endif 3197 } 3198 else 3199 throw uno::RuntimeException(); 3200 return aRef; 3201 } 3202 3203 uno::Reference< text::XTextCursor > SwXTextFrame::createTextCursorByRange(const uno::Reference< text::XTextRange > & aTextPosition) throw( uno::RuntimeException ) 3204 { 3205 vos::OGuard aGuard(Application::GetSolarMutex()); 3206 uno::Reference< text::XTextCursor > aRef; 3207 SwFrmFmt* pFmt = GetFrmFmt(); 3208 SwUnoInternalPaM aPam(*GetDoc()); 3209 if (pFmt && ::sw::XTextRangeToSwPaM(aPam, aTextPosition)) 3210 { 3211 SwNode& rNode = pFmt->GetCntnt().GetCntntIdx()->GetNode(); 3212 #if OSL_DEBUG_LEVEL > 1 3213 const SwStartNode* p1 = aPam.GetNode()->FindFlyStartNode(); 3214 const SwStartNode* p2 = rNode.FindFlyStartNode(); 3215 (void)p1; 3216 (void)p2; 3217 #endif 3218 if(aPam.GetNode()->FindFlyStartNode() == rNode.FindFlyStartNode()) 3219 { 3220 aRef = static_cast<text::XWordCursor*>( 3221 new SwXTextCursor(*pFmt->GetDoc(), this, CURSOR_FRAME, 3222 *aPam.GetPoint(), aPam.GetMark())); 3223 } 3224 } 3225 else 3226 throw uno::RuntimeException(); 3227 return aRef; 3228 } 3229 3230 uno::Reference< container::XEnumeration > SwXTextFrame::createEnumeration(void) throw( uno::RuntimeException ) 3231 { 3232 vos::OGuard aGuard(Application::GetSolarMutex()); 3233 uno::Reference< container::XEnumeration > aRef; 3234 SwFrmFmt* pFmt = GetFrmFmt(); 3235 if(pFmt) 3236 { 3237 SwPosition aPos(pFmt->GetCntnt().GetCntntIdx()->GetNode()); 3238 ::std::auto_ptr<SwUnoCrsr> pUnoCursor( 3239 GetDoc()->CreateUnoCrsr(aPos, sal_False)); 3240 pUnoCursor->Move(fnMoveForward, fnGoNode); 3241 // // no Cursor in protected sections 3242 // SwCrsrSaveState aSave( *pUnoCrsr ); 3243 // if(pUnoCrsr->IsInProtectTable( sal_True ) || 3244 // pUnoCrsr->IsSelOvr( SELOVER_TOGGLE | SELOVER_CHANGEPOS )) 3245 // throw uno::RuntimeException() ); 3246 aRef = new SwXParagraphEnumeration(this, pUnoCursor, CURSOR_FRAME); 3247 } 3248 return aRef; 3249 } 3250 3251 uno::Type SwXTextFrame::getElementType(void) throw( uno::RuntimeException ) 3252 { 3253 return ::getCppuType(static_cast<uno::Reference<text::XTextRange>*>(0)); 3254 } 3255 3256 sal_Bool SwXTextFrame::hasElements(void) throw( uno::RuntimeException ) 3257 { 3258 return sal_True; 3259 } 3260 3261 void SwXTextFrame::attach(const uno::Reference< text::XTextRange > & xTextRange) 3262 throw( lang::IllegalArgumentException, uno::RuntimeException ) 3263 { 3264 SwXFrame::attach(xTextRange); 3265 } 3266 3267 uno::Reference< text::XTextRange > SwXTextFrame::getAnchor(void) throw( uno::RuntimeException ) 3268 { 3269 vos::OGuard aGuard(Application::GetSolarMutex()); 3270 return SwXFrame::getAnchor(); 3271 } 3272 3273 void SwXTextFrame::dispose(void) throw( uno::RuntimeException ) 3274 { 3275 vos::OGuard aGuard(Application::GetSolarMutex()); 3276 SwXFrame::dispose(); 3277 } 3278 3279 void SwXTextFrame::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 3280 { 3281 SwXFrame::addEventListener(aListener); 3282 } 3283 3284 void SwXTextFrame::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 3285 { 3286 SwXFrame::removeEventListener(aListener); 3287 } 3288 3289 OUString SwXTextFrame::getImplementationName(void) throw( uno::RuntimeException ) 3290 { 3291 return C2U("SwXTextFrame"); 3292 } 3293 3294 sal_Bool SwXTextFrame::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 3295 { 3296 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.Text")|| 3297 COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextFrame")|| 3298 SwXFrame::supportsService(rServiceName); 3299 } 3300 3301 uno::Sequence< OUString > SwXTextFrame::getSupportedServiceNames(void) throw( uno::RuntimeException ) 3302 { 3303 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 3304 aRet.realloc(aRet.getLength() + 2); 3305 OUString* pArray = aRet.getArray(); 3306 pArray[aRet.getLength() - 2] = C2U("com.sun.star.text.TextFrame"); 3307 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.Text"); 3308 return aRet; 3309 } 3310 3311 void * SAL_CALL SwXTextFrame::operator new( size_t t) throw() 3312 { 3313 return SwXTextFrameBaseClass::operator new( t); 3314 } 3315 3316 void SAL_CALL SwXTextFrame::operator delete( void * p) throw() 3317 { 3318 SwXTextFrameBaseClass::operator delete(p); 3319 } 3320 3321 uno::Reference<container::XNameReplace > SAL_CALL SwXTextFrame::getEvents() 3322 throw(uno::RuntimeException) 3323 { 3324 return new SwFrameEventDescriptor( *this ); 3325 } 3326 3327 sal_Int64 SAL_CALL SwXTextFrame::getSomething( const uno::Sequence< sal_Int8 >& rId ) 3328 throw(uno::RuntimeException) 3329 { 3330 sal_Int64 nRet = SwXFrame::getSomething( rId ); 3331 if( !nRet ) 3332 nRet = SwXText::getSomething( rId ); 3333 3334 return nRet; 3335 } 3336 3337 ::uno::Any SwXTextFrame::getPropertyValue(const OUString& rPropertyName) 3338 throw( beans::UnknownPropertyException, lang::WrappedTargetException, uno::RuntimeException ) 3339 { 3340 vos::OGuard aGuard(Application::GetSolarMutex()); 3341 ::uno::Any aRet; 3342 if(rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_START_REDLINE))|| 3343 rPropertyName.equalsAsciiL(SW_PROP_NAME(UNO_NAME_END_REDLINE))) 3344 { 3345 //redline can only be returned if it's a living object 3346 if(!IsDescriptor()) 3347 aRet = SwXText::getPropertyValue(rPropertyName); 3348 } 3349 else 3350 aRet = SwXFrame::getPropertyValue(rPropertyName); 3351 return aRet; 3352 } 3353 /****************************************************************** 3354 * SwXTextGraphicObject 3355 ******************************************************************/ 3356 3357 SwXTextGraphicObject::SwXTextGraphicObject( SwDoc *pDoc ) : 3358 SwXFrame(FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC), pDoc) 3359 { 3360 } 3361 3362 SwXTextGraphicObject::SwXTextGraphicObject(SwFrmFmt& rFmt) : 3363 SwXFrame(rFmt, FLYCNTTYPE_GRF, aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_GRAPHIC)) 3364 { 3365 3366 } 3367 3368 SwXTextGraphicObject::~SwXTextGraphicObject() 3369 { 3370 3371 } 3372 3373 void SAL_CALL SwXTextGraphicObject::acquire( )throw() 3374 { 3375 SwXFrame::acquire(); 3376 } 3377 3378 void SAL_CALL SwXTextGraphicObject::release( )throw() 3379 { 3380 SwXFrame::release(); 3381 } 3382 3383 ::uno::Any SAL_CALL SwXTextGraphicObject::queryInterface( const uno::Type& aType ) 3384 throw(uno::RuntimeException) 3385 { 3386 ::uno::Any aRet = SwXFrame::queryInterface(aType); 3387 if(aRet.getValueType() == ::getCppuVoidType()) 3388 aRet = SwXTextGraphicObjectBaseClass::queryInterface(aType); 3389 return aRet; 3390 } 3391 3392 uno::Sequence< uno::Type > SAL_CALL 3393 SwXTextGraphicObject::getTypes( ) throw(uno::RuntimeException) 3394 { 3395 uno::Sequence< uno::Type > aGraphicTypes = SwXTextGraphicObjectBaseClass::getTypes(); 3396 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 3397 3398 long nIndex = aGraphicTypes.getLength(); 3399 aGraphicTypes.realloc( 3400 aGraphicTypes.getLength() + 3401 aFrameTypes.getLength()); 3402 3403 uno::Type* pGraphicTypes = aGraphicTypes.getArray(); 3404 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 3405 long nPos; 3406 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 3407 pGraphicTypes[nIndex++] = pFrameTypes[nPos]; 3408 3409 return aGraphicTypes; 3410 } 3411 3412 uno::Sequence< sal_Int8 > SAL_CALL SwXTextGraphicObject::getImplementationId( ) throw(uno::RuntimeException) 3413 { 3414 vos::OGuard aGuard(Application::GetSolarMutex()); 3415 static uno::Sequence< sal_Int8 > aId( 16 ); 3416 static sal_Bool bInit = sal_False; 3417 if(!bInit) 3418 { 3419 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 3420 bInit = sal_True; 3421 } 3422 return aId; 3423 } 3424 3425 void SwXTextGraphicObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException ) 3426 { 3427 SwXFrame::attach(xTextRange); 3428 } 3429 3430 uno::Reference< text::XTextRange > SwXTextGraphicObject::getAnchor(void) throw( uno::RuntimeException ) 3431 { 3432 vos::OGuard aGuard(Application::GetSolarMutex()); 3433 return SwXFrame::getAnchor(); 3434 } 3435 3436 void SwXTextGraphicObject::dispose(void) throw( uno::RuntimeException ) 3437 { 3438 vos::OGuard aGuard(Application::GetSolarMutex()); 3439 SwXFrame::dispose(); 3440 } 3441 3442 void SwXTextGraphicObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) 3443 throw( uno::RuntimeException ) 3444 { 3445 SwXFrame::addEventListener(aListener); 3446 } 3447 3448 void SwXTextGraphicObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) 3449 throw( uno::RuntimeException ) 3450 { 3451 SwXFrame::removeEventListener(aListener); 3452 } 3453 3454 OUString SwXTextGraphicObject::getImplementationName(void) throw( uno::RuntimeException ) 3455 { 3456 return C2U("SwXTextGraphicObject"); 3457 } 3458 3459 sal_Bool SwXTextGraphicObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 3460 { 3461 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextGraphicObject") || 3462 SwXFrame::supportsService(rServiceName); 3463 } 3464 3465 uno::Sequence< OUString > SwXTextGraphicObject::getSupportedServiceNames(void) 3466 throw( uno::RuntimeException ) 3467 { 3468 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 3469 aRet.realloc(aRet.getLength() + 1); 3470 OUString* pArray = aRet.getArray(); 3471 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextGraphicObject"); 3472 return aRet; 3473 } 3474 3475 void * SAL_CALL SwXTextGraphicObject::operator new( size_t t) throw() 3476 { 3477 return SwXTextGraphicObjectBaseClass::operator new(t); 3478 } 3479 3480 void SAL_CALL SwXTextGraphicObject::operator delete( void * p) throw() 3481 { 3482 SwXTextGraphicObjectBaseClass::operator delete(p); 3483 } 3484 3485 uno::Reference<container::XNameReplace> SAL_CALL 3486 SwXTextGraphicObject::getEvents() 3487 throw(uno::RuntimeException) 3488 { 3489 return new SwFrameEventDescriptor( *this ); 3490 } 3491 3492 /****************************************************************** 3493 * 3494 ******************************************************************/ 3495 3496 SwXTextEmbeddedObject::SwXTextEmbeddedObject( SwDoc *pDoc ) : 3497 SwXFrame(FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT), pDoc) 3498 { 3499 } 3500 3501 SwXTextEmbeddedObject::SwXTextEmbeddedObject(SwFrmFmt& rFmt) : 3502 SwXFrame(rFmt, FLYCNTTYPE_OLE, aSwMapProvider.GetPropertySet(PROPERTY_MAP_EMBEDDED_OBJECT)) 3503 { 3504 3505 } 3506 3507 SwXTextEmbeddedObject::~SwXTextEmbeddedObject() 3508 { 3509 3510 } 3511 3512 void SAL_CALL SwXTextEmbeddedObject::acquire()throw() 3513 { 3514 SwXFrame::acquire(); 3515 } 3516 3517 void SAL_CALL SwXTextEmbeddedObject::release()throw() 3518 { 3519 SwXFrame::release(); 3520 } 3521 3522 ::uno::Any SAL_CALL SwXTextEmbeddedObject::queryInterface( const uno::Type& aType ) 3523 throw( uno::RuntimeException) 3524 { 3525 ::uno::Any aRet = SwXFrame::queryInterface(aType);; 3526 if(aRet.getValueType() == ::getCppuVoidType()) 3527 aRet = SwXTextEmbeddedObjectBaseClass::queryInterface(aType); 3528 return aRet; 3529 } 3530 3531 uno::Sequence< uno::Type > SAL_CALL SwXTextEmbeddedObject::getTypes( ) throw(uno::RuntimeException) 3532 { 3533 uno::Sequence< uno::Type > aTextEmbeddedTypes = SwXTextEmbeddedObjectBaseClass::getTypes(); 3534 uno::Sequence< uno::Type > aFrameTypes = SwXFrame::getTypes(); 3535 3536 long nIndex = aTextEmbeddedTypes.getLength(); 3537 aTextEmbeddedTypes.realloc( 3538 aTextEmbeddedTypes.getLength() + 3539 aFrameTypes.getLength()); 3540 3541 uno::Type* pTextEmbeddedTypes = aTextEmbeddedTypes.getArray(); 3542 3543 const uno::Type* pFrameTypes = aFrameTypes.getConstArray(); 3544 long nPos; 3545 for(nPos = 0; nPos <aFrameTypes.getLength(); nPos++) 3546 pTextEmbeddedTypes[nIndex++] = pFrameTypes[nPos]; 3547 3548 return aTextEmbeddedTypes; 3549 } 3550 3551 uno::Sequence< sal_Int8 > SAL_CALL SwXTextEmbeddedObject::getImplementationId( ) throw(uno::RuntimeException) 3552 { 3553 vos::OGuard aGuard(Application::GetSolarMutex()); 3554 static uno::Sequence< sal_Int8 > aId( 16 ); 3555 static sal_Bool bInit = sal_False; 3556 if(!bInit) 3557 { 3558 rtl_createUuid( (sal_uInt8 *)(aId.getArray() ), 0, sal_True ); 3559 bInit = sal_True; 3560 } 3561 return aId; 3562 } 3563 3564 void SwXTextEmbeddedObject::attach(const uno::Reference< text::XTextRange > & xTextRange) throw( lang::IllegalArgumentException, uno::RuntimeException ) 3565 { 3566 SwXFrame::attach(xTextRange); 3567 } 3568 3569 uno::Reference< text::XTextRange > SwXTextEmbeddedObject::getAnchor(void) throw( uno::RuntimeException ) 3570 { 3571 vos::OGuard aGuard(Application::GetSolarMutex()); 3572 return SwXFrame::getAnchor(); 3573 } 3574 3575 void SwXTextEmbeddedObject::dispose(void) throw( uno::RuntimeException ) 3576 { 3577 vos::OGuard aGuard(Application::GetSolarMutex()); 3578 SwXFrame::dispose(); 3579 } 3580 3581 void SwXTextEmbeddedObject::addEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 3582 { 3583 SwXFrame::addEventListener(aListener); 3584 } 3585 3586 void SwXTextEmbeddedObject::removeEventListener(const uno::Reference< lang::XEventListener > & aListener) throw( uno::RuntimeException ) 3587 { 3588 SwXFrame::removeEventListener(aListener); 3589 } 3590 3591 uno::Reference< lang::XComponent > SwXTextEmbeddedObject::getEmbeddedObject(void) throw( uno::RuntimeException ) 3592 { 3593 uno::Reference< lang::XComponent > xRet; 3594 SwFrmFmt* pFmt = GetFrmFmt(); 3595 if(pFmt) 3596 { 3597 SwDoc* pDoc = pFmt->GetDoc(); 3598 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3599 DBG_ASSERT( pCnt->GetCntntIdx() && 3600 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3601 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3602 3603 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 3604 ->GetIndex() + 1 ]->GetOLENode(); 3605 uno::Reference < embed::XEmbeddedObject > xIP = pOleNode->GetOLEObj().GetOleRef(); 3606 if ( svt::EmbeddedObjectRef::TryRunningState( xIP ) ) 3607 { 3608 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here 3609 if ( pDoc->GetDocShell() ) 3610 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xIP, embed::Aspects::MSOLE_CONTENT ) ); 3611 3612 xRet = uno::Reference < lang::XComponent >( xIP->getComponent(), uno::UNO_QUERY ); 3613 uno::Reference< util::XModifyBroadcaster > xBrdcst( xRet, uno::UNO_QUERY); 3614 uno::Reference< frame::XModel > xModel( xRet, uno::UNO_QUERY); 3615 if( xBrdcst.is() && xModel.is() ) 3616 { 3617 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt ); 3618 //create a new one if the OLE object doesn't have one already 3619 if( !pListener ) 3620 { 3621 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel); 3622 xBrdcst->addModifyListener( xOLEListener ); 3623 } 3624 } 3625 } 3626 } 3627 return xRet; 3628 } 3629 3630 uno::Reference< embed::XEmbeddedObject > SAL_CALL SwXTextEmbeddedObject::getExtendedControlOverEmbeddedObject() 3631 throw( uno::RuntimeException ) 3632 { 3633 uno::Reference< embed::XEmbeddedObject > xResult; 3634 SwFrmFmt* pFmt = GetFrmFmt(); 3635 if(pFmt) 3636 { 3637 SwDoc* pDoc = pFmt->GetDoc(); 3638 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3639 DBG_ASSERT( pCnt->GetCntntIdx() && 3640 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3641 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3642 3643 SwOLENode* pOleNode = pDoc->GetNodes()[ pCnt->GetCntntIdx() 3644 ->GetIndex() + 1 ]->GetOLENode(); 3645 xResult = pOleNode->GetOLEObj().GetOleRef(); 3646 if ( svt::EmbeddedObjectRef::TryRunningState( xResult ) ) 3647 { 3648 // TODO/LATER: the listener registered after client creation should be able to handle scaling, after that the client is not necessary here 3649 if ( pDoc->GetDocShell() ) 3650 pDoc->GetDocShell()->GetIPClient( svt::EmbeddedObjectRef( xResult, embed::Aspects::MSOLE_CONTENT ) ); 3651 3652 uno::Reference < lang::XComponent > xComp( xResult->getComponent(), uno::UNO_QUERY ); 3653 uno::Reference< util::XModifyBroadcaster > xBrdcst( xComp, uno::UNO_QUERY); 3654 uno::Reference< frame::XModel > xModel( xComp, uno::UNO_QUERY); 3655 if( xBrdcst.is() && xModel.is() ) 3656 { 3657 SwXOLEListener* pListener = SwIterator<SwXOLEListener,SwFmt>::FirstElement( *pFmt ); 3658 //create a new one if the OLE object doesn't have one already 3659 if( !pListener ) 3660 { 3661 uno::Reference< util::XModifyListener > xOLEListener = new SwXOLEListener(*pFmt, xModel); 3662 xBrdcst->addModifyListener( xOLEListener ); 3663 } 3664 } 3665 } 3666 } 3667 return xResult; 3668 } 3669 3670 sal_Int64 SAL_CALL SwXTextEmbeddedObject::getAspect() throw (uno::RuntimeException) 3671 { 3672 SwFrmFmt* pFmt = GetFrmFmt(); 3673 if(pFmt) 3674 { 3675 SwDoc* pDoc = pFmt->GetDoc(); 3676 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3677 DBG_ASSERT( pCnt->GetCntntIdx() && 3678 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3679 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3680 3681 return pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetAspect(); 3682 } 3683 3684 return embed::Aspects::MSOLE_CONTENT; // return the default value 3685 } 3686 3687 void SAL_CALL SwXTextEmbeddedObject::setAspect( sal_Int64 nAspect ) throw (uno::RuntimeException) 3688 { 3689 SwFrmFmt* pFmt = GetFrmFmt(); 3690 if(pFmt) 3691 { 3692 SwDoc* pDoc = pFmt->GetDoc(); 3693 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3694 DBG_ASSERT( pCnt->GetCntntIdx() && 3695 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3696 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3697 3698 pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->SetAspect( nAspect ); 3699 } 3700 } 3701 3702 uno::Reference< graphic::XGraphic > SAL_CALL SwXTextEmbeddedObject::getReplacementGraphic() throw (uno::RuntimeException) 3703 { 3704 SwFrmFmt* pFmt = GetFrmFmt(); 3705 if(pFmt) 3706 { 3707 SwDoc* pDoc = pFmt->GetDoc(); 3708 const SwFmtCntnt* pCnt = &pFmt->GetCntnt(); 3709 DBG_ASSERT( pCnt->GetCntntIdx() && 3710 pDoc->GetNodes()[ pCnt->GetCntntIdx()-> 3711 GetIndex() + 1 ]->GetOLENode(), "kein OLE-Node?"); 3712 3713 Graphic* pGraphic = pDoc->GetNodes()[ pCnt->GetCntntIdx()->GetIndex() + 1 ]->GetOLENode()->GetGraphic(); 3714 if ( pGraphic ) 3715 return pGraphic->GetXGraphic(); 3716 } 3717 3718 return uno::Reference< graphic::XGraphic >(); 3719 } 3720 3721 3722 OUString SwXTextEmbeddedObject::getImplementationName(void) throw( uno::RuntimeException ) 3723 3724 { 3725 return C2U("SwXTextEmbeddedObject"); 3726 } 3727 3728 sal_Bool SwXTextEmbeddedObject::supportsService(const OUString& rServiceName) throw( uno::RuntimeException ) 3729 { 3730 return COMPARE_EQUAL == rServiceName.compareToAscii("com.sun.star.text.TextEmbeddedObject")|| 3731 SwXFrame::supportsService(rServiceName); 3732 } 3733 3734 uno::Sequence< OUString > SwXTextEmbeddedObject::getSupportedServiceNames(void) 3735 throw( uno::RuntimeException ) 3736 { 3737 uno::Sequence < OUString > aRet = SwXFrame::getSupportedServiceNames(); 3738 aRet.realloc(aRet.getLength() + 1); 3739 OUString* pArray = aRet.getArray(); 3740 pArray[aRet.getLength() - 1] = C2U("com.sun.star.text.TextEmbeddedObject"); 3741 return aRet; 3742 } 3743 3744 void * SAL_CALL SwXTextEmbeddedObject::operator new( size_t t) throw() 3745 { 3746 return SwXTextEmbeddedObjectBaseClass::operator new(t); 3747 } 3748 3749 void SAL_CALL SwXTextEmbeddedObject::operator delete( void * p) throw() 3750 { 3751 SwXTextEmbeddedObjectBaseClass::operator delete(p); 3752 } 3753 3754 uno::Reference<container::XNameReplace> SAL_CALL 3755 SwXTextEmbeddedObject::getEvents() 3756 throw(uno::RuntimeException) 3757 { 3758 return new SwFrameEventDescriptor( *this ); 3759 } 3760 3761 3762 /****************************************************************** 3763 * 3764 ******************************************************************/ 3765 TYPEINIT1(SwXOLEListener, SwClient); 3766 3767 SwXOLEListener::SwXOLEListener( SwFmt& rOLEFmt, uno::Reference< XModel > xOLE) : 3768 SwClient(&rOLEFmt), 3769 xOLEModel(xOLE) 3770 { 3771 } 3772 3773 SwXOLEListener::~SwXOLEListener() 3774 {} 3775 3776 void SwXOLEListener::modified( const lang::EventObject& /*rEvent*/ ) 3777 throw( uno::RuntimeException ) 3778 { 3779 vos::OGuard aGuard(Application::GetSolarMutex()); 3780 3781 SwOLENode* pNd = 0; 3782 SwFmt* pFmt = GetFmt(); 3783 if(pFmt) 3784 {const SwNodeIndex* pIdx = pFmt->GetCntnt().GetCntntIdx(); 3785 if(pIdx) 3786 { 3787 SwNodeIndex aIdx(*pIdx, 1); 3788 SwNoTxtNode* pNoTxt = aIdx.GetNode().GetNoTxtNode(); 3789 pNd = pNoTxt->GetOLENode(); 3790 } 3791 } 3792 if(!pNd) 3793 throw uno::RuntimeException(); 3794 3795 uno::Reference < embed::XEmbeddedObject > xIP = pNd->GetOLEObj().GetOleRef(); 3796 if ( xIP.is() ) 3797 { 3798 sal_Int32 nState = xIP->getCurrentState(); 3799 if ( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE ) 3800 return; 3801 } 3802 3803 // if the OLE-Node is UI-Active do nothing 3804 pNd->SetOLESizeInvalid( sal_True ); 3805 pNd->GetDoc()->SetOLEObjModified(); 3806 } 3807 3808 /* --------------------------------------------------------------------------- 3809 3810 ---------------------------------------------------------------------------*/ 3811 void SwXOLEListener::disposing( const lang::EventObject& rEvent ) 3812 throw( uno::RuntimeException ) 3813 { 3814 vos::OGuard aGuard(Application::GetSolarMutex()); 3815 3816 uno::Reference< util::XModifyListener > xListener( this ); 3817 3818 3819 uno::Reference< frame::XModel > xModel( rEvent.Source, uno::UNO_QUERY ); 3820 uno::Reference< util::XModifyBroadcaster > xBrdcst(xModel, uno::UNO_QUERY); 3821 3822 try 3823 { 3824 if( xBrdcst.is() ) 3825 xBrdcst->removeModifyListener( xListener ); 3826 } 3827 catch(uno::Exception const &) 3828 { 3829 DBG_ERROR("OLE Listener couldn't be removed"); 3830 } 3831 } 3832 /* --------------------------------------------------------------------------- 3833 3834 ---------------------------------------------------------------------------*/ 3835 void SwXOLEListener::Modify( const SfxPoolItem* pOld, const SfxPoolItem* pNew ) 3836 { 3837 ClientModify(this, pOld, pNew); 3838 if(!GetRegisteredIn()) 3839 xOLEModel = 0; 3840 } 3841 3842