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 : bool bNewFrm,
53 : const OString& sResType,
54 : bool bFormat,
55 : const OString& sDefPage,
56 : const OUString* pStr)
57 :
58 : : SfxTabDialog(pViewFrame, pParent, sResType,
59 0 : OUString("modules/swriter/ui/") +
60 0 : OStringToOUString(sResType.toAsciiLowerCase(), RTL_TEXTENCODING_UTF8) +
61 : (".ui"), &rCoreSet, pStr != 0)
62 : , m_bFormat(bFormat)
63 : , m_bNew(bNewFrm)
64 : , m_rSet(rCoreSet)
65 : , m_sDlgType(sResType)
66 0 : , m_pWrtShell(((SwView*)pViewFrame->GetViewShell())->GetWrtShellPtr())
67 : , m_nStdId(0)
68 : , m_nAddId(0)
69 : , m_nWrapId(0)
70 : , m_nUrlId(0)
71 : , m_nPictureId(0)
72 : , m_nCropId(0)
73 : , m_nColumnId(0)
74 : //, m_nBackgroundId(0)
75 : , m_nAreaId(0)
76 : , m_nTransparenceId(0)
77 : , m_nMacroId(0)
78 0 : , m_nBorderId(0)
79 : {
80 0 : sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
81 0 : m_bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
82 :
83 : // example font for both example TabPages
84 :
85 0 : if(pStr)
86 : {
87 0 : SetText(GetText() + SW_RESSTR(STR_COLL_HEADER) + *pStr + OUString(')'));
88 : }
89 :
90 0 : m_nStdId = AddTabPage("type", SwFrmPage::Create, 0);
91 0 : m_nAddId = AddTabPage("options", SwFrmAddPage::Create, 0);
92 0 : m_nWrapId = AddTabPage("wrap", SwWrapTabPage::Create, 0);
93 0 : m_nUrlId = AddTabPage("hyperlink", SwFrmURLPage::Create, 0);
94 0 : if (m_sDlgType == "PictureDialog")
95 : {
96 0 : m_nPictureId = AddTabPage("picture", SwGrfExtPage::Create, 0);
97 0 : m_nCropId = AddTabPage("crop", RID_SVXPAGE_GRFCROP);
98 : }
99 0 : if (m_sDlgType == "FrameDialog")
100 : {
101 0 : m_nColumnId = AddTabPage("columns", SwColumnPage::Create, 0);
102 : }
103 0 : SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
104 : OSL_ENSURE(pFact, "Dialogdiet fail!");
105 :
106 : //UUUU remove?
107 : // m_nBackgroundId = AddTabPage("background", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BACKGROUND ), 0);
108 :
109 : //UUUU add Area and Transparence TabPages
110 0 : m_nAreaId = AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
111 0 : m_nTransparenceId = AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
112 :
113 0 : m_nMacroId = AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), 0);
114 0 : m_nBorderId = AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), 0);
115 :
116 0 : if(m_bHTMLMode)
117 : {
118 0 : if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
119 : {
120 0 : if (m_sDlgType == "FrameDialog")
121 0 : RemoveTabPage("columns");
122 0 : RemoveTabPage("hyperlink");
123 0 : RemoveTabPage("macro");
124 : }
125 0 : else if (m_sDlgType == "PictureDialog")
126 0 : RemoveTabPage("crop");
127 0 : if( m_sDlgType != "FrameDialog" )
128 : {
129 : //UUUU RemoveTabPage("background");
130 0 : RemoveTabPage("area");
131 0 : RemoveTabPage("transparence");
132 : }
133 : }
134 :
135 0 : if (m_bNew)
136 0 : SetCurPageId("type");
137 :
138 0 : if (!sDefPage.isEmpty())
139 0 : SetCurPageId(sDefPage);
140 0 : }
141 :
142 0 : SwFrmDlg::~SwFrmDlg()
143 : {
144 0 : }
145 :
146 0 : void SwFrmDlg::PageCreated( sal_uInt16 nId, SfxTabPage &rPage )
147 : {
148 0 : SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
149 0 : if (nId == m_nStdId)
150 : {
151 0 : ((SwFrmPage&)rPage).SetNewFrame(m_bNew);
152 0 : ((SwFrmPage&)rPage).SetFormatUsed(m_bFormat);
153 0 : ((SwFrmPage&)rPage).SetFrmType(m_sDlgType);
154 : }
155 0 : else if (nId == m_nAddId)
156 : {
157 0 : ((SwFrmAddPage&)rPage).SetFormatUsed(m_bFormat);
158 0 : ((SwFrmAddPage&)rPage).SetFrmType(m_sDlgType);
159 0 : ((SwFrmAddPage&)rPage).SetNewFrame(m_bNew);
160 0 : ((SwFrmAddPage&)rPage).SetShell(m_pWrtShell);
161 : }
162 0 : else if (nId == m_nWrapId)
163 : {
164 0 : ((SwWrapTabPage&)rPage).SetNewFrame(m_bNew);
165 0 : ((SwWrapTabPage&)rPage).SetFormatUsed(m_bFormat, sal_False);
166 0 : ((SwWrapTabPage&)rPage).SetShell(m_pWrtShell);
167 : }
168 0 : else if (nId == m_nColumnId)
169 : {
170 0 : ((SwColumnPage&)rPage).SetFrmMode(sal_True);
171 0 : ((SwColumnPage&)rPage).SetFormatUsed(m_bFormat);
172 :
173 : const SwFmtFrmSize& rSize = (const SwFmtFrmSize&)
174 0 : m_rSet.Get( RES_FRM_SIZE );
175 0 : ((SwColumnPage&)rPage).SetPageWidth( rSize.GetWidth() );
176 : }
177 0 : else if (nId == m_nMacroId)
178 : {
179 0 : SfxAllItemSet aNewSet(*aSet.GetPool());
180 : aNewSet.Put( SwMacroAssignDlg::AddEvents(
181 0 : m_sDlgType == "PictureDialog" ? MACASSGN_GRAPHIC : m_sDlgType == "ObjectDialog" ? MACASSGN_OLE : MACASSGN_FRMURL ) );
182 0 : if (m_pWrtShell)
183 0 : rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame()->GetFrame().GetFrameInterface() );
184 0 : rPage.PageCreated(aNewSet);
185 : }
186 : //UUUU
187 : //else if (nId == m_nBackgroundId && m_sDlgType == "FrameDialog")
188 : //{
189 : // sal_Int32 nFlagType = SVX_SHOW_SELECTOR;
190 : // if (!m_bHTMLMode)
191 : // nFlagType |= SVX_ENABLE_TRANSPARENCY;
192 : // aSet.Put (SfxUInt32Item(SID_FLAG_TYPE, nFlagType));
193 : //
194 : // rPage.PageCreated(aSet);
195 : //}
196 0 : else if (nId == m_nBorderId)
197 : {
198 0 : aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,SW_BORDER_MODE_FRAME));
199 0 : rPage.PageCreated(aSet);
200 : }
201 : //UUUU inits for Area and Transparency TabPages
202 : // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
203 : // the color table) need to be added as items (e.g. SvxColorListItem) to make
204 : // these pages find the needed attributes for fill style suggestions.
205 : // These are set in preparation to trigger this dialog (FN_FORMAT_FRAME_DLG and
206 : // FN_DRAW_WRAP_DLG), but could also be directly added from the DrawModel.
207 0 : else if (nId == m_nAreaId)
208 : {
209 0 : SfxItemSet aNew(*GetInputSetImpl()->GetPool(),
210 : SID_COLOR_TABLE, SID_BITMAP_LIST,
211 0 : SID_OFFER_IMPORT, SID_OFFER_IMPORT, 0, 0);
212 :
213 0 : aNew.Put(m_rSet);
214 :
215 : // add flag for direct graphic content selection
216 0 : aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
217 :
218 0 : rPage.PageCreated(aNew);
219 : }
220 0 : else if (nId == m_nTransparenceId)
221 : {
222 0 : rPage.PageCreated(m_rSet);
223 0 : }
224 0 : }
225 :
226 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|