Kaydet (Commit) e74be9ad authored tarafından Akshay Deep's avatar Akshay Deep Kaydeden (comit) Heiko Tietze

Search feature for Special Characters

1. Name data stored in map
2. Retrive the data to compare with search string
3. create search control
4. populate search results
5. Read-only subset listbox meanwhile

Change-Id: I689bbee0dd9a226261c37a5824af7f83a510167d
Reviewed-on: https://gerrit.libreoffice.org/40563Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarHeiko Tietze <tietze.heiko@googlemail.com>
Tested-by: 's avatarHeiko Tietze <tietze.heiko@googlemail.com>
üst 86bc7207
......@@ -26,6 +26,7 @@
#include <vcl/lstbox.hxx>
#include <sfx2/basedlgs.hxx>
#include <svx/charmap.hxx>
#include <svx/searchcharmap.hxx>
#include <sfx2/charwin.hxx>
using namespace ::com::sun::star;
......@@ -70,12 +71,14 @@ private:
void init();
VclPtr<SvxShowCharSet> m_pShowSet;
VclPtr<SvxSearchCharSet> m_pSearchSet;
VclPtr<PushButton> m_pOKBtn;
VclPtr<FixedText> m_pFontText;
VclPtr<ListBox> m_pFontLB;
VclPtr<FixedText> m_pSubsetText;
VclPtr<ListBox> m_pSubsetLB;
VclPtr<SvxShowText> m_pShowChar;
VclPtr<Edit> m_pSearchText;
VclPtr<Edit> m_pHexCodeText;
VclPtr<Edit> m_pDecimalCodeText;
VclPtr<Button> m_pFavouritesBtn;
......@@ -83,8 +86,9 @@ private:
VclPtr<SvxCharView> m_pFavCharView[16];
VclPtr<VclMultiLineEdit> m_pCharName;
vcl::Font aFont;
const SubsetMap* pSubsetMap;
vcl::Font aFont;
const SubsetMap* pSubsetMap;
bool isSearchMode;
std::deque<OUString> maRecentCharList;
std::deque<OUString> maRecentCharFontList;
......@@ -102,6 +106,10 @@ private:
DECL_LINK(CharSelectHdl, SvxShowCharSet*, void);
DECL_LINK(CharHighlightHdl, SvxShowCharSet*, void);
DECL_LINK(CharPreSelectHdl, SvxShowCharSet*, void);
DECL_LINK(SearchCharDoubleClickHdl, SvxShowCharSet*,void);
DECL_LINK(SearchCharSelectHdl, SvxShowCharSet*, void);
DECL_LINK(SearchCharHighlightHdl, SvxShowCharSet*, void);
DECL_LINK(SearchCharPreSelectHdl, SvxShowCharSet*, void);
DECL_LINK(DecimalCodeChangeHdl, Edit&, void);
DECL_LINK(HexCodeChangeHdl, Edit&, void);
DECL_LINK(CharClickHdl, SvxCharView*, void);
......@@ -112,6 +120,8 @@ private:
DECL_LINK(InsertClickHdl, Button*, void);
DECL_STATIC_LINK(SvxCharacterMap, LoseFocusHdl, Control&, void);
DECL_LINK(FavSelectHdl, Button*, void);
DECL_LINK(SearchUpdateHdl, Edit&, void);
DECL_LINK(SearchFieldGetFocusHdl, Control&, void);
static void fillAllSubsets(ListBox &rListBox);
void selectCharByCode(Radix radix);
......@@ -145,6 +155,8 @@ public:
void setFavButtonState(const OUString& sTitle, const OUString& rFont);
void setCharName(sal_UCS4 nDecimalValue);
void toggleSearchView(bool state);
};
#endif
......
......@@ -86,36 +86,36 @@
<property name="hexpand">True</property>
<property name="column_spacing">12</property>
<child>
<object class="GtkLabel" id="fontft">
<object class="GtkLabel" id="subsetft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="specialcharacters|fontft">Font:</property>
<property name="halign">start</property>
<property name="label" translatable="yes" context="specialcharacters|subsetft">Subset:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">fontlb</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="subsetft">
<object class="GtkComboBox" id="fontlb">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes" context="specialcharacters|subsetft">Subset:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">subsetlb</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">0</property>
<property name="left_attach">1</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="fontlb">
<object class="GtkLabel" id="fontft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="halign">start</property>
<property name="label" translatable="yes" context="specialcharacters|fontft">Font:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="left_attach">1</property>
......@@ -129,10 +129,33 @@
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">3</property>
<property name="left_attach">2</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="srchft">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Search:</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="search">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
......@@ -140,20 +163,6 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="svxlo-SvxShowCharSet" id="showcharset">
<property name="width_request">580</property>
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkGrid" id="grid3">
<property name="visible">True</property>
......@@ -745,6 +754,47 @@
<property name="width">2</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box6">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="svxlo-SvxShowCharSet" id="showcharset">
<property name="width_request">580</property>
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="svxlo-SvxSearchCharSet" id="searchcharset">
<property name="width_request">580</property>
<property name="height_request">250</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
......
......@@ -275,6 +275,9 @@
<glade-widget-class title="Math Char Selection" name="svxlo-SvxShowCharSet"
generic-name="Math Char Selection" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Math Char Selection" name="svxlo-SvxSearchCharSet"
generic-name="Math Char Selection" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
<glade-widget-class title="Number Preview" name="cuilo-SvxNumberPreview"
generic-name="Number Preview Window" parent="GtkDrawingArea"
icon-name="widget-gtk-drawingarea"/>
......
......@@ -60,10 +60,10 @@ public:
virtual void dispose() override;
virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
void RecalculateFont(vcl::RenderContext& rRenderContext);
virtual void RecalculateFont(vcl::RenderContext& rRenderContext);
void SelectCharacter( sal_uInt32 cNew );
sal_UCS4 GetSelectCharacter() const;
virtual sal_UCS4 GetSelectCharacter() const;
void SetDoubleClickHdl( const Link<SvxShowCharSet*,void>& rLink ) { aDoubleClkHdl = rLink; }
void SetSelectHdl( const Link<SvxShowCharSet*,void>& rHdl ) { aSelectHdl = rHdl; }
......@@ -72,11 +72,11 @@ public:
static sal_uInt32& getSelectedChar();
void SetFont( const vcl::Font& rFont );
svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
virtual svx::SvxShowCharSetItem* ImplGetItem( int _nPos );
int FirstInView() const;
int LastInView() const;
virtual int LastInView() const;
int PixelToMapIndex( const Point&) const;
void SelectIndex( int index, bool bFocus = false );
virtual void SelectIndex( int index, bool bFocus = false );
void OutputIndex( int index );
void DeSelect();
bool IsSelected(sal_uInt16 _nPos) const { return _nPos == nSelectedIndex; }
......@@ -86,7 +86,7 @@ public:
ScrollBar& getScrollBar() { return *aVscrollSB.get();}
void ReleaseAccessible();
sal_Int32 getMaxCharCount() const;
virtual sal_Int32 getMaxCharCount() const;
virtual void Resize() override;
......@@ -106,7 +106,7 @@ protected:
virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
private:
protected:
typedef std::map<sal_Int32, std::shared_ptr<svx::SvxShowCharSetItem> > ItemsMap;
ItemsMap m_aItems;
Link<SvxShowCharSet*,void> aDoubleClkHdl;
......@@ -131,8 +131,8 @@ private:
bool mbUpdateBackground : 1;
private:
void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2);
protected:
virtual void DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2);
void InitSettings(vcl::RenderContext& rRenderContext);
// abstraction layers are: Unicode<->MapIndex<->Pixel
Point MapIndexToPixel( int) const;
......
/* -*- 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 <map>
#include <memory>
#include <sal/types.h>
#include <rtl/ref.hxx>
#include <svx/svxdllapi.h>
#include <svx/charmap.hxx>
#include <tools/gen.hxx>
#include <tools/link.hxx>
#include <vcl/ctrl.hxx>
#include <vcl/event.hxx>
#include <vcl/outdev.hxx>
#include <svx/ucsubset.hxx>
#include <vcl/metric.hxx>
#include <vcl/vclptr.hxx>
#include <vcl/window.hxx>
#include <vector>
#include <unordered_map>
namespace com { namespace sun { namespace star {
namespace accessibility { class XAccessible; }
} } }
namespace vcl { class Font; }
#define COLUMN_COUNT 16
#define ROW_COUNT 8
class CommandEvent;
class ScrollBar;
namespace svx
{
struct SvxShowCharSetItem;
class SvxShowCharSetVirtualAcc;
}
class SVX_DLLPUBLIC SvxSearchCharSet : public SvxShowCharSet
{
public:
SvxSearchCharSet( vcl::Window* pParent );
virtual ~SvxSearchCharSet() override;
virtual void dispose() override;
virtual void RecalculateFont(vcl::RenderContext& rRenderContext) override;
void SelectCharacter( const Subset* sub);
virtual sal_UCS4 GetSelectCharacter() 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 AppendCharList(std::vector<sal_UCS4> cCharList);
void ClearPreviousData();
virtual sal_Int32 getMaxCharCount() const override;
protected:
virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& ) override;
virtual void KeyInput( const KeyEvent& rKEvt ) override;
private:
sal_Int32 nCount;
//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 DrawChars_Impl(vcl::RenderContext& rRenderContext, int n1, int n2) override;
};
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
......@@ -22,6 +22,7 @@
#include <svx/svxdllapi.h>
#include <unordered_map>
#include <vcl/metric.hxx>
#include <list>
......
......@@ -108,6 +108,7 @@ $(eval $(call gb_Library_add_exception_objects,svx,\
svx/source/customshapes/EnhancedCustomShapeHandle \
svx/source/dialog/_bmpmask \
svx/source/dialog/charmap \
svx/source/dialog/searchcharmap \
svx/source/dialog/connctrl \
svx/source/dialog/_contdlg \
svx/source/dialog/contwnd \
......
......@@ -25,6 +25,8 @@
#include <rtl/textenc.h>
#include <svx/ucsubset.hxx>
#include <unordered_map>
#include <svx/strings.hrc>
......@@ -146,7 +148,7 @@ void SvxShowCharSet::MouseButtonDown( const MouseEvent& rMEvt )
CaptureMouse();
int nIndex = PixelToMapIndex( rMEvt.GetPosPixel() );
// Fire the focus event
// Fire the focus event
SelectIndex( nIndex, true);
}
......@@ -231,7 +233,7 @@ int SvxShowCharSet::LastInView() const
}
inline Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const
Point SvxShowCharSet::MapIndexToPixel( int nIndex ) const
{
const int nBase = FirstInView();
int x = ((nIndex - nBase) % COLUMN_COUNT) * nX;
......@@ -650,7 +652,6 @@ void SvxShowCharSet::OutputIndex( int nNewIndex )
{
SelectIndex( nNewIndex, true );
aSelectHdl.Call( this );
}
......@@ -763,9 +764,13 @@ SubsetMap::SubsetMap( const FontCharMapRef& rxFontCharMap )
const Subset* SubsetMap::GetNextSubset( bool bFirst ) const
{
if( bFirst )
{
maSubsetIterator = maSubsets.begin();
}
if( maSubsetIterator == maSubsets.end() )
return nullptr;
const Subset* s = &*(maSubsetIterator++);
return s;
}
......@@ -781,7 +786,8 @@ const Subset* SubsetMap::GetSubsetByUnicode( sal_UCS4 cChar ) const
inline Subset::Subset(sal_UCS4 nMin, sal_UCS4 nMax, const OUString& rName)
: mnRangeMin(nMin), mnRangeMax(nMax), maRangeName(rName)
{}
{
}
void SubsetMap::InitList()
{
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment