LCOV - code coverage report
Current view: top level - libreoffice/extensions/source/bibliography - general.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 454 0.0 %
Date: 2012-12-27 Functions: 0 26 0.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10