LibreOffice Module fpicker (master) 1
iodlgimp.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <sal/config.h>
21
22#include <string_view>
23
24#include "fileview.hxx"
25#include "iodlgimp.hxx"
26#include <tools/debug.hxx>
27#include <tools/urlobj.hxx>
28#include <svtools/inettbc.hxx>
29#include "iodlg.hxx"
30#include <svtools/imagemgr.hxx>
31#include <svl/svlresid.hxx>
32#include <svl/svl.hrc>
33#include <utility>
34
35using namespace ::com::sun::star::uno;
36using namespace ::com::sun::star::lang;
37using namespace ::utl;
38
40 : m_aName(std::move( aName ))
41 , m_aType(std::move( aType ))
42{
43 m_aType = m_aType.toAsciiLowerCase();
44}
45
47{
48}
49
50//= SvtUpButton_Impl
51SvtUpButton_Impl::SvtUpButton_Impl(std::unique_ptr<weld::Toolbar> xToolbar,
52 std::unique_ptr<weld::Menu> xMenu,
53 SvtFileDialog* pDlg)
54 : m_xToolbar(std::move(xToolbar))
55 , m_xMenu(std::move(xMenu))
56 , m_pDlg(pDlg)
57{
58 m_xToolbar->set_item_menu("up_btn", m_xMenu.get());
59 m_xToolbar->connect_clicked(LINK(this, SvtUpButton_Impl, ClickHdl));
60 m_xMenu->connect_activate(LINK(this, SvtUpButton_Impl, SelectHdl));
61}
62
64{
65 SvtFileView* pBox = m_pDlg->GetView();
66
67 sal_uInt16 nItemId = 1;
68
69 aURLs.clear();
70 m_xMenu->clear();
71
72 // determine parent levels
73 INetURLObject aObject( pBox->GetViewURL() );
74 sal_Int32 nCount = aObject.getSegmentCount();
75
76 ::svtools::VolumeInfo aVolInfo( true /* volume */, false /* remote */,
77 false /* removable */, false /* floppy */,
78 false /* compact disk */ );
79 OUString aVolumeImage( SvFileInformationManager::GetFolderImageId( aVolInfo ) );
80
81 while ( nCount >= 1 )
82 {
83 aObject.removeSegment();
84 OUString aParentURL(aObject.GetMainURL(INetURLObject::DecodeMechanism::NONE));
85
86 OUString aTitle;
87
88 if (nCount == 1) // adjust the title of the top level entry (the workspace)
89 aTitle = SvlResId(STR_SVT_MIMETYPE_CNT_FSYSBOX);
90 else if (!m_pDlg->ContentGetTitle(aParentURL, aTitle) || aTitle.isEmpty())
91 aTitle = aObject.getName();
92
93 OUString aImage = ( nCount > 1 ) // if nCount == 1 means workplace, which detects the wrong image
94 ? SvFileInformationManager::GetImageId( aObject ) : aVolumeImage;
95
96 m_xMenu->append(OUString::number(nItemId), aTitle, aImage);
97 aURLs.push_back(aParentURL);
98
99 ++nItemId;
100 --nCount;
101 }
102}
103
104IMPL_LINK(SvtUpButton_Impl, SelectHdl, const OUString&, rId, void)
105{
106 sal_uInt32 nId = rId.toUInt32();
107 if (nId)
108 {
109 --nId;
110 assert( nId <= aURLs.size() && "SvtUpButton_Impl: wrong index" );
111
112 m_pDlg->OpenURL_Impl(aURLs[nId]);
113 }
114}
115
116IMPL_LINK_NOARG(SvtUpButton_Impl, ClickHdl, const OUString&, void)
117{
118 m_pDlg->PrevLevel_Impl();
119}
120
121// SvtExpFileDlg_Impl
123 : m_pCurFilter( nullptr )
124 , m_eMode( FILEDLG_MODE_OPEN )
125 , m_eDlgType( FILEDLG_TYPE_FILEDLG )
126 , m_nStyle( PickerFlags::NONE )
127 , m_aFilterIdle("fpicker SvtExpFileDlg_Impl m_aFilterIdle")
128 , m_bDoubleClick( false )
129 , m_bMultiSelection( false )
130{
131}
132
134{
135}
136
137void SvtExpFileDlg_Impl::SetStandardDir( const OUString& _rDir )
138{
139 m_aStdDir = _rDir;
140 if (m_aStdDir.isEmpty())
141 m_aStdDir = "file:///";
142}
143
144namespace {
145 OUString lcl_DecoratedFilter( std::u16string_view _rOriginalFilter )
146 {
147 return "<" + OUString::Concat(_rOriginalFilter) + ">";
148 }
149}
150
151void SvtExpFileDlg_Impl::SetCurFilter( SvtFileDialogFilter_Impl const * pFilter, const OUString& rDisplayName )
152{
153 DBG_ASSERT( pFilter, "SvtExpFileDlg_Impl::SetCurFilter: invalid filter!" );
154 DBG_ASSERT( ( rDisplayName == pFilter->GetName() )
155 || ( rDisplayName == lcl_DecoratedFilter( pFilter->GetName() ) ),
156 "SvtExpFileDlg_Impl::SetCurFilter: arguments are inconsistent!" );
157
158 m_pCurFilter = pFilter;
159 m_sCurrentFilterDisplayName = rDisplayName;
160}
161
163{
164 // insert and set user data
165 OUString sId(weld::toId(pFilterDesc));
166 OUString sName = pFilterDesc->GetName();
167 if (pFilterDesc->isGroupSeparator())
168 m_xLbFilter->append_separator(sId);
169 else
170 m_xLbFilter->append(sId, sName);
171}
172
174{
175 // clear the current list
176 m_xLbFilter->clear();
177
178 // reinit it
179 sal_uInt16 nPos = m_aFilter.size();
180
181 // search for the first entry which is no group separator
182 while ( nPos-- && m_aFilter[ nPos ]->isGroupSeparator() )
183 ;
184
185 // add all following entries
186 while ( static_cast<sal_Int16>(nPos) >= 0 )
188}
189
190/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
uno::Type m_aType
OUString getName(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true, DecodeMechanism eMechanism=DecodeMechanism::ToIUri, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
OUString GetMainURL(DecodeMechanism eMechanism, rtl_TextEncoding eCharset=RTL_TEXTENCODING_UTF8) const
bool removeSegment(sal_Int32 nIndex=LAST_SEGMENT, bool bIgnoreFinalSlash=true)
sal_Int32 getSegmentCount(bool bIgnoreFinalSlash=true) const
static SVT_DLLPUBLIC OUString GetImageId(const INetURLObject &rURL, bool bBig=false)
static SVT_DLLPUBLIC OUString GetFolderImageId(const svtools::VolumeInfo &rInfo)
SvtFileDialogFilterList_Impl m_aFilter
Definition: iodlgimp.hxx:112
const SvtFileDialogFilter_Impl * m_pCurFilter
Definition: iodlgimp.hxx:106
void SetCurFilter(SvtFileDialogFilter_Impl const *_pFilter, const OUString &rDisplayName)
Definition: iodlgimp.cxx:151
void SetStandardDir(const OUString &rDir)
Definition: iodlgimp.cxx:137
void InsertFilterListEntry(const SvtFileDialogFilter_Impl *_pFilterDesc)
Definition: iodlgimp.cxx:162
OUString m_aStdDir
Definition: iodlgimp.hxx:141
OUString m_sCurrentFilterDisplayName
Definition: iodlgimp.hxx:107
std::unique_ptr< weld::ComboBox > m_xLbFilter
Definition: iodlgimp.hxx:122
SvtFileDialogFilter_Impl(OUString aName, OUString aType)
Definition: iodlgimp.cxx:39
bool isGroupSeparator() const
Definition: iodlgimp.hxx:58
const OUString & GetName() const
Definition: iodlgimp.hxx:54
SvtFileView * GetView() override
Definition: iodlg.hxx:297
bool ContentGetTitle(const OUString &rURL, OUString &rTitle)
Definition: iodlg.cxx:2240
const OUString & GetViewURL() const
Definition: fileview.cxx:1022
std::unique_ptr< weld::Menu > m_xMenu
Definition: iodlgimp.hxx:79
std::unique_ptr< weld::Toolbar > m_xToolbar
Definition: iodlgimp.hxx:78
void FillURLMenu()
Definition: iodlgimp.cxx:63
std::vector< OUString > aURLs
Definition: iodlgimp.hxx:82
SvtUpButton_Impl(std::unique_ptr< weld::Toolbar > xToolbar, std::unique_ptr< weld::Menu > xMenu, SvtFileDialog *pDlg)
Definition: iodlgimp.cxx:51
SvtFileDialog * m_pDlg
Definition: iodlgimp.hxx:80
int nCount
#define DBG_ASSERT(sCon, aError)
OUString sName
PickerFlags
OUString aName
IMPL_LINK_NOARG(SvtUpButton_Impl, ClickHdl, const OUString &, void)
Definition: iodlgimp.cxx:116
IMPL_LINK(SvtUpButton_Impl, SelectHdl, const OUString &, rId, void)
Definition: iodlgimp.cxx:104
@ FILEDLG_MODE_OPEN
Definition: iodlgimp.hxx:65
@ FILEDLG_TYPE_FILEDLG
Definition: iodlgimp.hxx:71
sal_uInt16 nPos
NONE
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
OUString toId(const void *pValue)
sal_Int16 nId
OUString m_aName
SVL_DLLPUBLIC OUString SvlResId(TranslateId sContextAndId)
OUString sId