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/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 <globals.hrc>
37 #include <strings.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 // the dialog's carrier
48  weld::Window* pParent,
49  const SfxItemSet& rCoreSet,
50  bool bNewFrame,
51  const OUString& sResType,
52  bool bFormat,
53  const OString& sDefPage,
54  const OUString* pStr)
55 
56  : SfxTabDialogController(pParent, "modules/swriter/ui/" + sResType.toAsciiLowerCase() + ".ui",
57  sResType.toUtf8(), &rCoreSet, pStr != nullptr)
58  , m_bFormat(bFormat)
59  , m_bNew(bNewFrame)
60  , m_rSet(rCoreSet)
61  , m_sDlgType(sResType)
62  , m_pWrtShell(static_cast<SwView*>(pViewFrame->GetViewShell())->GetWrtShellPtr())
63 {
64  sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
65  bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
66 
67  // example font for both example TabPages
68 
69  if (pStr)
70  {
71  m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_FRMUI_COLL_HEADER) + *pStr + ")");
72  }
73 
74  AddTabPage("type", SwFramePage::Create, nullptr);
75  AddTabPage("options", SwFrameAddPage::Create, nullptr);
76  AddTabPage("wrap", SwWrapTabPage::Create, nullptr);
77  AddTabPage("hyperlink", SwFrameURLPage::Create, nullptr);
78  if (m_sDlgType == "PictureDialog")
79  {
80  AddTabPage("picture", SwGrfExtPage::Create, nullptr);
81  AddTabPage("crop", RID_SVXPAGE_GRFCROP);
82  }
83  if (m_sDlgType == "FrameDialog")
84  {
85  AddTabPage("columns", SwColumnPage::Create, nullptr);
86  }
88 
89  // add Area and Transparence TabPages
90  AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
91  AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
92 
93  AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), nullptr);
94  AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr);
95 
96  if(bHTMLMode)
97  {
98  if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
99  {
100  if (m_sDlgType == "FrameDialog")
101  RemoveTabPage("columns");
102  RemoveTabPage("hyperlink");
103  RemoveTabPage("macro");
104  }
105  else if (m_sDlgType == "PictureDialog")
106  RemoveTabPage("crop");
107  if( m_sDlgType != "FrameDialog" )
108  {
109  // RemoveTabPage("background");
110  RemoveTabPage("area");
111  RemoveTabPage("transparence");
112  }
113  }
114 
115  if (m_bNew)
116  SetCurPageId("type");
117 
118  if (!sDefPage.isEmpty())
119  SetCurPageId(sDefPage);
120 }
121 
123 {
124 }
125 
126 void 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  SfxItemSet aNew(*GetInputSetImpl()->GetPool(),
179  svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
180  SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
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 }
194 
195 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
#define RES_FRM_SIZE
Definition: hintids.hxx:196
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:47
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2331
bool const m_bNew
Definition: frmdlg.hxx:32
virtual void PageCreated(const SfxAllItemSet &aSet)
static SfxAbstractDialogFactory * Create()
long GetWidth() const
void SetShell(SwViewShell *pSh)
Definition: newfrm.cxx:352
void RemoveTabPage(const OString &rName)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: wrap.cxx:117
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: frmdlg.cxx:126
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
OUString const m_sDlgType
Definition: frmdlg.hxx:34
void SetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame)
static SfxEventNamesItem AddEvents(DlgEventType eType)
Definition: macassgn.cxx:43
HTMLMODE_ON
sal_uInt16 GetHtmlMode(const SwDocShell *pShell)
Definition: viewopt.cxx:340
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:828
SwWrtShell * m_pWrtShell
Definition: frmdlg.hxx:35
OUString SwResId(const char *pId)
Definition: swmodule.cxx:190
SfxItemPool * GetPool() const
SwDocShell * GetDocShell()
Definition: view.cxx:1128
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)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2755
bool const m_bFormat
Definition: frmdlg.hxx:31
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: frmpage.cxx:2822
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: column.cxx:601
virtual ~SwFrameDlg() override
Definition: frmdlg.cxx:122
Definition: view.hxx:146
void SetCurPageId(const OString &rName)