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 OString& rId, SfxTabPage& rPage)
63{
64 if (rId == "font")
65 {
66 const FontList* pApm_pFontList = nullptr;
68
69 if ( pSh )
70 {
71 const SvxFontListItem* pFLItem = static_cast<const SvxFontListItem*>(
72 pSh->GetItem( SID_ATTR_CHAR_FONTLIST ));
73 if ( pFLItem )
74 pApm_pFontList = pFLItem->GetFontList();
75 }
76
77 const FontList* pList = pApm_pFontList;
78
79 if ( !pList )
80 {
81 if ( !m_pFontList )
83 pList = m_pFontList.get();
84 }
85
86 static_cast<SvxCharNamePage&>(rPage).
87 SetFontList( SvxFontListItem( pList, SID_ATTR_CHAR_FONTLIST ) );
88 static_cast<SvxCharNamePage&>(rPage).EnableSearchMode();
89 }
90 else if (rId == "labelTP_PARA_STD")
91 {
92 static_cast<SvxStdParagraphTabPage&>(rPage).EnableAutoFirstLine();
93 }
94 else if (rId == "labelTP_PARA_ALIGN")
95 {
96 static_cast<SvxParaAlignTabPage&>(rPage).EnableJustifyExt();
97 }
98 else if (rId == "background")
99 {
100 SfxAllItemSet aSet(*(GetInputSetImpl()->GetPool()));
101 aSet.Put(SfxUInt32Item(SID_FLAG_TYPE,static_cast<sal_uInt32>(SvxBackgroundTabFlags::SHOW_HIGHLIGHTING)));
102 rPage.PageCreated(aSet);
103 }
104}
105
107 SearchAttrItemList& rLst, const WhichRangesContainer& pWhRanges)
108 : GenericDialogController(pParent, "cui/ui/searchattrdialog.ui", "SearchAttrDialog")
109 , rList(rLst)
110 , m_xAttrLB(m_xBuilder->weld_tree_view("treeview"))
111 , m_xOKBtn(m_xBuilder->weld_button("ok"))
112{
113 m_xAttrLB->set_size_request(m_xAttrLB->get_approximate_digit_width() * 50,
114 m_xAttrLB->get_height_rows(12));
115
116 m_xAttrLB->enable_toggle_buttons(weld::ColumnToggleType::Check);
117
118 m_xOKBtn->connect_clicked(LINK( this, SvxSearchAttributeDialog, OKHdl));
119
121 DBG_ASSERT( pSh, "No DocShell" );
122
123 SfxItemPool& rPool = pSh->GetPool();
124 SfxItemSet aSet( rPool, pWhRanges );
125 SfxWhichIter aIter( aSet );
126 sal_uInt16 nWhich = aIter.FirstWhich();
127
128 while ( nWhich )
129 {
130 sal_uInt16 nSlot = rPool.GetSlotId( nWhich );
131 if ( nSlot >= SID_SVX_START )
132 {
133 bool bChecked = false, bFound = false;
134 for ( sal_uInt16 i = 0; !bFound && i < rList.Count(); ++i )
135 {
136 if ( nSlot == rList[i].nSlot )
137 {
138 bFound = true;
139 if ( IsInvalidItem( rList[i].pItem ) )
140 bChecked = true;
141 }
142 }
143
144 // item resources are in svx
145 sal_uInt32 nId = SvxAttrNameTable::FindIndex(nSlot);
147 {
148 m_xAttrLB->append();
149 const int nRow = m_xAttrLB->n_children() - 1;
150 m_xAttrLB->set_toggle(nRow, bChecked ? TRISTATE_TRUE : TRISTATE_FALSE);
151 m_xAttrLB->set_text(nRow, SvxAttrNameTable::GetString(nId), 0);
152 m_xAttrLB->set_id(nRow, OUString::number(nSlot));
153 }
154 else
155 SAL_WARN( "cui.dialogs", "no resource for slot id " << static_cast<sal_Int32>(nSlot) );
156 }
157 nWhich = aIter.NextWhich();
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 SfxObjectShell * Current()
SfxItemPool & GetPool() const
const SfxPoolItem * GetItem(sal_uInt16 nSlotId) const
void AddTabPage(const OString &rName, CreateTabPage pCreateFunc, GetTabPageRanges pRangesFunc)
void RemoveTabPage(const OString &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:2262
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:1673
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:1182
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:2632
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: chardlg.cxx:3149
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:1340
const FontList * GetFontList() const
static std::unique_ptr< SfxTabPage > Create(weld::Container *pPage, weld::DialogController *pController, const SfxItemSet *rSet)
Definition: paragrph.cxx:1044
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:106
virtual ~SvxSearchAttributeDialog() override
Definition: srchxtra.cxx:164
virtual void PageCreated(const OString &rId, SfxTabPage &rPage) override
Definition: srchxtra.cxx:62
virtual ~SvxSearchFormatDialog() override
Definition: srchxtra.cxx:58
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:199
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