summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorDaniel Bankston <daniel.e.bankston@gmail.com>2012-05-24 16:31:34 -0500
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-06-01 19:40:08 +0200
commit60f8cef7df244b0e9219e770a8d9ae9d02fe237f (patch)
tree3cd7cb37911bc7b81b59e03e16f8c1697323ce39 /sc
parent119b7085ee77c7bd033059332766e66cdcc81fec (diff)
Make suggested code style changes
Change-Id: I9cd71b78098adc6b0fee1139ffb1a1202d9981dc
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/xml/xmlcelli.cxx119
-rw-r--r--sc/source/filter/xml/xmlsubti.cxx3
-rw-r--r--sc/source/filter/xml/xmlsubti.hxx2
3 files changed, 56 insertions, 68 deletions
diff --git a/sc/source/filter/xml/xmlcelli.cxx b/sc/source/filter/xml/xmlcelli.cxx
index cd74d739d73f..08be576092ba 100644
--- a/sc/source/filter/xml/xmlcelli.cxx
+++ b/sc/source/filter/xml/xmlcelli.cxx
@@ -453,64 +453,61 @@ SvXMLImportContext *ScXMLTableRowCellContext::CreateChildContext( sal_uInt16 nPr
return pContext;
}
-namespace
+namespace {
+
+static bool ScCellExists( const ScAddress& rScAddress )
{
- static bool lcl_ScCellExists( const ScAddress& rScAddress )
- {
- return( rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW );
- }
+ return( rScAddress.Col() <= MAXCOL && rScAddress.Row() <= MAXROW );
+}
- static ScRange lcl_ScGetCellRangeByPosition( const ScRange& rScRange, const SCCOL nLeft, const SCROW nTop, const SCCOL nRight, const SCROW nBottom )
- throw( lang::IndexOutOfBoundsException )
+ScRange getCellRangeByPosition( const ScRange& rScRange, const SCCOL nLeft, const SCROW nTop, const SCCOL nRight, const SCROW nBottom )
+{
+ if( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
{
- if( nLeft >= 0 && nTop >= 0 && nRight >= 0 && nBottom >= 0 )
- {
- SCCOL nStartX = rScRange.aStart.Col() + nLeft;
- SCROW nStartY = rScRange.aStart.Row() + nTop;
- SCCOL nEndX = rScRange.aStart.Col() + nRight;
- SCROW nEndY = rScRange.aStart.Row() + nBottom;
-
- if( nStartX <= nEndX && nEndX <= rScRange.aEnd.Col() &&
- nStartY <= nEndY && nEndY <= rScRange.aEnd.Row() )
- {
- return ScRange( nStartX, nStartY, rScRange.aStart.Tab(), nEndX, nEndY, rScRange.aEnd.Tab() );
- }
- }
- throw lang::IndexOutOfBoundsException();
- }
+ SCCOL nStartX = rScRange.aStart.Col() + nLeft;
+ SCROW nStartY = rScRange.aStart.Row() + nTop;
+ SCCOL nEndX = rScRange.aStart.Col() + nRight;
+ SCROW nEndY = rScRange.aStart.Row() + nBottom;
- static ScRange lcl_ScGetCellRangeByPosition( const ScRange& rScRange, const ScAddress& rScCell ) throw( lang::IndexOutOfBoundsException )
- {
- try
+ if( nStartX <= nEndX && nEndX <= rScRange.aEnd.Col() &&
+ nStartY <= nEndY && nEndY <= rScRange.aEnd.Row() )
{
- return lcl_ScGetCellRangeByPosition( rScRange, rScCell.Col(), rScCell.Row(), rScCell.Col(), rScCell.Row() );
+ return ScRange( nStartX, nStartY, rScRange.aStart.Tab(), nEndX, nEndY, rScRange.aEnd.Tab() );
}
- catch( lang::IndexOutOfBoundsException & ) { throw; }
}
+ return ScRange( ScAddress::INITIALIZE_INVALID );
+}
+
+ScRange getCellRangeByPosition( const ScRange& rScRange, const ScAddress& rScCell )
+{
+ return getCellRangeByPosition( rScRange, rScCell.Col(), rScCell.Row(), rScCell.Col(), rScCell.Row() );
+}
- static void lcl_ScMerge( ScDocShell* pDocSh, const ScRange& rScRange, const bool bMerge )
+void merge( ScDocShell* pDocSh, const ScRange& rScRange, const bool bMerge )
+{
+ if( pDocSh )
{
- if( pDocSh )
- {
- ScCellMergeOption aMergeOption(
- rScRange.aStart.Col(), rScRange.aStart.Row(),
- rScRange.aEnd.Col(), rScRange.aEnd.Row(), false
- );
- aMergeOption.maTabs.insert( rScRange.aStart.Tab() );
- if ( bMerge )
- pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
- else
- pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true, true );
- }
+ ScCellMergeOption aMergeOption(
+ rScRange.aStart.Col(), rScRange.aStart.Row(),
+ rScRange.aEnd.Col(), rScRange.aEnd.Row(), false
+ );
+ aMergeOption.maTabs.insert( rScRange.aStart.Tab() );
+ if ( bMerge )
+ pDocSh->GetDocFunc().MergeCells( aMergeOption, false, true, true );
+ else
+ pDocSh->GetDocFunc().UnmergeCells( aMergeOption, true, true );
}
}
+} //anonymous namespace
+
bool ScXMLTableRowCellContext::IsMerged( const ScRange& rScRange, const ScAddress& rScCell, ScRange& rScCellRange ) const
{
- if( lcl_ScCellExists(rScCell) )
+ if( ScCellExists(rScCell) )
{
ScDocument* pDoc = rXMLImport.GetDocument();
- rScCellRange = lcl_ScGetCellRangeByPosition( rScRange, rScCell );
+ rScCellRange = getCellRangeByPosition( rScRange, rScCell );
+ if( !rScRange.IsValid() ) return false;
pDoc->ExtendOverlapped( rScCellRange );
pDoc->ExtendMerge( rScCellRange );
rScCellRange.Justify();
@@ -525,38 +522,30 @@ bool ScXMLTableRowCellContext::IsMerged( const ScRange& rScRange, const ScAddres
void ScXMLTableRowCellContext::DoMerge( const ScAddress& rScCellPos, const sal_Int32 nCols, const sal_Int32 nRows )
{
- if( lcl_ScCellExists(rScCellPos) )
+ if( ScCellExists(rScCellPos) )
{
ScRange aScCellRange;
SCTAB nCurrentSheet = GetScImport().GetTables().GetCurrentSheet();
ScRange aScRange( 0, 0, nCurrentSheet, MAXCOL, MAXROW, nCurrentSheet ); //the whole sheet
ScDocShell* pDocSh = static_cast< ScDocShell* >( rXMLImport.GetDocument()->GetDocumentShell() );
- // Stored merge range may actually be of a larger extend than what
- // we support, in which case getCellRangeByPosition() throws
- // IndexOutOfBoundsException. Do nothing then. ???
- try
+ if( IsMerged(aScRange, rScCellPos, aScCellRange) )
{
- if( IsMerged(aScRange, rScCellPos, aScCellRange) )
- {
- //unmerge
- ScRange aScMergeRange(
- lcl_ScGetCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
- aScCellRange.aEnd.Col(), aScCellRange.aEnd.Row() )
- );
- lcl_ScMerge( pDocSh, aScMergeRange, false );
- }
-
- //merge
+ //unmerge
ScRange aScMergeRange(
- lcl_ScGetCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
- aScCellRange.aEnd.Col() + nCols, aScCellRange.aEnd.Row() + nRows )
+ getCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
+ aScCellRange.aEnd.Col(), aScCellRange.aEnd.Row() )
);
- lcl_ScMerge( pDocSh, aScMergeRange, true );
- }
- catch( lang::IndexOutOfBoundsException & )
- {
- OSL_FAIL("ScXMLTableRowCellContext::DoMerge: range to be merged larger than what we support");
+ if( aScMergeRange.IsValid() )
+ merge( pDocSh, aScMergeRange, false );
}
+
+ //merge
+ ScRange aScMergeRange(
+ getCellRangeByPosition( aScRange, aScCellRange.aStart.Col(), aScCellRange.aStart.Row(),
+ aScCellRange.aEnd.Col() + nCols, aScCellRange.aEnd.Row() + nRows )
+ );
+ if( aScMergeRange.IsValid() )
+ merge( pDocSh, aScMergeRange, true );
}
}
diff --git a/sc/source/filter/xml/xmlsubti.cxx b/sc/source/filter/xml/xmlsubti.cxx
index ec633bfd70c3..5f33aca8f558 100644
--- a/sc/source/filter/xml/xmlsubti.cxx
+++ b/sc/source/filter/xml/xmlsubti.cxx
@@ -685,8 +685,7 @@ table::CellAddress ScMyTables::GetRealCellPos()
return aRealCellPos;
}
-//placeholder; needs more work
-const ScAddress ScMyTables::GetRealScCellPos() const
+ScAddress ScMyTables::GetRealScCellPos() const
{
sal_Int32 nRow = 0;
sal_Int32 nCol = 0;
diff --git a/sc/source/filter/xml/xmlsubti.hxx b/sc/source/filter/xml/xmlsubti.hxx
index 4fa41cb0d5b5..6fa8161b8161 100644
--- a/sc/source/filter/xml/xmlsubti.hxx
+++ b/sc/source/filter/xml/xmlsubti.hxx
@@ -171,7 +171,7 @@ public:
{ return ScMyOLEFixer::IsOLE(rShape); }
void DeleteTable();
com::sun::star::table::CellAddress GetRealCellPos();
- const ScAddress GetRealScCellPos() const;
+ ScAddress GetRealScCellPos() const;
void AddColCount(sal_Int32 nTempColCount);
void AddColStyle(const sal_Int32 nRepeat, const rtl::OUString& rCellStyleName);
ScXMLTabProtectionData& GetCurrentProtectionData() { return maProtectionData; }