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/source/ui/Accessibility/AccessibleDocument.cxx | 46 ++++++++++++----------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'sc/source/ui/Accessibility/AccessibleDocument.cxx') 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 =========================================== -- cgit