LibreOffice Module cui (master) 1
srchxtra.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 <srchxtra.hxx>
21#include <sal/log.hxx>
22#include <svl/cjkoptions.hxx>
23#include <svl/intitem.hxx>
24#include <svl/whiter.hxx>
25#include <sfx2/objsh.hxx>
26#include <svx/flagsdef.hxx>
27#include <svx/strarray.hxx>
28#include <editeng/flstitem.hxx>
29#include <chardlg.hxx>
30#include <paragrph.hxx>
31#include <backgrnd.hxx>
32#include <editeng/editids.hrc>
33#include <svx/svxids.hrc>
34#include <tools/debug.hxx>
35#include <tools/resary.hxx>
36#include <vcl/svapp.hxx>
37
39 : SfxTabDialogController(pParent, "cui/ui/searchformatdialog.ui", "SearchFormatDialog", &rSet)
40{
41 AddTabPage("font", SvxCharNamePage::Create, nullptr);
42 AddTabPage("fonteffects", SvxCharEffectsPage::Create, nullptr);
43 AddTabPage("position", SvxCharPositionPage::Create, nullptr);
44 AddTabPage("asianlayout", SvxCharTwoLinesPage::Create, nullptr);
45 AddTabPage("labelTP_PARA_STD", SvxStdParagraphTabPage::Create, nullptr);
46 AddTabPage("labelTP_PARA_ALIGN", SvxParaAlignTabPage::Create, nullptr);
47 AddTabPage("labelTP_PARA_EXT", SvxExtParagraphTabPage::Create, nullptr);
48 AddTabPage("labelTP_PARA_ASIAN", SvxAsianTabPage::Create, nullptr );
49 AddTabPage("background", SvxBkgTabPage::Create, nullptr);
50
51 // remove asian tabpages if necessary
53 RemoveTabPage("asianlayout");
55 RemoveTabPage("labelTP_PARA_ASIAN");
56}
57
59{
60}
61
62void SvxSearchFormatDialog::PageCreated(const OUString& rId, SfxTabPage& rPage)
63{
64 if (rId == "font")
65 {
66 const FontList* pApm_pFontList = nullptr;
68 {
69 const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>(
70 pSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
71 if ( pFLItem )
72 pApm_pFontList = pFLItem->GetFontList();
73 }
74
75 const FontList* pList = pApm_pFontList;
76
77 if ( !pList )
78 {
79 if ( !m_pFontList )
81 pList = m_pFontList.get();
82 }
83
84 static_cast<SvxCharNamePage&>(rPage).
85 SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
86 static_cast<SvxCharNamePage&>(rPage).EnableSearchMode();
87 }
88 else if (rId == "labelTP_PARA_STD")
89 {
90 static_cast<SvxStdParagraphTabPage&>(rPage).EnableAutoFirstLine();
91 }
92 else if (rId == "labelTP_PARA_ALIGN")
93 {
94 static_cast<SvxParaAlignTabPage&>(rPage).EnableJustifyExt();
95 }
96 else if (rId == "background")
97 {
98 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
99 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_HIGHLIGHTING)));
100 rPage.PageCreated(aSet);
101 }
102}
103
105 SearchAttrItemList& rLst, const WhichRangesContainer& pWhRanges)
106 : GenericDialogController(pParent, "cui/ui/searchattrdialog.ui", "SearchAttrDialog")
107 , rList(rLst)
108 , m_xAttrLB(m_xBuilder->weld_tree_view("treeview"))
109 , m_xOKBtn(m_xBuilder->weld_button("ok"))
110{
111 m_xAttrLB->set_size_request(m_xAttrLB->get_approximate_digit_width() * 50,
112 m_xAttrLB->get_height_rows(12));
113
114 m_xAttrLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
115
116 m_xOKBtn->connect_clicked(LINK( this, SvxSearchAttributeDialog, OKHdl));
117
119 DBG_ASSERT( pSh, "No DocShell" );
120 if (pSh)
121 {
122 SfxItemPool& rPool = pSh->GetPool();
123 SfxItemSet aSet( rPool, pWhRanges );
124 SfxWhichIter aIter( aSet );
125 sal_uInt16 nWhich = aIter.FirstWhich();
126
127 while ( nWhich )
128 {
129 sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
130 if ( nSlot >= SID_SVX_START )
131 {
132 bool bChecked = false, bFound = false;
133 for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
134 {
135 if ( nSlot == rList[i].nSlot )
136 {
137 bFound = true;
138 if ( IsInvalidItem( rList[i].pItem ) )
139 bChecked = true;
140 }
141 }
142
143 // item resources are in svx
144 sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot);
146 {
147 m_xAttrLB->append();
148 const int nRow = m_xAttrLB->n_children() - 1;
149 m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE);
150 m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0);
151 m_xAttrLB->set_id(nRow, OUString::number(nSlot));
152 }
153 else
154 SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) );
155 }
156 nWhich = aIter.NextWhich();
157 }
158 }
159
160 m_xAttrLB->make_sorted();
161 m_xAttrLB->select(0);
162}
163
165{
166}
167
169{
170 SearchAttrItem aInvalidItem;
171 aInvalidItem.pItem = INVALID_POOL_ITEM;
172
173 for (int i = 0, nCount = m_xAttrLB->n_children(); i < nCount; ++i)
174 {
175 sal_uInt16 nSlot = m_xAttrLB->get_id(i).toUInt32();
176 bool bChecked = m_xAttrLB->get_toggle(i) == TRISTATE_TRUE;
177
178 sal_uInt16 j;
179 for ( j = rList.Count(); j; )
180 {
181 SearchAttrItem& rItem = rList[ --j ];
182 if( rItem.nSlot == nSlot )
183 {
184 if( bChecked )
185 {
186 if( !IsInvalidItem( rItem.pItem ) )
187 delete rItem.pItem;
188 rItem.pItem = INVALID_POOL_ITEM;
189 }
190 else if( IsInvalidItem( rItem.pItem ) )
191 rItem.pItem = nullptr;
192 j = 1;
193 break;
194 }
195 }
196
197 if ( !j && bChecked )
198 {
199 aInvalidItem.nSlot = nSlot;
200 rList.Insert( aInvalidItem );
201 }
202 }
203
204 // remove invalid items (pItem == NULL)
205 for ( sal_uInt16 n = rList.Count(); n; )
206 if ( !rList[ --n ].pItem )
207 rList.Remove( n );
208
209 m_xDialog->response(RET_OK);
210}
211
212// class SvxSearchSimilarityDialog ---------------------------------------
213
215 sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)
216 : GenericDialogController(pParent, "cui/ui/similaritysearchdialog.ui", "SimilaritySearchDialog")
217 , m_xOtherFld(m_xBuilder->weld_spin_button("otherfld"))
218 , m_xLongerFld(m_xBuilder->weld_spin_button("longerfld"))
219 , m_xShorterFld(m_xBuilder->weld_spin_button("shorterfld"))
220 , m_xRelaxBox(m_xBuilder->weld_check_button("relaxbox"))
221{
222 m_xOtherFld->set_value(nOther);
223 m_xShorterFld->set_value(nShorter);
224 m_xLongerFld->set_value(nLonger);
225 m_xRelaxBox->set_active(bRelax);
226}
227
229{
230}
231
232/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Reference< XExecutableDialog > m_xDialog
static OutputDevice * GetDefaultDevice()
sal_uInt16 Count() const
sal_uInt16 GetSlotId(sal_uInt16 nWhich) const
const SfxPoolItem * Put(const SfxPoolItem &rItem, sal_uInt16 nWhich)
static SAL_WARN_UNUSED_RESULT SfxObjectShell * Current()
SfxItemPool & GetPool() const
void AddTabPage(const OUString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OUString &rName)
SfxItemSet * GetInputSetImpl()
virtual void PageCreated(const SfxAllItemSet &aSet)
sal_uInt16 FirstWhich()
sal_uInt16 NextWhich()
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:2515
static OUString GetString(sal_uInt32 i)
static sal_uInt32 FindIndex(int nValue)
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *)
Definition: backgrnd.cxx:227
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1681
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1188
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:2650
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:3170
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:1594
const FontList * GetFontList() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:1279
std::unique_ptr< weld::TreeView > m_xAttrLB
Definition: srchxtra.hxx:51
std::unique_ptr< weld::Button > m_xOKBtn
Definition: srchxtra.hxx:52
SearchAttrItemList & rList
Definition: srchxtra.hxx:49
SvxSearchAttributeDialog(weld::Window *pParent, SearchAttrItemList &rLst, const WhichRangesContainer &pWhRanges)
Definition: srchxtra.cxx:104
virtual ~SvxSearchAttributeDialog() override
Definition: srchxtra.cxx:164
virtual ~SvxSearchFormatDialog() override
Definition: srchxtra.cxx:58
virtual void PageCreated(const OUString &rId, SfxTabPage &rPage) override
Definition: srchxtra.cxx:62
std::unique_ptr< FontList > m_pFontList
Definition: srchxtra.hxx:36
SvxSearchFormatDialog(weld::Window *pParent, const SfxItemSet &rSet)
Definition: srchxtra.cxx:38
std::unique_ptr< weld::SpinButton > m_xOtherFld
Definition: srchxtra.hxx:62
SvxSearchSimilarityDialog(weld::Window *pParent, bool bRelax, sal_uInt16 nOther, sal_uInt16 nShorter, sal_uInt16 nLonger)
Definition: srchxtra.cxx:214
std::unique_ptr< weld::SpinButton > m_xShorterFld
Definition: srchxtra.hxx:64
std::unique_ptr< weld::CheckButton > m_xRelaxBox
Definition: srchxtra.hxx:65
std::unique_ptr< weld::SpinButton > m_xLongerFld
Definition: srchxtra.hxx:63
virtual ~SvxSearchSimilarityDialog() override
Definition: srchxtra.cxx:228
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:210
int nCount
#define DBG_ASSERT(sCon, aError)
TRISTATE_FALSE
TRISTATE_TRUE
sal_Int64 n
#define SAL_WARN(area, stream)
bool IsDoubleLinesEnabled()
bool IsAsianTypographyEnabled()
int i
sal_Int16 nId
#define INVALID_POOL_ITEM
bool IsInvalidItem(const SfxPoolItem *pItem)
#define RESARRAY_INDEX_NOTFOUND
static SfxItemSet & rSet
IMPL_LINK_NOARG(SvxSearchAttributeDialog, OKHdl, weld::Button &, void)
Definition: srchxtra.cxx:168
SfxPoolItem * pItem
sal_uInt16 nSlot
RET_OK