Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #include <comphelper/processfactory.hxx>
30 : : #include <com/sun/star/awt/PosSize.hpp>
31 : : #include <com/sun/star/sdbc/XRowSet.hpp>
32 : : #include <com/sun/star/sdb/XColumn.hpp>
33 : : #include <com/sun/star/sdb/CommandType.hpp>
34 : : #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
35 : : #include <com/sun/star/form/ListSourceType.hpp>
36 : : #include <com/sun/star/awt/XWindow.hpp>
37 : : #include <toolkit/helper/vclunohelper.hxx>
38 : : #include <cppuhelper/implbase1.hxx> // helper for implementations
39 : : #include "general.hxx"
40 : : #include "sections.hrc"
41 : : #include "bibresid.hxx"
42 : : #include "datman.hxx"
43 : : #include "bibconfig.hxx"
44 : : #include "bibprop.hrc"
45 : : #include "bib.hrc"
46 : : #include "bibmod.hxx"
47 : : #include "bibtools.hxx"
48 : : #include "bibliography.hrc"
49 : : #include <tools/debug.hxx>
50 : : #include <vcl/svapp.hxx>
51 : : #include <vcl/i18nhelp.hxx>
52 : : #include <vcl/mnemonic.hxx>
53 : : #include <algorithm>
54 : : #include <functional>
55 : : #include <vector>
56 : : #include <tools/urlobj.hxx>
57 : :
58 : : using namespace ::com::sun::star;
59 : : using namespace ::com::sun::star::uno;
60 : : using namespace ::com::sun::star::form;
61 : : using namespace ::com::sun::star::sdb;
62 : : using namespace ::rtl;
63 : :
64 : : #define C2U(cChar) OUString::createFromAscii(cChar)
65 : : #define C2S(cChar) String::CreateFromAscii(cChar)
66 : : #define DISTANCE_CONTROL_TO_FIXEDTEXT 5
67 : :
68 : 0 : ::Point lcl_MovePoint(const FixedText& rFixedText)
69 : : {
70 : 0 : ::Point aRet(rFixedText.GetPosPixel());
71 : 0 : aRet.X() += rFixedText.GetSizePixel().Width();
72 : 0 : aRet.X() += DISTANCE_CONTROL_TO_FIXEDTEXT;
73 : 0 : return aRet;
74 : : }
75 : :
76 : : //-----------------------------------------------------------------------------
77 : 0 : OUString lcl_GetColumnName( const Mapping* pMapping, sal_uInt16 nIndexPos )
78 : : {
79 : 0 : BibConfig* pBibConfig = BibModul::GetConfig();
80 : 0 : OUString sRet = pBibConfig->GetDefColumnName(nIndexPos);
81 [ # # ]: 0 : if(pMapping)
82 [ # # ]: 0 : for(sal_uInt16 i = 0; i < COLUMN_COUNT; i++)
83 : : {
84 [ # # ]: 0 : if(pMapping->aColumnPairs[i].sLogicalColumnName == sRet)
85 : : {
86 : 0 : sRet = pMapping->aColumnPairs[i].sRealColumnName;
87 : 0 : break;
88 : : }
89 : : }
90 : 0 : return sRet;
91 : : }
92 : :
93 [ # # ]: 0 : class BibPosListener :public cppu::WeakImplHelper1 <sdbc::XRowSetListener>
94 : : {
95 : : BibGeneralPage* pParentPage;
96 : : public:
97 : : BibPosListener(BibGeneralPage* pParent);
98 : :
99 : : //XPositioningListener
100 : : virtual void SAL_CALL cursorMoved(const lang::EventObject& event) throw( uno::RuntimeException );
101 : 0 : virtual void SAL_CALL rowChanged(const lang::EventObject& /*event*/) throw( uno::RuntimeException ){ /* not interested in */ }
102 : 0 : virtual void SAL_CALL rowSetChanged(const lang::EventObject& /*event*/) throw( uno::RuntimeException ){ /* not interested in */ }
103 : :
104 : : //XEventListener
105 : : virtual void SAL_CALL disposing(const lang::EventObject& Source) throw( uno::RuntimeException );
106 : :
107 : : };
108 : :
109 : 0 : BibPosListener::BibPosListener(BibGeneralPage* pParent) :
110 : 0 : pParentPage(pParent)
111 : : {
112 : 0 : }
113 : :
114 : 0 : void BibPosListener::cursorMoved(const lang::EventObject& /*aEvent*/) throw( uno::RuntimeException )
115 : : {
116 : : try
117 : : {
118 : 0 : uno::Reference< form::XBoundComponent > xLstBox = pParentPage->GetTypeListBoxModel();
119 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet(xLstBox, UNO_QUERY);
120 [ # # ]: 0 : if(xPropSet.is())
121 : : {
122 [ # # ]: 0 : BibConfig* pBibConfig = BibModul::GetConfig();
123 : 0 : BibDataManager* pDatMan = pParentPage->GetDataManager();
124 : 0 : BibDBDescriptor aDesc;
125 : 0 : aDesc.sDataSource = pDatMan->getActiveDataSource();
126 [ # # ]: 0 : aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
127 : 0 : aDesc.nCommandType = CommandType::TABLE;
128 : :
129 [ # # ]: 0 : const Mapping* pMapping = pBibConfig->GetMapping(aDesc);
130 : 0 : OUString sTypeMapping = pBibConfig->GetDefColumnName(AUTHORITYTYPE_POS);
131 [ # # ]: 0 : if(pMapping)
132 : : {
133 [ # # ]: 0 : for(sal_uInt16 nEntry = 0; nEntry < COLUMN_COUNT; nEntry++)
134 : : {
135 [ # # ]: 0 : if(pMapping->aColumnPairs[nEntry].sLogicalColumnName == sTypeMapping)
136 : : {
137 : 0 : sTypeMapping = pMapping->aColumnPairs[nEntry].sRealColumnName;
138 : 0 : break;
139 : : }
140 : : }
141 : : }
142 : 0 : rtl::OUString uTypeMapping = sTypeMapping;
143 : :
144 : 0 : uno::Reference< form::XForm > xForm = pDatMan->getForm();
145 [ # # ]: 0 : uno::Reference< sdbcx::XColumnsSupplier > xSupplyCols(xForm, UNO_QUERY);
146 : 0 : uno::Reference< container::XNameAccess > xValueAcc;
147 [ # # ]: 0 : if (xSupplyCols.is())
148 [ # # ][ # # ]: 0 : xValueAcc = xSupplyCols->getColumns();
[ # # ]
149 : :
150 : 0 : sal_Int16 nTempVal = -1;
151 [ # # ][ # # ]: 0 : if(xValueAcc.is() && xValueAcc->hasByName(uTypeMapping))
[ # # ][ # # ]
[ # # ]
152 : : {
153 [ # # ][ # # ]: 0 : uno::Any aVal = xValueAcc->getByName(uTypeMapping);
154 : 0 : uno::Reference< uno::XInterface > xInt = *(uno::Reference< uno::XInterface > *)aVal.getValue();
155 [ # # ]: 0 : uno::Reference< sdb::XColumn > xCol(xInt, UNO_QUERY);
156 : : DBG_ASSERT(xCol.is(), "BibPosListener::cursorMoved : invalid column (no sdb::XColumn) !");
157 [ # # ]: 0 : if (xCol.is())
158 : : {
159 [ # # ][ # # ]: 0 : nTempVal = xCol->getShort();
160 : : // getShort returns zero if the value is not a number
161 [ # # ][ # # ]: 0 : if (!nTempVal || xCol->wasNull())
[ # # ][ # # ]
[ # # ]
162 : : {
163 [ # # ][ # # ]: 0 : rtl::OUString sTempVal = xCol->getString();
164 [ # # ]: 0 : if(sTempVal != rtl::OUString('0'))
165 : 0 : nTempVal = -1;
166 : : }
167 : 0 : }
168 : : }
169 [ # # ][ # # ]: 0 : if(nTempVal < 0 || nTempVal >= TYPE_COUNT)
170 : : {
171 : 0 : uno::Any aSel;
172 [ # # ]: 0 : uno::Sequence<sal_Int16> aSelSeq(1);
173 [ # # ]: 0 : sal_Int16* pArr = aSelSeq.getArray();
174 : 0 : pArr[0] = TYPE_COUNT;
175 [ # # ]: 0 : aSel.setValue(&aSelSeq, ::getCppuType((Sequence<sal_Int16>*)0));
176 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue(C2U("SelectedItems"), aSel);
[ # # ]
177 : 0 : }
178 [ # # ]: 0 : }
179 : : }
180 : 0 : catch(const Exception&)
181 : : {
182 : : OSL_FAIL("BibPosListener::cursorMoved: something went wrong !");
183 : : }
184 : 0 : }
185 : :
186 : 0 : void BibPosListener::disposing(const lang::EventObject& /*Source*/) throw( uno::RuntimeException )
187 : : {
188 : 0 : }
189 : :
190 : 0 : BibGeneralPage::BibGeneralPage(Window* pParent, BibDataManager* pMan):
191 : : BibTabPage(pParent,BibResId(RID_TP_GENERAL)),
192 : : aControlParentWin(this, WB_DIALOGCONTROL),
193 : : aIdentifierFT(&aControlParentWin, BibResId(FT_IDENTIFIER )),
194 : : aAuthTypeFT(&aControlParentWin, BibResId(FT_AUTHTYPE )),
195 : : aYearFT(&aControlParentWin, BibResId(FT_YEAR )),
196 : : aAuthorFT(&aControlParentWin, BibResId(FT_AUTHOR )),
197 : : aTitleFT(&aControlParentWin, BibResId(FT_TITLE )),
198 : : aPublisherFT(&aControlParentWin, BibResId(FT_PUBLISHER )),
199 : : aAddressFT(&aControlParentWin, BibResId(FT_ADDRESS )),
200 : : aISBNFT(&aControlParentWin, BibResId(FT_ISBN )),
201 : : aChapterFT(&aControlParentWin, BibResId(FT_CHAPTER )),
202 : : aPagesFT(&aControlParentWin, BibResId(FT_PAGE )),
203 : : aFirstFL(&aControlParentWin, BibResId(FL_1 )),
204 : : aEditorFT(&aControlParentWin, BibResId(FT_EDITOR )),
205 : : aEditionFT(&aControlParentWin, BibResId(FT_EDITION )),
206 : : aBooktitleFT(&aControlParentWin, BibResId(FT_BOOKTITLE )),
207 : : aVolumeFT(&aControlParentWin, BibResId(FT_VOLUME )),
208 : : aHowpublishedFT(&aControlParentWin, BibResId(FT_HOWPUBLISHED )),
209 : : aOrganizationsFT(&aControlParentWin,BibResId(FT_ORGANIZATION )),
210 : : aInstitutionFT(&aControlParentWin, BibResId(FT_INSTITUTION )),
211 : : aSchoolFT(&aControlParentWin, BibResId(FT_SCHOOL )),
212 : : aReportTypeFT(&aControlParentWin, BibResId(FT_REPORT )),
213 : : aMonthFT(&aControlParentWin, BibResId(FT_MONTH )),
214 : : aSecondFL(&aControlParentWin, BibResId(FL_2 )),
215 : : aJournalFT(&aControlParentWin, BibResId(FT_JOURNAL )),
216 : : aNumberFT(&aControlParentWin, BibResId(FT_NUMBER )),
217 : : aSeriesFT(&aControlParentWin, BibResId(FT_SERIES )),
218 : : aAnnoteFT(&aControlParentWin, BibResId(FT_ANNOTE )),
219 : : aNoteFT(&aControlParentWin, BibResId(FT_NOTE )),
220 : : aURLFT(&aControlParentWin, BibResId(FT_URL )),
221 : : aThirdFL(&aControlParentWin, BibResId(FL_3 )),
222 : : aCustom1FT(&aControlParentWin, BibResId(FT_CUSTOM1 )),
223 : : aCustom2FT(&aControlParentWin, BibResId(FT_CUSTOM2 )),
224 : : aCustom3FT(&aControlParentWin, BibResId(FT_CUSTOM3 )),
225 : : aCustom4FT(&aControlParentWin, BibResId(FT_CUSTOM4 )),
226 : : aCustom5FT(&aControlParentWin, BibResId(FT_CUSTOM5 )),
227 : : aHoriScroll(this, WB_HORZ),
228 : : aVertScroll(this, WB_VERT),
229 : : sErrorPrefix(BibResId(ST_ERROR_PREFIX)),
230 [ # # ][ # # ]: 0 : pDatMan(pMan)
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # # ]
231 : : {
232 [ # # ]: 0 : aControlParentWin.Show();
233 [ # # ]: 0 : aControlParentWin.SetHelpId(HID_BIB_CONTROL_PARENT);
234 : 0 : aStdSize = GetOutputSizePixel();
235 : :
236 [ # # ][ # # ]: 0 : aBibTypeArr[0] = String(BibResId(ST_TYPE_ARTICLE));
[ # # ][ # # ]
237 [ # # ][ # # ]: 0 : aBibTypeArr[1] = String(BibResId(ST_TYPE_BOOK));
[ # # ][ # # ]
238 [ # # ][ # # ]: 0 : aBibTypeArr[2] = String(BibResId(ST_TYPE_BOOKLET));
[ # # ][ # # ]
239 [ # # ][ # # ]: 0 : aBibTypeArr[3] = String(BibResId(ST_TYPE_CONFERENCE));
[ # # ][ # # ]
240 [ # # ][ # # ]: 0 : aBibTypeArr[4] = String(BibResId(ST_TYPE_INBOOK ));
[ # # ][ # # ]
241 [ # # ][ # # ]: 0 : aBibTypeArr[5] = String(BibResId(ST_TYPE_INCOLLECTION));
[ # # ][ # # ]
242 [ # # ][ # # ]: 0 : aBibTypeArr[6] = String(BibResId(ST_TYPE_INPROCEEDINGS));
[ # # ][ # # ]
243 [ # # ][ # # ]: 0 : aBibTypeArr[7] = String(BibResId(ST_TYPE_JOURNAL ));
[ # # ][ # # ]
244 [ # # ][ # # ]: 0 : aBibTypeArr[8] = String(BibResId(ST_TYPE_MANUAL ));
[ # # ][ # # ]
245 [ # # ][ # # ]: 0 : aBibTypeArr[9] = String(BibResId(ST_TYPE_MASTERSTHESIS));
[ # # ][ # # ]
246 [ # # ][ # # ]: 0 : aBibTypeArr[10] = String(BibResId(ST_TYPE_MISC ));
[ # # ][ # # ]
247 [ # # ][ # # ]: 0 : aBibTypeArr[11] = String(BibResId(ST_TYPE_PHDTHESIS ));
[ # # ][ # # ]
248 [ # # ][ # # ]: 0 : aBibTypeArr[12] = String(BibResId(ST_TYPE_PROCEEDINGS ));
[ # # ][ # # ]
249 [ # # ][ # # ]: 0 : aBibTypeArr[13] = String(BibResId(ST_TYPE_TECHREPORT ));
[ # # ][ # # ]
250 [ # # ][ # # ]: 0 : aBibTypeArr[14] = String(BibResId(ST_TYPE_UNPUBLISHED ));
[ # # ][ # # ]
251 [ # # ][ # # ]: 0 : aBibTypeArr[15] = String(BibResId(ST_TYPE_EMAIL ));
[ # # ][ # # ]
252 [ # # ][ # # ]: 0 : aBibTypeArr[16] = String(BibResId(ST_TYPE_WWW ));
[ # # ][ # # ]
253 [ # # ][ # # ]: 0 : aBibTypeArr[17] = String(BibResId(ST_TYPE_CUSTOM1 ));
[ # # ][ # # ]
254 [ # # ][ # # ]: 0 : aBibTypeArr[18] = String(BibResId(ST_TYPE_CUSTOM2 ));
[ # # ][ # # ]
255 [ # # ][ # # ]: 0 : aBibTypeArr[19] = String(BibResId(ST_TYPE_CUSTOM3 ));
[ # # ][ # # ]
256 [ # # ][ # # ]: 0 : aBibTypeArr[20] = String(BibResId(ST_TYPE_CUSTOM4 ));
[ # # ][ # # ]
257 [ # # ][ # # ]: 0 : aBibTypeArr[21] = String(BibResId(ST_TYPE_CUSTOM5 ));
[ # # ][ # # ]
258 : :
259 [ # # ]: 0 : FreeResource();
260 : :
261 [ # # ]: 0 : InitFixedTexts();
262 : :
263 [ # # ]: 0 : aBasePos = aIdentifierFT.GetPosPixel();
264 : :
265 : 0 : sal_Int16* pMap = nFT2CtrlMap;
266 [ # # ]: 0 : for( sal_uInt16 i = 0 ; i < FIELD_COUNT ; ++i, ++pMap )
267 : : {
268 [ # # ]: 0 : aControls[ i ] = 0;
269 : 0 : *pMap = -1;
270 : : }
271 : :
272 [ # # ]: 0 : AdjustScrollbars();
273 [ # # ]: 0 : Link aScrollLnk(LINK(this, BibGeneralPage, ScrollHdl));
274 : 0 : aHoriScroll.SetScrollHdl( aScrollLnk );
275 : 0 : aVertScroll.SetScrollHdl( aScrollLnk );
276 : 0 : aHoriScroll.SetLineSize(10);
277 : 0 : aVertScroll.SetLineSize(10);
278 [ # # ]: 0 : aHoriScroll.SetPageSize( aIdentifierFT.GetSizePixel().Width());
279 : : aVertScroll.SetPageSize(
280 [ # # ][ # # ]: 0 : aPublisherFT.GetPosPixel().Y() - aIdentifierFT.GetPosPixel().Y());
281 [ # # ]: 0 : aHoriScroll.Show();
282 [ # # ]: 0 : aVertScroll.Show();
283 : :
284 [ # # ]: 0 : BibConfig* pBibConfig = BibModul::GetConfig();
285 : 0 : BibDBDescriptor aDesc;
286 : 0 : aDesc.sDataSource = pDatMan->getActiveDataSource();
287 [ # # ]: 0 : aDesc.sTableOrQuery = pDatMan->getActiveDataTable();
288 : 0 : aDesc.nCommandType = CommandType::TABLE;
289 [ # # ]: 0 : const Mapping* pMapping = pBibConfig->GetMapping(aDesc);
290 : :
291 [ # # ][ # # ]: 0 : xCtrlContnr = VCLUnoHelper::CreateControlContainer(&aControlParentWin);
292 : :
293 [ # # ][ # # ]: 0 : xMgr = comphelper::getProcessServiceFactory();
294 : : // the control should be a bit smaller than the fixed text
295 [ # # ]: 0 : Size aControlSize(aIdentifierFT.GetSizePixel());
296 : 0 : aControlSize.Width() = aControlSize.Width() * 8 / 10;
297 : :
298 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, IDENTIFIER_POS ), lcl_MovePoint( aIdentifierFT ),
299 : : aControlSize, sTableErrorString, aIdentifierFT.GetText(),
300 [ # # ][ # # ]: 0 : HID_BIB_IDENTIFIER_POS, 0 );
[ # # ][ # # ]
[ # # ]
301 : :
302 [ # # ][ # # ]: 0 : sTypeColumnName = lcl_GetColumnName(pMapping, AUTHORITYTYPE_POS);
303 : :
304 : 0 : AddControlWithError( sTypeColumnName, lcl_MovePoint(aAuthTypeFT ), aControlSize, sTableErrorString,
305 [ # # ][ # # ]: 0 : aAuthTypeFT.GetText(), HID_BIB_AUTHORITYTYPE_POS, 1 );
[ # # ][ # # ]
[ # # ]
306 : :
307 [ # # ]: 0 : ::Point aYearPos = lcl_MovePoint(aYearFT);
308 : : AddControlWithError( lcl_GetColumnName( pMapping, YEAR_POS ), aYearPos,
309 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aYearFT.GetText(), HID_BIB_YEAR_POS, 4 );
[ # # ][ # # ]
310 : :
311 : 0 : AddControlWithError( lcl_GetColumnName(pMapping, AUTHOR_POS), lcl_MovePoint(aAuthorFT),
312 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aAuthorFT.GetText(), HID_BIB_AUTHOR_POS, 2 );
[ # # ][ # # ]
[ # # ]
313 : :
314 [ # # ]: 0 : ::Point aTitlePos( lcl_MovePoint( aTitleFT ) );
315 [ # # ]: 0 : ::Size aTitleSize = aTitleFT.GetSizePixel();
316 : 0 : aTitleSize.Width() = aYearPos.X() + aControlSize.Width() - aTitlePos.X();
317 : : AddControlWithError( lcl_GetColumnName(pMapping, TITLE_POS), aTitlePos, aTitleSize, sTableErrorString,
318 [ # # ][ # # ]: 0 : aTitleFT.GetText(), HID_BIB_TITLE_POS, 22 );
[ # # ][ # # ]
319 : :
320 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, PUBLISHER_POS ), lcl_MovePoint( aPublisherFT),
321 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aPublisherFT.GetText(), HID_BIB_PUBLISHER_POS, 5 );
[ # # ][ # # ]
[ # # ]
322 : :
323 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, ADDRESS_POS ), lcl_MovePoint( aAddressFT ),
324 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aAddressFT.GetText(), HID_BIB_ADDRESS_POS, 7 );
[ # # ][ # # ]
[ # # ]
325 : :
326 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, ISBN_POS ), lcl_MovePoint( aISBNFT ),
327 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aISBNFT.GetText(), HID_BIB_ISBN_POS, 6 );
[ # # ][ # # ]
[ # # ]
328 : :
329 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CHAPTER_POS ), lcl_MovePoint(aChapterFT),
330 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aChapterFT.GetText(), HID_BIB_CHAPTER_POS, 10 );
[ # # ][ # # ]
[ # # ]
331 : :
332 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, PAGES_POS ), lcl_MovePoint( aPagesFT ),
333 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aPagesFT.GetText(), HID_BIB_PAGES_POS, 19 );
[ # # ][ # # ]
[ # # ]
334 : :
335 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, EDITOR_POS ), lcl_MovePoint( aEditorFT ),
336 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aEditorFT.GetText(), HID_BIB_EDITOR_POS, 12 );
[ # # ][ # # ]
[ # # ]
337 : :
338 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, EDITION_POS ), lcl_MovePoint(aEditionFT),
339 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aEditionFT.GetText(), HID_BIB_EDITION_POS, 11 );
[ # # ][ # # ]
[ # # ]
340 : :
341 : 0 : AddControlWithError( lcl_GetColumnName(pMapping, BOOKTITLE_POS), lcl_MovePoint(aBooktitleFT),
342 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aBooktitleFT.GetText(), HID_BIB_BOOKTITLE_POS, 9 );
[ # # ][ # # ]
[ # # ]
343 : :
344 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, VOLUME_POS ), lcl_MovePoint( aVolumeFT ),
345 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aVolumeFT.GetText(), HID_BIB_VOLUME_POS, 24 );
[ # # ][ # # ]
[ # # ]
346 : :
347 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, HOWPUBLISHED_POS ), lcl_MovePoint( aHowpublishedFT ),
348 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aHowpublishedFT.GetText(), HID_BIB_HOWPUBLISHED_POS, 13 );
[ # # ][ # # ]
[ # # ]
349 : :
350 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, ORGANIZATIONS_POS ), lcl_MovePoint( aOrganizationsFT ),
351 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aOrganizationsFT.GetText(), HID_BIB_ORGANIZATIONS_POS, 18 );
[ # # ][ # # ]
[ # # ]
352 : :
353 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, INSTITUTION_POS ), lcl_MovePoint( aInstitutionFT ),
354 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aInstitutionFT.GetText(), HID_BIB_INSTITUTION_POS, 14 );
[ # # ][ # # ]
[ # # ]
355 : :
356 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, SCHOOL_POS ), lcl_MovePoint( aSchoolFT ),
357 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aSchoolFT.GetText(), HID_BIB_SCHOOL_POS, 20 );
[ # # ][ # # ]
[ # # ]
358 : :
359 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, REPORTTYPE_POS ), lcl_MovePoint( aReportTypeFT ),
360 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aReportTypeFT.GetText(), HID_BIB_REPORTTYPE_POS, 23 );
[ # # ][ # # ]
[ # # ]
361 : :
362 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, MONTH_POS ), lcl_MovePoint( aMonthFT ),
363 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aMonthFT.GetText(), HID_BIB_MONTH_POS, 3 );
[ # # ][ # # ]
[ # # ]
364 : :
365 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, JOURNAL_POS ), lcl_MovePoint( aJournalFT ),
366 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aJournalFT.GetText(), HID_BIB_JOURNAL_POS, 15 );
[ # # ][ # # ]
[ # # ]
367 : :
368 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, NUMBER_POS ), lcl_MovePoint( aNumberFT ),
369 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aNumberFT.GetText(), HID_BIB_NUMBER_POS, 17 );
[ # # ][ # # ]
[ # # ]
370 : :
371 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, SERIES_POS ), lcl_MovePoint( aSeriesFT ),
372 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aSeriesFT.GetText(), HID_BIB_SERIES_POS, 21 );
[ # # ][ # # ]
[ # # ]
373 : :
374 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, ANNOTE_POS ), lcl_MovePoint( aAnnoteFT ),
375 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aAnnoteFT.GetText(), HID_BIB_ANNOTE_POS, 8 );
[ # # ][ # # ]
[ # # ]
376 : :
377 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, NOTE_POS ), lcl_MovePoint( aNoteFT ),
378 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aNoteFT.GetText(), HID_BIB_NOTE_POS, 16 );
[ # # ][ # # ]
[ # # ]
379 : :
380 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, URL_POS ), lcl_MovePoint( aURLFT ),
381 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aURLFT.GetText(), HID_BIB_URL_POS, 25 );
[ # # ][ # # ]
[ # # ]
382 : :
383 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM1_POS ), lcl_MovePoint( aCustom1FT ),
384 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aCustom1FT.GetText(), HID_BIB_CUSTOM1_POS, 26 );
[ # # ][ # # ]
[ # # ]
385 : :
386 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM2_POS ), lcl_MovePoint( aCustom2FT ),
387 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aCustom2FT.GetText(), HID_BIB_CUSTOM2_POS, 27 );
[ # # ][ # # ]
[ # # ]
388 : :
389 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM3_POS ), lcl_MovePoint( aCustom3FT ),
390 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aCustom3FT.GetText(), HID_BIB_CUSTOM3_POS, 28 );
[ # # ][ # # ]
[ # # ]
391 : :
392 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM4_POS ), lcl_MovePoint( aCustom4FT ),
393 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aCustom4FT.GetText(), HID_BIB_CUSTOM4_POS, 29 );
[ # # ][ # # ]
[ # # ]
394 : :
395 : 0 : AddControlWithError( lcl_GetColumnName( pMapping, CUSTOM5_POS ), lcl_MovePoint( aCustom5FT ),
396 [ # # ][ # # ]: 0 : aControlSize, sTableErrorString, aCustom5FT.GetText(), HID_BIB_CUSTOM5_POS, 30 );
[ # # ][ # # ]
[ # # ]
397 : :
398 [ # # ][ # # ]: 0 : xPosListener = new BibPosListener(this);
[ # # ]
399 [ # # ]: 0 : uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY);
400 [ # # ]: 0 : if(xRowSet.is())
401 [ # # ][ # # ]: 0 : xRowSet->addRowSetListener(xPosListener);
402 [ # # ]: 0 : uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
403 [ # # ][ # # ]: 0 : xFormCtrl->setContainer(xCtrlContnr);
404 [ # # ][ # # ]: 0 : xFormCtrl->activateTabOrder();
405 : :
406 [ # # ]: 0 : if(sTableErrorString.Len())
407 [ # # ]: 0 : sTableErrorString.Insert(sErrorPrefix, 0);
408 [ # # # # : 0 : }
# # # # ]
409 : : //-----------------------------------------------------------------------------
410 [ # # ][ # # ]: 0 : BibGeneralPage::~BibGeneralPage()
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
411 : : {
412 [ # # ][ # # ]: 0 : if (pDatMan && xPosListener.is())
[ # # ]
413 : : {
414 [ # # ]: 0 : uno::Reference< sdbc::XRowSet > xRowSet(pDatMan->getForm(), UNO_QUERY);
415 [ # # ]: 0 : if(xRowSet.is())
416 [ # # ][ # # ]: 0 : xRowSet->removeRowSetListener(xPosListener);
417 : : }
418 [ # # ][ # # ]: 0 : }
[ # # ]
[ # # # # ]
[ # # # #
# # # # ]
419 : :
420 : 0 : void BibGeneralPage::RemoveListeners()
421 : : {
422 [ # # ]: 0 : for(sal_uInt16 i = 0; i < FIELD_COUNT; i++)
423 : : {
424 [ # # ]: 0 : if(aControls[i].is())
425 : : {
426 [ # # ]: 0 : uno::Reference< awt::XWindow > xCtrWin(aControls[i], uno::UNO_QUERY );
427 [ # # ][ # # ]: 0 : xCtrWin->removeFocusListener( this );
[ # # ]
428 [ # # ]: 0 : aControls[i] = 0;
429 : : }
430 : : }
431 : 0 : }
432 : :
433 : 0 : void BibGeneralPage::CommitActiveControl()
434 : : {
435 [ # # ]: 0 : uno::Reference< form::runtime::XFormController > xFormCtrl = pDatMan->GetFormController();
436 [ # # ][ # # ]: 0 : uno::Reference< awt::XControl > xCurr = xFormCtrl->getCurrentControl();
437 [ # # ]: 0 : if(xCurr.is())
438 : : {
439 [ # # ][ # # ]: 0 : uno::Reference< awt::XControlModel > xModel = xCurr->getModel();
440 [ # # ]: 0 : uno::Reference< form::XBoundComponent > xBound(xModel, UNO_QUERY);
441 [ # # ]: 0 : if(xBound.is())
442 [ # # ][ # # ]: 0 : xBound->commit();
443 : 0 : }
444 : 0 : }
445 : : //-----------------------------------------------------------------------------
446 : 0 : void BibGeneralPage::AddControlWithError( const OUString& rColumnName, const ::Point& rPos, const ::Size& rSize,
447 : : String& rErrorString, String aColumnUIName, const rtl::OString& sHelpId, sal_uInt16 nIndexInFTArray )
448 : : {
449 : : // adds also the XControl and creates a map entry in nFT2CtrlMap[] for mapping between control and FT
450 : :
451 : 0 : sal_Int16 nIndex = -1;
452 [ # # ][ # # ]: 0 : uno::Reference< awt::XControlModel > xTmp = AddXControl(rColumnName, rPos, rSize, sHelpId, nIndex );
[ # # ]
453 [ # # ]: 0 : if( xTmp.is() )
454 : : {
455 : : DBG_ASSERT( nIndexInFTArray < FIELD_COUNT, "*BibGeneralPage::AddControlWithError(): wrong array index!" );
456 : : DBG_ASSERT( nFT2CtrlMap[ nIndexInFTArray ] < 0, "+BibGeneralPage::AddControlWithError(): index already in use!" );
457 : :
458 : 0 : nFT2CtrlMap[ nIndexInFTArray ] = nIndex;
459 : : }
460 : : else
461 : : {
462 [ # # ]: 0 : if( rErrorString.Len() )
463 [ # # ]: 0 : rErrorString += '\n';
464 : :
465 [ # # ][ # # ]: 0 : rErrorString += MnemonicGenerator::EraseAllMnemonicChars( aColumnUIName );
[ # # ]
466 : 0 : }
467 : 0 : }
468 : : //-----------------------------------------------------------------------------
469 : 0 : uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl(
470 : : const String& rName,
471 : : ::Point rPos, ::Size rSize, const rtl::OString& sHelpId, sal_Int16& rIndex )
472 : : {
473 : 0 : uno::Reference< awt::XControlModel > xCtrModel;
474 : : try
475 : : {
476 [ # # ]: 0 : sal_Bool bTypeListBox = sTypeColumnName == rName;
477 [ # # ][ # # ]: 0 : xCtrModel = pDatMan->loadControlModel(rName, bTypeListBox);
[ # # ]
478 [ # # ][ # # ]: 0 : if ( xCtrModel.is() && xMgr.is())
[ # # ]
479 : : {
480 [ # # ]: 0 : uno::Reference< beans::XPropertySet > xPropSet( xCtrModel, UNO_QUERY );
481 : :
482 [ # # ]: 0 : if( xPropSet.is())
483 : : {
484 [ # # ][ # # ]: 0 : uno::Reference< beans::XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo();
485 : :
486 [ # # ][ # # ]: 0 : uno::Any aAny = xPropSet->getPropertyValue( C2U("DefaultControl") );
487 : 0 : rtl::OUString aControlName;
488 : 0 : aAny >>= aControlName;
489 : :
490 : 0 : rtl::OUString uProp(C2U("HelpURL"));
491 [ # # ][ # # ]: 0 : if(xPropInfo->hasPropertyByName(uProp))
[ # # ]
492 : : {
493 : 0 : ::rtl::OUString sId = ::rtl::OUString::createFromAscii( INET_HID_SCHEME );
494 : : DBG_ASSERT( INetURLObject( rtl::OStringToOUString( sHelpId, RTL_TEXTENCODING_UTF8 ) ).GetProtocol() == INET_PROT_NOT_VALID, "Wrong HelpId!" );
495 [ # # ]: 0 : sId += ::rtl::OStringToOUString( sHelpId, RTL_TEXTENCODING_UTF8 );
496 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( uProp, makeAny( sId ) );
[ # # ]
497 : : }
498 : :
499 [ # # ]: 0 : if(bTypeListBox)
500 : : {
501 : : //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY);
502 [ # # ]: 0 : aAny <<= (sal_Int16)1;
503 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue(C2U("BoundColumn"), aAny);
504 : 0 : ListSourceType eSet = ListSourceType_VALUELIST;
505 [ # # ]: 0 : aAny.setValue( &eSet, ::getCppuType((const ListSourceType*)0) );
506 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue(C2U("ListSourceType"), aAny);
507 : :
508 [ # # ]: 0 : uno::Sequence<rtl::OUString> aListSource(TYPE_COUNT);
509 [ # # ]: 0 : rtl::OUString* pListSourceArr = aListSource.getArray();
510 : : //pListSourceArr[0] = C2U("select TypeName, TypeIndex from TypeNms");
511 [ # # ]: 0 : for(sal_Int32 i = 0; i < TYPE_COUNT; ++i)
512 : 0 : pListSourceArr[i] = rtl::OUString::valueOf(i);
513 [ # # ]: 0 : aAny.setValue(&aListSource, ::getCppuType((uno::Sequence<rtl::OUString>*)0));
514 : :
515 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue(C2U("ListSource"), aAny);
516 : :
517 [ # # ]: 0 : uno::Sequence<rtl::OUString> aValues(TYPE_COUNT + 1);
518 [ # # ]: 0 : rtl::OUString* pValuesArr = aValues.getArray();
519 [ # # ]: 0 : for(sal_uInt16 j = 0; j < TYPE_COUNT; j++)
520 [ # # ]: 0 : pValuesArr[j] = aBibTypeArr[j];
521 : : // empty string if an invalid value no values is set
522 : 0 : pValuesArr[TYPE_COUNT] = rtl::OUString();
523 : :
524 [ # # ]: 0 : aAny.setValue(&aValues, ::getCppuType((uno::Sequence<rtl::OUString>*)0));
525 : :
526 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue(C2U("StringItemList"), aAny);
527 : :
528 : 0 : sal_Bool bTrue = sal_True;
529 [ # # ]: 0 : aAny.setValue( &bTrue, ::getBooleanCppuType() );
530 [ # # ][ # # ]: 0 : xPropSet->setPropertyValue( C2U("Dropdown"), aAny );
531 : :
532 : 0 : aControlName = C2U("com.sun.star.form.control.ListBox");
533 [ # # ][ # # ]: 0 : xLBModel = Reference< form::XBoundComponent >(xCtrModel, UNO_QUERY);
[ # # ][ # # ]
534 : :
535 : : }
536 : :
537 [ # # ][ # # ]: 0 : uno::Reference< awt::XControl > xControl(xMgr->createInstance( aControlName ), UNO_QUERY );
[ # # ]
538 [ # # ]: 0 : if ( xControl.is() )
539 : : {
540 [ # # ][ # # ]: 0 : xControl->setModel( xCtrModel);
541 : :
542 : : // Peer als Child zu dem FrameWindow
543 [ # # ][ # # ]: 0 : xCtrlContnr->addControl(rName, xControl);
[ # # ]
544 [ # # ]: 0 : uno::Reference< awt::XWindow > xCtrWin(xControl, UNO_QUERY );
545 [ # # ][ # # ]: 0 : xCtrWin->addFocusListener( this );
[ # # ]
546 : 0 : rIndex = -1; // -> implies, that not found
547 [ # # ]: 0 : for(sal_uInt16 i = 0; i < FIELD_COUNT; i++)
548 [ # # ]: 0 : if(!aControls[i].is())
549 : : {
550 [ # # ]: 0 : aControls[i] = xCtrWin;
551 : 0 : rIndex = sal_Int16( i );
552 : 0 : break;
553 : : }
554 [ # # ][ # # ]: 0 : xCtrWin->setVisible( sal_True );
555 [ # # ][ # # ]: 0 : xControl->setDesignMode( sal_True );
556 : : // initially switch on the desing mode - switch it off _after_ loading the form
557 : :
558 [ # # ]: 0 : xCtrWin->setPosSize(rPos.X(), rPos.Y(), rSize.Width(),
559 [ # # ]: 0 : rSize.Height(), awt::PosSize::POSSIZE);
560 : 0 : }
561 [ # # ]: 0 : }
562 : : }
563 : : }
564 [ # # ]: 0 : catch(Exception& rEx)
565 : : {
566 : : (void) rEx; // make compiler happy
567 : : OSL_FAIL("BibGeneralPage::AddXControl: something went wrong !");
568 : : }
569 : 0 : return xCtrModel;
570 : : }
571 : :
572 : 0 : void BibGeneralPage::AdjustScrollbars()
573 : : {
574 [ # # ]: 0 : long nVertScrollWidth = aVertScroll.GetSizePixel().Width();
575 [ # # ]: 0 : long nHoriScrollHeight = aHoriScroll.GetSizePixel().Height();
576 : 0 : ::Size aOutSize(GetOutputSizePixel());
577 : 0 : sal_Bool bHoriVisible = aOutSize.Width() <= aStdSize.Width();
578 [ # # ]: 0 : sal_Bool bVertVisible = (aOutSize.Height()-(bHoriVisible ? nHoriScrollHeight : 0)) <= (aStdSize.Height());
579 [ # # ]: 0 : aHoriScroll.Show(bHoriVisible);
580 [ # # ]: 0 : aVertScroll.Show(bVertVisible);
581 : :
582 [ # # ]: 0 : if(bHoriVisible)
583 : : {
584 : 0 : ::Size aHoriSize(aOutSize.Width() - (bVertVisible ? nVertScrollWidth : 0),
585 [ # # ]: 0 : nHoriScrollHeight);
586 [ # # ]: 0 : aHoriScroll.SetSizePixel(aHoriSize);
587 [ # # ]: 0 : aHoriScroll.SetRange( Range(0, aStdSize.Width()));
588 [ # # ][ # # ]: 0 : aHoriScroll.SetVisibleSize( aHoriSize.Width() - (bVertVisible ? nVertScrollWidth : 0));
589 : : }
590 [ # # ]: 0 : if(bVertVisible)
591 : : {
592 : 0 : ::Size aVertSize(nHoriScrollHeight, aOutSize.Height() -
593 [ # # ]: 0 : (bHoriVisible ? nHoriScrollHeight : 0));
594 [ # # ]: 0 : aVertScroll.SetSizePixel(aVertSize);
595 [ # # ]: 0 : aVertScroll.SetRange( Range(0, aStdSize.Height()));
596 [ # # ]: 0 : aVertScroll.SetVisibleSize( aVertSize.Height() );
597 : : }
598 : :
599 : 0 : ::Size aSize(8, 8);
600 [ # # ][ # # ]: 0 : aSize = LogicToPixel(aSize, MapMode(MAP_APPFONT));
[ # # ]
601 : 0 : ::Size aScrollSize(aOutSize.Width() - aSize.Height(), aSize.Height());
602 : 0 : ::Point aScrollPos(0, aOutSize.Height() - aSize.Height());
603 [ # # ]: 0 : aHoriScroll.SetPosSizePixel(aScrollPos, aScrollSize);
604 : :
605 : 0 : aScrollPos.X() = aOutSize.Width() - aSize.Width();
606 : 0 : aScrollPos.Y() = 0;
607 : 0 : aScrollSize.Width() = aSize.Width();
608 : 0 : aScrollSize.Height() = aOutSize.Height() - aSize.Height();
609 [ # # ]: 0 : aVertScroll.SetPosSizePixel(aScrollPos, aScrollSize);
610 : :
611 : 0 : ::Size aControlParentWinSz(aOutSize);
612 [ # # ]: 0 : if(bHoriVisible)
613 : 0 : aControlParentWinSz.Height() -= aSize.Height();
614 [ # # ]: 0 : if(bVertVisible)
615 : 0 : aControlParentWinSz.Width() -= aSize.Width();
616 [ # # ]: 0 : aControlParentWin.SetSizePixel(aControlParentWinSz);
617 : 0 : }
618 : :
619 : 0 : void BibGeneralPage::Resize()
620 : : {
621 : 0 : AdjustScrollbars();
622 : 0 : ScrollHdl(&aVertScroll);
623 : 0 : ScrollHdl(&aHoriScroll);
624 : 0 : Window::Resize();
625 : 0 : }
626 : :
627 : 0 : void BibGeneralPage::InitFixedTexts( void )
628 : : {
629 : : String aFixedStrings[ FIELD_COUNT ] =
630 : : {
631 : : String( BibResId( ST_IDENTIFIER ) ),
632 : : String( BibResId( ST_AUTHTYPE ) ),
633 : : String( BibResId( ST_AUTHOR ) ),
634 : : String( BibResId( ST_TITLE ) ),
635 : : String( BibResId( ST_MONTH ) ),
636 : : String( BibResId( ST_YEAR ) ),
637 : : String( BibResId( ST_ISBN ) ),
638 : : String( BibResId( ST_BOOKTITLE ) ),
639 : : String( BibResId( ST_CHAPTER ) ),
640 : : String( BibResId( ST_EDITION ) ),
641 : : String( BibResId( ST_EDITOR ) ),
642 : : String( BibResId( ST_HOWPUBLISHED ) ),
643 : : String( BibResId( ST_INSTITUTION ) ),
644 : : String( BibResId( ST_JOURNAL ) ),
645 : : String( BibResId( ST_NOTE ) ),
646 : : String( BibResId( ST_ANNOTE ) ),
647 : : String( BibResId( ST_NUMBER ) ),
648 : : String( BibResId( ST_ORGANIZATION ) ),
649 : : String( BibResId( ST_PAGE ) ),
650 : : String( BibResId( ST_PUBLISHER ) ),
651 : : String( BibResId( ST_ADDRESS ) ),
652 : : String( BibResId( ST_SCHOOL ) ),
653 : : String( BibResId( ST_SERIES ) ),
654 : : String( BibResId( ST_REPORT ) ),
655 : : String( BibResId( ST_VOLUME ) ),
656 : : String( BibResId( ST_URL ) ),
657 : : String( BibResId( ST_CUSTOM1 ) ),
658 : : String( BibResId( ST_CUSTOM2 ) ),
659 : : String( BibResId( ST_CUSTOM3 ) ),
660 : : String( BibResId( ST_CUSTOM4 ) ),
661 : : String( BibResId( ST_CUSTOM5 ) )
662 [ # # ][ # # ]: 0 : };
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # ][ # # ]
[ # # # #
# # ]
663 : :
664 : 0 : aFixedTexts[0] = &aIdentifierFT;
665 : 0 : aFixedTexts[1] = &aAuthTypeFT;
666 : 0 : aFixedTexts[2] = &aAuthorFT;
667 : 0 : aFixedTexts[3] = &aTitleFT;
668 : 0 : aFixedTexts[4] = &aMonthFT;
669 : 0 : aFixedTexts[5] = &aYearFT;
670 : 0 : aFixedTexts[6] = &aISBNFT;
671 : 0 : aFixedTexts[7] = &aBooktitleFT;
672 : 0 : aFixedTexts[8] = &aChapterFT;
673 : 0 : aFixedTexts[9] = &aEditionFT;
674 : 0 : aFixedTexts[10] = &aEditorFT;
675 : 0 : aFixedTexts[11] = &aHowpublishedFT;
676 : 0 : aFixedTexts[12] = &aInstitutionFT;
677 : 0 : aFixedTexts[13] = &aJournalFT;
678 : 0 : aFixedTexts[14] = &aNoteFT;
679 : 0 : aFixedTexts[15] = &aAnnoteFT;
680 : 0 : aFixedTexts[16] = &aNumberFT;
681 : 0 : aFixedTexts[17] = &aOrganizationsFT;
682 : 0 : aFixedTexts[18] = &aPagesFT;
683 : 0 : aFixedTexts[19] = &aPublisherFT;
684 : 0 : aFixedTexts[20] = &aAddressFT;
685 : 0 : aFixedTexts[21] = &aSchoolFT;
686 : 0 : aFixedTexts[22] = &aSeriesFT;
687 : 0 : aFixedTexts[23] = &aReportTypeFT;
688 : 0 : aFixedTexts[24] = &aVolumeFT;
689 : 0 : aFixedTexts[25] = &aURLFT;
690 : 0 : aFixedTexts[26] = &aCustom1FT;
691 : 0 : aFixedTexts[27] = &aCustom2FT;
692 : 0 : aFixedTexts[28] = &aCustom3FT;
693 : 0 : aFixedTexts[29] = &aCustom4FT;
694 : 0 : aFixedTexts[30] = &aCustom5FT;
695 : :
696 : : int i;
697 : :
698 [ # # ]: 0 : MnemonicGenerator aMnemonicGenerator;
699 : : // init mnemonics, first register all strings
700 [ # # ]: 0 : for( i = 0 ; i < FIELD_COUNT ; ++i )
701 [ # # ]: 0 : aMnemonicGenerator.RegisterMnemonic( aFixedStrings[ i ] );
702 : :
703 : : // ... then get all strings
704 [ # # ]: 0 : for( i = 0 ; i < FIELD_COUNT ; ++i )
705 [ # # ]: 0 : aMnemonicGenerator.CreateMnemonic( aFixedStrings[ i ] );
706 : :
707 : : // set texts
708 [ # # ]: 0 : for( i = 0 ; i < FIELD_COUNT ; ++i )
709 [ # # ][ # # ]: 0 : aFixedTexts[ i ]->SetText( aFixedStrings[ i ] );
[ # # ][ # # ]
710 : 0 : }
711 : :
712 : 0 : IMPL_LINK(BibGeneralPage, ScrollHdl, ScrollBar*, pScroll)
713 : : {
714 : 0 : sal_Bool bVertical = &aVertScroll == pScroll;
715 : 0 : long nOffset = 0;
716 : 0 : long nCurrentOffset = 0;
717 [ # # ]: 0 : if(bVertical)
718 : 0 : nCurrentOffset = aFixedTexts[0]->GetPosPixel().Y() - aBasePos.Y();
719 : : else
720 : 0 : nCurrentOffset = aFixedTexts[0]->GetPosPixel().X() - aBasePos.X();
721 [ # # ]: 0 : nOffset = pScroll->IsVisible() ? pScroll->GetThumbPos() + nCurrentOffset : nCurrentOffset;
722 : :
723 [ # # ]: 0 : for(sal_uInt16 i = 0; i < FIELD_COUNT; i++)
724 : : {
725 [ # # ]: 0 : ::Point aPos = aFixedTexts[i]->GetPosPixel();
726 [ # # ]: 0 : if(bVertical)
727 : 0 : aPos.Y() -= nOffset;
728 : : else
729 : 0 : aPos.X() -= nOffset;
730 [ # # ]: 0 : aFixedTexts[i]->SetPosPixel(aPos);
731 [ # # ]: 0 : if(aControls[i].is())
732 : : {
733 [ # # ][ # # ]: 0 : awt::Rectangle aRect = aControls[i]->getPosSize();
734 : 0 : long nX = aRect.X;
735 : 0 : long nY = aRect.Y;
736 [ # # ]: 0 : if(bVertical)
737 : 0 : nY -= nOffset;
738 : : else
739 : 0 : nX -= nOffset;
740 [ # # ][ # # ]: 0 : aControls[i]->setPosSize(nX, nY, 0, 0, awt::PosSize::POS);
741 : : }
742 : : }
743 : 0 : return 0;
744 : : }
745 : :
746 : 0 : void BibGeneralPage::focusGained(const awt::FocusEvent& rEvent) throw( uno::RuntimeException )
747 : : {
748 [ # # ]: 0 : Reference<awt::XWindow> xCtrWin(rEvent.Source, UNO_QUERY );
749 [ # # ]: 0 : if(xCtrWin.is())
750 : : {
751 : 0 : ::Size aOutSize = aControlParentWin.GetOutputSizePixel();
752 [ # # ][ # # ]: 0 : awt::Rectangle aRect = xCtrWin->getPosSize();
753 : 0 : long nX = aRect.X;
754 [ # # ]: 0 : if(nX < 0)
755 : : {
756 : : // left of the visible area
757 [ # # ]: 0 : aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX);
758 [ # # ]: 0 : ScrollHdl(&aHoriScroll);
759 : : }
760 [ # # ]: 0 : else if(nX > aOutSize.Width())
761 : : {
762 : : // right of the visible area
763 [ # # ][ # # ]: 0 : aHoriScroll.SetThumbPos(aHoriScroll.GetThumbPos() + nX - aOutSize.Width() + aFixedTexts[0]->GetSizePixel().Width());
764 [ # # ]: 0 : ScrollHdl(&aHoriScroll);
765 : : }
766 : 0 : long nY = aRect.Y;
767 [ # # ]: 0 : if(nY < 0)
768 : : {
769 : : // below the visible area
770 [ # # ]: 0 : aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY);
771 [ # # ]: 0 : ScrollHdl(&aVertScroll);
772 : : }
773 [ # # ]: 0 : else if(nY > aOutSize.Height())
774 : : {
775 : : // over the visible area
776 [ # # ][ # # ]: 0 : aVertScroll.SetThumbPos(aVertScroll.GetThumbPos() + nY - aOutSize.Height()+ aFixedTexts[0]->GetSizePixel().Height());
777 [ # # ]: 0 : ScrollHdl(&aVertScroll);
778 : : }
779 : 0 : }
780 : 0 : }
781 : :
782 : 0 : void BibGeneralPage::focusLost(const awt::FocusEvent& ) throw( uno::RuntimeException )
783 : : {
784 : 0 : CommitActiveControl();
785 : 0 : }
786 : :
787 : 0 : void BibGeneralPage::disposing(const lang::EventObject& /*Source*/) throw( uno::RuntimeException )
788 : : {
789 : 0 : }
790 : :
791 : 0 : void BibGeneralPage::GetFocus()
792 : : {
793 : 0 : Reference< awt::XWindow >* pxControl = aControls;
794 : :
795 [ # # ]: 0 : for( int i = FIELD_COUNT ; i ; --i, ++pxControl )
796 : : {
797 [ # # ]: 0 : if( pxControl->is() )
798 : : {
799 : 0 : ( *pxControl )->setFocus();
800 : 0 : return;
801 : : }
802 : : }
803 : :
804 : : // fallback
805 : 0 : aControlParentWin.GrabFocus();
806 : : }
807 : :
808 : 0 : sal_Bool BibGeneralPage::HandleShortCutKey( const KeyEvent& rKeyEvent )
809 : : {
810 : : DBG_ASSERT( KEY_MOD2 == rKeyEvent.GetKeyCode().GetModifier(), "+BibGeneralPage::HandleShortCutKey(): this is not for me!" );
811 : :
812 [ # # ][ # # ]: 0 : const vcl::I18nHelper& rI18nHelper = Application::GetSettings().GetUILocaleI18nHelper();
813 : 0 : const xub_Unicode c = rKeyEvent.GetCharCode();
814 : 0 : sal_Bool bHandled = sal_False;
815 : :
816 : : sal_Int16 i;
817 : :
818 : : typedef std::vector< sal_Int16 > sal_Int16_vector;
819 : :
820 : 0 : sal_Int16_vector::size_type nFocused = 0xFFFF; // index of focused in vector, no one focused initial
821 : : DBG_ASSERT( nFocused > 0, "*BibGeneralPage::HandleShortCutKey(): size_type works not as expected!" );
822 : :
823 [ # # ]: 0 : sal_Int16_vector aMatchList;
824 : :
825 [ # # ]: 0 : for( i = 0 ; i < FIELD_COUNT ; ++i )
826 : : {
827 [ # # ][ # # ]: 0 : if( rI18nHelper.MatchMnemonic( aFixedTexts[ i ]->GetText(), c ) )
[ # # ][ # # ]
828 : : {
829 : 0 : bHandled = sal_True;
830 : 0 : sal_Int16 nCtrlIndex = nFT2CtrlMap[ i ];
831 : :
832 [ # # ]: 0 : if( nCtrlIndex >= 0 )
833 : : { // store index of control
834 : : DBG_ASSERT( aControls[ nCtrlIndex ].is(), "-BibGeneralPage::HandleShortCutKey(): valid index and no control?" );
835 : :
836 [ # # ]: 0 : uno::Reference< awt::XControl > xControl( aControls[ nCtrlIndex ], UNO_QUERY );
837 : : DBG_ASSERT( xControl.is(), "-BibGeneralPage::HandleShortCutKey(): a control wich is not a control!" );
838 : :
839 [ # # ][ # # ]: 0 : Window* pWindow = VCLUnoHelper::GetWindow( xControl->getPeer() );
[ # # ]
840 : :
841 [ # # ]: 0 : if( pWindow )
842 : : {
843 [ # # ]: 0 : aMatchList.push_back( nCtrlIndex );
844 [ # # ][ # # ]: 0 : if( pWindow->HasChildPathFocus() )
845 : : { // save focused control
846 : : DBG_ASSERT( nFocused == 0xFFFF, "+BibGeneralPage::HandleShortCutKey(): more than one with focus?!" );
847 : : DBG_ASSERT( !aMatchList.empty(), "+BibGeneralPage::HandleShortCutKey(): push_back and no content?!" );
848 : 0 : nFocused = aMatchList.size() - 1;
849 : : }
850 : 0 : }
851 : : }
852 : : }
853 : : }
854 : :
855 [ # # ]: 0 : if( bHandled )
856 : : {
857 : : DBG_ASSERT( !aMatchList.empty(), "*BibGeneralPage::HandleShortCutKey(): be prepared to crash..." );
858 : :
859 [ # # ]: 0 : if( nFocused >= ( aMatchList.size() - 1 ) )
860 : : // >=... includes 0xFFFF
861 : : // no one or last focused, take first
862 : 0 : nFocused = 0;
863 : : else
864 : : // take next one
865 : 0 : nFocused++;
866 : :
867 [ # # ][ # # ]: 0 : aControls[ aMatchList[ nFocused ] ]->setFocus();
[ # # ]
868 : : }
869 : :
870 : 0 : return bHandled;
871 : : }
872 : :
873 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|