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