lok: ensure that dialog windows are focused before emitting events.
[LibreOffice.git] / linguistic / source / convdic.hxx
blob1a93599eee6c37da851e6e774ae6386b9c2000a4
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
19 #ifndef INCLUDED_LINGUISTIC_SOURCE_CONVDIC_HXX
20 #define INCLUDED_LINGUISTIC_SOURCE_CONVDIC_HXX
22 #include <com/sun/star/linguistic2/XConversionDictionary.hpp>
23 #include <com/sun/star/linguistic2/XConversionPropertyType.hpp>
24 #include <com/sun/star/util/XFlushable.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <cppuhelper/implbase.hxx>
27 #include <comphelper/interfacecontainer2.hxx>
29 #include <memory>
30 #include <set>
31 #include <unordered_map>
32 #include <linguistic/misc.hxx>
33 #include "defs.hxx"
35 // text conversion dictionary extension
36 #define CONV_DIC_EXT "tcd"
37 #define CONV_DIC_DOT_EXT ".tcd"
39 #define SN_CONV_DICTIONARY "com.sun.star.linguistic2.ConversionDictionary"
42 bool IsConvDic( const OUString &rFileURL, LanguageType &nLang, sal_Int16 &nConvType );
44 typedef std::unordered_multimap<OUString, OUString> ConvMap;
46 typedef std::set<OUString> ConvMapKeySet;
48 typedef std::unordered_multimap<OUString, sal_Int16> PropTypeMap;
50 class ConvDic :
51 public ::cppu::WeakImplHelper
53 css::linguistic2::XConversionDictionary,
54 css::linguistic2::XConversionPropertyType,
55 css::util::XFlushable,
56 css::lang::XServiceInfo
59 friend class ConvDicXMLExport;
61 protected:
63 ::comphelper::OInterfaceContainerHelper2 aFlushListeners;
65 ConvMap aFromLeft;
66 std::unique_ptr< ConvMap > pFromRight; // only available for bidirectional conversion dictionaries
68 std::unique_ptr< PropTypeMap > pConvPropType;
70 OUString aMainURL; // URL to file
71 OUString aName;
72 LanguageType nLanguage;
73 sal_Int16 nConversionType;
74 sal_Int16 nMaxLeftCharCount;
75 sal_Int16 nMaxRightCharCount;
76 bool bMaxCharCountIsValid;
77 bool bNeedEntries;
78 bool bIsModified;
79 bool bIsActive;
81 // disallow copy-constructor and assignment-operator for now
82 ConvDic(const ConvDic &);
83 ConvDic & operator = (const ConvDic &);
85 static ConvMap::iterator GetEntry( ConvMap &rMap, const OUString &rFirstText, const OUString &rSecondText );
86 void Load();
87 void Save();
89 public:
90 ConvDic( const OUString &rName,
91 LanguageType nLanguage,
92 sal_Int16 nConversionType,
93 bool bBiDirectional,
94 const OUString &rMainURL);
95 virtual ~ConvDic() override;
97 // XConversionDictionary
98 virtual OUString SAL_CALL getName( ) override;
99 virtual css::lang::Locale SAL_CALL getLocale( ) override;
100 virtual sal_Int16 SAL_CALL getConversionType( ) override;
101 virtual void SAL_CALL setActive( sal_Bool bActivate ) override;
102 virtual sal_Bool SAL_CALL isActive( ) override;
103 virtual void SAL_CALL clear( ) override;
104 virtual css::uno::Sequence< OUString > SAL_CALL getConversions( const OUString& aText, sal_Int32 nStartPos, sal_Int32 nLength, css::linguistic2::ConversionDirection eDirection, sal_Int32 nTextConversionOptions ) override;
105 virtual css::uno::Sequence< OUString > SAL_CALL getConversionEntries( css::linguistic2::ConversionDirection eDirection ) override;
106 virtual void SAL_CALL addEntry( const OUString& aLeftText, const OUString& aRightText ) override;
107 virtual void SAL_CALL removeEntry( const OUString& aLeftText, const OUString& aRightText ) override;
108 virtual sal_Int16 SAL_CALL getMaxCharCount( css::linguistic2::ConversionDirection eDirection ) override;
110 // XConversionPropertyType
111 virtual void SAL_CALL setPropertyType( const OUString& aLeftText, const OUString& aRightText, ::sal_Int16 nPropertyType ) override;
112 virtual ::sal_Int16 SAL_CALL getPropertyType( const OUString& aLeftText, const OUString& aRightText ) override;
114 // XFlushable
115 virtual void SAL_CALL flush( ) override;
116 virtual void SAL_CALL addFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
117 virtual void SAL_CALL removeFlushListener( const css::uno::Reference< css::util::XFlushListener >& l ) override;
119 // XServiceInfo
120 virtual OUString SAL_CALL getImplementationName( ) override;
121 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
122 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
124 bool HasEntry( const OUString &rLeftText, const OUString &rRightText );
125 void AddEntry( const OUString &rLeftText, const OUString &rRightText );
126 void RemoveEntry( const OUString &rLeftText, const OUString &rRightText );
129 #endif
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */