LibreOffice Module extensions (master) 1
bibview.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
21#include <strings.hrc>
22#include "general.hxx"
23#include "bibview.hxx"
24#include "datman.hxx"
25#include "bibresid.hxx"
26#include "bibmod.hxx"
27#include "bibconfig.hxx"
28
29
30#include <vcl/svapp.hxx>
31#include <vcl/weld.hxx>
32
33using namespace ::com::sun::star;
34using namespace ::com::sun::star::form;
35using namespace ::com::sun::star::beans;
36using namespace ::com::sun::star::lang;
37using namespace ::com::sun::star::uno;
38
39namespace
40{
41 class MessageWithCheck : public weld::MessageDialogController
42 {
43 private:
44 std::unique_ptr<weld::CheckButton> m_xWarningOnBox;
45 public:
46 MessageWithCheck(weld::Window *pParent)
47 : MessageDialogController(pParent, "modules/sbibliography/ui/querydialog.ui", "QueryDialog", "ask")
48 , m_xWarningOnBox(m_xBuilder->weld_check_button("ask"))
49 {
50 }
51 bool get_active() const { return m_xWarningOnBox->get_active(); }
52 };
53}
54
55namespace bib
56{
57
58
59 BibView::BibView( vcl::Window* _pParent, BibDataManager* _pManager, WinBits _nStyle )
60 :BibWindow( _pParent, _nStyle )
61 ,m_pDatMan( _pManager )
62 ,m_xDatMan( _pManager )
63 ,m_pGeneralPage( nullptr )
64 ,m_aFormControlContainer(this)
65 {
66 if ( m_xDatMan.is() )
68 }
69
70
72 {
74 }
75
77 {
80 pGeneralPage.disposeAndClear(); // dispose will commit any uncommitted weld::Entry changes
81
84
86 }
87
89 {
90 // TODO:
91 // this is _strange_: Why not updating the existent general page?
92 // I consider the current behaviour a HACK.
93 if ( m_pGeneralPage )
94 {
95 m_pGeneralPage->Hide();
97 }
98
100 m_pGeneralPage->Show();
101
102 if( HasFocus() )
103 // "delayed" GetFocus() because GetFocus() is initially called before GeneralPage is created
104 m_pGeneralPage->GrabFocus();
105
106 OUString sErrorString( m_pGeneralPage->GetErrorString() );
107 if ( sErrorString.isEmpty() )
108 return;
109
112 {
113 //no connection is available -> the data base has to be assigned
115 bExecute = false;
116 }
117 else if(bExecute)
118 {
119 sErrorString += "\n" + BibResId(RID_MAP_QUESTION);
120
121 MessageWithCheck aQueryBox(GetFrameWeld());
122 aQueryBox.set_primary_text(sErrorString);
123
124 short nResult = aQueryBox.run();
125 BibModul::GetConfig()->SetShowColumnAssignmentWarning(!aQueryBox.get_active());
126
127 if( RET_YES != nResult )
128 {
129 bExecute = false;
130 }
131 }
132 if(bExecute)
133 {
134 Application::PostUserEvent( LINK( this, BibView, CallMappingHdl ), nullptr, true );
135 }
136 }
137
139
140 void BibViewFormControlContainer::_loaded( const EventObject& _rEvent )
141 {
142 mpBibView->UpdatePages();
144 mpBibView->Resize();
145 }
146
147 void BibViewFormControlContainer::_reloaded( const EventObject& _rEvent )
148 {
149 mpBibView->UpdatePages();
151 mpBibView->Resize();
152 }
153
154 IMPL_LINK_NOARG( BibView, CallMappingHdl, void*, void)
155 {
156 m_pDatMan->CreateMappingDialog(GetFrameWeld());
157 }
158
160 {
161 if ( m_pGeneralPage )
162 {
163 ::Size aSz( GetOutputSizePixel() );
164 m_pGeneralPage->SetSizePixel( aSz );
165 }
166 Window::Resize();
167 }
168
169 Reference< awt::XControlContainer > BibViewFormControlContainer::getControlContainer()
170 {
171 return nullptr;
172 }
173
175 {
176 if( m_pGeneralPage )
177 m_pGeneralPage->GrabFocus();
178 }
179
180 bool BibView::HandleShortCutKey( const KeyEvent& rKeyEvent )
181 {
182 return m_pGeneralPage && m_pGeneralPage->HandleShortCutKey( rKeyEvent );
183 }
184
185
186} // namespace bib
187
188
189/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
OUString BibResId(TranslateId aId)
Definition: bibmod.cxx:57
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
void SetShowColumnAssignmentWarning(bool bSet)
Definition: bibconfig.hxx:138
bool IsShowColumnAssignmentWarning() const
Definition: bibconfig.hxx:136
void DispatchDBChangeDialog()
Definition: datman.cxx:1330
bool HasActiveConnection() const
Definition: datman.cxx:1390
static BibConfig * GetConfig()
Definition: bibmod.cxx:82
void disposeAndClear()
void clear()
static VclPtr< reference_type > Create(Arg &&... arg)
BibViewFormControlContainer(BibView *pBibView)
Definition: bibview.cxx:138
void connectForm(const css::uno::Reference< css::form::XLoadable > &_rxForm)
virtual void _loaded(const css::lang::EventObject &_rEvent) override
Definition: bibview.cxx:140
virtual void _reloaded(const css::lang::EventObject &_rEvent) override
Definition: bibview.cxx:147
virtual css::uno::Reference< css::awt::XControlContainer > getControlContainer() override
Definition: bibview.cxx:169
VclPtr< BibView > mpBibView
Definition: bibview.hxx:36
virtual bool HandleShortCutKey(const KeyEvent &rKeyEvent) override
Definition: bibview.cxx:180
virtual void Resize() override
Definition: bibview.cxx:159
virtual void GetFocus() override
Definition: bibview.cxx:174
virtual void dispose() override
Definition: bibview.cxx:76
BibView(vcl::Window *_pParent, BibDataManager *_pDatMan, WinBits nStyle)
Definition: bibview.cxx:59
VclPtr< BibGeneralPage > m_pGeneralPage
Definition: bibview.hxx:56
virtual ~BibView() override
Definition: bibview.cxx:71
BibViewFormControlContainer m_aFormControlContainer
Definition: bibview.hxx:57
BibDataManager * m_pDatMan
Definition: bibview.hxx:54
void UpdatePages()
Definition: bibview.cxx:88
css::uno::Reference< css::form::XLoadable > m_xDatMan
Definition: bibview.hxx:55
virtual void _loaded(const css::lang::EventObject &_rEvent) override
virtual void dispose() override
bool HasFocus() const
Size GetOutputSizePixel() const
weld::Window * GetFrameWeld() const
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
Definition: bibbeam.cxx:40
IMPL_LINK_NOARG(BibBeamer, RecalcLayout_Impl, void *, void)
Definition: bibbeam.cxx:259
RET_YES
sal_Int64 WinBits
std::unique_ptr< weld::CheckButton > m_xWarningOnBox