LibreOffice Module sw (master) 1
frmdlg.cxx
Go to the documentation of this file.
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/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>
35
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>
42
43// the dialog's carrier
45 weld::Window* pParent,
46 const SfxItemSet& rCoreSet,
47 bool bNewFrame,
48 const OUString& sResType,
49 bool bFormat,
50 const OString& sDefPage,
51 const OUString* pStr)
52
53 : SfxTabDialogController(pParent, "modules/swriter/ui/" + sResType.toAsciiLowerCase() + ".ui",
54 sResType.toUtf8(), &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*>(pViewFrame->GetViewShell())->GetWrtShellPtr())
60{
61 sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
62 bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
63
64 // example font for both example TabPages
65
66 if (pStr)
67 {
68 m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_FRMUI_COLL_HEADER) + *pStr + ")");
69 }
70
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")
76 {
77 AddTabPage("picture", SwGrfExtPage::Create, nullptr);
78 AddTabPage("crop", RID_SVXPAGE_GRFCROP);
79 }
80 if (m_sDlgType == "FrameDialog")
81 {
82 AddTabPage("columns", SwColumnPage::Create, nullptr);
83 }
85
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 ) );
89
90 AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), nullptr);
91 AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr);
92
93 if(bHTMLMode)
94 {
95 if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
96 {
97 if (m_sDlgType == "FrameDialog")
98 RemoveTabPage("columns");
99 RemoveTabPage("hyperlink");
100 RemoveTabPage("macro");
101 }
102 else if (m_sDlgType == "PictureDialog")
103 RemoveTabPage("crop");
104 if( m_sDlgType != "FrameDialog" )
105 {
106 // RemoveTabPage("background");
107 RemoveTabPage("area");
108 RemoveTabPage("transparence");
109 }
110 }
111
113 RemoveTabPage("macro");
114
115 if (m_bNew)
116 SetCurPageId("type");
117
118 if (!sDefPage.isEmpty())
119 SetCurPageId(sDefPage);
120}
121
123{
124}
125
126void SwFrameDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
127{
128 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
129 if (rId == "type")
130 {
131 static_cast<SwFramePage&>(rPage).SetNewFrame(m_bNew);
132 static_cast<SwFramePage&>(rPage).SetFormatUsed(m_bFormat);
133 static_cast<SwFramePage&>(rPage).SetFrameType(m_sDlgType);
134 }
135 else if (rId == "options")
136 {
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);
141 }
142 else if (rId == "wrap")
143 {
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);
147 }
148 else if (rId == "columns")
149 {
150 static_cast<SwColumnPage&>(rPage).SetFrameMode(true);
151 static_cast<SwColumnPage&>(rPage).SetFormatUsed(m_bFormat);
152
153 const SwFormatFrameSize& rSize = m_rSet.Get( RES_FRM_SIZE );
154 static_cast<SwColumnPage&>(rPage).SetPageWidth( rSize.GetWidth() );
155 }
156 else if (rId == "macro")
157 {
158 SfxAllItemSet aNewSet(*aSet.GetPool());
160 m_sDlgType == "PictureDialog" ? MACASSGN_GRAPHIC : m_sDlgType == "ObjectDialog" ? MACASSGN_OLE : MACASSGN_FRMURL ) );
161 if (m_pWrtShell)
163 rPage.PageCreated(aNewSet);
164 }
165 else if (rId == "borders")
166 {
167 aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME)));
168 rPage.PageCreated(aSet);
169 }
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")
177 {
178 SfxItemSetFixed<SID_COLOR_TABLE, SID_PATTERN_LIST,
179 SID_OFFER_IMPORT, SID_OFFER_IMPORT>
180 aNew(*GetInputSetImpl()->GetPool());
181
182 aNew.Put(m_rSet);
183
184 // add flag for direct graphic content selection
185 aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
186
187 rPage.PageCreated(aNew);
188 }
189 else if (rId == "transparence")
190 {
191 rPage.PageCreated(m_rSet);
192 }
193 else if (rId == "crop")
194 {
195 sal_Int32 nPreferredDPI = m_pWrtShell->GetDoc()->getIDocumentSettingAccess().getImagePreferredDPI();
196 if (nPreferredDPI)
197 rPage.getAdditionalProperties().emplace("PreferredDPI", css::uno::Any(nPreferredDPI));
198 }
199}
200
201/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
virtual sal_Int32 getImagePreferredDPI()=0
virtual GetTabPageRanges GetTabPageRangesFunc(sal_uInt16 nId)=0
static SfxAbstractDialogFactory * Create()
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
SfxItemPool * GetPool() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void SetCurPageId(const OString &rName)
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OString &rName)
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const SfxAllItemSet &aSet)
std::unordered_map< OString, css::uno::Any > & getAdditionalProperties()
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
SfxFrame & GetFrame() const
SfxViewFrame * GetViewFrame() const
tools::Long GetWidth() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:585
IDocumentSettingAccess const & getIDocumentSettingAccess() const
Definition: doc.cxx:182
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2824
bool m_bNew
Definition: frmdlg.hxx:32
virtual ~SwFrameDlg() override
Definition: frmdlg.cxx:122
const SfxItemSet & m_rSet
Definition: frmdlg.hxx:33
OUString m_sDlgType
Definition: frmdlg.hxx:34
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: frmdlg.cxx:126
SwFrameDlg(SfxViewFrame const *pFrame, weld::Window *pParent, const SfxItemSet &rCoreSet, bool bNewFrame, const OUString &sResType, bool bFormat, const OString &sDefPage=OString(), const OUString *pFormatStr=nullptr)
Definition: frmdlg.cxx:44
bool m_bFormat
Definition: frmdlg.hxx:31
SwWrtShell * m_pWrtShell
Definition: frmdlg.hxx:35
This is the Position & Size tab page of the Insert -> Frame -> Frame dialog.
Definition: frmpage.hxx:39
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:831
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2759
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2335
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:38
SwDoc * GetDoc() const
Definition: viewsh.hxx:290
Definition: view.hxx:146
SwDocShell * GetDocShell()
Definition: view.cxx:1160
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: wrap.cxx:119
const SwView & GetView() const
Definition: wrtsh.hxx:443
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
HTMLMODE_ON
@ MACASSGN_GRAPHIC
Definition: macassgn.hxx:32
@ MACASSGN_FRMURL
Definition: macassgn.hxx:34
@ MACASSGN_OLE
Definition: macassgn.hxx:33
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:332