diff options
Diffstat (limited to 'oox')
-rw-r--r-- | oox/source/ole/axcontrol.cxx | 9 | ||||
-rw-r--r-- | oox/source/vml/vmldrawing.cxx | 55 |
2 files changed, 57 insertions, 7 deletions
diff --git a/oox/source/ole/axcontrol.cxx b/oox/source/ole/axcontrol.cxx index bb6fdbc6b1c7..cfe7121ff1f0 100644 --- a/oox/source/ole/axcontrol.cxx +++ b/oox/source/ole/axcontrol.cxx @@ -1555,13 +1555,8 @@ void AxMorphDataModelBase::convertProperties( PropertyMap& rPropMap, const Contr rConv.convertColor( rPropMap, PROP_TextColor, mnTextColor ); if ( mnDisplayStyle == AX_DISPLAYSTYLE_OPTBUTTON ) { - // Form Radio Controls (non-ActiveX) have no group name, but autoGroup - // with their group box, or frame, or sheet, or document. - // So ensure that SOME name is given for a group name - // TODO: ActiveX controls without a Group name shouldn't autogroup - // with non-ActiveX option buttons. - // TODO: each application should test if control's area is fully inside - // a GroupBox, and give those a separate group name. + // If unspecified, radio buttons autoGroup in the same document/sheet + // NOTE: form controls should not autoGroup with ActiveX controls - see drawingfragment.cxx OUString sGroupName = !maGroupName.isEmpty() ? maGroupName : "autoGroup_"; rPropMap.setProperty( PROP_GroupName, sGroupName ); } diff --git a/oox/source/vml/vmldrawing.cxx b/oox/source/vml/vmldrawing.cxx index 57c099c0745d..944047c25b55 100644 --- a/oox/source/vml/vmldrawing.cxx +++ b/oox/source/vml/vmldrawing.cxx @@ -34,6 +34,8 @@ #include <oox/ole/axcontrol.hxx> #include <oox/vml/vmlshape.hxx> #include <oox/vml/vmlshapecontainer.hxx> +#include <tools/diagnose_ex.h> +#include <tools/gen.hxx> namespace oox { namespace vml { @@ -145,6 +147,59 @@ void Drawing::convertAndInsert() const { Reference< XShapes > xShapes( mxDrawPage, UNO_QUERY ); mxShapes->convertAndInsert( xShapes ); + + // Group together form control radio buttons that are in the same groupBox + std::map<OUString, tools::Rectangle> GroupBoxMap; + std::map<Reference< XPropertySet >, tools::Rectangle> RadioButtonMap; + for ( sal_Int32 i = 0; i < xShapes->getCount(); ++i ) + { + try + { + Reference< XControlShape > xCtrlShape( xShapes->getByIndex(i), UNO_QUERY_THROW ); + Reference< XControlModel > xCtrlModel( xCtrlShape->getControl(), UNO_SET_THROW ); + Reference< XServiceInfo > xModelSI (xCtrlModel, UNO_QUERY_THROW ); + Reference< XPropertySet > aProps( xCtrlModel, UNO_QUERY_THROW ); + + OUString sName; + aProps->getPropertyValue("Name") >>= sName; + const ::Point aPoint( xCtrlShape->getPosition().X, xCtrlShape->getPosition().Y ); + const ::Size aSize( xCtrlShape->getSize().Width, xCtrlShape->getSize().Height ); + const tools::Rectangle aRect( aPoint, aSize ); + if ( !sName.isEmpty() + && xModelSI->supportsService("com.sun.star.awt.UnoControlGroupBoxModel") ) + { + GroupBoxMap[sName] = aRect; + } + else if ( xModelSI->supportsService("com.sun.star.awt.UnoControlRadioButtonModel") ) + { + OUString sGroupName; + aProps->getPropertyValue("GroupName") >>= sGroupName; + // only Form Controls are affected by Group Boxes - see drawingfragment.cxx + if ( sGroupName == "autoGroup_formControl" ) + RadioButtonMap[aProps] = aRect; + } + } + catch (uno::Exception&) + { + DBG_UNHANDLED_EXCEPTION(); + } + } + for ( auto& BoxItr : GroupBoxMap ) + { + const uno::Any aGroup( OUString("autoGroup_").concat(BoxItr.first) ); + for ( auto RadioItr = RadioButtonMap.begin(); RadioItr != RadioButtonMap.end(); ) + { + if ( BoxItr.second.IsInside(RadioItr->second) ) + { + RadioItr->first->setPropertyValue("GroupName", aGroup ); + // If conflict, first created GroupBox wins + RadioButtonMap.erase( RadioItr++ ); + } + else + RadioItr++; + } + } + } sal_Int32 Drawing::getLocalShapeIndex( const OUString& rShapeId ) const |