diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-27 13:35:46 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-11-28 10:01:31 -0500 |
commit | 0ce2977569c5d08e66b325590ee470504afb928f (patch) | |
tree | 2664e1e842391f01b2972629ee693412f8788464 /svtools | |
parent | 3bf14d298342806125e54a075ea4c8ec6132aa38 (diff) |
Extract SvViewData into separate header/source files.
I'll merge it with SvViewDataEntry next...
Change-Id: I542732213f52a3efafaa059dd46668888d4c20f1
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/Library_svt.mk | 1 | ||||
-rw-r--r-- | svtools/inc/svtools/treelist.hxx | 110 | ||||
-rw-r--r-- | svtools/inc/svtools/treelistbox.hxx | 1 | ||||
-rw-r--r-- | svtools/inc/svtools/viewdataentry.hxx | 91 | ||||
-rw-r--r-- | svtools/source/contnr/fileview.cxx | 1 | ||||
-rw-r--r-- | svtools/source/contnr/treelist.cxx | 72 | ||||
-rw-r--r-- | svtools/source/contnr/viewdataentry.cxx | 50 |
7 files changed, 191 insertions, 135 deletions
diff --git a/svtools/Library_svt.mk b/svtools/Library_svt.mk index 7ed5a70e201d..97b7e2e9ec73 100644 --- a/svtools/Library_svt.mk +++ b/svtools/Library_svt.mk @@ -97,6 +97,7 @@ $(eval $(call gb_Library_add_exception_objects,svt,\ svtools/source/contnr/treelist \ svtools/source/contnr/treelistbox \ svtools/source/contnr/treelistentry \ + svtools/source/contnr/viewdataentry \ svtools/source/control/asynclink \ svtools/source/control/calendar \ svtools/source/control/collatorres \ diff --git a/svtools/inc/svtools/treelist.hxx b/svtools/inc/svtools/treelist.hxx index 9886207e817a..1c4d664b271d 100644 --- a/svtools/inc/svtools/treelist.hxx +++ b/svtools/inc/svtools/treelist.hxx @@ -44,71 +44,9 @@ #define LISTACTION_RESORTED 10 #define LISTACTION_CLEARED 11 -// Entryflags that are attached to the View -#define SVLISTENTRYFLAG_SELECTED 0x0001 -#define SVLISTENTRYFLAG_EXPANDED 0x0002 -#define SVLISTENTRYFLAG_FOCUSED 0x0004 -#define SVLISTENTRYFLAG_CURSORED 0x0008 -#define SVLISTENTRYFLAG_NOT_SELECTABLE 0x0010 - class SvTreeListEntry; class SvListView; - -class SvViewData -{ -friend class SvTreeList; -friend class SvListView; - - sal_uLong nVisPos; -protected: - sal_uInt16 nFlags; -public: - SvViewData(); - SvViewData( const SvViewData& ); - virtual ~SvViewData(); - - sal_Bool IsSelected() const - { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_SELECTED) != 0; } - - sal_Bool IsExpanded() const - { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_EXPANDED) != 0; } - - sal_Bool HasFocus() const - { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_FOCUSED) != 0; } - - sal_Bool IsCursored() const - { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_CURSORED) != 0; } - - bool IsSelectable() const - { return (bool)(nFlags & SVLISTENTRYFLAG_NOT_SELECTABLE) == 0; } - - void SetFocus( sal_Bool bFocus) - { - if ( !bFocus ) - nFlags &= (~SVLISTENTRYFLAG_FOCUSED); - else - nFlags |= SVLISTENTRYFLAG_FOCUSED; - } - - void SetCursored( sal_Bool bCursored ) - { - if ( !bCursored ) - nFlags &= (~SVLISTENTRYFLAG_CURSORED); - else - nFlags |= SVLISTENTRYFLAG_CURSORED; - } - - sal_uInt16 GetFlags() const - { return nFlags; } - - void SetSelectable( bool bSelectable ) - { - if( bSelectable ) - nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE); - else - nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE; - } -}; +class SvViewData; enum SvSortMode { SortAscending, SortDescending, SortNone }; @@ -427,52 +365,6 @@ public: virtual void ModelHasEntryInvalidated( SvTreeListEntry* pEntry ); }; -inline sal_Bool SvListView::IsExpanded( SvTreeListEntry* pEntry ) const -{ - DBG_ASSERT(pEntry,"IsExpanded:No Entry"); - SvDataTable::const_iterator itr = maDataTable.find(pEntry); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); - return itr->second->IsExpanded(); -} - -inline sal_Bool SvListView::IsSelected( SvTreeListEntry* pEntry ) const -{ - DBG_ASSERT(pEntry,"IsExpanded:No Entry"); - SvDataTable::const_iterator itr = maDataTable.find(pEntry ); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); - return itr->second->IsSelected(); -} - -inline sal_Bool SvListView::HasEntryFocus( SvTreeListEntry* pEntry ) const -{ - DBG_ASSERT(pEntry,"IsExpanded:No Entry"); - SvDataTable::const_iterator itr = maDataTable.find(pEntry ); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); - return itr->second->HasFocus(); -} - -inline void SvListView::SetEntryFocus( SvTreeListEntry* pEntry, sal_Bool bFocus ) -{ - DBG_ASSERT(pEntry,"SetEntryFocus:No Entry"); - SvDataTable::iterator itr = maDataTable.find(pEntry); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); - itr->second->SetFocus(bFocus); -} - -inline const SvViewData* SvListView::GetViewData( const SvTreeListEntry* pEntry ) const -{ - SvDataTable::const_iterator itr = maDataTable.find( const_cast<SvTreeListEntry*>(pEntry) ); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); - return itr->second; -} - -inline SvViewData* SvListView::GetViewData( SvTreeListEntry* pEntry ) -{ - SvDataTable::iterator itr = maDataTable.find( pEntry ); - DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); - return itr->second; -} - #endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/inc/svtools/treelistbox.hxx b/svtools/inc/svtools/treelistbox.hxx index 549e859cbc62..11e36c1a32f9 100644 --- a/svtools/inc/svtools/treelistbox.hxx +++ b/svtools/inc/svtools/treelistbox.hxx @@ -37,6 +37,7 @@ #include <tools/contnr.hxx> #include <svtools/treelist.hxx> #include <svtools/transfer.hxx> +#include "svtools/viewdataentry.hxx" class Application; class SvTreeListBox; diff --git a/svtools/inc/svtools/viewdataentry.hxx b/svtools/inc/svtools/viewdataentry.hxx new file mode 100644 index 000000000000..769381aff749 --- /dev/null +++ b/svtools/inc/svtools/viewdataentry.hxx @@ -0,0 +1,91 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#ifndef __SVTOOLS_VIEWDATAENTRY_HXX__ +#define __SVTOOLS_VIEWDATAENTRY_HXX__ + +#include "svtdllapi.h" +#include "tools/solar.h" + +// Entryflags that are attached to the View +#define SVLISTENTRYFLAG_SELECTED 0x0001 +#define SVLISTENTRYFLAG_EXPANDED 0x0002 +#define SVLISTENTRYFLAG_FOCUSED 0x0004 +#define SVLISTENTRYFLAG_CURSORED 0x0008 +#define SVLISTENTRYFLAG_NOT_SELECTABLE 0x0010 + +class SVT_DLLPUBLIC SvViewData +{ +friend class SvTreeList; +friend class SvListView; + + sal_uLong nVisPos; +protected: + sal_uInt16 nFlags; +public: + SvViewData(); + SvViewData( const SvViewData& ); + virtual ~SvViewData(); + + sal_Bool IsSelected() const + { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_SELECTED) != 0; } + + sal_Bool IsExpanded() const + { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_EXPANDED) != 0; } + + sal_Bool HasFocus() const + { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_FOCUSED) != 0; } + + sal_Bool IsCursored() const + { return (sal_Bool)(nFlags & SVLISTENTRYFLAG_CURSORED) != 0; } + + bool IsSelectable() const + { return (bool)(nFlags & SVLISTENTRYFLAG_NOT_SELECTABLE) == 0; } + + void SetFocus( sal_Bool bFocus) + { + if ( !bFocus ) + nFlags &= (~SVLISTENTRYFLAG_FOCUSED); + else + nFlags |= SVLISTENTRYFLAG_FOCUSED; + } + + void SetCursored( sal_Bool bCursored ) + { + if ( !bCursored ) + nFlags &= (~SVLISTENTRYFLAG_CURSORED); + else + nFlags |= SVLISTENTRYFLAG_CURSORED; + } + + sal_uInt16 GetFlags() const + { return nFlags; } + + void SetSelectable( bool bSelectable ) + { + if( bSelectable ) + nFlags &= (~SVLISTENTRYFLAG_NOT_SELECTABLE); + else + nFlags |= SVLISTENTRYFLAG_NOT_SELECTABLE; + } +}; + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/svtools/source/contnr/fileview.cxx b/svtools/source/contnr/fileview.cxx index 5233af647014..32fd7d3c8972 100644 --- a/svtools/source/contnr/fileview.cxx +++ b/svtools/source/contnr/fileview.cxx @@ -26,6 +26,7 @@ #include <svtools/headbar.hxx> #include <svtools/svtabbx.hxx> #include <svtools/svtools.hrc> +#include "svtools/viewdataentry.hxx" #include "fileview.hrc" #include "contentenumeration.hxx" #include <svtools/AccessibleBrowseBoxObjType.hxx> diff --git a/svtools/source/contnr/treelist.cxx b/svtools/source/contnr/treelist.cxx index b18f1c05f984..4750c61fae65 100644 --- a/svtools/source/contnr/treelist.cxx +++ b/svtools/source/contnr/treelist.cxx @@ -23,32 +23,6 @@ #include <stdio.h> -DBG_NAME(SvViewData); - -SvViewData::SvViewData() -{ - DBG_CTOR(SvViewData,0); - nFlags = 0; - nVisPos = 0; -} - -SvViewData::SvViewData( const SvViewData& rData ) -{ - DBG_CTOR(SvViewData,0); - nFlags = rData.nFlags; - nFlags &= ~( SVLISTENTRYFLAG_SELECTED | SVLISTENTRYFLAG_FOCUSED ); - nVisPos = rData.nVisPos; -} - -SvViewData::~SvViewData() -{ - DBG_DTOR(SvViewData,0); -#ifdef DBG_UTIL - nVisPos = 0x12345678; - nFlags = 0x1234; -#endif -} - SvTreeList::SvTreeList() { nEntryCount = 0; @@ -1507,6 +1481,52 @@ void SvListView::InitViewData( SvViewData*, SvTreeListEntry* ) { } +sal_Bool SvListView::IsExpanded( SvTreeListEntry* pEntry ) const +{ + DBG_ASSERT(pEntry,"IsExpanded:No Entry"); + SvDataTable::const_iterator itr = maDataTable.find(pEntry); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); + return itr->second->IsExpanded(); +} + +sal_Bool SvListView::IsSelected( SvTreeListEntry* pEntry ) const +{ + DBG_ASSERT(pEntry,"IsExpanded:No Entry"); + SvDataTable::const_iterator itr = maDataTable.find(pEntry ); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); + return itr->second->IsSelected(); +} + +sal_Bool SvListView::HasEntryFocus( SvTreeListEntry* pEntry ) const +{ + DBG_ASSERT(pEntry,"IsExpanded:No Entry"); + SvDataTable::const_iterator itr = maDataTable.find(pEntry ); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); + return itr->second->HasFocus(); +} + +void SvListView::SetEntryFocus( SvTreeListEntry* pEntry, sal_Bool bFocus ) +{ + DBG_ASSERT(pEntry,"SetEntryFocus:No Entry"); + SvDataTable::iterator itr = maDataTable.find(pEntry); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in Table"); + itr->second->SetFocus(bFocus); +} + +const SvViewData* SvListView::GetViewData( const SvTreeListEntry* pEntry ) const +{ + SvDataTable::const_iterator itr = maDataTable.find( const_cast<SvTreeListEntry*>(pEntry) ); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); + return itr->second; +} + +SvViewData* SvListView::GetViewData( SvTreeListEntry* pEntry ) +{ + SvDataTable::iterator itr = maDataTable.find( pEntry ); + DBG_ASSERT(itr != maDataTable.end(),"Entry not in model or wrong view"); + return itr->second; +} + StringCompare SvTreeList::Compare(const SvTreeListEntry* pLeft, const SvTreeListEntry* pRight) const { if( aCompareLink.IsSet()) diff --git a/svtools/source/contnr/viewdataentry.cxx b/svtools/source/contnr/viewdataentry.cxx new file mode 100644 index 000000000000..4508782e2ee4 --- /dev/null +++ b/svtools/source/contnr/viewdataentry.cxx @@ -0,0 +1,50 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* + * This file is part of the LibreOffice project. + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + * + * This file incorporates work covered by the following license notice: + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed + * with this work for additional information regarding copyright + * ownership. The ASF licenses this file to you under the Apache + * License, Version 2.0 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.apache.org/licenses/LICENSE-2.0 . + */ + +#include "svtools/viewdataentry.hxx" + +#include "tools/debug.hxx" + +DBG_NAME(SvViewData); + +SvViewData::SvViewData() +{ + DBG_CTOR(SvViewData,0); + nFlags = 0; + nVisPos = 0; +} + +SvViewData::SvViewData( const SvViewData& rData ) +{ + DBG_CTOR(SvViewData,0); + nFlags = rData.nFlags; + nFlags &= ~( SVLISTENTRYFLAG_SELECTED | SVLISTENTRYFLAG_FOCUSED ); + nVisPos = rData.nVisPos; +} + +SvViewData::~SvViewData() +{ + DBG_DTOR(SvViewData,0); +#ifdef DBG_UTIL + nVisPos = 0x12345678; + nFlags = 0x1234; +#endif +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |