From ebdaab9d4a042f1338f97628cf0c0f294d7dc059 Mon Sep 17 00:00:00 2001 From: Caolán McNamara Date: Thu, 9 Apr 2015 20:43:28 +0100 Subject: Related: tdf#90472 initial load of bibliography doesn't... set bibliography type moving to a new row will set the new type, but initially its not set because the ListStore property was set after the model is connected to the database so at the initial connection time there isn't a available set of values to map the row to. So move that connection code from general.cxx to datman.cxx and put it before the connection is established we can then remove the intermediate aBibTypeArr list and those resources then need to be global bib ones. Change-Id: I12276c3df9955ec399e1b5de6d0836c69ebb1ebb Reviewed-on: https://gerrit.libreoffice.org/15220 Tested-by: Christian Lohmaier Reviewed-by: Christian Lohmaier --- extensions/source/bibliography/bib.hrc | 23 ++++ extensions/source/bibliography/datman.cxx | 59 +++++++++- extensions/source/bibliography/general.cxx | 76 ++---------- extensions/source/bibliography/general.hxx | 1 - extensions/source/bibliography/sections.hrc | 23 ---- extensions/source/bibliography/sections.src | 177 ++++++++++++++-------------- 6 files changed, 181 insertions(+), 178 deletions(-) diff --git a/extensions/source/bibliography/bib.hrc b/extensions/source/bibliography/bib.hrc index cb9a7e22f2a2..9752c06f5803 100644 --- a/extensions/source/bibliography/bib.hrc +++ b/extensions/source/bibliography/bib.hrc @@ -80,6 +80,29 @@ #define ST_CUSTOM4 (RID_BIB_STRING + 35) #define ST_CUSTOM5 (RID_BIB_STRING + 36) +#define ST_TYPE_ARTICLE (RID_BIB_STRING + 38) +#define ST_TYPE_BOOK (RID_BIB_STRING + 39) +#define ST_TYPE_BOOKLET (RID_BIB_STRING + 40) +#define ST_TYPE_CONFERENCE (RID_BIB_STRING + 41) +#define ST_TYPE_INBOOK (RID_BIB_STRING + 42) +#define ST_TYPE_INCOLLECTION (RID_BIB_STRING + 43) +#define ST_TYPE_INPROCEEDINGS (RID_BIB_STRING + 44) +#define ST_TYPE_JOURNAL (RID_BIB_STRING + 45) +#define ST_TYPE_MANUAL (RID_BIB_STRING + 46) +#define ST_TYPE_MASTERSTHESIS (RID_BIB_STRING + 47) +#define ST_TYPE_MISC (RID_BIB_STRING + 48) +#define ST_TYPE_PHDTHESIS (RID_BIB_STRING + 49) +#define ST_TYPE_PROCEEDINGS (RID_BIB_STRING + 50) +#define ST_TYPE_TECHREPORT (RID_BIB_STRING + 51) +#define ST_TYPE_UNPUBLISHED (RID_BIB_STRING + 52) +#define ST_TYPE_EMAIL (RID_BIB_STRING + 53) +#define ST_TYPE_WWW (RID_BIB_STRING + 54) +#define ST_TYPE_CUSTOM1 (RID_BIB_STRING + 55) +#define ST_TYPE_CUSTOM2 (RID_BIB_STRING + 56) +#define ST_TYPE_CUSTOM3 (RID_BIB_STRING + 57) +#define ST_TYPE_CUSTOM4 (RID_BIB_STRING + 58) +#define ST_TYPE_CUSTOM5 (RID_BIB_STRING + 59) + #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index 28bbd27208df..751f692047a0 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -59,12 +60,12 @@ #include "bibresid.hxx" #include "bibmod.hxx" #include "bibview.hxx" -// #100312# --------- #include "bibprop.hrc" #include "toolbar.hxx" #include "toolbar.hrc" #include "bibconfig.hxx" #include "bibbeam.hxx" +#include "general.hxx" #include "bib.hrc" #include "datman.hrc" #include "bibliography.hrc" @@ -1378,6 +1379,62 @@ Reference< awt::XControlModel > BibDataManager::loadControlModel( xPropSet->setPropertyValue( FM_PROP_CONTROLSOURCE, makeAny( rName ) ); xPropSet->setPropertyValue("NativeWidgetLook", makeAny( true ) ); + if (bForceListBox) + { + uno::Any aAny; + + //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY); + aAny <<= (sal_Int16)1; + xPropSet->setPropertyValue("BoundColumn", aAny); + ListSourceType eSet = ListSourceType_VALUELIST; + aAny.setValue( &eSet, ::cppu::UnoType::get() ); + xPropSet->setPropertyValue("ListSourceType", aAny); + + uno::Sequence aListSource(TYPE_COUNT); + OUString* pListSourceArr = aListSource.getArray(); + //pListSourceArr[0] = "select TypeName, TypeIndex from TypeNms"; + for(sal_Int32 i = 0; i < TYPE_COUNT; ++i) + pListSourceArr[i] = OUString::number(i); + aAny.setValue(&aListSource, cppu::UnoType>::get()); + + xPropSet->setPropertyValue("ListSource", aAny); + + uno::Sequence aValues(TYPE_COUNT + 1); + OUString* pValuesArr = aValues.getArray(); + pValuesArr[0] = BIB_RESSTR(ST_TYPE_ARTICLE); + pValuesArr[1] = BIB_RESSTR(ST_TYPE_BOOK); + pValuesArr[2] = BIB_RESSTR(ST_TYPE_BOOKLET); + pValuesArr[3] = BIB_RESSTR(ST_TYPE_CONFERENCE); + pValuesArr[4] = BIB_RESSTR(ST_TYPE_INBOOK ); + pValuesArr[5] = BIB_RESSTR(ST_TYPE_INCOLLECTION); + pValuesArr[6] = BIB_RESSTR(ST_TYPE_INPROCEEDINGS); + pValuesArr[7] = BIB_RESSTR(ST_TYPE_JOURNAL ); + pValuesArr[8] = BIB_RESSTR(ST_TYPE_MANUAL ); + pValuesArr[9] = BIB_RESSTR(ST_TYPE_MASTERSTHESIS); + pValuesArr[10] = BIB_RESSTR(ST_TYPE_MISC ); + pValuesArr[11] = BIB_RESSTR(ST_TYPE_PHDTHESIS ); + pValuesArr[12] = BIB_RESSTR(ST_TYPE_PROCEEDINGS ); + pValuesArr[13] = BIB_RESSTR(ST_TYPE_TECHREPORT ); + pValuesArr[14] = BIB_RESSTR(ST_TYPE_UNPUBLISHED ); + pValuesArr[15] = BIB_RESSTR(ST_TYPE_EMAIL ); + pValuesArr[16] = BIB_RESSTR(ST_TYPE_WWW ); + pValuesArr[17] = BIB_RESSTR(ST_TYPE_CUSTOM1 ); + pValuesArr[18] = BIB_RESSTR(ST_TYPE_CUSTOM2 ); + pValuesArr[19] = BIB_RESSTR(ST_TYPE_CUSTOM3 ); + pValuesArr[20] = BIB_RESSTR(ST_TYPE_CUSTOM4 ); + pValuesArr[21] = BIB_RESSTR(ST_TYPE_CUSTOM5 ); + // empty string if an invalid value no values is set + pValuesArr[TYPE_COUNT] = OUString(); + + aAny.setValue(&aValues, cppu::UnoType>::get()); + + xPropSet->setPropertyValue("StringItemList", aAny); + + sal_Bool bTrue = sal_True; + aAny.setValue( &bTrue, cppu::UnoType::get() ); + xPropSet->setPropertyValue( "Dropdown", aAny ); + } + Reference< XFormComponent > aFormComp(xModel,UNO_QUERY ); Reference< XNameContainer > xNameCont( m_xForm, UNO_QUERY ); diff --git a/extensions/source/bibliography/general.cxx b/extensions/source/bibliography/general.cxx index 2babb133beb3..057c01ebdbc4 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -23,7 +23,6 @@ #include #include #include -#include #include #include #include @@ -222,29 +221,6 @@ BibGeneralPage::BibGeneralPage(Window* pParent, BibDataManager* pMan): aControlParentWin.SetHelpId(HID_BIB_CONTROL_PARENT); aStdSize = GetOutputSizePixel(); - aBibTypeArr[0] = BIB_RESSTR(ST_TYPE_ARTICLE); - aBibTypeArr[1] = BIB_RESSTR(ST_TYPE_BOOK); - aBibTypeArr[2] = BIB_RESSTR(ST_TYPE_BOOKLET); - aBibTypeArr[3] = BIB_RESSTR(ST_TYPE_CONFERENCE); - aBibTypeArr[4] = BIB_RESSTR(ST_TYPE_INBOOK ); - aBibTypeArr[5] = BIB_RESSTR(ST_TYPE_INCOLLECTION); - aBibTypeArr[6] = BIB_RESSTR(ST_TYPE_INPROCEEDINGS); - aBibTypeArr[7] = BIB_RESSTR(ST_TYPE_JOURNAL ); - aBibTypeArr[8] = BIB_RESSTR(ST_TYPE_MANUAL ); - aBibTypeArr[9] = BIB_RESSTR(ST_TYPE_MASTERSTHESIS); - aBibTypeArr[10] = BIB_RESSTR(ST_TYPE_MISC ); - aBibTypeArr[11] = BIB_RESSTR(ST_TYPE_PHDTHESIS ); - aBibTypeArr[12] = BIB_RESSTR(ST_TYPE_PROCEEDINGS ); - aBibTypeArr[13] = BIB_RESSTR(ST_TYPE_TECHREPORT ); - aBibTypeArr[14] = BIB_RESSTR(ST_TYPE_UNPUBLISHED ); - aBibTypeArr[15] = BIB_RESSTR(ST_TYPE_EMAIL ); - aBibTypeArr[16] = BIB_RESSTR(ST_TYPE_WWW ); - aBibTypeArr[17] = BIB_RESSTR(ST_TYPE_CUSTOM1 ); - aBibTypeArr[18] = BIB_RESSTR(ST_TYPE_CUSTOM2 ); - aBibTypeArr[19] = BIB_RESSTR(ST_TYPE_CUSTOM3 ); - aBibTypeArr[20] = BIB_RESSTR(ST_TYPE_CUSTOM4 ); - aBibTypeArr[21] = BIB_RESSTR(ST_TYPE_CUSTOM5 ); - FreeResource(); InitFixedTexts(); @@ -461,7 +437,7 @@ uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl( uno::Reference< awt::XControlModel > xCtrModel; try { - bool bTypeListBox = sTypeColumnName == rName; + const bool bTypeListBox = sTypeColumnName == rName; xCtrModel = pDatMan->loadControlModel(rName, bTypeListBox); if ( xCtrModel.is() ) { @@ -471,9 +447,17 @@ uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl( { uno::Reference< beans::XPropertySetInfo > xPropInfo = xPropSet->getPropertySetInfo(); - uno::Any aAny = xPropSet->getPropertyValue( "DefaultControl" ); OUString aControlName; - aAny >>= aControlName; + if (bTypeListBox) + { + aControlName = "com.sun.star.form.control.ListBox"; + xLBModel = Reference< form::XBoundComponent >(xCtrModel, UNO_QUERY); + } + else + { + uno::Any aAny = xPropSet->getPropertyValue( "DefaultControl" ); + aAny >>= aControlName; + } OUString uProp("HelpURL"); if(xPropInfo->hasPropertyByName(uProp)) @@ -484,44 +468,6 @@ uno::Reference< awt::XControlModel > BibGeneralPage::AddXControl( xPropSet->setPropertyValue( uProp, makeAny( sId ) ); } - if(bTypeListBox) - { - //uno::Reference< beans::XPropertySet > xPropSet(xControl, UNO_QUERY); - aAny <<= (sal_Int16)1; - xPropSet->setPropertyValue("BoundColumn", aAny); - ListSourceType eSet = ListSourceType_VALUELIST; - aAny.setValue( &eSet, ::cppu::UnoType::get() ); - xPropSet->setPropertyValue("ListSourceType", aAny); - - uno::Sequence aListSource(TYPE_COUNT); - OUString* pListSourceArr = aListSource.getArray(); - //pListSourceArr[0] = "select TypeName, TypeIndex from TypeNms"; - for(sal_Int32 i = 0; i < TYPE_COUNT; ++i) - pListSourceArr[i] = OUString::number(i); - aAny.setValue(&aListSource, ::getCppuType((uno::Sequence*)0)); - - xPropSet->setPropertyValue("ListSource", aAny); - - uno::Sequence aValues(TYPE_COUNT + 1); - OUString* pValuesArr = aValues.getArray(); - for(sal_uInt16 j = 0; j < TYPE_COUNT; j++) - pValuesArr[j] = aBibTypeArr[j]; - // empty string if an invalid value no values is set - pValuesArr[TYPE_COUNT] = OUString(); - - aAny.setValue(&aValues, ::getCppuType((uno::Sequence*)0)); - - xPropSet->setPropertyValue("StringItemList", aAny); - - sal_Bool bTrue = sal_True; - aAny.setValue( &bTrue, ::getBooleanCppuType() ); - xPropSet->setPropertyValue( "Dropdown", aAny ); - - aControlName = "com.sun.star.form.control.ListBox"; - xLBModel = Reference< form::XBoundComponent >(xCtrModel, UNO_QUERY); - - } - uno::Reference< XComponentContext > xContext = comphelper::getProcessComponentContext(); uno::Reference< awt::XControl > xControl( xContext->getServiceManager()->createInstanceWithContext(aControlName, xContext), UNO_QUERY); if ( xControl.is() ) diff --git a/extensions/source/bibliography/general.hxx b/extensions/source/bibliography/general.hxx index 526319f009fb..14e44fb0bb13 100644 --- a/extensions/source/bibliography/general.hxx +++ b/extensions/source/bibliography/general.hxx @@ -102,7 +102,6 @@ class BibGeneralPage: public BibGeneralPageBaseClass, public BibTabPage Size aStdSize; Point aBasePos; - OUString aBibTypeArr[ TYPE_COUNT ]; OUString sErrorPrefix; OUString sTableErrorString; diff --git a/extensions/source/bibliography/sections.hrc b/extensions/source/bibliography/sections.hrc index 9d040568a93b..c5e951607dbf 100644 --- a/extensions/source/bibliography/sections.hrc +++ b/extensions/source/bibliography/sections.hrc @@ -59,27 +59,4 @@ #define FL_2 35 #define FL_3 36 -#define ST_TYPE_ARTICLE 40 -#define ST_TYPE_BOOK 41 -#define ST_TYPE_BOOKLET 42 -#define ST_TYPE_CONFERENCE 43 -#define ST_TYPE_INBOOK 44 -#define ST_TYPE_INCOLLECTION 45 -#define ST_TYPE_INPROCEEDINGS 46 -#define ST_TYPE_JOURNAL 47 -#define ST_TYPE_MANUAL 48 -#define ST_TYPE_MASTERSTHESIS 49 -#define ST_TYPE_MISC 50 -#define ST_TYPE_PHDTHESIS 51 -#define ST_TYPE_PROCEEDINGS 52 -#define ST_TYPE_TECHREPORT 53 -#define ST_TYPE_UNPUBLISHED 54 -#define ST_TYPE_EMAIL 55 -#define ST_TYPE_WWW 56 -#define ST_TYPE_CUSTOM1 57 -#define ST_TYPE_CUSTOM2 58 -#define ST_TYPE_CUSTOM3 59 -#define ST_TYPE_CUSTOM4 60 -#define ST_TYPE_CUSTOM5 61 - /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/extensions/source/bibliography/sections.src b/extensions/source/bibliography/sections.src index d6fbac802856..92fb2cc6bacd 100644 --- a/extensions/source/bibliography/sections.src +++ b/extensions/source/bibliography/sections.src @@ -244,94 +244,6 @@ TabPage RID_TP_GENERAL { Text [ en-US ] = "The following column names could not be assigned:\n"; }; - String ST_TYPE_ARTICLE - { - Text [ en-US ] = "Article"; - }; - String ST_TYPE_BOOK - { - Text [ en-US ] = "Book"; - }; - String ST_TYPE_BOOKLET - { - Text [ en-US ] = "Brochures"; - }; - String ST_TYPE_CONFERENCE - { - Text [ en-US ] = "Conference proceedings"; - }; - String ST_TYPE_INBOOK - { - Text [ en-US ] = "Book excerpt"; - }; - String ST_TYPE_INCOLLECTION - { - Text [ en-US ] = "Book excerpt with title"; - }; - String ST_TYPE_INPROCEEDINGS - { - Text [ en-US ] = "Conference proceedings"; - }; - String ST_TYPE_JOURNAL - { - Text [ en-US ] = "Journal"; - }; - String ST_TYPE_MANUAL - { - Text [ en-US ] = "Techn. documentation"; - }; - String ST_TYPE_MASTERSTHESIS - { - Text [ en-US ] = "Thesis"; - }; - String ST_TYPE_MISC - { - Text [ en-US ] = "Miscellaneous"; - }; - String ST_TYPE_PHDTHESIS - { - Text [ en-US ] = "Dissertation"; - }; - String ST_TYPE_PROCEEDINGS - { - Text [ en-US ] = "Conference proceedings"; - }; - String ST_TYPE_TECHREPORT - { - Text [ en-US ] = "Research report"; - }; - String ST_TYPE_UNPUBLISHED - { - Text [ en-US ] = "Unpublished"; - }; - String ST_TYPE_EMAIL - { - Text [ en-US ] = "e-mail"; - }; - String ST_TYPE_WWW - { - Text [ en-US ] = "WWW document"; - }; - String ST_TYPE_CUSTOM1 - { - Text [ en-US ] = "User-defined1"; - }; - String ST_TYPE_CUSTOM2 - { - Text [ en-US ] = "User-defined2"; - }; - String ST_TYPE_CUSTOM3 - { - Text [ en-US ] = "User-defined3"; - }; - String ST_TYPE_CUSTOM4 - { - Text [ en-US ] = "User-defined4"; - }; - String ST_TYPE_CUSTOM5 - { - Text [ en-US ] = "User-defined5"; - }; Text [ en-US ] = "General"; }; @@ -461,4 +373,93 @@ String ST_CUSTOM5 Text [ en-US ] = "User-defined field ~5"; }; +String ST_TYPE_ARTICLE +{ + Text [ en-US ] = "Article"; +}; +String ST_TYPE_BOOK +{ + Text [ en-US ] = "Book"; +}; +String ST_TYPE_BOOKLET +{ + Text [ en-US ] = "Brochures"; +}; +String ST_TYPE_CONFERENCE +{ + Text [ en-US ] = "Conference proceedings"; +}; +String ST_TYPE_INBOOK +{ + Text [ en-US ] = "Book excerpt"; +}; +String ST_TYPE_INCOLLECTION +{ + Text [ en-US ] = "Book excerpt with title"; +}; +String ST_TYPE_INPROCEEDINGS +{ + Text [ en-US ] = "Conference proceedings"; +}; +String ST_TYPE_JOURNAL +{ + Text [ en-US ] = "Journal"; +}; +String ST_TYPE_MANUAL +{ + Text [ en-US ] = "Techn. documentation"; +}; +String ST_TYPE_MASTERSTHESIS +{ + Text [ en-US ] = "Thesis"; +}; +String ST_TYPE_MISC +{ + Text [ en-US ] = "Miscellaneous"; +}; +String ST_TYPE_PHDTHESIS +{ + Text [ en-US ] = "Dissertation"; +}; +String ST_TYPE_PROCEEDINGS +{ + Text [ en-US ] = "Conference proceedings"; +}; +String ST_TYPE_TECHREPORT +{ + Text [ en-US ] = "Research report"; +}; +String ST_TYPE_UNPUBLISHED +{ + Text [ en-US ] = "Unpublished"; +}; +String ST_TYPE_EMAIL +{ + Text [ en-US ] = "e-mail"; +}; +String ST_TYPE_WWW +{ + Text [ en-US ] = "WWW document"; +}; +String ST_TYPE_CUSTOM1 +{ + Text [ en-US ] = "User-defined1"; +}; +String ST_TYPE_CUSTOM2 +{ + Text [ en-US ] = "User-defined2"; +}; +String ST_TYPE_CUSTOM3 +{ + Text [ en-US ] = "User-defined3"; +}; +String ST_TYPE_CUSTOM4 +{ + Text [ en-US ] = "User-defined4"; +}; +String ST_TYPE_CUSTOM5 +{ + Text [ en-US ] = "User-defined5"; +}; + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit v1.2.3