[Libreoffice-commits] core.git: Branch 'feature/gsoc-calc-enhanced-db-range' - 4 commits - sc/inc sc/source
Akash Shetye
shetyeakash at gmail.com
Thu Aug 29 16:17:25 PDT 2013
sc/inc/dbdataformatting.hxx | 24 +++++-----
sc/source/core/data/fillinfo.cxx | 34 ++++++++++++++
sc/source/core/tool/dbdata2.cxx | 74 +++++++++----------------------
sc/source/core/tool/dbdataformatting.cxx | 53 ++++++++++++++++++++--
sc/source/filter/inc/stylesbuffer.hxx | 3 -
sc/source/filter/oox/stylesbuffer.cxx | 25 ++++++++--
6 files changed, 141 insertions(+), 72 deletions(-)
New commits:
commit 219738ee4deee6204ed19c9681cde6c7579297c1
Author: Akash Shetye <shetyeakash at gmail.com>
Date: Fri Aug 30 04:46:14 2013 +0530
Revised the code for cell style calculation
Change-Id: Ib2a66148ec6461f3b8ce5a4de7dabcc78dadaea3
diff --git a/sc/source/core/tool/dbdata2.cxx b/sc/source/core/tool/dbdata2.cxx
index 879437a..073dea2 100644
--- a/sc/source/core/tool/dbdata2.cxx
+++ b/sc/source/core/tool/dbdata2.cxx
@@ -16,14 +16,12 @@ OUString ScDBData::GetCellStyle( const ScAddress& rPos, bool bRowStripe )
//first see if the DB Range has any DB Formatting at all
if( !HasFormatting() )
return OUString("Default");
+ //Check if the bRowStripe specified applies?
+ if ( bRowStripe == true && !(mpTableFormatData->GetBandedRows()) )
+ return OUString("Default");//Asked banded rows, but not banded
+ if ( bRowStripe == false && !(mpTableFormatData->GetBandedColumns()) )
+ return OUString("Default");//asked banded cols, but not banded here
//Calculating which style sheet is applicable to the give cell begins now
- //Create a whole row stripe map
- std::vector< OUString > aRowStripeSeq;
- //Create a whole column stripe map
- std::vector< OUString > aColStripeSeq;
- //The above two vectors represent a whole row/col stripe by
- //using consecutive entries of stylenames into the vector
- //just as it would look like in a rendered single stripe.
ScDBDataFormatting aDBFormatting;
GetTableFormatting( aDBFormatting );
sal_Int32 i;
@@ -31,6 +29,7 @@ OUString ScDBData::GetCellStyle( const ScAddress& rPos, bool bRowStripe )
sal_Int32 nSecondSize;
OUString aFirstStyle;
OUString aSecondStyle;
+ sal_Int32 nStyleIndex;
if ( bRowStripe )
{
//Fill the row stripe sequence
@@ -38,65 +37,38 @@ OUString ScDBData::GetCellStyle( const ScAddress& rPos, bool bRowStripe )
aFirstStyle = aDBFormatting.GetFirstRowStripeStyle();
nSecondSize = aDBFormatting.GetSecondRowStripeSize();
aSecondStyle = aDBFormatting.GetSecondRowStripeStyle();
- for ( i = 1; i <= nFirstSize; ++i )
- {
- //Add the first row stripe style to the RowStripeSeq vector nFirstSize
- //many times.
- aRowStripeSeq.push_back( aFirstStyle );
- }
- for ( i = 1; i<= nSecondSize; ++i )
- {
- //Similarly
- aRowStripeSeq.push_back( aSecondStyle );
- }
}
- //Fill the column stripe sequence
else
{
+ //Fill the col stripe sequence
nFirstSize = aDBFormatting.GetFirstColStripeSize();
aFirstStyle = aDBFormatting.GetFirstColStripeStyle();
nSecondSize = aDBFormatting.GetSecondColStripeSize();
aSecondStyle = aDBFormatting.GetSecondColStripeStyle();
- for ( i = 1; i<=nFirstSize; ++i )
- {
- aColStripeSeq.push_back( aFirstStyle );
- }
- for ( i = 1; i<=nSecondSize; ++i )
- {
- aColStripeSeq.push_back( aSecondStyle );
- }
}
- //This approach of calculating the stripe sequence will be bad
- //if stripe sizes are huge, they generally aren't.
- //Now the math.
- //We used 1-based addressing for this instead of the 0-based used in Calc
if ( bRowStripe )
{
- sal_Int32 nStyleIndex = ( rPos.Row() + 1 ) % ( aRowStripeSeq.size() );
- if ( nStyleIndex == 0 )
- {
- //Return the last entry in the vector
- return aRowStripeSeq[ ( aRowStripeSeq.size() - 1 ) ];
- }
+ nStyleIndex = ( rPos.Row() + 1 ) % ( nFirstSize + nSecondSize );
+ }
+ else
+ {
+ nStyleIndex = ( rPos.Col() + 1 ) % ( nFirstSize + nSecondSize );
+ }
+ if ( nStyleIndex == 0 )
+ {
+ sal_Int32 nEntryNo = ( ( nFirstSize + nSecondSize ) );
+ if ( nEntryNo <= nFirstSize )
+ return aFirstStyle;
else
- {
- //Return the nStyleIndex'th entry
- return aRowStripeSeq[ ( nStyleIndex - 1) ];
- }
+ return aSecondStyle;
}
else
{
- sal_Int32 nStyleIndex = ( rPos.Row() + 1 ) % ( aRowStripeSeq.size() );
- if ( nStyleIndex == 0 )
- {
- //Return the last entry in the vector
- return aColStripeSeq[ ( aColStripeSeq.size() - 1 ) ];
- }
+ sal_Int32 nEntryNo = ( nStyleIndex );
+ if ( nEntryNo <= nFirstSize )
+ return aFirstStyle;
else
- {
- //Return the nStyleIndex'th entry
- return aColStripeSeq[ ( nStyleIndex - 1 ) ];
- }
+ return aSecondStyle;
}
}
commit 9b09732f864d5599f1e85b5ba717d77595b1abd9
Author: Akash Shetye <shetyeakash at gmail.com>
Date: Fri Aug 30 04:40:26 2013 +0530
Added support for importing stripe sizes as well
Change-Id: I83b83d74b6241f4884461f4d07944946e1f25fe8
diff --git a/sc/source/filter/inc/stylesbuffer.hxx b/sc/source/filter/inc/stylesbuffer.hxx
index c274d2d..44c4d68 100644
--- a/sc/source/filter/inc/stylesbuffer.hxx
+++ b/sc/source/filter/inc/stylesbuffer.hxx
@@ -789,7 +789,8 @@ typedef ::boost::shared_ptr< Dxf > DxfRef;
struct TableStyleElementModel
{
- sal_Int32 maDxfId;
+ sal_Int32 nDxfId;
+ sal_Int32 nSize;
OUString maStyleElementType;
};
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx
index 82f9315..c5ccdb4 100644
--- a/sc/source/filter/oox/stylesbuffer.cxx
+++ b/sc/source/filter/oox/stylesbuffer.cxx
@@ -2644,10 +2644,15 @@ void TableStyle::importTableStyleElement( const AttributeList& rAttribs )
//Get the table Style element type.
OUString aStyleElementType = rAttribs.getXString( XML_type, OUString() );
//Extract the Dxf Id and create such a style
- sal_Int32 aDxfId = static_cast< sal_Int32 >( rAttribs.getInteger( XML_dxfId, -1 ) );
- SAL_WARN_IF( (aDxfId == -1) ,"sc", "TableStyle::importTableStyleElement - DxfId not defined for table style element" );
+ sal_Int32 nDxfId = static_cast< sal_Int32 >( rAttribs.getInteger( XML_dxfId, -1 ) );
+ SAL_WARN_IF( (nDxfId == -1) ,"sc", "TableStyle::importTableStyleElement - DxfId not defined for table style element" );
+ sal_Int32 nSize = static_cast< sal_Int32 >( rAttribs.getInteger( XML_size, -1 ) );
+ SAL_WARN_IF( ( nSize == -1 ), "sc", "TableStyle::importTableStyleElement - Size not defined assuming as 1");
+ if ( nSize == -1 )
+ nSize = 1;
TableStyleElementModel aTableStyleElementModel;
- aTableStyleElementModel.maDxfId = aDxfId;
+ aTableStyleElementModel.nDxfId = nDxfId;
+ aTableStyleElementModel.nSize = nSize;
aTableStyleElementModel.maStyleElementType = aStyleElementType;
maStyleElementVector.push_back( aTableStyleElementModel );
}
@@ -2668,15 +2673,27 @@ void TableStyle::finalizeImport()
for( TableStyleElementModelVector::iterator itr = maStyleElementVector.begin(); itr!=maStyleElementVector.end(); ++itr)
{
//Should I stop on finding this missing feild or keep going?
- OUString aDxfStyleName = getStyles().createDxfStyle( itr->maDxfId );
+ OUString aDxfStyleName = getStyles().createDxfStyle( itr->nDxfId );
if( itr->maStyleElementType.equals("firstColumnStripe") )
+ {
mxTableFormatting->SetFirstColStripeStyle( aDxfStyleName );
+ mxTableFormatting->SetFirstColStripeSize( itr->nSize );
+ }
else if( itr->maStyleElementType.equals("secondColumnStripe") )
+ {
mxTableFormatting->SetSecondColStripeStyle( aDxfStyleName );
+ mxTableFormatting->SetSecondColStripeSize( itr->nSize );
+ }
else if( itr->maStyleElementType.equals("firstRowStripe") )
+ {
mxTableFormatting->SetFirstRowStripeStyle( aDxfStyleName );
+ mxTableFormatting->SetFirstRowStripeSize( itr->nSize );
+ }
else if( itr->maStyleElementType.equals("secondRowStripe") )
+ {
mxTableFormatting->SetSecondRowStripeStyle( aDxfStyleName );
+ mxTableFormatting->SetSecondRowStripeSize( itr->nSize );
+ }
}
}
commit cc5ab36c5ae3e9145261ec7645e2e798aa2fd95e
Author: Akash Shetye <shetyeakash at gmail.com>
Date: Fri Aug 30 04:39:20 2013 +0530
Adds the code to fill info to allow cell colouring.
Change-Id: I5a037c97192ac40be9b76f7eb8ef550a2f7205b0
diff --git a/sc/source/core/data/fillinfo.cxx b/sc/source/core/data/fillinfo.cxx
index 5f9b6ce..4a60e68 100644
--- a/sc/source/core/data/fillinfo.cxx
+++ b/sc/source/core/data/fillinfo.cxx
@@ -41,6 +41,7 @@
#include "stlpool.hxx"
#include "cellvalue.hxx"
#include "mtvcellfunc.hxx"
+#include "dbdata.hxx"
const sal_uInt16 ROWINFO_MAX = 1024;
@@ -537,6 +538,39 @@ void ScDocument::FillInfo(
pThisRowInfo->bEmptyBack = false;
}
+ //Exp Code
+ //Overwrite this pBackground value
+ //Get cell style for this cell
+ if ( pDBCollection )
+ {
+ ScDBCollection::NamedDBs& aNamedDBs = pDBCollection->getNamedDBs();
+ ScDBData* pDBData = pDBCollection->GetDBAtCursor( nX, nCurRow, nTab, false );
+ if ( pDBData && pDBData->HasFormatting() )
+ {
+ ScDBDataFormatting aDBFormatting;
+ pDBData->GetTableFormatting( aDBFormatting );
+ //Getting the applicable cell style name
+ //First for banded columns/lowest priority
+ OUString aCellStyleName;
+ if ( aDBFormatting.GetBandedColumns() )
+ aCellStyleName = pDBData->GetCellStyle( ScAddress( nX, nCurRow, nTab ), false );
+ //Second for banded rows/highest priority
+ if ( aDBFormatting.GetBandedRows() )
+ aCellStyleName = pDBData->GetCellStyle( ScAddress( nX, nCurRow, nTab ), true );
+ if ( !aCellStyleName.isEmpty() )
+ {
+ SfxStyleSheetBase* pStyleSheet = pStlPool->Find(aCellStyleName, SFX_STYLE_FAMILY_PARA );
+ if ( pStyleSheet )
+ {
+ SfxItemSet aStyleSheetItemSet = pStyleSheet->GetItemSet();
+ pInfo->pBackground = ( const SvxBrushItem * )aStyleSheetItemSet.GetItem( ATTR_BACKGROUND );
+ }
+ }
+ }
+ }
+ //From the style get the SfxItemSet
+ //Exp Code ends
+
if ( bContainsCondFormat )
{
bool bFound = false;
commit e3995f25d94f74b325e94f41df7e0d3b64adc617
Author: Akash Shetye <shetyeakash at gmail.com>
Date: Fri Aug 30 04:37:40 2013 +0530
Added nFirstRowStripeSize etc to the initializers for various constructors
Change-Id: I32645a5056fb6147dc2c23dd8fe97ab8834d38df
diff --git a/sc/inc/dbdataformatting.hxx b/sc/inc/dbdataformatting.hxx
index c14bed1..e984275 100644
--- a/sc/inc/dbdataformatting.hxx
+++ b/sc/inc/dbdataformatting.hxx
@@ -19,10 +19,10 @@ class SC_DLLPUBLIC ScDBDataFormatting
OUString maSecondRowStripeStyle;
OUString maFirstColStripeStyle;
OUString maSecondColStripeStyle;
- sal_Int32 maFirstRowStripeSize;
- sal_Int32 maSecondRowStripeSize;
- sal_Int32 maFirstColStripeSize;
- sal_Int32 maSecondColStripeSize;
+ sal_Int32 nFirstRowStripeSize;
+ sal_Int32 nSecondRowStripeSize;
+ sal_Int32 nFirstColStripeSize;
+ sal_Int32 nSecondColStripeSize;
bool mbBandedRows;
bool mbBandedColumns;
public:
@@ -39,14 +39,14 @@ public:
const OUString& GetSecondRowStripeStyle() const;
const OUString& GetFirstColStripeStyle() const;
const OUString& GetSecondColStripeStyle() const;
- sal_Int32 GetFirstRowStripeSize() const { return maFirstRowStripeSize; }
- sal_Int32 GetSecondRowStripeSize() const { return maSecondRowStripeSize; }
- sal_Int32 GetFirstColStripeSize() const { return maFirstColStripeSize; }
- sal_Int32 GetSecondColStripeSize() const { return maSecondColStripeSize; }
- void SetFirstRowStripeSize( const sal_Int32 nSize ){ maFirstRowStripeSize = nSize; }
- void SetSecondRowStripeSize( const sal_Int32 nSize ){ maSecondRowStripeSize = nSize; }
- void SetFirstColStripeSize( const sal_Int32 nSize ){ maFirstColStripeSize = nSize; }
- void SetSecondColStripeSize( const sal_Int32 nSize ){ maSecondColStripeSize = nSize; }
+ sal_Int32 GetFirstRowStripeSize();
+ sal_Int32 GetSecondRowStripeSize();
+ sal_Int32 GetFirstColStripeSize();
+ sal_Int32 GetSecondColStripeSize();
+ void SetFirstRowStripeSize( sal_Int32 nSize );
+ void SetSecondRowStripeSize( sal_Int32 nSize );
+ void SetFirstColStripeSize( sal_Int32 nSize );
+ void SetSecondColStripeSize( sal_Int32 nSize );
void SetFirstRowStripeStyle( const OUString& aStyleName );
void SetSecondRowStripeStyle( const OUString& aStyleName );
void SetFirstColStripeStyle( const OUString& aStyleName );
diff --git a/sc/source/core/tool/dbdataformatting.cxx b/sc/source/core/tool/dbdataformatting.cxx
index 07f1ede..1864698 100644
--- a/sc/source/core/tool/dbdataformatting.cxx
+++ b/sc/source/core/tool/dbdataformatting.cxx
@@ -16,10 +16,10 @@ ScDBDataFormatting::ScDBDataFormatting():
maSecondRowStripeStyle ( "Default" ),
maFirstColStripeStyle ( "Default" ),
maSecondColStripeStyle ( "Default" ),
- maFirstRowStripeSize ( 1 ),
- maSecondRowStripeSize ( 1 ),
- maFirstColStripeSize ( 1 ),
- maSecondColStripeSize ( 1 ),
+ nFirstRowStripeSize ( 1 ),
+ nSecondRowStripeSize ( 1 ),
+ nFirstColStripeSize ( 1 ),
+ nSecondColStripeSize ( 1 ),
mbBandedRows ( false ),
mbBandedColumns ( false )
{
@@ -31,6 +31,10 @@ ScDBDataFormatting::ScDBDataFormatting(const OUString& rTableStyleName, const OU
maSecondRowStripeStyle ( rSecondRowStripeStyle ),
maFirstColStripeStyle ( rFirstColStripeStyle ),
maSecondColStripeStyle ( rSecondColStripeStyle ),
+ nFirstRowStripeSize ( 1 ),
+ nSecondRowStripeSize ( 1 ),
+ nFirstColStripeSize ( 1 ),
+ nSecondColStripeSize ( 1 ),
mbBandedRows ( bBRows ),
mbBandedColumns ( bBCols )
{
@@ -42,6 +46,10 @@ ScDBDataFormatting::ScDBDataFormatting( const ScDBDataFormatting& rTableFormatDa
maSecondRowStripeStyle ( rTableFormatData.maSecondRowStripeStyle ),
maFirstColStripeStyle ( rTableFormatData.maFirstColStripeStyle ),
maSecondColStripeStyle ( rTableFormatData.maSecondColStripeStyle ),
+ nFirstRowStripeSize ( rTableFormatData.nFirstRowStripeSize ),
+ nSecondRowStripeSize ( rTableFormatData.nSecondRowStripeSize ),
+ nFirstColStripeSize ( rTableFormatData.nFirstColStripeSize ),
+ nSecondColStripeSize ( rTableFormatData.nSecondColStripeSize ),
mbBandedRows ( rTableFormatData.mbBandedRows ),
mbBandedColumns ( rTableFormatData.mbBandedColumns )
{
@@ -116,3 +124,40 @@ void ScDBDataFormatting::SetSecondColStripeStyle( const OUString& aStyleName )
{
maSecondColStripeStyle = aStyleName;
}
+
+void ScDBDataFormatting::SetFirstRowStripeSize( sal_Int32 nSize)
+{
+ nFirstRowStripeSize = nSize;
+}
+void ScDBDataFormatting::SetSecondRowStripeSize( sal_Int32 nSize )
+{
+ nSecondRowStripeSize = nSize;
+}
+void ScDBDataFormatting::SetFirstColStripeSize( sal_Int32 nSize )
+{
+ nFirstColStripeSize = nSize;
+}
+void ScDBDataFormatting::SetSecondColStripeSize( sal_Int32 nSize )
+{
+ nSecondColStripeSize = nSize;
+}
+
+sal_Int32 ScDBDataFormatting::GetFirstRowStripeSize()
+{
+ return nFirstRowStripeSize;
+}
+
+sal_Int32 ScDBDataFormatting::GetSecondRowStripeSize()
+{
+ return nSecondRowStripeSize;
+}
+
+sal_Int32 ScDBDataFormatting::GetFirstColStripeSize()
+{
+ return nFirstColStripeSize;
+}
+
+sal_Int32 ScDBDataFormatting::GetSecondColStripeSize()
+{
+ return nSecondColStripeSize;
+}
More information about the Libreoffice-commits
mailing list