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