LCOV - code coverage report
Current view: top level - sw/source/core/uibase/shells - frmsh.cxx (source / functions) Hit Total Coverage
Test: commit 0e63ca4fde4e446f346e35849c756a30ca294aab Lines: 5 603 0.8 %
Date: 2014-04-11 Functions: 5 20 25.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10