android: Update app-specific/MIME type icons
[LibreOffice.git] / sw / source / ui / frmdlg / frmdlg.cxx
blob0eaf29dfe6db17c7ed864e1fa36ebc5ff0418f34
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <svx/dialogs.hrc>
21 #include <hintids.hxx>
22 #include <sfx2/viewfrm.hxx>
23 #include <sfx2/sfxdlg.hxx>
24 #include <sfx2/htmlmode.hxx>
25 #include <fmtfsize.hxx>
26 #include <wrtsh.hxx>
27 #include <view.hxx>
28 #include <viewopt.hxx>
29 #include <frmdlg.hxx>
30 #include <frmpage.hxx>
31 #include <wrap.hxx>
32 #include <column.hxx>
33 #include <macassgn.hxx>
34 #include <IDocumentSettingAccess.hxx>
36 #include <strings.hrc>
37 #include <svl/eitem.hxx>
38 #include <svx/svxids.hrc>
39 #include <svx/flagsdef.hxx>
40 #include <svx/drawitem.hxx>
41 #include <comphelper/lok.hxx>
43 // the dialog's carrier
44 SwFrameDlg::SwFrameDlg(const SfxViewFrame& rViewFrame,
45 weld::Window* pParent,
46 const SfxItemSet& rCoreSet,
47 bool bNewFrame,
48 const OUString& sResType,
49 bool bFormat,
50 const OUString& sDefPage,
51 const OUString* pStr)
53 : SfxTabDialogController(pParent, "modules/swriter/ui/" + sResType.toAsciiLowerCase() + ".ui",
54 sResType, &rCoreSet, pStr != nullptr)
55 , m_bFormat(bFormat)
56 , m_bNew(bNewFrame)
57 , m_rSet(rCoreSet)
58 , m_sDlgType(sResType)
59 , m_pWrtShell(static_cast<SwView*>(rViewFrame.GetViewShell())->GetWrtShellPtr())
61 sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
62 bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
64 // example font for both example TabPages
66 if (pStr)
68 m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_FRMUI_COLL_HEADER) + *pStr + ")");
71 AddTabPage("type", SwFramePage::Create, nullptr);
72 AddTabPage("options", SwFrameAddPage::Create, nullptr);
73 AddTabPage("wrap", SwWrapTabPage::Create, nullptr);
74 AddTabPage("hyperlink", SwFrameURLPage::Create, nullptr);
75 if (m_sDlgType == "PictureDialog")
77 AddTabPage("picture", SwGrfExtPage::Create, nullptr);
78 AddTabPage("crop", RID_SVXPAGE_GRFCROP);
80 if (m_sDlgType == "FrameDialog")
82 AddTabPage("columns", SwColumnPage::Create, nullptr);
84 SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
86 // add Area and Transparence TabPages
87 AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
88 AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
90 AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), nullptr);
91 AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr);
93 if(bHTMLMode)
95 if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
97 if (m_sDlgType == "FrameDialog")
98 RemoveTabPage("columns");
99 RemoveTabPage("hyperlink");
100 RemoveTabPage("macro");
102 else if (m_sDlgType == "PictureDialog")
103 RemoveTabPage("crop");
104 if( m_sDlgType != "FrameDialog" )
106 // RemoveTabPage("background");
107 RemoveTabPage("area");
108 RemoveTabPage("transparence");
112 if(comphelper::LibreOfficeKit::isActive())
113 RemoveTabPage("macro");
115 if (m_bNew)
116 SetCurPageId("type");
118 if (!sDefPage.isEmpty())
119 SetCurPageId(sDefPage);
122 SwFrameDlg::~SwFrameDlg()
126 void SwFrameDlg::PageCreated(const OUString& rId, SfxTabPage &rPage)
128 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
129 if (rId == "type")
131 static_cast<SwFramePage&>(rPage).SetNewFrame(m_bNew);
132 static_cast<SwFramePage&>(rPage).SetFormatUsed(m_bFormat);
133 static_cast<SwFramePage&>(rPage).SetFrameType(m_sDlgType);
135 else if (rId == "options")
137 static_cast<SwFrameAddPage&>(rPage).SetFormatUsed(m_bFormat);
138 static_cast<SwFrameAddPage&>(rPage).SetFrameType(m_sDlgType);
139 static_cast<SwFrameAddPage&>(rPage).SetNewFrame(m_bNew);
140 static_cast<SwFrameAddPage&>(rPage).SetShell(m_pWrtShell);
142 else if (rId == "wrap")
144 static_cast<SwWrapTabPage&>(rPage).SetNewFrame(m_bNew);
145 static_cast<SwWrapTabPage&>(rPage).SetFormatUsed(m_bFormat, false);
146 static_cast<SwWrapTabPage&>(rPage).SetShell(m_pWrtShell);
148 else if (rId == "columns")
150 static_cast<SwColumnPage&>(rPage).SetFrameMode(true);
151 static_cast<SwColumnPage&>(rPage).SetFormatUsed(m_bFormat);
153 const SwFormatFrameSize& rSize = m_rSet.Get( RES_FRM_SIZE );
154 static_cast<SwColumnPage&>(rPage).SetPageWidth( rSize.GetWidth() );
156 else if (rId == "macro")
158 SfxAllItemSet aNewSet(*aSet.GetPool());
159 aNewSet.Put( SwMacroAssignDlg::AddEvents(
160 m_sDlgType == "PictureDialog" ? MACASSGN_GRAPHIC : m_sDlgType == "ObjectDialog" ? MACASSGN_OLE : MACASSGN_FRMURL ) );
161 if (m_pWrtShell)
162 rPage.SetFrame( m_pWrtShell->GetView().GetViewFrame().GetFrame().GetFrameInterface() );
163 rPage.PageCreated(aNewSet);
165 else if (rId == "borders")
167 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME)));
168 rPage.PageCreated(aSet);
170 // inits for Area and Transparency TabPages
171 // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
172 // the color table) need to be added as items (e.g. SvxColorListItem) to make
173 // these pages find the needed attributes for fill style suggestions.
174 // These are set in preparation to trigger this dialog (FN_FORMAT_FRAME_DLG and
175 // FN_DRAW_WRAP_DLG), but could also be directly added from the DrawModel.
176 else if (rId == "area")
178 SfxItemSetFixed<SID_COLOR_TABLE, SID_PATTERN_LIST,
179 SID_OFFER_IMPORT, SID_OFFER_IMPORT>
180 aNew(*GetInputSetImpl()->GetPool());
182 aNew.Put(m_rSet);
184 // add flag for direct graphic content selection
185 aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
187 rPage.PageCreated(aNew);
189 else if (rId == "transparence")
191 rPage.PageCreated(m_rSet);
193 else if (rId == "crop")
195 sal_Int32 nPreferredDPI = m_pWrtShell->GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
196 if (nPreferredDPI)
197 rPage.getAdditionalProperties().emplace("PreferredDPI", css::uno::Any(nPreferredDPI));
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */