1*efeef26fSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*efeef26fSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*efeef26fSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*efeef26fSAndrew Rist * distributed with this work for additional information 6*efeef26fSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*efeef26fSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*efeef26fSAndrew Rist * "License"); you may not use this file except in compliance 9*efeef26fSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*efeef26fSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*efeef26fSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*efeef26fSAndrew Rist * software distributed under the License is distributed on an 15*efeef26fSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*efeef26fSAndrew Rist * KIND, either express or implied. See the License for the 17*efeef26fSAndrew Rist * specific language governing permissions and limitations 18*efeef26fSAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*efeef26fSAndrew Rist *************************************************************/ 21*efeef26fSAndrew Rist 22*efeef26fSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_sw.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <hintids.hxx> 29cdf0e10cSrcweir #include <uitool.hxx> 30cdf0e10cSrcweir #include <svl/urihelper.hxx> 31cdf0e10cSrcweir #include <svl/PasswordHelper.hxx> 32cdf0e10cSrcweir #include <vcl/msgbox.hxx> 33cdf0e10cSrcweir #include <svl/stritem.hxx> 34cdf0e10cSrcweir #include <svl/eitem.hxx> 35cdf0e10cSrcweir #include <sot/formats.hxx> 36cdf0e10cSrcweir #include <sfx2/passwd.hxx> 37cdf0e10cSrcweir #include <sfx2/docfilt.hxx> 38cdf0e10cSrcweir #include <sfx2/request.hxx> 39cdf0e10cSrcweir #include <sfx2/docfile.hxx> 40cdf0e10cSrcweir #include <sfx2/linkmgr.hxx> 41cdf0e10cSrcweir #include <editeng/sizeitem.hxx> 42cdf0e10cSrcweir #include <svtools/htmlcfg.hxx> 43cdf0e10cSrcweir #include <section.hxx> 44cdf0e10cSrcweir #include <docary.hxx> 45cdf0e10cSrcweir #include <regionsw.hxx> 46cdf0e10cSrcweir #include <basesh.hxx> 47cdf0e10cSrcweir #include <wdocsh.hxx> 48cdf0e10cSrcweir #include <view.hxx> 49cdf0e10cSrcweir #include <swmodule.hxx> 50cdf0e10cSrcweir #include <wrtsh.hxx> 51cdf0e10cSrcweir #include <swundo.hxx> // fuer Undo-Ids 52cdf0e10cSrcweir #include <column.hxx> 53cdf0e10cSrcweir #include <fmtfsize.hxx> 54cdf0e10cSrcweir #include <swunodef.hxx> 55cdf0e10cSrcweir #include <shellio.hxx> 56cdf0e10cSrcweir #include <helpid.h> 57cdf0e10cSrcweir #include <cmdid.h> 58cdf0e10cSrcweir #include <regionsw.hrc> 59cdf0e10cSrcweir #include <comcore.hrc> 60cdf0e10cSrcweir #include <globals.hrc> 61cdf0e10cSrcweir #include <sfx2/bindings.hxx> 62cdf0e10cSrcweir #include <svx/htmlmode.hxx> 63cdf0e10cSrcweir #include <svx/dlgutil.hxx> 64cdf0e10cSrcweir #include "swabstdlg.hxx" 65cdf0e10cSrcweir 66cdf0e10cSrcweir /*-------------------------------------------------------------------- 67cdf0e10cSrcweir Beschreibung: Bereiche einfuegen 68cdf0e10cSrcweir --------------------------------------------------------------------*/ 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir void SwBaseShell::InsertRegionDialog(SfxRequest& rReq) 72cdf0e10cSrcweir { 73cdf0e10cSrcweir SwWrtShell& rSh = GetShell(); 74cdf0e10cSrcweir const SfxItemSet *pSet = rReq.GetArgs(); 75cdf0e10cSrcweir 76cdf0e10cSrcweir SfxItemSet aSet(GetPool(), 77cdf0e10cSrcweir RES_COL, RES_COL, 78cdf0e10cSrcweir RES_LR_SPACE, RES_LR_SPACE, 79cdf0e10cSrcweir RES_COLUMNBALANCE, RES_FRAMEDIR, 80cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND, 81cdf0e10cSrcweir RES_FRM_SIZE, RES_FRM_SIZE, 82cdf0e10cSrcweir RES_FTN_AT_TXTEND, RES_END_AT_TXTEND, 83cdf0e10cSrcweir SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 84cdf0e10cSrcweir 0); 85cdf0e10cSrcweir 86cdf0e10cSrcweir if (!pSet || pSet->Count()==0) 87cdf0e10cSrcweir { 88cdf0e10cSrcweir SwRect aRect; 89cdf0e10cSrcweir rSh.CalcBoundRect(aRect, FLY_AS_CHAR); 90cdf0e10cSrcweir 91cdf0e10cSrcweir long nWidth = aRect.Width(); 92cdf0e10cSrcweir aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) 95cdf0e10cSrcweir aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); 96cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 97cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 98cdf0e10cSrcweir AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION, 99cdf0e10cSrcweir &GetView().GetViewFrame()->GetWindow(), aSet , rSh); 100cdf0e10cSrcweir DBG_ASSERT(aTabDlg, "Dialogdiet fail!"); 101cdf0e10cSrcweir aTabDlg->Execute(); 102cdf0e10cSrcweir rReq.Ignore(); 103cdf0e10cSrcweir delete aTabDlg; 104cdf0e10cSrcweir } 105cdf0e10cSrcweir else 106cdf0e10cSrcweir { 107cdf0e10cSrcweir const SfxPoolItem *pItem = 0; 108cdf0e10cSrcweir String aTmpStr; 109cdf0e10cSrcweir if ( SFX_ITEM_SET == 110cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_NAME, sal_True, &pItem) ) 111cdf0e10cSrcweir aTmpStr = rSh.GetUniqueSectionName( 112cdf0e10cSrcweir &((const SfxStringItem *)pItem)->GetValue() ); 113cdf0e10cSrcweir else 114cdf0e10cSrcweir aTmpStr = rSh.GetUniqueSectionName(); 115cdf0e10cSrcweir 116cdf0e10cSrcweir SwSectionData aSection(CONTENT_SECTION, aTmpStr); 117cdf0e10cSrcweir rReq.SetReturnValue(SfxStringItem(FN_INSERT_REGION, aTmpStr)); 118cdf0e10cSrcweir 119cdf0e10cSrcweir aSet.Put( *pSet ); 120cdf0e10cSrcweir if(SFX_ITEM_SET == pSet->GetItemState(SID_ATTR_COLUMNS, sal_False, &pItem)|| 121cdf0e10cSrcweir SFX_ITEM_SET == pSet->GetItemState(FN_INSERT_REGION, sal_False, &pItem)) 122cdf0e10cSrcweir { 123cdf0e10cSrcweir SwFmtCol aCol; 124cdf0e10cSrcweir SwRect aRect; 125cdf0e10cSrcweir rSh.CalcBoundRect(aRect, FLY_AS_CHAR); 126cdf0e10cSrcweir long nWidth = aRect.Width(); 127cdf0e10cSrcweir 128cdf0e10cSrcweir sal_uInt16 nCol = ((SfxUInt16Item *)pItem)->GetValue(); 129cdf0e10cSrcweir if(nCol) 130cdf0e10cSrcweir { 131cdf0e10cSrcweir aCol.Init( nCol, 0, static_cast< sal_uInt16 >(nWidth) ); 132cdf0e10cSrcweir aSet.Put(aCol); 133cdf0e10cSrcweir } 134cdf0e10cSrcweir } 135cdf0e10cSrcweir else if(SFX_ITEM_SET == pSet->GetItemState(RES_COL, sal_False, &pItem)) 136cdf0e10cSrcweir { 137cdf0e10cSrcweir aSet.Put(*pItem); 138cdf0e10cSrcweir } 139cdf0e10cSrcweir 140cdf0e10cSrcweir const sal_Bool bHidden = SFX_ITEM_SET == 141cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_HIDDEN, sal_True, &pItem)? 142cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 143cdf0e10cSrcweir const sal_Bool bProtect = SFX_ITEM_SET == 144cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_PROTECT, sal_True, &pItem)? 145cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 146cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections 147cdf0e10cSrcweir const sal_Bool bEditInReadonly = SFX_ITEM_SET == 148cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY, sal_True, &pItem)? 149cdf0e10cSrcweir (sal_Bool)((const SfxBoolItem *)pItem)->GetValue():sal_False; 150cdf0e10cSrcweir // <-- 151cdf0e10cSrcweir 152cdf0e10cSrcweir aSection.SetProtectFlag(bProtect); 153cdf0e10cSrcweir aSection.SetHidden(bHidden); 154cdf0e10cSrcweir // --> FME 2004-06-22 #114856# edit in readonly sections 155cdf0e10cSrcweir aSection.SetEditInReadonlyFlag(bEditInReadonly); 156cdf0e10cSrcweir // <-- 157cdf0e10cSrcweir 158cdf0e10cSrcweir if(SFX_ITEM_SET == 159cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_REGION_CONDITION, sal_True, &pItem)) 160cdf0e10cSrcweir aSection.SetCondition(((const SfxStringItem *)pItem)->GetValue()); 161cdf0e10cSrcweir 162cdf0e10cSrcweir String aFile, aSub; 163cdf0e10cSrcweir if(SFX_ITEM_SET == 164cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_1, sal_True, &pItem)) 165cdf0e10cSrcweir aFile = ((const SfxStringItem *)pItem)->GetValue(); 166cdf0e10cSrcweir 167cdf0e10cSrcweir if(SFX_ITEM_SET == 168cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_3, sal_True, &pItem)) 169cdf0e10cSrcweir aSub = ((const SfxStringItem *)pItem)->GetValue(); 170cdf0e10cSrcweir 171cdf0e10cSrcweir 172cdf0e10cSrcweir if(aFile.Len() || aSub.Len()) 173cdf0e10cSrcweir { 174cdf0e10cSrcweir String sLinkFileName(sfx2::cTokenSeperator); 175cdf0e10cSrcweir sLinkFileName += sfx2::cTokenSeperator; 176cdf0e10cSrcweir sLinkFileName.SetToken(0, sfx2::cTokenSeperator,aFile); 177cdf0e10cSrcweir 178cdf0e10cSrcweir if(SFX_ITEM_SET == 179cdf0e10cSrcweir pSet->GetItemState(FN_PARAM_2, sal_True, &pItem)) 180cdf0e10cSrcweir sLinkFileName.SetToken(1, sfx2::cTokenSeperator, 181cdf0e10cSrcweir ((const SfxStringItem *)pItem)->GetValue()); 182cdf0e10cSrcweir 183cdf0e10cSrcweir sLinkFileName += aSub; 184cdf0e10cSrcweir aSection.SetType( FILE_LINK_SECTION ); 185cdf0e10cSrcweir aSection.SetLinkFileName(sLinkFileName); 186cdf0e10cSrcweir } 187cdf0e10cSrcweir rSh.InsertSection(aSection, aSet.Count() ? &aSet : 0); 188cdf0e10cSrcweir rReq.Done(); 189cdf0e10cSrcweir } 190cdf0e10cSrcweir } 191cdf0e10cSrcweir 192cdf0e10cSrcweir IMPL_STATIC_LINK( SwWrtShell, InsertRegionDialog, SwSectionData*, pSect ) 193cdf0e10cSrcweir { 194cdf0e10cSrcweir ::std::auto_ptr<SwSectionData> pSectionData(pSect); 195cdf0e10cSrcweir if (pSectionData.get()) 196cdf0e10cSrcweir { 197cdf0e10cSrcweir SfxItemSet aSet(pThis->GetView().GetPool(), 198cdf0e10cSrcweir RES_COL, RES_COL, 199cdf0e10cSrcweir RES_BACKGROUND, RES_BACKGROUND, 200cdf0e10cSrcweir RES_FRM_SIZE, RES_FRM_SIZE, 201cdf0e10cSrcweir SID_ATTR_PAGE_SIZE, SID_ATTR_PAGE_SIZE, 202cdf0e10cSrcweir 0); 203cdf0e10cSrcweir SwRect aRect; 204cdf0e10cSrcweir pThis->CalcBoundRect(aRect, FLY_AS_CHAR); 205cdf0e10cSrcweir long nWidth = aRect.Width(); 206cdf0e10cSrcweir aSet.Put(SwFmtFrmSize(ATT_VAR_SIZE, nWidth)); 207cdf0e10cSrcweir // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten) 208cdf0e10cSrcweir aSet.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE, Size(nWidth, nWidth))); 209cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 210cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 211cdf0e10cSrcweir AbstractInsertSectionTabDialog* aTabDlg = pFact->CreateInsertSectionTabDialog( DLG_INSERT_SECTION, 212cdf0e10cSrcweir &pThis->GetView().GetViewFrame()->GetWindow(),aSet , *pThis); 213cdf0e10cSrcweir DBG_ASSERT(aTabDlg, "Dialogdiet fail!"); 214cdf0e10cSrcweir aTabDlg->SetSectionData(*pSectionData); 215cdf0e10cSrcweir aTabDlg->Execute(); 216cdf0e10cSrcweir 217cdf0e10cSrcweir delete aTabDlg; 218cdf0e10cSrcweir } 219cdf0e10cSrcweir return 0; 220cdf0e10cSrcweir } 221cdf0e10cSrcweir 222cdf0e10cSrcweir /*-------------------------------------------------------------------- 223cdf0e10cSrcweir Beschreibung: Bereich bearbeiten 224cdf0e10cSrcweir --------------------------------------------------------------------*/ 225cdf0e10cSrcweir 226cdf0e10cSrcweir void SwBaseShell::EditRegionDialog(SfxRequest& rReq) 227cdf0e10cSrcweir { 228cdf0e10cSrcweir const SfxItemSet* pArgs = rReq.GetArgs(); 229cdf0e10cSrcweir sal_uInt16 nSlot = rReq.GetSlot(); 230cdf0e10cSrcweir const SfxPoolItem* pItem = 0; 231cdf0e10cSrcweir if(pArgs) 232cdf0e10cSrcweir pArgs->GetItemState(nSlot, sal_False, &pItem); 233cdf0e10cSrcweir SwWrtShell& rWrtShell = GetShell(); 234cdf0e10cSrcweir 235cdf0e10cSrcweir switch ( nSlot ) 236cdf0e10cSrcweir { 237cdf0e10cSrcweir case FN_EDIT_REGION: 238cdf0e10cSrcweir { 239cdf0e10cSrcweir Window* pParentWin = &GetView().GetViewFrame()->GetWindow(); 240cdf0e10cSrcweir sal_Bool bStart = sal_True; 241cdf0e10cSrcweir if(bStart) 242cdf0e10cSrcweir { 243cdf0e10cSrcweir SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create(); 244cdf0e10cSrcweir DBG_ASSERT(pFact, "Dialogdiet fail!"); 245cdf0e10cSrcweir AbstractEditRegionDlg* pEditRegionDlg = pFact->CreateEditRegionDlg( MD_EDIT_REGION, 246cdf0e10cSrcweir pParentWin, rWrtShell); 247cdf0e10cSrcweir DBG_ASSERT(pEditRegionDlg, "Dialogdiet fail!"); 248cdf0e10cSrcweir if(pItem && pItem->ISA(SfxStringItem)) 249cdf0e10cSrcweir { 250cdf0e10cSrcweir pEditRegionDlg->SelectSection(((const SfxStringItem*)pItem)->GetValue()); 251cdf0e10cSrcweir } 252cdf0e10cSrcweir pEditRegionDlg->Execute(); 253cdf0e10cSrcweir delete pEditRegionDlg; 254cdf0e10cSrcweir } 255cdf0e10cSrcweir else 256cdf0e10cSrcweir InfoBox(pParentWin, SW_RES(REG_WRONG_PASSWORD)).Execute(); 257cdf0e10cSrcweir } 258cdf0e10cSrcweir break; 259cdf0e10cSrcweir } 260cdf0e10cSrcweir } 261