ooo-build r12954 - trunk/patches/test/vba



Author: noelpwer
Date: Tue Jun 24 17:15:04 2008
New Revision: 12954
URL: http://svn.gnome.org/viewvc/ooo-build?rev=12954&view=rev

Log:
snapshot with persisted groupname for dialogs ( and new logic in the
importer for creating a groupname )


Modified:
   trunk/patches/test/vba/ObjectModule.diff

Modified: trunk/patches/test/vba/ObjectModule.diff
==============================================================================
--- trunk/patches/test/vba/ObjectModule.diff	(original)
+++ trunk/patches/test/vba/ObjectModule.diff	Tue Jun 24 17:15:04 2008
@@ -1964,10 +1964,18 @@
          if( xStringResourceManager.is() )
          {
 diff --git svx/inc/svx/msocximex.hxx svx/inc/svx/msocximex.hxx
-index 05e3c75..7a98fbe 100644
+index 05e3c75..31258f4 100644
 --- svx/inc/svx/msocximex.hxx
 +++ svx/inc/svx/msocximex.hxx
-@@ -404,6 +404,8 @@ public:
+@@ -289,6 +289,7 @@ public:
+         sal_uInt16 mnTabPos;
+ 	UniString sName;
+ 	UniString msToolTip;
++	UniString msParentName;
+ 	OCX_FontData aFontData;
+         SfxObjectShell *pDocSh;
+ protected:
+@@ -404,6 +405,8 @@ public:
  	sal_uInt32 nGroupNameLen;
  	sal_uInt32 nUnknown10;
  
@@ -1976,7 +1984,7 @@
  	char *pValue;
  	char *pCaption;
  	char *pGroupName;
-@@ -487,6 +489,8 @@ struct ContainerRecord
+@@ -487,6 +490,8 @@ struct ContainerRecord
  
      ::rtl::OUString cName;
      ::rtl::OUString controlTip;
@@ -1985,7 +1993,70 @@
  
      sal_uInt32 nTop;
      sal_uInt32 nLeft;
-@@ -1086,7 +1090,8 @@ class OCX_ListBox : public OCX_ModernCon
+@@ -500,54 +505,8 @@ typedef std::vector<OCX_Control*>::itera
+ typedef std::vector<OCX_Control*>::const_iterator CtrlIteratorConst;
+ typedef std::vector<OCX_Control*>  CtrlList;
+ 
+-
+-
+-class RBGroup
+-{
+-    public:
+-    RBGroup():mRBGroupPos(0){}
+-    RBGroup(sal_uInt16& groupPos ):mRBGroupPos(groupPos){}
+-    sal_Int16 tabPos() const { return mRBGroupPos; }
+-    std::vector<OCX_Control*>::size_type numControls()
+-    { return mpControls.size(); }
+-    std::vector<OCX_Control*>& controls() { return mpControls; }
+-
+-    void add(OCX_Control* pRB);
+-    private:
+-    sal_uInt16 mRBGroupPos;
+-    std::vector<OCX_Control*> mpControls;
+-};
+-
+-typedef ::std::hash_map < ::rtl::OUString, RBGroup*, ::rtl::OUStringHash,
+-    ::std::equal_to< ::rtl::OUString > > RBGroupHash;
+-typedef std::vector<RBGroup*>::iterator GroupIterator;
+-
+ class OCX_OptionButton;
+ 
+-class RBGroupManager
+-{
+-public:
+-    RBGroupManager( String& defaultName );
+-    ~RBGroupManager();
+-
+-    CtrlList insertGroupsIntoControlList( const CtrlList& sourceList );
+-    void addRadioButton( OCX_OptionButton* pRButton );
+-private:
+-
+-    void addSeperator( std::vector< OCX_Control* >& dest );
+-    void copyList( std::vector< OCX_Control* >& src,
+-                  std::vector< OCX_Control* >& dest,
+-                  bool addGroupSeperator );
+-
+-    RBGroupHash rbGroups;
+-    String mSDefaultName;
+-    std::vector< RBGroup* > groupList;
+-    sal_uInt16 numRadioButtons;
+-};
+-
+-
+-
+-
+ class OCX_ContainerControl : public OCX_Control
+ {
+ public:
+@@ -586,7 +545,6 @@ protected:
+             OCX_Control* pParent = NULL );
+         rtl::OUString createSubStreamName( const sal_uInt32& subStorageID );
+ 
+-        RBGroupManager rbGroupMgr;
+         com::sun::star::uno::Reference<
+                 com::sun::star::container::XNameContainer > mxParent;
+ 	std::vector<OCX_Control*> mpControls;
+@@ -1086,7 +1044,8 @@ class OCX_ListBox : public OCX_ModernCon
  public:
  	OCX_ListBox() : OCX_ModernControl(rtl::OUString::createFromAscii("ListBox")){
  		msFormType = rtl::OUString::createFromAscii("com.sun.star.form.component.ListBox");
@@ -1996,7 +2067,7 @@
  		mnForeColor = 0x80000008;
  		nBorderColor = 0x80000006;
 diff --git svx/source/msfilter/msocximex.cxx svx/source/msfilter/msocximex.cxx
-index 143c66b..6af2878 100644
+index 143c66b..9b61c5a 100644
 --- svx/source/msfilter/msocximex.cxx
 +++ svx/source/msfilter/msocximex.cxx
 @@ -49,6 +49,10 @@
@@ -2049,7 +2120,214 @@
              }
  
              // seek to end of data
-@@ -2825,7 +2844,66 @@ sal_Bool OCX_ListBox::Import(com::sun::s
+@@ -825,176 +844,6 @@ class ContainerRecordReaderFac
+ 
+ // ============================================================================
+ 
+-void RBGroup::add(OCX_Control* pRB)
+-{
+-    // The tab index for the group is calculated as
+-    // the lowest tab index found in the list of RadioButtons
+-    if ( pRB->mnTabPos < mRBGroupPos )
+-    {
+-        mRBGroupPos = pRB->mnTabPos;
+-        CtrlIterator aEnd = mpControls.end();
+-        for (CtrlIterator aIter = mpControls.begin(); aIter != aEnd; ++ aIter )
+-        {
+-            (*aIter)->mnTabPos = mRBGroupPos;
+-        }
+-    }
+-    mpControls.push_back( pRB );
+-}
+-
+-struct SortGroupByTabPos
+-{
+-    bool operator()( const RBGroup* a, const RBGroup* b )
+-    {
+-        return a->tabPos() < b->tabPos();
+-    }
+-};
+-
+-RBGroupManager::RBGroupManager( String& defaultName ):mSDefaultName( defaultName ),
+-    numRadioButtons(0)
+-{
+-    groupList.reserve( 8 ); // reserve far more than we expect
+-}
+-
+-RBGroupManager::~RBGroupManager()
+-{
+-    for ( GroupIterator gIter=groupList.begin(); gIter!=groupList.end(); ++gIter )
+-    {
+-        delete( *gIter );
+-    }
+-}
+-
+-// Loose description of the method below ( I sure there is a better way to do
+-// this )
+-// In order to "fake" MS grouping behavior for OptionButtons the OptionButtons
+-// in the same group need to have consecutive tab indices ( regardless of the
+-// imported tab indices of the RadioButtons ). Additionally if two
+-// groups of OptionButtons end up having all consecutive indices they
+-// will be treated as a single group by OpenOffice. In this case
+-// a dummy seperator control needs to be inserted between the groups.
+-//
+-// This method returns a new list "destinationList" containing the controls
+-// passed in "sourceList" and the OptionButtons contained in the various
+-// Groups maintained by this  class.
+-// Controls are ordered in the destination list by tab index.
+-// Each RadioButtonGroup has a tab index associated with it.
+-// ( Tab index of a RadioGroup is determined as the tab index of the
+-// OptionButton control with the lowest tab index in the group )
+-
+-
+-void RBGroupManager::addRadioButton( OCX_OptionButton* pRButton )
+-{
+-    if ( pRButton )
+-    {
+-        OUString groupName = mSDefaultName;
+-        if ( pRButton->nGroupNameLen )
+-        {
+-            groupName =
+-                lclCreateOUString(pRButton->pGroupName,
+-                    pRButton->nGroupNameLen);
+-        }
+-        ++numRadioButtons;
+-        RBGroupHash::iterator iter = rbGroups.find( groupName );
+-        if ( iter != rbGroups.end() )
+-        {
+-            iter->second->controls().push_back( pRButton );
+-        }
+-        else
+-        {
+-            RBGroup* newGroup = new RBGroup(pRButton->mnTabPos);
+-            newGroup->controls().push_back( pRButton );
+-            rbGroups[ groupName ] = newGroup;
+-            groupList.push_back( newGroup );
+-        }
+-
+-    }
+-}
+-
+-CtrlList RBGroupManager::insertGroupsIntoControlList( const CtrlList& sourceList )
+-{
+-    ::std::sort( groupList.begin(), groupList.end(), SortGroupByTabPos() );
+-    std::vector<OCX_Control*> destinationList;
+-    if ( groupList.size() )
+-    {
+-        destinationList.reserve( sourceList.size() + numRadioButtons );
+-
+-        GroupIterator groupEnd = groupList.end();
+-        CtrlIteratorConst sourceEnd = sourceList.end();
+-
+-        size_t prevGroupListSize = 0;
+-
+-        CtrlIteratorConst containees = sourceList.begin();
+-        GroupIterator groupIter=groupList.begin();
+-        while ( containees != sourceEnd ||
+-                groupIter != groupEnd )
+-        {
+-            bool addGroupSeperator = false;
+-            if ( containees != sourceEnd )
+-            {
+-                if ( groupIter != groupEnd )
+-                {
+-                    sal_Int16 groupTabPos = (*groupIter)->tabPos();
+-                    if ( (*containees)->mnTabPos >= groupTabPos )
+-                    {
+-                       if ( !(destinationList.size() >=  prevGroupListSize ))
+-                        {
+-                            addGroupSeperator = true;
+-                        }
+-                        copyList( (*groupIter)->controls(), destinationList, addGroupSeperator );
+-                        ++groupIter;
+-
+-                        prevGroupListSize = destinationList.size();
+-                    }
+-                }
+-                destinationList.push_back(*containees);
+-                ++containees;
+-            }
+-            else
+-            {
+-               if ( groupIter != groupEnd )
+-               {
+-                    if ( !(destinationList.size() >  prevGroupListSize ))
+-                    {
+-                        addGroupSeperator = true;
+-                    }
+-                    copyList( (*groupIter)->controls(), destinationList, addGroupSeperator );
+-                    ++groupIter;
+-                    prevGroupListSize = destinationList.size();
+-                }
+-            }
+-        }
+-    }
+-    else
+-    {
+-        destinationList = sourceList;
+-    }
+-    return destinationList;
+-
+-}
+-
+-
+-void RBGroupManager::addSeperator( std::vector< OCX_Control* >& dest )
+-{
+-    OCX_Control* seperator = new OCX_CommandButton;
+-    seperator->SetInDialog(true);
+-    seperator->sName = C2S("GroupSeperator");
+-    dest.push_back( seperator );
+-}
+-
+-void RBGroupManager::copyList( std::vector< OCX_Control* >& src,
+-    std::vector< OCX_Control* >& dest,
+-    bool addGroupSeperator )
+-{
+-    if ( addGroupSeperator )
+-    {
+-        addSeperator( dest );
+-    }
+-
+-    for ( CtrlIterator rbIter = src.begin(); rbIter != src.end(); ++rbIter )
+-    {
+-        dest.push_back( *rbIter );
+-    }
+-}
+-
+ class OCX_UserFormLabel : public OCX_Label
+ {
+ public:
+@@ -1709,9 +1558,26 @@ sal_Bool OCX_OptionButton::Import(com::s
+     aTmp <<= ::com::sun::star::style::VerticalAlignment_MIDDLE;
+     rPropSet->setPropertyValue( WW8_ASCII2STR("VerticalAlign"), aTmp );
+ 
+-    if ( pGroupName )
+-    {
+-        aTmp <<= lclCreateOUString( pGroupName, nGroupNameLen );
++    // If this is a dialog control then we need to  set a groupname *always*
++    // well actually pGroupName should *only* be set if this is a dialog control, 
++    // but.. you can't be too careful
++    if ( pGroupName && GetInDialog() )
++    {
++        // By default groupnames are not set in Excel, it's not unusual to have
++        // a number of groups of radiobuttons located inside frame ( or other container
++        // controls ) where there is *no* specific groupname set for the radiobuttons.
++        // But... there is implicit grouping for radio buttons in seperate containers
++        // e.g. radio buttons in a frame are by default in the same group.
++        // Unfortunately in openoffice there are no containers below the dialog itself :-(
++        // To ensure correct grouping for imported radiobuttons either with no groupname
++        // or identical groupnames that are in separate containers we *must* ensure
++        // that a suitable groupname is applied. 
++        // Because controlNames are unique even across different containers we can use the
++        // controls container (e.g. parent) name as a prefix for a group name
++        rtl::OUString sGroupName = msParentName;
++        if ( pGroupName )
++            sGroupName = sGroupName.concat( C2U( ":" ) ).concat( lclCreateOUString( pGroupName, nGroupNameLen ) );
++        aTmp <<= sGroupName;
+         rPropSet->setPropertyValue( WW8_ASCII2STR("GroupName"), aTmp);
+     }
+ 
+@@ -2825,7 +2691,66 @@ sal_Bool OCX_ListBox::Import(com::sun::s
  
      aTmp <<= ImportColor( nBorderColor );
      rPropSet->setPropertyValue( WW8_ASCII2STR("BorderColor"), aTmp);
@@ -2106,17 +2384,26 @@
 +         beans::NamedValue aArg1;
 +         aArg1.Name = C2U("CellRange");
 +         aArg1.Value <<= aAddress;
- 
++
 +         uno::Sequence< uno::Any > aArgs(1);
 +         aArgs[ 0 ]  <<= aArg1;
-+
+ 
 +         uno::Reference< form::binding::XListEntrySource > xSource( xFac->createInstanceWithArguments( C2U("com.sun.star.table.CellRangeListSource" ), aArgs ), uno::UNO_QUERY );
 +         xListEntrySink->setListEntrySource( xSource );
 +    }
  	aFontData.Import(rPropSet);
  	return sal_True;
  }
-@@ -3600,13 +3678,26 @@ void OCX_ContainerControl::ProcessContro
+@@ -3416,7 +3341,7 @@ OCX_ContainerControl::OCX_ContainerContr
+             const ::rtl::OUString& sN,
+             const uno::Reference< container::XNameContainer >  &rParent,
+             OCX_Control* pParent ) :
+-                OCX_Control(sN, pParent), rbGroupMgr( sName ), mxParent(rParent), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER )
++                OCX_Control(sN, pParent), mxParent(rParent), nNoRecords(0), nTotalLen(0), containerType( STDCONTAINER )
+ {
+ 
+     mContainerStorage = parent->OpenSotStorage(storageName,
+@@ -3600,16 +3525,30 @@ void OCX_ContainerControl::ProcessContro
      {
          // A container control needs to read the f stream in
          // the folder ( substorage ) associated with this control
@@ -2149,7 +2436,38 @@
          }
  
          pControl->sName = rec.cName;
-@@ -4247,7 +4338,7 @@ sal_Bool OCX_UserForm::Import(
++        pControl->msParentName = sName;
+         pControl->msToolTip = rec.controlTip;
+         // Position of controls is relative to the container
+         pControl->mnTop = rec.nTop + mnTop;
+@@ -3637,17 +3576,7 @@ void OCX_ContainerControl::ProcessContro
+         // set stream to position behind substream of this control
+         oStream->Seek( nStrmPos + rec.nSubStreamLen );
+ 
+-        //need to fake grouping behaviour for radio ( option ) buttons
+-        if ( rec.nTypeIdent == OPTIONBUTTON )
+-        {
+-            OCX_OptionButton* pRButton =
+-                static_cast< OCX_OptionButton*>(pControl);
+-            rbGroupMgr.addRadioButton( pRButton );
+-        }
+-        else
+-        {
+-            mpControls.push_back( pControl );
+-        }
++        mpControls.push_back( pControl );
+     }
+ }
+ 
+@@ -3670,7 +3599,6 @@ sal_Bool OCX_ContainerControl::Read(SvSt
+     // this ensures that the default tab index created by Star/Open office
+     // reflects the "flattened" ms tab order.
+     ::std::sort( mpControls.begin(), mpControls.end(), SortOrderByTabPos() );
+-    mpControls = rbGroupMgr.insertGroupsIntoControlList( mpControls );
+ 	return true;
+ }
+ 
+@@ -4247,7 +4175,7 @@ sal_Bool OCX_UserForm::Import(
      OCX_ContainerControl::Import( xPropSet );
  
      uno::Reference<io::XInputStreamProvider> xSource =
@@ -2426,7 +2744,7 @@
  	xml::sax::InputSource source;
  	source.aInputStream = xInput;
 diff --git xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
-index 4a2c142..b419162 100644
+index 4a2c142..d61cd41 100644
 --- xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
 +++ xmlscript/source/xmldlg_imexp/xmldlg_expmodels.cxx
 @@ -33,7 +33,11 @@
@@ -2508,6 +2826,15 @@
      // string item list
      Sequence< OUString > itemValues;
      if ((readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("StringItemList") ) ) >>= itemValues) &&
+@@ -388,6 +441,8 @@ void ElementDescriptor::readRadioButtonM
+                            OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":image-position") ) );
+     readBoolAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+                   OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":multiline") ) );
++    readStringAttr( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
++                    OUString( RTL_CONSTASCII_USTRINGPARAM(XMLNS_DIALOGS_PREFIX ":group-name") ) );
+ 
+     sal_Int16 nState = 0;
+     if (readProp( OUString( RTL_CONSTASCII_USTRINGPARAM("State") ) ) >>= nState)
 diff --git xmlscript/source/xmldlg_imexp/xmldlg_export.cxx xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
 index 999f899..0d6fb8a 100644
 --- xmlscript/source/xmldlg_imexp/xmldlg_export.cxx
@@ -2532,7 +2859,7 @@
              else if (xServiceInfo->supportsService( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlGroupBoxModel") ) ) )
              {
 diff --git xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
-index ba05479..34d9d46 100644
+index ba05479..3eec45b 100644
 --- xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
 +++ xmlscript/source/xmldlg_imexp/xmldlg_impmodels.cxx
 @@ -34,6 +34,12 @@
@@ -2548,7 +2875,37 @@
  
  
  using namespace ::com::sun::star;
-@@ -1638,9 +1644,24 @@ Reference< xml::input::XElement > MenuLi
+@@ -1341,7 +1347,8 @@ void TitledBoxElement::endElement()
+ 		
+ 		ControlImportContext ctx(
+ 			_pImport, getControlId( xAttributes ),
+-			OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) );
++			//OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.awt.UnoControlRadioButtonModel") ) );
++			OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.RadioButton") ) );
+ 		Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
+ 		
+ 		Reference< xml::input::XElement > xStyle( getStyle( xAttributes ) );
+@@ -1377,6 +1384,9 @@ void TitledBoxElement::endElement()
+         ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+                                    OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+                                    xAttributes );
++        ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
++                                  OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ),
++                                  xAttributes );
+ 		
+ 		sal_Int16 nVal = 0;
+ 		sal_Bool bChecked = sal_False;
+@@ -1505,6 +1515,9 @@ void RadioGroupElement::endElement()
+         ctx.importBooleanProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("MultiLine") ),
+                                    OUString( RTL_CONSTASCII_USTRINGPARAM("multiline") ),
+                                    xAttributes );
++        ctx.importStringProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("GroupName") ),
++                                  OUString( RTL_CONSTASCII_USTRINGPARAM("group-name") ),
++                                  xAttributes );
+ 		sal_Int16 nVal = 0;
+ 		sal_Bool bChecked = sal_False;
+ 		if (getBoolAttr( &bChecked,
+@@ -1638,9 +1651,24 @@ Reference< xml::input::XElement > MenuLi
  void MenuListElement::endElement()
  	throw (xml::sax::SAXException, RuntimeException)
  {
@@ -2574,7 +2931,7 @@
  	Reference< beans::XPropertySet > xControlModel( ctx.getControlModel() );
  	
  	Reference< xml::input::XElement > xStyle( getStyle( _xAttributes ) );
-@@ -1673,13 +1694,66 @@ void MenuListElement::endElement()
+@@ -1673,13 +1701,66 @@ void MenuListElement::endElement()
  	ctx.importAlignProperty( OUString( RTL_CONSTASCII_USTRINGPARAM("Align") ),
                               OUString( RTL_CONSTASCII_USTRINGPARAM("align") ),
                               _xAttributes );



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]