[Libreoffice-commits] core.git: sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Mon Jan 6 09:46:49 PST 2014


 sc/inc/document.hxx                                          |   11 --
 sc/source/core/data/documen2.cxx                             |    3 
 sc/source/ui/Accessibility/AccessibleDocument.cxx            |   46 +++++------
 sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx |   38 +++++----
 sc/source/ui/docshell/docsh.cxx                              |    1 
 sc/source/ui/inc/docsh.hxx                                   |    5 -
 6 files changed, 47 insertions(+), 57 deletions(-)

New commits:
commit b4ea08def28a510212f4de355b384e8542c014d4
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Mon Jan 6 12:45:43 2014 -0500

    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

diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx
index 95443b5..0b7fe1d 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 58310967..8803d25 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 47a5177..993da13 100644
--- a/sc/source/ui/Accessibility/AccessibleDocument.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocument.cxx
@@ -69,6 +69,7 @@
 #include <comphelper/sequence.hxx>
 #include <comphelper/servicehelper.hxx>
 #include <sfx2/viewfrm.hxx>
+#include <sfx2/docfile.hxx>
 #include <svx/unoshcol.hxx>
 #include <svx/unoshape.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
@@ -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 94c28ec..d9abbb9 100644
--- a/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
+++ b/sc/source/ui/Accessibility/AccessibleDocumentPagePreview.cxx
@@ -51,6 +51,7 @@
 #include <svx/unoshape.hxx>
 #include <unotools/accessiblerelationsethelper.hxx>
 #include <vcl/svapp.hxx>
+#include <sfx2/docfile.hxx>
 #include <comphelper/servicehelper.hxx>
 
 #include <vector>
@@ -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 3e18270..01d4736 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 9bff2f0..7e10390 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)


More information about the Libreoffice-commits mailing list