summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-05 17:12:06 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-11 08:01:24 +0200
commitb5a33fff1d9b40488336c94c92c9e97ee2f1e53d (patch)
tree6f60f6c4587ebe0fa7d9e533e5d9cf2f5a314772 /sc
parentcaad0f6c79909f2fb4865ac8395fc1798b8be7a6 (diff)
remove uno from oox cond format import code
Change-Id: I762a502403ecb31371efc0384376d283f7f09949
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/conditio.hxx2
-rw-r--r--sc/source/core/data/conditio.cxx45
-rw-r--r--sc/source/filter/inc/condformatbuffer.hxx8
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx146
-rw-r--r--sc/source/ui/unoobj/fmtuno.cxx29
5 files changed, 102 insertions, 128 deletions
diff --git a/sc/inc/conditio.hxx b/sc/inc/conditio.hxx
index 6874c7815645..70c182f74508 100644
--- a/sc/inc/conditio.hxx
+++ b/sc/inc/conditio.hxx
@@ -203,6 +203,8 @@ public:
virtual ScFormatEntry* Clone(ScDocument* pDoc = NULL) const;
+ static ScConditionMode GetModeFromApi(sal_Int32 nOperator);
+
protected:
virtual void DataChanged( const ScRange* pModified ) const;
ScDocument* GetDocument() const { return mpDoc; }
diff --git a/sc/source/core/data/conditio.cxx b/sc/source/core/data/conditio.cxx
index a4cd9ac0b9d8..a270e30fa846 100644
--- a/sc/source/core/data/conditio.cxx
+++ b/sc/source/core/data/conditio.cxx
@@ -33,6 +33,8 @@
#include <rtl/math.hxx>
#include <unotools/collatorwrapper.hxx>
+#include <com/sun/star/sheet/ConditionOperator2.hpp>
+
#include "conditio.hxx"
#include "cell.hxx"
#include "document.hxx"
@@ -1202,6 +1204,49 @@ ScFormatEntry* ScConditionEntry::Clone(ScDocument* pDoc) const
return new ScConditionEntry(pDoc, *this);
}
+ScConditionMode ScConditionEntry::GetModeFromApi(sal_Int32 nOperation)
+{
+ ScConditionMode eMode = SC_COND_NONE;
+ switch (nOperation)
+ {
+ case com::sun::star::sheet::ConditionOperator2::EQUAL:
+ eMode = SC_COND_EQUAL;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::LESS:
+ eMode = SC_COND_LESS;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::GREATER:
+ eMode = SC_COND_GREATER;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::LESS_EQUAL:
+ eMode = SC_COND_EQLESS;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::GREATER_EQUAL:
+ eMode = SC_COND_EQGREATER;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::NOT_EQUAL:
+ eMode = SC_COND_NOTEQUAL;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::BETWEEN:
+ eMode = SC_COND_BETWEEN;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::NOT_BETWEEN:
+ eMode = SC_COND_NOTBETWEEN;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::FORMULA:
+ eMode = SC_COND_DIRECT;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::DUPLICATE:
+ eMode = SC_COND_DUPLICATE;
+ break;
+ case com::sun::star::sheet::ConditionOperator2::NOT_DUPLICATE:
+ eMode = SC_COND_NOTDUPLICATE;
+ break;
+ default:
+ break;
+ }
+ return eMode;
+}
//------------------------------------------------------------------------
ScCondFormatEntry::ScCondFormatEntry( ScConditionMode eOper,
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 4dbe61330ac0..8bb94f42394b 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -41,6 +41,7 @@ namespace com { namespace sun { namespace star {
class ScColorScaleFormat;
class ScDataBarFormat;
struct ScDataBarFormatData;
+class ScConditionalFormat;
namespace oox {
namespace xls {
@@ -144,7 +145,7 @@ private:
class CondFormatRule : public WorksheetHelper
{
public:
- explicit CondFormatRule( const CondFormat& rCondFormat );
+ explicit CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat );
/** Imports rule settings from the cfRule element. */
void importCfRule( const AttributeList& rAttribs );
@@ -155,8 +156,7 @@ public:
void importCfRule( SequenceInputStream& rStrm );
/** Creates a conditional formatting rule in the Calc document. */
- void finalizeImport(
- const ::com::sun::star::uno::Reference< ::com::sun::star::sheet::XSheetConditionalEntries >& rxEntries );
+ void finalizeImport();
/** Returns the priority of this rule. */
inline sal_Int32 getPriority() const { return maModel.mnPriority; }
@@ -167,6 +167,7 @@ public:
private:
const CondFormat& mrCondFormat;
CondFormatRuleModel maModel;
+ ScConditionalFormat* mpFormat;
boost::scoped_ptr<ColorScaleRule> mpColor;
boost::scoped_ptr<DataBarRule> mpDataBar;
};
@@ -217,6 +218,7 @@ private:
CondFormatModel maModel; /// Model of this conditional formatting.
CondFormatRuleMap maRules; /// Maps formatting rules by priority.
+ ScConditionalFormat* mpFormat;
};
typedef ::boost::shared_ptr< CondFormat > CondFormatRef;
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 49d7a5064875..b110df2b92f8 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -54,12 +54,15 @@
#include "themebuffer.hxx"
#include "colorscale.hxx"
+#include "conditio.hxx"
#include "document.hxx"
#include "convuno.hxx"
#include "docfunc.hxx"
#include "markdata.hxx"
#include "docpool.hxx"
#include "scitems.hxx"
+#include "tokenarray.hxx"
+#include "tokenuno.hxx"
namespace oox {
namespace xls {
@@ -379,9 +382,10 @@ void CondFormatRuleModel::setBiff12TextType( sal_Int32 nOperator )
// ============================================================================
-CondFormatRule::CondFormatRule( const CondFormat& rCondFormat ) :
+CondFormatRule::CondFormatRule( const CondFormat& rCondFormat, ScConditionalFormat* pFormat ) :
WorksheetHelper( rCondFormat ),
- mrCondFormat( rCondFormat )
+ mrCondFormat( rCondFormat ),
+ mpFormat(pFormat)
{
}
@@ -611,7 +615,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm )
}
}
-void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >& rxEntries )
+void CondFormatRule::finalizeImport()
{
sal_Int32 eOperator = ::com::sun::star::sheet::ConditionOperator2::NONE;
@@ -781,107 +785,43 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA;
}
- if( rxEntries.is() && (eOperator != ::com::sun::star::sheet::ConditionOperator2::NONE) && !maModel.maFormulas.empty() )
+ CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress();
+ ScAddress aPos;
+ ScUnoConversion::FillScAddress( aPos, aBaseAddr );
+ if( (eOperator != ::com::sun::star::sheet::ConditionOperator2::NONE) && !maModel.maFormulas.empty() )
{
- ::std::vector< PropertyValue > aProps;
- // create condition properties
- lclAppendProperty( aProps, CREATE_OUSTRING( "Operator" ), eOperator );
- lclAppendProperty( aProps, CREATE_OUSTRING( "Formula1" ), maModel.maFormulas[ 0 ] );
- if( maModel.maFormulas.size() >= 2 )
- lclAppendProperty( aProps, CREATE_OUSTRING( "Formula2" ), maModel.maFormulas[ 1 ] );
-
- // style name for the formatting attributes
- OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
- if( !aStyleName.isEmpty() )
- lclAppendProperty( aProps, CREATE_OUSTRING( "StyleName" ), aStyleName );
-
- // append the new rule
- try
- {
- rxEntries->addNew( ContainerHelper::vectorToSequence( aProps ) );
- }
- catch( Exception& )
+ ScDocument& rDoc = getScDocument();
+ boost::scoped_ptr<ScTokenArray> pTokenArray2;
+ if( maModel.maFormulas.size() >= 2)
{
+ pTokenArray2.reset(new ScTokenArray());
+ ScTokenConversion::ConvertToTokenArray( rDoc, *pTokenArray2.get(), maModel.maFormulas[ 1 ] );
}
+
+ ScTokenArray aTokenArray;
+ OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId );
+ ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, maModel.maFormulas[ 0 ] );
+ ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(ScCondFormatEntry::GetModeFromApi(eOperator),
+ &aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName);
+ mpFormat->AddEntry(pNewEntry);
}
else if( mpColor )
{
ScDocument& rDoc = getScDocument();
ScColorScaleFormat* pFormatEntry = new ScColorScaleFormat(&rDoc);
- const ApiCellRangeList& rRanges = mrCondFormat.getRanges();
- ScRange aRange;
- ScUnoConversion::FillScRange(aRange, *rRanges.begin());
-
- ScConditionalFormat* pFormat = rDoc.GetCondFormat( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
- if(!pFormat)
- {
- pFormat = new ScConditionalFormat(0, &rDoc);
- pFormat->AddEntry(pFormatEntry);
- rDoc.AddCondFormat(pFormat, aRange.aStart.Tab());
- }
- else
- pFormat->AddEntry(pFormatEntry);
-
-
- sal_Int32 nIndex = pFormat->GetKey();
+ mpFormat->AddEntry(pFormatEntry);
- ScRangeList aList;
- // apply attributes to cells
- //
- for( ApiCellRangeList::const_iterator itr = rRanges.begin(); itr != rRanges.end(); ++itr)
- {
- ScUnoConversion::FillScRange(aRange, *itr);
- ScPatternAttr aPattern( rDoc.GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.SetMarkArea(aRange);
- rDoc.ApplySelectionPattern( aPattern , aMarkData);
-
- aList.Append(aRange);
- }
- if(aList.size())
- mpColor->AddEntries( pFormatEntry, &rDoc, aList.front()->aStart );
- else
- mpColor->AddEntries( pFormatEntry, &rDoc, ScAddress() );
- pFormat->AddRange(aList);
+ mpColor->AddEntries( pFormatEntry, &rDoc, aPos );
}
else if (mpDataBar)
{
- ScRangeList aList;
-
ScDocument& rDoc = getScDocument();
ScDataBarFormat* pFormatEntry = new ScDataBarFormat(&rDoc);
- const ApiCellRangeList& rRanges = mrCondFormat.getRanges();
- ScRange aRange;
- ScUnoConversion::FillScRange(aRange, *rRanges.begin());
-
- ScConditionalFormat* pFormat = rDoc.GetCondFormat( aRange.aStart.Col(), aRange.aStart.Row(), aRange.aStart.Tab() );
- if(!pFormat)
- {
- pFormat = new ScConditionalFormat(0, &rDoc);
- sal_Int32 nKey = rDoc.AddCondFormat(pFormat, aRange.aStart.Tab());
- pFormat->SetKey(nKey);
- }
- pFormat->AddEntry(pFormatEntry);
- sal_Int32 nIndex = pFormat->GetKey();
- // apply attributes to cells
- //
- for( ApiCellRangeList::const_iterator itr = rRanges.begin(); itr != rRanges.end(); ++itr)
- {
- ScUnoConversion::FillScRange(aRange, *itr);
- ScPatternAttr aPattern( rDoc.GetPool() );
- aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
- ScMarkData aMarkData;
- aMarkData.SetMarkArea(aRange);
- rDoc.ApplySelectionPattern( aPattern , aMarkData);
-
- aList.Append(aRange);
- }
- mpDataBar->SetData( pFormatEntry, &rDoc, aList.front()->aStart );
+ mpFormat->AddEntry(pFormatEntry);
+ mpDataBar->SetData( pFormatEntry, &rDoc, aPos );
- pFormat->AddRange(aList);
}
}
@@ -911,7 +851,8 @@ CondFormatModel::CondFormatModel() :
// ============================================================================
CondFormat::CondFormat( const WorksheetHelper& rHelper ) :
- WorksheetHelper( rHelper )
+ WorksheetHelper( rHelper ),
+ mpFormat(NULL)
{
}
@@ -919,6 +860,7 @@ void CondFormat::importConditionalFormatting( const AttributeList& rAttribs )
{
getAddressConverter().convertToCellRangeList( maModel.maRanges, rAttribs.getString( XML_sqref, OUString() ), getSheetIndex(), true );
maModel.mbPivot = rAttribs.getBool( XML_pivot, false );
+ mpFormat = new ScConditionalFormat(0, &getScDocument());
}
CondFormatRuleRef CondFormat::importCfRule( const AttributeList& rAttribs )
@@ -946,23 +888,29 @@ void CondFormat::importCfRule( SequenceInputStream& rStrm )
void CondFormat::finalizeImport()
{
- try
- {
- Reference< XSheetCellRanges > xRanges( getCellRangeList( maModel.maRanges ), UNO_SET_THROW );
- PropertySet aPropSet( xRanges );
- Reference< XSheetConditionalEntries > xEntries( aPropSet.getAnyProperty( PROP_ConditionalFormat ), UNO_QUERY_THROW );
- // maRules is sorted by rule priority
- maRules.forEachMem( &CondFormatRule::finalizeImport, ::boost::cref( xEntries ) );
- aPropSet.setProperty( PROP_ConditionalFormat, xEntries );
- }
- catch( Exception& )
+ ScDocument& rDoc = getScDocument();
+ maRules.forEachMem( &CondFormatRule::finalizeImport );
+ sal_Int32 nIndex = getScDocument().AddCondFormat(mpFormat, maModel.maRanges.getBaseAddress().Sheet);
+
+ ScRangeList aList;
+ for( ApiCellRangeList::const_iterator itr = maModel.maRanges.begin(); itr != maModel.maRanges.end(); ++itr)
{
+ ScRange aRange;
+ ScUnoConversion::FillScRange(aRange, *itr);
+ ScPatternAttr aPattern( rDoc.GetPool() );
+ aPattern.GetItemSet().Put( SfxUInt32Item( ATTR_CONDITIONAL, nIndex ) );
+ ScMarkData aMarkData;
+ aMarkData.SetMarkArea(aRange);
+ rDoc.ApplySelectionPattern( aPattern , aMarkData);
+
+ aList.Append(aRange);
}
+ mpFormat->AddRange(aList);
}
CondFormatRuleRef CondFormat::createRule()
{
- return CondFormatRuleRef( new CondFormatRule( *this ) );
+ return CondFormatRuleRef( new CondFormatRule( *this, mpFormat ) );
}
void CondFormat::insertRule( CondFormatRuleRef xRule )
diff --git a/sc/source/ui/unoobj/fmtuno.cxx b/sc/source/ui/unoobj/fmtuno.cxx
index 81e442091b86..09adcf9c2406 100644
--- a/sc/source/ui/unoobj/fmtuno.cxx
+++ b/sc/source/ui/unoobj/fmtuno.cxx
@@ -102,29 +102,6 @@ sal_Int32 lcl_ConditionModeToOperatorNew( ScConditionMode eMode )
return eOper;
}
-ScConditionMode lcl_ConditionOperatorToModeNew( sal_Int32 eOper )
-{
- ScConditionMode eMode = SC_COND_NONE;
- switch (eOper)
- {
- case sheet::ConditionOperator2::EQUAL: eMode = SC_COND_EQUAL; break;
- case sheet::ConditionOperator2::LESS: eMode = SC_COND_LESS; break;
- case sheet::ConditionOperator2::GREATER: eMode = SC_COND_GREATER; break;
- case sheet::ConditionOperator2::LESS_EQUAL: eMode = SC_COND_EQLESS; break;
- case sheet::ConditionOperator2::GREATER_EQUAL: eMode = SC_COND_EQGREATER; break;
- case sheet::ConditionOperator2::NOT_EQUAL: eMode = SC_COND_NOTEQUAL; break;
- case sheet::ConditionOperator2::BETWEEN: eMode = SC_COND_BETWEEN; break;
- case sheet::ConditionOperator2::NOT_BETWEEN: eMode = SC_COND_NOTBETWEEN; break;
- case sheet::ConditionOperator2::FORMULA: eMode = SC_COND_DIRECT; break;
- case sheet::ConditionOperator2::DUPLICATE: eMode = SC_COND_DUPLICATE; break;
- default:
- {
- // added to avoid warnings
- }
- }
- return eMode;
-}
-
sheet::ConditionOperator lcl_ConditionModeToOperator( ScConditionMode eMode )
{
sheet::ConditionOperator eOper = sheet::ConditionOperator_NONE;
@@ -307,7 +284,7 @@ void SAL_CALL ScTableConditionalFormat::addNew(
if ( rProp.Name == SC_UNONAME_OPERATOR )
{
sal_Int32 eOper = ScUnoHelpFunctions::GetEnumFromAny( rProp.Value );
- aEntry.meMode = lcl_ConditionOperatorToModeNew( eOper );
+ aEntry.meMode = ScConditionEntry::GetModeFromApi( eOper );
}
else if ( rProp.Name == SC_UNONAME_FORMULA1 )
{
@@ -586,7 +563,7 @@ void SAL_CALL ScTableConditionalEntry::setConditionOperator( sal_Int32 nOperator
throw(uno::RuntimeException)
{
SolarMutexGuard aGuard;
- aData.meMode = lcl_ConditionOperatorToModeNew( nOperator );
+ aData.meMode = ScConditionEntry::GetModeFromApi( nOperator );
}
rtl::OUString SAL_CALL ScTableConditionalEntry::getFormula1() throw(uno::RuntimeException)
@@ -784,7 +761,7 @@ void SAL_CALL ScTableValidationObj::setConditionOperator( sal_Int32 nOperator )
throw(uno::RuntimeException)
{
SolarMutexGuard aGuard;
- nMode = sal::static_int_cast<sal_uInt16>( lcl_ConditionOperatorToModeNew( nOperator ) );
+ nMode = sal::static_int_cast<sal_uInt16>( ScConditionEntry::GetModeFromApi( nOperator ) );
}
rtl::OUString SAL_CALL ScTableValidationObj::getFormula1() throw(uno::RuntimeException)