diff options
author | Caolán McNamara <caolanm@redhat.com> | 2015-04-09 20:43:28 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2015-04-09 21:09:08 +0100 |
commit | 3e41b069bcc1482eb4d3fabb6d475db4bf3d4e57 (patch) | |
tree | 2efed384047c9f5990614e6470f156e58e2a0f7b | |
parent | 7dbaf2b093136bc0e85c255f9b8a7cdac73db4cf (diff) |
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
-rw-r--r-- | extensions/source/bibliography/datman.cxx | 59 | ||||
-rw-r--r-- | extensions/source/bibliography/general.cxx | 76 | ||||
-rw-r--r-- | extensions/source/bibliography/general.hxx | 1 |
3 files changed, 69 insertions, 67 deletions
diff --git a/extensions/source/bibliography/datman.cxx b/extensions/source/bibliography/datman.cxx index f28936d540f1..74715bc31404 100644 --- a/extensions/source/bibliography/datman.cxx +++ b/extensions/source/bibliography/datman.cxx @@ -37,6 +37,7 @@ #include <com/sun/star/sdbc/XConnection.hpp> #include <com/sun/star/sdb/XCompletedConnection.hpp> #include <com/sun/star/task/InteractionHandler.hpp> +#include <com/sun/star/form/ListSourceType.hpp> #include <com/sun/star/form/XLoadable.hpp> #include <com/sun/star/form/runtime/FormController.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> @@ -60,12 +61,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 "bibliography.hrc" #include <connectivity/dbtools.hxx> @@ -1271,6 +1272,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<ListSourceType>::get() ); + xPropSet->setPropertyValue("ListSourceType", aAny); + + uno::Sequence<OUString> 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<uno::Sequence<OUString>>::get()); + + xPropSet->setPropertyValue("ListSource", aAny); + + uno::Sequence<OUString> 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].clear(); + + aAny.setValue(&aValues, cppu::UnoType<uno::Sequence<OUString>>::get()); + + xPropSet->setPropertyValue("StringItemList", aAny); + + sal_Bool bTrue = sal_True; + aAny.setValue( &bTrue, cppu::UnoType<bool>::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 3829d4fa279c..02764e4e5816 100644 --- a/extensions/source/bibliography/general.cxx +++ b/extensions/source/bibliography/general.cxx @@ -23,7 +23,6 @@ #include <com/sun/star/sdb/XColumn.hpp> #include <com/sun/star/sdb/CommandType.hpp> #include <com/sun/star/sdbcx/XColumnsSupplier.hpp> -#include <com/sun/star/form/ListSourceType.hpp> #include <com/sun/star/awt/XWindow.hpp> #include <toolkit/helper/vclunohelper.hxx> #include <cppuhelper/implbase1.hxx> @@ -204,29 +203,6 @@ BibGeneralPage::BibGeneralPage(vcl::Window* pParent, BibDataManager* pMan): get(pCustom4FT, "custom4"); get(pCustom5FT, "custom5"); - 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 ); - InitFixedTexts(); sal_Int16* pMap = nFT2CtrlMap; @@ -430,7 +406,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() ) { @@ -440,9 +416,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)) @@ -453,44 +437,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<ListSourceType>::get() ); - xPropSet->setPropertyValue("ListSourceType", aAny); - - uno::Sequence<OUString> 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<uno::Sequence<OUString>>::get()); - - xPropSet->setPropertyValue("ListSource", aAny); - - uno::Sequence<OUString> 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].clear(); - - aAny.setValue(&aValues, cppu::UnoType<uno::Sequence<OUString>>::get()); - - xPropSet->setPropertyValue("StringItemList", aAny); - - sal_Bool bTrue = sal_True; - aAny.setValue( &bTrue, cppu::UnoType<bool>::get() ); - 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 9e96c3343f7b..0b89c0ea322e 100644 --- a/extensions/source/bibliography/general.hxx +++ b/extensions/source/bibliography/general.hxx @@ -96,7 +96,6 @@ class BibGeneralPage: public BibGeneralPageBaseClass, public BibTabPage ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > aControls[ FIELD_COUNT ]; - OUString aBibTypeArr[ TYPE_COUNT ]; OUString sErrorPrefix; OUString sTableErrorString; |