[Libreoffice-commits] core.git: Branch 'feature/gsoc-calc-enhanced-db-range' - sc/inc sc/source
Akash Shetye
shetyeakash at gmail.com
Wed Jul 3 09:49:52 PDT 2013
sc/inc/datauno.hxx | 2 ++
sc/source/filter/inc/workbookhelper.hxx | 4 ++++
sc/source/filter/oox/tablebuffer.cxx | 3 +++
sc/source/filter/oox/workbookhelper.cxx | 15 +++++++++++++++
sc/source/ui/docshell/dbdocfun.cxx | 15 ++++++++++++++-
sc/source/ui/inc/dbdocfun.hxx | 2 ++
sc/source/ui/unoobj/datauno.cxx | 12 ++++++++++++
7 files changed, 52 insertions(+), 1 deletion(-)
New commits:
commit 27d635053cc44a1013b7e5e5c50a11d1d9b39a28
Author: Akash Shetye <shetyeakash at gmail.com>
Date: Wed Jul 3 22:14:22 2013 +0530
Tried to add code for filling in formatting attribute in ScDBData failed
The problem is with the use of XDatabaseRange in the filter import code. We do not deal directly with ScDBData objects. Since I cannot modify the XDatabaseRange definition we need to find a cleverer way to call SetTableFormatting on an ScDBData object. I am kinda stuck here. Please help.
Change-Id: Ia64da4f4c161b88912b97c27ad9f52a86f3564ef
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index 2acde18..0613c79 100644
--- a/sc/inc/datauno.hxx
+++ b/sc/inc/datauno.hxx
@@ -23,6 +23,7 @@
#include "global.hxx"
#include "queryparam.hxx"
#include "subtotalparam.hxx"
+#include "dbdataformatting.hxx"
#include <com/sun/star/sheet/TableFilterField.hpp>
#include <com/sun/star/sheet/GeneralFunction.hpp>
@@ -625,6 +626,7 @@ public:
virtual void SAL_CALL addNewByName( const OUString& aName,
const ::com::sun::star::table::CellRangeAddress& aRange )
throw(::com::sun::star::uno::RuntimeException);
+ virtual void SAL_CALL addDatabaseRangeFormatting( const OUString& aName, const ScDBDataFormatting& rTableFormatData ) throw (::com::sun::star::uno::RuntimeException);
virtual void SAL_CALL removeByName( const OUString& aName )
throw(::com::sun::star::uno::RuntimeException);
diff --git a/sc/source/filter/inc/workbookhelper.hxx b/sc/source/filter/inc/workbookhelper.hxx
index fa1ce19..a3ac4d9 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -25,6 +25,7 @@
#include "oox/helper/storagebase.hxx"
#include "biffhelper.hxx"
#include "rangenam.hxx"
+#include "dbdataformatting.hxx"
namespace com { namespace sun { namespace star {
namespace container { class XNameAccess; }
@@ -197,6 +198,9 @@ public:
OUString& orName,
const ::com::sun::star::table::CellRangeAddress& rRangeAddr ) const;
+ /** Allows setting the table(database range) formatting attribute of ScDBData instances*/
+ void addDatabaseFormatting( const OUString& rName, const ScDBDataFormatting& rDBDataFormatting );
+
/** Creates and returns an unnamed database range on-the-fly in the Calc document.
The range will not be buffered in the global table buffer. */
::com::sun::star::uno::Reference< ::com::sun::star::sheet::XDatabaseRange >
diff --git a/sc/source/filter/oox/tablebuffer.cxx b/sc/source/filter/oox/tablebuffer.cxx
index c4580c6..b1b930d 100644
--- a/sc/source/filter/oox/tablebuffer.cxx
+++ b/sc/source/filter/oox/tablebuffer.cxx
@@ -111,8 +111,11 @@ void Table::finalizeImport()
//Setting the ScDBDataFormatting (Table style) attribute.
ScDBDataFormatting aTableFormatting = getStyles().getTableStyle( maModel.maTableStyleName )->getTableFormatting(); //May fail in cases of malformed corrupt table/table#.xml where the maTableStyleName is messed up
+
+ //can mess up if aTableFormatting is nothing. Need to handle that
aTableFormatting.SetBandedRows( maModel.mbShowRowStripes );
aTableFormatting.SetBandedColumns( maModel.mbShowColumnStripes );
+ addDatabaseFormatting( maDBRangeName, aTableFormatting );
//Add this table formatting information to the ScDBData instance.
//xDatabaseRange->SetTableFormatting( aTableFormatting );
//Still figuring how to have an ScDBData object out of this
diff --git a/sc/source/filter/oox/workbookhelper.cxx b/sc/source/filter/oox/workbookhelper.cxx
index 6ab4eca..ade4821 100644
--- a/sc/source/filter/oox/workbookhelper.cxx
+++ b/sc/source/filter/oox/workbookhelper.cxx
@@ -174,6 +174,8 @@ public:
ScRangeData* createLocalNamedRangeObject( OUString& orName, const Sequence< FormulaToken>& rTokens, sal_Int32 nIndex, sal_Int32 nNameFlags, sal_Int32 nTab ) const;
/** Creates and returns a database range on-the-fly in the Calc document. */
Reference< XDatabaseRange > createDatabaseRangeObject( OUString& orName, const CellRangeAddress& rRangeAddr ) const;
+ /** Adds a DBData formatting object to a DB Range's formatting attribute*/
+ void addDatabaseFormatting( const OUString& rName, const ScDBDataFormatting& rDBDataFormatting );
/** Creates and returns an unnamed database range on-the-fly in the Calc document. */
Reference< XDatabaseRange > createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const;
/** Creates and returns a com.sun.star.style.Style object for cells or pages. */
@@ -461,6 +463,14 @@ Reference< XDatabaseRange > WorkbookGlobals::createDatabaseRangeObject( OUString
return xDatabaseRange;
}
+void WorkbookGlobals::addDatabaseFormatting( const OUString& rName, const ScDBDataFormatting& rDBDataFormatting )
+{
+ PropertySet aDocProps( mxDoc );
+ Reference< XDatabaseRanges > xDatabaseRanges( aDocProps.getAnyProperty( PROP_DatabaseRanges ), UNO_QUERY_THROW );
+ //xDatabaseRanges->addDatabaseRangeFormatting( rName, rDBDataFormatting );
+ //Need some way to add the formatting information. Stuck here major.
+}
+
Reference< XDatabaseRange > WorkbookGlobals::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
{
// validate cell range
@@ -797,6 +807,11 @@ Reference< XDatabaseRange > WorkbookHelper::createDatabaseRangeObject( OUString&
return mrBookGlob.createDatabaseRangeObject( orName, rRangeAddr );
}
+void WorkbookHelper::addDatabaseFormatting( const OUString& rName, const ScDBDataFormatting& rDBDataFormatting )
+{
+ mrBookGlob.addDatabaseFormatting( rName, rDBDataFormatting );
+}
+
Reference< XDatabaseRange > WorkbookHelper::createUnnamedDatabaseRangeObject( const CellRangeAddress& rRangeAddr ) const
{
return mrBookGlob.createUnnamedDatabaseRangeObject( rRangeAddr );
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index 5a4b6fd..e022c01 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -57,7 +57,6 @@ using namespace ::com::sun::star;
bool ScDBDocFunc::AddDBRange( const OUString& rName, const ScRange& rRange, sal_Bool /* bApi */ )
{
-
ScDocShellModificator aModificator( rDocShell );
ScDocument* pDoc = rDocShell.GetDocument();
@@ -191,6 +190,20 @@ bool ScDBDocFunc::RenameDBRange( const String& rOld, const String& rNew )
return bDone;
}
+bool ScDBDocFunc::AddDBFormatting( const OUString& rName, const ScDBDataFormatting& rDBFormatting )
+{
+ ScDocument* pDoc = rDocShell.GetDocument();
+ ScDBCollection* pDocColl = pDoc->GetDBCollection();
+ ScDBCollection::NamedDBs& rDBs = pDocColl->getNamedDBs();
+ ScDBData* pDBData = rDBs.findByUpperName(ScGlobal::pCharClass->uppercase(rName));
+ if( pDBData )
+ {
+ pDBData->SetTableFormatting( rDBFormatting );
+ return true;
+ }
+ return false;
+}
+
bool ScDBDocFunc::ModifyDBData( const ScDBData& rNewData )
{
bool bDone = false;
diff --git a/sc/source/ui/inc/dbdocfun.hxx b/sc/source/ui/inc/dbdocfun.hxx
index 10a38df..5b97dac 100644
--- a/sc/source/ui/inc/dbdocfun.hxx
+++ b/sc/source/ui/inc/dbdocfun.hxx
@@ -21,6 +21,7 @@
#define SC_DBDOCFUN_HXX
#include "address.hxx"
+#include "dbdataformatting.hxx"
#include <tools/solar.h>
#include <com/sun/star/uno/Sequence.hxx>
@@ -85,6 +86,7 @@ public:
bool AddDBRange( const OUString& rName, const ScRange& rRange, sal_Bool bApi );
bool DeleteDBRange( const OUString& rName );
bool RenameDBRange( const String& rOld, const String& rNew );
+ bool AddDBFormatting( const OUString& rName, const ScDBDataFormatting& rDBFormatting );
bool ModifyDBData( const ScDBData& rNewData ); // Name unveraendert
bool RepeatDB( const OUString& rDBName, bool bRecord, bool bApi, bool bIsUnnamed=false, SCTAB aTab = 0);
diff --git a/sc/source/ui/unoobj/datauno.cxx b/sc/source/ui/unoobj/datauno.cxx
index 079e97b..8412b75 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -2314,6 +2314,18 @@ void SAL_CALL ScDatabaseRangesObj::addNewByName( const OUString& aName,
throw uno::RuntimeException(); // no other exceptions specified
}
+void SAL_CALL ScDatabaseRangesObj::addDatabaseRangeFormatting( const OUString& rName, const ScDBDataFormatting& rTableFormatData ) throw (uno::RuntimeException)
+{
+ bool bDone = false;
+ if( pDocShell )
+ {
+ ScDBDocFunc aFunc( *pDocShell );
+ bDone = (aFunc.AddDBFormatting( rName, rTableFormatData ));
+ }
+ if( !bDone )
+ throw uno::RuntimeException();
+}
+
void SAL_CALL ScDatabaseRangesObj::removeByName( const OUString& aName )
throw(uno::RuntimeException)
{
More information about the Libreoffice-commits
mailing list