Fixed for i#103021
[ooovba.git] / applied_patches / 0111-xl-import-formradiobutton.diff
blob0ce913222fb13f57602dd259261a24bd19993dc5
1 diff --git sc/source/filter/excel/xiescher.cxx sc/source/filter/excel/xiescher.cxx
2 index b19de94..1df3f38 100644
3 --- sc/source/filter/excel/xiescher.cxx
4 +++ sc/source/filter/excel/xiescher.cxx
5 @@ -1709,22 +1709,15 @@ SdrObject* XclImpControlHelper::CreateSdrObjectFromShape(
6 return xSdrObj.release();
9 -void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const
10 +void XclImpControlHelper::ApplySheetLinkProps() const
13 Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
14 if( !xCtrlModel.is() )
15 return;
17 ScfPropertySet aPropSet( xCtrlModel );
19 - // #118053# #i51348# set object name at control model
20 - aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() );
22 - // control visible and printable?
23 - aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() );
24 - aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() );
26 - // sheet links
27 + // sheet links
28 if( SfxObjectShell* pDocShell = mrRoot.GetDocShell() )
30 Reference< XMultiServiceFactory > xFactory( pDocShell->GetModel(), UNO_QUERY );
31 @@ -1787,7 +1780,26 @@ void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) co
37 +void XclImpControlHelper::ProcessControl( const XclImpDrawObjBase& rDrawObj ) const
39 + Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( mxShape );
40 + if( !xCtrlModel.is() )
41 + return;
43 + ApplySheetLinkProps();
45 + ScfPropertySet aPropSet( xCtrlModel );
47 + // #118053# #i51348# set object name at control model
48 + aPropSet.SetStringProperty( CREATE_OUSTRING( "Name" ), rDrawObj.GetObjName() );
50 + // control visible and printable?
51 + aPropSet.SetBoolProperty( CREATE_OUSTRING( "EnableVisible" ), rDrawObj.IsVisible() );
52 + aPropSet.SetBoolProperty( CREATE_OUSTRING( "Printable" ), rDrawObj.IsPrintable() );
55 // virtual call for type specific processing
56 DoProcessControl( aPropSet );
58 @@ -2118,6 +2130,45 @@ void XclImpOptionButtonObj::DoProcessControl( ScfPropertySet& rPropSet ) const
60 XclImpCheckBoxObj::DoProcessControl( rPropSet );
61 // TODO: grouping
62 + XclImpOptionButtonObj* pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().FindDrawObj( XclObjId( GetScTab(), mnNextInGroup ) ).get() );
63 + if ( ( pTbxObj && pTbxObj->mnFirstInGroup ) )
64 + {
65 + // Group has terminated
66 + // traverse each RadioButton in group and
67 + // a) apply the groupname
68 + // b) propagate the linked cell from the lead radiobutton
69 + // c) apply the correct Ref value
70 + XclImpOptionButtonObj* pLeader = pTbxObj;
71 + ;
72 + sal_Int32 nRefVal = 1;
73 + OSL_TRACE( "0x%x start group ", pLeader->GetObjId().mnObjId );
74 + do
75 + {
77 + Reference< XControlModel > xCtrlModel = XclControlHelper::GetControlModel( pTbxObj->mxShape );
78 + if ( xCtrlModel.is() )
79 + {
80 + ScfPropertySet aProps( xCtrlModel );
81 + rtl::OUString sGroupName = rtl::OUString::valueOf( static_cast< sal_Int32 >( pLeader->GetDffShapeId() ) );
83 + aProps.SetStringProperty( CREATE_OUSTRING( "GroupName" ), sGroupName );
84 + aProps.SetStringProperty( CREATE_OUSTRING( "RefValue" ), rtl::OUString::valueOf( nRefVal++ ) );
85 + if ( pLeader->HasCellLink() && !pTbxObj->HasCellLink() )
86 + {
87 + // propagate cell link info
88 + pTbxObj->mxCellLink.reset( new ScAddress( *pLeader->mxCellLink.get() ) );
89 + pTbxObj->ApplySheetLinkProps();
90 + }
91 + pTbxObj = dynamic_cast< XclImpOptionButtonObj* >( GetObjectManager().FindDrawObj( XclObjId( GetScTab(), pTbxObj->mnNextInGroup ) ).get() );
92 + }
93 + else
94 + pTbxObj = NULL;
95 + } while ( pTbxObj && !( pTbxObj->mnFirstInGroup == 1 ) );
96 + }
97 + else
98 + {
99 + // not the leader? try and find it
103 OUString XclImpOptionButtonObj::DoGetServiceName() const
104 diff --git sc/source/filter/inc/xiescher.hxx sc/source/filter/inc/xiescher.hxx
105 index 2296996..3e59515 100644
106 --- sc/source/filter/inc/xiescher.hxx
107 +++ sc/source/filter/inc/xiescher.hxx
108 @@ -498,6 +498,10 @@ protected:
109 /** Derived classes will set additional properties for the current form control. */
110 virtual void DoProcessControl( ScfPropertySet& rPropSet ) const;
112 + void ApplySheetLinkProps() const;
113 + mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
114 + mxShape; /// The UNO wrapper of the control shape.
115 + ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document.
116 private:
117 /** Reads a list of cell ranges from a formula at the current stream position. */
118 void ReadRangeList( ScRangeList& rScRanges, XclImpStream& rStrm );
119 @@ -506,9 +510,6 @@ private:
121 private:
122 const XclImpRoot& mrRoot; /// Not derived from XclImpRoot to allow multiple inheritance.
123 - mutable ::com::sun::star::uno::Reference< ::com::sun::star::drawing::XShape >
124 - mxShape; /// The UNO wrapper of the control shape.
125 - ScfRef< ScAddress > mxCellLink; /// Linked cell in the Calc document.
126 ScfRef< ScRange > mxSrcRange; /// Source data range in the Calc document.
127 XclCtrlBindMode meBindMode; /// Value binding mode.
129 @@ -610,6 +611,7 @@ protected:
130 virtual XclTbxEventType DoGetEventType() const;
132 protected:
133 + void ApplyGrouping( XclImpOptionButtonObj& rLeader, sal_Int32 nRefVal );
134 sal_uInt16 mnNextInGroup; /// Next option button in a group.
135 sal_uInt16 mnFirstInGroup; /// 1 = Button is the first in a group.