summaryrefslogtreecommitdiff
path: root/sc/source/ui/docshell
diff options
context:
space:
mode:
authorobo <obo@openoffice.org>2010-06-23 13:54:50 +0200
committerobo <obo@openoffice.org>2010-06-23 13:54:50 +0200
commit99785733db84e98dbac03d6be0879908955cbc3c (patch)
treea6e8cecb2a75bb6bcd9542e7fd18ae6b5700c18e /sc/source/ui/docshell
parentb3579d71c6536ab1d03cc47249d582a574fd054a (diff)
parent829b756e967201a2642ba3303aafbaac074037d4 (diff)
CWS-TOOLING: integrate CWS calc55
Diffstat (limited to 'sc/source/ui/docshell')
-rw-r--r--sc/source/ui/docshell/dbdocfun.cxx7
-rwxr-xr-xsc/source/ui/docshell/docsh.cxx59
-rw-r--r--sc/source/ui/docshell/docsh2.cxx2
-rw-r--r--sc/source/ui/docshell/docsh3.cxx10
4 files changed, 75 insertions, 3 deletions
diff --git a/sc/source/ui/docshell/dbdocfun.cxx b/sc/source/ui/docshell/dbdocfun.cxx
index e3f94199612a..cf149d258062 100644
--- a/sc/source/ui/docshell/dbdocfun.cxx
+++ b/sc/source/ui/docshell/dbdocfun.cxx
@@ -1278,6 +1278,13 @@ BOOL ScDBDocFunc::DataPilotUpdate( ScDPObject* pOldObj, const ScDPObject* pNewOb
// output range must be set at pNewObj
pDestObj = new ScDPObject( *pNewObj );
+
+ // #i94570# When changing the output position in the dialog, a new table is created
+ // with the settings from the old table, including the name.
+ // So we have to check for duplicate names here (before inserting).
+ if ( pDoc->GetDPCollection()->GetByName(pDestObj->GetName()) )
+ pDestObj->SetName( String() ); // ignore the invalid name, create a new name below
+
pDestObj->SetAlive(TRUE);
if ( !pDoc->GetDPCollection()->InsertNewTable(pDestObj) )
{
diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx
index 9c45fc0093a1..a446c86b4d1b 100755
--- a/sc/source/ui/docshell/docsh.cxx
+++ b/sc/source/ui/docshell/docsh.cxx
@@ -69,6 +69,9 @@
#include "chgviset.hxx"
#include <sfx2/request.hxx>
#include <com/sun/star/document/UpdateDocMode.hpp>
+#include <com/sun/star/container/XContentEnumerationAccess.hpp>
+#include <com/sun/star/sheet/XSpreadsheetView.hpp>
+#include <com/sun/star/task/XJob.hpp>
#include "scabstdlg.hxx" //CHINA001
@@ -352,6 +355,20 @@ void ScDocShell::AfterXMLLoading(sal_Bool bRet)
// else; nothing has to happen, because it is a user given name
}
}
+
+ // #i94570# DataPilot table names have to be unique, or the tables can't be accessed by API.
+ // If no name (or an invalid name, skipped in ScXMLDataPilotTableContext::EndElement) was set, create a new name.
+ ScDPCollection* pDPCollection = aDocument.GetDPCollection();
+ if ( pDPCollection )
+ {
+ USHORT nDPCount = pDPCollection->GetCount();
+ for (USHORT nDP=0; nDP<nDPCount; nDP++)
+ {
+ ScDPObject* pDPObj = (*pDPCollection)[nDP];
+ if ( !pDPObj->GetName().Len() )
+ pDPObj->SetName( pDPCollection->CreateNewName() );
+ }
+ }
}
ScColumn::bDoubleAlloc = sal_False;
}
@@ -458,7 +475,7 @@ BOOL __EXPORT ScDocShell::Load( SfxMedium& rMedium )
// only the latin script language is loaded
// -> initialize the others from options (before loading)
- InitOptions();
+ InitOptions(true);
GetUndoManager()->Clear();
@@ -582,6 +599,46 @@ void __EXPORT ScDocShell::Notify( SfxBroadcaster&, const SfxHint& rHint )
}
}
}
+
+ try
+ {
+ uno::Reference< uno::XComponentContext > xContext;
+ uno::Reference< lang::XMultiServiceFactory > xServiceManager = ::comphelper::getProcessServiceFactory();
+ uno::Reference< beans::XPropertySet > xProp( xServiceManager, uno::UNO_QUERY_THROW );
+ xProp->getPropertyValue( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "DefaultContext" ) ) ) >>= xContext;
+ if ( xContext.is() )
+ {
+ uno::Reference< container::XContentEnumerationAccess > xEnumAccess( xServiceManager, uno::UNO_QUERY_THROW );
+ uno::Reference< container::XEnumeration> xEnum = xEnumAccess->createContentEnumeration(
+ ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.sheet.SpreadsheetDocumentJob" ) ) );
+ if ( xEnum.is() )
+ {
+ while ( xEnum->hasMoreElements() )
+ {
+ uno::Any aAny = xEnum->nextElement();
+ uno::Reference< lang::XSingleComponentFactory > xFactory;
+ aAny >>= xFactory;
+ if ( xFactory.is() )
+ {
+ uno::Reference< task::XJob > xJob( xFactory->createInstanceWithContext( xContext ), uno::UNO_QUERY_THROW );
+ uno::Sequence< beans::NamedValue > aArgsForJob(1);
+ ScViewData* pViewData = GetViewData();
+ SfxViewShell* pViewShell = ( pViewData ? pViewData->GetViewShell() : NULL );
+ SfxViewFrame* pViewFrame = ( pViewShell ? pViewShell->GetViewFrame() : NULL );
+ SfxFrame* pFrame = ( pViewFrame ? &pViewFrame->GetFrame() : NULL );
+ uno::Reference< frame::XController > xController = ( pFrame ? pFrame->GetController() : 0 );
+ uno::Reference< sheet::XSpreadsheetView > xSpreadsheetView( xController, uno::UNO_QUERY_THROW );
+ aArgsForJob[0] = beans::NamedValue( ::rtl::OUString::createFromAscii( "SpreadsheetView" ),
+ uno::makeAny( xSpreadsheetView ) );
+ xJob->execute( aArgsForJob );
+ }
+ }
+ }
+ }
+ }
+ catch ( uno::Exception & )
+ {
+ }
}
break;
case SFX_EVENT_SAVEDOC:
diff --git a/sc/source/ui/docshell/docsh2.cxx b/sc/source/ui/docshell/docsh2.cxx
index 9e3ed217382f..14ff7622818c 100644
--- a/sc/source/ui/docshell/docsh2.cxx
+++ b/sc/source/ui/docshell/docsh2.cxx
@@ -93,7 +93,7 @@ BOOL __EXPORT ScDocShell::InitNew( const uno::Reference < embed::XStorage >& xSt
aDocument.SetDrawDefaults(); // drawing layer defaults that are set only in InitNew
// InitOptions sets the document languages, must be called before CreateStandardStyles
- InitOptions();
+ InitOptions(false);
aDocument.GetStyleSheetPool()->CreateStandardStyles();
aDocument.UpdStlShtPtrsFrmNms();
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 4709a065792f..233843935bbd 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -424,7 +424,7 @@ double ScDocShell::GetOutputFactor() const
//---------------------------------------------------------------------
-void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs)
+void ScDocShell::InitOptions(bool bForLoading) // called from InitNew and Load
{
// Einstellungen aus dem SpellCheckCfg kommen in Doc- und ViewOptions
@@ -440,6 +440,14 @@ void ScDocShell::InitOptions() // Fortsetzung von InitNew (CLOOKs)
// zweistellige Jahreszahleneingabe aus Extras->Optionen->Allgemein->Sonstiges
aDocOpt.SetYear2000( sal::static_int_cast<USHORT>( ::utl::MiscCfg().GetYear2000() ) );
+ if (bForLoading)
+ {
+ // #i112123# No style:decimal-places attribute means automatic decimals, not the configured default,
+ // so it must not be taken from the global options.
+ // Calculation settings are handled separately in ScXMLBodyContext::EndElement.
+ aDocOpt.SetStdPrecision( SvNumberFormatter::UNLIMITED_PRECISION );
+ }
+
aDocument.SetDocOptions( aDocOpt );
aDocument.SetViewOptions( aViewOpt );