Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <cmdid.h>
30 : : #include <swtypes.hxx>
31 : : #include <sfx2/basedlgs.hxx>
32 : : #include <sfx2/dispatch.hxx>
33 : : #include <vcl/msgbox.hxx>
34 : : #include <svx/htmlmode.hxx>
35 : : #include <viewopt.hxx>
36 : : #include <docsh.hxx>
37 : : #include <fldwrap.hxx>
38 : : #include <wrtsh.hxx>
39 : : #include <view.hxx>
40 : : #include <swmodule.hxx>
41 : :
42 : : #include <helpid.h>
43 : : #include <fldui.hrc>
44 : : #include <globals.hrc>
45 : : #include <fldtdlg.hrc>
46 : : #include "swabstdlg.hxx"
47 : :
48 [ + - ][ # # ]: 32289 : SFX_IMPL_CHILDWINDOW_WITHID(SwFldDlgWrapper, FN_INSERT_FIELD)
49 : :
50 : 0 : SwChildWinWrapper::SwChildWinWrapper(Window *pParentWindow, sal_uInt16 nId) :
51 : : SfxChildWindow(pParentWindow, nId),
52 [ # # ]: 0 : m_pDocSh(0)
53 : : {
54 : : // avoid flickering of buttons:
55 [ # # ]: 0 : m_aUpdateTimer.SetTimeout(200);
56 [ # # ]: 0 : m_aUpdateTimer.SetTimeoutHdl(LINK(this, SwChildWinWrapper, UpdateHdl));
57 : 0 : }
58 : :
59 : 0 : IMPL_LINK_NOARG(SwChildWinWrapper, UpdateHdl)
60 : : {
61 : 0 : GetWindow()->Activate(); // update dialog
62 : :
63 : 0 : return 0;
64 : : }
65 : :
66 : : /*--------------------------------------------------------------------
67 : : Description: newly initialise dialog after Doc switch
68 : : --------------------------------------------------------------------*/
69 : 0 : sal_Bool SwChildWinWrapper::ReInitDlg(SwDocShell *)
70 : : {
71 : 0 : sal_Bool bRet = sal_False;
72 : :
73 [ # # ]: 0 : if (m_pDocSh != GetOldDocShell())
74 : : {
75 : 0 : m_aUpdateTimer.Stop();
76 : 0 : bRet = sal_True; // immediate Update
77 : : }
78 : : else
79 : 0 : m_aUpdateTimer.Start();
80 : :
81 : 0 : return bRet;
82 : : }
83 : :
84 : 0 : SfxChildWinInfo SwFldDlgWrapper::GetInfo() const
85 : : {
86 : 0 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
87 [ # # ]: 0 : aInfo.aPos = GetWindow()->OutputToAbsoluteScreenPixel(aInfo.aPos);
88 : 0 : return aInfo;
89 : : }
90 : :
91 : 0 : SwFldDlgWrapper::SwFldDlgWrapper( Window* _pParent, sal_uInt16 nId,
92 : : SfxBindings* pB,
93 : : SfxChildWinInfo* )
94 : 0 : : SwChildWinWrapper( _pParent, nId )
95 : : {
96 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
97 : : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
98 : :
99 [ # # ]: 0 : AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
100 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
101 : 0 : pDlgInterface = pDlg;
102 [ # # ]: 0 : pWindow = pDlg->GetWindow();
103 [ # # ]: 0 : pDlg->Start();
104 : 0 : eChildAlignment = SFX_ALIGN_NOALIGNMENT;
105 : 0 : }
106 : :
107 : : /*--------------------------------------------------------------------
108 : : Description: newly initialise dialog after Doc switch
109 : : --------------------------------------------------------------------*/
110 : 0 : sal_Bool SwFldDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
111 : : {
112 : : sal_Bool bRet;
113 : :
114 [ # # ]: 0 : if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
115 : : {
116 : 0 : pDlgInterface->ReInitDlg();
117 : : }
118 : :
119 : 0 : return bRet;
120 : : }
121 : :
122 : 0 : void SwFldDlgWrapper::ShowPage(sal_uInt16 nPage)
123 : : {
124 [ # # ]: 0 : pDlgInterface->ShowPage(nPage ? nPage : TP_FLD_REF);
125 : 0 : }
126 : :
127 [ + - ][ # # ]: 73 : SFX_IMPL_CHILDWINDOW(SwFldDataOnlyDlgWrapper, FN_INSERT_FIELD_DATA_ONLY)
128 : :
129 : 0 : SfxChildWinInfo SwFldDataOnlyDlgWrapper::GetInfo() const
130 : : {
131 : 0 : SfxChildWinInfo aInfo = SfxChildWindow::GetInfo();
132 : : // prevent instatiation of dialog other than by calling
133 : : // the mail merge dialog
134 : 0 : aInfo.bVisible = sal_False;
135 : 0 : return aInfo;
136 : : }
137 : :
138 : 0 : SwFldDataOnlyDlgWrapper::SwFldDataOnlyDlgWrapper( Window* _pParent, sal_uInt16 nId,
139 : : SfxBindings* pB,
140 : : SfxChildWinInfo* pInfo )
141 : 0 : : SwChildWinWrapper( _pParent, nId )
142 : : {
143 [ # # ]: 0 : SwAbstractDialogFactory* pFact = SwAbstractDialogFactory::Create();
144 : : OSL_ENSURE(pFact, "SwAbstractDialogFactory fail!");
145 : :
146 [ # # ]: 0 : AbstractSwFldDlg* pDlg = pFact->CreateSwFldDlg(pB, this, _pParent, DLG_FLD_INSERT );
147 : : OSL_ENSURE(pDlg, "Dialogdiet fail!");
148 : 0 : pDlgInterface = pDlg;
149 : :
150 [ # # ]: 0 : pWindow = pDlg->GetWindow();
151 [ # # ]: 0 : pDlg->ActivateDatabasePage();
152 [ # # ]: 0 : pDlg->Start();
153 [ # # ]: 0 : pDlg->Initialize( pInfo );
154 : 0 : eChildAlignment = SFX_ALIGN_NOALIGNMENT;
155 : 0 : }
156 : :
157 : : /* --------------------------------------------------
158 : : * re-init after doc activation
159 : : * --------------------------------------------------*/
160 : 0 : sal_Bool SwFldDataOnlyDlgWrapper::ReInitDlg(SwDocShell *pDocSh)
161 : : {
162 : : sal_Bool bRet;
163 [ # # ]: 0 : if ((bRet = SwChildWinWrapper::ReInitDlg(pDocSh)) == sal_True) // update immediately, Doc switch
164 : : {
165 : 0 : pDlgInterface->ReInitDlg();
166 : : }
167 : :
168 : 0 : return bRet;
169 : : }
170 : :
171 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|