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 <sfx2/basedlgs.hxx>
22 #include <docsh.hxx>
23 #include <fldwrap.hxx>
24 
25 #include <swabstdlg.hxx>
26 
28 
29 SwChildWinWrapper::SwChildWinWrapper(vcl::Window *pParentWindow, sal_uInt16 nId) :
30  SfxChildWindow(pParentWindow, nId),
31  m_pDocSh(nullptr)
32 {
33  // avoid flickering of buttons:
34  m_aUpdateTimer.SetTimeout(200);
35  m_aUpdateTimer.SetInvokeHandler(LINK(this, SwChildWinWrapper, UpdateHdl));
36 }
37 
39 {
40  if (GetController())
41  GetController()->Activate(); // update dialog
42 }
43 
44 // newly initialise dialog after Doc switch
46 {
47  bool bRet = false;
48 
49  if (m_pDocSh != GetOldDocShell())
50  {
52  bRet = true; // immediate Update
53  }
54  else
56 
57  return bRet;
58 }
59 
61 {
63  return aInfo;
64 }
65 
67  SfxBindings* pB,
69  : SwChildWinWrapper( _pParent, nId )
70 {
72  pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
73  SetController(pDlgInterface->GetController());
74  pDlgInterface->StartExecuteAsync(nullptr);
75 }
76 
77 // newly initialise dialog after Doc switch
79 {
80  bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
81  if (bRet) // update immediately, Doc switch
82  {
83  pDlgInterface->ReInitDlg();
84  }
85 
86  return bRet;
87 }
88 
90 {
91  pDlgInterface->ShowReferencePage();
92 }
93 
95 
97 {
99 // prevent instantiation of dialog other than by calling
100 // the mail merge dialog
101  aInfo.bVisible = false;
102  return aInfo;
103 }
104 
106  SfxBindings* pB,
107  SfxChildWinInfo* pInfo )
108  : SwChildWinWrapper( _pParent, nId )
109 {
111  pDlgInterface = pFact->CreateSwFieldDlg(pB, this, _pParent->GetFrameWeld());
112 
113  SetController(pDlgInterface->GetController());
114  pDlgInterface->ActivateDatabasePage();
115  pDlgInterface->StartExecuteAsync(nullptr);
116  pDlgInterface->Initialize( pInfo );
117 }
118 
119 // re-init after doc activation
121 {
122  bool bRet = SwChildWinWrapper::ReInitDlg(pDocSh);
123  if (bRet) // update immediately, Doc switch
124  {
125  pDlgInterface->ReInitDlg();
126  }
127 
128  return bRet;
129 }
130 
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
SwDocShell * m_pDocSh
Definition: chldwrap.hxx:30
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: fldwrap.cxx:120
ScopedVclPtr< AbstractSwFieldDlg > pDlgInterface
Definition: fldwrap.hxx:31
SwDocShell * GetOldDocShell()
Definition: chldwrap.hxx:41
virtual bool ReInitDlg(SwDocShell *pDocSh) override
Definition: fldwrap.cxx:78
weld::Window * GetFrameWeld() const
#define FN_INSERT_FIELD_DATA_ONLY
Definition: cmdid.h:210
ScopedVclPtr< AbstractSwFieldDlg > pDlgInterface
Definition: fldwrap.hxx:45
SwFieldDataOnlyDlgWrapper(vcl::Window *pParent, sal_uInt16 nId, SfxBindings *pBindings, SfxChildWinInfo *pInfo)
Definition: fldwrap.cxx:105
void ShowReferencePage()
Definition: fldwrap.cxx:89
IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl, Timer *, void)
Definition: fldwrap.cxx:38
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:66
SFX_IMPL_CHILDWINDOW(SvxRubyChildWindow, SID_RUBY_DIALOG)
#define FN_INSERT_FIELD
Definition: cmdid.h:198
void Stop()
void SetController(std::shared_ptr< SfxDialogController > controller)
virtual bool ReInitDlg(SwDocShell *pDocSh)
Definition: fldwrap.cxx:45
virtual SfxChildWinInfo GetInfo() const