xref: /trunk/main/sw/source/ui/frmdlg/frmdlg.cxx (revision cdf0e10c)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sw.hxx"
30 
31 #ifdef SW_DLLIMPLEMENTATION
32 #undef SW_DLLIMPLEMENTATION
33 #endif
34 
35 #include <svx/dialogs.hrc>
36 #include <hintids.hxx>
37 #include <tools/list.hxx>
38 #include <sfx2/viewfrm.hxx>
39 #include <svx/htmlmode.hxx>
40 #include <fmtfsize.hxx>
41 #include <wrtsh.hxx>
42 #ifndef _VIEW_HXX
43 #include <view.hxx>
44 #endif
45 #include <docsh.hxx>
46 #include <viewopt.hxx>
47 #include <frmdlg.hxx>
48 #include <frmpage.hxx>
49 #include <wrap.hxx>
50 #include <column.hxx>
51 #include <macassgn.hxx>
52 
53 #ifndef _FRMUI_HRC
54 #include <frmui.hrc>
55 #endif
56 #ifndef _GLOBALS_HRC
57 #include <globals.hrc>
58 #endif
59 #include <svx/svxids.hrc>
60 #include <svx/flagsdef.hxx>
61 #include <svx/svxdlg.hxx>
62 
63 /*--------------------------------------------------------------------
64 	Beschreibung:	Der Traeger des Dialoges
65  --------------------------------------------------------------------*/
66 
67 SwFrmDlg::SwFrmDlg( SfxViewFrame*       pViewFrame,
68 					Window*				pParent,
69 					const SfxItemSet& 	rCoreSet,
70 					sal_Bool 				bNewFrm,
71 					sal_uInt16				nResType,
72                     sal_Bool                bFormat,
73 					sal_uInt16				nDefPage,
74 					const String* 		pStr) :
75 
76     SfxTabDialog(pViewFrame, pParent, SW_RES(nResType), &rCoreSet, pStr != 0),
77     m_bFormat(bFormat),
78     m_bNew(bNewFrm),
79     m_rSet(rCoreSet),
80     m_nDlgType(nResType),
81     m_pWrtShell(((SwView*)pViewFrame->GetViewShell())->GetWrtShellPtr())
82 {
83 	FreeResource();
84     sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
85     m_bHTMLMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
86 
87 	// BspFont fuer beide Bsp-TabPages
88 	//
89 	if(pStr)
90 	{
91 		String aTmp( GetText() );
92 		aTmp += SW_RESSTR(STR_COLL_HEADER);
93 		aTmp += *pStr;
94 		aTmp += ')';
95 	}
96 
97     AddTabPage(TP_FRM_STD,  SwFrmPage::Create, 0);
98 	AddTabPage(TP_FRM_ADD,	SwFrmAddPage::Create, 0);
99 	AddTabPage(TP_FRM_WRAP,	SwWrapTabPage::Create, 0);
100 	AddTabPage(TP_FRM_URL,	SwFrmURLPage::Create, 0);
101     if(m_nDlgType == DLG_FRM_GRF)
102 	{
103 		AddTabPage( TP_GRF_EXT,	SwGrfExtPage::Create, 0 );
104         AddTabPage( RID_SVXPAGE_GRFCROP );
105 	}
106     if (m_nDlgType == DLG_FRM_STD)
107 	{
108 		AddTabPage(TP_COLUMN,	SwColumnPage::Create,  	 0);
109 	}
110     SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
111     DBG_ASSERT(pFact, "Dialogdiet fail!");
112     AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
113 	AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
114     AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
115 
116     if(m_bHTMLMode)
117 	{
118         switch( m_nDlgType )
119 		{
120 		case DLG_FRM_STD:
121 				if(0  == (nHtmlMode & HTMLMODE_SOME_ABS_POS))
122 					RemoveTabPage(TP_BORDER);
123 				RemoveTabPage(TP_COLUMN);
124 			// kein break
125 		case DLG_FRM_OLE:
126 				RemoveTabPage(TP_FRM_URL);
127 				RemoveTabPage(TP_MACRO_ASSIGN);
128 			break;
129 		case DLG_FRM_GRF:
130 				RemoveTabPage(RID_SVXPAGE_GRFCROP);
131 			break;
132 		}
133 		if( 0  == (nHtmlMode & HTMLMODE_SOME_ABS_POS) ||
134             m_nDlgType != DLG_FRM_STD )
135 			RemoveTabPage(TP_BACKGROUND);
136 	}
137 
138     if (m_bNew)
139 		SetCurPageId(TP_FRM_STD);
140 
141 	if (nDefPage)
142 		SetCurPageId(nDefPage);
143 }
144 
145 /*--------------------------------------------------------------------
146 	Beschreibung:
147  --------------------------------------------------------------------*/
148 
149 SwFrmDlg::~SwFrmDlg()
150 {
151 }
152 
153 
154 
155 
156 void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
157 {
158     SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
159 	switch ( nId )
160 	{
161 	case TP_FRM_STD:
162         ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
163         ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
164         ((SwFrmPage&)rPage).SetFrmType(m_nDlgType);
165 		break;
166 
167 	case TP_FRM_ADD:
168         ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
169         ((SwFrmAddPage&)rPage).SetFrmType(m_nDlgType);
170         ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
171         ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
172 		break;
173 
174 	case TP_FRM_WRAP:
175         ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
176         ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, sal_False);
177         ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
178 		break;
179 
180 	case TP_COLUMN:
181 		{
182 			((SwColumnPage&)rPage).SetFrmMode(sal_True);
183             ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
184 
185 			const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
186                                                 m_rSet.Get( RES_FRM_SIZE );
187 			((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
188 		}
189 		break;
190 
191 	case TP_MACRO_ASSIGN:
192 		{
193 		SfxAllItemSet aNewSet(*aSet.GetPool());
194 		aNewSet.Put( SwMacroAssignDlg::AddEvents(
195 			DLG_FRM_GRF == m_nDlgType ? MACASSGN_GRAPHIC : DLG_FRM_OLE == m_nDlgType ? MACASSGN_OLE : MACASSGN_FRMURL ) );
196         if ( m_pWrtShell )
197             rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
198 		rPage.PageCreated(aNewSet);
199 		break;
200 		}
201 
202 	case TP_BACKGROUND:
203         if( DLG_FRM_STD == m_nDlgType )
204         {
205             sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
206             if(!m_bHTMLMode)
207                 nFlagType |= SVX_ENABLE_TRANSPARENCY;
208             aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
209             rPage.PageCreated(aSet);
210         }
211 		break;
212 
213 	case TP_BORDER:
214 		{
215 			aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
216 			rPage.PageCreated(aSet);
217 		}
218 		break;
219 	}
220 }
221 
222