[Libreoffice-commits] .: Branch 'feature/calc-xml-source' - sc/inc sc/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Wed Oct 3 07:33:19 PDT 2012


 sc/inc/orcusfilters.hxx                     |    5 ++++-
 sc/source/filter/inc/orcusfiltersimpl.hxx   |    4 +++-
 sc/source/filter/orcus/orcusfiltersimpl.cxx |   17 +++++++++++++----
 sc/source/ui/inc/xmlsourcedlg.hxx           |    4 ++--
 sc/source/ui/src/xmlsourcedlg.src           |    6 ++++++
 sc/source/ui/xmlsource/xmlsourcedlg.cxx     |   12 ++++--------
 6 files changed, 32 insertions(+), 16 deletions(-)

New commits:
commit 159319f96eeb88bc11b86ea2bfd47d90a3bd050a
Author: Kohei Yoshida <kohei.yoshida at gmail.com>
Date:   Wed Oct 3 10:33:09 2012 -0400

    Use different icon for recurring elements.
    
    Change-Id: I3869e4a1f2f4b68d57641395daaf79d911a1a891

diff --git a/sc/inc/orcusfilters.hxx b/sc/inc/orcusfilters.hxx
index 2379c67..2ec5a49 100644
--- a/sc/inc/orcusfilters.hxx
+++ b/sc/inc/orcusfilters.hxx
@@ -14,6 +14,7 @@
 
 class ScDocument;
 class SvTreeListBox;
+class Image;
 
 /**
  * Collection of orcus filter wrappers.
@@ -25,7 +26,9 @@ public:
 
     virtual bool importCSV(ScDocument& rDoc, const rtl::OUString& rPath) const = 0;
 
-    virtual bool loadXMLStructure(const rtl::OUString& rPath, SvTreeListBox& rTree) const = 0;
+    virtual bool loadXMLStructure(
+       SvTreeListBox& rTreeCtrl, const rtl::OUString& rPath,
+       const Image& rImgDefaultElem, const Image& rImgRepeatElem) const = 0;
 };
 
 #endif
diff --git a/sc/source/filter/inc/orcusfiltersimpl.hxx b/sc/source/filter/inc/orcusfiltersimpl.hxx
index f51f00f..311b6e0 100644
--- a/sc/source/filter/inc/orcusfiltersimpl.hxx
+++ b/sc/source/filter/inc/orcusfiltersimpl.hxx
@@ -17,7 +17,9 @@ class ScOrcusFiltersImpl : public ScOrcusFilters
 public:
     virtual bool importCSV(ScDocument& rDoc, const rtl::OUString& rPath) const;
 
-    virtual bool loadXMLStructure(const rtl::OUString& rPath, SvTreeListBox& rTree) const;
+    virtual bool loadXMLStructure(
+       SvTreeListBox& rTreeCtrl, const rtl::OUString& rPath,
+       const Image& rImgDefaultElem, const Image& rImgRepeatElem) const;
 };
 
 #endif
diff --git a/sc/source/filter/orcus/orcusfiltersimpl.cxx b/sc/source/filter/orcus/orcusfiltersimpl.cxx
index 721e5ee..8453043 100644
--- a/sc/source/filter/orcus/orcusfiltersimpl.cxx
+++ b/sc/source/filter/orcus/orcusfiltersimpl.cxx
@@ -175,12 +175,18 @@ bool ScOrcusFiltersImpl::importCSV(ScDocument& rDoc, const OUString& rPath) cons
 
 void populateTree(
    SvTreeListBox& rTreeCtrl, orcus::xml_structure_tree::walker& rWalker,
-   const orcus::xml_structure_tree::element_name& rElemName, bool bRepeat, SvLBoxEntry* pParent)
+   const orcus::xml_structure_tree::element_name& rElemName, bool bRepeat, const Image& rImgRepeatElem, SvLBoxEntry* pParent)
 {
     // TODO: Make use of bRepeat flag.
 
     OUString aName(rElemName.name.get(), rElemName.name.size(), RTL_TEXTENCODING_UTF8);
     SvLBoxEntry* pEntry = rTreeCtrl.InsertEntry(aName, pParent);
+    if (bRepeat)
+    {
+        rTreeCtrl.SetExpandedEntryBmp(pEntry, rImgRepeatElem);
+        rTreeCtrl.SetCollapsedEntryBmp(pEntry, rImgRepeatElem);
+    }
+
     if (pParent)
         rTreeCtrl.Expand(pParent);
 
@@ -192,12 +198,13 @@ void populateTree(
     for (; it != itEnd; ++it)
     {
         orcus::xml_structure_tree::element aElem = rWalker.descend(*it);
-        populateTree(rTreeCtrl, rWalker, *it, aElem.repeat, pEntry);
+        populateTree(rTreeCtrl, rWalker, *it, aElem.repeat, rImgRepeatElem, pEntry);
         rWalker.ascend();
     }
 }
 
-bool ScOrcusFiltersImpl::loadXMLStructure(const OUString& rPath, SvTreeListBox& rTreeCtrl) const
+bool ScOrcusFiltersImpl::loadXMLStructure(
+   SvTreeListBox& rTreeCtrl, const rtl::OUString& rPath, const Image& rImgDefaultElem, const Image& rImgRepeatElem) const
 {
     INetURLObject aURL(rPath);
     OString aSysPath = rtl::OUStringToOString(aURL.getFSysPath(SYSTEM_PATH), RTL_TEXTENCODING_UTF8);
@@ -217,12 +224,14 @@ bool ScOrcusFiltersImpl::loadXMLStructure(const OUString& rPath, SvTreeListBox&
         aXmlTree.parse(&aStrm[0], aStrm.size());
 
         rTreeCtrl.Clear();
+        rTreeCtrl.SetDefaultCollapsedEntryBmp(rImgDefaultElem);
+        rTreeCtrl.SetDefaultExpandedEntryBmp(rImgDefaultElem);
 
         orcus::xml_structure_tree::walker aWalker = aXmlTree.get_walker();
 
         // Root element.
         orcus::xml_structure_tree::element aElem = aWalker.root();
-        populateTree(rTreeCtrl, aWalker, aElem.name, aElem.repeat, NULL);
+        populateTree(rTreeCtrl, aWalker, aElem.name, aElem.repeat, rImgRepeatElem, NULL);
     }
     catch (const std::exception&)
     {
diff --git a/sc/source/ui/inc/xmlsourcedlg.hxx b/sc/source/ui/inc/xmlsourcedlg.hxx
index 6e32d12..b6fb2ba 100644
--- a/sc/source/ui/inc/xmlsourcedlg.hxx
+++ b/sc/source/ui/inc/xmlsourcedlg.hxx
@@ -23,8 +23,6 @@ class ScDocument;
 
 class ScXMLSourceTree : public SvTreeListBox
 {
-    Image maImgElemDefault;
-    Image maImgElemRepeat;
 public:
     ScXMLSourceTree(Window* pParent, const ResId& rResId);
 };
@@ -42,6 +40,8 @@ class ScXMLSourceDlg : public ModalDialog
     CancelButton maBtnCancel;
 
     Image maImgFileOpen;
+    Image maImgElemDefault;
+    Image maImgElemRepeat;
 
     ScDocument* mpDoc;
 
diff --git a/sc/source/ui/src/xmlsourcedlg.src b/sc/source/ui/src/xmlsourcedlg.src
index f55110b..564b9d1 100644
--- a/sc/source/ui/src/xmlsourcedlg.src
+++ b/sc/source/ui/src/xmlsourcedlg.src
@@ -62,6 +62,12 @@ ModalDialog RID_SCDLG_XML_SOURCE
         MaskColor = STD_MASKCOLOR ;
     };
 
+    Image IMG_ELEMENT_REPEAT
+    {
+        ImageBitmap = Bitmap { File = "pages.png" ; };
+        MaskColor = STD_MASKCOLOR ;
+    };
+
     Image IMG_FILE_OPEN
     {
         ImageBitmap = Bitmap { File = "file.png" ; };
diff --git a/sc/source/ui/xmlsource/xmlsourcedlg.cxx b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
index 39ccbe5..7f0a48b 100644
--- a/sc/source/ui/xmlsource/xmlsourcedlg.cxx
+++ b/sc/source/ui/xmlsource/xmlsourcedlg.cxx
@@ -23,13 +23,7 @@ using namespace com::sun::star;
 
 
 ScXMLSourceTree::ScXMLSourceTree(Window* pParent, const ResId& rResId) :
-    SvTreeListBox(pParent, rResId),
-    maImgElemDefault(ScResId(IMG_ELEMENT_DEFAULT)),
-    maImgElemRepeat(ScResId(IMG_ELEMENT_REPEAT))
-{
-    SetDefaultExpandedEntryBmp(maImgElemDefault);
-    SetDefaultCollapsedEntryBmp(maImgElemDefault);
-}
+    SvTreeListBox(pParent, rResId) {}
 
 ScXMLSourceDlg::ScXMLSourceDlg(Window* pParent, ScDocument* pDoc) :
     ModalDialog(pParent, ScResId(RID_SCDLG_XML_SOURCE)),
@@ -40,6 +34,8 @@ ScXMLSourceDlg::ScXMLSourceDlg(Window* pParent, ScDocument* pDoc) :
     maLbTree(this, ScResId(LB_SOURCE_TREE)),
     maBtnCancel(this, ScResId(BTN_CANCEL)),
     maImgFileOpen(ScResId(IMG_FILE_OPEN)),
+    maImgElemDefault(ScResId(IMG_ELEMENT_DEFAULT)),
+    maImgElemRepeat(ScResId(IMG_ELEMENT_REPEAT)),
     mpDoc(pDoc)
 {
     maBtnSelectSource.SetModeImage(maImgFileOpen);
@@ -84,7 +80,7 @@ void ScXMLSourceDlg::LoadSourceFileStructure(const OUString& rPath)
     if (!pOrcus)
         return;
 
-    pOrcus->loadXMLStructure(rPath, maLbTree);
+    pOrcus->loadXMLStructure(maLbTree, rPath, maImgElemDefault, maImgElemRepeat);
 }
 
 IMPL_LINK(ScXMLSourceDlg, BtnPressedHdl, Button*, pBtn)


More information about the Libreoffice-commits mailing list