Commits

Anonymous committed 4347b75 Merge

container_controls: merge ( from pull )

Comments (0)

Files changed (15)

oox/inc/oox/helper/propertyset.hxx

 
 #include <com/sun/star/beans/XPropertySet.hpp>
 #include <com/sun/star/beans/XMultiPropertySet.hpp>
-#include <com/sun/star/frame/XModel.hpp>
 
 namespace oox {
 
     setAnyProperty( nPropId, ::com::sun::star::uno::Any( rValue ) );
 }
 
-class FormPropertySet : public PropertySet
-{
-public:
-    inline explicit     FormPropertySet() : PropertySet() {}
-
-    /** Constructs a property set wrapper with the passed UNO property set. */
-    inline explicit     FormPropertySet(
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& rxPropSet ) : PropertySet( rxPropSet ) {}
-
-    /** Constructs a property set wrapper after querying the XPropertySet interface. */
-    template< typename Type >
-    inline explicit     FormPropertySet( const Type& rObject ) : PropertySet( rObject ) {}
-    void setDataAwareProperties(  const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel, const PropertyMap& );
-};
 // ============================================================================
 
 } // namespace oox

oox/inc/oox/ole/axcontrol.hxx

 
 #include <boost/shared_ptr.hpp>
 #include "oox/helper/binarystreambase.hxx"
+#include "oox/helper/propertyset.hxx"
 #include "oox/ole/axbinaryreader.hxx"
 #include "oox/ole/olehelper.hxx"
 
     namespace awt { class XControlModel; }
     namespace container { class XIndexContainer; }
     namespace drawing { class XDrawPage; }
+    namespace frame { class XModel; }
     namespace form { class XFormsSupplier; }
     namespace lang { class XMultiServiceFactory; }
 } } }
 {
 public:
     explicit            ControlConverter(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const GraphicHelper& rGraphicHelper,
                             bool bDefaultColorBgr = true );
     virtual             ~ControlConverter();
                             sal_Int32 nMin, sal_Int32 nMax, sal_Int32 nPosition,
                             sal_Int32 nSmallChange, sal_Int32 nLargeChange, bool bAwtModel ) const;
 
+    /** Binds the passed control model to the passed data sources. The
+        implementation will check which source types are supported. */
+    void                bindToSources(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
+                            const ::rtl::OUString& rCtrlSource,
+                            const ::rtl::OUString& rRowSource,
+                            sal_Int32 nRefSheet = 0 ) const;
+                            
     // ActiveX (Forms 2.0) specific conversion --------------------------------
 
     /** Converts the Forms 2.0 background formatting to UNO properties. */
                             sal_Int32 nOrientation ) const;
 
 private:
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
     const GraphicHelper& mrGraphicHelper;
+    mutable PropertySet maAddressConverter;
+    mutable PropertySet maRangeConverter;
     bool                mbDefaultColorBgr;
 };
 
 {
 public:
     explicit            EmbeddedForm(
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxModelFactory,
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XDrawPage >& rxDrawPage,
                             const GraphicHelper& rGraphicHelper,
                             bool bDefaultColorBgr = true );

oox/inc/oox/ole/vbacontrol.hxx

 #define OOX_OLE_VBACONTROL_HXX
 
 #include "oox/ole/axcontrol.hxx"
-#include <com/sun/star/frame/XModel.hpp>
 
 namespace com { namespace sun { namespace star {
     namespace container { class XNameContainer; }
                             ApiControlType eCtrlType,
                             sal_Int32 nCtrlIndex ) const;
 
-    void                convertDataAwareProperties( PropertyMap& rPropMap );
+    /** Binds the passed control model to the data sources. The implementation
+        will check which source types are supported. */
+    void                bindToSources(
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
+                            const ControlConverter& rConv ) const;
 
 protected:
     ::rtl::OUString     maName;             /// Name of the control.
         and converts all control properties. */
     void                createAndConvert(
                             sal_Int32 nCtrlIndex,
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxParentNC,
                             const ControlConverter& rConv ) const;
 
 
     /** Converts all control properties, and inserts and converts embedded controls. */
     bool                convertProperties(
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
                             const ControlConverter& rConv,
                             sal_Int32 nCtrlIndex ) const;
 
 // ============================================================================
 
-class VbaUserForm : public VbaFormControl, public ControlConverter
+class VbaUserForm : public VbaFormControl
 {
 public:
     explicit            VbaUserForm(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& rxGlobalFactory,
+                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const GraphicHelper& rGraphicHelper,
                             bool bDefaultColorBgr = true );
 
     /** Imports the form and its embedded controls, and inserts the form with
         all its controls into the passed dialog library. */
     void                importForm(
-                            const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >& rxDocModel,
                             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >& rxDialogLib,
                             StorageBase& rVbaFormStrg,
                             const ::rtl::OUString& rModuleName,
                             rtl_TextEncoding eTextEnc );
-                            
+
 private:
     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > mxGlobalFactory;
+    ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel > mxDocModel;
+    ControlConverter    maConverter;
 };
 
 // ============================================================================

oox/inc/oox/ole/vbahelper.hxx

 const sal_uInt16 VBA_ID_MODULETYPEDOCUMENT      = 0x0022;
 const sal_uInt16 VBA_ID_MODULETYPEPROCEDURAL    = 0x0021;
 const sal_uInt16 VBA_ID_PROJECTCODEPAGE         = 0x0003;
-const sal_uInt16 VBA_ID_PROJECTNAME             = 0x0004;
 const sal_uInt16 VBA_ID_PROJECTEND              = 0x0010;
 const sal_uInt16 VBA_ID_PROJECTMODULES          = 0x000F;
+const sal_uInt16 VBA_ID_PROJECTNAME             = 0x0004;
 const sal_uInt16 VBA_ID_PROJECTVERSION          = 0x0009;
 
 // ============================================================================

oox/inc/oox/ole/vbaproject.hxx

                         mxDialogLib;        /// The dialog library of the document used for import.
     ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameContainer >
                         mxOleOverridesSink;
-    ::rtl::OUString     maPrjName;        /// Name of VBA project being imported
+    ::rtl::OUString     maPrjName;          /// Name of VBA project being imported
 };
 
 // ============================================================================

oox/inc/oox/xls/drawingfragment.hxx

 
 #include <com/sun/star/awt/Rectangle.hpp>
 #include <com/sun/star/awt/Size.hpp>
+#include "oox/ole/axcontrol.hxx"
 #include "oox/drawingml/shape.hxx"
 #include "oox/vml/vmldrawing.hxx"
 #include "oox/vml/vmldrawingfragment.hxx"
     virtual void        convertControlClientData(
                             const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControlModel >& rxCtrlModel,
                             const ::oox::vml::ShapeClientData& rClientData ) const;
+
+private:
+    ::oox::ole::ControlConverter maControlConv;
 };
 
 // ============================================================================
 } // namespace oox
 
 #endif
-

oox/source/helper/propertyset.cxx

 #include <osl/diagnose.h>
 #include "oox/helper/propertymap.hxx"
 
-#include <com/sun/star/lang/XMultiServiceFactory.hpp>
-#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/form/binding/XBindableValue.hpp>
-#include <com/sun/star/form/binding/XListEntrySink.hpp>
-#include <com/sun/star/form/binding/XListEntrySource.hpp>
-#include <com/sun/star/form/binding/XValueBinding.hpp>
-#include <com/sun/star/table/CellRangeAddress.hpp>
-#include <com/sun/star/table/CellAddress.hpp>
-#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
-#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
-#include <com/sun/star/container/XNameAccess.hpp>
-#include <oox/helper/helper.hxx>
-
-#include "properties.hxx"
-
 using ::rtl::OUString;
 using ::rtl::OStringBuffer;
 using ::rtl::OUStringToOString;
 using ::com::sun::star::uno::Reference;
 using ::com::sun::star::uno::Sequence;
 using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::makeAny;
 using ::com::sun::star::uno::UNO_QUERY;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
-using ::com::sun::star::lang::XMultiServiceFactory;
 using ::com::sun::star::beans::XPropertySet;
-using ::com::sun::star::beans::NamedValue;
-using ::com::sun::star::frame::XModel;
-using ::com::sun::star::container::XNameAccess;
-using ::com::sun::star::form::binding::XBindableValue;
-using ::com::sun::star::form::binding::XListEntrySink;
-using ::com::sun::star::form::binding::XListEntrySource;
-using ::com::sun::star::form::binding::XValueBinding;
-using ::com::sun::star::table::CellRangeAddress;
-using ::com::sun::star::table::CellAddress;
-using ::com::sun::star::sheet::XCellRangeReferrer;
-using ::com::sun::star::sheet::XCellRangeAddressable;
 
 namespace oox {
 
     PropertyMap::dump( Reference< XPropertySet >( getXPropertySet(), UNO_QUERY ) );
 }
 #endif
-bool lcl_isNamedRange( const rtl::OUString& sAddress, const Reference< XModel >& xModel, CellRangeAddress& aAddress )
-{
-    bool bRes = false;
-    const static OUString sNamedRanges( RTL_CONSTASCII_USTRINGPARAM("NamedRanges"));
-    Reference< XCellRangeReferrer > xReferrer;
-    try
-    {
-        Reference< XPropertySet > xPropSet( xModel, UNO_QUERY_THROW );
-        Reference< XNameAccess > xNamed( xPropSet->getPropertyValue( sNamedRanges ), UNO_QUERY_THROW );
-        xReferrer.set ( xNamed->getByName( sAddress ), UNO_QUERY );
-    }
-    catch( Exception& /*e*/ )
-    {
-        // do nothing
-    }
-    if ( xReferrer.is() )
-    {
-        Reference< XCellRangeAddressable > xRangeAddressable( xReferrer->getReferredCells(), UNO_QUERY );
-        if ( xRangeAddressable.is() )
-        {
-            aAddress = xRangeAddressable->getRangeAddress();
-            bRes = true;
-        }
-    }
-    return bRes;
-}
-
-void lcl_ApplyListSourceAndBindableStuff( const Reference< XModel >& xModel, const Reference< XPropertySet >& rPropSet, const OUString& rsCtrlSource, const OUString& rsRowSource )
-{
-// XBindable etc.
-    Reference< XMultiServiceFactory > xFac;
-    if ( xModel.is() )
-        xFac.set( xModel, UNO_QUERY );
-    Reference< XBindableValue > xBindable( rPropSet, UNO_QUERY );
-    if (  xFac.is() && rsCtrlSource.getLength() && xBindable.is() )
-    {
-         
-         // OOo address structures
-         // RefCell - convert from XL
-         // pretend we converted the imported string address into the
-         // appropriate address structure
-         Reference< XPropertySet > xConvertor( xFac->createInstance( CREATE_OUSTRING( "com.sun.star.table.CellAddressConversion" )), UNO_QUERY );
-         CellAddress aAddress;
-         if ( xConvertor.is() )
-         {
-             // we need this service to properly convert XL notation also
-             // Should be easy to extend
-             xConvertor->setPropertyValue( CREATE_OUSTRING( "XL_A1_Representation" ), makeAny( rsCtrlSource ) );
-             xConvertor->getPropertyValue( CREATE_OUSTRING( "Address" ) ) >>= aAddress;    
-         }
-        
-         NamedValue aArg1;
-         aArg1.Name = CREATE_OUSTRING("BoundCell");
-         aArg1.Value <<= aAddress;
-
-         Sequence< Any > aArgs(1);
-         aArgs[ 0 ]  <<= aArg1;
-
-         Reference< XValueBinding > xBinding( xFac->createInstanceWithArguments( CREATE_OUSTRING("com.sun.star.table.CellValueBinding" ), aArgs ), UNO_QUERY );
-         xBindable->setValueBinding( xBinding );
-    }
-    Reference< XListEntrySink > xListEntrySink( rPropSet, UNO_QUERY );
-    if (  xFac.is() && rsRowSource.getLength() && xListEntrySink.is() )
-    {
-         
-         // OOo address structures
-         // RefCell - convert from XL
-         // pretend we converted the imported string address into the
-         // appropriate address structure
-         Reference< XPropertySet > xConvertor( xFac->createInstance( CREATE_OUSTRING( "com.sun.star.table.CellRangeAddressConversion" )), UNO_QUERY );
-         CellRangeAddress aAddress;
-         if ( xConvertor.is() )
-         {
-             if ( !lcl_isNamedRange( rsRowSource, xModel, aAddress ) )
-             {
-                 // we need this service to properly convert XL notation also
-                 // Should be easy to extend
-                 xConvertor->setPropertyValue( CREATE_OUSTRING( "XL_A1_Representation" ), makeAny( rsRowSource ) );
-                 xConvertor->getPropertyValue( CREATE_OUSTRING( "Address" ) ) >>= aAddress;
-             }
-         }
-        
-         NamedValue aArg1;
-         aArg1.Name = CREATE_OUSTRING("CellRange");
-         aArg1.Value <<= aAddress;
-
-         Sequence< Any > aArgs(1);
-         aArgs[ 0 ]  <<= aArg1;
-
-         Reference< XListEntrySource > xSource( xFac->createInstanceWithArguments( CREATE_OUSTRING("com.sun.star.table.CellRangeListSource" ), aArgs ), UNO_QUERY );
-         xListEntrySink->setListEntrySource( xSource );
-    }
-}
-void FormPropertySet::setDataAwareProperties( const Reference< XModel >& rxDocModel, const PropertyMap& rMap )
-{
-    OUString sRowSource;
-    OUString sControlSource;
-    if ( rMap.hasProperty( PROP_ControlSource ) )
-        *(rMap.getProperty( PROP_ControlSource )) >>= sControlSource;
-    if ( rMap.hasProperty( PROP_RowSource ) )
-        *(rMap.getProperty( PROP_RowSource )) >>= sRowSource;
-    lcl_ApplyListSourceAndBindableStuff( rxDocModel, getXPropertySet(), sControlSource, sRowSource );
-}
 
 // ============================================================================
 

oox/source/ole/axcontrol.cxx

 #include <com/sun/star/awt/TextAlign.hpp>
 #include <com/sun/star/awt/VisualEffect.hpp>
 #include <com/sun/star/awt/XControlModel.hpp>
+#include <com/sun/star/beans/NamedValue.hpp>
 #include <com/sun/star/container/XIndexContainer.hpp>
 #include <com/sun/star/form/XForm.hpp>
 #include <com/sun/star/form/XFormComponent.hpp>
 #include <com/sun/star/form/XFormsSupplier.hpp>
+#include <com/sun/star/form/binding/XBindableValue.hpp>
+#include <com/sun/star/form/binding/XListEntrySink.hpp>
+#include <com/sun/star/form/binding/XListEntrySource.hpp>
+#include <com/sun/star/form/binding/XValueBinding.hpp>
 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
+#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
+#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
 #include <com/sun/star/style/VerticalAlignment.hpp>
+#include <com/sun/star/table/CellAddress.hpp>
+#include <com/sun/star/table/CellRangeAddress.hpp>
 #include "properties.hxx"
 #include "tokens.hxx"
 #include "oox/helper/attributelist.hxx"
 #include "oox/helper/binaryinputstream.hxx"
 #include "oox/helper/graphichelper.hxx"
 #include "oox/helper/propertymap.hxx"
-#include "oox/helper/propertyset.hxx"
-
-using ::rtl::OUString;
-using ::com::sun::star::awt::Point;
-using ::com::sun::star::awt::Size;
-using ::com::sun::star::awt::XControlModel;
-using ::com::sun::star::container::XIndexContainer;
-using ::com::sun::star::container::XNameContainer;
-using ::com::sun::star::drawing::XDrawPage;
-using ::com::sun::star::form::XForm;
-using ::com::sun::star::form::XFormComponent;
-using ::com::sun::star::lang::XMultiServiceFactory;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::UNO_QUERY;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
-using ::com::sun::star::uno::UNO_SET_THROW;
 
 namespace oox {
 namespace ole {
 
+using ::rtl::OUString;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::beans;
+using namespace ::com::sun::star::container;
+using namespace ::com::sun::star::drawing;
+using namespace ::com::sun::star::form;
+using namespace ::com::sun::star::form::binding;
+using namespace ::com::sun::star::frame;
+using namespace ::com::sun::star::lang;
+using namespace ::com::sun::star::sheet;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::uno;
+
 // ============================================================================
 
 namespace {
 const sal_Int16 API_STATE_CHECKED           = 1;
 const sal_Int16 API_STATE_DONTKNOW          = 2;
 
+// ----------------------------------------------------------------------------
+
+/** Tries to extract a range address from a defined name. */
+bool lclExtractRangeFromName( CellRangeAddress& orRangeAddr, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
+{
+    try
+    {
+        PropertySet aPropSet( rxDocModel );
+        Reference< XNameAccess > xRangesNA( aPropSet.getAnyProperty( PROP_NamedRanges ), UNO_QUERY_THROW );
+        Reference< XCellRangeReferrer > xReferrer( xRangesNA->getByName( rAddressString ), UNO_QUERY_THROW );
+        Reference< XCellRangeAddressable > xAddressable( xReferrer->getReferredCells(), UNO_QUERY_THROW );
+        orRangeAddr = xAddressable->getRangeAddress();
+        return true;
+    }
+    catch( Exception& )
+    {
+    }
+    return false;
+}
+
+bool lclExtractAddressFromName( CellAddress& orAddress, const Reference< XModel >& rxDocModel, const OUString& rAddressString )
+{
+    CellRangeAddress aRangeAddr;
+    if( lclExtractRangeFromName( aRangeAddr, rxDocModel, rAddressString ) &&
+        (aRangeAddr.StartColumn == aRangeAddr.EndColumn) &&
+        (aRangeAddr.StartRow == aRangeAddr.EndRow) )
+    {
+        orAddress.Sheet = aRangeAddr.Sheet;
+        orAddress.Column = aRangeAddr.StartColumn;
+        orAddress.Row = aRangeAddr.StartRow;
+        return true;
+    }
+    return false;
+}
+
+void lclPrepareConverter( PropertySet& rConverter, const Reference< XModel >& rxDocModel,
+        const OUString& rAddressString, sal_Int32 nRefSheet, bool bRange )
+{
+    if( !rConverter.is() ) try
+    {
+        Reference< XMultiServiceFactory > xFactory( rxDocModel, UNO_QUERY_THROW );
+        OUString aServiceName = bRange ?
+            CREATE_OUSTRING( "com.sun.star.table.CellRangeAddressConversion" ) :
+            CREATE_OUSTRING( "com.sun.star.table.CellAddressConversion" );
+        rConverter.set( xFactory->createInstance( aServiceName ) );
+    }
+    catch( Exception& )
+    {
+    }
+    rConverter.setProperty( PROP_XL_A1_Representation, rAddressString );
+    rConverter.setProperty( PROP_ReferenceSheet, nRefSheet );
+}
+
 } // namespace
 
 // ============================================================================
 
-ControlConverter::ControlConverter( const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
+ControlConverter::ControlConverter( const Reference< XModel >& rxDocModel,
+        const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
+    mxDocModel( rxDocModel ),
     mrGraphicHelper( rGraphicHelper ),
     mbDefaultColorBgr( bDefaultColorBgr )
 {
+    OSL_ENSURE( mxDocModel.is(), "ControlConverter::ControlConverter - missing document model" );
 }
 
 ControlConverter::~ControlConverter()
     rPropMap.setProperty( bAwtModel ? PROP_ScrollValue : PROP_DefaultScrollValue, nPosition );
 }
 
+void ControlConverter::bindToSources( const Reference< XControlModel >& rxCtrlModel,
+        const OUString& rCtrlSource, const OUString& rRowSource, sal_Int32 nRefSheet ) const
+{
+    // value binding
+    if( rCtrlSource.getLength() > 0 ) try
+    {
+        // first check if the XBindableValue interface is supported
+        Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
+
+        // convert address string to cell address struct
+        CellAddress aAddress;
+        if( !lclExtractAddressFromName( aAddress, mxDocModel, rCtrlSource ) )
+        {
+            lclPrepareConverter( maAddressConverter, mxDocModel, rCtrlSource, nRefSheet, false );
+            if( !maAddressConverter.getProperty( aAddress, PROP_Address ) )
+                throw RuntimeException();
+        }
+
+        // create argument sequence
+        NamedValue aValue;
+        aValue.Name = CREATE_OUSTRING( "BoundCell" );
+        aValue.Value <<= aAddress;
+        Sequence< Any > aArgs( 1 );
+        aArgs[ 0 ] <<= aValue;
+
+        // create the CellValueBinding instance and set at the control model
+        Reference< XMultiServiceFactory > xFactory( mxDocModel, UNO_QUERY_THROW );
+        Reference< XValueBinding > xBinding( xFactory->createInstanceWithArguments(
+            CREATE_OUSTRING( "com.sun.star.table.CellValueBinding" ), aArgs ), UNO_QUERY_THROW );
+        xBindable->setValueBinding( xBinding );
+    }
+    catch( Exception& )
+    {
+    }
+
+    // list entry source
+    if( rRowSource.getLength() > 0 ) try
+    {
+        // first check if the XListEntrySink interface is supported
+        Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
+
+        // convert address string to cell range address struct
+        CellRangeAddress aRangeAddr;
+        if( !lclExtractRangeFromName( aRangeAddr, mxDocModel, rRowSource ) )
+        {
+            lclPrepareConverter( maRangeConverter, mxDocModel, rRowSource, nRefSheet, true );
+            if( !maRangeConverter.getProperty( aRangeAddr, PROP_Address ) )
+                throw RuntimeException();
+        }
+
+        // create argument sequence
+        NamedValue aValue;
+        aValue.Name = CREATE_OUSTRING( "CellRange" );
+        aValue.Value <<= aRangeAddr;
+        Sequence< Any > aArgs( 1 );
+        aArgs[ 0 ] <<= aValue;
+
+        // create the EntrySource instance and set at the control model
+        Reference< XMultiServiceFactory > xFactory( mxDocModel, UNO_QUERY_THROW );
+        Reference< XListEntrySource > xEntrySource( xFactory->createInstanceWithArguments(
+            CREATE_OUSTRING( "com.sun.star.table.CellRangeListSource"  ), aArgs ), UNO_QUERY_THROW );
+        xEntrySink->setListEntrySource( xEntrySource );
+    }
+    catch( Exception& )
+    {
+    }
+}
+
 // ActiveX (Forms 2.0) specific conversion ------------------------------------
 
 void ControlConverter::convertAxBackground( PropertyMap& rPropMap,
 
 // ============================================================================
 
-EmbeddedForm::EmbeddedForm( const Reference< XMultiServiceFactory >& rxModelFactory,
+EmbeddedForm::EmbeddedForm( const Reference< XModel >& rxDocModel,
         const Reference< XDrawPage >& rxDrawPage, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
-    ControlConverter( rGraphicHelper, bDefaultColorBgr ),
-    mxModelFactory( rxModelFactory ),
+    ControlConverter( rxDocModel, rGraphicHelper, bDefaultColorBgr ),
+    mxModelFactory( rxDocModel, UNO_QUERY ),
     mxFormsSupp( rxDrawPage, UNO_QUERY )
 {
     OSL_ENSURE( mxModelFactory.is(), "EmbeddedForm::EmbeddedForm - missing service factory" );

oox/source/ole/vbacontrol.cxx

             case VBA_SITE_TEXTBOX:          xCtrlModel.reset( new AxTextBoxModel );         break;
             case VBA_SITE_LISTBOX:          xCtrlModel.reset( new AxListBoxModel );         break;
             case VBA_SITE_COMBOBOX:         xCtrlModel.reset( new AxComboBoxModel );        break;
-            case VBA_SITE_SPINBUTTON:       xCtrlModel.reset( new AxSpinButtonModel );  break;
+            case VBA_SITE_SPINBUTTON:       xCtrlModel.reset( new AxSpinButtonModel );      break;
             case VBA_SITE_SCROLLBAR:        xCtrlModel.reset( new AxScrollBarModel );       break;
             case VBA_SITE_TABSTRIP:         xCtrlModel.reset( new AxTabStripModel );        break;
             case VBA_SITE_FRAME:            xCtrlModel.reset( new AxFrameModel );           break;
     return xCtrlModel;
 }
 
-void VbaSiteModel::convertDataAwareProperties( PropertyMap& rPropMap )
-{
-    rPropMap.setProperty( PROP_ControlSource, maControlSource );
-    rPropMap.setProperty( PROP_RowSource, maRowSource );
-}
-
 void VbaSiteModel::convertProperties( PropertyMap& rPropMap,
         const ControlConverter& rConv, ApiControlType eCtrlType, sal_Int32 nCtrlIndex ) const
 {
     }
 }
 
+void VbaSiteModel::bindToSources( const Reference< XControlModel >& rxCtrlModel, const ControlConverter& rConv ) const
+{
+    rConv.bindToSources( rxCtrlModel, maControlSource, maRowSource );
+}
+
 // ============================================================================
 
 VbaFormControl::VbaFormControl()
 }
 
 void VbaFormControl::createAndConvert( sal_Int32 nCtrlIndex,
-         const Reference< XModel >& rxDocModel,
         const Reference< XNameContainer >& rxParentNC, const ControlConverter& rConv ) const
 {
     if( rxParentNC.is() && mxSiteModel.get() && mxCtrlModel.get() ) try
         Reference< XControlModel > xCtrlModel( xModelFactory->createInstance( aServiceName ), UNO_QUERY_THROW );
 
         // convert all properties and embedded controls
-        if( convertProperties( rxDocModel, xCtrlModel, rConv, nCtrlIndex ) )
+        if( convertProperties( xCtrlModel, rConv, nCtrlIndex ) )
         {
             // insert into parent container
             const OUString& rCtrlName = mxSiteModel->getName();
     }
 }
 
-bool VbaFormControl::convertProperties( const Reference< XModel >& rxDocModel, const Reference< XControlModel >& rxCtrlModel,
+bool VbaFormControl::convertProperties( const Reference< XControlModel >& rxCtrlModel,
         const ControlConverter& rConv, sal_Int32 nCtrlIndex ) const
 {
     if( rxCtrlModel.is() && mxSiteModel.get() && mxCtrlModel.get() )
             // convert all properties
             PropertyMap aPropMap;
             mxSiteModel->convertProperties( aPropMap, rConv, mxCtrlModel->getControlType(), nCtrlIndex );
-            PropertyMap aDataPropMap;
-            mxSiteModel->convertDataAwareProperties( aDataPropMap );
             mxCtrlModel->convertProperties( aPropMap, rConv );
             mxCtrlModel->convertSize( aPropMap, rConv );
-            FormPropertySet aPropSet( rxCtrlModel );
+            PropertySet aPropSet( rxCtrlModel );
             aPropSet.setProperties( aPropMap );
-            aPropSet.setDataAwareProperties( rxDocModel, aDataPropMap );
+
+            // bind to control source and row source range
+            mxSiteModel->bindToSources( rxCtrlModel, rConv );
 
             // create and convert all embedded controls
             if( !maControls.empty() ) try
                 /*  Call conversion for all controls. Pass vector index as new
                     tab order to make option button groups work correctly. */
                 maControls.forEachMemWithIndex( &VbaFormControl::createAndConvert,
-                    ::boost::cref( rxDocModel ), ::boost::cref( xCtrlModelNC ), ::boost::cref( rConv ) );
+                    ::boost::cref( xCtrlModelNC ), ::boost::cref( rConv ) );
             }
             catch( Exception& )
             {
 // ----------------------------------------------------------------------------
 
 VbaUserForm::VbaUserForm( const Reference< XMultiServiceFactory >& rxGlobalFactory,
-        const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
-    ControlConverter( rGraphicHelper, bDefaultColorBgr ),
-    mxGlobalFactory( rxGlobalFactory )
+        const Reference< XModel >& rxDocModel, const GraphicHelper& rGraphicHelper, bool bDefaultColorBgr ) :
+    mxGlobalFactory( rxGlobalFactory ),
+    mxDocModel( rxDocModel ),
+    maConverter( rxDocModel, rGraphicHelper, bDefaultColorBgr )
 {
     OSL_ENSURE( mxGlobalFactory.is(), "VbaUserForm::VbaUserForm - missing service factory" );
+    OSL_ENSURE( mxDocModel.is(), "VbaUserForm::VbaUserForm - missing document model" );
 }
 
-void VbaUserForm::importForm( const Reference< XModel >& rxDocModel, const Reference< XNameContainer >& rxDialogLib,
+void VbaUserForm::importForm( const Reference< XNameContainer >& rxDialogLib,
         StorageBase& rVbaFormStrg, const OUString& rModuleName, rtl_TextEncoding eTextEnc )
 {
     OSL_ENSURE( rxDialogLib.is(), "VbaUserForm::importForm - missing dialog library" );
-    if( !mxGlobalFactory.is() || !rxDialogLib.is() )
+    if( !mxGlobalFactory.is() || !mxDocModel.is() || !rxDialogLib.is() )
         return;
 
     // check that the '03VBFrame' stream exists, this is required for forms
         Reference< XNameContainer > xDialogNC( xDialogModel, UNO_QUERY_THROW );
 
         // convert properties and embedded controls
-        if( convertProperties( rxDocModel, xDialogModel, *this, 0 ) )
+        if( convertProperties( xDialogModel, maConverter, 0 ) )
         {
             // export the dialog to XML and insert it into the dialog library
             PropertySet aFactoryProps( mxGlobalFactory );
             Reference< XComponentContext > xCompContext( aFactoryProps.getAnyProperty( PROP_DefaultContext ), UNO_QUERY_THROW );
-            Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, xCompContext, rxDocModel ), UNO_SET_THROW );
+            Reference< XInputStreamProvider > xDialogSource( ::xmlscript::exportDialogModel( xDialogNC, xCompContext, mxDocModel ), UNO_SET_THROW );
             OSL_ENSURE( !rxDialogLib->hasByName( aFormName ), "VbaUserForm::importForm - multiple dialogs with equal name" );
             ContainerHelper::insertByName( rxDialogLib, aFormName, Any( xDialogSource ) );
         }

oox/source/ole/vbaproject.cxx

                     eTextEnc = eNewTextEnc;
             }
             break;
+            case VBA_ID_PROJECTNAME:
+            {
+                OUString aPrjName = aRecStrm.readCharArrayUC( nRecSize, eTextEnc );
+                OSL_ENSURE( aPrjName.getLength() > 0, "VbaProject::importVba - invalid project name" );
+                if( aPrjName.getLength() > 0 )
+                    maPrjName = aPrjName;
+            }
+            break;
             case VBA_ID_PROJECTMODULES:
                 OOX_ENSURE_RECORDSIZE( nRecSize == 2 );
                 OSL_ENSURE( aModules.empty(), "VbaProject::importVba - unexpected PROJECTMODULES record" );
                 aModulesByStrm[ rxModule->getStreamName() ] = rxModule;
             }
             break;
-            case VBA_ID_PROJECTNAME:
-            {
-                maPrjName = aRecStrm.readCharArrayUC( nRecSize, eTextEnc );
-                OSL_ENSURE( maPrjName.getLength() > 0, "VbaProject::importVba - invalid project name" );
-            }
-            break;
 #undef OOX_ENSURE_RECORDSIZE
         }
     }
 
                 // create and import the form
                 Reference< XNameContainer > xDialogLib( createDialogLibrary(), UNO_SET_THROW );
-                VbaUserForm aForm( mxGlobalFactory, rGraphicHelper, bDefaultColorBgr );
-                aForm.importForm( mxDocModel, xDialogLib, *xSubStrg, aModuleName, eTextEnc );
+                VbaUserForm aForm( mxGlobalFactory, mxDocModel, rGraphicHelper, bDefaultColorBgr );
+                aForm.importForm( xDialogLib, *xSubStrg, aModuleName, eTextEnc );
             }
             catch( Exception& )
             {

oox/source/token/genproperties.pl

 {
     chomp( $_ );
     $_ =~ s/\s*//g;
-    $_ =~ /^[A-Z][a-zA-Z0-9]*$/ or die "invalid character in property '$_'";
+    $_ =~ /^[A-Z][a-zA-Z0-9_]*$/ or die "invalid character in property '$_'";
     $id = "PROP_$_";
     $props{$_} = $id;
 }

oox/source/token/properties.txt

 AdjustContrast
 AdjustLuminance
 AdjustmentValues
+Address
 Align
 AnchorPosition
 ArrangeOrder
 ConditionalFormat
 ConnectBars
 ContainsHeader
-ControlSource
 Coordinates
 CopyBack
 CopyFormulas
 RefY
 Reference
 ReferenceDevice
+ReferenceSheet
 RegularExpressions
 RelId
 RelativeHorizontalTabbarWidth
 RotationVertical
 RowGrand
 RowLabelRanges
-RowSource
 ScaleMode
 ScaleToPages
 ScaleToPagesX
 Width
 WriteProtectionPassword
 WritingMode
+XL_A1_Representation
 ZoomType
 ZoomValue

oox/source/vml/vmldrawing.cxx

 {
     if( !mxCtrlForm.get() )
         mxCtrlForm.reset( new ::oox::ole::EmbeddedForm(
-            mrFilter.getModelFactory(), mxDrawPage, mrFilter.getGraphicHelper() ) );
+            mrFilter.getModel(), mxDrawPage, mrFilter.getGraphicHelper() ) );
     return *mxCtrlForm;
 }
 

oox/source/xls/drawingfragment.cxx

 
 #include "oox/xls/drawingfragment.hxx"
 #include <com/sun/star/awt/Point.hpp>
-#include <com/sun/star/beans/NamedValue.hpp>
-#include <com/sun/star/form/binding/XBindableValue.hpp>
-#include <com/sun/star/form/binding/XListEntrySink.hpp>
-#include <com/sun/star/form/binding/XListEntrySource.hpp>
-#include <com/sun/star/form/binding/XValueBinding.hpp>
 #include "properties.hxx"
 #include "oox/helper/attributelist.hxx"
 #include "oox/helper/propertyset.hxx"
 #include "oox/xls/unitconverter.hxx"
 
 using ::rtl::OUString;
-using ::com::sun::star::uno::Any;
-using ::com::sun::star::uno::Exception;
-using ::com::sun::star::uno::Reference;
-using ::com::sun::star::uno::Sequence;
-using ::com::sun::star::uno::UNO_QUERY;
-using ::com::sun::star::uno::UNO_QUERY_THROW;
-using ::com::sun::star::beans::NamedValue;
-using ::com::sun::star::awt::Point;
-using ::com::sun::star::awt::Rectangle;
-using ::com::sun::star::awt::Size;
-using ::com::sun::star::awt::XControlModel;
-using ::com::sun::star::form::binding::XBindableValue;
-using ::com::sun::star::form::binding::XListEntrySink;
-using ::com::sun::star::form::binding::XListEntrySource;
-using ::com::sun::star::form::binding::XValueBinding;
-using ::com::sun::star::table::CellAddress;
-using ::com::sun::star::table::CellRangeAddress;
+using namespace ::com::sun::star::awt;
+using namespace ::com::sun::star::table;
+using namespace ::com::sun::star::uno;
 using ::oox::core::ContextHandlerRef;
 using ::oox::drawingml::ConnectorShapeContext;
 using ::oox::drawingml::GraphicalObjectFrameContext;
 
 VmlDrawing::VmlDrawing( const WorksheetHelper& rHelper ) :
     ::oox::vml::Drawing( rHelper.getOoxFilter(), rHelper.getDrawPage(), ::oox::vml::VMLDRAWING_EXCEL ),
-    WorksheetHelper( rHelper )
+    WorksheetHelper( rHelper ),
+    maControlConv( rHelper.getBaseFilter().getModel(), rHelper.getBaseFilter().getGraphicHelper() )
 {
 }
 
         // printable
         aPropSet.setProperty( PROP_Printable, rClientData.mbPrintObject );
 
-        // linked cell
-        if( rClientData.maLinkedCell.getLength() > 0 ) try
-        {
-            Reference< XBindableValue > xBindable( rxCtrlModel, UNO_QUERY_THROW );
-
-            // convert formula string to cell address
-            FormulaParser& rParser = getFormulaParser();
-            TokensFormulaContext aContext( true, false );
-            aContext.setBaseAddress( CellAddress( getSheetIndex(), 0, 0 ) );
-            rParser.importFormula( aContext, rClientData.maLinkedCell );
-            CellAddress aAddress;
-            if( rParser.extractCellAddress( aAddress, aContext.getTokens(), true ) )
-            {
-                // create argument sequence for createInstanceWithArguments()
-                NamedValue aValue;
-                aValue.Name = CREATE_OUSTRING( "BoundCell" );
-                aValue.Value <<= aAddress;
-                Sequence< Any > aArgs( 1 );
-                aArgs[ 0 ] <<= aValue;
-
-                // create the CellValueBinding instance and set at the control model
-                Reference< XValueBinding > xBinding( getDocumentFactory()->createInstanceWithArguments(
-                    CREATE_OUSTRING( "com.sun.star.table.CellValueBinding" ), aArgs ), UNO_QUERY_THROW );
-                xBindable->setValueBinding( xBinding );
-            }
-        }
-        catch( Exception& )
-        {
-        }
-
-        // source range
-        if( rClientData.maSourceRange.getLength() > 0 ) try
-        {
-            Reference< XListEntrySink > xEntrySink( rxCtrlModel, UNO_QUERY_THROW );
-
-            // convert formula string to cell range
-            FormulaParser& rParser = getFormulaParser();
-            TokensFormulaContext aContext( true, false );
-            aContext.setBaseAddress( CellAddress( getSheetIndex(), 0, 0 ) );
-            rParser.importFormula( aContext, rClientData.maSourceRange );
-            CellRangeAddress aRange;
-            if( rParser.extractCellRange( aRange, aContext.getTokens(), true ) )
-            {
-                // create argument sequence for createInstanceWithArguments()
-                NamedValue aValue;
-                aValue.Name = CREATE_OUSTRING( "CellRange" );
-                aValue.Value <<= aRange;
-                Sequence< Any > aArgs( 1 );
-                aArgs[ 0 ] <<= aValue;
-
-                // create the EntrySource instance and set at the control model
-                Reference< XListEntrySource > xEntrySource( getDocumentFactory()->createInstanceWithArguments(
-                    CREATE_OUSTRING( "com.sun.star.table.CellRangeListSource"  ), aArgs ), UNO_QUERY_THROW );
-                xEntrySink->setListEntrySource( xEntrySource );
-            }
-        }
-        catch( Exception& )
-        {
-        }
+        // control sources
+        if( (rClientData.maLinkedCell.getLength() > 0) || (rClientData.maSourceRange.getLength() > 0) )
+            maControlConv.bindToSources( rxCtrlModel, rClientData.maLinkedCell, rClientData.maSourceRange, getSheetIndex() );
     }
 }
 
 
 } // namespace xls
 } // namespace oox
-

vbahelper/util/makefile.mk

         $(VCLLIB) \
         $(TKLIB) \
                 $(BASICLIB) \
+                $(OOXLIB) \
 
 SHL2DEPN=$(SHL1TARGETN)
 SHL2LIBS=$(SLB)$/$(TARGET_MSFORMS).lib