1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: regionsw.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <hintids.hxx>
37 #include <svtools/urihelper.hxx>
38 #include <svtools/PasswordHelper.hxx>
39 #ifndef _MSGBOX_HXX //autogen
40 #include <vcl/msgbox.hxx>
42 #include <svtools/stritem.hxx>
43 #include <svtools/eitem.hxx>
44 #include <sot/formats.hxx>
45 #ifndef _PASSWD_HXX //autogen
46 #include <sfx2/passwd.hxx>
48 #include <sfx2/docfilt.hxx>
49 #include <sfx2/request.hxx>
50 #include <sfx2/docfile.hxx>
51 #include <sfx2/linkmgr.hxx>
52 #ifndef _SVX_SIZEITEM_HXX //autogen
54 #include <svx/sizeitem.hxx>
57 #include <svx/htmlcfg.hxx>
58 #include <section.hxx>
60 #include <regionsw.hxx>
70 #include <swmodule.hxx>
72 #include <swundo.hxx> // fuer Undo-Ids
74 #include <fmtfsize.hxx>
75 #include <swunodef.hxx>
76 #include <shellio.hxx>
85 #include <regionsw.hrc>
88 #include <comcore.hrc>
91 #include <globals.hrc>
93 #include <sfx2/bindings.hxx>
94 #include <svx/htmlmode.hxx>
95 #include <svx/dlgutil.hxx>
96 #include "swabstdlg.hxx"
98 /*--------------------------------------------------------------------
99 Beschreibung: Bereiche einfuegen
100 --------------------------------------------------------------------*/
103 void SwBaseShell::InsertRegionDialog(SfxRequest
& rReq
)
105 SwWrtShell
& rSh
= GetShell();
106 const SfxItemSet
*pSet
= rReq
.GetArgs();
108 SfxItemSet
aSet(GetPool(),
110 RES_LR_SPACE
, RES_LR_SPACE
,
111 RES_COLUMNBALANCE
, RES_FRAMEDIR
,
112 RES_BACKGROUND
, RES_BACKGROUND
,
113 RES_FRM_SIZE
, RES_FRM_SIZE
,
114 RES_FTN_AT_TXTEND
, RES_END_AT_TXTEND
,
115 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
118 if (!pSet
|| pSet
->Count()==0)
121 rSh
.CalcBoundRect(aRect
, FLY_IN_CNTNT
);
123 long nWidth
= aRect
.Width();
124 aSet
.Put(SwFmtFrmSize(ATT_VAR_SIZE
, nWidth
));
126 // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten)
127 aSet
.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE
, Size(nWidth
, nWidth
)));
128 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
129 DBG_ASSERT(pFact
, "Dialogdiet fail!");
130 AbstractInsertSectionTabDialog
* aTabDlg
= pFact
->CreateInsertSectionTabDialog( DLG_INSERT_SECTION
,
131 &GetView().GetViewFrame()->GetWindow(), aSet
, rSh
);
132 DBG_ASSERT(aTabDlg
, "Dialogdiet fail!");
139 const SfxPoolItem
*pItem
= 0;
142 pSet
->GetItemState(FN_PARAM_REGION_NAME
, TRUE
, &pItem
) )
143 aTmpStr
= rSh
.GetUniqueSectionName(
144 &((const SfxStringItem
*)pItem
)->GetValue() );
146 aTmpStr
= rSh
.GetUniqueSectionName();
148 SwSection
aSection(CONTENT_SECTION
,aTmpStr
);
149 rReq
.SetReturnValue(SfxStringItem(FN_INSERT_REGION
, aTmpStr
));
152 if(SFX_ITEM_SET
== pSet
->GetItemState(SID_ATTR_COLUMNS
, FALSE
, &pItem
)||
153 SFX_ITEM_SET
== pSet
->GetItemState(FN_INSERT_REGION
, FALSE
, &pItem
))
157 rSh
.CalcBoundRect(aRect
, FLY_IN_CNTNT
);
158 long nWidth
= aRect
.Width();
160 USHORT nCol
= ((SfxUInt16Item
*)pItem
)->GetValue();
163 aCol
.Init( nCol
, 0, static_cast< USHORT
>(nWidth
) );
167 else if(SFX_ITEM_SET
== pSet
->GetItemState(RES_COL
, FALSE
, &pItem
))
172 const BOOL bHidden
= SFX_ITEM_SET
==
173 pSet
->GetItemState(FN_PARAM_REGION_HIDDEN
, TRUE
, &pItem
)?
174 (BOOL
)((const SfxBoolItem
*)pItem
)->GetValue():FALSE
;
175 const BOOL bProtect
= SFX_ITEM_SET
==
176 pSet
->GetItemState(FN_PARAM_REGION_PROTECT
, TRUE
, &pItem
)?
177 (BOOL
)((const SfxBoolItem
*)pItem
)->GetValue():FALSE
;
178 // --> FME 2004-06-22 #114856# edit in readonly sections
179 const BOOL bEditInReadonly
= SFX_ITEM_SET
==
180 pSet
->GetItemState(FN_PARAM_REGION_EDIT_IN_READONLY
, TRUE
, &pItem
)?
181 (BOOL
)((const SfxBoolItem
*)pItem
)->GetValue():FALSE
;
184 aSection
.SetProtect(bProtect
);
185 aSection
.SetHidden(bHidden
);
186 // --> FME 2004-06-22 #114856# edit in readonly sections
187 aSection
.SetEditInReadonly(bEditInReadonly
);
191 pSet
->GetItemState(FN_PARAM_REGION_CONDITION
, TRUE
, &pItem
))
192 aSection
.SetCondition(((const SfxStringItem
*)pItem
)->GetValue());
196 pSet
->GetItemState(FN_PARAM_1
, TRUE
, &pItem
))
197 aFile
= ((const SfxStringItem
*)pItem
)->GetValue();
200 pSet
->GetItemState(FN_PARAM_3
, TRUE
, &pItem
))
201 aSub
= ((const SfxStringItem
*)pItem
)->GetValue();
204 if(aFile
.Len() || aSub
.Len())
206 String
sLinkFileName(sfx2::cTokenSeperator
);
207 sLinkFileName
+= sfx2::cTokenSeperator
;
208 sLinkFileName
.SetToken(0, sfx2::cTokenSeperator
,aFile
);
211 pSet
->GetItemState(FN_PARAM_2
, TRUE
, &pItem
))
212 sLinkFileName
.SetToken(1, sfx2::cTokenSeperator
,
213 ((const SfxStringItem
*)pItem
)->GetValue());
215 sLinkFileName
+= aSub
;
216 aSection
.SetType( FILE_LINK_SECTION
);
217 aSection
.SetLinkFileName(sLinkFileName
);
219 rSh
.InsertSection(aSection
, aSet
.Count() ? &aSet
: 0);
224 IMPL_STATIC_LINK( SwWrtShell
, InsertRegionDialog
, SwSection
*, pSect
)
228 SfxItemSet
aSet(pThis
->GetView().GetPool(),
230 RES_BACKGROUND
, RES_BACKGROUND
,
231 RES_FRM_SIZE
, RES_FRM_SIZE
,
232 SID_ATTR_PAGE_SIZE
, SID_ATTR_PAGE_SIZE
,
235 pThis
->CalcBoundRect(aRect
, FLY_IN_CNTNT
);
236 long nWidth
= aRect
.Width();
237 aSet
.Put(SwFmtFrmSize(ATT_VAR_SIZE
, nWidth
));
238 // Hoehe=Breite fuer konsistentere Vorschau (analog zu Bereich bearbeiten)
239 aSet
.Put(SvxSizeItem(SID_ATTR_PAGE_SIZE
, Size(nWidth
, nWidth
)));
240 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
241 DBG_ASSERT(pFact
, "Dialogdiet fail!");
242 AbstractInsertSectionTabDialog
* aTabDlg
= pFact
->CreateInsertSectionTabDialog( DLG_INSERT_SECTION
,
243 &pThis
->GetView().GetViewFrame()->GetWindow(),aSet
, *pThis
);
244 DBG_ASSERT(aTabDlg
, "Dialogdiet fail!");
245 aTabDlg
->SetSection(*pSect
);
254 /*--------------------------------------------------------------------
255 Beschreibung: Bereich bearbeiten
256 --------------------------------------------------------------------*/
258 void SwBaseShell::EditRegionDialog(SfxRequest
& rReq
)
260 const SfxItemSet
* pArgs
= rReq
.GetArgs();
261 USHORT nSlot
= rReq
.GetSlot();
262 const SfxPoolItem
* pItem
= 0;
264 pArgs
->GetItemState(nSlot
, FALSE
, &pItem
);
265 SwWrtShell
& rWrtShell
= GetShell();
271 Window
* pParentWin
= &GetView().GetViewFrame()->GetWindow();
275 SwAbstractDialogFactory
* pFact
= SwAbstractDialogFactory::Create();
276 DBG_ASSERT(pFact
, "Dialogdiet fail!");
277 AbstractEditRegionDlg
* pEditRegionDlg
= pFact
->CreateEditRegionDlg( MD_EDIT_REGION
,
278 pParentWin
, rWrtShell
);
279 DBG_ASSERT(pEditRegionDlg
, "Dialogdiet fail!");
280 if(pItem
&& pItem
->ISA(SfxStringItem
))
282 pEditRegionDlg
->SelectSection(((const SfxStringItem
*)pItem
)->GetValue());
284 pEditRegionDlg
->Execute();
285 delete pEditRegionDlg
;
288 InfoBox(pParentWin
, SW_RES(REG_WRONG_PASSWORD
)).Execute();