summaryrefslogtreecommitdiff
path: root/sc/source/ui/view/cellsh1.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'sc/source/ui/view/cellsh1.cxx')
-rw-r--r--sc/source/ui/view/cellsh1.cxx30
1 files changed, 25 insertions, 5 deletions
diff --git a/sc/source/ui/view/cellsh1.cxx b/sc/source/ui/view/cellsh1.cxx
index 7722f9ca1c1b..45c47ef492b7 100644
--- a/sc/source/ui/view/cellsh1.cxx
+++ b/sc/source/ui/view/cellsh1.cxx
@@ -17,6 +17,7 @@
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
+#include <globalnames.hxx>
#include <config_features.h>
#include <com/sun/star/i18n/TextConversionOption.hpp>
@@ -2794,12 +2795,31 @@ void ScCellShell::ExecuteDataPilotDialog()
pTabViewShell->GetFrameWeld(), bEnableExt));
// Populate named ranges (if any).
- ScRangeName* pRangeName = pDoc->GetRangeName();
- if (pRangeName)
+ // We must take into account 2 types of scope : global doc and sheets
+ // for global doc: <name of the range>
+ // for sheets: <sheetname>.<name of the range>
+ std::map<OUString, ScRangeName*> aRangeMap;
+ pDoc->GetRangeNameMap(aRangeMap);
+ for (auto const& elemRangeMap : aRangeMap)
{
- ScRangeName::const_iterator itr = pRangeName->begin(), itrEnd = pRangeName->end();
- for (; itr != itrEnd; ++itr)
- pTypeDlg->AppendNamedRange(itr->second->GetName());
+ ScRangeName* pRangeName = elemRangeMap.second;
+ if (pRangeName)
+ {
+ if (elemRangeMap.first == STR_GLOBAL_RANGE_NAME)
+ {
+ for (auto const& elem : *pRangeName)
+ pTypeDlg->AppendNamedRange(elem.second->GetName());
+ }
+ else
+ {
+ OUString aScope(elemRangeMap.first);
+ ScGlobal::AddQuotes(aScope, '\'');
+ for (auto const& elem : *pRangeName)
+ {
+ pTypeDlg->AppendNamedRange(aScope + "." + elem.second->GetName());
+ }
+ }
+ }
}
if ( pTypeDlg->Execute() == RET_OK )