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>
34 
35 #include <strings.hrc>
36 #include <svl/eitem.hxx>
37 #include <svx/svxids.hrc>
38 #include <svx/flagsdef.hxx>
39 #include <svx/drawitem.hxx>
40 #include <comphelper/lok.hxx>
41 
42 // the dialog's carrier
44  weld::Window* pParent,
45  const SfxItemSet& rCoreSet,
46  bool bNewFrame,
47  const OUString& sResType,
48  bool bFormat,
49  const OString& sDefPage,
50  const OUString* pStr)
51 
52  : SfxTabDialogController(pParent, "modules/swriter/ui/" + sResType.toAsciiLowerCase() + ".ui",
53  sResType.toUtf8(), &rCoreSet, pStr != nullptr)
54  , m_bFormat(bFormat)
55  , m_bNew(bNewFrame)
56  , m_rSet(rCoreSet)
57  , m_sDlgType(sResType)
58  , m_pWrtShell(static_cast<SwView*>(pViewFrame->GetViewShell())->GetWrtShellPtr())
59 {
60  sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
61  bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
62 
63  // example font for both example TabPages
64 
65  if (pStr)
66  {
67  m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_FRMUI_COLL_HEADER) + *pStr + ")");
68  }
69 
70  AddTabPage("type", SwFramePage::Create, nullptr);
71  AddTabPage("options", SwFrameAddPage::Create, nullptr);
72  AddTabPage("wrap", SwWrapTabPage::Create, nullptr);
73  AddTabPage("hyperlink", SwFrameURLPage::Create, nullptr);
74  if (m_sDlgType == "PictureDialog")
75  {
76  AddTabPage("picture", SwGrfExtPage::Create, nullptr);
77  AddTabPage("crop", RID_SVXPAGE_GRFCROP);
78  }
79  if (m_sDlgType == "FrameDialog")
80  {
81  AddTabPage("columns", SwColumnPage::Create, nullptr);
82  }
84 
85  // add Area and Transparence TabPages
86  AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
87  AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
88 
89  AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), nullptr);
90  AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr);
91 
92  if(bHTMLMode)
93  {
94  if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
95  {
96  if (m_sDlgType == "FrameDialog")
97  RemoveTabPage("columns");
98  RemoveTabPage("hyperlink");
99  RemoveTabPage("macro");
100  }
101  else if (m_sDlgType == "PictureDialog")
102  RemoveTabPage("crop");
103  if( m_sDlgType != "FrameDialog" )
104  {
105  // RemoveTabPage("background");
106  RemoveTabPage("area");
107  RemoveTabPage("transparence");
108  }
109  }
110 
112  RemoveTabPage("macro");
113 
114  if (m_bNew)
115  SetCurPageId("type");
116 
117  if (!sDefPage.isEmpty())
118  SetCurPageId(sDefPage);
119 }
120 
122 {
123 }
124 
125 void SwFrameDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
126 {
127  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
128  if (rId == "type")
129  {
130  static_cast<SwFramePage&>(rPage).SetNewFrame(m_bNew);
131  static_cast<SwFramePage&>(rPage).SetFormatUsed(m_bFormat);
132  static_cast<SwFramePage&>(rPage).SetFrameType(m_sDlgType);
133  }
134  else if (rId == "options")
135  {
136  static_cast<SwFrameAddPage&>(rPage).SetFormatUsed(m_bFormat);
137  static_cast<SwFrameAddPage&>(rPage).SetFrameType(m_sDlgType);
138  static_cast<SwFrameAddPage&>(rPage).SetNewFrame(m_bNew);
139  static_cast<SwFrameAddPage&>(rPage).SetShell(m_pWrtShell);
140  }
141  else if (rId == "wrap")
142  {
143  static_cast<SwWrapTabPage&>(rPage).SetNewFrame(m_bNew);
144  static_cast<SwWrapTabPage&>(rPage).SetFormatUsed(m_bFormat, false);
145  static_cast<SwWrapTabPage&>(rPage).SetShell(m_pWrtShell);
146  }
147  else if (rId == "columns")
148  {
149  static_cast<SwColumnPage&>(rPage).SetFrameMode(true);
150  static_cast<SwColumnPage&>(rPage).SetFormatUsed(m_bFormat);
151 
152  const SwFormatFrameSize& rSize = m_rSet.Get( RES_FRM_SIZE );
153  static_cast<SwColumnPage&>(rPage).SetPageWidth( rSize.GetWidth() );
154  }
155  else if (rId == "macro")
156  {
157  SfxAllItemSet aNewSet(*aSet.GetPool());
159  m_sDlgType == "PictureDialog" ? MACASSGN_GRAPHIC : m_sDlgType == "ObjectDialog" ? MACASSGN_OLE : MACASSGN_FRMURL ) );
160  if (m_pWrtShell)
162  rPage.PageCreated(aNewSet);
163  }
164  else if (rId == "borders")
165  {
166  aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME)));
167  rPage.PageCreated(aSet);
168  }
169  // inits for Area and Transparency TabPages
170  // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
171  // the color table) need to be added as items (e.g. SvxColorListItem) to make
172  // these pages find the needed attributes for fill style suggestions.
173  // These are set in preparation to trigger this dialog (FN_FORMAT_FRAME_DLG and
174  // FN_DRAW_WRAP_DLG), but could also be directly added from the DrawModel.
175  else if (rId == "area")
176  {
177  SfxItemSet aNew(*GetInputSetImpl()->GetPool(),
178  svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
179  SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
180 
181  aNew.Put(m_rSet);
182 
183  // add flag for direct graphic content selection
184  aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
185 
186  rPage.PageCreated(aNew);
187  }
188  else if (rId == "transparence")
189  {
190  rPage.PageCreated(m_rSet);
191  }
192 }
193 
194 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
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:43
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2336
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
constexpr TypedWhichId< SwFormatFrameSize > RES_FRM_SIZE(89)
long GetWidth() const
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:351
void RemoveTabPage(const OString &rName)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: wrap.cxx:114
SfxItemSet * GetInputSetImpl()
bool m_bNew
Definition: frmdlg.hxx:32
OUString m_sDlgType
Definition: frmdlg.hxx:34
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: frmdlg.cxx:125
const SwView & GetView() const
Definition: wrtsh.hxx:428
virtual CreateTabPage GetTabPageCreatorFunc(sal_uInt16 nId)=0
SfxFrame & GetFrame() const
const SfxItemSet & m_rSet
Definition: frmdlg.hxx:33
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:38
bool m_bFormat
Definition: frmdlg.hxx:31
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:337
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:831
SwWrtShell * m_pWrtShell
Definition: frmdlg.hxx:35
OUString SwResId(const char *pId)
Definition: swmodule.cxx:178
SfxItemPool * GetPool() const
SwDocShell * GetDocShell()
Definition: view.cxx:1107
const css::uno::Reference< css::frame::XFrame > & GetFrameInterface() const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
virtual GetTabPageRanges GetTabPageRangesFunc(sal_uInt16 nId)=0
const SfxPoolItem & Get(sal_uInt16 nWhich, bool bSrchInParent=true) const
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
Reference< XExecutableDialog > m_xDialog
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2760
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2827
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:591
virtual ~SwFrameDlg() override
Definition: frmdlg.cxx:121
Definition: view.hxx:144
void SetCurPageId(const OString &rName)