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 
41 // the dialog's carrier
43  weld::Window* pParent,
44  const SfxItemSet& rCoreSet,
45  bool bNewFrame,
46  const OUString& sResType,
47  bool bFormat,
48  const OString& sDefPage,
49  const OUString* pStr)
50 
51  : SfxTabDialogController(pParent, "modules/swriter/ui/" + sResType.toAsciiLowerCase() + ".ui",
52  sResType.toUtf8(), &rCoreSet, pStr != nullptr)
53  , m_bFormat(bFormat)
54  , m_bNew(bNewFrame)
55  , m_rSet(rCoreSet)
56  , m_sDlgType(sResType)
57  , m_pWrtShell(static_cast<SwView*>(pViewFrame->GetViewShell())->GetWrtShellPtr())
58 {
59  sal_uInt16 nHtmlMode = ::GetHtmlMode(m_pWrtShell->GetView().GetDocShell());
60  bool bHTMLMode = (nHtmlMode & HTMLMODE_ON) != 0;
61 
62  // example font for both example TabPages
63 
64  if (pStr)
65  {
66  m_xDialog->set_title(m_xDialog->get_title() + SwResId(STR_FRMUI_COLL_HEADER) + *pStr + ")");
67  }
68 
69  AddTabPage("type", SwFramePage::Create, nullptr);
70  AddTabPage("options", SwFrameAddPage::Create, nullptr);
71  AddTabPage("wrap", SwWrapTabPage::Create, nullptr);
72  AddTabPage("hyperlink", SwFrameURLPage::Create, nullptr);
73  if (m_sDlgType == "PictureDialog")
74  {
75  AddTabPage("picture", SwGrfExtPage::Create, nullptr);
76  AddTabPage("crop", RID_SVXPAGE_GRFCROP);
77  }
78  if (m_sDlgType == "FrameDialog")
79  {
80  AddTabPage("columns", SwColumnPage::Create, nullptr);
81  }
83 
84  // add Area and Transparence TabPages
85  AddTabPage("area", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_AREA ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_AREA ));
86  AddTabPage("transparence", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_TRANSPARENCE ), pFact->GetTabPageRangesFunc( RID_SVXPAGE_TRANSPARENCE ) );
87 
88  AddTabPage("macro", pFact->GetTabPageCreatorFunc(RID_SVXPAGE_MACROASSIGN), nullptr);
89  AddTabPage("borders", pFact->GetTabPageCreatorFunc( RID_SVXPAGE_BORDER ), nullptr);
90 
91  if(bHTMLMode)
92  {
93  if (m_sDlgType == "FrameDialog" || m_sDlgType == "ObjectDialog")
94  {
95  if (m_sDlgType == "FrameDialog")
96  RemoveTabPage("columns");
97  RemoveTabPage("hyperlink");
98  RemoveTabPage("macro");
99  }
100  else if (m_sDlgType == "PictureDialog")
101  RemoveTabPage("crop");
102  if( m_sDlgType != "FrameDialog" )
103  {
104  // RemoveTabPage("background");
105  RemoveTabPage("area");
106  RemoveTabPage("transparence");
107  }
108  }
109 
110  if (m_bNew)
111  SetCurPageId("type");
112 
113  if (!sDefPage.isEmpty())
114  SetCurPageId(sDefPage);
115 }
116 
118 {
119 }
120 
121 void SwFrameDlg::PageCreated(const OString& rId, SfxTabPage &rPage)
122 {
123  SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
124  if (rId == "type")
125  {
126  static_cast<SwFramePage&>(rPage).SetNewFrame(m_bNew);
127  static_cast<SwFramePage&>(rPage).SetFormatUsed(m_bFormat);
128  static_cast<SwFramePage&>(rPage).SetFrameType(m_sDlgType);
129  }
130  else if (rId == "options")
131  {
132  static_cast<SwFrameAddPage&>(rPage).SetFormatUsed(m_bFormat);
133  static_cast<SwFrameAddPage&>(rPage).SetFrameType(m_sDlgType);
134  static_cast<SwFrameAddPage&>(rPage).SetNewFrame(m_bNew);
135  static_cast<SwFrameAddPage&>(rPage).SetShell(m_pWrtShell);
136  }
137  else if (rId == "wrap")
138  {
139  static_cast<SwWrapTabPage&>(rPage).SetNewFrame(m_bNew);
140  static_cast<SwWrapTabPage&>(rPage).SetFormatUsed(m_bFormat, false);
141  static_cast<SwWrapTabPage&>(rPage).SetShell(m_pWrtShell);
142  }
143  else if (rId == "columns")
144  {
145  static_cast<SwColumnPage&>(rPage).SetFrameMode(true);
146  static_cast<SwColumnPage&>(rPage).SetFormatUsed(m_bFormat);
147 
148  const SwFormatFrameSize& rSize = m_rSet.Get( RES_FRM_SIZE );
149  static_cast<SwColumnPage&>(rPage).SetPageWidth( rSize.GetWidth() );
150  }
151  else if (rId == "macro")
152  {
153  SfxAllItemSet aNewSet(*aSet.GetPool());
155  m_sDlgType == "PictureDialog" ? MACASSGN_GRAPHIC : m_sDlgType == "ObjectDialog" ? MACASSGN_OLE : MACASSGN_FRMURL ) );
156  if (m_pWrtShell)
158  rPage.PageCreated(aNewSet);
159  }
160  else if (rId == "borders")
161  {
162  aSet.Put (SfxUInt16Item(SID_SWMODE_TYPE,static_cast<sal_uInt16>(SwBorderModes::FRAME)));
163  rPage.PageCreated(aSet);
164  }
165  // inits for Area and Transparency TabPages
166  // The selection attribute lists (XPropertyList derivates, e.g. XColorList for
167  // the color table) need to be added as items (e.g. SvxColorListItem) to make
168  // these pages find the needed attributes for fill style suggestions.
169  // These are set in preparation to trigger this dialog (FN_FORMAT_FRAME_DLG and
170  // FN_DRAW_WRAP_DLG), but could also be directly added from the DrawModel.
171  else if (rId == "area")
172  {
173  SfxItemSet aNew(*GetInputSetImpl()->GetPool(),
174  svl::Items<SID_COLOR_TABLE, SID_PATTERN_LIST,
175  SID_OFFER_IMPORT, SID_OFFER_IMPORT>{});
176 
177  aNew.Put(m_rSet);
178 
179  // add flag for direct graphic content selection
180  aNew.Put(SfxBoolItem(SID_OFFER_IMPORT, true));
181 
182  rPage.PageCreated(aNew);
183  }
184  else if (rId == "transparence")
185  {
186  rPage.PageCreated(m_rSet);
187  }
188 }
189 
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SfxViewFrame * GetViewFrame() const
#define RES_FRM_SIZE
Definition: hintids.hxx:289
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:42
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()
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: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:121
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:117
Definition: view.hxx:146
void SetCurPageId(const OString &rName)