1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22
23
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26
27 #ifdef SW_DLLIMPLEMENTATION
28 #undef SW_DLLIMPLEMENTATION
29 #endif
30
31 #include <svx/dialogs.hrc>
32 #include <hintids.hxx>
33 #include <tools/list.hxx>
34 #include <sfx2/viewfrm.hxx>
35 #include <svx/htmlmode.hxx>
36 #include <fmtfsize.hxx>
37 #include <wrtsh.hxx>
38 #ifndef _VIEW_HXX
39 #include <view.hxx>
40 #endif
41 #include <docsh.hxx>
42 #include <viewopt.hxx>
43 #include <frmdlg.hxx>
44 #include <frmpage.hxx>
45 #include <wrap.hxx>
46 #include <column.hxx>
47 #include <macassgn.hxx>
48
49 #ifndef _FRMUI_HRC
50 #include <frmui.hrc>
51 #endif
52 #ifndef _GLOBALS_HRC
53 #include <globals.hrc>
54 #endif
55 #include <svx/svxids.hrc>
56 #include <svx/flagsdef.hxx>
57 #include <svx/svxdlg.hxx>
58
59 /*--------------------------------------------------------------------
60 Beschreibung: Der Traeger des Dialoges
61 --------------------------------------------------------------------*/
62
SwFrmDlg(SfxViewFrame * pViewFrame,Window * pParent,const SfxItemSet & rCoreSet,sal_Bool bNewFrm,sal_uInt16 nResType,sal_Bool bFormat,sal_uInt16 nDefPage,const String * pStr)63 SwFrmDlg::SwFrmDlg( SfxViewFrame* pViewFrame,
64 Window* pParent,
65 const SfxItemSet& rCoreSet,
66 sal_Bool bNewFrm,
67 sal_uInt16 nResType,
68 sal_Bool bFormat,
69 sal_uInt16 nDefPage,
70 const String* pStr) :
71
72 SfxTabDialog(pViewFrame, pParent, SW_RES(nResType), &rCoreSet, pStr != 0),
73 m_bFormat(bFormat),
74 m_bNew(bNewFrm),
75 m_rSet(rCoreSet),
76 m_nDlgType(nResType),
77 m_pWrtShell(((SwView*)pViewFrame->GetViewShell())->GetWrtShellPtr())
78 {
79 FreeResource();
80 sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
81 m_bHTMLMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
82
83 // BspFont fuer beide Bsp-TabPages
84 //
85 if(pStr)
86 {
87 String aTmp( GetText() );
88 aTmp += SW_RESSTR(STR_COLL_HEADER);
89 aTmp += *pStr;
90 aTmp += ')';
91 }
92
93 AddTabPage(TP_FRM_STD, SwFrmPage::Create, 0);
94 AddTabPage(TP_FRM_ADD, SwFrmAddPage::Create, 0);
95 AddTabPage(TP_FRM_WRAP, SwWrapTabPage::Create, 0);
96 AddTabPage(TP_FRM_URL, SwFrmURLPage::Create, 0);
97 if(m_nDlgType == DLG_FRM_GRF)
98 {
99 AddTabPage( TP_GRF_EXT, SwGrfExtPage::Create, 0 );
100 AddTabPage( RID_SVXPAGE_GRFCROP );
101 }
102 if (m_nDlgType == DLG_FRM_STD)
103 {
104 AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
105 }
106 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
107 DBG_ASSERT(pFact, "Dialogdiet fail!");
108
109 //UUUU remove?
110 // AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
111
112 //UUUU add Area and Transparence TabPages
113 AddTabPage(RID_SVXPAGE_AREA);
114 AddTabPage(RID_SVXPAGE_TRANSPARENCE);
115
116 AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
117 AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
118
119 if(m_bHTMLMode)
120 {
121 switch( m_nDlgType )
122 {
123 case DLG_FRM_STD:
124 if(0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))
125 RemoveTabPage(TP_BORDER);
126 RemoveTabPage(TP_COLUMN);
127 // kein break
128 case DLG_FRM_OLE:
129 RemoveTabPage(TP_FRM_URL);
130 RemoveTabPage(TP_MACRO_ASSIGN);
131 break;
132 case DLG_FRM_GRF:
133 RemoveTabPage(RID_SVXPAGE_GRFCROP);
134 break;
135 }
136 if( 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS) || m_nDlgType != DLG_FRM_STD )
137 {
138 //UUUU RemoveTabPage(TP_BACKGROUND);
139 RemoveTabPage(RID_SVXPAGE_AREA);
140 RemoveTabPage(RID_SVXPAGE_TRANSPARENCE);
141 }
142 }
143
144 if (m_bNew)
145 SetCurPageId(TP_FRM_STD);
146
147 if (nDefPage)
148 SetCurPageId(nDefPage);
149 }
150
151 /*--------------------------------------------------------------------
152 Beschreibung:
153 --------------------------------------------------------------------*/
154
~SwFrmDlg()155 SwFrmDlg::~SwFrmDlg()
156 {
157 }
158
159
160
161
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)162 void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
163 {
164 switch ( nId )
165 {
166 case TP_FRM_STD:
167 ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
168 ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
169 ((SwFrmPage&)rPage).SetFrmType(m_nDlgType);
170 break;
171
172 case TP_FRM_ADD:
173 ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
174 ((SwFrmAddPage&)rPage).SetFrmType(m_nDlgType);
175 ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
176 ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
177 break;
178
179 case TP_FRM_WRAP:
180 ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
181 ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, sal_False);
182 ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
183 break;
184
185 case TP_COLUMN:
186 {
187 ((SwColumnPage&)rPage).SetFrmMode(sal_True);
188 ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
189
190 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
191 m_rSet.Get( RES_FRM_SIZE );
192 ((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
193 }
194 break;
195
196 case TP_MACRO_ASSIGN:
197 {
198 SfxAllItemSet aNewSet(*GetInputSetImpl()->GetPool());
199 aNewSet.Put( SwMacroAssignDlg::AddEvents(
200 DLG_FRM_GRF == m_nDlgType ? MACASSGN_GRAPHIC : DLG_FRM_OLE == m_nDlgType ? MACASSGN_OLE : MACASSGN_FRMURL ) );
201 if ( m_pWrtShell )
202 rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
203 rPage.PageCreated(aNewSet);
204 break;
205 }
206
207 //UUUU
208 //case TP_BACKGROUND:
209 // if( DLG_FRM_STD == m_nDlgType )
210 // {
211 // sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
212 // if(!m_bHTMLMode)
213 // nFlagType |= SVX_ENABLE_TRANSPARENCY;
214 // SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
215 // aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
216 // rPage.PageCreated(aSet);
217 // }
218 // break;
219
220 case TP_BORDER:
221 {
222 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
223 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
224 rPage.PageCreated(aSet);
225 }
226 break;
227
228 //UUUU inits for Area and Transparency TabPages
229 // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
230 // the color table) need to be added as items (e.g. SvxColorTableItem) to make
231 // these pages find the needed attributes for fill style suggestions.
232 // These are set in preparation to trigger this dialog (FN_FORMAT_FRAME_DLG and
233 // FN_DRAW_WRAP_DLG), but could also be directly added from the DrawModel.
234 case RID_SVXPAGE_AREA:
235 {
236 SfxItemSet aNew(*GetInputSetImpl()->GetPool(),
237 SID_COLOR_TABLE, SID_BITMAP_LIST,
238 SID_OFFER_IMPORT, SID_OFFER_IMPORT, 0, 0);
239
240 aNew.Put(m_rSet);
241
242 // add flag for direct graphic content selection
243 aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
244
245 rPage.PageCreated(aNew);
246 }
247 break;
248
249 case RID_SVXPAGE_TRANSPARENCE:
250 {
251 rPage.PageCreated(m_rSet);
252 }
253 break;
254 }
255 }
256
257 // eof
258