1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_extensions.hxx"
32 #include <comphelper/processfactory.hxx>
33 #include <com/sun/star/awt/PosSize.hpp>
34 #include <com/sun/star/sdbc/XRowSet.hpp>
35 #include <com/sun/star/sdb/XColumn.hpp>
36 #include <com/sun/star/sdb/CommandType.hpp>
37 #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
38 #include <com/sun/star/form/ListSourceType.hpp>
39 #include <com/sun/star/awt/XWindow.hpp>
40 #include <toolkit/helper/vclunohelper.hxx>
41 #include <cppuhelper/implbase1.hxx> // helper for implementations
42 #include "general.hxx"
43 #include "sections.hrc"
44 #include "bibresid.hxx"
46 #include "bibconfig.hxx"
47 #include "bibprop.hrc"
50 #include "bibtools.hxx"
51 #include "bibliography.hrc"
52 #include <tools/debug.hxx>
53 #include <vcl/mnemonic.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/i18nhelp.hxx>
56 #include <vcl/mnemonic.hxx>
61 using namespace ::com::sun::star
;
62 using namespace ::com::sun::star::uno
;
63 using namespace ::com::sun::star::form
;
64 using namespace ::com::sun::star::sdb
;
65 using namespace ::rtl
;
67 #define C2U(cChar) OUString::createFromAscii(cChar)
68 #define C2S(cChar) String::CreateFromAscii(cChar)
69 #define DISTANCE_CONTROL_TO_FIXEDTEXT 5
71 ::Point
lcl_MovePoint(const FixedText
& rFixedText
)
73 ::Point
aRet(rFixedText
.GetPosPixel());
74 aRet
.X() += rFixedText
.GetSizePixel().Width();
75 aRet
.X() += DISTANCE_CONTROL_TO_FIXEDTEXT
;
79 //-----------------------------------------------------------------------------
80 OUString
lcl_GetColumnName( const Mapping
* pMapping
, sal_uInt16 nIndexPos
)
82 BibConfig
* pBibConfig
= BibModul::GetConfig();
83 OUString sRet
= pBibConfig
->GetDefColumnName(nIndexPos
);
85 for(sal_uInt16 i
= 0; i
< COLUMN_COUNT
; i
++)
87 if(pMapping
->aColumnPairs
[i
].sLogicalColumnName
== sRet
)
89 sRet
= pMapping
->aColumnPairs
[i
].sRealColumnName
;
95 /* -----------------------------04.01.00 10:54--------------------------------
97 ---------------------------------------------------------------------------*/
98 class BibPosListener
:public cppu::WeakImplHelper1
<sdbc::XRowSetListener
>
100 BibGeneralPage
* pParentPage
;
102 BibPosListener(BibGeneralPage
* pParent
);
104 //XPositioningListener
105 virtual void SAL_CALL
cursorMoved(const lang::EventObject
& event
) throw( uno::RuntimeException
);
106 virtual void SAL_CALL
rowChanged(const lang::EventObject
& /*event*/) throw( uno::RuntimeException
){ /* not interested in */ }
107 virtual void SAL_CALL
rowSetChanged(const lang::EventObject
& /*event*/) throw( uno::RuntimeException
){ /* not interested in */ }
110 virtual void SAL_CALL
disposing(const lang::EventObject
& Source
) throw( uno::RuntimeException
);
113 /* -----------------------------04.01.00 10:57--------------------------------
115 ---------------------------------------------------------------------------*/
116 BibPosListener::BibPosListener(BibGeneralPage
* pParent
) :
120 /* -----------------------------04.01.00 10:57--------------------------------
122 ---------------------------------------------------------------------------*/
123 void BibPosListener::cursorMoved(const lang::EventObject
& /*aEvent*/) throw( uno::RuntimeException
)
127 uno::Reference
< form::XBoundComponent
> xLstBox
= pParentPage
->GetTypeListBoxModel();
128 uno::Reference
< beans::XPropertySet
> xPropSet(xLstBox
, UNO_QUERY
);
131 BibConfig
* pBibConfig
= BibModul::GetConfig();
132 BibDataManager
* pDatMan
= pParentPage
->GetDataManager();
133 BibDBDescriptor aDesc
;
134 aDesc
.sDataSource
= pDatMan
->getActiveDataSource();
135 aDesc
.sTableOrQuery
= pDatMan
->getActiveDataTable();
136 aDesc
.nCommandType
= CommandType::TABLE
;
138 const Mapping
* pMapping
= pBibConfig
->GetMapping(aDesc
);
139 OUString sTypeMapping
= pBibConfig
->GetDefColumnName(AUTHORITYTYPE_POS
);
142 for(sal_uInt16 nEntry
= 0; nEntry
< COLUMN_COUNT
; nEntry
++)
144 if(pMapping
->aColumnPairs
[nEntry
].sLogicalColumnName
== sTypeMapping
)
146 sTypeMapping
= pMapping
->aColumnPairs
[nEntry
].sRealColumnName
;
151 rtl::OUString uTypeMapping
= sTypeMapping
;
153 uno::Reference
< form::XForm
> xForm
= pDatMan
->getForm();
154 uno::Reference
< sdbcx::XColumnsSupplier
> xSupplyCols(xForm
, UNO_QUERY
);
155 uno::Reference
< container::XNameAccess
> xValueAcc
;
156 if (xSupplyCols
.is())
157 xValueAcc
= xSupplyCols
->getColumns();
159 sal_Int16 nTempVal
= -1;
160 if(xValueAcc
.is() && xValueAcc
->hasByName(uTypeMapping
))
162 uno::Any aVal
= xValueAcc
->getByName(uTypeMapping
);
163 uno::Reference
< uno::XInterface
> xInt
= *(uno::Reference
< uno::XInterface
> *)aVal
.getValue();
164 uno::Reference
< sdb::XColumn
> xCol(xInt
, UNO_QUERY
);
165 DBG_ASSERT(xCol
.is(), "BibPosListener::positioned : invalid column (no sdb::XColumn) !");
168 nTempVal
= xCol
->getShort();
169 // getShort returns zero if the value is not a number
170 if (!nTempVal
|| xCol
->wasNull())
172 rtl::OUString sTempVal
= xCol
->getString();
173 if(sTempVal
!= rtl::OUString('0'))
178 if(nTempVal
< 0 || nTempVal
>= TYPE_COUNT
)
181 uno::Sequence
<sal_Int16
> aSelSeq(1);
182 sal_Int16
* pArr
= aSelSeq
.getArray();
183 pArr
[0] = TYPE_COUNT
;
184 aSel
.setValue(&aSelSeq
, ::getCppuType((Sequence
<sal_Int16
>*)0));
185 xPropSet
->setPropertyValue(C2U("SelectedItems"), aSel
);
189 catch(Exception
& rEx
)
191 (void) rEx
; // make compiler happy
192 DBG_ERROR("BibPosListener::positioned: something went wrong !");
195 /* -----------------------------04.01.00 11:28--------------------------------
197 ---------------------------------------------------------------------------*/
198 void BibPosListener::disposing(const lang::EventObject
& /*Source*/) throw( uno::RuntimeException
)
202 /* -----------------16.11.99 13:06-------------------
204 --------------------------------------------------*/
205 BibGeneralPage::BibGeneralPage(Window
* pParent
, BibDataManager
* pMan
):
206 BibTabPage(pParent
,BibResId(RID_TP_GENERAL
)),
207 aControlParentWin(this, WB_DIALOGCONTROL
),
208 aIdentifierFT(&aControlParentWin
, BibResId(FT_IDENTIFIER
)),
209 aAuthTypeFT(&aControlParentWin
, BibResId(FT_AUTHTYPE
)),
210 aYearFT(&aControlParentWin
, BibResId(FT_YEAR
)),
211 aAuthorFT(&aControlParentWin
, BibResId(FT_AUTHOR
)),
212 aTitleFT(&aControlParentWin
, BibResId(FT_TITLE
)),
213 aPublisherFT(&aControlParentWin
, BibResId(FT_PUBLISHER
)),
214 aAddressFT(&aControlParentWin
, BibResId(FT_ADDRESS
)),
215 aISBNFT(&aControlParentWin
, BibResId(FT_ISBN
)),
216 aChapterFT(&aControlParentWin
, BibResId(FT_CHAPTER
)),
217 aPagesFT(&aControlParentWin
, BibResId(FT_PAGE
)),
218 aFirstFL(&aControlParentWin
, BibResId(FL_1
)),
219 aEditorFT(&aControlParentWin
, BibResId(FT_EDITOR
)),
220 aEditionFT(&aControlParentWin
, BibResId(FT_EDITION
)),
221 aBooktitleFT(&aControlParentWin
, BibResId(FT_BOOKTITLE
)),
222 aVolumeFT(&aControlParentWin
, BibResId(FT_VOLUME
)),
223 aHowpublishedFT(&aControlParentWin
, BibResId(FT_HOWPUBLISHED
)),
224 aOrganizationsFT(&aControlParentWin
,BibResId(FT_ORGANIZATION
)),
225 aInstitutionFT(&aControlParentWin
, BibResId(FT_INSTITUTION
)),
226 aSchoolFT(&aControlParentWin
, BibResId(FT_SCHOOL
)),
227 aReportTypeFT(&aControlParentWin
, BibResId(FT_REPORT
)),
228 aMonthFT(&aControlParentWin
, BibResId(FT_MONTH
)),
229 aSecondFL(&aControlParentWin
, BibResId(FL_2
)),
230 aJournalFT(&aControlParentWin
, BibResId(FT_JOURNAL
)),
231 aNumberFT(&aControlParentWin
, BibResId(FT_NUMBER
)),
232 aSeriesFT(&aControlParentWin
, BibResId(FT_SERIES
)),
233 aAnnoteFT(&aControlParentWin
, BibResId(FT_ANNOTE
)),
234 aNoteFT(&aControlParentWin
, BibResId(FT_NOTE
)),
235 aURLFT(&aControlParentWin
, BibResId(FT_URL
)),
236 aThirdFL(&aControlParentWin
, BibResId(FL_3
)),
237 aCustom1FT(&aControlParentWin
, BibResId(FT_CUSTOM1
)),
238 aCustom2FT(&aControlParentWin
, BibResId(FT_CUSTOM2
)),
239 aCustom3FT(&aControlParentWin
, BibResId(FT_CUSTOM3
)),
240 aCustom4FT(&aControlParentWin
, BibResId(FT_CUSTOM4
)),
241 aCustom5FT(&aControlParentWin
, BibResId(FT_CUSTOM5
)),
242 aHoriScroll(this, WB_HORZ
),
243 aVertScroll(this, WB_VERT
),
244 sErrorPrefix(BibResId(ST_ERROR_PREFIX
)),
247 aControlParentWin
.Show();
248 aControlParentWin
.SetHelpId(HID_BIB_CONTROL_PARENT
);
249 aStdSize
= GetOutputSizePixel();
251 aBibTypeArr
[0] = String(BibResId(ST_TYPE_ARTICLE
));
252 aBibTypeArr
[1] = String(BibResId(ST_TYPE_BOOK
));
253 aBibTypeArr
[2] = String(BibResId(ST_TYPE_BOOKLET
));
254 aBibTypeArr
[3] = String(BibResId(ST_TYPE_CONFERENCE
));
255 aBibTypeArr
[4] = String(BibResId(ST_TYPE_INBOOK
));
256 aBibTypeArr
[5] = String(BibResId(ST_TYPE_INCOLLECTION
));
257 aBibTypeArr
[6] = String(BibResId(ST_TYPE_INPROCEEDINGS
));
258 aBibTypeArr
[7] = String(BibResId(ST_TYPE_JOURNAL
));
259 aBibTypeArr
[8] = String(BibResId(ST_TYPE_MANUAL
));
260 aBibTypeArr
[9] = String(BibResId(ST_TYPE_MASTERSTHESIS
));
261 aBibTypeArr
[10] = String(BibResId(ST_TYPE_MISC
));
262 aBibTypeArr
[11] = String(BibResId(ST_TYPE_PHDTHESIS
));
263 aBibTypeArr
[12] = String(BibResId(ST_TYPE_PROCEEDINGS
));
264 aBibTypeArr
[13] = String(BibResId(ST_TYPE_TECHREPORT
));
265 aBibTypeArr
[14] = String(BibResId(ST_TYPE_UNPUBLISHED
));
266 aBibTypeArr
[15] = String(BibResId(ST_TYPE_EMAIL
));
267 aBibTypeArr
[16] = String(BibResId(ST_TYPE_WWW
));
268 aBibTypeArr
[17] = String(BibResId(ST_TYPE_CUSTOM1
));
269 aBibTypeArr
[18] = String(BibResId(ST_TYPE_CUSTOM2
));
270 aBibTypeArr
[19] = String(BibResId(ST_TYPE_CUSTOM3
));
271 aBibTypeArr
[20] = String(BibResId(ST_TYPE_CUSTOM4
));
272 aBibTypeArr
[21] = String(BibResId(ST_TYPE_CUSTOM5
));
278 aBasePos
= aIdentifierFT
.GetPosPixel();
280 INT16
* pMap
= nFT2CtrlMap
;
281 for( USHORT i
= 0 ; i
< FIELD_COUNT
; ++i
, ++pMap
)
288 Link
aScrollLnk(LINK(this, BibGeneralPage
, ScrollHdl
));
289 aHoriScroll
.SetScrollHdl( aScrollLnk
);
290 aVertScroll
.SetScrollHdl( aScrollLnk
);
291 aHoriScroll
.SetLineSize(10);
292 aVertScroll
.SetLineSize(10);
293 aHoriScroll
.SetPageSize( aIdentifierFT
.GetSizePixel().Width());
294 aVertScroll
.SetPageSize(
295 aPublisherFT
.GetPosPixel().Y() - aIdentifierFT
.GetPosPixel().Y());
299 BibConfig
* pBibConfig
= BibModul::GetConfig();
300 BibDBDescriptor aDesc
;
301 aDesc
.sDataSource
= pDatMan
->getActiveDataSource();
302 aDesc
.sTableOrQuery
= pDatMan
->getActiveDataTable();
303 aDesc
.nCommandType
= CommandType::TABLE
;
304 const Mapping
* pMapping
= pBibConfig
->GetMapping(aDesc
);
306 xCtrlContnr
= VCLUnoHelper::CreateControlContainer(&aControlParentWin
);
308 xMgr
= comphelper::getProcessServiceFactory();
309 // the control should be a bit smaller than the fixed text
310 Size
aControlSize(aIdentifierFT
.GetSizePixel());
311 aControlSize
.Width() = aControlSize
.Width() * 8 / 10;
313 AddControlWithError( lcl_GetColumnName( pMapping
, IDENTIFIER_POS
), lcl_MovePoint( aIdentifierFT
),
314 aControlSize
, sTableErrorString
, aIdentifierFT
.GetText(),
315 HID_BIB_IDENTIFIER_POS
, 0 );
317 sTypeColumnName
= lcl_GetColumnName(pMapping
, AUTHORITYTYPE_POS
);
319 AddControlWithError( sTypeColumnName
, lcl_MovePoint(aAuthTypeFT
), aControlSize
, sTableErrorString
,
320 aAuthTypeFT
.GetText(), HID_BIB_AUTHORITYTYPE_POS
, 1 );
322 ::Point aYearPos
= lcl_MovePoint(aYearFT
);
323 AddControlWithError( lcl_GetColumnName( pMapping
, YEAR_POS
), aYearPos
,
324 aControlSize
, sTableErrorString
, aYearFT
.GetText(), HID_BIB_YEAR_POS
, 4 );
326 AddControlWithError( lcl_GetColumnName(pMapping
, AUTHOR_POS
), lcl_MovePoint(aAuthorFT
),
327 aControlSize
, sTableErrorString
, aAuthorFT
.GetText(), HID_BIB_AUTHOR_POS
, 2 );
329 ::Point
aTitlePos( lcl_MovePoint( aTitleFT
) );
330 ::Size aTitleSize
= aTitleFT
.GetSizePixel();
331 aTitleSize
.Width() = aYearPos
.X() + aControlSize
.Width() - aTitlePos
.X();
332 AddControlWithError( lcl_GetColumnName(pMapping
, TITLE_POS
), aTitlePos
, aTitleSize
, sTableErrorString
,
333 aTitleFT
.GetText(), HID_BIB_TITLE_POS
, 22 );
335 AddControlWithError( lcl_GetColumnName( pMapping
, PUBLISHER_POS
), lcl_MovePoint( aPublisherFT
),
336 aControlSize
, sTableErrorString
, aPublisherFT
.GetText(), HID_BIB_PUBLISHER_POS
, 5 );
338 AddControlWithError( lcl_GetColumnName( pMapping
, ADDRESS_POS
), lcl_MovePoint( aAddressFT
),
339 aControlSize
, sTableErrorString
, aAddressFT
.GetText(), HID_BIB_ADDRESS_POS
, 7 );
341 AddControlWithError( lcl_GetColumnName( pMapping
, ISBN_POS
), lcl_MovePoint( aISBNFT
),
342 aControlSize
, sTableErrorString
, aISBNFT
.GetText(), HID_BIB_ISBN_POS
, 6 );
344 AddControlWithError( lcl_GetColumnName( pMapping
, CHAPTER_POS
), lcl_MovePoint(aChapterFT
),
345 aControlSize
, sTableErrorString
, aChapterFT
.GetText(), HID_BIB_CHAPTER_POS
, 10 );
347 AddControlWithError( lcl_GetColumnName( pMapping
, PAGES_POS
), lcl_MovePoint( aPagesFT
),
348 aControlSize
, sTableErrorString
, aPagesFT
.GetText(), HID_BIB_PAGES_POS
, 19 );
350 AddControlWithError( lcl_GetColumnName( pMapping
, EDITOR_POS
), lcl_MovePoint( aEditorFT
),
351 aControlSize
, sTableErrorString
, aEditorFT
.GetText(), HID_BIB_EDITOR_POS
, 12 );
353 AddControlWithError( lcl_GetColumnName( pMapping
, EDITION_POS
), lcl_MovePoint(aEditionFT
),
354 aControlSize
, sTableErrorString
, aEditionFT
.GetText(), HID_BIB_EDITION_POS
, 11 );
356 AddControlWithError( lcl_GetColumnName(pMapping
, BOOKTITLE_POS
), lcl_MovePoint(aBooktitleFT
),
357 aControlSize
, sTableErrorString
, aBooktitleFT
.GetText(), HID_BIB_BOOKTITLE_POS
, 9 );
359 AddControlWithError( lcl_GetColumnName( pMapping
, VOLUME_POS
), lcl_MovePoint( aVolumeFT
),
360 aControlSize
, sTableErrorString
, aVolumeFT
.GetText(), HID_BIB_VOLUME_POS
, 24 );
362 AddControlWithError( lcl_GetColumnName( pMapping
, HOWPUBLISHED_POS
), lcl_MovePoint( aHowpublishedFT
),
363 aControlSize
, sTableErrorString
, aHowpublishedFT
.GetText(), HID_BIB_HOWPUBLISHED_POS
, 13 );
365 AddControlWithError( lcl_GetColumnName( pMapping
, ORGANIZATIONS_POS
), lcl_MovePoint( aOrganizationsFT
),
366 aControlSize
, sTableErrorString
, aOrganizationsFT
.GetText(), HID_BIB_ORGANIZATIONS_POS
, 18 );
368 AddControlWithError( lcl_GetColumnName( pMapping
, INSTITUTION_POS
), lcl_MovePoint( aInstitutionFT
),
369 aControlSize
, sTableErrorString
, aInstitutionFT
.GetText(), HID_BIB_INSTITUTION_POS
, 14 );
371 AddControlWithError( lcl_GetColumnName( pMapping
, SCHOOL_POS
), lcl_MovePoint( aSchoolFT
),
372 aControlSize
, sTableErrorString
, aSchoolFT
.GetText(), HID_BIB_SCHOOL_POS
, 20 );
374 AddControlWithError( lcl_GetColumnName( pMapping
, REPORTTYPE_POS
), lcl_MovePoint( aReportTypeFT
),
375 aControlSize
, sTableErrorString
, aReportTypeFT
.GetText(), HID_BIB_REPORTTYPE_POS
, 23 );
377 AddControlWithError( lcl_GetColumnName( pMapping
, MONTH_POS
), lcl_MovePoint( aMonthFT
),
378 aControlSize
, sTableErrorString
, aMonthFT
.GetText(), HID_BIB_MONTH_POS
, 3 );
380 AddControlWithError( lcl_GetColumnName( pMapping
, JOURNAL_POS
), lcl_MovePoint( aJournalFT
),
381 aControlSize
, sTableErrorString
, aJournalFT
.GetText(), HID_BIB_JOURNAL_POS
, 15 );
383 AddControlWithError( lcl_GetColumnName( pMapping
, NUMBER_POS
), lcl_MovePoint( aNumberFT
),
384 aControlSize
, sTableErrorString
, aNumberFT
.GetText(), HID_BIB_NUMBER_POS
, 17 );
386 AddControlWithError( lcl_GetColumnName( pMapping
, SERIES_POS
), lcl_MovePoint( aSeriesFT
),
387 aControlSize
, sTableErrorString
, aSeriesFT
.GetText(), HID_BIB_SERIES_POS
, 21 );
389 AddControlWithError( lcl_GetColumnName( pMapping
, ANNOTE_POS
), lcl_MovePoint( aAnnoteFT
),
390 aControlSize
, sTableErrorString
, aAnnoteFT
.GetText(), HID_BIB_ANNOTE_POS
, 8 );
392 AddControlWithError( lcl_GetColumnName( pMapping
, NOTE_POS
), lcl_MovePoint( aNoteFT
),
393 aControlSize
, sTableErrorString
, aNoteFT
.GetText(), HID_BIB_NOTE_POS
, 16 );
395 AddControlWithError( lcl_GetColumnName( pMapping
, URL_POS
), lcl_MovePoint( aURLFT
),
396 aControlSize
, sTableErrorString
, aURLFT
.GetText(), HID_BIB_URL_POS
, 25 );
398 AddControlWithError( lcl_GetColumnName( pMapping
, CUSTOM1_POS
), lcl_MovePoint( aCustom1FT
),
399 aControlSize
, sTableErrorString
, aCustom1FT
.GetText(), HID_BIB_CUSTOM1_POS
, 26 );
401 AddControlWithError( lcl_GetColumnName( pMapping
, CUSTOM2_POS
), lcl_MovePoint( aCustom2FT
),
402 aControlSize
, sTableErrorString
, aCustom2FT
.GetText(), HID_BIB_CUSTOM2_POS
, 27 );
404 AddControlWithError( lcl_GetColumnName( pMapping
, CUSTOM3_POS
), lcl_MovePoint( aCustom3FT
),
405 aControlSize
, sTableErrorString
, aCustom3FT
.GetText(), HID_BIB_CUSTOM3_POS
, 28 );
407 AddControlWithError( lcl_GetColumnName( pMapping
, CUSTOM4_POS
), lcl_MovePoint( aCustom4FT
),
408 aControlSize
, sTableErrorString
, aCustom4FT
.GetText(), HID_BIB_CUSTOM4_POS
, 29 );
410 AddControlWithError( lcl_GetColumnName( pMapping
, CUSTOM5_POS
), lcl_MovePoint( aCustom5FT
),
411 aControlSize
, sTableErrorString
, aCustom5FT
.GetText(), HID_BIB_CUSTOM5_POS
, 30 );
413 xPosListener
= new BibPosListener(this);
414 uno::Reference
< sdbc::XRowSet
> xRowSet(pDatMan
->getForm(), UNO_QUERY
);
416 xRowSet
->addRowSetListener(xPosListener
);
417 uno::Reference
< form::runtime::XFormController
> xFormCtrl
= pDatMan
->GetFormController();
418 xFormCtrl
->setContainer(xCtrlContnr
);
419 xFormCtrl
->activateTabOrder();
421 if(sTableErrorString
.Len())
422 sTableErrorString
.Insert(sErrorPrefix
, 0);
424 //-----------------------------------------------------------------------------
425 BibGeneralPage::~BibGeneralPage()
427 if (pDatMan
&& xPosListener
.is())
429 uno::Reference
< sdbc::XRowSet
> xRowSet(pDatMan
->getForm(), UNO_QUERY
);
431 xRowSet
->removeRowSetListener(xPosListener
);
434 /* -----------------------------14.04.00 13:11--------------------------------
436 ---------------------------------------------------------------------------*/
437 void BibGeneralPage::RemoveListeners()
439 for(USHORT i
= 0; i
< FIELD_COUNT
; i
++)
441 if(aControls
[i
].is())
443 uno::Reference
< awt::XWindow
> xCtrWin(aControls
[i
], uno::UNO_QUERY
);
444 xCtrWin
->removeFocusListener( this );
449 /* -----------------------------21.01.00 17:05--------------------------------
451 ---------------------------------------------------------------------------*/
452 void BibGeneralPage::CommitActiveControl()
454 uno::Reference
< form::runtime::XFormController
> xFormCtrl
= pDatMan
->GetFormController();
455 uno::Reference
< awt::XControl
> xCurr
= xFormCtrl
->getCurrentControl();
458 uno::Reference
< awt::XControlModel
> xModel
= xCurr
->getModel();
459 uno::Reference
< form::XBoundComponent
> xBound(xModel
, UNO_QUERY
);
464 //-----------------------------------------------------------------------------
465 void BibGeneralPage::AddControlWithError( const OUString
& rColumnName
, const ::Point
& rPos
, const ::Size
& rSize
,
466 String
& rErrorString
, String aColumnUIName
, sal_uInt16 nHelpId
, sal_uInt16 nIndexInFTArray
)
468 // adds also the XControl and creates a map entry in nFT2CtrlMap[] for mapping between control and FT
471 uno::Reference
< awt::XControlModel
> xTmp
= AddXControl(rColumnName
, rPos
, rSize
, nHelpId
, nIndex
);
474 DBG_ASSERT( nIndexInFTArray
< FIELD_COUNT
, "*BibGeneralPage::AddControlWithError(): wrong array index!" );
475 DBG_ASSERT( nFT2CtrlMap
[ nIndexInFTArray
] < 0, "+BibGeneralPage::AddControlWithError(): index already in use!" );
477 nFT2CtrlMap
[ nIndexInFTArray
] = nIndex
;
481 if( rErrorString
.Len() )
482 rErrorString
+= '\n';
484 rErrorString
+= MnemonicGenerator::EraseAllMnemonicChars( aColumnUIName
);
487 //-----------------------------------------------------------------------------
488 uno::Reference
< awt::XControlModel
> BibGeneralPage::AddXControl(
490 ::Point rPos
, ::Size rSize
, sal_uInt16 nHelpId
, INT16
& rIndex
)
492 uno::Reference
< awt::XControlModel
> xCtrModel
;
495 sal_Bool bTypeListBox
= sTypeColumnName
== rName
;
496 xCtrModel
= pDatMan
->loadControlModel(rName
, bTypeListBox
);
497 if ( xCtrModel
.is() && xMgr
.is())
499 uno::Reference
< beans::XPropertySet
> xPropSet( xCtrModel
, UNO_QUERY
);
503 uno::Reference
< beans::XPropertySetInfo
> xPropInfo
= xPropSet
->getPropertySetInfo();
505 uno::Any aAny
= xPropSet
->getPropertyValue( C2U("DefaultControl") );
506 rtl::OUString aControlName
;
507 aAny
>>= aControlName
;
509 rtl::OUString
uProp(C2U("HelpURL"));
510 if(xPropInfo
->hasPropertyByName(uProp
))
512 String
sId(C2S("HID:"));
513 sId
+= String::CreateFromInt32(nHelpId
);
514 rtl::OUString
uId(sId
) ;
515 uno::Any aVal
; aVal
<<= uId
;
516 xPropSet
->setPropertyValue(uProp
, aVal
);
521 //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY);
522 aAny
<<= (sal_Int16
)1;
523 xPropSet
->setPropertyValue(C2U("BoundColumn"), aAny
);
524 ListSourceType eSet
= ListSourceType_VALUELIST
;
525 aAny
.setValue( &eSet
, ::getCppuType((const ListSourceType
*)0) );
526 xPropSet
->setPropertyValue(C2U("ListSourceType"), aAny
);
528 uno::Sequence
<rtl::OUString
> aListSource(TYPE_COUNT
);
529 rtl::OUString
* pListSourceArr
= aListSource
.getArray();
530 //pListSourceArr[0] = C2U("select TypeName, TypeIndex from TypeNms");
531 for(sal_uInt16 i
= 0; i
< TYPE_COUNT
; i
++)
532 pListSourceArr
[i
] = String::CreateFromInt32(i
);
533 aAny
.setValue(&aListSource
, ::getCppuType((uno::Sequence
<rtl::OUString
>*)0));
535 xPropSet
->setPropertyValue(C2U("ListSource"), aAny
);
537 uno::Sequence
<rtl::OUString
> aValues(TYPE_COUNT
+ 1);
538 rtl::OUString
* pValuesArr
= aValues
.getArray();
539 for(sal_uInt16 j
= 0; j
< TYPE_COUNT
; j
++)
540 pValuesArr
[j
] = aBibTypeArr
[j
];
541 // empty string if an invalid value no values is set
542 pValuesArr
[TYPE_COUNT
] = rtl::OUString();
544 aAny
.setValue(&aValues
, ::getCppuType((uno::Sequence
<rtl::OUString
>*)0));
546 xPropSet
->setPropertyValue(C2U("StringItemList"), aAny
);
548 BOOL bTrue
= sal_True
;
549 aAny
.setValue( &bTrue
, ::getBooleanCppuType() );
550 xPropSet
->setPropertyValue( C2U("Dropdown"), aAny
);
552 aControlName
= C2U("com.sun.star.form.control.ListBox");
553 xLBModel
= Reference
< form::XBoundComponent
>(xCtrModel
, UNO_QUERY
);
557 uno::Reference
< awt::XControl
> xControl(xMgr
->createInstance( aControlName
), UNO_QUERY
);
560 xControl
->setModel( xCtrModel
);
562 // Peer als Child zu dem FrameWindow
563 xCtrlContnr
->addControl(rName
, xControl
);
564 uno::Reference
< awt::XWindow
> xCtrWin(xControl
, UNO_QUERY
);
565 xCtrWin
->addFocusListener( this );
566 rIndex
= -1; // -> implies, that not found
567 for(USHORT i
= 0; i
< FIELD_COUNT
; i
++)
568 if(!aControls
[i
].is())
570 aControls
[i
] = xCtrWin
;
574 xCtrWin
->setVisible( sal_True
);
575 xControl
->setDesignMode( sal_True
);
576 // initially switch on the desing mode - switch it off _after_ loading the form
577 // 17.10.2001 - 93107 - frank.schoenheit@sun.com
579 xCtrWin
->setPosSize(rPos
.X(), rPos
.Y(), rSize
.Width(),
580 rSize
.Height(), awt::PosSize::POSSIZE
);
585 catch(Exception
& rEx
)
587 (void) rEx
; // make compiler happy
588 DBG_ERROR("BibGeneralPage::AddXControl: something went wrong !");
593 void BibGeneralPage::AdjustScrollbars()
595 long nVertScrollWidth
= aVertScroll
.GetSizePixel().Width();
596 long nHoriScrollHeight
= aHoriScroll
.GetSizePixel().Height();
597 ::Size
aOutSize(GetOutputSizePixel());
598 BOOL bHoriVisible
= aOutSize
.Width() <= aStdSize
.Width();
599 BOOL bVertVisible
= (aOutSize
.Height()-(bHoriVisible
? nHoriScrollHeight
: 0)) <= (aStdSize
.Height());
600 aHoriScroll
.Show(bHoriVisible
);
601 aVertScroll
.Show(bVertVisible
);
605 ::Size
aHoriSize(aOutSize
.Width() - (bVertVisible
? nVertScrollWidth
: 0),
607 aHoriScroll
.SetSizePixel(aHoriSize
);
608 aHoriScroll
.SetRange( Range(0, aStdSize
.Width()));
609 aHoriScroll
.SetVisibleSize( aHoriSize
.Width() - (bVertVisible
? nVertScrollWidth
: 0));
613 ::Size
aVertSize(nHoriScrollHeight
, aOutSize
.Height() -
614 (bHoriVisible
? nHoriScrollHeight
: 0));
615 aVertScroll
.SetSizePixel(aVertSize
);
616 aVertScroll
.SetRange( Range(0, aStdSize
.Height()));
617 aVertScroll
.SetVisibleSize( aVertSize
.Height() );
621 aSize
= LogicToPixel(aSize
, MapMode(MAP_APPFONT
));
622 ::Size
aScrollSize(aOutSize
.Width() - aSize
.Height(), aSize
.Height());
623 ::Point
aScrollPos(0, aOutSize
.Height() - aSize
.Height());
624 aHoriScroll
.SetPosSizePixel(aScrollPos
, aScrollSize
);
626 aScrollPos
.X() = aOutSize
.Width() - aSize
.Width();
628 aScrollSize
.Width() = aSize
.Width();
629 aScrollSize
.Height() = aOutSize
.Height() - aSize
.Height();
630 aVertScroll
.SetPosSizePixel(aScrollPos
, aScrollSize
);
632 ::Size
aControlParentWinSz(aOutSize
);
634 aControlParentWinSz
.Height() -= aSize
.Height();
636 aControlParentWinSz
.Width() -= aSize
.Width();
637 aControlParentWin
.SetSizePixel(aControlParentWinSz
);
640 void BibGeneralPage::Resize()
643 ScrollHdl(&aVertScroll
);
644 ScrollHdl(&aHoriScroll
);
648 void BibGeneralPage::InitFixedTexts( void )
650 String aFixedStrings
[ FIELD_COUNT
] =
652 String( BibResId( ST_IDENTIFIER
) ),
653 String( BibResId( ST_AUTHTYPE
) ),
654 String( BibResId( ST_AUTHOR
) ),
655 String( BibResId( ST_TITLE
) ),
656 String( BibResId( ST_MONTH
) ),
657 String( BibResId( ST_YEAR
) ),
658 String( BibResId( ST_ISBN
) ),
659 String( BibResId( ST_BOOKTITLE
) ),
660 String( BibResId( ST_CHAPTER
) ),
661 String( BibResId( ST_EDITION
) ),
662 String( BibResId( ST_EDITOR
) ),
663 String( BibResId( ST_HOWPUBLISHED
) ),
664 String( BibResId( ST_INSTITUTION
) ),
665 String( BibResId( ST_JOURNAL
) ),
666 String( BibResId( ST_NOTE
) ),
667 String( BibResId( ST_ANNOTE
) ),
668 String( BibResId( ST_NUMBER
) ),
669 String( BibResId( ST_ORGANIZATION
) ),
670 String( BibResId( ST_PAGE
) ),
671 String( BibResId( ST_PUBLISHER
) ),
672 String( BibResId( ST_ADDRESS
) ),
673 String( BibResId( ST_SCHOOL
) ),
674 String( BibResId( ST_SERIES
) ),
675 String( BibResId( ST_REPORT
) ),
676 String( BibResId( ST_VOLUME
) ),
677 String( BibResId( ST_URL
) ),
678 String( BibResId( ST_CUSTOM1
) ),
679 String( BibResId( ST_CUSTOM2
) ),
680 String( BibResId( ST_CUSTOM3
) ),
681 String( BibResId( ST_CUSTOM4
) ),
682 String( BibResId( ST_CUSTOM5
) )
685 aFixedTexts
[0] = &aIdentifierFT
;
686 aFixedTexts
[1] = &aAuthTypeFT
;
687 aFixedTexts
[2] = &aAuthorFT
;
688 aFixedTexts
[3] = &aTitleFT
;
689 aFixedTexts
[4] = &aMonthFT
;
690 aFixedTexts
[5] = &aYearFT
;
691 aFixedTexts
[6] = &aISBNFT
;
692 aFixedTexts
[7] = &aBooktitleFT
;
693 aFixedTexts
[8] = &aChapterFT
;
694 aFixedTexts
[9] = &aEditionFT
;
695 aFixedTexts
[10] = &aEditorFT
;
696 aFixedTexts
[11] = &aHowpublishedFT
;
697 aFixedTexts
[12] = &aInstitutionFT
;
698 aFixedTexts
[13] = &aJournalFT
;
699 aFixedTexts
[14] = &aNoteFT
;
700 aFixedTexts
[15] = &aAnnoteFT
;
701 aFixedTexts
[16] = &aNumberFT
;
702 aFixedTexts
[17] = &aOrganizationsFT
;
703 aFixedTexts
[18] = &aPagesFT
;
704 aFixedTexts
[19] = &aPublisherFT
;
705 aFixedTexts
[20] = &aAddressFT
;
706 aFixedTexts
[21] = &aSchoolFT
;
707 aFixedTexts
[22] = &aSeriesFT
;
708 aFixedTexts
[23] = &aReportTypeFT
;
709 aFixedTexts
[24] = &aVolumeFT
;
710 aFixedTexts
[25] = &aURLFT
;
711 aFixedTexts
[26] = &aCustom1FT
;
712 aFixedTexts
[27] = &aCustom2FT
;
713 aFixedTexts
[28] = &aCustom3FT
;
714 aFixedTexts
[29] = &aCustom4FT
;
715 aFixedTexts
[30] = &aCustom5FT
;
719 MnemonicGenerator aMnemonicGenerator
;
720 // init mnemonics, first register all strings
721 for( i
= 0 ; i
< FIELD_COUNT
; ++i
)
722 aMnemonicGenerator
.RegisterMnemonic( aFixedStrings
[ i
] );
724 // ... then get all strings
725 for( i
= 0 ; i
< FIELD_COUNT
; ++i
)
726 aMnemonicGenerator
.CreateMnemonic( aFixedStrings
[ i
] );
729 for( i
= 0 ; i
< FIELD_COUNT
; ++i
)
730 aFixedTexts
[ i
]->SetText( aFixedStrings
[ i
] );
733 IMPL_LINK(BibGeneralPage
, ScrollHdl
, ScrollBar
*, pScroll
)
735 BOOL bVertical
= &aVertScroll
== pScroll
;
737 long nCurrentOffset
= 0;
739 nCurrentOffset
= aFixedTexts
[0]->GetPosPixel().Y() - aBasePos
.Y();
741 nCurrentOffset
= aFixedTexts
[0]->GetPosPixel().X() - aBasePos
.X();
742 nOffset
= pScroll
->IsVisible() ? pScroll
->GetThumbPos() + nCurrentOffset
: nCurrentOffset
;;
744 for(USHORT i
= 0; i
< FIELD_COUNT
; i
++)
746 ::Point aPos
= aFixedTexts
[i
]->GetPosPixel();
751 aFixedTexts
[i
]->SetPosPixel(aPos
);
752 if(aControls
[i
].is())
754 awt::Rectangle aRect
= aControls
[i
]->getPosSize();
761 aControls
[i
]->setPosSize(nX
, nY
, 0, 0, awt::PosSize::POS
);
767 void BibGeneralPage::focusGained(const awt::FocusEvent
& rEvent
) throw( uno::RuntimeException
)
769 Reference
<awt::XWindow
> xCtrWin(rEvent
.Source
, UNO_QUERY
);
772 ::Size aOutSize
= aControlParentWin
.GetOutputSizePixel();
773 awt::Rectangle aRect
= xCtrWin
->getPosSize();
777 // left of the visible area
778 aHoriScroll
.SetThumbPos(aHoriScroll
.GetThumbPos() + nX
);
779 ScrollHdl(&aHoriScroll
);
781 else if(nX
> aOutSize
.Width())
783 // right of the visible area
784 aHoriScroll
.SetThumbPos(aHoriScroll
.GetThumbPos() + nX
- aOutSize
.Width() + aFixedTexts
[0]->GetSizePixel().Width());
785 ScrollHdl(&aHoriScroll
);
790 // below the visible area
791 aVertScroll
.SetThumbPos(aVertScroll
.GetThumbPos() + nY
);
792 ScrollHdl(&aVertScroll
);
794 else if(nY
> aOutSize
.Height())
796 // over the visible area
797 aVertScroll
.SetThumbPos(aVertScroll
.GetThumbPos() + nY
- aOutSize
.Height()+ aFixedTexts
[0]->GetSizePixel().Height());
798 ScrollHdl(&aVertScroll
);
803 void BibGeneralPage::focusLost(const awt::FocusEvent
& ) throw( uno::RuntimeException
)
805 CommitActiveControl();
808 void BibGeneralPage::disposing(const lang::EventObject
& /*Source*/) throw( uno::RuntimeException
)
812 void BibGeneralPage::GetFocus()
814 Reference
< awt::XWindow
>* pxControl
= aControls
;
816 for( int i
= FIELD_COUNT
; i
; --i
, ++pxControl
)
818 if( pxControl
->is() )
820 ( *pxControl
)->setFocus();
826 aControlParentWin
.GrabFocus();
829 BOOL
BibGeneralPage::HandleShortCutKey( const KeyEvent
& rKeyEvent
)
831 DBG_ASSERT( KEY_MOD2
== rKeyEvent
.GetKeyCode().GetModifier(), "+BibGeneralPage::HandleShortCutKey(): this is not for me!" );
833 const vcl::I18nHelper
& rI18nHelper
= Application::GetSettings().GetUILocaleI18nHelper();
834 const xub_Unicode c
= rKeyEvent
.GetCharCode();
835 BOOL bHandled
= FALSE
;
839 typedef std::vector
< sal_Int16
> sal_Int16_vector
;
841 sal_Int16_vector::size_type nFocused
= 0xFFFF; // index of focused in vector, no one focused initial
842 DBG_ASSERT( nFocused
> 0, "*BibGeneralPage::HandleShortCutKey(): size_type works not as expected!" );
844 sal_Int16_vector aMatchList
;
846 for( i
= 0 ; i
< FIELD_COUNT
; ++i
)
848 if( rI18nHelper
.MatchMnemonic( aFixedTexts
[ i
]->GetText(), c
) )
851 sal_Int16 nCtrlIndex
= nFT2CtrlMap
[ i
];
853 if( nCtrlIndex
>= 0 )
854 { // store index of control
855 DBG_ASSERT( aControls
[ nCtrlIndex
].is(), "-BibGeneralPage::HandleShortCutKey(): valid index and no control?" );
857 uno::Reference
< awt::XControl
> xControl( aControls
[ nCtrlIndex
], UNO_QUERY
);
858 DBG_ASSERT( xControl
.is(), "-BibGeneralPage::HandleShortCutKey(): a control wich is not a control!" );
860 Window
* pWindow
= VCLUnoHelper::GetWindow( xControl
->getPeer() );
864 aMatchList
.push_back( nCtrlIndex
);
865 if( pWindow
->HasChildPathFocus() )
866 { // save focused control
867 DBG_ASSERT( nFocused
== 0xFFFF, "+BibGeneralPage::HandleShortCutKey(): more than one with focus?!" );
868 DBG_ASSERT( aMatchList
.size() > 0, "+BibGeneralPage::HandleShortCutKey(): push_back and no content?!" );
869 nFocused
= aMatchList
.size() - 1;
878 DBG_ASSERT( aMatchList
.size() > 0, "*BibGeneralPage::HandleShortCutKey(): be prepared to crash..." );
880 if( nFocused
>= ( aMatchList
.size() - 1 ) )
881 // >=... includes 0xFFFF
882 // no one or last focused, take first
888 aControls
[ aMatchList
[ nFocused
] ]->setFocus();