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

Generated by: LCOV version 1.10