LibreOffice Module sw (master)  1
fldwrap.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 <cmdid.h>
21 #include <swtypes.hxx>
22 #include <sfx2/basedlgs.hxx>
23 #include <sfx2/dispatch.hxx>
24 #include <sfx2/htmlmode.hxx>
25 #include <viewopt.hxx>
26 #include <docsh.hxx>
27 #include <fldwrap.hxx>
28 #include <wrtsh.hxx>
29 #include <view.hxx>
30 #include <swmodule.hxx>
31 
32 #include <globals.hrc>
33 #include <swabstdlg.hxx>
34 
36 
37 SwChildWinWrapper::SwChildWinWrapper(vcl::Window *pParentWindow, sal_uInt16 nId) :
38  SfxChildWindow(pParentWindow, nId),
39  m_pDocSh(nullptr)
40 {
41  // avoid flickering of buttons:
42  m_aUpdateTimer.SetTimeout(200);
43  m_aUpdateTimer.SetInvokeHandler(LINK(this, SwChildWinWrapper, UpdateHdl));
44 }
45 
47 {
48  if (GetController())
49  GetController()->Activate(); // update dialog
50 }
51 
52 // newly initialise dialog after Doc switch
54 {
55  bool bRet = false;
56 
57  if (m_pDocSh != GetOldDocShell())
58  {
60  bRet = true; // immediate Update
61  }
62  else
64 
65  return bRet;
66 }
67 
69 {
71  return aInfo;
72 }
73 
75  SfxBindings* pB,
77  : SwChildWinWrapper( _pParent, nId )
78 {
80  pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
81  SetController(pDlgInterface->GetController());
82  pDlgInterface->StartExecuteAsync(nullptr);
83 }
84 
85 // newly initialise dialog after Doc switch
87 {
88  bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
89  if (bRet) // update immediately, Doc switch
90  {
91  pDlgInterface->ReInitDlg();
92  }
93 
94  return bRet;
95 }
96 
98 {
99  pDlgInterface->ShowReferencePage();
100 }
101 
103 
105 {
107 // prevent instantiation of dialog other than by calling
108 // the mail merge dialog
109  aInfo.bVisible = false;
110  return aInfo;
111 }
112 
114  SfxBindings* pB,
115  SfxChildWinInfo* pInfo )
116  : SwChildWinWrapper( _pParent, nId )
117 {
119  pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
120 
121  SetController(pDlgInterface->GetController());
122  pDlgInterface->ActivateDatabasePage();
123  pDlgInterface->StartExecuteAsync(nullptr);
124  pDlgInterface->Initialize( pInfo );
125 }
126 
127 // re-init after doc activation
129 {
130  bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
131  if (bRet) // update immediately, Doc switch
132  {
133  pDlgInterface->ReInitDlg();
134  }
135 
136  return bRet;
137 }
138 
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwDocShell * m_pDocSh
Definition: chldwrap.hxx:30
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: fldwrap.cxx:128
ScopedVclPtr< AbstractSwFieldDlg > pDlgInterface
Definition: fldwrap.hxx:31
SwDocShell * GetOldDocShell()
Definition: chldwrap.hxx:41
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: fldwrap.cxx:86
weld::Window * GetFrameWeld() const
#define FN_INSERT_FIELD_DATA_ONLY
Definition: cmdid.h:202
ScopedVclPtr< AbstractSwFieldDlg > pDlgInterface
Definition: fldwrap.hxx:45
SwFieldDataOnlyDlgWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: fldwrap.cxx:113
void ShowReferencePage()
Definition: fldwrap.cxx:97
IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl, Timer *, void)
Definition: fldwrap.cxx:46
virtual void Start() override
virtual VclPtr< AbstractSwFieldDlg > CreateSwFieldDlg(SfxBindings *pB, SwChildWinWrapper *pCW, weld::Window *pParent)=0
SFX_IMPL_CHILDWINDOW_WITHID(SearchResultsDlgWrapper, SID_SEARCH_RESULTS_DIALOG)
static SwAbstractDialogFactory * Create()
Definition: swabstdlg.cxx:36
Timer m_aUpdateTimer
Definition: chldwrap.hxx:29
SwFieldDlgWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: fldwrap.cxx:74
SFX_IMPL_CHILDWINDOW(SvxRubyChildWindow, SID_RUBY_DIALOG)
#define FN_INSERT_FIELD
Definition: cmdid.h:190
void Stop()
void SetController(std::shared_ptr< SfxDialogController > controller)
virtual bool ReInitDlg(SwDocShell *pDocSh)
Definition: fldwrap.cxx:53
virtual SfxChildWinInfo GetInfo() const