[Libreoffice-commits] core.git: Branch 'feature/autostyle' - 2 commits - xmloff/inc xmloff/source
Michael Meeks
michael.meeks at suse.com
Fri Mar 15 10:37:30 PDT 2013
xmloff/inc/xmloff/xmlaustp.hxx | 12 ++
xmloff/source/chart/SchXMLExport.cxx | 151 +++++++++++----------------------
xmloff/source/draw/sdxmlexp.cxx | 3
xmloff/source/forms/layerexport.cxx | 14 ---
xmloff/source/style/XMLPageExport.cxx | 16 ---
xmloff/source/style/impastp4.cxx | 27 +++++
xmloff/source/table/XMLTableExport.cxx | 56 ++++--------
7 files changed, 116 insertions(+), 163 deletions(-)
New commits:
commit a7af1d075fe3e5b46345c5191998b0103298057f
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Mar 15 17:36:17 2013 +0000
cleanup automatic style creation helper to further shrink code.
Change-Id: I30804115e397ef02977f1d5629df3924dcc5b962
diff --git a/xmloff/inc/xmloff/xmlaustp.hxx b/xmloff/inc/xmloff/xmlaustp.hxx
index dfdcc23..dbd61ec 100644
--- a/xmloff/inc/xmloff/xmlaustp.hxx
+++ b/xmloff/inc/xmloff/xmlaustp.hxx
@@ -56,8 +56,16 @@ class XMLOFF_DLLPUBLIC SvXMLAutoFilteredSet
/// return the relevant family's property mapper
const UniReference < SvXMLExportPropertyMapper > & getMapper();
/// filter properties
- SvXMLAutoFilteredSet &filter( const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > &xPropSet );
+ void filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > &xPropSet );
+ /// filter properties - query for XPropertySet with no throw on failure
+ void filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > &xInterface,
+ ::com::sun::star::uno::UnoReference_Query );
+ /// filter properties - query for XPropertySet with exception on failure
+ void filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > &xInterface,
+ ::com::sun::star::uno::UnoReference_QueryThrow );
/// discard all content
void clear();
/// do we have any valid properties ie. some were not filtered ?
diff --git a/xmloff/source/chart/SchXMLExport.cxx b/xmloff/source/chart/SchXMLExport.cxx
index 3bc3937..d24c97d 100644
--- a/xmloff/source/chart/SchXMLExport.cxx
+++ b/xmloff/source/chart/SchXMLExport.cxx
@@ -1241,11 +1241,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
SvXMLElementExport* pElChart = 0;
// get property states for autostyles
- {
- Reference< beans::XPropertySet > xPropSet( rChartDoc->getArea(), uno::UNO_QUERY );
- if( xPropSet.is())
- aPropertyStates.filter( xPropSet );
- }
+ aPropertyStates.filter( rChartDoc->getArea(), uno::UNO_QUERY );
if( bExportContent )
{
@@ -1325,11 +1321,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
if( bHasMainTitle )
{
// get property states for autostyles
- {
- Reference< beans::XPropertySet > xPropSet( rChartDoc->getTitle(), uno::UNO_QUERY );
- if( xPropSet.is())
- aPropertyStates.filter( xPropSet );
- }
+ aPropertyStates.filter( rChartDoc->getTitle(), uno::UNO_QUERY );
if( bExportContent )
{
@@ -1368,11 +1360,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
if( bHasSubTitle )
{
// get property states for autostyles
- {
- Reference< beans::XPropertySet > xPropSet( rChartDoc->getSubTitle(), uno::UNO_QUERY );
- if( xPropSet.is())
- aPropertyStates.filter( xPropSet );
- }
+ aPropertyStates.filter( rChartDoc->getSubTitle(), uno::UNO_QUERY );
if( bExportContent )
{
@@ -1410,9 +1398,7 @@ void SchXMLExportHelper_Impl::parseDocument( Reference< chart::XChartDocument >&
if( bHasLegend )
{
// get property states for autostyles
- Reference< beans::XPropertySet > xPropSet( rChartDoc->getLegend(), uno::UNO_QUERY );
- if( xPropSet.is())
- aPropertyStates.filter( xPropSet );
+ aPropertyStates.filter( rChartDoc->getLegend(), uno::UNO_QUERY );
if( bExportContent )
{
@@ -2061,66 +2047,49 @@ void SchXMLExportHelper_Impl::exportPlotArea(
if( xStockPropProvider.is())
{
// stock-gain-marker
- Reference< beans::XPropertySet > xStockPropSet = xStockPropProvider->getUpBar();
- if( xStockPropSet.is())
+ aPropertyStates.filter( xStockPropProvider->getUpBar() );
+ if( !aPropertyStates.empty() )
{
- aPropertyStates.clear();
- aPropertyStates.filter( xStockPropSet );
-
- if( !aPropertyStates.empty() )
+ if( bExportContent )
{
- if( bExportContent )
- {
- AddAutoStyleAttribute( aPropertyStates );
-
- SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, sal_True, sal_True );
- }
- else
- {
- CollectAutoStyle( aPropertyStates );
- }
+ AddAutoStyleAttribute( aPropertyStates );
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_GAIN_MARKER, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
// stock-loss-marker
- xStockPropSet = xStockPropProvider->getDownBar();
- if( xStockPropSet.is())
+ aPropertyStates.filter( xStockPropProvider->getDownBar() );
+ if( !aPropertyStates.empty() )
{
- aPropertyStates.filter( xStockPropSet );
-
- if( !aPropertyStates.empty() )
+ if( bExportContent )
{
- if( bExportContent )
- {
- AddAutoStyleAttribute( aPropertyStates );
+ AddAutoStyleAttribute( aPropertyStates );
- SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, sal_True, sal_True );
- }
- else
- {
- CollectAutoStyle( aPropertyStates );
- }
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_LOSS_MARKER, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
// stock-range-line
- xStockPropSet = xStockPropProvider->getMinMaxLine();
- if( xStockPropSet.is())
+ aPropertyStates.filter( xStockPropProvider->getMinMaxLine() );
+ if( !aPropertyStates.empty() )
{
- aPropertyStates.filter( xStockPropSet );
-
- if( !aPropertyStates.empty() )
+ if( bExportContent )
{
- if( bExportContent )
- {
- AddAutoStyleAttribute( aPropertyStates );
+ AddAutoStyleAttribute( aPropertyStates );
- SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, sal_True, sal_True );
- }
- else
- {
- CollectAutoStyle( aPropertyStates );
- }
+ SvXMLElementExport aGain( mrExport, XML_NAMESPACE_CHART, XML_STOCK_RANGE_LINE, sal_True, sal_True );
+ }
+ else
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
}
@@ -2133,54 +2102,40 @@ void SchXMLExportHelper_Impl::exportPlotArea(
if( mxExpPropMapper.is() &&
xWallFloorSupplier.is())
{
- // remove property states for autostyles
- aPropertyStates.clear();
-
- Reference< beans::XPropertySet > xWallPropSet( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
- if( xWallPropSet.is())
+ aPropertyStates.filter( xWallFloorSupplier->getWall(), uno::UNO_QUERY );
+ if( !aPropertyStates.empty() )
{
- aPropertyStates.filter( xWallPropSet );
- if( !aPropertyStates.empty() )
+ // write element
+ if( bExportContent )
{
- // write element
- if( bExportContent )
- {
- // add style name attribute
- AddAutoStyleAttribute( aPropertyStates );
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
- SvXMLElementExport aWall( mrExport, XML_NAMESPACE_CHART, XML_WALL, sal_True, sal_True );
- }
- else // autostyles
- {
- CollectAutoStyle( aPropertyStates );
- }
+ SvXMLElementExport aWall( mrExport, XML_NAMESPACE_CHART, XML_WALL, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
// floor element
// -------------
- // remove property states for autostyles
- aPropertyStates.clear();
-
- Reference< beans::XPropertySet > xFloorPropSet( xWallFloorSupplier->getFloor(), uno::UNO_QUERY );
- if( xFloorPropSet.is())
+ aPropertyStates.filter( xWallFloorSupplier->getFloor(), uno::UNO_QUERY );
+ if( !aPropertyStates.empty() )
{
- aPropertyStates.filter( xFloorPropSet );
- if( !aPropertyStates.empty() )
+ // write element
+ if( bExportContent )
{
- // write element
- if( bExportContent )
- {
- // add style name attribute
- AddAutoStyleAttribute( aPropertyStates );
+ // add style name attribute
+ AddAutoStyleAttribute( aPropertyStates );
- SvXMLElementExport aFloor( mrExport, XML_NAMESPACE_CHART, XML_FLOOR, sal_True, sal_True );
- }
- else // autostyles
- {
- CollectAutoStyle( aPropertyStates );
- }
+ SvXMLElementExport aFloor( mrExport, XML_NAMESPACE_CHART, XML_FLOOR, sal_True, sal_True );
+ }
+ else // autostyles
+ {
+ CollectAutoStyle( aPropertyStates );
}
}
}
diff --git a/xmloff/source/draw/sdxmlexp.cxx b/xmloff/source/draw/sdxmlexp.cxx
index 8c714ee..5365c87 100644
--- a/xmloff/source/draw/sdxmlexp.cxx
+++ b/xmloff/source/draw/sdxmlexp.cxx
@@ -1692,7 +1692,8 @@ OUString SdXMLExport::ImpCreatePresPageStyleName( Reference<XDrawPage> xDrawPage
SvXMLAutoFilteredSet aFilterSet( GetAutoStylePool(),
XML_STYLE_FAMILY_SD_DRAWINGPAGE_ID );
- sStyleName = aFilterSet.filter( xPropSet ).add( "" );
+ aFilterSet.filter( xPropSet );
+ sStyleName = aFilterSet.add( "" );
}
return sStyleName;
diff --git a/xmloff/source/style/impastp4.cxx b/xmloff/source/style/impastp4.cxx
index 581fb17..2457cc8 100644
--- a/xmloff/source/style/impastp4.cxx
+++ b/xmloff/source/style/impastp4.cxx
@@ -495,11 +495,32 @@ SvXMLAutoFilteredSet::~SvXMLAutoFilteredSet()
{
}
-SvXMLAutoFilteredSet &SvXMLAutoFilteredSet::filter( const ::com::sun::star::uno::Reference<
- ::com::sun::star::beans::XPropertySet > &xPropSet )
+void SvXMLAutoFilteredSet::filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::beans::XPropertySet > &xPropSet )
{
maProperties = mpFamily->mxMapper->Filter( xPropSet );
- return *this;
+}
+
+void SvXMLAutoFilteredSet::filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > &xInterface,
+ ::com::sun::star::uno::UnoReference_Query )
+{
+ uno::Reference< beans::XPropertySet > xPropSet( xInterface, uno::UNO_QUERY );
+ if( xPropSet.is() )
+ maProperties = mpFamily->mxMapper->Filter( xPropSet );
+ else
+ maProperties.clear();
+}
+
+void SvXMLAutoFilteredSet::filter( const ::com::sun::star::uno::Reference<
+ ::com::sun::star::uno::XInterface > &xInterface,
+ ::com::sun::star::uno::UnoReference_QueryThrow )
+{
+ uno::Reference< beans::XPropertySet > xPropSet( xInterface, uno::UNO_QUERY_THROW );
+ if( xPropSet.is() )
+ maProperties = mpFamily->mxMapper->Filter( xPropSet );
+ else
+ maProperties.clear();
}
bool SvXMLAutoFilteredSet::hasValidContent()
commit 4b75e6ffbfc3ba2e836ebe7ce021e916fcdd11cf
Author: Michael Meeks <michael.meeks at suse.com>
Date: Fri Mar 15 17:16:43 2013 +0000
use new automatic style creation helper for rest of xmloff.
Change-Id: Id177e51dd09ff1812cfd13afc47031af2ecd23c9
diff --git a/xmloff/source/forms/layerexport.cxx b/xmloff/source/forms/layerexport.cxx
index 13e0ed3..da2745b 100644
--- a/xmloff/source/forms/layerexport.cxx
+++ b/xmloff/source/forms/layerexport.cxx
@@ -626,7 +626,8 @@ namespace xmloff
// determine a number style, if needed
xColumnPropertiesMeta = xColumnProperties->getPropertySetInfo();
// get the styles of the column
- ::std::vector< XMLPropertyState > aPropertyStates = m_xStyleExportMapper->Filter( xColumnProperties );
+ SvXMLAutoFilteredSet aPropertyStates( m_rContext.GetAutoStylePool(), XML_STYLE_FAMILY_CONTROL_ID );
+ aPropertyStates.filter( xColumnProperties );
// care for the number format, additionally
::rtl::OUString sColumnNumberStyle;
@@ -643,20 +644,11 @@ namespace xmloff
aPropertyStates.push_back( aNumberStyleState );
}
-#if OSL_DEBUG_LEVEL > 0
- ::std::vector< XMLPropertyState >::const_iterator aHaveALook = aPropertyStates.begin();
- for ( ; aHaveALook != aPropertyStates.end(); ++aHaveALook )
- {
- (void)aHaveALook;
- }
-#endif
-
// ----------------------------------
// determine the column style
-
if ( !aPropertyStates.empty() )
{ // add to the style pool
- ::rtl::OUString sColumnStyleName = m_rContext.GetAutoStylePool()->Add( XML_STYLE_FAMILY_CONTROL_ID, aPropertyStates );
+ ::rtl::OUString sColumnStyleName = aPropertyStates.add( "" );
OSL_ENSURE( m_aGridColumnStyles.end() == m_aGridColumnStyles.find( xColumnProperties ),
"OFormLayerXMLExport_Impl::collectGridColumnStylesAndIds: already have a style for this column!" );
diff --git a/xmloff/source/style/XMLPageExport.cxx b/xmloff/source/style/XMLPageExport.cxx
index 371bf42..797bb3f 100644
--- a/xmloff/source/style/XMLPageExport.cxx
+++ b/xmloff/source/style/XMLPageExport.cxx
@@ -64,18 +64,10 @@ void XMLPageExport::collectPageMasterAutoStyle(
const Reference < XPropertySet > & rPropSet,
OUString& rPageMasterName )
{
- DBG_ASSERT( xPageMasterPropSetMapper.is(), "page master family/XMLPageMasterPropSetMapper not found" );
- if( xPageMasterPropSetMapper.is() )
- {
- ::std::vector<XMLPropertyState> xPropStates = xPageMasterExportPropMapper->Filter( rPropSet );
- if( !xPropStates.empty())
- {
- OUString sParent;
- rPageMasterName = rExport.GetAutoStylePool()->Find( XML_STYLE_FAMILY_PAGE_MASTER, sParent, xPropStates );
- if (rPageMasterName.isEmpty())
- rPageMasterName = rExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_PAGE_MASTER, sParent, xPropStates);
- }
- }
+ SvXMLAutoFilteredSet xPropStates( rExport.GetAutoStylePool(), XML_STYLE_FAMILY_PAGE_MASTER );
+ xPropStates.filter( rPropSet );
+ if( !xPropStates.empty())
+ rPageMasterName = xPropStates.add( "" );
}
void XMLPageExport::exportMasterPageContent(
diff --git a/xmloff/source/table/XMLTableExport.cxx b/xmloff/source/table/XMLTableExport.cxx
index b06df84..9222da6 100644
--- a/xmloff/source/table/XMLTableExport.cxx
+++ b/xmloff/source/table/XMLTableExport.cxx
@@ -187,24 +187,6 @@ XMLTableExport::~XMLTableExport ()
// --------------------------------------------------------------------
-static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
-{
- if( !xPropStates.empty() )
- {
- std::vector< XMLPropertyState >::const_iterator aIter( xPropStates.begin() );
- std::vector< XMLPropertyState >::const_iterator aEnd( xPropStates.end() );
- while( aIter != aEnd )
- {
- if( aIter->mnIndex != -1 )
- return true;
- ++aIter;
- }
- }
- return false;
-}
-
-// --------------------------------------------------------------------
-
void XMLTableExport::collectTableAutoStyles(const Reference < XColumnRowRange >& xColumnRowRange)
{
if( !mbExportTables )
@@ -217,17 +199,17 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
{
Reference< XIndexAccess > xIndexAccessCols( xColumnRowRange->getColumns(), UNO_QUERY_THROW );
const sal_Int32 nColumnCount = xIndexAccessCols->getCount();
- for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
+ for( sal_Int32 nColumn = 0; nColumn < nColumnCount; ++nColumn ) try
{
Reference< XPropertySet > xPropSet( xIndexAccessCols->getByIndex(nColumn) , UNO_QUERY_THROW );
- std::vector< XMLPropertyState > xPropStates( mxColumnExportPropertySetMapper->Filter( xPropSet ) );
-
- if( has_states( xPropStates ) )
- {
- const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_COLUMN, xPropStates) );
- Reference< XInterface > xKey( xPropSet, UNO_QUERY );
- pTableInfo->maColumnStyleMap[xKey] = sStyleName;
- }
+ SvXMLAutoFilteredSet xPropStates( mrExport.GetAutoStylePool(), XML_STYLE_FAMILY_TABLE_COLUMN );
+ xPropStates.filter( xPropSet );
+
+ if( xPropStates.hasValidContent() )
+ {
+ Reference< XInterface > xKey( xPropSet, UNO_QUERY );
+ pTableInfo->maColumnStyleMap[xKey] = xPropStates.add( "" );
+ }
}
catch(const Exception&)
{
@@ -240,16 +222,16 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
StringStatisticHelper aStringStatistic;
- for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) try
+ for( sal_Int32 nRow = 0; nRow < nRowCount; ++nRow ) try
{
- Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
- std::vector< XMLPropertyState > xRowPropStates( mxRowExportPropertySetMapper->Filter( xPropSet ) );
+ Reference< XPropertySet > xPropSet( xIndexAccessRows->getByIndex(nRow) , UNO_QUERY_THROW );
+ SvXMLAutoFilteredSet xPropStates( mrExport.GetAutoStylePool(), XML_STYLE_FAMILY_TABLE_ROW );
+ xPropStates.filter( xPropSet );
- if( has_states( xRowPropStates ) )
+ if( xPropStates.hasValidContent() )
{
- const OUString sStyleName( mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_ROW, xRowPropStates) );
Reference< XInterface > xKey( xPropSet, UNO_QUERY );
- pTableInfo->maRowStyleMap[xKey] = sStyleName;
+ pTableInfo->maRowStyleMap[xKey] = xPropStates.add( "" );
}
// get the current row
@@ -271,9 +253,11 @@ static bool has_states( const std::vector< XMLPropertyState >& xPropStates )
// create auto style, if needed
OUString sStyleName;
- std::vector< XMLPropertyState > xCellPropStates( mxCellExportPropertySetMapper->Filter( xCellSet ) );
- if( has_states( xCellPropStates ) )
- sStyleName = mrExport.GetAutoStylePool()->Add(XML_STYLE_FAMILY_TABLE_CELL, xCellPropStates);
+ SvXMLAutoFilteredSet xCellPropStates( mrExport.GetAutoStylePool(), XML_STYLE_FAMILY_TABLE_CELL );
+ xCellPropStates.filter( xCellSet );
+
+ if( xCellPropStates.hasValidContent() )
+ sStyleName = xCellPropStates.add( "" );
else
sStyleName = sParentStyleName;
More information about the Libreoffice-commits
mailing list