Update ooo320-m1
[ooovba.git] / sw / source / ui / frmdlg / frmdlg.cxx
blobb484810ed9cbc3187eb492ff71359cab9d24b716
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: frmdlg.cxx,v $
10 * $Revision: 1.14 $
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"
34 #ifdef SW_DLLIMPLEMENTATION
35 #undef SW_DLLIMPLEMENTATION
36 #endif
38 #include <svx/dialogs.hrc>
39 #include <hintids.hxx>
40 #include <tools/list.hxx>
41 #include <sfx2/viewfrm.hxx>
42 #include <svx/htmlmode.hxx>
43 #include <fmtfsize.hxx>
44 #include <wrtsh.hxx>
45 #ifndef _VIEW_HXX
46 #include <view.hxx>
47 #endif
48 #include <docsh.hxx>
49 #include <viewopt.hxx>
50 #include <frmdlg.hxx>
51 #include <frmpage.hxx>
52 #include <wrap.hxx>
53 #include <column.hxx>
54 #include <macassgn.hxx>
56 #ifndef _FRMUI_HRC
57 #include <frmui.hrc>
58 #endif
59 #ifndef _GLOBALS_HRC
60 #include <globals.hrc>
61 #endif
62 #include <svx/svxids.hrc>
63 #include <svx/flagsdef.hxx>
64 #include <svx/svxdlg.hxx>
66 /*--------------------------------------------------------------------
67 Beschreibung: Der Traeger des Dialoges
68 --------------------------------------------------------------------*/
70 SwFrmDlg::SwFrmDlg( SfxViewFrame* pViewFrame,
71 Window* pParent,
72 const SfxItemSet& rCoreSet,
73 BOOL bNewFrm,
74 USHORT nResType,
75 BOOL bFormat,
76 UINT16 nDefPage,
77 const String* pStr) :
79 SfxTabDialog(pViewFrame, pParent, SW_RES(nResType), &rCoreSet, pStr != 0),
80 m_bFormat(bFormat),
81 m_bNew(bNewFrm),
82 m_rSet(rCoreSet),
83 m_nDlgType(nResType),
84 m_pWrtShell(((SwView*)pViewFrame->GetViewShell())->GetWrtShellPtr())
86 FreeResource();
87 USHORT nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
88 m_bHTMLMode = static_cast< BOOL >(nHtmlMode & HTMLMODE_ON);
90 // BspFont fuer beide Bsp-TabPages
92 if(pStr)
94 String aTmp( GetText() );
95 aTmp += SW_RESSTR(STR_COLL_HEADER);
96 aTmp += *pStr;
97 aTmp += ')';
99 AddTabPage(TP_FRM_STD, SwFrmPage::Create, 0);
100 AddTabPage(TP_FRM_ADD, SwFrmAddPage::Create, 0);
101 AddTabPage(TP_FRM_WRAP, SwWrapTabPage::Create, 0);
102 AddTabPage(TP_FRM_URL, SwFrmURLPage::Create, 0);
103 if(m_nDlgType == DLG_FRM_GRF)
105 AddTabPage( TP_GRF_EXT, SwGrfExtPage::Create, 0 );
106 AddTabPage( RID_SVXPAGE_GRFCROP );
108 if (m_nDlgType == DLG_FRM_STD)
110 AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
112 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
113 DBG_ASSERT(pFact, "Dialogdiet fail!");
114 AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
115 AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
116 AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
118 if(m_bHTMLMode)
120 switch( m_nDlgType )
122 case DLG_FRM_STD:
123 if(0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS))
124 RemoveTabPage(TP_BORDER);
125 RemoveTabPage(TP_COLUMN);
126 // kein break
127 case DLG_FRM_OLE:
128 RemoveTabPage(TP_FRM_URL);
129 RemoveTabPage(TP_MACRO_ASSIGN);
130 break;
131 case DLG_FRM_GRF:
132 RemoveTabPage(RID_SVXPAGE_GRFCROP);
133 break;
135 if( 0 == (nHtmlMode & HTMLMODE_SOME_ABS_POS) ||
136 m_nDlgType != DLG_FRM_STD )
137 RemoveTabPage(TP_BACKGROUND);
140 if (m_bNew)
141 SetCurPageId(TP_FRM_STD);
143 if (nDefPage)
144 SetCurPageId(nDefPage);
147 /*--------------------------------------------------------------------
148 Beschreibung:
149 --------------------------------------------------------------------*/
151 SwFrmDlg::~SwFrmDlg()
158 void SwFrmDlg::PageCreated( USHORT nId, SfxTabPage &rPage )
160 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
161 switch ( nId )
163 case TP_FRM_STD:
164 ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
165 ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
166 ((SwFrmPage&)rPage).SetFrmType(m_nDlgType);
167 break;
169 case TP_FRM_ADD:
170 ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
171 ((SwFrmAddPage&)rPage).SetFrmType(m_nDlgType);
172 ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
173 ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
174 break;
176 case TP_FRM_WRAP:
177 ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
178 ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, FALSE);
179 ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
180 break;
182 case TP_COLUMN:
184 ((SwColumnPage&)rPage).SetFrmMode(TRUE);
185 ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
187 const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
188 m_rSet.Get( RES_FRM_SIZE );
189 ((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
191 break;
193 case TP_MACRO_ASSIGN:
195 SfxAllItemSet aNewSet(*aSet.GetPool());
196 aNewSet.Put( SwMacroAssignDlg::AddEvents(
197 DLG_FRM_GRF == m_nDlgType ? MACASSGN_GRAPHIC : DLG_FRM_OLE == m_nDlgType ? MACASSGN_OLE : MACASSGN_FRMURL ) );
198 if ( m_pWrtShell )
199 rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame()->GetFrameInterface() );
200 rPage.PageCreated(aNewSet);
201 break;
204 case TP_BACKGROUND:
205 if( DLG_FRM_STD == m_nDlgType )
207 sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
208 if(!m_bHTMLMode)
209 nFlagType |= SVX_ENABLE_TRANSPARENCY;
210 aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
211 rPage.PageCreated(aSet);
213 break;
215 case TP_BORDER:
217 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
218 rPage.PageCreated(aSet);
220 break;