1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 // MARKER(update_precomp.py): autogen include statement, do not remove 23 #include "precompiled_sw.hxx" 24 25 #include <hintids.hxx> 26 #include <svl/whiter.hxx> 27 #include <svtools/imapobj.hxx> 28 #include <svl/srchitem.hxx> 29 #include <svtools/imap.hxx> 30 #include <sfx2/viewfrm.hxx> 31 #include <basic/sbstar.hxx> 32 #include <svl/rectitem.hxx> 33 #include <svl/ptitem.hxx> 34 #include <svl/stritem.hxx> 35 #include <svl/intitem.hxx> 36 #include <svl/eitem.hxx> 37 #include <editeng/colritem.hxx> 38 #include <editeng/bolnitem.hxx> 39 #include <editeng/boxitem.hxx> 40 #include <editeng/protitem.hxx> 41 #include <sfx2/dispatch.hxx> 42 #include <sfx2/request.hxx> 43 #include <sfx2/objface.hxx> 44 #include <sfx2/sidebar/EnumContext.hxx> 45 #include <svx/hlnkitem.hxx> 46 #include <svx/svdview.hxx> 47 #include <vcl/msgbox.hxx> 48 #include <doc.hxx> 49 #include <fmturl.hxx> 50 #include <fmtclds.hxx> 51 #include <fmtcnct.hxx> 52 #include <swmodule.hxx> 53 #include <wrtsh.hxx> 54 #include <wview.hxx> 55 #include <frmatr.hxx> 56 #include <uitool.hxx> 57 #include <frmfmt.hxx> 58 #include <frmsh.hxx> 59 #include <frmmgr.hxx> 60 #include <frmdlg.hxx> 61 #include <swevent.hxx> 62 #include <usrpref.hxx> 63 #include <edtwin.hxx> 64 #include <swdtflvr.hxx> 65 #include <swwait.hxx> 66 #include <docstat.hxx> 67 #include <IDocumentStatistics.hxx> 68 #include <comphelper/processfactory.hxx> 69 #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> 70 #include <helpid.h> 71 #include <cmdid.h> 72 #include <cfgitems.hxx> 73 #include <globals.hrc> 74 #include <popup.hrc> 75 #include <shells.hrc> 76 #include "swabstdlg.hxx" 77 #include "misc.hrc" 78 #include <svx/dialogs.hrc> 79 80 #include <docsh.hxx> 81 #include <svx/drawitem.hxx> 82 83 using namespace ::com::sun::star; 84 using namespace ::com::sun::star::uno; 85 86 // Prototypen ------------------------------------------------------------ 87 88 void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine); 89 const SwFrmFmt* lcl_GetFrmFmtByName(SwWrtShell& rSh, const String& rName) 90 { 91 sal_uInt16 nCount = rSh.GetFlyCount(FLYCNTTYPE_FRM); 92 for( sal_uInt16 i = 0; i < nCount; i++) 93 { 94 const SwFrmFmt* pFmt = rSh.GetFlyNum(i, FLYCNTTYPE_FRM); 95 if(pFmt->GetName() == rName) 96 return pFmt; 97 } 98 return 0; 99 } 100 101 #define SwFrameShell 102 #include <sfx2/msg.hxx> 103 #include "swslots.hxx" 104 105 SFX_IMPL_INTERFACE(SwFrameShell, SwBaseShell, SW_RES(STR_SHELLNAME_FRAME)) 106 { 107 SFX_POPUPMENU_REGISTRATION(SW_RES(MN_FRM_POPUPMENU)); 108 SFX_OBJECTBAR_REGISTRATION(SFX_OBJECTBAR_OBJECT, SW_RES(RID_FRAME_TOOLBOX)); 109 } 110 111 112 113 void SwFrameShell::Execute(SfxRequest &rReq) 114 { 115 //Erstmal die, die keinen FrmMgr benoetigen. 116 SwWrtShell &rSh = GetShell(); 117 sal_Bool bMore = sal_False; 118 const SfxItemSet* pArgs = rReq.GetArgs(); 119 const SfxPoolItem* pItem; 120 sal_uInt16 nSlot = rReq.GetSlot(); 121 122 switch ( nSlot ) 123 { 124 case FN_FRAME_TO_ANCHOR: 125 if ( rSh.IsFrmSelected() ) 126 { 127 rSh.GotoFlyAnchor(); 128 rSh.EnterStdMode(); 129 rSh.CallChgLnk(); 130 } 131 break; 132 case SID_FRAME_TO_TOP: 133 rSh.SelectionToTop(); 134 break; 135 136 case SID_FRAME_TO_BOTTOM: 137 rSh.SelectionToBottom(); 138 break; 139 140 case FN_FRAME_UP: 141 rSh.SelectionToTop( sal_False ); 142 break; 143 144 case FN_FRAME_DOWN: 145 rSh.SelectionToBottom( sal_False ); 146 break; 147 case FN_INSERT_FRAME: 148 if (!pArgs) 149 { 150 // Rahmen existiert bereits, Rahmendialog zur Bearbeitung oeffnen 151 SfxUInt16Item aDefPage(FN_FORMAT_FRAME_DLG, TP_COLUMN); 152 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute( FN_FORMAT_FRAME_DLG, 153 SFX_CALLMODE_SYNCHRON|SFX_CALLMODE_RECORD, 154 &aDefPage, 0L ); 155 156 } 157 else 158 { 159 // Rahmen existiert bereits, nur Spaltenanzahl wird geaendert 160 sal_uInt16 nCols = 1; 161 if(pArgs->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem) == SFX_ITEM_SET) 162 nCols = ((SfxUInt16Item *)pItem)->GetValue(); 163 164 SfxItemSet aSet(GetPool(),RES_COL,RES_COL); 165 rSh.GetFlyFrmAttr( aSet ); 166 SwFmtCol aCol((const SwFmtCol&)aSet.Get(RES_COL)); 167 // GutterWidth wird nicht immer uebergeben, daher erst besorgen (siehe view2: Execute auf diesen Slot) 168 sal_uInt16 nGutterWidth = aCol.GetGutterWidth(); 169 if(!nCols ) 170 nCols++; 171 aCol.Init(nCols, nGutterWidth, aCol.GetWishWidth()); 172 aSet.Put(aCol); 173 // Vorlagen-AutoUpdate 174 SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); 175 if(pFmt && pFmt->IsAutoUpdateFmt()) 176 { 177 rSh.AutoUpdateFrame(pFmt, aSet); 178 } 179 else 180 { 181 rSh.StartAllAction(); 182 rSh.SetFlyFrmAttr( aSet ); 183 rSh.SetModified(); 184 rSh.EndAllAction(); 185 } 186 187 } 188 return; 189 190 case SID_HYPERLINK_SETLINK: 191 { 192 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(SID_HYPERLINK_SETLINK, sal_False, &pItem)) 193 { 194 const SvxHyperlinkItem& rHLinkItem = *(const SvxHyperlinkItem *)pItem; 195 const String& rURL = rHLinkItem.GetURL(); 196 const String& rTarget = rHLinkItem.GetTargetFrame(); 197 198 SfxItemSet aSet( rSh.GetAttrPool(), RES_URL, RES_URL ); 199 rSh.GetFlyFrmAttr( aSet ); 200 SwFmtURL aURL( (SwFmtURL&)aSet.Get( RES_URL ) ); 201 202 String sOldName(rHLinkItem.GetName()); 203 String sFlyName(rSh.GetFlyName()); 204 if (sOldName.ToUpperAscii() != sFlyName.ToUpperAscii()) 205 { 206 String sName(sOldName); 207 sal_uInt16 i = 1; 208 while (rSh.FindFlyByName(sName)) 209 { 210 sName = sOldName; 211 sName += '_'; 212 sName += String::CreateFromInt32(i++); 213 } 214 rSh.SetFlyName(sName); 215 } 216 aURL.SetURL( rURL, sal_False ); 217 aURL.SetTargetFrameName(rTarget); 218 219 aSet.Put( aURL ); 220 rSh.SetFlyFrmAttr( aSet ); 221 } 222 } 223 break; 224 225 case FN_FRAME_CHAIN: 226 rSh.GetView().GetEditWin().SetChainMode( !rSh.GetView().GetEditWin().IsChainMode() ); 227 break; 228 229 case FN_FRAME_UNCHAIN: 230 rSh.Unchain( (SwFrmFmt&)*rSh.GetFlyFrmFmt() ); 231 GetView().GetViewFrame()->GetBindings().Invalidate(FN_FRAME_CHAIN); 232 break; 233 case FN_FORMAT_FOOTNOTE_DLG: 234 { 235 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 236 DBG_ASSERT(pFact, "SwAbstractDialogFactory fail!"); 237 238 VclAbstractDialog* pDlg = pFact->CreateSwFootNoteOptionDlg( GetView().GetWindow(), GetView().GetWrtShell(), DLG_DOC_FOOTNOTE ); 239 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 240 pDlg->Execute(); 241 delete pDlg; 242 break; 243 } 244 case FN_NUMBERING_OUTLINE_DLG: 245 { 246 SfxItemSet aTmp(GetPool(), FN_PARAM_1, FN_PARAM_1); 247 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 248 DBG_ASSERT(pFact, "Dialogdiet fail!"); 249 SfxAbstractTabDialog* pDlg = pFact->CreateSwTabDialog( DLG_TAB_OUTLINE, 250 GetView().GetWindow(), &aTmp, GetView().GetWrtShell()); 251 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 252 pDlg->Execute(); 253 delete pDlg; 254 rReq.Done(); 255 break; 256 } 257 case SID_OPEN_XML_FILTERSETTINGS: 258 { 259 try 260 { 261 uno::Reference < ui::dialogs::XExecutableDialog > xDialog(::comphelper::getProcessServiceFactory()->createInstance(rtl::OUString::createFromAscii("com.sun.star.comp.ui.XSLTFilterDialog")), uno::UNO_QUERY); 262 if( xDialog.is() ) 263 { 264 xDialog->execute(); 265 } 266 } 267 catch( uno::Exception& ) 268 { 269 } 270 rReq.Ignore (); 271 } 272 break; 273 case FN_WORDCOUNT_DIALOG: 274 { 275 SwDocStat aCurr; 276 SwDocStat aDocStat( rSh.getIDocumentStatistics()->GetDocStat() ); 277 { 278 SwWait aWait( *GetView().GetDocShell(), sal_True ); 279 rSh.StartAction(); 280 rSh.CountWords( aCurr ); 281 rSh.UpdateDocStat( aDocStat ); 282 rSh.EndAction(); 283 } 284 285 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 286 DBG_ASSERT(pFact, "Dialogdiet fail!"); 287 AbstractSwWordCountDialog* pDialog = pFact->CreateSwWordCountDialog( GetView().GetWindow() ); 288 pDialog->SetValues(aCurr, aDocStat ); 289 pDialog->Execute(); 290 delete pDialog; 291 } 292 break; 293 default: bMore = sal_True; 294 } 295 296 if ( !bMore ) 297 { 298 return; 299 } 300 301 SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE ); 302 sal_Bool bUpdateMgr = sal_True; 303 sal_Bool bCopyToFmt = sal_False; 304 switch ( nSlot ) 305 { 306 case SID_OBJECT_ALIGN_MIDDLE: 307 case FN_FRAME_ALIGN_VERT_CENTER: 308 aMgr.SetVertOrientation( text::VertOrientation::CENTER ); 309 break; 310 case SID_OBJECT_ALIGN_DOWN : 311 case FN_FRAME_ALIGN_VERT_BOTTOM: 312 aMgr.SetVertOrientation( text::VertOrientation::BOTTOM ); 313 break; 314 case SID_OBJECT_ALIGN_UP : 315 case FN_FRAME_ALIGN_VERT_TOP: 316 aMgr.SetVertOrientation( text::VertOrientation::TOP ); 317 break; 318 319 case FN_FRAME_ALIGN_VERT_CHAR_CENTER: 320 aMgr.SetVertOrientation( text::VertOrientation::CHAR_CENTER ); 321 break; 322 323 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: 324 aMgr.SetVertOrientation( text::VertOrientation::CHAR_BOTTOM ); 325 break; 326 327 case FN_FRAME_ALIGN_VERT_CHAR_TOP: 328 aMgr.SetVertOrientation( text::VertOrientation::CHAR_TOP ); 329 break; 330 331 case FN_FRAME_ALIGN_VERT_ROW_CENTER: 332 aMgr.SetVertOrientation( text::VertOrientation::LINE_CENTER ); 333 break; 334 335 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: 336 aMgr.SetVertOrientation( text::VertOrientation::LINE_BOTTOM ); 337 break; 338 339 case FN_FRAME_ALIGN_VERT_ROW_TOP: 340 aMgr.SetVertOrientation( text::VertOrientation::LINE_TOP ); 341 break; 342 case SID_OBJECT_ALIGN_CENTER : 343 case FN_FRAME_ALIGN_HORZ_CENTER: 344 aMgr.SetHorzOrientation( text::HoriOrientation::CENTER ); 345 break; 346 case SID_OBJECT_ALIGN_RIGHT: 347 case FN_FRAME_ALIGN_HORZ_RIGHT: 348 aMgr.SetHorzOrientation( text::HoriOrientation::RIGHT ); 349 break; 350 case SID_OBJECT_ALIGN_LEFT: 351 case FN_FRAME_ALIGN_HORZ_LEFT: 352 aMgr.SetHorzOrientation( text::HoriOrientation::LEFT ); 353 break; 354 355 case FN_SET_FRM_POSITION: 356 { 357 aMgr.SetAbsPos(((SfxPointItem &)pArgs->Get 358 (FN_SET_FRM_POSITION)).GetValue()); 359 } 360 break; 361 case SID_ATTR_BRUSH: 362 { 363 if(pArgs) 364 { 365 aMgr.SetAttrSet( *pArgs ); 366 bCopyToFmt = sal_True; 367 } 368 } 369 break; 370 case SID_ATTR_ULSPACE: 371 case SID_ATTR_LRSPACE: 372 { 373 if(pArgs && SFX_ITEM_SET == pArgs->GetItemState(GetPool().GetWhich(nSlot), sal_False, &pItem)) 374 { 375 aMgr.SetAttrSet( *pArgs ); 376 if(SID_ATTR_ULSPACE == nSlot && SID_ATTR_ULSPACE == nSlot) 377 bCopyToFmt = sal_True; 378 } 379 } 380 break; 381 382 case SID_ATTR_TRANSFORM: 383 { 384 bool bApplyNewSize = false; 385 386 Size aNewSize = aMgr.GetSize(); 387 if ( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_TRANSFORM_WIDTH, sal_False, &pItem ) ) 388 { 389 aNewSize.setWidth( static_cast< const SfxUInt32Item* >(pItem)->GetValue() ); 390 bApplyNewSize = true; 391 } 392 393 if ( SFX_ITEM_SET == pArgs->GetItemState( SID_ATTR_TRANSFORM_HEIGHT, sal_False, &pItem ) ) 394 { 395 aNewSize.setHeight( static_cast< const SfxUInt32Item* >(pItem)->GetValue() ); 396 bApplyNewSize = true; 397 } 398 399 if ( bApplyNewSize ) 400 { 401 aMgr.SetSize( aNewSize ); 402 } 403 else 404 { 405 bUpdateMgr = sal_False; 406 } 407 408 } 409 break; 410 411 case FN_FORMAT_FRAME_DLG: 412 case FN_DRAW_WRAP_DLG: 413 { 414 const int nSel = rSh.GetSelectionType(); 415 if (nSel & nsSelectionType::SEL_GRF) 416 { 417 rSh.GetView().GetViewFrame()->GetDispatcher()->Execute(FN_FORMAT_GRAFIC_DLG); 418 bUpdateMgr = sal_False; 419 } 420 else 421 { 422 SfxItemSet aSet(GetPool(), //UUUU sorted by indices 423 RES_FRMATR_BEGIN, RES_FRMATR_END-1, // [82 424 425 //UUUU FillAttribute support 426 XATTR_FILL_FIRST, XATTR_FILL_LAST, // [1014 427 428 SID_DOCFRAME, SID_DOCFRAME, // [5598 429 430 SID_ATTR_BRUSH, SID_ATTR_BRUSH, // [10001 431 SID_ATTR_BORDER_INNER, SID_ATTR_BORDER_INNER, // [10023 432 SID_ATTR_LRSPACE, SID_ATTR_ULSPACE, // [10048 433 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, // [10051 434 435 //UUUU items to hand over XPropertyList things like 436 // XColorList, XHatchList, XGradientList and XBitmapList 437 // to the Area TabPage 438 SID_COLOR_TABLE, SID_BITMAP_LIST, // [10179 439 440 SID_HTML_MODE, SID_HTML_MODE, // [10414 441 FN_GET_PRINT_AREA, FN_GET_PRINT_AREA, // [21032 442 FN_SURROUND, FN_HORI_ORIENT, // [21303 443 FN_SET_FRM_NAME, FN_SET_FRM_NAME, // [21306 444 FN_KEEP_ASPECT_RATIO, FN_KEEP_ASPECT_RATIO, // [21307 445 FN_SET_FRM_ALT_NAME, FN_SET_FRM_ALT_NAME, // [21318 446 FN_OLE_IS_MATH, FN_OLE_IS_MATH, // [22314 447 FN_MATH_BASELINE_ALIGNMENT, FN_MATH_BASELINE_ALIGNMENT, // [22315 448 FN_PARAM_CHAIN_PREVIOUS, FN_PARAM_CHAIN_NEXT, // [22420 449 450 0); 451 452 //UUUU create needed items for XPropertyList entries from the DrawModel so that 453 // the Area TabPage can access them 454 const SdrModel* pDrawModel = rSh.GetView().GetDocShell()->GetDoc()->GetDrawModel(); 455 456 aSet.Put(SvxColorTableItem(pDrawModel->GetColorTableFromSdrModel(), SID_COLOR_TABLE)); 457 aSet.Put(SvxGradientListItem(pDrawModel->GetGradientListFromSdrModel(), SID_GRADIENT_LIST)); 458 aSet.Put(SvxHatchListItem(pDrawModel->GetHatchListFromSdrModel(), SID_HATCH_LIST)); 459 aSet.Put(SvxBitmapListItem(pDrawModel->GetBitmapListFromSdrModel(), SID_BITMAP_LIST)); 460 461 const SwViewOption* pVOpt = rSh.GetViewOptions(); 462 if(nSel & nsSelectionType::SEL_OLE) 463 aSet.Put( SfxBoolItem(FN_KEEP_ASPECT_RATIO, pVOpt->IsKeepRatio()) ); 464 aSet.Put(SfxUInt16Item(SID_HTML_MODE, ::GetHtmlMode(GetView().GetDocShell()))); 465 aSet.Put(SfxStringItem(FN_SET_FRM_NAME, rSh.GetFlyName())); 466 if( nSel & nsSelectionType::SEL_OLE ) 467 { 468 aSet.Put( SfxStringItem( FN_SET_FRM_ALT_NAME, rSh.GetObjTitle() ) ); 469 } 470 471 const SwRect &rPg = rSh.GetAnyCurRect(RECT_PAGE); 472 SwFmtFrmSize aFrmSize(ATT_VAR_SIZE, rPg.Width(), rPg.Height()); 473 aFrmSize.SetWhich(GetPool().GetWhich(SID_ATTR_PAGE_SIZE)); 474 aSet.Put(aFrmSize); 475 476 const SwRect &rPr = rSh.GetAnyCurRect(RECT_PAGE_PRT); 477 SwFmtFrmSize aPrtSize(ATT_VAR_SIZE, rPr.Width(), rPr.Height()); 478 aPrtSize.SetWhich(GetPool().GetWhich(FN_GET_PRINT_AREA)); 479 aSet.Put(aPrtSize); 480 481 aSet.Put(aMgr.GetAttrSet()); 482 aSet.SetParent( aMgr.GetAttrSet().GetParent() ); 483 484 // Bei %-Werten Groesse initialisieren 485 SwFmtFrmSize& rSize = (SwFmtFrmSize&)aSet.Get(RES_FRM_SIZE); 486 if (rSize.GetWidthPercent() && rSize.GetWidthPercent() != 0xff) 487 rSize.SetWidth(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Width()); 488 if (rSize.GetHeightPercent() && rSize.GetHeightPercent() != 0xff) 489 rSize.SetHeight(rSh.GetAnyCurRect(RECT_FLY_EMBEDDED).Height()); 490 491 // disable vertical positioning for Math Objects anchored 'as char' if baseline alignment is activated 492 aSet.Put( SfxBoolItem( FN_MATH_BASELINE_ALIGNMENT, 493 rSh.GetDoc()->get( IDocumentSettingAccess::MATH_BASELINE_ALIGNMENT ) ) ); 494 const uno::Reference < embed::XEmbeddedObject > xObj( rSh.GetOleRef() ); 495 aSet.Put( SfxBoolItem( FN_OLE_IS_MATH, xObj.is() && SotExchange::IsMath( xObj->getClassID() ) ) ); 496 497 sal_uInt16 nDefPage = 0; 498 if(pArgs && pArgs->GetItemState(FN_FORMAT_FRAME_DLG, sal_False, &pItem) == SFX_ITEM_SET) 499 nDefPage = ((SfxUInt16Item *)pItem)->GetValue(); 500 501 aSet.Put(SfxFrameItem( SID_DOCFRAME, &GetView().GetViewFrame()->GetTopFrame())); 502 FieldUnit eMetric = ::GetDfltMetric(0 != PTR_CAST(SwWebView, &GetView())); 503 SW_MOD()->PutItem(SfxUInt16Item(SID_ATTR_METRIC, static_cast< sal_uInt16 >(eMetric) )); 504 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 505 DBG_ASSERT(pFact, "Dialogdiet fail!"); 506 SfxAbstractTabDialog* pDlg = pFact->CreateFrmTabDialog( DLG_FRM_STD, 507 GetView().GetViewFrame(), 508 GetView().GetWindow(), 509 aSet, sal_False, 510 nSel & nsSelectionType::SEL_GRF ? DLG_FRM_GRF : 511 nSel & nsSelectionType::SEL_OLE ? DLG_FRM_OLE : 512 DLG_FRM_STD, 513 sal_False, 514 nDefPage); 515 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 516 517 if ( nSlot == FN_DRAW_WRAP_DLG ) 518 { 519 pDlg->SetCurPageId(TP_FRM_WRAP); 520 } 521 522 if ( pDlg->Execute() ) 523 { 524 const SfxItemSet* pOutSet = pDlg->GetOutputItemSet(); 525 if(pOutSet) 526 { 527 rReq.Done(*pOutSet); 528 if(nSel & nsSelectionType::SEL_OLE && 529 SFX_ITEM_SET == pOutSet->GetItemState(FN_KEEP_ASPECT_RATIO, sal_True, &pItem)) 530 { 531 SwViewOption aUsrPref( *pVOpt ); 532 aUsrPref.SetKeepRatio(((const SfxBoolItem*)pItem)->GetValue()); 533 SW_MOD()->ApplyUsrPref(aUsrPref, &GetView()); 534 } 535 if (SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_ALT_NAME, sal_True, &pItem)) 536 { 537 // --> OD 2009-07-13 #i73249# 538 // rSh.SetAlternateText(((const SfxStringItem*)pItem)->GetValue()); 539 rSh.SetObjTitle(((const SfxStringItem*)pItem)->GetValue()); 540 // <-- 541 } 542 // Vorlagen-AutoUpdate 543 SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); 544 if(pFmt && pFmt->IsAutoUpdateFmt()) 545 { 546 rSh.AutoUpdateFrame(pFmt, *pOutSet); 547 // alles, dass das Format nicht kann, muss hart 548 // gesetzt werden 549 if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, sal_False, &pItem)) 550 rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue()); 551 SfxItemSet aShellSet(GetPool(), RES_FRM_SIZE, RES_FRM_SIZE, 552 RES_SURROUND, RES_SURROUND, 553 RES_ANCHOR, RES_ANCHOR, 554 RES_VERT_ORIENT,RES_HORI_ORIENT, 555 0); 556 aShellSet.Put(*pOutSet); 557 aMgr.SetAttrSet(aShellSet); 558 if(SFX_ITEM_SET == pOutSet->GetItemState(FN_SET_FRM_NAME, sal_False, &pItem)) 559 rSh.SetFlyName(((SfxStringItem*)pItem)->GetValue()); 560 } 561 else 562 aMgr.SetAttrSet( *pOutSet ); 563 564 const SwFrmFmt* pCurrFlyFmt = rSh.GetFlyFrmFmt(); 565 if(SFX_ITEM_SET == 566 pOutSet->GetItemState(FN_PARAM_CHAIN_PREVIOUS, 567 sal_False, &pItem)) 568 { 569 rSh.HideChainMarker(); 570 571 String sPrevName = 572 ((const SfxStringItem*)pItem)->GetValue(); 573 const SwFmtChain &rChain = pCurrFlyFmt->GetChain(); 574 //needs cast - no non-const method available 575 SwFlyFrmFmt* pFlyFmt = 576 (SwFlyFrmFmt*)rChain.GetPrev(); 577 if(pFlyFmt) 578 { 579 if (pFlyFmt->GetName() != sPrevName) 580 { 581 rSh.Unchain(*pFlyFmt); 582 } 583 else 584 sPrevName.Erase(); 585 } 586 587 if(sPrevName.Len()) 588 { 589 //needs cast - no non-const method available 590 SwFrmFmt* pPrevFmt = (SwFrmFmt*) 591 lcl_GetFrmFmtByName(rSh, sPrevName); 592 DBG_ASSERT(pPrevFmt, "No frame found!"); 593 if(pPrevFmt) 594 { 595 rSh.Chain(*pPrevFmt, *pCurrFlyFmt); 596 } 597 } 598 rSh.SetChainMarker(); 599 } 600 if(SFX_ITEM_SET == 601 pOutSet->GetItemState(FN_PARAM_CHAIN_NEXT, sal_False, 602 &pItem)) 603 { 604 rSh.HideChainMarker(); 605 String sNextName = 606 ((const SfxStringItem*)pItem)->GetValue(); 607 const SwFmtChain &rChain = pCurrFlyFmt->GetChain(); 608 //needs cast - no non-const method available 609 SwFlyFrmFmt* pFlyFmt = 610 (SwFlyFrmFmt*)rChain.GetNext(); 611 if(pFlyFmt) 612 { 613 if (pFlyFmt->GetName() != sNextName) 614 { 615 rSh.Unchain(*((SwFlyFrmFmt*) pCurrFlyFmt)); 616 } 617 else 618 sNextName.Erase(); 619 } 620 621 if(sNextName.Len()) 622 { 623 //needs cast - no non-const method available 624 SwFrmFmt* pNextFmt = (SwFrmFmt*) 625 lcl_GetFrmFmtByName(rSh, sNextName); 626 DBG_ASSERT(pNextFmt, "No frame found!"); 627 if(pNextFmt) 628 { 629 rSh.Chain(*(SwFrmFmt*) 630 pCurrFlyFmt, *pNextFmt); 631 } 632 } 633 rSh.SetChainMarker(); 634 } 635 } 636 } 637 else 638 bUpdateMgr = sal_False; 639 delete pDlg; 640 } 641 } 642 break; 643 case FN_FRAME_MIRROR_ON_EVEN_PAGES: 644 { 645 SwFmtHoriOrient aHori(aMgr.GetHoriOrient()); 646 sal_Bool bMirror = !aHori.IsPosToggle(); 647 aHori.SetPosToggle(bMirror); 648 SfxItemSet aSet(GetPool(), RES_HORI_ORIENT, RES_HORI_ORIENT); 649 aSet.Put(aHori); 650 aMgr.SetAttrSet(aSet); 651 bCopyToFmt = sal_True; 652 rReq.SetReturnValue(SfxBoolItem(nSlot, bMirror)); 653 } 654 break; 655 // --> OD 2009-07-14 #i73249# 656 case FN_TITLE_DESCRIPTION_SHAPE: 657 { 658 bUpdateMgr = sal_False; 659 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); 660 if ( pSdrView && 661 pSdrView->GetMarkedObjectCount() == 1 ) 662 { 663 String aDescription(rSh.GetObjDescription()); 664 String aTitle(rSh.GetObjTitle()); 665 666 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 667 OSL_ENSURE(pFact, "Dialogdiet fail!"); 668 AbstractSvxObjectTitleDescDialog* pDlg = 669 pFact->CreateSvxObjectTitleDescDialog( NULL, 670 aTitle, 671 aDescription ); 672 OSL_ENSURE(pDlg, "Dialogdiet fail!"); 673 674 if ( pDlg->Execute() == RET_OK ) 675 { 676 pDlg->GetDescription(aDescription); 677 pDlg->GetTitle(aTitle); 678 679 rSh.SetObjDescription(aDescription); 680 rSh.SetObjTitle(aTitle); 681 } 682 683 delete pDlg; 684 } 685 } 686 break; 687 // <-- 688 default: 689 ASSERT( !this, "falscher Dispatcher" ); 690 return; 691 } 692 if ( bUpdateMgr ) 693 { 694 SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); 695 if ( bCopyToFmt && pFmt && pFmt->IsAutoUpdateFmt() ) 696 { 697 rSh.AutoUpdateFrame(pFmt, aMgr.GetAttrSet()); 698 } 699 else 700 { 701 aMgr.UpdateFlyFrm(); 702 } 703 } 704 705 } 706 707 /*-------------------------------------------------------------------- 708 Beschreibung: 709 --------------------------------------------------------------------*/ 710 711 712 void SwFrameShell::GetState(SfxItemSet& rSet) 713 { 714 SwWrtShell &rSh = GetShell(); 715 sal_Bool bHtmlMode = 0 != ::GetHtmlMode(rSh.GetView().GetDocShell()); 716 if (rSh.IsFrmSelected()) 717 { 718 SfxItemSet aSet( rSh.GetAttrPool(), 719 RES_LR_SPACE, RES_UL_SPACE, 720 RES_PROTECT, RES_HORI_ORIENT, 721 RES_OPAQUE, RES_OPAQUE, 722 RES_PRINT, RES_OPAQUE, 723 0 ); 724 rSh.GetFlyFrmAttr( aSet ); 725 726 sal_Bool bProtect = rSh.IsSelObjProtected(FLYPROTECT_POS); 727 sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; 728 729 bProtect |= bParentCntProt; 730 731 const sal_uInt16 eFrmType = rSh.GetFrmType(0,sal_True); 732 SwFlyFrmAttrMgr aMgr( sal_False, &rSh, FRMMGR_TYPE_NONE ); 733 734 SfxWhichIter aIter( rSet ); 735 sal_uInt16 nWhich = aIter.FirstWhich(); 736 while ( nWhich ) 737 { 738 switch ( nWhich ) 739 { 740 case RES_FRM_SIZE: 741 { 742 SwFmtFrmSize aSz(aMgr.GetFrmSize()); 743 rSet.Put(aSz); 744 } 745 break; 746 case RES_VERT_ORIENT: 747 case RES_HORI_ORIENT: 748 case SID_ATTR_ULSPACE: 749 case SID_ATTR_LRSPACE: 750 case RES_LR_SPACE: 751 case RES_UL_SPACE: 752 case RES_PROTECT: 753 case RES_OPAQUE: 754 case RES_PRINT: 755 case RES_SURROUND: 756 { 757 rSet.Put(aSet.Get(GetPool().GetWhich(nWhich), sal_True )); 758 } 759 break; 760 case SID_OBJECT_ALIGN_LEFT : 761 case SID_OBJECT_ALIGN_CENTER : 762 case SID_OBJECT_ALIGN_RIGHT : 763 case FN_FRAME_ALIGN_HORZ_CENTER: 764 case FN_FRAME_ALIGN_HORZ_RIGHT: 765 case FN_FRAME_ALIGN_HORZ_LEFT: 766 if ( (eFrmType & FRMTYPE_FLY_INCNT) || 767 bProtect || 768 ((nWhich == FN_FRAME_ALIGN_HORZ_CENTER || nWhich == SID_OBJECT_ALIGN_CENTER)&& bHtmlMode) ) 769 rSet.DisableItem( nWhich ); 770 break; 771 case FN_FRAME_ALIGN_VERT_ROW_TOP: 772 case FN_FRAME_ALIGN_VERT_ROW_CENTER: 773 case FN_FRAME_ALIGN_VERT_ROW_BOTTOM: 774 case FN_FRAME_ALIGN_VERT_CHAR_TOP: 775 case FN_FRAME_ALIGN_VERT_CHAR_CENTER: 776 case FN_FRAME_ALIGN_VERT_CHAR_BOTTOM: 777 if ( !(eFrmType & FRMTYPE_FLY_INCNT) || bProtect 778 || (bHtmlMode && FN_FRAME_ALIGN_VERT_CHAR_BOTTOM == nWhich) ) 779 rSet.DisableItem( nWhich ); 780 break; 781 782 case SID_OBJECT_ALIGN_UP : 783 case SID_OBJECT_ALIGN_MIDDLE : 784 case SID_OBJECT_ALIGN_DOWN : 785 786 case FN_FRAME_ALIGN_VERT_TOP: 787 case FN_FRAME_ALIGN_VERT_CENTER: 788 case FN_FRAME_ALIGN_VERT_BOTTOM: 789 if ( bProtect || (bHtmlMode && eFrmType & FRMTYPE_FLY_ATCNT) ) 790 rSet.DisableItem( nWhich ); 791 else 792 { 793 sal_uInt16 nId = 0; 794 if (eFrmType & FRMTYPE_FLY_INCNT) 795 { 796 switch (nWhich) 797 { 798 case SID_OBJECT_ALIGN_UP : 799 case FN_FRAME_ALIGN_VERT_TOP: 800 nId = STR_TOP_BASE; break; 801 case SID_OBJECT_ALIGN_MIDDLE : 802 case FN_FRAME_ALIGN_VERT_CENTER: 803 nId = STR_CENTER_BASE; break; 804 case SID_OBJECT_ALIGN_DOWN : 805 case FN_FRAME_ALIGN_VERT_BOTTOM: 806 if(!bHtmlMode) 807 nId = STR_BOTTOM_BASE; 808 else 809 rSet.DisableItem( nWhich ); 810 break; 811 } 812 } 813 else 814 { 815 if (nWhich != FN_FRAME_ALIGN_VERT_TOP && 816 nWhich != SID_OBJECT_ALIGN_UP ) 817 { 818 if (aMgr.GetAnchor() == FLY_AT_FLY) 819 { 820 const SwFrmFmt* pFmt = rSh.IsFlyInFly(); 821 if (pFmt) 822 { 823 const SwFmtFrmSize& rFrmSz = pFmt->GetFrmSize(); 824 if (rFrmSz.GetHeightSizeType() != ATT_FIX_SIZE) 825 { 826 rSet.DisableItem( nWhich ); 827 break; 828 } 829 } 830 } 831 } 832 switch (nWhich) 833 { 834 case SID_OBJECT_ALIGN_UP : 835 case FN_FRAME_ALIGN_VERT_TOP: 836 nId = STR_TOP; break; 837 case SID_OBJECT_ALIGN_MIDDLE: 838 case FN_FRAME_ALIGN_VERT_CENTER: 839 nId = STR_CENTER_VERT; break; 840 case SID_OBJECT_ALIGN_DOWN: 841 case FN_FRAME_ALIGN_VERT_BOTTOM: 842 nId = STR_BOTTOM; break; 843 } 844 } 845 if ( nId ) 846 rSet.Put( SfxStringItem( nWhich, SW_RES(nId) )); 847 } 848 break; 849 case SID_HYPERLINK_GETLINK: 850 { 851 String sURL; 852 SvxHyperlinkItem aHLinkItem; 853 const SfxPoolItem* pItem; 854 855 SfxItemSet aURLSet(GetPool(), RES_URL, RES_URL); 856 rSh.GetFlyFrmAttr( aURLSet ); 857 858 if(SFX_ITEM_SET == aURLSet.GetItemState(RES_URL, sal_True, &pItem)) 859 { 860 const SwFmtURL* pFmtURL = (const SwFmtURL*)pItem; 861 aHLinkItem.SetURL(pFmtURL->GetURL()); 862 aHLinkItem.SetTargetFrame(pFmtURL->GetTargetFrameName()); 863 aHLinkItem.SetName(rSh.GetFlyName()); 864 } 865 866 aHLinkItem.SetInsertMode((SvxLinkInsertMode)(aHLinkItem.GetInsertMode() | 867 (bHtmlMode ? HLINK_HTMLMODE : 0))); 868 869 rSet.Put(aHLinkItem); 870 } 871 break; 872 873 case FN_FRAME_CHAIN: 874 { 875 const int nSel = rSh.GetSelectionType(); 876 if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE) 877 rSet.DisableItem( FN_FRAME_CHAIN ); 878 else 879 { 880 const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt(); 881 if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || 882 !pFmt || pFmt->GetChain().GetNext() ) 883 { 884 rSet.DisableItem( FN_FRAME_CHAIN ); 885 } 886 else 887 { 888 sal_Bool bChainMode = rSh.GetView().GetEditWin().IsChainMode(); 889 rSet.Put( SfxBoolItem( FN_FRAME_CHAIN, bChainMode ) ); 890 } 891 } 892 } 893 break; 894 case FN_FRAME_UNCHAIN: 895 { 896 const int nSel = rSh.GetSelectionType(); 897 if (nSel & nsSelectionType::SEL_GRF || nSel & nsSelectionType::SEL_OLE) 898 rSet.DisableItem( FN_FRAME_UNCHAIN ); 899 else 900 { 901 const SwFrmFmt *pFmt = rSh.GetFlyFrmFmt(); 902 if ( bParentCntProt || rSh.GetView().GetEditWin().GetApplyTemplate() || 903 !pFmt || !pFmt->GetChain().GetNext() ) 904 { 905 rSet.DisableItem( FN_FRAME_UNCHAIN ); 906 } 907 } 908 } 909 break; 910 case SID_FRAME_TO_TOP: 911 case SID_FRAME_TO_BOTTOM: 912 case FN_FRAME_UP: 913 case FN_FRAME_DOWN: 914 if ( bParentCntProt ) 915 rSet.DisableItem( nWhich ); 916 break; 917 918 case SID_ATTR_TRANSFORM: 919 { 920 rSet.DisableItem( nWhich ); 921 } 922 break; 923 924 case SID_ATTR_TRANSFORM_PROTECT_SIZE: 925 { 926 const sal_uInt8 eProtection = rSh.IsSelObjProtected( FLYPROTECT_SIZE ); 927 if ( ( eProtection & FLYPROTECT_CONTENT ) || 928 ( eProtection & FLYPROTECT_SIZE ) ) 929 { 930 rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, sal_True ) ); 931 } 932 else 933 { 934 rSet.Put( SfxBoolItem( SID_ATTR_TRANSFORM_PROTECT_SIZE, sal_False ) ); 935 } 936 } 937 break; 938 939 case SID_ATTR_TRANSFORM_WIDTH: 940 { 941 rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_WIDTH, aMgr.GetSize().getWidth() ) ); 942 } 943 break; 944 945 case SID_ATTR_TRANSFORM_HEIGHT: 946 { 947 rSet.Put( SfxUInt32Item( SID_ATTR_TRANSFORM_HEIGHT, aMgr.GetSize().getHeight() ) ); 948 } 949 break; 950 951 case FN_FORMAT_FRAME_DLG: 952 { 953 const int nSel = rSh.GetSelectionType(); 954 if ( bParentCntProt || nSel & nsSelectionType::SEL_GRF) 955 rSet.DisableItem( nWhich ); 956 } 957 break; 958 959 case FN_TITLE_DESCRIPTION_SHAPE: 960 { 961 SwWrtShell &rWrtSh = GetShell(); 962 SdrView* pSdrView = rWrtSh.GetDrawViewWithValidMarkList(); 963 if ( !pSdrView || 964 pSdrView->GetMarkedObjectCount() != 1 ) 965 { 966 rSet.DisableItem( nWhich ); 967 } 968 969 } 970 break; 971 972 default: 973 /* do nothing */; 974 break; 975 } 976 nWhich = aIter.NextWhich(); 977 } 978 } 979 } 980 981 /*-------------------------------------------------------------------- 982 Beschreibung: Ctor fuer FrameShell 983 --------------------------------------------------------------------*/ 984 985 986 SwFrameShell::SwFrameShell(SwView &_rView) : 987 SwBaseShell( _rView ) 988 { 989 SetName(String::CreateFromAscii("Frame")); 990 SetHelpId(SW_FRAMESHELL); 991 992 /* #96392# Use this to announce it is the frame shell who creates the 993 selection. */ 994 SwTransferable::CreateSelection( _rView.GetWrtShell(), (ViewShell *) this ); 995 996 SfxShell::SetContextName(sfx2::sidebar::EnumContext::GetContextName(sfx2::sidebar::EnumContext::Context_Frame)); 997 } 998 999 SwFrameShell::~SwFrameShell() 1000 { 1001 /* #96392# Only clear the selection if it was this frame shell who created 1002 it. */ 1003 SwTransferable::ClearSelection( GetShell(), (ViewShell *) this ); 1004 } 1005 1006 /*-------------------------------------------------------------------- 1007 Beschreibung: 1008 --------------------------------------------------------------------*/ 1009 1010 1011 1012 void SwFrameShell::ExecFrameStyle(SfxRequest& rReq) 1013 { 1014 SwWrtShell &rSh = GetShell(); 1015 sal_Bool bDefault = sal_False; 1016 if (!rSh.IsFrmSelected()) 1017 return; 1018 1019 // Erst Default-BoxItem aus Pool holen. Wenn ungleich normalem Boxitem, 1020 // dann ist es bereits geaendert worden (neues ist kein Default). 1021 const SvxBoxItem* pPoolBoxItem = (const SvxBoxItem*)::GetDfltAttr(RES_BOX); 1022 1023 const SfxItemSet *pArgs = rReq.GetArgs(); 1024 SfxItemSet aFrameSet(rSh.GetAttrPool(), RES_BOX, RES_BOX); 1025 1026 rSh.GetFlyFrmAttr( aFrameSet ); 1027 const SvxBoxItem& rBoxItem = (const SvxBoxItem&)aFrameSet.Get(RES_BOX); 1028 1029 if (pPoolBoxItem == &rBoxItem) 1030 bDefault = sal_True; 1031 1032 SvxBoxItem aBoxItem(rBoxItem); 1033 1034 SvxBorderLine aBorderLine; 1035 const SfxPoolItem *pItem = 0; 1036 1037 if(pArgs) //irgendein Controller kann auch mal nichts liefern #48169# 1038 { 1039 switch (rReq.GetSlot()) 1040 { 1041 case SID_ATTR_BORDER: 1042 { 1043 if (pArgs->GetItemState(RES_BOX, sal_True, &pItem) == SFX_ITEM_SET) 1044 { 1045 SvxBoxItem aNewBox(*((SvxBoxItem *)pItem)); 1046 const SvxBorderLine* pBorderLine; 1047 1048 if ((pBorderLine = aBoxItem.GetTop()) != NULL) 1049 lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); 1050 if ((pBorderLine = aBoxItem.GetBottom()) != NULL) 1051 lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); 1052 if ((pBorderLine = aBoxItem.GetLeft()) != NULL) 1053 lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); 1054 if ((pBorderLine = aBoxItem.GetRight()) != NULL) 1055 lcl_FrmGetMaxLineWidth(pBorderLine, aBorderLine); 1056 1057 if(aBorderLine.GetOutWidth() == 0) 1058 { 1059 aBorderLine.SetInWidth(0); 1060 aBorderLine.SetOutWidth(DEF_LINE_WIDTH_0); 1061 aBorderLine.SetDistance(0); 1062 } 1063 //Distance nur setzen, wenn der Request vom Controller kommt 1064 1065 if(!StarBASIC::IsRunning()) 1066 { 1067 aNewBox.SetDistance( rBoxItem.GetDistance() ); 1068 } 1069 1070 aBoxItem = aNewBox; 1071 SvxBorderLine aDestBorderLine; 1072 1073 if ((pBorderLine = aBoxItem.GetTop()) != NULL) 1074 aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); 1075 if ((pBorderLine = aBoxItem.GetBottom()) != NULL) 1076 aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); 1077 if ((pBorderLine = aBoxItem.GetLeft()) != NULL) 1078 aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); 1079 if ((pBorderLine = aBoxItem.GetRight()) != NULL) 1080 aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); 1081 } 1082 } 1083 break; 1084 1085 case SID_FRAME_LINESTYLE: 1086 { 1087 if (pArgs->GetItemState(SID_FRAME_LINESTYLE, sal_False, &pItem) == SFX_ITEM_SET) 1088 { 1089 const SvxLineItem* pLineItem = 1090 (const SvxLineItem*)pItem; 1091 1092 if ( pLineItem->GetLine() ) 1093 { 1094 aBorderLine = *(pLineItem->GetLine()); 1095 1096 if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() && 1097 !aBoxItem.GetLeft() && !aBoxItem.GetRight()) 1098 { 1099 aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); 1100 aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); 1101 aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); 1102 aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); 1103 } 1104 else 1105 { 1106 if( aBoxItem.GetTop() ) 1107 { 1108 aBorderLine.SetColor( aBoxItem.GetTop()->GetColor() ); 1109 aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); 1110 } 1111 if( aBoxItem.GetBottom() ) 1112 { 1113 aBorderLine.SetColor( aBoxItem.GetBottom()->GetColor()); 1114 aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); 1115 } 1116 if( aBoxItem.GetLeft() ) 1117 { 1118 aBorderLine.SetColor( aBoxItem.GetLeft()->GetColor()); 1119 aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); 1120 } 1121 if( aBoxItem.GetRight() ) 1122 { 1123 aBorderLine.SetColor(aBoxItem.GetRight()->GetColor()); 1124 aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); 1125 } 1126 } 1127 } 1128 else 1129 { 1130 aBoxItem.SetLine(0, BOX_LINE_TOP); 1131 aBoxItem.SetLine(0, BOX_LINE_BOTTOM); 1132 aBoxItem.SetLine(0, BOX_LINE_LEFT); 1133 aBoxItem.SetLine(0, BOX_LINE_RIGHT); 1134 } 1135 } 1136 } 1137 break; 1138 1139 case SID_FRAME_LINECOLOR: 1140 { 1141 if (pArgs->GetItemState(SID_FRAME_LINECOLOR, sal_False, &pItem) == SFX_ITEM_SET) 1142 { 1143 const Color& rNewColor = ((const SvxColorItem*)pItem)->GetValue(); 1144 1145 if (!aBoxItem.GetTop() && !aBoxItem.GetBottom() && 1146 !aBoxItem.GetLeft() && !aBoxItem.GetRight()) 1147 { 1148 aBorderLine.SetColor( rNewColor ); 1149 aBoxItem.SetLine(&aBorderLine, BOX_LINE_TOP); 1150 aBoxItem.SetLine(&aBorderLine, BOX_LINE_BOTTOM); 1151 aBoxItem.SetLine(&aBorderLine, BOX_LINE_LEFT); 1152 aBoxItem.SetLine(&aBorderLine, BOX_LINE_RIGHT); 1153 } 1154 else 1155 { 1156 if ( aBoxItem.GetTop() ) 1157 ((SvxBorderLine*)aBoxItem.GetTop())->SetColor( rNewColor ); 1158 if ( aBoxItem.GetBottom() ) 1159 ((SvxBorderLine*)aBoxItem.GetBottom())->SetColor( rNewColor ); 1160 if ( aBoxItem.GetLeft() ) 1161 ((SvxBorderLine*)aBoxItem.GetLeft())->SetColor( rNewColor ); 1162 if ( aBoxItem.GetRight() ) 1163 ((SvxBorderLine*)aBoxItem.GetRight())->SetColor( rNewColor ); 1164 } 1165 } 1166 } 1167 break; 1168 } 1169 } 1170 if (bDefault && (aBoxItem.GetTop() || aBoxItem.GetBottom() || 1171 aBoxItem.GetLeft() || aBoxItem.GetRight())) 1172 { 1173 aBoxItem.SetDistance(MIN_BORDER_DIST); 1174 } 1175 aFrameSet.Put( aBoxItem ); 1176 // Vorlagen-AutoUpdate 1177 SwFrmFmt* pFmt = rSh.GetCurFrmFmt(); 1178 if(pFmt && pFmt->IsAutoUpdateFmt()) 1179 { 1180 rSh.AutoUpdateFrame(pFmt, aFrameSet); 1181 } 1182 else 1183 rSh.SetFlyFrmAttr( aFrameSet ); 1184 1185 } 1186 1187 1188 1189 void lcl_FrmGetMaxLineWidth(const SvxBorderLine* pBorderLine, SvxBorderLine& rBorderLine) 1190 { 1191 if(pBorderLine->GetInWidth() > rBorderLine.GetInWidth()) 1192 rBorderLine.SetInWidth(pBorderLine->GetInWidth()); 1193 1194 if(pBorderLine->GetOutWidth() > rBorderLine.GetOutWidth()) 1195 rBorderLine.SetOutWidth(pBorderLine->GetOutWidth()); 1196 1197 if(pBorderLine->GetDistance() > rBorderLine.GetDistance()) 1198 rBorderLine.SetDistance(pBorderLine->GetDistance()); 1199 1200 rBorderLine.SetColor(pBorderLine->GetColor()); 1201 } 1202 1203 1204 1205 void SwFrameShell::GetLineStyleState(SfxItemSet &rSet) 1206 { 1207 SwWrtShell &rSh = GetShell(); 1208 sal_Bool bParentCntProt = rSh.IsSelObjProtected( FLYPROTECT_CONTENT|FLYPROTECT_PARENT ) != 0; 1209 1210 if (bParentCntProt) 1211 { 1212 if (rSh.IsFrmSelected()) 1213 rSet.DisableItem( SID_FRAME_LINECOLOR ); 1214 1215 rSet.DisableItem( SID_ATTR_BORDER ); 1216 rSet.DisableItem( SID_FRAME_LINESTYLE ); 1217 } 1218 else 1219 { 1220 if (rSh.IsFrmSelected()) 1221 { 1222 SfxItemSet aFrameSet( rSh.GetAttrPool(), RES_BOX, RES_BOX ); 1223 1224 rSh.GetFlyFrmAttr(aFrameSet); 1225 1226 const SvxBorderLine* pLine = ((const SvxBoxItem&)aFrameSet.Get(RES_BOX)).GetTop(); 1227 rSet.Put(SvxColorItem(pLine ? pLine->GetColor() : Color(), SID_FRAME_LINECOLOR)); 1228 } 1229 } 1230 } 1231 1232 void SwFrameShell::StateInsert(SfxItemSet &rSet) 1233 { 1234 const int nSel = GetShell().GetSelectionType(); 1235 if ( (nSel & nsSelectionType::SEL_GRF) 1236 || (nSel & nsSelectionType::SEL_OLE) ) 1237 { 1238 rSet.DisableItem(FN_INSERT_FRAME); 1239 } 1240 else if ( GetShell().CrsrInsideInputFld() ) 1241 { 1242 rSet.DisableItem(FN_INSERT_FRAME); 1243 } 1244 } 1245 1246 //UUUU 1247 void SwFrameShell::GetDrawAttrStateTextFrame(SfxItemSet &rSet) 1248 { 1249 SwWrtShell &rSh = GetShell(); 1250 1251 if(rSh.IsFrmSelected()) 1252 { 1253 rSh.GetFlyFrmAttr(rSet); 1254 } 1255 else 1256 { 1257 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); 1258 1259 if(pSdrView) 1260 { 1261 rSet.Put(pSdrView->GetDefaultAttr()); 1262 } 1263 } 1264 } 1265 1266 //UUUU 1267 void SwFrameShell::ExecDrawAttrArgsTextFrame(SfxRequest& rReq) 1268 { 1269 const SfxItemSet* pArgs = rReq.GetArgs(); 1270 SwWrtShell& rSh = GetShell(); 1271 1272 if(pArgs) 1273 { 1274 if(rSh.IsFrmSelected()) 1275 { 1276 rSh.SetFlyFrmAttr(const_cast< SfxItemSet& >(*pArgs)); 1277 } 1278 else 1279 { 1280 SdrView* pSdrView = rSh.GetDrawViewWithValidMarkList(); 1281 1282 if(pSdrView) 1283 { 1284 pSdrView->SetDefaultAttr(*pArgs, sal_False); 1285 } 1286 } 1287 } 1288 else 1289 { 1290 SfxDispatcher* pDis = rSh.GetView().GetViewFrame()->GetDispatcher(); 1291 1292 switch(rReq.GetSlot()) 1293 { 1294 case SID_ATTR_FILL_STYLE: 1295 case SID_ATTR_FILL_COLOR: 1296 case SID_ATTR_FILL_GRADIENT: 1297 case SID_ATTR_FILL_HATCH: 1298 case SID_ATTR_FILL_BITMAP: 1299 case SID_ATTR_FILL_TRANSPARENCE: 1300 case SID_ATTR_FILL_FLOATTRANSPARENCE: 1301 { 1302 pDis->Execute(SID_ATTRIBUTES_AREA, sal_False); 1303 break; 1304 } 1305 } 1306 } 1307 } 1308 1309 //UUUU 1310 void SwFrameShell::ExecDrawDlgTextFrame(SfxRequest& rReq) 1311 { 1312 switch(rReq.GetSlot()) 1313 { 1314 case SID_ATTRIBUTES_AREA: 1315 { 1316 SwWrtShell& rSh = GetShell(); 1317 1318 if(rSh.IsFrmSelected()) 1319 { 1320 SdrView* pView = rSh.GetDrawView(); 1321 SdrModel* pDoc = pView->GetModel(); 1322 SfxItemSet aNewAttr(pDoc->GetItemPool()); 1323 1324 // get attributes from FlyFrame 1325 rSh.GetFlyFrmAttr(aNewAttr); 1326 1327 SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create(); 1328 DBG_ASSERT(pFact, "Dialogdiet Factory fail!"); 1329 AbstractSvxAreaTabDialog * pDlg = pFact->CreateSvxAreaTabDialog( 1330 NULL, 1331 &aNewAttr, 1332 pDoc, 1333 false); 1334 DBG_ASSERT(pDlg, "Dialogdiet fail!"); 1335 1336 if(RET_OK == pDlg->Execute()) 1337 { 1338 // set attributes at FlyFrame 1339 rSh.SetFlyFrmAttr(const_cast< SfxItemSet& >(*pDlg->GetOutputItemSet())); 1340 1341 static sal_uInt16 __READONLY_DATA aInval[] = 1342 { 1343 SID_ATTR_FILL_STYLE, 1344 SID_ATTR_FILL_COLOR, 1345 SID_ATTR_FILL_TRANSPARENCE, 1346 SID_ATTR_FILL_FLOATTRANSPARENCE, 1347 0 1348 }; 1349 1350 SfxBindings &rBnd = GetView().GetViewFrame()->GetBindings(); 1351 1352 rBnd.Invalidate(aInval); 1353 rBnd.Update(SID_ATTR_FILL_STYLE); 1354 rBnd.Update(SID_ATTR_FILL_COLOR); 1355 rBnd.Update(SID_ATTR_FILL_TRANSPARENCE); 1356 rBnd.Update(SID_ATTR_FILL_FLOATTRANSPARENCE); 1357 } 1358 1359 delete pDlg; 1360 } 1361 1362 break; 1363 } 1364 } 1365 } 1366 1367 //UUUU 1368 void SwFrameShell::DisableStateTextFrame(SfxItemSet &rSet) 1369 { 1370 SfxWhichIter aIter(rSet); 1371 sal_uInt16 nWhich(aIter.FirstWhich()); 1372 1373 while(nWhich) 1374 { 1375 switch(nWhich) 1376 { 1377 case SID_ATTRIBUTES_AREA: 1378 { 1379 SwWrtShell& rSh = GetShell(); 1380 1381 if(!rSh.IsFrmSelected()) 1382 { 1383 rSet.DisableItem(nWhich); 1384 } 1385 1386 break; 1387 } 1388 default: 1389 { 1390 rSet.DisableItem(nWhich); 1391 break; 1392 } 1393 } 1394 1395 nWhich = aIter.NextWhich(); 1396 } 1397 } 1398 1399 // eof 1400