summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkash Shetye <shetyeakash@gmail.com>2013-07-03 22:14:22 +0530
committerKohei Yoshida <kohei.yoshida@gmail.com>2013-08-05 14:30:21 -0400
commit4a3b09cf9dbd07d01c4ba36c8c9f0031a5219ef8 (patch)
tree2f3d8a501f1170ff38eeb79e5141fdd29c98bc40
parent13989c3d07d24f192dc12eb4c665905d8728a473 (diff)
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
-rw-r--r--sc/inc/datauno.hxx2
-rw-r--r--sc/source/filter/inc/workbookhelper.hxx4
-rw-r--r--sc/source/filter/oox/tablebuffer.cxx3
-rw-r--r--sc/source/filter/oox/workbookhelper.cxx15
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx15
-rw-r--r--sc/source/ui/inc/dbdocfun.hxx2
-rw-r--r--sc/source/ui/unoobj/datauno.cxx12
7 files changed, 52 insertions, 1 deletions
diff --git a/sc/inc/datauno.hxx b/sc/inc/datauno.hxx
index a2562c21f7bf..d0e01b5ed8e4 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>
@@ -624,6 +625,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 f4ce1cc1e37c..1fb611633aa7 100644
--- a/sc/source/filter/inc/workbookhelper.hxx
+++ b/sc/source/filter/inc/workbookhelper.hxx
@@ -26,6 +26,7 @@
#include "oox/drawingml/chart/chartconverter.hxx"
#include "biffhelper.hxx"
#include "rangenam.hxx"
+#include "dbdataformatting.hxx"
namespace com { namespace sun { namespace star {
namespace container { class XNameAccess; }
@@ -199,6 +200,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 c4580c65e456..b1b930d13406 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 37d5191e3a93..0c60d8518fcf 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. */
@@ -463,6 +465,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
@@ -807,6 +817,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 1c35fd65f02f..fd0b74aad476 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 10a38dfb0e15..5b97dac07014 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 23cf3da9c0b6..c2746eedb89b 100644
--- a/sc/source/ui/unoobj/datauno.cxx
+++ b/sc/source/ui/unoobj/datauno.cxx
@@ -2285,6 +2285,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)
{