include/svx/searchcharmap.hxx | 69 ------- solenv/clang-format/excludelist | 1 svx/Library_svx.mk | 1 svx/source/dialog/searchcharmap.cxx | 319 ------------------------------------ 4 files changed, 390 deletions(-)
New commits: commit 34ecd310be72ae52edd8024bbe9cbbdc41886842 Author: Parth Raiyani <[email protected]> AuthorDate: Mon Nov 3 16:45:00 2025 +0530 Commit: Szymon Kłos <[email protected]> CommitDate: Wed Nov 12 05:50:26 2025 +0100 Remove search character map implementation and related references - these files are not needed now after special characters iconview conversion Change-Id: I4bb4fefc6092ccaa3112e1b0cc21741b35257d9b Signed-off-by: Parth Raiyani <[email protected]> Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193346 Reviewed-by: Szymon Kłos <[email protected]> Tested-by: Jenkins CollaboraOffice <[email protected]> diff --git a/include/svx/searchcharmap.hxx b/include/svx/searchcharmap.hxx deleted file mode 100644 index b07d58a4c8ad..000000000000 --- a/include/svx/searchcharmap.hxx +++ /dev/null @@ -1,69 +0,0 @@ -/* -*- 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 INCLUDED_SVX_SEARCHCHARMAP_HXX -#define INCLUDED_SVX_SEARCHCHARMAP_HXX - -#include <memory> - -#include <sal/types.h> -#include <svx/svxdllapi.h> -#include <svx/charmap.hxx> -#include <vcl/outdev.hxx> -#include <vcl/vclptr.hxx> -#include <unordered_map> - -namespace svx { struct SvxShowCharSetItem; } -namespace tools { class Rectangle; } -namespace weld { class ScrolledWindow; } - -class Subset; - -class SVX_DLLPUBLIC SvxSearchCharSet final : public SvxShowCharSet -{ -public: - SvxSearchCharSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow, const VclPtr<VirtualDevice> &rDevice); - virtual ~SvxSearchCharSet() override; - - virtual void RecalculateFont(vcl::RenderContext& rRenderContext) override; - - void SelectCharacter( const Subset* sub); - virtual sal_UCS4 GetSelectCharacter() const override; - virtual sal_UCS4 GetCharFromIndex(int index) const override; - - virtual svx::SvxShowCharSetItem* ImplGetItem( int _nPos ) override; - virtual int LastInView() const override; - virtual void SelectIndex( int index, bool bFocus = false ) override; - void AppendCharToList(sal_UCS4 cChar); - void ClearPreviousData(); - void UpdateScrollRange(); - - virtual sal_Int32 getMaxCharCount() const override; - -private: - //index to char code mapping for the search - //to uniquely identify each appended element - std::unordered_map<sal_Int32, sal_UCS4> m_aItemList; -private: - virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect) override; - virtual bool KeyInput(const KeyEvent& rKEvt) override; -}; - -#endif - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/solenv/clang-format/excludelist b/solenv/clang-format/excludelist index 1d2d798658aa..9612018ea395 100644 --- a/solenv/clang-format/excludelist +++ b/solenv/clang-format/excludelist @@ -11315,7 +11315,6 @@ svx/source/dialog/rlrcitem.cxx svx/source/dialog/rlrcitem.hxx svx/source/dialog/rulritem.cxx svx/source/dialog/samecontentlistbox.cxx -svx/source/dialog/searchcharmap.cxx svx/source/dialog/spacinglistbox.cxx svx/source/dialog/srchctrl.cxx svx/source/dialog/srchdlg.cxx diff --git a/svx/Library_svx.mk b/svx/Library_svx.mk index 4f5f7ba04793..0e65029f9e2d 100644 --- a/svx/Library_svx.mk +++ b/svx/Library_svx.mk @@ -128,7 +128,6 @@ $(eval $(call gb_Library_add_exception_objects,svx,\ svx/source/dialog/_bmpmask \ svx/source/dialog/charmap \ svx/source/dialog/cuicharmap \ - svx/source/dialog/searchcharmap \ svx/source/dialog/connctrl \ svx/source/dialog/_contdlg \ svx/source/dialog/contwnd \ diff --git a/svx/source/dialog/searchcharmap.cxx b/svx/source/dialog/searchcharmap.cxx deleted file mode 100644 index b883ac39694e..000000000000 --- a/svx/source/dialog/searchcharmap.cxx +++ /dev/null @@ -1,319 +0,0 @@ -/* -*- 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 <config_wasm_strip.h> - -#include <vcl/event.hxx> -#include <vcl/virdev.hxx> - -#include <svx/ucsubset.hxx> -#include <unordered_map> - -#include <svx/searchcharmap.hxx> - -#include <charmapacc.hxx> - -#include <rtl/ustrbuf.hxx> - -using namespace ::com::sun::star; - - -SvxSearchCharSet::SvxSearchCharSet(std::unique_ptr<weld::ScrolledWindow> pScrolledWindow, const VclPtr<VirtualDevice>& rVirDev) - : SvxShowCharSet(std::move(pScrolledWindow), rVirDev) -{ -} - -int SvxSearchCharSet::LastInView() const -{ - int nIndex = FirstInView(); - nIndex += ROW_COUNT * COLUMN_COUNT - 1; - return std::min<int>(nIndex, getMaxCharCount() -1); -} - -bool SvxSearchCharSet::KeyInput(const KeyEvent& rKEvt) -{ - vcl::KeyCode aCode = rKEvt.GetKeyCode(); - - if (aCode.GetModifier()) - return false; - - int tmpSelected = nSelectedIndex; - - bool bRet = true; - - switch (aCode.GetCode()) - { - case KEY_RETURN: - return SvxShowCharSet::KeyInput(rKEvt); - case KEY_SPACE: - aDoubleClkHdl.Call(this); - return true; - case KEY_LEFT: - --tmpSelected; - break; - case KEY_RIGHT: - ++tmpSelected; - break; - case KEY_UP: - tmpSelected -= COLUMN_COUNT; - break; - case KEY_DOWN: - tmpSelected += COLUMN_COUNT; - break; - case KEY_PAGEUP: - tmpSelected -= ROW_COUNT * COLUMN_COUNT; - break; - case KEY_PAGEDOWN: - tmpSelected += ROW_COUNT * COLUMN_COUNT; - break; - case KEY_HOME: - tmpSelected = 0; - break; - case KEY_END: - tmpSelected = getMaxCharCount() - 1; - break; - case KEY_TAB: // some fonts have a character at these unicode control codes - case KEY_ESCAPE: - bRet = false; - tmpSelected = - 1; // mark as invalid - break; - default: - tmpSelected = -1; - bRet = false; - break; - } - - if ( tmpSelected >= 0 ) - { - SelectIndex( tmpSelected, true ); - aPreSelectHdl.Call( this ); - } - - return bRet; -} - -void SvxSearchCharSet::SelectCharacter( const Subset* sub ) -{ - if (!mxFontCharMap.is()) - RecalculateFont(*mxVirDev); - - // get next available char of current font - sal_UCS4 cChar = sub->GetRangeMin(); - int nMapIndex = 0; - - while(cChar <= sub->GetRangeMax() && nMapIndex == 0) - { - auto it = std::find_if(m_aItemList.begin(), m_aItemList.end(), - [&cChar](const std::pair<const sal_Int32, sal_UCS4>& rItem) { return rItem.second == cChar; }); - if (it != m_aItemList.end()) - nMapIndex = it->first; - cChar++; - } - - if(nMapIndex == 0) - SelectIndex( 0 ); - else - SelectIndex( nMapIndex ); - aHighHdl.Call(this); - // move selected item to top row if not in focus - //TO.DO aVscrollSB->SetThumbPos( nMapIndex / COLUMN_COUNT ); - Invalidate(); -} - -sal_UCS4 SvxSearchCharSet::GetCharFromIndex(int index) const -{ - std::unordered_map<sal_Int32, sal_UCS4>::const_iterator got = m_aItemList.find(index); - return (got != m_aItemList.end()) ? got->second : 0; -} - -void SvxSearchCharSet::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) -{ - InitSettings(rRenderContext); - RecalculateFont(rRenderContext); - DrawChars_Impl(rRenderContext, FirstInView(), LastInView()); -} - -sal_UCS4 SvxSearchCharSet::GetSelectCharacter() const -{ - if( nSelectedIndex >= 0 ) - { - std::unordered_map<sal_Int32,sal_UCS4>::const_iterator got = m_aItemList.find (nSelectedIndex); - - if(got == m_aItemList.end()) - return 1; - else - return got->second; - } - return 1; -} - -void SvxSearchCharSet::RecalculateFont(vcl::RenderContext& rRenderContext) -{ - if (!mbRecalculateFont) - return; - - Size aSize(GetOutputSizePixel()); - - vcl::Font aFont = maFont; - aFont.SetWeight(WEIGHT_LIGHT); - aFont.SetAlignment(ALIGN_TOP); - int nFontHeight = (aSize.Height() - 5) * 2 / (3 * ROW_COUNT); - maFontSize = rRenderContext.PixelToLogic(Size(0, nFontHeight)); - aFont.SetFontSize(maFontSize); - aFont.SetTransparent(true); - rRenderContext.SetFont(aFont); - rRenderContext.GetFontCharMap(mxFontCharMap); - m_aItems.clear(); - loadFavCharacterList(); - - nX = aSize.Width() / COLUMN_COUNT; - nY = aSize.Height() / ROW_COUNT; - - UpdateScrollRange(); - - // rearrange CharSet element in sync with nX- and nY-multiples - Size aDrawSize(nX * COLUMN_COUNT, nY * ROW_COUNT); - m_nXGap = (aSize.Width() - aDrawSize.Width()) / 2; - m_nYGap = (aSize.Height() - aDrawSize.Height()) / 2; - - mbRecalculateFont = false; -} - -void SvxSearchCharSet::UpdateScrollRange() -{ - //scrollbar settings - int nLastRow = (getMaxCharCount() - 1 + COLUMN_COUNT) / COLUMN_COUNT; - mxScrollArea->vadjustment_configure(mxScrollArea->vadjustment_get_value(), 0, nLastRow, 1, ROW_COUNT - 1, ROW_COUNT); -} - -void SvxSearchCharSet::SelectIndex(int nNewIndex, bool bFocus) -{ - if (!mxFontCharMap.is()) - RecalculateFont(*mxVirDev); - - if( nNewIndex < 0 ) - { - mxScrollArea->vadjustment_set_value(0); - nSelectedIndex = bFocus ? 0 : -1; - Invalidate(); - } - else if( nNewIndex < FirstInView() ) - { - // need to scroll up to see selected item - int nOldPos = mxScrollArea->vadjustment_get_value(); - int nDelta = (FirstInView() - nNewIndex + COLUMN_COUNT-1) / COLUMN_COUNT; - mxScrollArea->vadjustment_set_value(nOldPos - nDelta); - nSelectedIndex = nNewIndex; - Invalidate(); - } - else if( nNewIndex > LastInView() ) - { - // need to scroll down to see selected item - int nOldPos = mxScrollArea->vadjustment_get_value(); - int nDelta = (nNewIndex - LastInView() + COLUMN_COUNT) / COLUMN_COUNT; - mxScrollArea->vadjustment_set_value(nOldPos + nDelta); - - if (nNewIndex < getMaxCharCount()) - { - nSelectedIndex = nNewIndex; - Invalidate(); - } - else if (nOldPos != mxScrollArea->vadjustment_get_value()) - { - Invalidate(); - } - } - else - { - nSelectedIndex = nNewIndex; - Invalidate(); - } - - if( nSelectedIndex >= 0 ) - { -#if 0 - if( m_xAccessible.is() ) - { - svx::SvxShowCharSetItem* pItem = ImplGetItem(nSelectedIndex); - // Don't fire the focus event. - if ( bFocus ) - m_xAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set - else - m_xAccessible->fireEvent( AccessibleEventId::ACTIVE_DESCENDANT_CHANGED_NOFOCUS, Any(), makeAny(pItem->GetAccessible()) ); // this call assures that m_pItem is set - - assert(pItem->m_xItem.is() && "No accessible created!"); - Any aOldAny, aNewAny; - aNewAny <<= AccessibleStateType::FOCUSED; - // Don't fire the focus event. - if ( bFocus ) - pItem->m_xItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny ); - - aNewAny <<= AccessibleStateType::SELECTED; - pItem->m_xItem->fireEvent( AccessibleEventId::STATE_CHANGED, aOldAny, aNewAny ); - } -#endif - aSelectHdl.Call(this); - } - aHighHdl.Call( this ); -} - -SvxSearchCharSet::~SvxSearchCharSet() -{ -} - -svx::SvxShowCharSetItem* SvxSearchCharSet::ImplGetItem( int _nPos ) -{ - ItemsMap::iterator aFind = m_aItems.find(_nPos); - if ( aFind == m_aItems.end() ) - { -#if !ENABLE_WASM_STRIP_ACCESSIBILITY - OSL_ENSURE(m_xAccessible.is(), "Who wants to create a child of my table without a parent?"); -#endif - auto xItem = std::make_shared<svx::SvxShowCharSetItem>(*this, - m_xAccessible.get(), sal::static_int_cast< sal_uInt16 >(_nPos)); - aFind = m_aItems.emplace(_nPos, xItem).first; - OUStringBuffer buf; - std::unordered_map<sal_Int32,sal_UCS4>::const_iterator got = m_aItemList.find (_nPos); - if (got != m_aItemList.end()) - buf.appendUtf32(got->second); - aFind->second->maText = buf.makeStringAndClear(); - Point pix = MapIndexToPixel( _nPos ); - aFind->second->maRect = tools::Rectangle( Point( pix.X() + 1, pix.Y() + 1 ), Size(nX-1,nY-1) ); - } - - return aFind->second.get(); -} - -sal_Int32 SvxSearchCharSet::getMaxCharCount() const -{ - return m_aItemList.size(); -} - -void SvxSearchCharSet::ClearPreviousData() -{ - m_aItemList.clear(); - Invalidate(); -} - -void SvxSearchCharSet::AppendCharToList(sal_UCS4 sChar) -{ - m_aItemList.insert(std::make_pair(m_aItemList.size(), sChar)); -} - -/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
