LCOV - code coverage report
Current view: top level - sw/source/ui/dialog - regionsw.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 107 0.0 %
Date: 2012-08-25 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 244 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*************************************************************************
       3                 :            :  *
       4                 :            :  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       5                 :            :  *
       6                 :            :  * Copyright 2000, 2010 Oracle and/or its affiliates.
       7                 :            :  *
       8                 :            :  * OpenOffice.org - a multi-platform office productivity suite
       9                 :            :  *
      10                 :            :  * This file is part of OpenOffice.org.
      11                 :            :  *
      12                 :            :  * OpenOffice.org is free software: you can redistribute it and/or modify
      13                 :            :  * it under the terms of the GNU Lesser General Public License version 3
      14                 :            :  * only, as published by the Free Software Foundation.
      15                 :            :  *
      16                 :            :  * OpenOffice.org is distributed in the hope that it will be useful,
      17                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      18                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      19                 :            :  * GNU Lesser General Public License version 3 for more details
      20                 :            :  * (a copy is included in the LICENSE file that accompanied this code).
      21                 :            :  *
      22                 :            :  * You should have received a copy of the GNU Lesser General Public License
      23                 :            :  * version 3 along with OpenOffice.org.  If not, see
      24                 :            :  * <http://www.openoffice.org/license.html>
      25                 :            :  * for a copy of the LGPLv3 License.
      26                 :            :  *
      27                 :            :  ************************************************************************/
      28                 :            : 
      29                 :            : #include <hintids.hxx>
      30                 :            : #include <uitool.hxx>
      31                 :            : #include <svl/urihelper.hxx>
      32                 :            : #include <svl/PasswordHelper.hxx>
      33                 :            : #include <vcl/msgbox.hxx>
      34                 :            : #include <svl/stritem.hxx>
      35                 :            : #include <svl/eitem.hxx>
      36                 :            : #include <sot/formats.hxx>
      37                 :            : #include <sfx2/passwd.hxx>
      38                 :            : #include <sfx2/docfilt.hxx>
      39                 :            : #include <sfx2/request.hxx>
      40                 :            : #include <sfx2/docfile.hxx>
      41                 :            : #include <sfx2/linkmgr.hxx>
      42                 :            : #include <editeng/sizeitem.hxx>
      43                 :            : #include <svtools/htmlcfg.hxx>
      44                 :            : #include <section.hxx>
      45                 :            : #include <docary.hxx>
      46                 :            : #include <regionsw.hxx>
      47                 :            : #include <basesh.hxx>
      48                 :            : #include <wdocsh.hxx>
      49                 :            : #include <view.hxx>
      50                 :            : #include <swmodule.hxx>
      51                 :            : #include <wrtsh.hxx>
      52                 :            : #include <swundo.hxx>                   // for Undo-Ids
      53                 :            : #include <column.hxx>
      54                 :            : #include <fmtfsize.hxx>
      55                 :            : #include <shellio.hxx>
      56                 :            : #include <helpid.h>
      57                 :            : #include <cmdid.h>
      58                 :            : #include <regionsw.hrc>
      59                 :            : #include <comcore.hrc>
      60                 :            : #include <globals.hrc>
      61                 :            : #include <sfx2/bindings.hxx>
      62                 :            : #include <svx/htmlmode.hxx>
      63                 :            : #include <svx/dlgutil.hxx>
      64                 :            : #include "swabstdlg.hxx"
      65                 :            : #include <boost/scoped_ptr.hpp>
      66                 :            : 
      67                 :          0 : void SwBaseShell::InsertRegionDialog(SfxRequest& rReq)
      68                 :            : {
      69         [ #  # ]:          0 :     SwWrtShell& rSh = GetShell();
      70                 :          0 :     const SfxItemSet *pSet = rReq.GetArgs();
      71                 :            : 
      72                 :          0 :     SfxItemSet aSet(GetPool(),
      73                 :            :             RES_COL, RES_COL,
      74                 :            :             RES_LR_SPACE, RES_LR_SPACE,
      75                 :            :             RES_COLUMNBALANCE, RES_FRAMEDIR,
      76                 :            :             RES_BACKGROUND, RES_BACKGROUND,
      77                 :            :             RES_FRM_SIZE, RES_FRM_SIZE,
      78                 :            :             RES_FTN_AT_TXTEND, RES_END_AT_TXTEND,
      79                 :            :             SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
      80         [ #  # ]:          0 :             0);
      81                 :            : 
      82 [ #  # ][ #  # ]:          0 :     if (!pSet || pSet->Count()==0)
                 [ #  # ]
      83                 :            :     {
      84                 :          0 :         SwRect aRect;
      85         [ #  # ]:          0 :         rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
      86                 :            : 
      87                 :          0 :         long nWidth = aRect.Width();
      88 [ #  # ][ #  # ]:          0 :         aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
                 [ #  # ]
      89                 :            : 
      90                 :            :         // height=width for more consistent preview (analog to edit region)
      91 [ #  # ][ #  # ]:          0 :         aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
                 [ #  # ]
      92         [ #  # ]:          0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
      93                 :            :         OSL_ENSURE(pFact, "Dialogdiet fail!");
      94                 :            :         AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION,
      95 [ #  # ][ #  # ]:          0 :                                                         &GetView().GetViewFrame()->GetWindow(), aSet , rSh);
      96                 :            :         OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
      97         [ #  # ]:          0 :         aTabDlg->Execute();
      98         [ #  # ]:          0 :         rReq.Ignore();
      99 [ #  # ][ #  # ]:          0 :         delete aTabDlg;
     100                 :            :     }
     101                 :            :     else
     102                 :            :     {
     103                 :          0 :         const SfxPoolItem *pItem = 0;
     104         [ #  # ]:          0 :         String aTmpStr;
     105         [ #  # ]:          0 :         if ( SFX_ITEM_SET ==
     106         [ #  # ]:          0 :                 pSet->GetItemState(FN_PARAM_REGION_NAME, sal_True, &pItem) )
     107                 :            :             aTmpStr = rSh.GetUniqueSectionName(
     108 [ #  # ][ #  # ]:          0 :                     &((const SfxStringItem *)pItem)->GetValue() );
                 [ #  # ]
     109                 :            :         else
     110 [ #  # ][ #  # ]:          0 :             aTmpStr = rSh.GetUniqueSectionName();
                 [ #  # ]
     111                 :            : 
     112         [ #  # ]:          0 :         SwSectionData aSection(CONTENT_SECTION, aTmpStr);
     113 [ #  # ][ #  # ]:          0 :         rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr));
                 [ #  # ]
     114                 :            : 
     115         [ #  # ]:          0 :         aSet.Put( *pSet );
     116 [ #  # ][ #  # ]:          0 :         if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem)||
         [ #  # ][ #  # ]
     117         [ #  # ]:          0 :             SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, sal_False, &pItem))
     118                 :            :         {
     119         [ #  # ]:          0 :             SwFmtCol aCol;
     120                 :          0 :             SwRect aRect;
     121         [ #  # ]:          0 :             rSh.CalcBoundRect(aRect, FLY_AS_CHAR);
     122                 :          0 :             long nWidth = aRect.Width();
     123                 :            : 
     124                 :          0 :             sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue();
     125         [ #  # ]:          0 :             if(nCol)
     126                 :            :             {
     127         [ #  # ]:          0 :                 aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) );
     128         [ #  # ]:          0 :                 aSet.Put(aCol);
     129         [ #  # ]:          0 :             }
     130                 :            :         }
     131 [ #  # ][ #  # ]:          0 :         else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, sal_False, &pItem))
     132                 :            :         {
     133         [ #  # ]:          0 :             aSet.Put(*pItem);
     134                 :            :         }
     135                 :            : 
     136                 :            :         const sal_Bool bHidden = SFX_ITEM_SET ==
     137         [ #  # ]:          0 :             pSet->GetItemState(FN_PARAM_REGION_HIDDEN, sal_True, &pItem)?
     138         [ #  # ]:          0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     139                 :            :         const sal_Bool bProtect = SFX_ITEM_SET ==
     140         [ #  # ]:          0 :             pSet->GetItemState(FN_PARAM_REGION_PROTECT, sal_True, &pItem)?
     141         [ #  # ]:          0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     142                 :            :         // #114856# edit in readonly sections
     143                 :            :         const sal_Bool bEditInReadonly = SFX_ITEM_SET ==
     144         [ #  # ]:          0 :             pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, sal_True, &pItem)?
     145         [ #  # ]:          0 :             (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False;
     146                 :            : 
     147                 :          0 :         aSection.SetProtectFlag(bProtect);
     148                 :          0 :         aSection.SetHidden(bHidden);
     149                 :            :         // #114856# edit in readonly sections
     150                 :          0 :         aSection.SetEditInReadonlyFlag(bEditInReadonly);
     151                 :            : 
     152         [ #  # ]:          0 :         if(SFX_ITEM_SET ==
     153         [ #  # ]:          0 :                 pSet->GetItemState(FN_PARAM_REGION_CONDITION, sal_True, &pItem))
     154         [ #  # ]:          0 :             aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue());
     155                 :            : 
     156 [ #  # ][ #  # ]:          0 :         String aFile, aSub;
     157         [ #  # ]:          0 :         if(SFX_ITEM_SET ==
     158         [ #  # ]:          0 :                 pSet->GetItemState(FN_PARAM_1, sal_True, &pItem))
     159         [ #  # ]:          0 :             aFile = ((const SfxStringItem *)pItem)->GetValue();
     160                 :            : 
     161         [ #  # ]:          0 :         if(SFX_ITEM_SET ==
     162         [ #  # ]:          0 :                 pSet->GetItemState(FN_PARAM_3, sal_True, &pItem))
     163         [ #  # ]:          0 :             aSub = ((const SfxStringItem *)pItem)->GetValue();
     164                 :            : 
     165                 :            : 
     166 [ #  # ][ #  # ]:          0 :         if(aFile.Len() || aSub.Len())
                 [ #  # ]
     167                 :            :         {
     168         [ #  # ]:          0 :             String sLinkFileName = rtl::OUString(sfx2::cTokenSeperator);
     169         [ #  # ]:          0 :             sLinkFileName += sfx2::cTokenSeperator;
     170         [ #  # ]:          0 :             sLinkFileName.SetToken(0, sfx2::cTokenSeperator,aFile);
     171                 :            : 
     172         [ #  # ]:          0 :             if(SFX_ITEM_SET ==
     173         [ #  # ]:          0 :                     pSet->GetItemState(FN_PARAM_2, sal_True, &pItem))
     174                 :            :                 sLinkFileName.SetToken(1, sfx2::cTokenSeperator,
     175         [ #  # ]:          0 :                     ((const SfxStringItem *)pItem)->GetValue());
     176                 :            : 
     177         [ #  # ]:          0 :             sLinkFileName += aSub;
     178                 :          0 :             aSection.SetType( FILE_LINK_SECTION );
     179 [ #  # ][ #  # ]:          0 :             aSection.SetLinkFileName(sLinkFileName);
     180                 :            :         }
     181 [ #  # ][ #  # ]:          0 :         rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0);
     182 [ #  # ][ #  # ]:          0 :         rReq.Done();
         [ #  # ][ #  # ]
                 [ #  # ]
     183         [ #  # ]:          0 :     }
     184                 :          0 : }
     185                 :            : 
     186                 :          0 : IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect )
     187                 :            : {
     188                 :          0 :     boost::scoped_ptr<SwSectionData> xSectionData(pSect);
     189         [ #  # ]:          0 :     if (xSectionData.get())
     190                 :            :     {
     191                 :          0 :         SfxItemSet aSet(pThis->GetView().GetPool(),
     192                 :            :                 RES_COL, RES_COL,
     193                 :            :                 RES_BACKGROUND, RES_BACKGROUND,
     194                 :            :                 RES_FRM_SIZE, RES_FRM_SIZE,
     195                 :            :                 SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE,
     196         [ #  # ]:          0 :                 0);
     197                 :          0 :         SwRect aRect;
     198         [ #  # ]:          0 :         pThis->CalcBoundRect(aRect, FLY_AS_CHAR);
     199                 :          0 :         long nWidth = aRect.Width();
     200 [ #  # ][ #  # ]:          0 :         aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth));
                 [ #  # ]
     201                 :            :         // height=width for more consistent preview (analog to edit region)
     202 [ #  # ][ #  # ]:          0 :         aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth)));
                 [ #  # ]
     203         [ #  # ]:          0 :         SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     204                 :            :         OSL_ENSURE(pFact, "Dialogdiet fail!");
     205                 :            :         AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION,
     206 [ #  # ][ #  # ]:          0 :                                                         &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis);
     207                 :            :         OSL_ENSURE(aTabDlg, "Dialogdiet fail!");
     208         [ #  # ]:          0 :         aTabDlg->SetSectionData(*xSectionData);
     209         [ #  # ]:          0 :         aTabDlg->Execute();
     210                 :            : 
     211 [ #  # ][ #  # ]:          0 :         delete aTabDlg;
                 [ #  # ]
     212                 :            :     }
     213         [ #  # ]:          0 :     return 0;
     214                 :            : }
     215                 :            : 
     216                 :          0 : void SwBaseShell::EditRegionDialog(SfxRequest& rReq)
     217                 :            : {
     218                 :          0 :     const SfxItemSet* pArgs = rReq.GetArgs();
     219                 :          0 :     sal_uInt16 nSlot = rReq.GetSlot();
     220                 :          0 :     const SfxPoolItem* pItem = 0;
     221         [ #  # ]:          0 :     if(pArgs)
     222         [ #  # ]:          0 :         pArgs->GetItemState(nSlot, sal_False, &pItem);
     223         [ #  # ]:          0 :     SwWrtShell& rWrtShell = GetShell();
     224                 :            : 
     225         [ #  # ]:          0 :     switch ( nSlot )
     226                 :            :     {
     227                 :            :         case FN_EDIT_REGION:
     228                 :            :         {
     229         [ #  # ]:          0 :             Window* pParentWin = &GetView().GetViewFrame()->GetWindow();
     230                 :          0 :             sal_Bool bStart = sal_True;
     231         [ #  # ]:          0 :             if(bStart)
     232                 :            :             {
     233         [ #  # ]:          0 :                 SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
     234                 :            :                 OSL_ENSURE(pFact, "Dialogdiet fail!");
     235                 :            :                 AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg( MD_EDIT_REGION,
     236         [ #  # ]:          0 :                                                         pParentWin, rWrtShell);
     237                 :            :                 OSL_ENSURE(pEditRegionDlg, "Dialogdiet fail!");
     238 [ #  # ][ #  # ]:          0 :                 if(pItem && pItem->ISA(SfxStringItem))
         [ #  # ][ #  # ]
                 [ #  # ]
     239                 :            :                 {
     240         [ #  # ]:          0 :                     pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue());
     241                 :            :                 }
     242         [ #  # ]:          0 :                 pEditRegionDlg->Execute();
     243 [ #  # ][ #  # ]:          0 :                 delete pEditRegionDlg;
     244                 :            :             }
     245                 :            :             else
     246 [ #  # ][ #  # ]:          0 :                 InfoBox(pParentWin, SW_RES(REG_WRONG_PASSWORD)).Execute();
                 [ #  # ]
     247                 :            :         }
     248                 :          0 :         break;
     249                 :            :     }
     250                 :          0 : }
     251                 :            : 
     252                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10