LibreOffice Module extensions (master) 1
general.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
21#include <com/sun/star/beans/XPropertyChangeListener.hpp>
22#include <com/sun/star/form/XBoundComponent.hpp>
23#include <com/sun/star/sdbc/XRowSet.hpp>
24#include <com/sun/star/sdb/XColumn.hpp>
25#include <com/sun/star/sdb/CommandType.hpp>
26#include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
27#include <com/sun/star/uri/UriReferenceFactory.hpp>
28
29#include <o3tl/safeint.hxx>
30#include <o3tl/string_view.hxx>
31#include <sal/log.hxx>
32#include <osl/diagnose.h>
34#include <utility>
35#include <vcl/event.hxx>
36#include <vcl/mnemonic.hxx>
37#include "general.hxx"
38#include "bibresid.hxx"
39#include "datman.hxx"
40#include "bibconfig.hxx"
41#include <strings.hrc>
42#include "bibmod.hxx"
43#include <helpids.h>
44#include <algorithm>
46#include <sfx2/objsh.hxx>
47
48using namespace ::com::sun::star;
49using namespace ::com::sun::star::uno;
50using namespace ::com::sun::star::form;
51using namespace ::com::sun::star::sdb;
52
53namespace
54{
56bool SplitUrlAndPage(const OUString& rText, OUString& rUrl, int& nPageNumber)
57{
58 uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
59 = uri::UriReferenceFactory::create(comphelper::getProcessComponentContext());
60 uno::Reference<uri::XUriReference> xUriRef;
61 try
62 {
63 xUriRef = xUriReferenceFactory->parse(rText);
64 }
65 catch (const uno::Exception& rException)
66 {
67 SAL_WARN("extensions.biblio",
68 "SplitUrlAndPage: failed to parse url: " << rException.Message);
69 return false;
70 }
71
72 OUString aPagePrefix("page=");
73 if (!xUriRef->getFragment().startsWith(aPagePrefix))
74 {
75 return false;
76 }
77
78 nPageNumber = o3tl::toInt32(xUriRef->getFragment().subView(aPagePrefix.getLength()));
79 xUriRef->clearFragment();
80 rUrl = xUriRef->getUriReference();
81 return true;
82}
83
85OUString MergeUrlAndPage(const OUString& rUrl, const weld::SpinButton& rPageSB)
86{
87 if (!rPageSB.get_sensitive())
88 {
89 return rUrl;
90 }
91
92 uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
93 = uri::UriReferenceFactory::create(comphelper::getProcessComponentContext());
94 uno::Reference<uri::XUriReference> xUriRef;
95 try
96 {
97 xUriRef = xUriReferenceFactory->parse(rUrl);
98 }
99 catch (const uno::Exception& rException)
100 {
101 SAL_WARN("extensions.biblio",
102 "MergeUrlAndPage: failed to parse url: " << rException.Message);
103 return rUrl;
104 }
105
106 OUString aFragment("page=" + OUString::number(rPageSB.get_value()));
107 xUriRef->setFragment(aFragment);
108 return xUriRef->getUriReference();
109}
110}
111
112static OUString lcl_GetColumnName( const Mapping* pMapping, sal_uInt16 nIndexPos )
113{
114 BibConfig* pBibConfig = BibModul::GetConfig();
115 OUString sRet = pBibConfig->GetDefColumnName(nIndexPos);
116 if(pMapping)
117 for(const auto & aColumnPair : pMapping->aColumnPairs)
118 {
119 if(aColumnPair.sLogicalColumnName == sRet)
120 {
121 sRet = aColumnPair.sRealColumnName;
122 break;
123 }
124 }
125 return sRet;
126}
127
129 : InterimItemWindow(pParent, "modules/sbibliography/ui/generalpage.ui", "GeneralPage")
130 , BibShortCutHandler(this)
131 , xScrolledWindow(m_xBuilder->weld_scrolled_window("scrolledwindow"))
132 , xGrid(m_xBuilder->weld_widget("grid"))
133 , xIdentifierFT(m_xBuilder->weld_label("shortname"))
134 , xIdentifierED(m_xBuilder->weld_entry("shortnamecontrol"))
135 , xAuthTypeFT(m_xBuilder->weld_label("authtype"))
136 , xAuthTypeLB(m_xBuilder->weld_combo_box("authtypecontrol"))
137 , xYearFT(m_xBuilder->weld_label("year"))
138 , xYearED(m_xBuilder->weld_entry("yearcontrol"))
139 , xAuthorFT(m_xBuilder->weld_label("authors"))
140 , xAuthorED(m_xBuilder->weld_entry("authorscontrol"))
141 , xTitleFT(m_xBuilder->weld_label("title"))
142 , xTitleED(m_xBuilder->weld_entry("titlecontrol"))
143 , xPublisherFT(m_xBuilder->weld_label("publisher"))
144 , xPublisherED(m_xBuilder->weld_entry("publishercontrol"))
145 , xAddressFT(m_xBuilder->weld_label("address"))
146 , xAddressED(m_xBuilder->weld_entry("addresscontrol"))
147 , xISBNFT(m_xBuilder->weld_label("isbn"))
148 , xISBNED(m_xBuilder->weld_entry("isbncontrol"))
149 , xChapterFT(m_xBuilder->weld_label("chapter"))
150 , xChapterED(m_xBuilder->weld_entry("chaptercontrol"))
151 , xPagesFT(m_xBuilder->weld_label("pages"))
152 , xPagesED(m_xBuilder->weld_entry("pagescontrol"))
153 , xEditorFT(m_xBuilder->weld_label("editor"))
154 , xEditorED(m_xBuilder->weld_entry("editorcontrol"))
155 , xEditionFT(m_xBuilder->weld_label("edition"))
156 , xEditionED(m_xBuilder->weld_entry("editioncontrol"))
157 , xBooktitleFT(m_xBuilder->weld_label("booktitle"))
158 , xBooktitleED(m_xBuilder->weld_entry("booktitlecontrol"))
159 , xVolumeFT(m_xBuilder->weld_label("volume"))
160 , xVolumeED(m_xBuilder->weld_entry("volumecontrol"))
161 , xHowpublishedFT(m_xBuilder->weld_label("publicationtype"))
162 , xHowpublishedED(m_xBuilder->weld_entry("publicationtypecontrol"))
163 , xOrganizationsFT(m_xBuilder->weld_label("organization"))
164 , xOrganizationsED(m_xBuilder->weld_entry("organizationcontrol"))
165 , xInstitutionFT(m_xBuilder->weld_label("institution"))
166 , xInstitutionED(m_xBuilder->weld_entry("institutioncontrol"))
167 , xSchoolFT(m_xBuilder->weld_label("university"))
168 , xSchoolED(m_xBuilder->weld_entry("universitycontrol"))
169 , xReportTypeFT(m_xBuilder->weld_label("reporttype"))
170 , xReportTypeED(m_xBuilder->weld_entry("reporttypecontrol"))
171 , xMonthFT(m_xBuilder->weld_label("month"))
172 , xMonthED(m_xBuilder->weld_entry("monthcontrol"))
173 , xJournalFT(m_xBuilder->weld_label("journal"))
174 , xJournalED(m_xBuilder->weld_entry("journalcontrol"))
175 , xNumberFT(m_xBuilder->weld_label("number"))
176 , xNumberED(m_xBuilder->weld_entry("numbercontrol"))
177 , xSeriesFT(m_xBuilder->weld_label("series"))
178 , xSeriesED(m_xBuilder->weld_entry("seriescontrol"))
179 , xAnnoteFT(m_xBuilder->weld_label("annotation"))
180 , xAnnoteED(m_xBuilder->weld_entry("annotationcontrol"))
181 , xNoteFT(m_xBuilder->weld_label("note"))
182 , xNoteED(m_xBuilder->weld_entry("notecontrol"))
183 , xURLFT(m_xBuilder->weld_label("url"))
184 , xURLED(m_xBuilder->weld_entry("urlcontrol"))
185 , xCustom1FT(m_xBuilder->weld_label("custom1"))
186 , xCustom1ED(m_xBuilder->weld_entry("custom1control"))
187 , xCustom2FT(m_xBuilder->weld_label("custom2"))
188 , xCustom2ED(m_xBuilder->weld_entry("custom2control"))
189 , xCustom3FT(m_xBuilder->weld_label("custom3"))
190 , xCustom3ED(m_xBuilder->weld_entry("custom3control"))
191 , xCustom4FT(m_xBuilder->weld_label("custom4"))
192 , xCustom4ED(m_xBuilder->weld_entry("custom4control"))
193 , xCustom5FT(m_xBuilder->weld_label("custom5"))
194 , xCustom5ED(m_xBuilder->weld_entry("custom5control"))
195 , m_xLocalURLFT(m_xBuilder->weld_label("localurl"))
196 , m_xLocalURLED(m_xBuilder->weld_entry("localurlcontrol"))
197 , m_xLocalBrowseButton(m_xBuilder->weld_button("localbrowse"))
198 , m_xLocalPageCB(m_xBuilder->weld_check_button("localpagecb"))
199 , m_xLocalPageSB(m_xBuilder->weld_spin_button("localpagesb"))
200 , pDatMan(pMan)
201{
203
204 BibConfig* pBibConfig = BibModul::GetConfig();
205 BibDBDescriptor aDesc;
208 aDesc.nCommandType = CommandType::TABLE;
209 const Mapping* pMapping = pBibConfig->GetMapping(aDesc);
210
211 xIdentifierED->connect_key_press(LINK(this, BibGeneralPage, FirstElementKeyInputHdl));
212
214 xIdentifierFT->get_label(), *xIdentifierED,
216
218 xAuthTypeFT->get_label(), *xAuthTypeLB,
220
222 xYearFT->get_label(), *xYearED,
224
226 xAuthorFT->get_label(), *xAuthorED,
228
230 xTitleFT->get_label(), *xTitleED,
232
234 xPublisherFT->get_label(), *xPublisherED,
236
238 xAddressFT->get_label(), *xAddressED,
240
242 xISBNFT->get_label(), *xISBNED,
244
246 xChapterFT->get_label(), *xChapterED,
248
250 xPagesFT->get_label(), *xPagesED,
252
254 xEditorFT->get_label(), *xEditorED,
256
258 xEditionFT->get_label(), *xEditionED,
260
262 xBooktitleFT->get_label(), *xBooktitleED,
264
266 xVolumeFT->get_label(), *xVolumeED,
268
270 xHowpublishedFT->get_label(), *xHowpublishedED,
272
274 xOrganizationsFT->get_label(), *xOrganizationsED,
276
278 xInstitutionFT->get_label(), *xInstitutionED,
280
282 xSchoolFT->get_label(), *xSchoolED,
284
286 xReportTypeFT->get_label(), *xReportTypeED,
288
290 xMonthFT->get_label(), *xMonthED,
292
294 xJournalFT->get_label(), *xJournalED,
296
298 xNumberFT->get_label(), *xNumberED,
300
302 xSeriesFT->get_label(), *xSeriesED,
304
306 xAnnoteFT->get_label(), *xAnnoteED,
308
310 xNoteFT->get_label(), *xNoteED,
312
314 xURLFT->get_label(), *xURLED,
316
318 xCustom1FT->get_label(), *xCustom1ED,
320
322 xCustom2FT->get_label(), *xCustom2ED,
324
326 xCustom3FT->get_label(), *xCustom3ED,
328
330 xCustom4FT->get_label(), *xCustom4ED,
332
334 xCustom5FT->get_label(), *xCustom5ED,
336
338 m_xLocalURLFT->get_label(), *m_xLocalURLED,
340
341 m_xLocalBrowseButton->connect_clicked(LINK(this, BibGeneralPage, BrowseHdl));
342 m_xLocalPageCB->connect_toggled(LINK(this, BibGeneralPage, PageNumHdl));
343
344 m_xLocalURLED->connect_key_press(LINK(this, BibGeneralPage, LastElementKeyInputHdl));
345
346 if(!sTableErrorString.isEmpty())
347 sTableErrorString = BibResId(ST_ERROR_PREFIX) + sTableErrorString;
348
349 SetText(BibResId(ST_TYPE_TITLE));
350
351 Size aSize(LogicToPixel(Size(0, 209), MapMode(MapUnit::MapAppFont)));
352 set_height_request(aSize.Height());
353}
354
356{
357 sfx2::FileDialogHelper aFileDlg(ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE,
358 FileDialogFlags::NONE, GetFrameWeld());
359 OUString aPath = m_xLocalURLED->get_text();
360 if (!aPath.isEmpty())
361 {
362 aFileDlg.SetDisplayDirectory(aPath);
363 }
364 else
365 {
366 OUString aBaseURL;
368 {
369 aBaseURL = pShell->getDocumentBaseURL();
370 }
371 if (!aBaseURL.isEmpty())
372 {
373 aFileDlg.SetDisplayDirectory(aBaseURL);
374 }
375 }
376
377 if (aFileDlg.Execute() != ERRCODE_NONE)
378 {
379 return;
380 }
381
382 weld::Entry& rEntry = *m_xLocalURLED;
383 rEntry.set_text(aFileDlg.GetPath());
384};
385
386IMPL_LINK(BibGeneralPage, PageNumHdl, weld::Toggleable&, rPageCB, void)
387{
388 weld::SpinButton& rPageSB = *m_xLocalPageSB;
389 if (rPageCB.get_active())
390 {
391 rPageSB.set_sensitive(true);
392 rPageSB.set_value(1);
393 }
394 else
395 {
396 rPageSB.set_sensitive(false);
397 }
398}
399
400IMPL_LINK(BibGeneralPage, FirstElementKeyInputHdl, const KeyEvent&, rKeyEvent, bool)
401{
402 sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
403 bool bShift = rKeyEvent.GetKeyCode().IsShift();
404 bool bCtrl = rKeyEvent.GetKeyCode().IsMod1();
405 bool bAlt = rKeyEvent.GetKeyCode().IsMod2();
406 if (KEY_TAB == nCode && bShift && !bCtrl && !bAlt)
407 {
408 SaveChanges();
409 uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
410 if (xRowSet.is() && !xRowSet->isFirst())
411 xRowSet->previous();
412 m_xLocalURLED->grab_focus();
413 m_xLocalURLED->select_region(0, -1);
414 GainFocusHdl(*m_xLocalURLED);
415 return true;
416 }
417 return false;
418}
419
421{
422 Reference< XForm > xForm = pDatMan->getForm();
423 Reference< beans::XPropertySet > xProps( xForm, UNO_QUERY );
424 Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
425 if (!xResUpd.is() )
426 return;
427
428 Any aModified = xProps->getPropertyValue( "IsModified" );
429 bool bFlag = false;
430 if ( !( aModified >>= bFlag ) || !bFlag )
431 return;
432
433 try
434 {
435 Any aNew = xProps->getPropertyValue( "IsNew" );
436 aNew >>= bFlag;
437 if ( bFlag )
438 xResUpd->insertRow();
439 else
440 xResUpd->updateRow();
441 }
442 catch( const uno::Exception&) {}
443}
444
445IMPL_LINK(BibGeneralPage, LastElementKeyInputHdl, const KeyEvent&, rKeyEvent, bool)
446{
447 sal_uInt16 nCode = rKeyEvent.GetKeyCode().GetCode();
448 bool bShift = rKeyEvent.GetKeyCode().IsShift();
449 bool bCtrl = rKeyEvent.GetKeyCode().IsMod1();
450 bool bAlt = rKeyEvent.GetKeyCode().IsMod2();
451 if (KEY_TAB != nCode || bShift || bCtrl || bAlt)
452 return false;
453 SaveChanges();
454 uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
455 if (xRowSet.is())
456 {
457 if (xRowSet->isLast())
458 {
459 uno::Reference<sdbc::XResultSetUpdate> xUpdateCursor(xRowSet, UNO_QUERY);
460 if (xUpdateCursor.is())
461 xUpdateCursor->moveToInsertRow();
462 }
463 else
464 (void)xRowSet->next();
465 }
466 xIdentifierED->grab_focus();
467 xIdentifierED->select_region(0, -1);
468 GainFocusHdl(*xIdentifierED);
469 return true;
470}
471
473{
474 disposeOnce();
475}
476
477class ChangeListener : public cppu::WeakImplHelper<css::beans::XPropertyChangeListener>
478{
479public:
480 explicit ChangeListener(css::uno::Reference<css::beans::XPropertySet> xPropSet)
481 : m_xPropSet(std::move(xPropSet))
482 , m_bSelfChanging(false)
483 {
484 }
485
486 virtual void SAL_CALL disposing(lang::EventObject const &) override
487 {
488 }
489
490 virtual void start() = 0;
491 virtual void stop()
492 {
493 WriteBack();
494 }
495
496 virtual void WriteBack() = 0;
497
498protected:
499 css::uno::Reference<css::beans::XPropertySet> m_xPropSet;
501};
502
503namespace
504{
505 class EntryChangeListener : public ChangeListener
506 {
507 public:
508 explicit EntryChangeListener(weld::Entry& rEntry, const css::uno::Reference<css::beans::XPropertySet>& rPropSet,
509 BibGeneralPage& rPage)
510 : ChangeListener(rPropSet)
511 , m_rEntry(rEntry)
512 , m_rPage(rPage)
513 {
514 rEntry.connect_focus_out(LINK(this, EntryChangeListener, LoseFocusHdl));
515 setValue(rPropSet->getPropertyValue("Text"));
516 }
517
518 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override
519 {
520 if (m_bSelfChanging)
521 return;
522 setValue(evt.NewValue);
523 }
524
525 virtual void start() override
526 {
527 m_xPropSet->addPropertyChangeListener("Text", this);
528 }
529
530 virtual void stop() override
531 {
532 m_xPropSet->removePropertyChangeListener("Text", this);
534 }
535
536 private:
537 weld::Entry& m_rEntry;
538 BibGeneralPage& m_rPage;
539
540 DECL_LINK(LoseFocusHdl, weld::Widget&, void);
541
543 void setValue(const css::uno::Any& rValue)
544 {
545 OUString sNewName;
546 rValue >>= sNewName;
547 if (&m_rEntry == &m_rPage.GetLocalURLED())
548 {
549 OUString aUrl;
550 int nPageNumber;
551 if (SplitUrlAndPage(sNewName, aUrl, nPageNumber))
552 {
553 m_rEntry.set_text(aUrl);
554 m_rPage.GetLocalPageCB().set_active(true);
555 m_rPage.GetLocalPageSB().set_sensitive(true);
556 m_rPage.GetLocalPageSB().set_value(nPageNumber);
557 }
558 else
559 {
560 m_rEntry.set_text(sNewName);
561 m_rPage.GetLocalPageCB().set_active(false);
562 m_rPage.GetLocalPageSB().set_sensitive(false);
563 m_rPage.GetLocalPageSB().set_value(0);
564 }
565 }
566 else
567 {
568 m_rEntry.set_text(sNewName);
569 }
570
571 m_rEntry.save_value();
572 if (&m_rEntry == &m_rPage.GetLocalURLED())
573 {
574 m_rPage.GetLocalPageSB().save_value();
575 }
576 }
577
579 virtual void WriteBack() override
580 {
581 bool bLocalURL = &m_rEntry == &m_rPage.GetLocalURLED()
583 if (!m_rEntry.get_value_changed_from_saved() && !bLocalURL)
584 return;
585
586 m_bSelfChanging = true;
587
588 OUString aText;
589 if (&m_rEntry == &m_rPage.GetLocalURLED())
590 {
591 aText = MergeUrlAndPage(m_rEntry.get_text(), m_rPage.GetLocalPageSB());
592 }
593 else
594 {
595 aText = m_rEntry.get_text();
596 }
597 m_xPropSet->setPropertyValue("Text", Any(aText));
598
599 css::uno::Reference<css::form::XBoundComponent> xBound(m_xPropSet, css::uno::UNO_QUERY);
600 if (xBound.is())
601 xBound->commit();
602
603 m_bSelfChanging = false;
604 m_rEntry.save_value();
605 if (&m_rEntry == &m_rPage.GetLocalURLED())
606 {
607 m_rPage.GetLocalPageSB().save_value();
608 }
609 }
610
611 };
612
613 IMPL_LINK_NOARG(EntryChangeListener, LoseFocusHdl, weld::Widget&, void)
614 {
615 WriteBack();
616 }
617
618 class ComboBoxChangeListener : public ChangeListener
619 {
620 public:
621 explicit ComboBoxChangeListener(weld::ComboBox& rComboBox, const css::uno::Reference<css::beans::XPropertySet>& rPropSet)
622 : ChangeListener(rPropSet)
623 , m_rComboBox(rComboBox)
624 {
625 rComboBox.connect_changed(LINK(this, ComboBoxChangeListener, ChangeHdl));
626 setValue(rPropSet->getPropertyValue("SelectedItems"));
627 }
628
629 virtual void SAL_CALL propertyChange(const css::beans::PropertyChangeEvent& evt) override
630 {
631 if (m_bSelfChanging)
632 return;
633 setValue(evt.NewValue);
634 }
635
636 virtual void start() override
637 {
638 m_xPropSet->addPropertyChangeListener("SelectedItems", this);
639 }
640
641 virtual void stop() override
642 {
643 m_xPropSet->removePropertyChangeListener("SelectedItems", this);
645 }
646
647 private:
648 weld::ComboBox& m_rComboBox;
649
650 DECL_LINK(ChangeHdl, weld::ComboBox&, void);
651
652 void setValue(const css::uno::Any& rValue)
653 {
654 sal_Int16 nSelection = -1;
655 Sequence<sal_Int16> aSelection;
656 rValue >>= aSelection;
657 if (aSelection.hasElements())
658 nSelection = aSelection[0];
659
660 m_rComboBox.set_active(nSelection);
661 m_rComboBox.save_value();
662 }
663
664 virtual void WriteBack() override
665 {
666 if (!m_rComboBox.get_value_changed_from_saved())
667 return;
668 m_bSelfChanging = true;
669
670 Sequence<sal_Int16> aSelection{ o3tl::narrowing<sal_Int16>(m_rComboBox.get_active()) };
671 m_xPropSet->setPropertyValue("SelectedItems", Any(aSelection));
672
673 css::uno::Reference<css::form::XBoundComponent> xBound(m_xPropSet, css::uno::UNO_QUERY);
674 if (xBound.is())
675 xBound->commit();
676
677 m_bSelfChanging = false;
678 m_rComboBox.save_value();
679 }
680 };
681
682 IMPL_LINK_NOARG(ComboBoxChangeListener, ChangeHdl, weld::ComboBox&, void)
683 {
684 WriteBack();
685 }
686}
687
689{
690 for (auto& listener : maChangeListeners)
691 listener->stop();
692 maChangeListeners.clear();
693
694 SaveChanges();
695
696 xScrolledWindow.reset();
697 xGrid.reset();
698 xIdentifierFT.reset();
699 xIdentifierED.reset();
700 xAuthTypeFT.reset();
701 xAuthTypeLB.reset();
702 xYearFT.reset();
703 xYearED.reset();
704 xAuthorFT.reset();
705 xAuthorED.reset();
706 xTitleFT.reset();
707 xTitleED.reset();
708 xPublisherFT.reset();
709 xPublisherED.reset();
710 xAddressFT.reset();
711 xAddressED.reset();
712 xISBNFT.reset();
713 xISBNED.reset();
714 xChapterFT.reset();
715 xChapterED.reset();
716 xPagesFT.reset();
717 xPagesED.reset();
718 xEditorFT.reset();
719 xEditorED.reset();
720 xEditionFT.reset();
721 xEditionED.reset();
722 xBooktitleFT.reset();
723 xBooktitleED.reset();
724 xVolumeFT.reset();
725 xVolumeED.reset();
726 xHowpublishedFT.reset();
727 xHowpublishedED.reset();
728 xOrganizationsFT.reset();
729 xOrganizationsED.reset();
730 xInstitutionFT.reset();
731 xInstitutionED.reset();
732 xSchoolFT.reset();
733 xSchoolED.reset();
734 xReportTypeFT.reset();
735 xReportTypeED.reset();
736 xMonthFT.reset();
737 xMonthED.reset();
738 xJournalFT.reset();
739 xJournalED.reset();
740 xNumberFT.reset();
741 xNumberED.reset();
742 xSeriesFT.reset();
743 xSeriesED.reset();
744 xAnnoteFT.reset();
745 xAnnoteED.reset();
746 xNoteFT.reset();
747 xNoteED.reset();
748 xURLFT.reset();
749 xURLED.reset();
750 xCustom1FT.reset();
751 xCustom1ED.reset();
752 xCustom2FT.reset();
753 xCustom2ED.reset();
754 xCustom3FT.reset();
755 xCustom3ED.reset();
756 xCustom4FT.reset();
757 xCustom4ED.reset();
758 xCustom5FT.reset();
759 xCustom5ED.reset();
760 m_xLocalURLFT.reset();
761 m_xLocalURLED.reset();
762 m_xLocalBrowseButton.reset();
763 m_xLocalPageCB.reset();
764 m_xLocalPageSB.reset();
766}
767
769
771
773
774bool BibGeneralPage::AddXControl(const OUString& rName, weld::Entry& rEntry)
775{
776 uno::Reference< awt::XControlModel > xCtrModel;
777 try
778 {
779 xCtrModel = pDatMan->loadControlModel(rName, false);
780 if ( xCtrModel.is() )
781 {
782 uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
783
784 if( xPropSet.is())
785 {
786 maChangeListeners.emplace_back(new EntryChangeListener(rEntry, xPropSet, *this));
787 maChangeListeners.back()->start();
788 if (&rEntry == m_xLocalURLED.get())
789 {
791 m_xLocalPageSB->connect_focus_out(LINK(this, BibGeneralPage, LosePageFocusHdl));
792 }
793 }
794 }
795 }
796 catch(const Exception&)
797 {
798 OSL_FAIL("BibGeneralPage::AddXControl: something went wrong!");
799 }
800 return xCtrModel.is();
801}
802
804{
805 m_aURLListener->WriteBack();
806}
807
808IMPL_LINK(BibGeneralPage, GainFocusHdl, weld::Widget&, rWidget, void)
809{
810 int x, y, width, height;
811 if (!rWidget.get_extents_relative_to(*xGrid, x, y, width, height))
812 return;
813
814 int bottom = y + height;
815 int nVScrollPos = xScrolledWindow->vadjustment_get_value();
816 if (y < nVScrollPos || bottom > nVScrollPos + xScrolledWindow->vadjustment_get_page_size())
817 xScrolledWindow->vadjustment_set_value(y);
818
819 int right = x + width;
820 int nHScrollPos = xScrolledWindow->hadjustment_get_value();
821 if (x < nHScrollPos || right > nHScrollPos + xScrolledWindow->hadjustment_get_page_size())
822 xScrolledWindow->hadjustment_set_value(x);
823}
824
825template<class Target> void BibGeneralPage::AddControlWithError(const OUString& rColumnName, const OUString& rColumnUIName,
826 Target& rWidget, OUString& rErrorString, const OUString& rHelpId)
827{
828 rWidget.set_help_id(rHelpId);
829 rWidget.connect_focus_in(LINK(this, BibGeneralPage, GainFocusHdl));
830 bool bSuccess = AddXControl(rColumnName, rWidget);
831 if (!bSuccess)
832 {
833 if( !rErrorString.isEmpty() )
834 rErrorString += "\n";
835
836 rErrorString += MnemonicGenerator::EraseAllMnemonicChars(rColumnUIName);
837 }
838}
839
840bool BibGeneralPage::AddXControl(const OUString& rName, weld::ComboBox& rList)
841{
842 uno::Reference< awt::XControlModel > xCtrModel;
843 try
844 {
845 xCtrModel = pDatMan->loadControlModel(rName, true);
846 if ( xCtrModel.is() )
847 {
848 uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
849
850 if( xPropSet.is())
851 {
852 css::uno::Sequence<OUString> aEntries;
853 xPropSet->getPropertyValue("StringItemList") >>= aEntries;
854 for (const OUString& rString : std::as_const(aEntries))
855 rList.append_text(rString);
856
857 sal_Int16 nSelection = -1;
858 Sequence<sal_Int16> aSelection;
859 xPropSet->getPropertyValue("SelectedItems") >>= aSelection;
860 if (aSelection.hasElements())
861 nSelection = aSelection[0];
862
863 rList.set_active(nSelection);
864 rList.save_value();
865
866 maChangeListeners.emplace_back(new ComboBoxChangeListener(rList, xPropSet));
867 maChangeListeners.back()->start();
868 }
869 }
870 }
871 catch(const Exception&)
872 {
873 OSL_FAIL("BibGeneralPage::AddXControl: something went wrong!");
874 }
875 return xCtrModel.is();
876}
877
878/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define EDITION_POS
Definition: bibconfig.hxx:40
#define VOLUME_POS
Definition: bibconfig.hxx:56
#define CUSTOM1_POS
Definition: bibconfig.hxx:58
#define MONTH_POS
Definition: bibconfig.hxx:45
#define INSTITUTION_POS
Definition: bibconfig.hxx:43
#define CHAPTER_POS
Definition: bibconfig.hxx:39
#define ADDRESS_POS
Definition: bibconfig.hxx:52
#define EDITOR_POS
Definition: bibconfig.hxx:41
#define PUBLISHER_POS
Definition: bibconfig.hxx:51
#define SERIES_POS
Definition: bibconfig.hxx:54
#define IDENTIFIER_POS
Definition: bibconfig.hxx:32
#define NOTE_POS
Definition: bibconfig.hxx:46
#define NUMBER_POS
Definition: bibconfig.hxx:48
#define ORGANIZATIONS_POS
Definition: bibconfig.hxx:49
#define ANNOTE_POS
Definition: bibconfig.hxx:47
#define JOURNAL_POS
Definition: bibconfig.hxx:44
#define AUTHOR_POS
Definition: bibconfig.hxx:34
#define CUSTOM5_POS
Definition: bibconfig.hxx:62
#define BOOKTITLE_POS
Definition: bibconfig.hxx:38
#define ISBN_POS
Definition: bibconfig.hxx:37
#define LOCAL_URL_POS
Definition: bibconfig.hxx:63
#define YEAR_POS
Definition: bibconfig.hxx:36
#define PAGES_POS
Definition: bibconfig.hxx:50
#define CUSTOM4_POS
Definition: bibconfig.hxx:61
#define TITLE_POS
Definition: bibconfig.hxx:35
#define AUTHORITYTYPE_POS
Definition: bibconfig.hxx:33
#define URL_POS
Definition: bibconfig.hxx:57
#define HOWPUBLISHED_POS
Definition: bibconfig.hxx:42
#define CUSTOM3_POS
Definition: bibconfig.hxx:60
#define REPORTTYPE_POS
Definition: bibconfig.hxx:55
#define SCHOOL_POS
Definition: bibconfig.hxx:53
#define CUSTOM2_POS
Definition: bibconfig.hxx:59
OUString BibResId(TranslateId aId)
Definition: bibmod.cxx:57
const Mapping * GetMapping(const BibDBDescriptor &rDesc) const
Definition: bibconfig.cxx:250
const OUString & GetDefColumnName(sal_uInt16 nIndex) const
Definition: bibconfig.hxx:121
const OUString & getActiveDataTable() const
Definition: datman.hxx:128
css::uno::Reference< css::awt::XControlModel > loadControlModel(const OUString &rName, bool bForceListBox)
Definition: datman.cxx:1177
const OUString & getActiveDataSource() const
Definition: datman.hxx:125
const css::uno::Reference< css::form::XForm > & getForm() const
Definition: datman.hxx:139
std::unique_ptr< weld::Label > xSchoolFT
Definition: general.hxx:81
std::unique_ptr< weld::CheckButton > m_xLocalPageCB
Definition: general.hxx:116
std::unique_ptr< weld::Label > xReportTypeFT
Definition: general.hxx:84
std::unique_ptr< weld::Entry > xSchoolED
Definition: general.hxx:82
std::unique_ptr< weld::ScrolledWindow > xScrolledWindow
Definition: general.hxx:37
std::unique_ptr< weld::Entry > xCustom2ED
Definition: general.hxx:106
std::unique_ptr< weld::Entry > xTitleED
Definition: general.hxx:51
std::unique_ptr< weld::Label > xCustom5FT
Definition: general.hxx:111
std::unique_ptr< weld::Label > xBooktitleFT
Definition: general.hxx:70
std::unique_ptr< weld::Label > xIdentifierFT
Definition: general.hxx:40
std::unique_ptr< weld::Label > xNoteFT
Definition: general.hxx:98
std::unique_ptr< weld::SpinButton > m_xLocalPageSB
Definition: general.hxx:117
std::vector< rtl::Reference< ChangeListener > > maChangeListeners
Definition: general.hxx:121
std::unique_ptr< weld::Label > xURLFT
Definition: general.hxx:100
std::unique_ptr< weld::Entry > xNumberED
Definition: general.hxx:92
std::unique_ptr< weld::Label > xAuthTypeFT
Definition: general.hxx:43
std::unique_ptr< weld::Label > xISBNFT
Definition: general.hxx:57
std::unique_ptr< weld::Label > xNumberFT
Definition: general.hxx:91
std::unique_ptr< weld::Label > xSeriesFT
Definition: general.hxx:93
virtual ~BibGeneralPage() override
Definition: general.cxx:472
std::unique_ptr< weld::Entry > xCustom3ED
Definition: general.hxx:108
std::unique_ptr< weld::Label > xOrganizationsFT
Definition: general.hxx:77
std::unique_ptr< weld::Entry > xMonthED
Definition: general.hxx:87
std::unique_ptr< weld::Label > xAnnoteFT
Definition: general.hxx:96
std::unique_ptr< weld::Entry > xCustom4ED
Definition: general.hxx:110
std::unique_ptr< weld::Label > xYearFT
Definition: general.hxx:45
std::unique_ptr< weld::Entry > xReportTypeED
Definition: general.hxx:85
std::unique_ptr< weld::Entry > xYearED
Definition: general.hxx:46
std::unique_ptr< weld::Entry > xVolumeED
Definition: general.hxx:73
std::unique_ptr< weld::Label > xInstitutionFT
Definition: general.hxx:79
std::unique_ptr< weld::Label > xVolumeFT
Definition: general.hxx:72
std::unique_ptr< weld::Entry > xCustom1ED
Definition: general.hxx:104
std::unique_ptr< weld::Entry > xJournalED
Definition: general.hxx:90
std::unique_ptr< weld::Label > xEditionFT
Definition: general.hxx:67
std::unique_ptr< weld::Entry > xISBNED
Definition: general.hxx:58
std::unique_ptr< weld::Entry > xEditionED
Definition: general.hxx:68
std::unique_ptr< weld::Label > xAuthorFT
Definition: general.hxx:48
void SaveChanges()
Definition: general.cxx:420
std::unique_ptr< weld::Entry > xHowpublishedED
Definition: general.hxx:75
weld::CheckButton & GetLocalPageCB()
Definition: general.cxx:770
std::unique_ptr< weld::Entry > xPublisherED
Definition: general.hxx:54
std::unique_ptr< weld::Entry > xIdentifierED
Definition: general.hxx:41
std::unique_ptr< weld::Label > xMonthFT
Definition: general.hxx:86
std::unique_ptr< weld::Entry > xEditorED
Definition: general.hxx:66
std::unique_ptr< weld::Label > xChapterFT
Definition: general.hxx:60
std::unique_ptr< weld::Entry > m_xLocalURLED
Definition: general.hxx:114
weld::Entry & GetLocalURLED()
Definition: general.cxx:768
std::unique_ptr< weld::Entry > xAnnoteED
Definition: general.hxx:97
std::unique_ptr< weld::Widget > xGrid
Definition: general.hxx:38
std::unique_ptr< weld::ComboBox > xAuthTypeLB
Definition: general.hxx:44
std::unique_ptr< weld::Label > xCustom3FT
Definition: general.hxx:107
virtual void dispose() override
Definition: general.cxx:688
std::unique_ptr< weld::Entry > xOrganizationsED
Definition: general.hxx:78
std::unique_ptr< weld::Label > xEditorFT
Definition: general.hxx:65
std::unique_ptr< weld::Label > xCustom4FT
Definition: general.hxx:109
std::unique_ptr< weld::Label > xAddressFT
Definition: general.hxx:55
std::unique_ptr< weld::Label > xTitleFT
Definition: general.hxx:50
std::unique_ptr< weld::Label > xPagesFT
Definition: general.hxx:62
std::unique_ptr< weld::Entry > xAddressED
Definition: general.hxx:56
std::unique_ptr< weld::Label > xPublisherFT
Definition: general.hxx:53
BibDataManager * pDatMan
Definition: general.hxx:124
bool AddXControl(const OUString &rName, weld::Entry &rEntry)
Definition: general.cxx:774
std::unique_ptr< weld::Entry > xChapterED
Definition: general.hxx:61
std::unique_ptr< weld::Entry > xNoteED
Definition: general.hxx:99
std::unique_ptr< weld::Entry > xSeriesED
Definition: general.hxx:94
std::unique_ptr< weld::Entry > xAuthorED
Definition: general.hxx:49
void AddControlWithError(const OUString &rColumnName, const OUString &rColumnUIName, Target &rWidget, OUString &rErrorString, const OUString &rHelpId)
Definition: general.cxx:825
weld::SpinButton & GetLocalPageSB()
Definition: general.cxx:772
std::unique_ptr< weld::Button > m_xLocalBrowseButton
Definition: general.hxx:115
std::unique_ptr< weld::Label > m_xLocalURLFT
Definition: general.hxx:113
std::unique_ptr< weld::Label > xCustom1FT
Definition: general.hxx:103
std::unique_ptr< weld::Entry > xPagesED
Definition: general.hxx:63
std::unique_ptr< weld::Label > xJournalFT
Definition: general.hxx:89
std::unique_ptr< weld::Label > xCustom2FT
Definition: general.hxx:105
rtl::Reference< ChangeListener > m_aURLListener
Definition: general.hxx:122
std::unique_ptr< weld::Entry > xInstitutionED
Definition: general.hxx:80
std::unique_ptr< weld::Entry > xBooktitleED
Definition: general.hxx:71
std::unique_ptr< weld::Entry > xURLED
Definition: general.hxx:101
std::unique_ptr< weld::Label > xHowpublishedFT
Definition: general.hxx:74
OUString sTableErrorString
Definition: general.hxx:119
std::unique_ptr< weld::Entry > xCustom5ED
Definition: general.hxx:112
BibGeneralPage(vcl::Window *pParent, BibDataManager *pDatMan)
Definition: general.cxx:128
static BibConfig * GetConfig()
Definition: bibmod.cxx:82
ChangeListener(css::uno::Reference< css::beans::XPropertySet > xPropSet)
Definition: general.cxx:480
css::uno::Reference< css::beans::XPropertySet > m_xPropSet
Definition: general.cxx:499
virtual void SAL_CALL disposing(lang::EventObject const &) override
Definition: general.cxx:486
virtual void WriteBack()=0
virtual void start()=0
bool m_bSelfChanging
Definition: general.cxx:500
virtual void stop()
Definition: general.cxx:491
virtual void SetText(const OUString &rStr) override
virtual void dispose() override
static OUString EraseAllMnemonicChars(const OUString &rStr)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
constexpr tools::Long Height() const
OUString GetPath() const
void SetDisplayDirectory(const OUString &rPath)
void SetStyle(WinBits nStyle)
Point LogicToPixel(const Point &rLogicPt) const
void set_height_request(sal_Int32 nHeightRequest)
WinBits GetStyle() const
bool get_value_changed_from_saved() const
virtual void set_active(int pos)=0
void append_text(const OUString &rStr)
virtual int get_active() const=0
void connect_changed(const Link< ComboBox &, void > &rLink)
virtual void set_text(const OUString &rText)=0
void save_value()
virtual OUString get_text() const=0
bool get_value_changed_from_saved() const
virtual void set_value(sal_Int64 value)=0
virtual sal_Int64 get_value() const=0
virtual void set_active(bool active)=0
virtual void set_sensitive(bool sensitive)=0
virtual void connect_focus_out(const Link< Widget &, void > &rLink)
virtual bool get_sensitive() const=0
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
OString right
OString bottom
float y
float x
ScXMLEditAttributeMap::Entry const aEntries[]
#define ERRCODE_NONE
IMPL_LINK(BibGeneralPage, PageNumHdl, weld::Toggleable &, rPageCB, void)
Definition: general.cxx:386
static OUString lcl_GetColumnName(const Mapping *pMapping, sal_uInt16 nIndexPos)
Definition: general.cxx:112
IMPL_LINK_NOARG(BibGeneralPage, BrowseHdl, weld::Button &, void)
Definition: general.cxx:355
constexpr OUStringLiteral HID_BIB_MONTH_POS
Definition: helpids.h:45
constexpr OUStringLiteral HID_BIB_YEAR_POS
Definition: helpids.h:36
constexpr OUStringLiteral HID_BIB_AUTHOR_POS
Definition: helpids.h:34
constexpr OUStringLiteral HID_BIB_CUSTOM3_POS
Definition: helpids.h:60
constexpr OUStringLiteral HID_BIB_VOLUME_POS
Definition: helpids.h:56
constexpr OUStringLiteral HID_BIB_CUSTOM2_POS
Definition: helpids.h:59
constexpr OUStringLiteral HID_BIB_HOWPUBLISHED_POS
Definition: helpids.h:42
constexpr OUStringLiteral HID_BIB_AUTHORITYTYPE_POS
Definition: helpids.h:33
constexpr OUStringLiteral HID_BIB_SERIES_POS
Definition: helpids.h:54
constexpr OUStringLiteral HID_BIB_ADDRESS_POS
Definition: helpids.h:52
constexpr OUStringLiteral HID_BIB_REPORTTYPE_POS
Definition: helpids.h:55
constexpr OUStringLiteral HID_BIB_ISBN_POS
Definition: helpids.h:37
constexpr OUStringLiteral HID_BIB_ANNOTE_POS
Definition: helpids.h:47
constexpr OUStringLiteral HID_BIB_JOURNAL_POS
Definition: helpids.h:44
constexpr OUStringLiteral HID_BIB_SCHOOL_POS
Definition: helpids.h:53
constexpr OUStringLiteral HID_BIB_CUSTOM4_POS
Definition: helpids.h:61
constexpr OUStringLiteral HID_BIB_IDENTIFIER_POS
Definition: helpids.h:32
constexpr OUStringLiteral HID_BIB_URL_POS
Definition: helpids.h:57
constexpr OUStringLiteral HID_BIB_EDITION_POS
Definition: helpids.h:40
constexpr OUStringLiteral HID_BIB_EDITOR_POS
Definition: helpids.h:41
constexpr OUStringLiteral HID_BIB_PUBLISHER_POS
Definition: helpids.h:51
constexpr OUStringLiteral HID_BIB_ORGANIZATIONS_POS
Definition: helpids.h:49
constexpr OUStringLiteral HID_BIB_LOCAL_URL_POS
Definition: helpids.h:63
constexpr OUStringLiteral HID_BIB_CUSTOM1_POS
Definition: helpids.h:58
constexpr OUStringLiteral HID_BIB_PAGES_POS
Definition: helpids.h:50
constexpr OUStringLiteral HID_BIB_NUMBER_POS
Definition: helpids.h:48
constexpr OUStringLiteral HID_BIB_INSTITUTION_POS
Definition: helpids.h:43
constexpr OUStringLiteral HID_BIB_TITLE_POS
Definition: helpids.h:35
constexpr OUStringLiteral HID_BIB_BOOKTITLE_POS
Definition: helpids.h:38
constexpr OUStringLiteral HID_BIB_NOTE_POS
Definition: helpids.h:46
constexpr OUStringLiteral HID_BIB_CHAPTER_POS
Definition: helpids.h:39
constexpr OUStringLiteral HID_BIB_CUSTOM5_POS
Definition: helpids.h:62
constexpr sal_uInt16 KEY_TAB
uno_Mapping * pMapping
#define SAL_WARN(area, stream)
@ Exception
Reference< XComponentContext > getProcessComponentContext()
sal_Int32 toInt32(std::u16string_view str, sal_Int16 radix=10)
RegError REGISTRY_CALLTYPE setValue(RegKeyHandle hKey, rtl_uString *keyName, RegValueType valueType, RegValue pData, sal_uInt32 valueSize)
OUString sDataSource
Definition: bibconfig.hxx:84
OUString sTableOrQuery
Definition: bibconfig.hxx:85
sal_Int32 nCommandType
Definition: bibconfig.hxx:86
WinBits const WB_DIALOGCONTROL