Kaydet (Commit) 7c02faf5 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Properly hide implementation details.

If we are to hide, let's hide all.

Change-Id: Ic68926ee099ac80d2d477d68e3769a7203dfea6c
üst 077c80b9
...@@ -41,14 +41,10 @@ class SvXMLExport; ...@@ -41,14 +41,10 @@ class SvXMLExport;
class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper : public UniRefBase class XMLOFF_DLLPUBLIC SvXMLExportPropertyMapper : public UniRefBase
{ {
UniReference< SvXMLExportPropertyMapper> mxNextMapper; struct Impl;
Impl* mpImpl;
FilterPropertiesInfos_Impl *pCache;
protected: protected:
UniReference< XMLPropertySetMapper > maPropMapper;
OUString maStyleName;
/** Filter all properties we don't want to export: /** Filter all properties we don't want to export:
Take all properties of the XPropertySet which are also found in the Take all properties of the XPropertySet which are also found in the
...@@ -177,10 +173,10 @@ public: ...@@ -177,10 +173,10 @@ public:
const ::std::vector< XMLPropertyState > *pProperties = 0, const ::std::vector< XMLPropertyState > *pProperties = 0,
sal_uInt32 nIdx = 0 ) const; sal_uInt32 nIdx = 0 ) const;
inline const UniReference< XMLPropertySetMapper >& const UniReference<XMLPropertySetMapper>& getPropertySetMapper() const;
getPropertySetMapper() const { return maPropMapper; }
void SetStyleName( const OUString& rStyleName ) { maStyleName = rStyleName; } void SetStyleName( const OUString& rStyleName );
const OUString& GetStyleName() const;
}; };
#endif // _XMLOFF_XMLEXPPR_HXX #endif // _XMLOFF_XMLEXPPR_HXX
......
...@@ -361,14 +361,14 @@ void XMLChartExportPropertyMapper::handleSpecialItem( ...@@ -361,14 +361,14 @@ void XMLChartExportPropertyMapper::handleSpecialItem(
{ {
sal_Bool bHandled = sal_False; sal_Bool bHandled = sal_False;
sal_Int32 nContextId = maPropMapper->GetEntryContextId( rProperty.mnIndex ); sal_Int32 nContextId = getPropertySetMapper()->GetEntryContextId( rProperty.mnIndex );
if( nContextId ) if( nContextId )
{ {
bHandled = sal_True; bHandled = sal_True;
OUString sAttrName = maPropMapper->GetEntryXMLName( rProperty.mnIndex ); OUString sAttrName = getPropertySetMapper()->GetEntryXMLName( rProperty.mnIndex );
sal_uInt16 nNameSpace = maPropMapper->GetEntryNameSpace( rProperty.mnIndex ); sal_uInt16 nNameSpace = getPropertySetMapper()->GetEntryNameSpace( rProperty.mnIndex );
OUStringBuffer sValueBuffer; OUStringBuffer sValueBuffer;
OUString sValue; OUString sValue;
......
...@@ -1545,7 +1545,7 @@ void XMLShapeExportPropertyMapper::handleElementItem( ...@@ -1545,7 +1545,7 @@ void XMLShapeExportPropertyMapper::handleElementItem(
{ {
uno::Reference< container::XIndexReplace > xNumRule( rProperty.maValue, uno::UNO_QUERY ); uno::Reference< container::XIndexReplace > xNumRule( rProperty.maValue, uno::UNO_QUERY );
if( xNumRule.is() ) if( xNumRule.is() )
const_cast<XMLShapeExportPropertyMapper*>(this)->maNumRuleExp.exportNumberingRule( maStyleName, sal_False, xNumRule ); const_cast<XMLShapeExportPropertyMapper*>(this)->maNumRuleExp.exportNumberingRule(GetStyleName(), false, xNumRule);
} }
} }
break; break;
......
...@@ -204,32 +204,23 @@ public: ...@@ -204,32 +204,23 @@ public:
sal_uInt32 GetPropertyCount() const { return nCount; } sal_uInt32 GetPropertyCount() const { return nCount; }
}; };
typedef boost::unordered_map struct SvXMLExportPropertyMapper::Impl
<
PropertySetInfoKey,
FilterPropertiesInfo_Impl *,
PropertySetInfoHash,
PropertySetInfoHash
>
FilterOropertiesHashMap_Impl;
class FilterPropertiesInfos_Impl : public FilterOropertiesHashMap_Impl
{ {
public: typedef boost::unordered_map<PropertySetInfoKey, FilterPropertiesInfo_Impl*, PropertySetInfoHash, PropertySetInfoHash> CacheType;
~FilterPropertiesInfos_Impl (); CacheType maCache;
};
FilterPropertiesInfos_Impl::~FilterPropertiesInfos_Impl () UniReference<SvXMLExportPropertyMapper> mxNextMapper;
{ UniReference<XMLPropertySetMapper> mxPropMapper;
FilterOropertiesHashMap_Impl::iterator aIter = begin();
FilterOropertiesHashMap_Impl::iterator aEnd = end(); OUString maStyleName;
while( aIter != aEnd )
~Impl()
{ {
delete (*aIter).second; CacheType::iterator it = maCache.begin(), itEnd = maCache.end();
(*aIter).second = 0; for (; it != itEnd; ++it)
++aIter; delete it->second;
} }
} };
FilterPropertiesInfo_Impl::FilterPropertiesInfo_Impl() : FilterPropertiesInfo_Impl::FilterPropertiesInfo_Impl() :
nCount(0), nCount(0),
...@@ -544,44 +535,43 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray( ...@@ -544,44 +535,43 @@ void FilterPropertiesInfo_Impl::FillPropertyStateArray(
SvXMLExportPropertyMapper::SvXMLExportPropertyMapper( SvXMLExportPropertyMapper::SvXMLExportPropertyMapper(
const UniReference< XMLPropertySetMapper >& rMapper ) : const UniReference< XMLPropertySetMapper >& rMapper ) :
pCache( 0 ), mpImpl(new Impl)
maPropMapper( rMapper )
{ {
mpImpl->mxPropMapper = rMapper;
} }
SvXMLExportPropertyMapper::~SvXMLExportPropertyMapper() SvXMLExportPropertyMapper::~SvXMLExportPropertyMapper()
{ {
delete pCache; delete mpImpl;
mxNextMapper = 0;
} }
void SvXMLExportPropertyMapper::ChainExportMapper( void SvXMLExportPropertyMapper::ChainExportMapper(
const UniReference< SvXMLExportPropertyMapper>& rMapper ) const UniReference< SvXMLExportPropertyMapper>& rMapper )
{ {
// add map entries from rMapper to current map // add map entries from rMapper to current map
maPropMapper->AddMapperEntry( rMapper->getPropertySetMapper() ); mpImpl->mxPropMapper->AddMapperEntry( rMapper->getPropertySetMapper() );
// rMapper uses the same map as 'this' // rMapper uses the same map as 'this'
rMapper->maPropMapper = maPropMapper; rMapper->mpImpl->mxPropMapper = mpImpl->mxPropMapper;
// set rMapper as last mapper in current chain // set rMapper as last mapper in current chain
UniReference< SvXMLExportPropertyMapper > xNext = mxNextMapper; UniReference< SvXMLExportPropertyMapper > xNext = mpImpl->mxNextMapper;
if( xNext.is()) if( xNext.is())
{ {
while( xNext->mxNextMapper.is()) while (xNext->mpImpl->mxNextMapper.is())
xNext = xNext->mxNextMapper; xNext = xNext->mpImpl->mxNextMapper;
xNext->mxNextMapper = rMapper; xNext->mpImpl->mxNextMapper = rMapper;
} }
else else
mxNextMapper = rMapper; mpImpl->mxNextMapper = rMapper;
// if rMapper was already chained, correct // if rMapper was already chained, correct
// map pointer of successors // map pointer of successors
xNext = rMapper; xNext = rMapper;
while( xNext->mxNextMapper.is()) while (xNext->mpImpl->mxNextMapper.is())
{ {
xNext = xNext->mxNextMapper; xNext = xNext->mpImpl->mxNextMapper;
xNext->maPropMapper = maPropMapper; xNext->mpImpl->mxPropMapper = mpImpl->mxPropMapper;
} }
} }
...@@ -596,7 +586,7 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -596,7 +586,7 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
if( !xInfo.is() ) if( !xInfo.is() )
return aPropStateArray; return aPropStateArray;
sal_Int32 nProps = maPropMapper->GetEntryCount(); sal_Int32 nProps = mpImpl->mxPropMapper->GetEntryCount();
FilterPropertiesInfo_Impl *pFilterInfo = 0; FilterPropertiesInfo_Impl *pFilterInfo = 0;
...@@ -607,16 +597,12 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -607,16 +597,12 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
aImplId = xTypeProv->getImplementationId(); aImplId = xTypeProv->getImplementationId();
if( aImplId.getLength() == 16 ) if( aImplId.getLength() == 16 )
{ {
if( pCache ) // The key must not be created outside this block, because it
{ // keeps a reference to the property set info.
// The key must not be created outside this block, because it PropertySetInfoKey aKey( xInfo, aImplId );
// keeps a reference to the property set info. Impl::CacheType::iterator aIter = mpImpl->maCache.find(aKey);
PropertySetInfoKey aKey( xInfo, aImplId ); if (aIter != mpImpl->maCache.end())
FilterPropertiesInfos_Impl::iterator aIter = pFilterInfo = (*aIter).second;
pCache->find( aKey );
if( aIter != pCache->end() )
pFilterInfo = (*aIter).second;
}
} }
} }
...@@ -628,15 +614,15 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -628,15 +614,15 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
{ {
// Are we allowed to ask for the property? (MID_FLAG_NO_PROP..) // Are we allowed to ask for the property? (MID_FLAG_NO_PROP..)
// Does the PropertySet contain name of mpEntries-array ? // Does the PropertySet contain name of mpEntries-array ?
const OUString& rAPIName = maPropMapper->GetEntryAPIName( i ); const OUString& rAPIName = mpImpl->mxPropMapper->GetEntryAPIName( i );
const sal_Int32 nFlags = maPropMapper->GetEntryFlags( i ); const sal_Int32 nFlags = mpImpl->mxPropMapper->GetEntryFlags( i );
if( (0 == (nFlags & MID_FLAG_NO_PROPERTY_EXPORT)) && if( (0 == (nFlags & MID_FLAG_NO_PROPERTY_EXPORT)) &&
( (0 != (nFlags & MID_FLAG_MUST_EXIST)) || ( (0 != (nFlags & MID_FLAG_MUST_EXIST)) ||
xInfo->hasPropertyByName( rAPIName ) ) ) xInfo->hasPropertyByName( rAPIName ) ) )
{ {
const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() ); const SvtSaveOptions::ODFDefaultVersion nCurrentVersion( SvtSaveOptions().GetODFDefaultVersion() );
const SvtSaveOptions::ODFDefaultVersion nEarliestODFVersionForExport( const SvtSaveOptions::ODFDefaultVersion nEarliestODFVersionForExport(
maPropMapper->GetEarliestODFVersionForExport( i ) ); mpImpl->mxPropMapper->GetEarliestODFVersionForExport(i));
if( nCurrentVersion >= nEarliestODFVersionForExport if( nCurrentVersion >= nEarliestODFVersionForExport
|| nCurrentVersion == SvtSaveOptions::ODFVER_UNKNOWN || nCurrentVersion == SvtSaveOptions::ODFVER_UNKNOWN
|| nEarliestODFVersionForExport == SvtSaveOptions::ODFVER_UNKNOWN ) || nEarliestODFVersionForExport == SvtSaveOptions::ODFVER_UNKNOWN )
...@@ -655,19 +641,16 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -655,19 +641,16 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
xInfo = xWeakInfo; xInfo = xWeakInfo;
if( xInfo.is() ) if( xInfo.is() )
{ {
if( !pCache )
((SvXMLExportPropertyMapper *)this)->pCache =
new FilterPropertiesInfos_Impl;
PropertySetInfoKey aKey( xInfo, aImplId ); PropertySetInfoKey aKey( xInfo, aImplId );
(*pCache)[aKey] = pFilterInfo; mpImpl->maCache.insert(Impl::CacheType::value_type(aKey, pFilterInfo));
} }
else else
bDelInfo = sal_True; bDelInfo = true;
} }
else else
{ {
OSL_FAIL("here is no TypeProvider or the ImplId is wrong"); OSL_FAIL("here is no TypeProvider or the ImplId is wrong");
bDelInfo = sal_True; bDelInfo = true;
} }
} }
...@@ -675,9 +658,8 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter( ...@@ -675,9 +658,8 @@ vector< XMLPropertyState > SvXMLExportPropertyMapper::_Filter(
{ {
try try
{ {
pFilterInfo->FillPropertyStateArray(aPropStateArray, pFilterInfo->FillPropertyStateArray(
xPropSet, maPropMapper, aPropStateArray, xPropSet, mpImpl->mxPropMapper, bDefault);
bDefault);
} }
catch( UnknownPropertyException& ) catch( UnknownPropertyException& )
{ {
...@@ -703,8 +685,8 @@ void SvXMLExportPropertyMapper::ContextFilter( ...@@ -703,8 +685,8 @@ void SvXMLExportPropertyMapper::ContextFilter(
Reference< XPropertySet > rPropSet ) const Reference< XPropertySet > rPropSet ) const
{ {
// Derived class could implement this. // Derived class could implement this.
if( mxNextMapper.is() ) if (mpImpl->mxNextMapper.is())
mxNextMapper->ContextFilter( rProperties, rPropSet ); mpImpl->mxNextMapper->ContextFilter(rProperties, rPropSet);
} }
// Compares two Sequences of XMLPropertyState: // Compares two Sequences of XMLPropertyState:
...@@ -732,13 +714,13 @@ sal_Bool SvXMLExportPropertyMapper::Equals( ...@@ -732,13 +714,13 @@ sal_Bool SvXMLExportPropertyMapper::Equals(
if( rProp1.mnIndex != -1 ) if( rProp1.mnIndex != -1 )
{ {
// Now compare values // Now compare values
if( ( maPropMapper->GetEntryType( rProp1.mnIndex ) & if ( (mpImpl->mxPropMapper->GetEntryType( rProp1.mnIndex ) &
XML_TYPE_BUILDIN_CMP ) != 0 ) XML_TYPE_BUILDIN_CMP ) != 0 )
// simple type ( binary compare ) // simple type ( binary compare )
bRet = ( rProp1.maValue == rProp2.maValue ); bRet = ( rProp1.maValue == rProp2.maValue );
else else
// complex type ( ask for compare-function ) // complex type ( ask for compare-function )
bRet = maPropMapper->GetPropertyHandler( bRet = mpImpl->mxPropMapper->GetPropertyHandler(
rProp1.mnIndex )->equals( rProp1.maValue, rProp1.mnIndex )->equals( rProp1.maValue,
rProp2.maValue ); rProp2.maValue );
} }
...@@ -832,10 +814,10 @@ void SvXMLExportPropertyMapper::handleSpecialItem( ...@@ -832,10 +814,10 @@ void SvXMLExportPropertyMapper::handleSpecialItem(
const ::std::vector< XMLPropertyState > *pProperties, const ::std::vector< XMLPropertyState > *pProperties,
sal_uInt32 nIdx ) const sal_uInt32 nIdx ) const
{ {
OSL_ENSURE( mxNextMapper.is(), "special item not handled in xml export" ); OSL_ENSURE(mpImpl->mxNextMapper.is(), "special item not handled in xml export");
if( mxNextMapper.is() ) if (mpImpl->mxNextMapper.is())
mxNextMapper->handleSpecialItem( rAttrList, rProperty, rUnitConverter, mpImpl->mxNextMapper->handleSpecialItem(
rNamespaceMap, pProperties, nIdx ); rAttrList, rProperty, rUnitConverter, rNamespaceMap, pProperties, nIdx);
} }
/** this method is called for every item that has the /** this method is called for every item that has the
...@@ -847,10 +829,9 @@ void SvXMLExportPropertyMapper::handleElementItem( ...@@ -847,10 +829,9 @@ void SvXMLExportPropertyMapper::handleElementItem(
const ::std::vector< XMLPropertyState > *pProperties, const ::std::vector< XMLPropertyState > *pProperties,
sal_uInt32 nIdx ) const sal_uInt32 nIdx ) const
{ {
OSL_ENSURE( mxNextMapper.is(), "element item not handled in xml export" ); OSL_ENSURE(mpImpl->mxNextMapper.is(), "element item not handled in xml export");
if( mxNextMapper.is() ) if (mpImpl->mxNextMapper.is())
mxNextMapper->handleElementItem( rExport, rProperty, nFlags, mpImpl->mxNextMapper->handleElementItem(rExport, rProperty, nFlags, pProperties, nIdx);
pProperties, nIdx );
} }
// protected methods // protected methods
...@@ -872,7 +853,7 @@ void SvXMLExportPropertyMapper::_exportXML( ...@@ -872,7 +853,7 @@ void SvXMLExportPropertyMapper::_exportXML(
if( -1 == nPropMapStartIdx ) if( -1 == nPropMapStartIdx )
nPropMapStartIdx = 0; nPropMapStartIdx = 0;
if( -1 == nPropMapEndIdx ) if( -1 == nPropMapEndIdx )
nPropMapEndIdx = maPropMapper->GetEntryCount(); nPropMapEndIdx = mpImpl->mxPropMapper->GetEntryCount();
while( nIndex < nCount ) while( nIndex < nCount )
{ {
...@@ -880,7 +861,7 @@ void SvXMLExportPropertyMapper::_exportXML( ...@@ -880,7 +861,7 @@ void SvXMLExportPropertyMapper::_exportXML(
if( nPropMapIdx >= nPropMapStartIdx && if( nPropMapIdx >= nPropMapStartIdx &&
nPropMapIdx < nPropMapEndIdx )// valid entry? nPropMapIdx < nPropMapEndIdx )// valid entry?
{ {
sal_uInt32 nEFlags = maPropMapper->GetEntryFlags( nPropMapIdx ); sal_uInt32 nEFlags = mpImpl->mxPropMapper->GetEntryFlags(nPropMapIdx);
sal_uInt16 nEPType = GET_PROP_TYPE(nEFlags); sal_uInt16 nEPType = GET_PROP_TYPE(nEFlags);
OSL_ENSURE( nEPType >= (XML_TYPE_PROP_START>>XML_TYPE_PROP_SHIFT), OSL_ENSURE( nEPType >= (XML_TYPE_PROP_START>>XML_TYPE_PROP_SHIFT),
"no prop type sepcified" ); "no prop type sepcified" );
...@@ -918,8 +899,7 @@ void SvXMLExportPropertyMapper::_exportXML( ...@@ -918,8 +899,7 @@ void SvXMLExportPropertyMapper::_exportXML(
const ::std::vector< XMLPropertyState > *pProperties, const ::std::vector< XMLPropertyState > *pProperties,
sal_uInt32 nIdx ) const sal_uInt32 nIdx ) const
{ {
if ( ( maPropMapper->GetEntryFlags( rProperty.mnIndex ) & if ((mpImpl->mxPropMapper->GetEntryFlags(rProperty.mnIndex) & MID_FLAG_SPECIAL_ITEM_EXPORT) != 0)
MID_FLAG_SPECIAL_ITEM_EXPORT ) != 0 )
{ {
uno::Reference< container::XNameContainer > xAttrContainer; uno::Reference< container::XNameContainer > xAttrContainer;
if( (rProperty.maValue >>= xAttrContainer) && xAttrContainer.is() ) if( (rProperty.maValue >>= xAttrContainer) && xAttrContainer.is() )
...@@ -1028,23 +1008,21 @@ void SvXMLExportPropertyMapper::_exportXML( ...@@ -1028,23 +1008,21 @@ void SvXMLExportPropertyMapper::_exportXML(
rNamespaceMap, pProperties, nIdx ); rNamespaceMap, pProperties, nIdx );
} }
} }
else if ( ( maPropMapper->GetEntryFlags( rProperty.mnIndex ) & else if ((mpImpl->mxPropMapper->GetEntryFlags(rProperty.mnIndex) & MID_FLAG_ELEMENT_ITEM_EXPORT ) == 0)
MID_FLAG_ELEMENT_ITEM_EXPORT ) == 0 )
{ {
OUString aValue; OUString aValue;
const OUString sName( rNamespaceMap.GetQNameByKey( const OUString sName = rNamespaceMap.GetQNameByKey(
maPropMapper->GetEntryNameSpace( rProperty.mnIndex ), mpImpl->mxPropMapper->GetEntryNameSpace(rProperty.mnIndex),
maPropMapper->GetEntryXMLName( rProperty.mnIndex ) ) ); mpImpl->mxPropMapper->GetEntryXMLName(rProperty.mnIndex));
sal_Bool bRemove = sal_False; sal_Bool bRemove = sal_False;
if( ( maPropMapper->GetEntryFlags( rProperty.mnIndex ) & if ((mpImpl->mxPropMapper->GetEntryFlags( rProperty.mnIndex ) & MID_FLAG_MERGE_ATTRIBUTE) != 0)
MID_FLAG_MERGE_ATTRIBUTE ) != 0 )
{ {
aValue = rAttrList.getValueByName( sName ); aValue = rAttrList.getValueByName( sName );
bRemove = sal_True; bRemove = sal_True;
} }
if( maPropMapper->exportXML( aValue, rProperty, rUnitConverter ) ) if (mpImpl->mxPropMapper->exportXML(aValue, rProperty, rUnitConverter))
{ {
if( bRemove ) if( bRemove )
rAttrList.RemoveAttribute( sName ); rAttrList.RemoveAttribute( sName );
...@@ -1066,7 +1044,7 @@ void SvXMLExportPropertyMapper::exportElementItems( ...@@ -1066,7 +1044,7 @@ void SvXMLExportPropertyMapper::exportElementItems(
{ {
const sal_uInt16 nElement = rIndexArray[nIndex]; const sal_uInt16 nElement = rIndexArray[nIndex];
OSL_ENSURE( 0 != ( maPropMapper->GetEntryFlags( OSL_ENSURE( 0 != (mpImpl->mxPropMapper->GetEntryFlags(
rProperties[nElement].mnIndex ) & MID_FLAG_ELEMENT_ITEM_EXPORT), rProperties[nElement].mnIndex ) & MID_FLAG_ELEMENT_ITEM_EXPORT),
"wrong mid flag!" ); "wrong mid flag!" );
...@@ -1080,4 +1058,19 @@ void SvXMLExportPropertyMapper::exportElementItems( ...@@ -1080,4 +1058,19 @@ void SvXMLExportPropertyMapper::exportElementItems(
rExport.IgnorableWhitespace(); rExport.IgnorableWhitespace();
} }
const UniReference<XMLPropertySetMapper>& SvXMLExportPropertyMapper::getPropertySetMapper() const
{
return mpImpl->mxPropMapper;
}
void SvXMLExportPropertyMapper::SetStyleName( const OUString& rStyleName )
{
mpImpl->maStyleName = rStyleName;
}
const OUString& SvXMLExportPropertyMapper::GetStyleName() const
{
return mpImpl->maStyleName;
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment