xref: /aoo4110/main/sw/source/ui/frmdlg/frmdlg.cxx (revision b1cdbd2c)
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     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
109 	AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
110     AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
111 
112     if(m_bHTMLMode)
113 	{
114         switch( m_nDlgType )
115 		{
116 		case DLG_FRM_STD:
117 				if(0  == (nHtmlMode & HTMLMODE_SOME_ABS_POS))
118 					RemoveTabPage(TP_BORDER);
119 				RemoveTabPage(TP_COLUMN);
120 			// kein break
121 		case DLG_FRM_OLE:
122 				RemoveTabPage(TP_FRM_URL);
123 				RemoveTabPage(TP_MACRO_ASSIGN);
124 			break;
125 		case DLG_FRM_GRF:
126 				RemoveTabPage(RID_SVXPAGE_GRFCROP);
127 			break;
128 		}
129 		if( 0  == (nHtmlMode & HTMLMODE_SOME_ABS_POS) ||
130             m_nDlgType != DLG_FRM_STD )
131 			RemoveTabPage(TP_BACKGROUND);
132 	}
133 
134     if (m_bNew)
135 		SetCurPageId(TP_FRM_STD);
136 
137 	if (nDefPage)
138 		SetCurPageId(nDefPage);
139 }
140 
141 /*--------------------------------------------------------------------
142 	Beschreibung:
143  --------------------------------------------------------------------*/
144 
~SwFrmDlg()145 SwFrmDlg::~SwFrmDlg()
146 {
147 }
148 
149 
150 
151 
PageCreated(sal_uInt16 nId,SfxTabPage & rPage)152 void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
153 {
154     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
155 	switch ( nId )
156 	{
157 	case TP_FRM_STD:
158         ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
159         ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
160         ((SwFrmPage&)rPage).SetFrmType(m_nDlgType);
161 		break;
162 
163 	case TP_FRM_ADD:
164         ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
165         ((SwFrmAddPage&)rPage).SetFrmType(m_nDlgType);
166         ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
167         ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
168 		break;
169 
170 	case TP_FRM_WRAP:
171         ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
172         ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, sal_False);
173         ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
174 		break;
175 
176 	case TP_COLUMN:
177 		{
178 			((SwColumnPage&)rPage).SetFrmMode(sal_True);
179             ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
180 
181 			const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
182                                                 m_rSet.Get( RES_FRM_SIZE );
183 			((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
184 		}
185 		break;
186 
187 	case TP_MACRO_ASSIGN:
188 		{
189 		SfxAllItemSet aNewSet(*aSet.GetPool());
190 		aNewSet.Put( SwMacroAssignDlg::AddEvents(
191 			DLG_FRM_GRF == m_nDlgType ? MACASSGN_GRAPHIC : DLG_FRM_OLE == m_nDlgType ? MACASSGN_OLE : MACASSGN_FRMURL ) );
192         if ( m_pWrtShell )
193             rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
194 		rPage.PageCreated(aNewSet);
195 		break;
196 		}
197 
198 	case TP_BACKGROUND:
199         if( DLG_FRM_STD == m_nDlgType )
200         {
201             sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
202             if(!m_bHTMLMode)
203                 nFlagType |= SVX_ENABLE_TRANSPARENCY;
204             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
205             rPage.PageCreated(aSet);
206         }
207 		break;
208 
209 	case TP_BORDER:
210 		{
211 			aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
212 			rPage.PageCreated(aSet);
213 		}
214 		break;
215 	}
216 }
217 
218