From b4ea08def28a510212f4de355b384e8542c014d4 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Mon, 6 Jan 2014 12:45:43 -0500 Subject: Try not to use ScDocument as a "anything can go in" storage place. There are things that shouldn't be stored in ScDocument believe it or not. Change-Id: I6a06327549851fae0fdc0defbc716285d8456aa2 --- sc/inc/document.hxx | 11 ------ sc/source/core/data/documen2.cxx | 3 +- sc/source/ui/Accessibility/AccessibleDocument.cxx | 46 ++++++++++++---------- .../AccessibleDocumentPagePreview.cxx | 38 ++++++++++-------- sc/source/ui/docshell/docsh.cxx | 1 - sc/source/ui/inc/docsh.hxx | 5 --- 6 files changed, 47 insertions(+), 57 deletions(-) diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index 95443b5d9745..0b7fe1d1ae18 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -443,18 +443,7 @@ private: bool mbUseEmbedFonts; - OUString msDocAccTitle; - -public: - void setDocAccTitle( const OUString& rTitle ) { msDocAccTitle = rTitle; } - const OUString getDocAccTitle() const { return msDocAccTitle; } - -private: - bool mbReadOnly; - public: - void setDocReadOnly(bool b){ mbReadOnly = b; } - bool getDocReadOnly() const { return mbReadOnly; } sal_Bool IsCellInChangeTrack(const ScAddress &cell,Color *pColCellBoder); void GetCellChangeTrackNote(const ScAddress &cell, OUString &strTrackText, sal_Bool &pbLeftEdge); bool IsUsingEmbededFonts() { return mbUseEmbedFonts; } diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 583109677d90..8803d256ab07 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -220,8 +220,7 @@ ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mbStreamValidLocked( false ), mbUserInteractionEnabled(true), mnNamedRangesLockCount(0), - mbUseEmbedFonts(false), - mbReadOnly(false) + mbUseEmbedFonts(false) { SetStorageGrammar( formula::FormulaGrammar::GRAM_STORAGE_DEFAULT); diff --git a/sc/source/ui/Accessibility/AccessibleDocument.cxx b/sc/source/ui/Accessibility/AccessibleDocument.cxx index 47a5177c9b39..993da134ce57 100644 --- a/sc/source/ui/Accessibility/AccessibleDocument.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx @@ -69,6 +69,7 @@ #include #include #include +#include #include #include #include @@ -1859,30 +1860,33 @@ OUString SAL_CALL ScAccessibleDocument::getAccessibleName(void) throw (::com::sun::star::uno::RuntimeException) { - OUString sName = ScResId(STR_ACC_DOC_SPREADSHEET); + OUString aName = ScResId(STR_ACC_DOC_SPREADSHEET); ScDocument* pScDoc = GetDocument(); - if ( pScDoc ) + if (!pScDoc) + return aName; + + SfxObjectShell* pObjSh = pScDoc->GetDocumentShell(); + if (!pObjSh) + return aName; + + OUString aFileName; + SfxMedium* pMed = pObjSh->GetMedium(); + if (pMed) + aFileName = pMed->GetName(); + + if (aFileName.isEmpty()) + aFileName = pObjSh->GetTitle(SFX_TITLE_APINAME); + + + if (!aFileName.isEmpty()) { - OUString sFileName = pScDoc->getDocAccTitle(); - if ( !sFileName.getLength() ) - { - SfxObjectShell* pObjSh = pScDoc->GetDocumentShell(); - if ( pObjSh ) - { - sFileName = pObjSh->GetTitle( SFX_TITLE_APINAME ); - } - } - OUString sReadOnly; - if (pScDoc->getDocReadOnly()) - { - sReadOnly = ScResId(STR_ACC_DOC_SPREADSHEET_READONLY); - } - if ( sFileName.getLength() ) - { - sName = sFileName + sReadOnly + " - " + sName; - } + OUString aReadOnly; + if (pObjSh->IsReadOnly()) + aReadOnly = ScResId(STR_ACC_DOC_SPREADSHEET_READONLY); + + aName = aFileName + aReadOnly + " - " + aName; } - return sName; + return aName; } ///===== XAccessibleSelection =========================================== diff --git a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx index 94c28ecc4d53..d9abbb9c0fd8 100644 --- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx +++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx @@ -51,6 +51,7 @@ #include #include #include +#include #include #include @@ -1699,28 +1700,31 @@ ScShapeChildren* ScAccessibleDocumentPagePreview::GetShapeChildren() OUString ScAccessibleDocumentPagePreview::getAccessibleName(void) throw (::com::sun::star::uno::RuntimeException) { - OUString sName = ScResId(STR_ACC_DOC_SPREADSHEET); + OUString aName = ScResId(STR_ACC_DOC_SPREADSHEET); ScDocument* pScDoc = mpViewShell->GetDocument(); - if ( pScDoc ) + if (!pScDoc) + return aName; + + SfxObjectShell* pObjSh = pScDoc->GetDocumentShell(); + if (!pObjSh) + return aName; + + OUString aFileName; + SfxMedium* pMed = pObjSh->GetMedium(); + if (pMed) + aFileName = pMed->GetName(); + + if (aFileName.isEmpty()) + aFileName = pObjSh->GetTitle(SFX_TITLE_APINAME); + + if (!aFileName.isEmpty()) { - OUString sFileName = pScDoc->getDocAccTitle(); - if ( !sFileName.getLength() ) - { - SfxObjectShell* pObjSh = pScDoc->GetDocumentShell(); - if ( pObjSh ) - { - sFileName = pObjSh->GetTitle( SFX_TITLE_APINAME ); - } - } - if ( sFileName.getLength() ) - { - sName = sFileName + " - " + sName; - sName += ScResId(STR_ACC_DOC_PREVIEW_SUFFIX); + aName = aFileName + " - " + aName; + aName += ScResId(STR_ACC_DOC_PREVIEW_SUFFIX); - } } - return sName; + return aName; } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/ui/docshell/docsh.cxx b/sc/source/ui/docshell/docsh.cxx index 3e182701fce8..01d473605480 100644 --- a/sc/source/ui/docshell/docsh.cxx +++ b/sc/source/ui/docshell/docsh.cxx @@ -1606,7 +1606,6 @@ sal_Bool ScDocShell::Save() PrepareSaveGuard aPrepareGuard( *this); - aDocument.setDocAccTitle(OUString()); SfxViewFrame* pFrame1 = SfxViewFrame::GetFirst( this ); if (pFrame1) { diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 9bff2f06ad78..7e103902fb1f 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -423,11 +423,6 @@ public: void SetSolverSaveData( const ScOptSolverSave& rData ); ScSheetSaveData* GetSheetSaveData(); - void setDocAccTitle( const OUString& rTitle ) { aDocument.setDocAccTitle( rTitle ); } - const OUString getDocAccTitle() const { return aDocument.getDocAccTitle(); } - void setDocReadOnly(bool b) { aDocument.setDocReadOnly(b); } - bool getDocReadOnly() const { return aDocument.getDocReadOnly(); } - void ResetKeyBindings( ScOptionsUtil::KeyBindingType eType ); // password protection for Calc (derived from SfxObjectShell) -- cgit