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