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>
32#include <osl/diagnose.h>
56bool SplitUrlAndPage(
const OUString& rText, OUString& rUrl,
int& nPageNumber)
58 uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
60 uno::Reference<uri::XUriReference> xUriRef;
63 xUriRef = xUriReferenceFactory->parse(rText);
65 catch (
const uno::Exception& rException)
68 "SplitUrlAndPage: failed to parse url: " << rException.Message);
72 OUString aPagePrefix(
"page=");
73 if (!xUriRef->getFragment().startsWith(aPagePrefix))
78 nPageNumber =
o3tl::toInt32(xUriRef->getFragment().subView(aPagePrefix.getLength()));
79 xUriRef->clearFragment();
80 rUrl = xUriRef->getUriReference();
85OUString MergeUrlAndPage(
const OUString& rUrl,
const weld::SpinButton& rPageSB)
92 uno::Reference<uri::XUriReferenceFactory> xUriReferenceFactory
94 uno::Reference<uri::XUriReference> xUriRef;
97 xUriRef = xUriReferenceFactory->parse(rUrl);
99 catch (
const uno::Exception& rException)
102 "MergeUrlAndPage: failed to parse url: " << rException.Message);
106 OUString aFragment(
"page=" + OUString::number(rPageSB.
get_value()));
107 xUriRef->setFragment(aFragment);
108 return xUriRef->getUriReference();
117 for(
const auto & aColumnPair :
pMapping->aColumnPairs)
119 if(aColumnPair.sLogicalColumnName == sRet)
121 sRet = aColumnPair.sRealColumnName;
129 :
InterimItemWindow(pParent,
"modules/sbibliography/ui/generalpage.ui",
"GeneralPage")
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"))
359 OUString aPath = m_xLocalURLED->get_text();
360 if (!aPath.isEmpty())
369 aBaseURL = pShell->getDocumentBaseURL();
371 if (!aBaseURL.isEmpty())
389 if (rPageCB.get_active())
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)
409 uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
410 if (xRowSet.is() && !xRowSet->isFirst())
412 m_xLocalURLED->grab_focus();
413 m_xLocalURLED->select_region(0, -1);
414 GainFocusHdl(*m_xLocalURLED);
423 Reference< beans::XPropertySet > xProps( xForm, UNO_QUERY );
424 Reference< sdbc::XResultSetUpdate > xResUpd( xProps, UNO_QUERY );
428 Any aModified = xProps->getPropertyValue(
"IsModified" );
430 if ( !( aModified >>= bFlag ) || !bFlag )
435 Any aNew = xProps->getPropertyValue(
"IsNew" );
438 xResUpd->insertRow();
440 xResUpd->updateRow();
442 catch(
const uno::Exception&) {}
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)
454 uno::Reference<sdbc::XRowSet> xRowSet(pDatMan->getForm(), UNO_QUERY);
457 if (xRowSet->isLast())
459 uno::Reference<sdbc::XResultSetUpdate> xUpdateCursor(xRowSet, UNO_QUERY);
460 if (xUpdateCursor.is())
461 xUpdateCursor->moveToInsertRow();
464 (
void)xRowSet->next();
466 xIdentifierED->grab_focus();
467 xIdentifierED->select_region(0, -1);
468 GainFocusHdl(*xIdentifierED);
477class ChangeListener :
public cppu::WeakImplHelper<css::beans::XPropertyChangeListener>
486 virtual void SAL_CALL
disposing(lang::EventObject
const &)
override
508 explicit EntryChangeListener(
weld::Entry& rEntry,
const css::uno::Reference<css::beans::XPropertySet>& rPropSet,
515 setValue(rPropSet->getPropertyValue(
"Text"));
518 virtual void SAL_CALL propertyChange(
const css::beans::PropertyChangeEvent& evt)
override
525 virtual void start()
override
527 m_xPropSet->addPropertyChangeListener(
"Text",
this);
530 virtual void stop()
override
532 m_xPropSet->removePropertyChangeListener(
"Text",
this);
543 void setValue(
const css::uno::Any& rValue)
551 if (SplitUrlAndPage(sNewName, aUrl, nPageNumber))
586 m_bSelfChanging =
true;
597 m_xPropSet->setPropertyValue(
"Text",
Any(aText));
599 css::uno::Reference<css::form::XBoundComponent> xBound(m_xPropSet, css::uno::UNO_QUERY);
603 m_bSelfChanging =
false;
621 explicit ComboBoxChangeListener(
weld::ComboBox& rComboBox,
const css::uno::Reference<css::beans::XPropertySet>& rPropSet)
623 , m_rComboBox(rComboBox)
626 setValue(rPropSet->getPropertyValue(
"SelectedItems"));
629 virtual void SAL_CALL propertyChange(
const css::beans::PropertyChangeEvent& evt)
override
636 virtual void start()
override
638 m_xPropSet->addPropertyChangeListener(
"SelectedItems",
this);
641 virtual void stop()
override
643 m_xPropSet->removePropertyChangeListener(
"SelectedItems",
this);
652 void setValue(
const css::uno::Any& rValue)
654 sal_Int16 nSelection = -1;
655 Sequence<sal_Int16> aSelection;
656 rValue >>= aSelection;
657 if (aSelection.hasElements())
658 nSelection = aSelection[0];
668 m_bSelfChanging =
true;
670 Sequence<sal_Int16> aSelection{ o3tl::narrowing<sal_Int16>(m_rComboBox.
get_active()) };
671 m_xPropSet->setPropertyValue(
"SelectedItems",
Any(aSelection));
673 css::uno::Reference<css::form::XBoundComponent> xBound(m_xPropSet, css::uno::UNO_QUERY);
677 m_bSelfChanging =
false;
776 uno::Reference< awt::XControlModel > xCtrModel;
780 if ( xCtrModel.is() )
782 uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
786 maChangeListeners.emplace_back(
new EntryChangeListener(rEntry, xPropSet, *
this));
798 OSL_FAIL(
"BibGeneralPage::AddXControl: something went wrong!");
800 return xCtrModel.is();
805 m_aURLListener->WriteBack();
810 int x,
y, width, height;
811 if (!rWidget.get_extents_relative_to(*xGrid,
x,
y, width, 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);
820 int nHScrollPos = xScrolledWindow->hadjustment_get_value();
821 if (x < nHScrollPos || right > nHScrollPos + xScrolledWindow->hadjustment_get_page_size())
822 xScrolledWindow->hadjustment_set_value(
x);
826 Target& rWidget, OUString& rErrorString,
const OUString& rHelpId)
828 rWidget.set_help_id(rHelpId);
833 if( !rErrorString.isEmpty() )
834 rErrorString +=
"\n";
842 uno::Reference< awt::XControlModel > xCtrModel;
846 if ( xCtrModel.is() )
848 uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
852 css::uno::Sequence<OUString>
aEntries;
853 xPropSet->getPropertyValue(
"StringItemList") >>=
aEntries;
854 for (
const OUString& rString : std::as_const(
aEntries))
857 sal_Int16 nSelection = -1;
858 Sequence<sal_Int16> aSelection;
859 xPropSet->getPropertyValue(
"SelectedItems") >>= aSelection;
860 if (aSelection.hasElements())
861 nSelection = aSelection[0];
873 OSL_FAIL(
"BibGeneralPage::AddXControl: something went wrong!");
875 return xCtrModel.is();
#define ORGANIZATIONS_POS
#define AUTHORITYTYPE_POS
OUString BibResId(TranslateId aId)
const Mapping * GetMapping(const BibDBDescriptor &rDesc) const
const OUString & GetDefColumnName(sal_uInt16 nIndex) const
const OUString & getActiveDataTable() const
css::uno::Reference< css::awt::XControlModel > loadControlModel(const OUString &rName, bool bForceListBox)
const OUString & getActiveDataSource() const
const css::uno::Reference< css::form::XForm > & getForm() const
std::unique_ptr< weld::Label > xSchoolFT
std::unique_ptr< weld::CheckButton > m_xLocalPageCB
std::unique_ptr< weld::Label > xReportTypeFT
std::unique_ptr< weld::Entry > xSchoolED
std::unique_ptr< weld::ScrolledWindow > xScrolledWindow
std::unique_ptr< weld::Entry > xCustom2ED
std::unique_ptr< weld::Entry > xTitleED
std::unique_ptr< weld::Label > xCustom5FT
std::unique_ptr< weld::Label > xBooktitleFT
std::unique_ptr< weld::Label > xIdentifierFT
std::unique_ptr< weld::Label > xNoteFT
std::unique_ptr< weld::SpinButton > m_xLocalPageSB
std::vector< rtl::Reference< ChangeListener > > maChangeListeners
std::unique_ptr< weld::Label > xURLFT
std::unique_ptr< weld::Entry > xNumberED
std::unique_ptr< weld::Label > xAuthTypeFT
std::unique_ptr< weld::Label > xISBNFT
std::unique_ptr< weld::Label > xNumberFT
std::unique_ptr< weld::Label > xSeriesFT
virtual ~BibGeneralPage() override
std::unique_ptr< weld::Entry > xCustom3ED
std::unique_ptr< weld::Label > xOrganizationsFT
std::unique_ptr< weld::Entry > xMonthED
std::unique_ptr< weld::Label > xAnnoteFT
std::unique_ptr< weld::Entry > xCustom4ED
std::unique_ptr< weld::Label > xYearFT
std::unique_ptr< weld::Entry > xReportTypeED
std::unique_ptr< weld::Entry > xYearED
std::unique_ptr< weld::Entry > xVolumeED
std::unique_ptr< weld::Label > xInstitutionFT
std::unique_ptr< weld::Label > xVolumeFT
std::unique_ptr< weld::Entry > xCustom1ED
std::unique_ptr< weld::Entry > xJournalED
std::unique_ptr< weld::Label > xEditionFT
std::unique_ptr< weld::Entry > xISBNED
std::unique_ptr< weld::Entry > xEditionED
std::unique_ptr< weld::Label > xAuthorFT
std::unique_ptr< weld::Entry > xHowpublishedED
weld::CheckButton & GetLocalPageCB()
std::unique_ptr< weld::Entry > xPublisherED
std::unique_ptr< weld::Entry > xIdentifierED
std::unique_ptr< weld::Label > xMonthFT
std::unique_ptr< weld::Entry > xEditorED
std::unique_ptr< weld::Label > xChapterFT
std::unique_ptr< weld::Entry > m_xLocalURLED
weld::Entry & GetLocalURLED()
std::unique_ptr< weld::Entry > xAnnoteED
std::unique_ptr< weld::Widget > xGrid
std::unique_ptr< weld::ComboBox > xAuthTypeLB
std::unique_ptr< weld::Label > xCustom3FT
virtual void dispose() override
std::unique_ptr< weld::Entry > xOrganizationsED
std::unique_ptr< weld::Label > xEditorFT
std::unique_ptr< weld::Label > xCustom4FT
std::unique_ptr< weld::Label > xAddressFT
std::unique_ptr< weld::Label > xTitleFT
std::unique_ptr< weld::Label > xPagesFT
std::unique_ptr< weld::Entry > xAddressED
std::unique_ptr< weld::Label > xPublisherFT
bool AddXControl(const OUString &rName, weld::Entry &rEntry)
std::unique_ptr< weld::Entry > xChapterED
std::unique_ptr< weld::Entry > xNoteED
std::unique_ptr< weld::Entry > xSeriesED
std::unique_ptr< weld::Entry > xAuthorED
void AddControlWithError(const OUString &rColumnName, const OUString &rColumnUIName, Target &rWidget, OUString &rErrorString, const OUString &rHelpId)
weld::SpinButton & GetLocalPageSB()
std::unique_ptr< weld::Button > m_xLocalBrowseButton
std::unique_ptr< weld::Label > m_xLocalURLFT
std::unique_ptr< weld::Label > xCustom1FT
std::unique_ptr< weld::Entry > xPagesED
std::unique_ptr< weld::Label > xJournalFT
std::unique_ptr< weld::Label > xCustom2FT
rtl::Reference< ChangeListener > m_aURLListener
std::unique_ptr< weld::Entry > xInstitutionED
std::unique_ptr< weld::Entry > xBooktitleED
std::unique_ptr< weld::Entry > xURLED
std::unique_ptr< weld::Label > xHowpublishedFT
OUString sTableErrorString
std::unique_ptr< weld::Entry > xCustom5ED
BibGeneralPage(vcl::Window *pParent, BibDataManager *pDatMan)
static BibConfig * GetConfig()
ChangeListener(css::uno::Reference< css::beans::XPropertySet > xPropSet)
css::uno::Reference< css::beans::XPropertySet > m_xPropSet
virtual void SAL_CALL disposing(lang::EventObject const &) override
virtual void WriteBack()=0
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
void SetDisplayDirectory(const OUString &rPath)
void SetStyle(WinBits nStyle)
Point LogicToPixel(const Point &rLogicPt) const
void set_height_request(sal_Int32 nHeightRequest)
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
virtual OUString get_text() const=0
bool get_value_changed_from_saved() const
virtual void set_active(bool active)=0
weld::Window * GetFrameWeld(const SfxFrame *pFrame)
DECL_LINK(CheckNameHdl, SvxNameDialog &, bool)
ScXMLEditAttributeMap::Entry const aEntries[]
IMPL_LINK(BibGeneralPage, PageNumHdl, weld::Toggleable &, rPageCB, void)
static OUString lcl_GetColumnName(const Mapping *pMapping, sal_uInt16 nIndexPos)
IMPL_LINK_NOARG(BibGeneralPage, BrowseHdl, weld::Button &, void)
constexpr OUStringLiteral HID_BIB_MONTH_POS
constexpr OUStringLiteral HID_BIB_YEAR_POS
constexpr OUStringLiteral HID_BIB_AUTHOR_POS
constexpr OUStringLiteral HID_BIB_CUSTOM3_POS
constexpr OUStringLiteral HID_BIB_VOLUME_POS
constexpr OUStringLiteral HID_BIB_CUSTOM2_POS
constexpr OUStringLiteral HID_BIB_HOWPUBLISHED_POS
constexpr OUStringLiteral HID_BIB_AUTHORITYTYPE_POS
constexpr OUStringLiteral HID_BIB_SERIES_POS
constexpr OUStringLiteral HID_BIB_ADDRESS_POS
constexpr OUStringLiteral HID_BIB_REPORTTYPE_POS
constexpr OUStringLiteral HID_BIB_ISBN_POS
constexpr OUStringLiteral HID_BIB_ANNOTE_POS
constexpr OUStringLiteral HID_BIB_JOURNAL_POS
constexpr OUStringLiteral HID_BIB_SCHOOL_POS
constexpr OUStringLiteral HID_BIB_CUSTOM4_POS
constexpr OUStringLiteral HID_BIB_IDENTIFIER_POS
constexpr OUStringLiteral HID_BIB_URL_POS
constexpr OUStringLiteral HID_BIB_EDITION_POS
constexpr OUStringLiteral HID_BIB_EDITOR_POS
constexpr OUStringLiteral HID_BIB_PUBLISHER_POS
constexpr OUStringLiteral HID_BIB_ORGANIZATIONS_POS
constexpr OUStringLiteral HID_BIB_LOCAL_URL_POS
constexpr OUStringLiteral HID_BIB_CUSTOM1_POS
constexpr OUStringLiteral HID_BIB_PAGES_POS
constexpr OUStringLiteral HID_BIB_NUMBER_POS
constexpr OUStringLiteral HID_BIB_INSTITUTION_POS
constexpr OUStringLiteral HID_BIB_TITLE_POS
constexpr OUStringLiteral HID_BIB_BOOKTITLE_POS
constexpr OUStringLiteral HID_BIB_NOTE_POS
constexpr OUStringLiteral HID_BIB_CHAPTER_POS
constexpr OUStringLiteral HID_BIB_CUSTOM5_POS
constexpr sal_uInt16 KEY_TAB
#define LINK(Instance, Class, Member)
#define SAL_WARN(area, stream)
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)
WinBits const WB_DIALOGCONTROL