Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #include <svx/dialogs.hrc>
21 : #include <hintids.hxx>
22 : #include <sfx2/viewfrm.hxx>
23 : #include <sfx2/htmlmode.hxx>
24 : #include <fmtfsize.hxx>
25 : #include <wrtsh.hxx>
26 : #include <doc.hxx>
27 : #include <view.hxx>
28 : #include <docsh.hxx>
29 : #include <viewopt.hxx>
30 : #include <frmdlg.hxx>
31 : #include <frmpage.hxx>
32 : #include <wrap.hxx>
33 : #include <column.hxx>
34 : #include <macassgn.hxx>
35 :
36 : #include <frmui.hrc>
37 : #include <globals.hrc>
38 : #include <svx/svxids.hrc>
39 : #include <svx/flagsdef.hxx>
40 : #include <svx/svxdlg.hxx>
41 : #include <svx/svdmodel.hxx>
42 : #include <svx/drawitem.hxx>
43 : #include <svx/xfillit0.hxx>
44 : #include <svx/xflgrit.hxx>
45 :
46 : /*--------------------------------------------------------------------
47 : Description: the dialog's carrier
48 : --------------------------------------------------------------------*/
49 0 : SwFrmDlg::SwFrmDlg( SfxViewFrame* pViewFrame,
50 : Window* pParent,
51 : const SfxItemSet& rCoreSet,
52 : sal_Bool bNewFrm,
53 : sal_uInt16 nResType,
54 : sal_Bool bFormat,
55 : sal_uInt16 nDefPage,
56 : const String* pStr) :
57 :
58 : SfxTabDialog(pViewFrame, pParent, SW_RES(nResType), &rCoreSet, pStr != 0),
59 : m_bFormat(bFormat),
60 : m_bNew(bNewFrm),
61 : m_rSet(rCoreSet),
62 : m_nDlgType(nResType),
63 0 : m_pWrtShell(((SwView*)pViewFrame->GetViewShell())->GetWrtShellPtr())
64 : {
65 0 : FreeResource();
66 0 : sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
67 0 : m_bHTMLMode = static_cast< sal_Bool >(nHtmlMode & HTMLMODE_ON);
68 :
69 : // example font for both example TabPages
70 : //
71 0 : if(pStr)
72 : {
73 0 : String aTmp( GetText() );
74 0 : aTmp += SW_RESSTR(STR_COLL_HEADER);
75 0 : aTmp += *pStr;
76 0 : aTmp += ')';
77 : }
78 :
79 0 : AddTabPage(TP_FRM_STD, SwFrmPage::Create, 0);
80 0 : AddTabPage(TP_FRM_ADD, SwFrmAddPage::Create, 0);
81 0 : AddTabPage(TP_FRM_WRAP, SwWrapTabPage::Create, 0);
82 0 : AddTabPage(TP_FRM_URL, SwFrmURLPage::Create, 0);
83 0 : if(m_nDlgType == DLG_FRM_GRF)
84 : {
85 0 : AddTabPage( TP_GRF_EXT, SwGrfExtPage::Create, 0 );
86 0 : AddTabPage( RID_SVXPAGE_GRFCROP );
87 : }
88 0 : if (m_nDlgType == DLG_FRM_STD)
89 : {
90 0 : AddTabPage(TP_COLUMN, SwColumnPage::Create, 0);
91 : }
92 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
93 : OSL_ENSURE(pFact, "Dialogdiet fail!");
94 0 : AddTabPage(TP_BACKGROUND, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0 );
95 0 : AddTabPage( TP_MACRO_ASSIGN, pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
96 0 : AddTabPage( TP_BORDER, pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0 );
97 :
98 0 : if(m_bHTMLMode)
99 : {
100 0 : switch( m_nDlgType )
101 : {
102 : case DLG_FRM_STD:
103 0 : RemoveTabPage(TP_COLUMN);
104 : // no break
105 : case DLG_FRM_OLE:
106 0 : RemoveTabPage(TP_FRM_URL);
107 0 : RemoveTabPage(TP_MACRO_ASSIGN);
108 0 : break;
109 : case DLG_FRM_GRF:
110 0 : RemoveTabPage(RID_SVXPAGE_GRFCROP);
111 0 : break;
112 : }
113 0 : if( m_nDlgType != DLG_FRM_STD )
114 0 : RemoveTabPage(TP_BACKGROUND);
115 : }
116 :
117 0 : if (m_bNew)
118 0 : SetCurPageId(TP_FRM_STD);
119 :
120 0 : if (nDefPage)
121 0 : SetCurPageId(nDefPage);
122 0 : }
123 :
124 0 : SwFrmDlg::~SwFrmDlg()
125 : {
126 0 : }
127 :
128 0 : void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
129 : {
130 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
131 0 : switch ( nId )
132 : {
133 : case TP_FRM_STD:
134 0 : ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
135 0 : ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
136 0 : ((SwFrmPage&)rPage).SetFrmType(m_nDlgType);
137 0 : break;
138 :
139 : case TP_FRM_ADD:
140 0 : ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
141 0 : ((SwFrmAddPage&)rPage).SetFrmType(m_nDlgType);
142 0 : ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
143 0 : ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
144 0 : break;
145 :
146 : case TP_FRM_WRAP:
147 0 : ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
148 0 : ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, sal_False);
149 0 : ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
150 0 : break;
151 :
152 : case TP_COLUMN:
153 : {
154 0 : ((SwColumnPage&)rPage).SetFrmMode(sal_True);
155 0 : ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
156 :
157 : const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
158 0 : m_rSet.Get( RES_FRM_SIZE );
159 0 : ((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
160 : }
161 0 : break;
162 :
163 : case TP_MACRO_ASSIGN:
164 : {
165 0 : SfxAllItemSet aNewSet(*aSet.GetPool());
166 : aNewSet.Put( SwMacroAssignDlg::AddEvents(
167 0 : DLG_FRM_GRF == m_nDlgType ? MACASSGN_GRAPHIC : DLG_FRM_OLE == m_nDlgType ? MACASSGN_OLE : MACASSGN_FRMURL ) );
168 0 : if ( m_pWrtShell )
169 0 : rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
170 0 : rPage.PageCreated(aNewSet);
171 0 : break;
172 : }
173 :
174 : case TP_BACKGROUND:
175 0 : if( DLG_FRM_STD == m_nDlgType )
176 : {
177 0 : sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
178 0 : if(!m_bHTMLMode)
179 0 : nFlagType |= SVX_ENABLE_TRANSPARENCY;
180 0 : aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
181 :
182 0 : SvxGradientListItem aGradientListItem(m_pWrtShell->GetDoc()->GetOrCreateDrawModel()->GetGradientList(), SID_GRADIENT_LIST);
183 0 : aSet.Put(aGradientListItem);
184 :
185 0 : XFillStyleItem aFillStyleItem(((const XFillStyleItem&)m_rSet.Get(RES_FILL_STYLE)).GetValue(), SID_ATTR_FILL_STYLE);
186 0 : aSet.Put(aFillStyleItem);
187 :
188 0 : const XFillGradientItem& rFillGradientItem = (const XFillGradientItem&)m_rSet.Get(RES_FILL_GRADIENT);
189 0 : XFillGradientItem aFillGradientItem(rFillGradientItem.GetName(), rFillGradientItem.GetGradientValue(), SID_ATTR_FILL_GRADIENT);
190 0 : aSet.Put(aFillGradientItem);
191 :
192 0 : rPage.PageCreated(aSet);
193 : }
194 0 : break;
195 :
196 : case TP_BORDER:
197 : {
198 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
199 0 : rPage.PageCreated(aSet);
200 : }
201 0 : break;
202 0 : }
203 0 : }
204 :
205 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|